┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEmmanuel Pescosta <[email protected]>2014-08-13 22:06:28 +0200
committerEmmanuel Pescosta <[email protected]>2014-08-13 22:06:28 +0200
commit39d8fb12c1552ec708b5fc1846d7aa9828329417 (patch)
tree2dfa561935af1d7a133c94fb89b6cdd1b50320f0 /src
parent62418c58a58fac668e713655552b1c614b226298 (diff)
React on the redirection signal from DolphinView to properly update the tab and window titles.
REVIEW: 119697 BUG: 305721
Diffstat (limited to 'src')
-rw-r--r--src/dolphinmainwindow.cpp37
-rw-r--r--src/dolphinmainwindow.h12
-rw-r--r--src/dolphintabpage.cpp13
-rw-r--r--src/dolphintabpage.h7
-rw-r--r--src/dolphintabwidget.cpp9
-rw-r--r--src/dolphintabwidget.h6
6 files changed, 58 insertions, 26 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index 588bfda64..95b08af96 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -136,6 +136,8 @@ DolphinMainWindow::DolphinMainWindow() :
this, SLOT(activeViewChanged(DolphinViewContainer*)));
connect(m_tabWidget, SIGNAL(tabCountChanged(int)),
this, SLOT(tabCountChanged(int)));
+ connect(m_tabWidget, SIGNAL(currentUrlChanged(KUrl)),
+ this, SLOT(setUrlAsCaption(KUrl)));
setCentralWidget(m_tabWidget);
setupActions();
@@ -236,7 +238,6 @@ void DolphinMainWindow::changeUrl(const KUrl& url)
updatePasteAction();
updateViewActions();
updateGoActions();
- setUrlAsCaption(url);
emit urlChanged(url);
}
@@ -945,8 +946,6 @@ void DolphinMainWindow::activeViewChanged(DolphinViewContainer* viewContainer)
updateGoActions();
const KUrl url = viewContainer->url();
- setUrlAsCaption(url);
-
emit urlChanged(url);
}
@@ -958,6 +957,22 @@ void DolphinMainWindow::tabCountChanged(int count)
actionCollection()->action("activate_prev_tab")->setEnabled(enableTabActions);
}
+void DolphinMainWindow::setUrlAsCaption(const KUrl& url)
+{
+ QString caption;
+ if (!url.isLocalFile()) {
+ caption.append(url.protocol() + " - ");
+ if (url.hasHost()) {
+ caption.append(url.host() + " - ");
+ }
+ }
+
+ const QString fileName = url.fileName().isEmpty() ? "/" : url.fileName();
+ caption.append(fileName);
+
+ setCaption(caption);
+}
+
void DolphinMainWindow::setupActions()
{
// setup 'File' menu
@@ -1471,22 +1486,6 @@ bool DolphinMainWindow::isKompareInstalled() const
return installed;
}
-void DolphinMainWindow::setUrlAsCaption(const KUrl& url)
-{
- QString caption;
- if (!url.isLocalFile()) {
- caption.append(url.protocol() + " - ");
- if (url.hasHost()) {
- caption.append(url.host() + " - ");
- }
- }
-
- const QString fileName = url.fileName().isEmpty() ? "/" : url.fileName();
- caption.append(fileName);
-
- setCaption(caption);
-}
-
void DolphinMainWindow::createPanelAction(const KIcon& icon,
const QKeySequence& shortcut,
QAction* dockAction,
diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h
index 7bce7f13e..9d4c003af 100644
--- a/src/dolphinmainwindow.h
+++ b/src/dolphinmainwindow.h
@@ -429,6 +429,12 @@ private slots:
*/
void tabCountChanged(int count);
+ /**
+ * Sets the window caption to url.fileName() if this is non-empty,
+ * "/" if the URL is "file:///", and url.protocol() otherwise.
+ */
+ void setUrlAsCaption(const KUrl& url);
+
private:
void setupActions();
void setupDockWidgets();
@@ -465,12 +471,6 @@ private:
bool isKompareInstalled() const;
/**
- * Sets the window caption to url.fileName() if this is non-empty,
- * "/" if the URL is "file:///", and url.protocol() otherwise.
- */
- void setUrlAsCaption(const KUrl& url);
-
- /**
* Creates an action for showing/hiding a panel, that is accessible
* in "Configure toolbars..." and "Configure shortcuts...". This is necessary
* as the action for toggling the dock visibility is done by Qt which
diff --git a/src/dolphintabpage.cpp b/src/dolphintabpage.cpp
index 23e33c958..3d1ba5a3e 100644
--- a/src/dolphintabpage.cpp
+++ b/src/dolphintabpage.cpp
@@ -41,6 +41,8 @@ DolphinTabPage::DolphinTabPage(const KUrl& primaryUrl, const KUrl& secondaryUrl,
m_primaryViewContainer = createViewContainer(primaryUrl);
connect(m_primaryViewContainer->view(), SIGNAL(urlChanged(KUrl)),
this, SIGNAL(activeViewUrlChanged(KUrl)));
+ connect(m_primaryViewContainer->view(), SIGNAL(redirection(KUrl,KUrl)),
+ this, SLOT(slotViewUrlRedirection(KUrl,KUrl)));
m_splitter->addWidget(m_primaryViewContainer);
m_primaryViewContainer->show();
@@ -245,14 +247,25 @@ void DolphinTabPage::slotViewActivated()
if (newActiveView != oldActiveView) {
disconnect(oldActiveView, SIGNAL(urlChanged(KUrl)),
this, SIGNAL(activeViewUrlChanged(KUrl)));
+ disconnect(oldActiveView, SIGNAL(redirection(KUrl,KUrl)),
+ this, SLOT(slotViewUrlRedirection(KUrl,KUrl)));
connect(newActiveView, SIGNAL(urlChanged(KUrl)),
this, SIGNAL(activeViewUrlChanged(KUrl)));
+ connect(newActiveView, SIGNAL(redirection(KUrl,KUrl)),
+ this, SLOT(slotViewUrlRedirection(KUrl,KUrl)));
}
emit activeViewUrlChanged(activeViewContainer()->url());
emit activeViewChanged(activeViewContainer());
}
+void DolphinTabPage::slotViewUrlRedirection(const KUrl& oldUrl, const KUrl& newUrl)
+{
+ Q_UNUSED(oldUrl);
+
+ emit activeViewUrlChanged(newUrl);
+}
+
DolphinViewContainer* DolphinTabPage::createViewContainer(const KUrl& url) const
{
DolphinViewContainer* container = new DolphinViewContainer(url, m_splitter);
diff --git a/src/dolphintabpage.h b/src/dolphintabpage.h
index 278524792..de5a58915 100644
--- a/src/dolphintabpage.h
+++ b/src/dolphintabpage.h
@@ -133,6 +133,13 @@ private slots:
*/
void slotViewActivated();
+ /**
+ * Handles the view url redirection event.
+ *
+ * It emits the activeViewUrlChanged signal with the url \a newUrl.
+ */
+ void slotViewUrlRedirection(const KUrl& oldUrl, const KUrl& newUrl);
+
private:
/**
* Creates a new view container and does the default initialization.
diff --git a/src/dolphintabwidget.cpp b/src/dolphintabwidget.cpp
index ea71b4856..76d4b8d48 100644
--- a/src/dolphintabwidget.cpp
+++ b/src/dolphintabwidget.cpp
@@ -295,12 +295,19 @@ void DolphinTabWidget::tabUrlChanged(const KUrl& url)
if (index >= 0) {
tabBar()->setTabText(index, tabName(url));
tabBar()->setTabIcon(index, KIcon(KMimeType::iconNameForUrl(url)));
+
+ // Emit the currentUrlChanged signal if the url of the current tab has been changed.
+ if (index == currentIndex()) {
+ emit currentUrlChanged(url);
+ }
}
}
void DolphinTabWidget::currentTabChanged(int index)
{
- emit activeViewChanged(tabPageAt(index)->activeViewContainer());
+ DolphinViewContainer* viewContainer = tabPageAt(index)->activeViewContainer();
+ emit activeViewChanged(viewContainer);
+ emit currentUrlChanged(viewContainer->url());
}
void DolphinTabWidget::tabInserted(int index)
diff --git a/src/dolphintabwidget.h b/src/dolphintabwidget.h
index aaadbc997..98bcd985a 100644
--- a/src/dolphintabwidget.h
+++ b/src/dolphintabwidget.h
@@ -72,6 +72,12 @@ signals:
*/
void rememberClosedTab(const KUrl& url, const QByteArray& state);
+ /**
+ * Is emitted when the url of the current tab has been changed. This signal
+ * is also emitted when the active view has been changed.
+ */
+ void currentUrlChanged(const KUrl& url);
+
public slots:
/**
* Opens a new view with the current URL that is part of a tab and activates