diff --git a/mythplugins/mythbrowser/mythbrowser/mythbrowser.cpp b/mythplugins/mythbrowser/mythbrowser/mythbrowser.cpp index 68b1765c886..ef674bfb420 100644 --- a/mythplugins/mythbrowser/mythbrowser/mythbrowser.cpp +++ b/mythplugins/mythbrowser/mythbrowser/mythbrowser.cpp @@ -44,23 +44,25 @@ MythBrowser::~MythBrowser() bool MythBrowser::Create(void) { - bool foundtheme = false; - // Load the theme for this screen - foundtheme = LoadWindowFromXML("browser-ui.xml", "browser", this); - - if (!foundtheme) + if (!LoadWindowFromXML("browser-ui.xml", "browser", this)) return false; - MythUIWebBrowser *browser = dynamic_cast (GetChild("webbrowser")); - m_progressBar = dynamic_cast(GetChild("progressbar")); - m_statusText = dynamic_cast(GetChild("status")); - m_titleText = dynamic_cast(GetChild("title")); - m_pageList = dynamic_cast(GetChild("pagelist")); + bool err = false; + MythUIWebBrowser *browser = NULL; - if (!browser || !m_pageList) + UIUtilE::Assign(this, browser, "webbrowser", &err); + UIUtilE::Assign(this, m_pageList, "pagelist", &err); + UIUtilW::Assign(this, m_progressBar, "progressbar"); + UIUtilW::Assign(this, m_statusText, "status"); + UIUtilW::Assign(this, m_titleText, "title"); + UIUtilW::Assign(this, m_backButton, "back"); + UIUtilW::Assign(this, m_forwardButton, "forward"); + UIUtilW::Assign(this, m_exitButton, "exit"); + + if (err) { - LOG(VB_GENERAL, LOG_ERR, "Theme is missing critical theme elements."); + LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'browser'"); return false; } @@ -91,10 +93,31 @@ bool MythBrowser::Create(void) this, SLOT(slotLoadProgress(int))); connect(page, SIGNAL(statusBarMessage(const QString&)), this, SLOT(slotStatusBarMessage(const QString&))); + connect(page, SIGNAL(loadFinished(bool)), + this, SLOT(slotLoadFinished(bool))); if (m_progressBar) m_progressBar->SetTotal(100); + if (m_exitButton) + { + m_exitButton->SetEnabled(false); + m_exitButton->SetEnabled(true); + connect(m_exitButton, SIGNAL(Clicked()), this, SLOT(Close())); + } + + if (m_backButton) + { + m_backButton->SetEnabled(false); + connect(m_backButton, SIGNAL(Clicked()), this, SLOT(slotBack())); + } + + if (m_forwardButton) + { + m_forwardButton->SetEnabled(false); + connect(m_forwardButton, SIGNAL(Clicked()), this, SLOT(slotForward())); + } + BuildFocusList(); SetFocusWidget(browser); @@ -158,6 +181,8 @@ void MythBrowser::slotAddTab(const QString &url, bool doSwitch) this, SLOT(slotLoadProgress(int))); connect(page, SIGNAL(statusBarMessage(const QString&)), this, SLOT(slotStatusBarMessage(const QString&))); + connect(page, SIGNAL(loadFinished(bool)), + this, SLOT(slotLoadFinished(bool))); if (doSwitch) m_pageList->SetItemCurrent(m_browserList.size() -1); @@ -262,6 +287,12 @@ void MythBrowser::slotLoadFinished(bool OK) if (m_progressBar) m_progressBar->SetUsed(0); + + if (m_backButton) + m_backButton->SetEnabled(activeBrowser()->CanGoBack()); + + if (m_forwardButton) + m_forwardButton->SetEnabled(activeBrowser()->CanGoForward()); } void MythBrowser::slotLoadProgress(int progress) diff --git a/mythplugins/mythbrowser/mythbrowser/mythbrowser.h b/mythplugins/mythbrowser/mythbrowser/mythbrowser.h index 330d69f5348..0406e2077bf 100644 --- a/mythplugins/mythbrowser/mythbrowser/mythbrowser.h +++ b/mythplugins/mythbrowser/mythbrowser/mythbrowser.h @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -72,6 +73,9 @@ class MythBrowser : public MythScreenType MythUIProgressBar *m_progressBar; MythUIText *m_titleText; MythUIText *m_statusText; + MythUIButton *m_backButton; + MythUIButton *m_forwardButton; + MythUIButton *m_exitButton; int m_currentBrowser; QUrl m_url; diff --git a/mythplugins/mythbrowser/mythbrowser/webpage.cpp b/mythplugins/mythbrowser/mythbrowser/webpage.cpp index 2b6a8dacf26..9bb681d0f61 100644 --- a/mythplugins/mythbrowser/mythbrowser/webpage.cpp +++ b/mythplugins/mythbrowser/mythbrowser/webpage.cpp @@ -133,15 +133,13 @@ void WebPage::slotLoadStarted(void) void WebPage::slotLoadFinished(bool OK) { - (void) OK; - m_listItem->DisplayState("off", "loadingstate"); - slotLoadProgress(0); - slotIconChanged(); m_listItem->SetText(m_browser->GetTitle()); + + emit loadFinished(OK); } void WebPage::slotLoadProgress(int progress) diff --git a/mythplugins/mythbrowser/mythbrowser/webpage.h b/mythplugins/mythbrowser/mythbrowser/webpage.h index e07ee2edd5d..74e63bed437 100644 --- a/mythplugins/mythbrowser/mythbrowser/webpage.h +++ b/mythplugins/mythbrowser/mythbrowser/webpage.h @@ -31,6 +31,7 @@ class WebPage : public QObject signals: void loadProgress(int progress); void statusBarMessage(const QString &text); + void loadFinished(bool OK); protected slots: void slotLoadStarted(void);