Ticket #8398: mythbrowser-custom-homepage.patch

File mythbrowser-custom-homepage.patch, 5.8 KB (added by Robert S, 9 years ago)

mythgallery homepage patch

  • mythbrowser/mythbrowser/main.cpp

    old new  
    4242    return 0;
    4343}
    4444
     45void runBookmarkManager()
     46{
     47    mythplugin_run();
     48}
     49
     50void runHomepage()
     51{
     52    QString homepage = gContext->GetSetting("WebBrowserHomepage");
     53    handleMedia( homepage, "", "", "", "", 0, 0, 0, "");
     54}
     55
    4556void setupKeys(void)
    4657{
    4758    REG_KEY("Browser", "NEXTTAB", QT_TRANSLATE_NOOP("MythControls",
     
    4960    REG_KEY("Browser", "PREVTAB", QT_TRANSLATE_NOOP("MythControls",
    5061        "Move to previous browser tab"), "");
    5162
     63    REG_JUMP("Bookmarks", QT_TRANSLATE_NOOP("MythControls",
     64        "Show the bookmark manager"), "", runBookmarkManager);
     65    REG_JUMP("Homepage", QT_TRANSLATE_NOOP("MythControls",
     66        "Show the webbrowser homepage"), "", runHomepage);
     67   
    5268    REG_MEDIAPLAYER("WebBrowser", QT_TRANSLATE_NOOP("MythControls",
    5369        "Internal Web Browser"), handleMedia);
    5470}
     
    6985    if (gContext->GetSetting("WebBrowserZoomLevel").isEmpty())
    7086        gContext->SaveSetting("WebBrowserZoomLevel", "1.4");
    7187
     88    if (gContext->GetSetting("WebBrowserHomepage").isEmpty())
     89        gContext->SaveSetting("WebBrowserHomepage", "http://www.mythtv.org");
     90   
    7291    gContext->ActivateSettingsCache(true);
    7392
    7493    setupKeys();
  • mythbrowser/mythbrowser/browserdbutil.cpp

    old new  
    99#include "browserdbutil.h"
    1010#include "bookmarkmanager.h"
    1111
    12 const QString currentDatabaseVersion = "1002";
     12const QString currentDatabaseVersion = "1003";
    1313
    1414static bool UpdateDBVersionNumber(const QString &newnumber)
    1515{
     
    110110            return false;
    111111    }
    112112
     113    if (dbver == "1002")
     114    {
     115        const QString updates[] =
     116        {
     117            "INSERT INTO settings VALUES ('WebBrowserHomepage', 'www.mythtv.org', NULL);",
     118            ""
     119        };
     120        if (!performActualUpdate(updates, "1003", dbver))
     121            return false;
     122    }
     123
    113124    return true;
    114125}
    115126
  • mythbrowser/mythbrowser/bookmarkmanager.h

     
    5050
    5151  private:
    5252    MythUITextEdit   *m_commandEdit;
     53    MythUITextEdit   *m_homepageEdit;
    5354    MythUITextEdit   *m_zoomEdit;
    5455
    5556    MythUIText       *m_descriptionText;
  • mythbrowser/theme/default-wide/browser-ui.xml

     
    278278            <position>445,140</position>
    279279        </textedit>
    280280
     281        <textarea name="homepagelabel" from="basetextarea">
     282            <area>130,200,300,30</area>
     283            <align>right,vcenter</align>
     284            <value>Browser Command:</value>
     285        </textarea>
     286
     287        <textedit name="homepage" from="basetextedit">
     288            <position>445,190</position>
     289        </textedit>
     290
     291        <textarea name="zoomlabel" from="basetextarea">
     292            <area>130,250,300,30</area>
    281293        <textarea name="zoomlabel" from="basetextarea">
    282294            <area>130,250,300,30</area>
    283295            <align>right,vcenter</align>
  • mythbrowser/mythbrowser/bookmarkmanager.cpp

     
    2121BrowserConfig::BrowserConfig(MythScreenStack *parent, const char *name)
    2222    : MythScreenType(parent, name),
    2323      m_commandEdit(NULL),     m_zoomEdit(NULL),
     24      m_homepageEdit(NULL),
    2425      m_descriptionText(NULL), m_titleText(NULL),
    2526      m_okButton(NULL),        m_cancelButton(NULL)
    2627{
     
    4243          m_titleText->SetText(tr("MythBrowser Settings"));
    4344
    4445    m_commandEdit = dynamic_cast<MythUITextEdit *> (GetChild("command"));
     46    m_homepageEdit = dynamic_cast<MythUITextEdit *> (GetChild("homepage"));
    4547    m_zoomEdit = dynamic_cast<MythUITextEdit *> (GetChild("zoom"));
    4648
    4749    m_descriptionText = dynamic_cast<MythUIText *> (GetChild("description"));
     
    5860    m_commandEdit->SetText(gContext->GetSetting("WebBrowserCommand",
    5961                           "Internal"));
    6062
     63    m_homepageEdit->SetText(gContext->GetSetting("WebBrowserHomepage",
     64                           "http://www.mythtv.org"));
     65
    6166    m_zoomEdit->SetText(gContext->GetSetting("WebBrowserZoomLevel", "1.4"));
    6267
    6368    connect(m_okButton, SIGNAL(Clicked()), this, SLOT(slotSave()));
    6469    connect(m_cancelButton, SIGNAL(Clicked()), this, SLOT(Close()));
    6570
    6671    connect(m_commandEdit,  SIGNAL(TakingFocus()), SLOT(slotFocusChanged()));
     72    connect(m_homepageEdit,  SIGNAL(TakingFocus()), SLOT(slotFocusChanged()));
    6773    connect(m_zoomEdit   ,  SIGNAL(TakingFocus()), SLOT(slotFocusChanged()));
    6874    connect(m_okButton,     SIGNAL(TakingFocus()), SLOT(slotFocusChanged()));
    6975    connect(m_cancelButton, SIGNAL(TakingFocus()), SLOT(slotFocusChanged()));
     
    8995    gContext->SaveSetting("WebBrowserZoomLevel", QString("%1").arg(zoom));
    9096    gContext->SaveSetting("WebBrowserCommand", m_commandEdit->GetText());
    9197
     98    gContext->SaveSetting("WebBrowserHomepage", m_homepageEdit->GetText());
     99
    92100    Close();
    93101}
    94102
     
    120128                 "for the Internal browser are from 0.3 to 5.0 with 1.0 being "
    121129                 "normal size less than 1 is smaller and greater than 1 is "
    122130                 "larger than normal size.");
     131    else if (GetFocusWidget() == m_homepageEdit)
     132        msg = tr("This is the default homepage that will be used if the webbrowser "
     133                 "is called without an url or if the bookmark editor was not selected.");
    123134    else if (GetFocusWidget() == m_cancelButton)
    124135        msg = tr("Exit without saving settings");
    125136    else if (GetFocusWidget() == m_okButton)