Commit 16572164 authored by Eugene Popov's avatar Eugene Popov
Browse files

Fix updating window and tab titles

This MR fixes an issue where the window and tab titles don't properly handle creating/deleting/renaming items in the places bar, as well as switching to the Search mode.
parent 4b4f9880
......@@ -2134,6 +2134,8 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
this, &DolphinMainWindow::slotWriteStateChanged);
connect(container, &DolphinViewContainer::searchModeEnabledChanged,
this, &DolphinMainWindow::updateSearchAction);
connect(container, &DolphinViewContainer::captionChanged,
this, &DolphinMainWindow::updateWindowTitle);
const QAction* toggleSearchAction = actionCollection()->action(QStringLiteral("toggle_search"));
connect(toggleSearchAction, &QAction::triggered, container, &DolphinViewContainer::setSearchModeEnabled);
......
......@@ -162,10 +162,17 @@ void DolphinTabWidget::openNewTab(const QUrl& primaryUrl, const QUrl& secondaryU
this, &DolphinTabWidget::activeViewChanged);
connect(tabPage, &DolphinTabPage::activeViewUrlChanged,
this, &DolphinTabWidget::tabUrlChanged);
connect(tabPage->activeViewContainer(), &DolphinViewContainer::captionChanged, this, [this, tabPage]() {
const int tabIndex = indexOf(tabPage);
Q_ASSERT(tabIndex >= 0);
tabBar()->setTabText(tabIndex, tabName(tabPage));
});
int newTabIndex = -1;
if (!GeneralSettings::openNewTabAfterLastTab()) {
newTabIndex = currentIndex() + 1;
}
insertTab(newTabIndex, tabPage, QIcon() /* loaded in tabInserted */, tabName(tabPage));
if (focusWidget) {
......
......@@ -196,6 +196,17 @@ DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
}
});
KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel();
connect(placesModel, &KFilePlacesModel::dataChanged,
this, &DolphinViewContainer::slotPlacesModelChanged);
connect(placesModel, &KFilePlacesModel::rowsInserted,
this, &DolphinViewContainer::slotPlacesModelChanged);
connect(placesModel, &KFilePlacesModel::rowsRemoved,
this, &DolphinViewContainer::slotPlacesModelChanged);
connect(this, &DolphinViewContainer::searchModeEnabledChanged,
this, &DolphinViewContainer::captionChanged);
// Initialize kactivities resource instance
#ifdef HAVE_KACTIVITIES
......@@ -791,6 +802,13 @@ void DolphinViewContainer::showErrorMessage(const QString& msg)
showMessage(msg, Error);
}
void DolphinViewContainer::slotPlacesModelChanged()
{
if (!GeneralSettings::showFullPathInTitlebar() && !isSearchModeEnabled()) {
Q_EMIT captionChanged();
}
}
bool DolphinViewContainer::isSearchUrl(const QUrl& url) const
{
return url.scheme().contains(QLatin1String("search"));
......
......@@ -223,6 +223,12 @@ Q_SIGNALS:
*/
void writeStateChanged(bool isFolderWritable);
/**
* Is emitted when the Caption has been changed.
* @see DolphinViewContainer::caption()
*/
void captionChanged();
private Q_SLOTS:
/**
* Updates the number of items (= number of files + number of
......@@ -349,6 +355,12 @@ private Q_SLOTS:
*/
void showErrorMessage(const QString& msg);
/**
* Is invoked when a KFilePlacesModel has been changed
* @see DolphinPlacesModelSingleton::instance().placesModel()
*/
void slotPlacesModelChanged();
private:
/**
* @return True if the URL protocol is a search URL (e. g. baloosearch:// or filenamesearch://).
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment