mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 09:50:12 +00:00
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.
This commit is contained in:
parent
4b4f988078
commit
1657216474
|
@ -2134,6 +2134,8 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
|
||||||
this, &DolphinMainWindow::slotWriteStateChanged);
|
this, &DolphinMainWindow::slotWriteStateChanged);
|
||||||
connect(container, &DolphinViewContainer::searchModeEnabledChanged,
|
connect(container, &DolphinViewContainer::searchModeEnabledChanged,
|
||||||
this, &DolphinMainWindow::updateSearchAction);
|
this, &DolphinMainWindow::updateSearchAction);
|
||||||
|
connect(container, &DolphinViewContainer::captionChanged,
|
||||||
|
this, &DolphinMainWindow::updateWindowTitle);
|
||||||
|
|
||||||
const QAction* toggleSearchAction = actionCollection()->action(QStringLiteral("toggle_search"));
|
const QAction* toggleSearchAction = actionCollection()->action(QStringLiteral("toggle_search"));
|
||||||
connect(toggleSearchAction, &QAction::triggered, container, &DolphinViewContainer::setSearchModeEnabled);
|
connect(toggleSearchAction, &QAction::triggered, container, &DolphinViewContainer::setSearchModeEnabled);
|
||||||
|
|
|
@ -162,10 +162,17 @@ void DolphinTabWidget::openNewTab(const QUrl& primaryUrl, const QUrl& secondaryU
|
||||||
this, &DolphinTabWidget::activeViewChanged);
|
this, &DolphinTabWidget::activeViewChanged);
|
||||||
connect(tabPage, &DolphinTabPage::activeViewUrlChanged,
|
connect(tabPage, &DolphinTabPage::activeViewUrlChanged,
|
||||||
this, &DolphinTabWidget::tabUrlChanged);
|
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;
|
int newTabIndex = -1;
|
||||||
if (!GeneralSettings::openNewTabAfterLastTab()) {
|
if (!GeneralSettings::openNewTabAfterLastTab()) {
|
||||||
newTabIndex = currentIndex() + 1;
|
newTabIndex = currentIndex() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
insertTab(newTabIndex, tabPage, QIcon() /* loaded in tabInserted */, tabName(tabPage));
|
insertTab(newTabIndex, tabPage, QIcon() /* loaded in tabInserted */, tabName(tabPage));
|
||||||
|
|
||||||
if (focusWidget) {
|
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
|
// Initialize kactivities resource instance
|
||||||
|
|
||||||
#ifdef HAVE_KACTIVITIES
|
#ifdef HAVE_KACTIVITIES
|
||||||
|
@ -791,6 +802,13 @@ void DolphinViewContainer::showErrorMessage(const QString& msg)
|
||||||
showMessage(msg, Error);
|
showMessage(msg, Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DolphinViewContainer::slotPlacesModelChanged()
|
||||||
|
{
|
||||||
|
if (!GeneralSettings::showFullPathInTitlebar() && !isSearchModeEnabled()) {
|
||||||
|
Q_EMIT captionChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool DolphinViewContainer::isSearchUrl(const QUrl& url) const
|
bool DolphinViewContainer::isSearchUrl(const QUrl& url) const
|
||||||
{
|
{
|
||||||
return url.scheme().contains(QLatin1String("search"));
|
return url.scheme().contains(QLatin1String("search"));
|
||||||
|
|
|
@ -223,6 +223,12 @@ Q_SIGNALS:
|
||||||
*/
|
*/
|
||||||
void writeStateChanged(bool isFolderWritable);
|
void writeStateChanged(bool isFolderWritable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is emitted when the Caption has been changed.
|
||||||
|
* @see DolphinViewContainer::caption()
|
||||||
|
*/
|
||||||
|
void captionChanged();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
* Updates the number of items (= number of files + number of
|
* Updates the number of items (= number of files + number of
|
||||||
|
@ -349,6 +355,12 @@ private Q_SLOTS:
|
||||||
*/
|
*/
|
||||||
void showErrorMessage(const QString& msg);
|
void showErrorMessage(const QString& msg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is invoked when a KFilePlacesModel has been changed
|
||||||
|
* @see DolphinPlacesModelSingleton::instance().placesModel()
|
||||||
|
*/
|
||||||
|
void slotPlacesModelChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* @return True if the URL protocol is a search URL (e. g. baloosearch:// or filenamesearch://).
|
* @return True if the URL protocol is a search URL (e. g. baloosearch:// or filenamesearch://).
|
||||||
|
|
Loading…
Reference in a new issue