diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2011-02-16 01:47:08 +0100 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2011-02-17 17:16:57 +0100 |
commit | 88a5c9816cd6a07240a4a94820e0a809aecd074a (patch) | |
tree | 73bb9984dc8543115ff3a998ea2fe7bcfc477b50 /src | |
parent | Add opensearch description file for bing and yahoo suggestions (diff) | |
download | rekonq-88a5c9816cd6a07240a4a94820e0a809aecd074a.tar.xz |
Cleans up "tab switch" management and expecially the use of signals
on that.
This, expecially to avoid double calls on functions to manage tab switching and info updating.
Reviewed by NOBODY (oops...)
Diffstat (limited to 'src')
-rw-r--r-- | src/mainview.cpp | 18 | ||||
-rw-r--r-- | src/mainview.h | 6 | ||||
-rw-r--r-- | src/mainwindow.cpp | 5 |
3 files changed, 21 insertions, 8 deletions
diff --git a/src/mainview.cpp b/src/mainview.cpp index fe6413a1..dfa202dc 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -112,7 +112,6 @@ void MainView::postLaunch() // Session Manager connect(this, SIGNAL(tabsChanged()), Application::sessionManager(), SLOT(saveSession())); - connect(this, SIGNAL(currentChanged(int)), Application::sessionManager(), SLOT(saveSession())); m_addTabButton->setDefaultAction(m_parentWindow->actionByName("new_tab")); @@ -267,6 +266,8 @@ void MainView::currentChanged(int index) tab->view()->setFocus(); tabBar()->resetTabHighlighted(index); + + emit tabsChanged(); } @@ -316,9 +317,13 @@ WebTab *MainView::newWebTab(bool focused) { setCurrentWidget(tab); } - - emit tabsChanged(); - + else + { + // if tab is not focused, + // current index doesn't change... + emit tabsChanged(); + } + return tab; } @@ -484,7 +489,9 @@ void MainView::closeTab(int index, bool del) tabToClose->deleteLater(); } - emit tabsChanged(); + // if tab was not focused, current index does not change... + if(index != currentIndex()) + emit tabsChanged(); } @@ -594,6 +601,7 @@ void MainView::webViewUrlChanged(const QUrl &url) } if (ReKonfig::hoveringTabOption() == 2) tabBar()->setTabToolTip(index, webTab(index)->url().toMimeDataString()); + emit tabsChanged(); } diff --git a/src/mainview.h b/src/mainview.h index 6af4012c..749fb7ea 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -97,7 +97,11 @@ public: inline QList<HistoryItem> recentlyClosedTabs() { return m_recentlyClosedTabs; } Q_SIGNALS: - // tab widget signals + // tabs change when: + // - current tab change + // - one tab is closed + // - one tab is added + // - one tab is updated (eg: changes url) void tabsChanged(); // current tab signals diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 35f47701..24dc8658 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -311,7 +311,6 @@ void MainWindow::postLaunch() connect(m_view, SIGNAL(openNextInHistory()), this, SLOT(openNext())); // update toolbar actions signals - connect(m_view, SIGNAL(tabsChanged()), this, SLOT(updateActions())); connect(m_view, SIGNAL(currentChanged(int)), this, SLOT(updateActions())); //Change window icon according to tab icon @@ -408,7 +407,6 @@ void MainWindow::setupActions() actionCollection()->addAction(QL1S("stop_reload") , m_stopReloadAction); m_stopReloadAction->setShortcutConfigurable(false); connect(m_view, SIGNAL(browserTabLoading(bool)), this, SLOT(browserLoading(bool))); - browserLoading(false); //first init for blank start page a = new KAction(i18n("Open Location"), this); KShortcut openLocationShortcut(Qt::CTRL + Qt::Key_L); @@ -981,6 +979,7 @@ WebTab *MainWindow::currentTab() const void MainWindow::browserLoading(bool v) { + kDebug() << "-------------------------------------------------------------------"; QAction *stop = actionCollection()->action( QL1S("stop") ); QAction *reload = actionCollection()->action( QL1S("view_redisplay") ); if (v) @@ -1000,6 +999,8 @@ void MainWindow::browserLoading(bool v) m_stopReloadAction->setText(i18n("Reload")); connect(m_stopReloadAction, SIGNAL(triggered(bool)), reload, SIGNAL(triggered(bool))); stop->setEnabled(false); + + updateActions(); } } |