From 3ff131b27dff7b0742094051f4262d2dd7d3322d Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 18 Feb 2019 12:47:20 -0800 Subject: [PATCH] Desktop: show the filter information in the window title Instead of using the filter widget itself to show the information how many dives are displayed, put it in the window title where it's visible even if the filter widget isn't shown. If the filter is not active, simply show the total number of dives. Signed-off-by: Dirk Hohndel --- desktop-widgets/filterwidget2.cpp | 12 ++++++++++-- desktop-widgets/filterwidget2.h | 2 ++ desktop-widgets/mainwindow.cpp | 3 ++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/desktop-widgets/filterwidget2.cpp b/desktop-widgets/filterwidget2.cpp index 592f016d1..5f78d6396 100644 --- a/desktop-widgets/filterwidget2.cpp +++ b/desktop-widgets/filterwidget2.cpp @@ -229,8 +229,16 @@ void FilterWidget2::filterDataChanged(const FilterData &data) void FilterWidget2::countsChanged() { - ui.filterText->setText(tr("%L1/%L2 shown").arg(MultiFilterSortModel::instance()->divesDisplayed) - .arg(dive_table.nr)); + updateWindowTitle(); +} + +QString FilterWidget2::shownText() +{ + if (isActive()) + return tr("%L1/%L2 shown").arg(MultiFilterSortModel::instance()->divesDisplayed) + .arg(dive_table.nr); + else + return tr("%L1 dives").arg(dive_table.nr); } bool FilterWidget2::isActive() const diff --git a/desktop-widgets/filterwidget2.h b/desktop-widgets/filterwidget2.h index d974fb78f..297d65e4e 100644 --- a/desktop-widgets/filterwidget2.h +++ b/desktop-widgets/filterwidget2.h @@ -20,6 +20,8 @@ class FilterWidget2 : public QWidget { public: explicit FilterWidget2(QWidget *parent = 0); void updateFilter(); + QString shownText(); + protected: void hideEvent(QHideEvent *event) override; void showEvent(QShowEvent *event) override; diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 4d3df6ccb..5095ab130 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -1636,7 +1636,8 @@ void MainWindow::setTitle() } QString unsaved = (unsaved_changes() ? " *" : ""); - setWindowTitle("Subsurface: " + displayedFilename(existing_filename) + unsaved); + QString shown = QString(" (%1)").arg(filterWidget2.shownText()); + setWindowTitle("Subsurface: " + displayedFilename(existing_filename) + unsaved + shown); } void MainWindow::importFiles(const QStringList fileNames)