Permalink
Browse files

MythBrowser: Focus improvements/fixes and show a default url when cre…

…ating a new tab.

Simplify making the active browser active now that MythUIWebBrowser handles most of this
automatically.

Also when creating a new tab show a default url (currently hard coded to
'www.google.com') instead of just showing a blank page. At some point the
bookmark editor should allow you to set a default home page of your choice.
  • Loading branch information...
1 parent c17798a commit 6f4c6983f306d282f35c7572b68d8174592c6a87 Paul Harrison committed May 5, 2011
View
44 mythplugins/mythbrowser/mythbrowser/mythbrowser.cpp
@@ -98,8 +98,6 @@ MythUIWebBrowser* MythBrowser::activeBrowser(void)
void MythBrowser::slotEnterURL(void)
{
- activeBrowser()->SetActive(false);
-
MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
QString message = tr("Enter URL");
@@ -112,26 +110,26 @@ void MythBrowser::slotEnterURL(void)
connect(dialog, SIGNAL(haveResult(QString)),
SLOT(slotOpenURL(QString)), Qt::QueuedConnection);
-
- connect(dialog, SIGNAL(Exiting()), SLOT(slotExitingMenu()));
}
void MythBrowser::slotAddTab(const QString &url, bool doSwitch)
{
QString name = QString("browser%1").arg(m_browserList.size() + 1);
- WebPage *page = new WebPage(
- this, m_browserList[0]->getBrowser()->GetArea(),
- name.toAscii().constData());
+ WebPage *page = new WebPage(this, m_browserList[0]->getBrowser()->GetArea(),
+ name.toAscii().constData());
page->getBrowser()->SetZoom(m_zoom);
- if (url != "")
- {
- QString newUrl = url;
- if (!url.startsWith("http://") && !url.startsWith("https://") &&
- !url.startsWith("file:/") )
- newUrl.prepend("http://");
- page->getBrowser()->LoadPage(QUrl::fromEncoded(newUrl.toLocal8Bit()));
- }
+ m_browserList.append(page);
+
+ QString newUrl = url;
+
+ if (newUrl.isEmpty())
+ newUrl = "http://www.google.com"; // TODO: add a user definable home page
+
+ if (!newUrl.startsWith("http://") && !newUrl.startsWith("https://") &&
+ !newUrl.startsWith("file:/") )
+ newUrl.prepend("http://");
+ page->getBrowser()->LoadPage(QUrl::fromEncoded(newUrl.toLocal8Bit()));
page->SetActive(false);
@@ -140,8 +138,6 @@ void MythBrowser::slotAddTab(const QString &url, bool doSwitch)
connect(page, SIGNAL(statusBarMessage(const QString&)),
this, SLOT(slotStatusBarMessage(const QString&)));
- m_browserList.append(page);
-
if (doSwitch)
m_pageList->SetItemCurrent(m_browserList.size() -1);
}
@@ -176,6 +172,8 @@ void MythBrowser::switchTab(int newTab)
if (m_currentBrowser >= 0 && m_currentBrowser < m_browserList.size())
m_browserList[m_currentBrowser]->SetActive(false);
+ BuildFocusList();
+
m_browserList[newTab]->SetActive(true);
m_currentBrowser = newTab;
@@ -216,8 +214,6 @@ void MythBrowser::slotForward()
void MythBrowser::slotAddBookmark()
{
- activeBrowser()->SetActive(false);
-
m_editBookmark.category = "";
m_editBookmark.name = m_pageList->GetValue();
m_editBookmark.url = activeBrowser()->GetUrl().toString();
@@ -230,8 +226,6 @@ void MythBrowser::slotAddBookmark()
if (editor->Create())
mainStack->AddScreen(editor);
-
- connect(editor, SIGNAL(Exiting()), SLOT(slotExitingMenu()));
}
void MythBrowser::slotLoadStarted(void)
@@ -331,7 +325,6 @@ bool MythBrowser::keyPressEvent(QKeyEvent *event)
if (action == "MENU")
{
- activeBrowser()->SetActive(false);
slotStatusBarMessage("");
QString label = tr("Actions");
@@ -345,8 +338,6 @@ bool MythBrowser::keyPressEvent(QKeyEvent *event)
m_menuPopup->SetReturnEvent(this, "action");
- connect(m_menuPopup, SIGNAL(Exiting()), SLOT(slotExitingMenu()));
-
m_menuPopup->AddButton(tr("Enter URL"), SLOT(slotEnterURL()));
if (activeBrowser()->CanGoBack())
@@ -403,9 +394,4 @@ bool MythBrowser::keyPressEvent(QKeyEvent *event)
return handled;
}
-void MythBrowser::slotExitingMenu(void)
-{
- if (GetFocusWidget() == activeBrowser())
- activeBrowser()->SetActive(true);
-}
View
1 mythplugins/mythbrowser/mythbrowser/mythbrowser.h
@@ -52,7 +52,6 @@ class MythBrowser : public MythScreenType
void slotTabSelected(MythUIButtonListItem *item);
void slotTabLosingFocus(void);
void slotIconChanged(void);
- void slotExitingMenu(void);
private:
MythUIWebBrowser* activeBrowser(void);

0 comments on commit 6f4c698

Please sign in to comment.