From 882cd347c892b39c56715b6a56ae97e95e8eb5f4 Mon Sep 17 00:00:00 2001 From: Martchus Date: Fri, 20 Dec 2024 19:38:11 +0100 Subject: [PATCH] Hide "Downloads" tab by default The "Downloads" tab is most of the time empty despite downloads going on, see https://github.com/Martchus/syncthingtray/issues/293. It actually needs quite some rework to be useful but most users probably don't use it anyway. Not even the official GUI shows the download progress. So for now let's hide it by default. It would make sense to extend the GUI to be able to show out of sync items like the official GUI does. Maybe this could replace the "Downloads" tab in the future. --- plasmoid/lib/appearanceoptionpage.ui | 65 ++++++++++++------- plasmoid/lib/settingsdialog.cpp | 2 + plasmoid/lib/syncthingapplet.cpp | 2 + plasmoid/lib/syncthingapplet.h | 17 +++++ .../contents/ui/FullRepresentation.qml | 26 ++++---- .../contents/ui/FullRepresentation.qml | 26 ++++---- syncthingwidgets/misc/utils.cpp | 4 +- .../settings/appearanceoptionpage.ui | 8 +++ syncthingwidgets/settings/settings.cpp | 2 + syncthingwidgets/settings/settings.h | 1 + syncthingwidgets/settings/settingsdialog.cpp | 2 + tray/gui/traywidget.cpp | 1 + tray/gui/traywidget.ui | 36 +++++----- 13 files changed, 125 insertions(+), 67 deletions(-) diff --git a/plasmoid/lib/appearanceoptionpage.ui b/plasmoid/lib/appearanceoptionpage.ui index 05bcff0c..9344549b 100644 --- a/plasmoid/lib/appearanceoptionpage.ui +++ b/plasmoid/lib/appearanceoptionpage.ui @@ -114,26 +114,6 @@ - - - - States to enable passive mode - - - true - - - - - - - QAbstractItemView::NoSelection - - - QListView::Batched - - - @@ -142,9 +122,30 @@ - + + + 0 + + + + + Downloads + + + + + + + Show tab texts + + + + + + + - Show tab texts + Icons @@ -162,10 +163,23 @@ - - + + - Icons + States to enable passive mode + + + true + + + + + + + QAbstractItemView::NoSelection + + + QListView::Batched @@ -190,6 +204,7 @@ widthSpinBox heightSpinBox + showDownloadsCheckBox showTabTextsCheckBox preferIconsFromThemeCheckBox passiveListView diff --git a/plasmoid/lib/settingsdialog.cpp b/plasmoid/lib/settingsdialog.cpp index c00fe49e..fa3f74e5 100644 --- a/plasmoid/lib/settingsdialog.cpp +++ b/plasmoid/lib/settingsdialog.cpp @@ -92,6 +92,7 @@ bool AppearanceOptionPage::apply() KConfigGroup config = m_applet->config(); config.writeEntry("size", QSize(ui()->widthSpinBox->value(), ui()->heightSpinBox->value())); config.writeEntry("showTabTexts", ui()->showTabTextsCheckBox->isChecked()); + config.writeEntry("showDownloads", ui()->showDownloadsCheckBox->isChecked()); config.writeEntry("preferIconsFromTheme", ui()->preferIconsFromThemeCheckBox->isChecked()); config.writeEntry("passiveStates", m_passiveStatusSelection.toVariantList()); @@ -105,6 +106,7 @@ void AppearanceOptionPage::reset() ui()->widthSpinBox->setValue(size.width()); ui()->heightSpinBox->setValue(size.height()); ui()->showTabTextsCheckBox->setChecked(config.readEntry<>("showTabTexts", false)); + ui()->showDownloadsCheckBox->setChecked(config.readEntry<>("showDownloads", false)); ui()->preferIconsFromThemeCheckBox->setChecked(config.readEntry<>("preferIconsFromTheme", false)); m_passiveStatusSelection.applyVariantList(config.readEntry("passiveStates", QVariantList())); } diff --git a/plasmoid/lib/syncthingapplet.cpp b/plasmoid/lib/syncthingapplet.cpp index 6c96edc6..2deaf013 100644 --- a/plasmoid/lib/syncthingapplet.cpp +++ b/plasmoid/lib/syncthingapplet.cpp @@ -96,6 +96,7 @@ SyncthingApplet::SyncthingApplet(QObject *parent, const QVariantList &data) , m_hasInternalErrors(false) , m_initialized(false) , m_showTabTexts(false) + , m_showDownloads(false) , m_applyingSettingsForWizard(false) { // configure connection @@ -694,6 +695,7 @@ void SyncthingApplet::applySettings(int changeConnectionIndex) // apply appearance settings setSize(config.readEntry("size", QSize(25, 25))); setShowingTabTexts(config.readEntry("showTabTexts", false)); + setShowingDownloads(config.readEntry("showDownloads", false)); IconManager::instance().applySettings(&settings.icons.status, nullptr, settings.icons.usePaletteForStatus, false); // restore selected states diff --git a/plasmoid/lib/syncthingapplet.h b/plasmoid/lib/syncthingapplet.h index 10b6021e..ec71a24f 100644 --- a/plasmoid/lib/syncthingapplet.h +++ b/plasmoid/lib/syncthingapplet.h @@ -82,6 +82,7 @@ class SyncthingApplet : public Plasma::Applet { Q_PROPERTY(bool hasInternalErrors READ hasInternalErrors NOTIFY hasInternalErrorsChanged) Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY sizeChanged) Q_PROPERTY(bool showTabTexts READ isShowingTabTexts WRITE setShowingTabTexts NOTIFY showTabTextsChanged) + Q_PROPERTY(bool showDownloads READ isShowingDownloads WRITE setShowingDownloads NOTIFY showDownloadsChanged) Q_PROPERTY(bool passive READ isPassive NOTIFY passiveChanged) Q_PROPERTY(QList passiveStates READ passiveStates WRITE setPassiveStates) Q_PROPERTY(QString faUrl READ faUrl NOTIFY faUrlChanged) @@ -124,6 +125,8 @@ class SyncthingApplet : public Plasma::Applet { void setSize(const QSize &size); bool isShowingTabTexts() const; void setShowingTabTexts(bool showTabTexts); + bool isShowingDownloads() const; + void setShowingDownloads(bool showDownloads); bool isPassive() const; const QList &passiveStates() const; void setPassiveStates(const QList &passiveStates); @@ -165,6 +168,7 @@ public Q_SLOTS: void hasInternalErrorsChanged(bool hasInternalErrors); void sizeChanged(const QSize &size); void showTabTextsChanged(bool isShowingTabTexts); + void showDownloadsChanged(bool isShowingDownloads); void passiveChanged(bool passive); void faUrlChanged(const QString &faUrl); @@ -224,6 +228,7 @@ private Q_SLOTS: bool m_hasInternalErrors; bool m_initialized; bool m_showTabTexts; + bool m_showDownloads; bool m_applyingSettingsForWizard; QSize m_size; }; @@ -326,6 +331,18 @@ inline void SyncthingApplet::setShowingTabTexts(bool showTabTexts) } } +inline bool SyncthingApplet::isShowingDownloads() const +{ + return m_showDownloads; +} + +inline void SyncthingApplet::setShowingDownloads(bool showDownloads) +{ + if (showDownloads != m_showDownloads) { + emit showDownloadsChanged(m_showDownloads = showDownloads); + } +} + inline bool SyncthingApplet::isPassive() const { return status() == Plasma::Types::PassiveStatus; diff --git a/plasmoid/package5/contents/ui/FullRepresentation.qml b/plasmoid/package5/contents/ui/FullRepresentation.qml index d6e991a9..ed078055 100644 --- a/plasmoid/package5/contents/ui/FullRepresentation.qml +++ b/plasmoid/package5/contents/ui/FullRepresentation.qml @@ -24,7 +24,8 @@ PlasmaExtras.Representation { height: units.iconSizes.medium PlasmaComponents3.TabBar { id: tabBar - readonly property double buttonWidth: parent.width / count + readonly property int buttonCount: plasmoid.nativeInterface.showDownloads ? 4 : 3 + readonly property double buttonWidth: parent.width / buttonCount position: PlasmaComponents3.TabBar.Footer Layout.fillWidth: true Layout.fillHeight: true @@ -40,18 +41,19 @@ PlasmaExtras.Representation { icon.source: plasmoid.nativeInterface.faUrl + "sitemap" width: tabBar.buttonWidth } - TabButton { - id: downloadsTabButton - text: qsTr("Downloads") - icon.source: plasmoid.nativeInterface.faUrl + "download" - width: tabBar.buttonWidth - } TabButton { id: recentChangesTabButton text: qsTr("History") icon.source: plasmoid.nativeInterface.faUrl + "history" width: tabBar.buttonWidth } + TabButton { + id: downloadsTabButton + text: qsTr("Downloads") + icon.source: plasmoid.nativeInterface.faUrl + "download" + visible: plasmoid.nativeInterface.showDownloads + width: visible ? tabBar.buttonWidth : 0 + } } } @@ -60,8 +62,8 @@ PlasmaExtras.Representation { switch (tabBar.currentIndex) { case 0: return directoriesPage case 1: return devicesPage - case 2: return downloadsPage - case 3: return recentChangesPage + case 2: return recentChangesPage + case 3: return downloadsPage default: return directoriesPage } } @@ -290,12 +292,12 @@ PlasmaExtras.Representation { DevicesPage { id: devicesPage } - DownloadsPage { - id: downloadsPage - } RecentChangesPage { id: recentChangesPage } + DownloadsPage { + id: downloadsPage + } } } } diff --git a/plasmoid/package6/contents/ui/FullRepresentation.qml b/plasmoid/package6/contents/ui/FullRepresentation.qml index d4dbaa44..10ef310d 100644 --- a/plasmoid/package6/contents/ui/FullRepresentation.qml +++ b/plasmoid/package6/contents/ui/FullRepresentation.qml @@ -29,7 +29,8 @@ PlasmaExtras.Representation { height: Kirigami.Units.iconSizes.medium contentItem: PlasmaComponents3.TabBar { id: tabBar - readonly property double buttonWidth: parent.width / count + readonly property int buttonCount: plasmoid.showDownloads ? 4 : 3 + readonly property double buttonWidth: parent.width / buttonCount position: PlasmaComponents3.TabBar.Footer Layout.fillWidth: true Layout.fillHeight: true @@ -46,18 +47,19 @@ PlasmaExtras.Representation { icon.source: plasmoid.faUrl + "sitemap" width: tabBar.buttonWidth } - TabButton { - id: downloadsTabButton - text: qsTr("Downloads") - icon.source: plasmoid.faUrl + "download" - width: tabBar.buttonWidth - } TabButton { id: recentChangesTabButton text: qsTr("History") icon.source: plasmoid.faUrl + "history" width: tabBar.buttonWidth } + TabButton { + id: downloadsTabButton + text: qsTr("Downloads") + icon.source: plasmoid.faUrl + "download" + visible: plasmoid.showDownloads + width: visible ? tabBar.buttonWidth : 0 + } } } @@ -66,8 +68,8 @@ PlasmaExtras.Representation { switch (tabBar.currentIndex) { case 0: return directoriesPage case 1: return devicesPage - case 2: return downloadsPage - case 3: return recentChangesPage + case 2: return recentChangesPage + case 3: return downloadsPage default: return directoriesPage } } @@ -296,12 +298,12 @@ PlasmaExtras.Representation { DevicesPage { id: devicesPage } - DownloadsPage { - id: downloadsPage - } RecentChangesPage { id: recentChangesPage } + DownloadsPage { + id: downloadsPage + } } } } diff --git a/syncthingwidgets/misc/utils.cpp b/syncthingwidgets/misc/utils.cpp index a875de2b..5b9482b0 100644 --- a/syncthingwidgets/misc/utils.cpp +++ b/syncthingwidgets/misc/utils.cpp @@ -12,8 +12,8 @@ namespace QtGui { void handleRelevantControlsChanged(bool visible, int tabIndex, Data::SyncthingConnection &connection) { auto flags = connection.pollingFlags(); - CppUtilities::modFlagEnum(flags, Data::SyncthingConnection::PollingFlags::DownloadProgress, visible && tabIndex == 2); - CppUtilities::modFlagEnum(flags, Data::SyncthingConnection::PollingFlags::DiskEvents, visible && tabIndex == 3); + CppUtilities::modFlagEnum(flags, Data::SyncthingConnection::PollingFlags::DownloadProgress, visible && tabIndex == 3); + CppUtilities::modFlagEnum(flags, Data::SyncthingConnection::PollingFlags::DiskEvents, visible && tabIndex == 2); CppUtilities::modFlagEnum(flags, Data::SyncthingConnection::PollingFlags::TrafficStatistics, visible); CppUtilities::modFlagEnum(flags, Data::SyncthingConnection::PollingFlags::DeviceStatistics, visible && tabIndex == 1); connection.setPollingFlags(flags); diff --git a/syncthingwidgets/settings/appearanceoptionpage.ui b/syncthingwidgets/settings/appearanceoptionpage.ui index f350f7e6..43a1f820 100644 --- a/syncthingwidgets/settings/appearanceoptionpage.ui +++ b/syncthingwidgets/settings/appearanceoptionpage.ui @@ -335,6 +335,13 @@ + + + + Downloads + + + @@ -412,6 +419,7 @@ widthSpinBox heightSpinBox showTrafficCheckBox + showDownloadsCheckBox showTabTextsCheckBox preferIconsFromThemeCheckBox useCursorPosCheckBox diff --git a/syncthingwidgets/settings/settings.cpp b/syncthingwidgets/settings/settings.cpp index b776d576..82d90514 100644 --- a/syncthingwidgets/settings/settings.cpp +++ b/syncthingwidgets/settings/settings.cpp @@ -342,6 +342,7 @@ bool restore() v.ignoreInavailabilityAfterStart = settings.value(QStringLiteral("ignoreInavailabilityAfterStart"), v.ignoreInavailabilityAfterStart).toUInt(); auto &appearance = v.appearance; appearance.showTraffic = settings.value(QStringLiteral("showTraffic"), appearance.showTraffic).toBool(); + appearance.showDownloads = settings.value(QStringLiteral("showDownloads"), appearance.showDownloads).toBool(); appearance.showTabTexts = settings.value(QStringLiteral("showTabTexts"), appearance.showTabTexts).toBool(); if (auto windowType = settings.value(QStringLiteral("windowType")); windowType.isValid()) { appearance.windowType = windowType.toInt(); @@ -487,6 +488,7 @@ bool save() settings.setValue(QStringLiteral("ignoreInavailabilityAfterStart"), v.ignoreInavailabilityAfterStart); const auto &appearance = v.appearance; settings.setValue(QStringLiteral("showTraffic"), appearance.showTraffic); + settings.setValue(QStringLiteral("showDownloads"), appearance.showDownloads); settings.setValue(QStringLiteral("showTabTexts"), appearance.showTabTexts); settings.setValue(QStringLiteral("windowType"), appearance.windowType); settings.setValue(QStringLiteral("trayMenuSize"), appearance.trayMenuSize); diff --git a/syncthingwidgets/settings/settings.h b/syncthingwidgets/settings/settings.h index 64d81eae..bde05f44 100644 --- a/syncthingwidgets/settings/settings.h +++ b/syncthingwidgets/settings/settings.h @@ -64,6 +64,7 @@ struct SYNCTHINGWIDGETS_EXPORT NotifyOn { struct SYNCTHINGWIDGETS_EXPORT Appearance { bool showTraffic = true; + bool showDownloads = false; bool showTabTexts = true; int windowType = 0; // corresponds to TrayMenu::WindowType QSize trayMenuSize = QSize(575, 475); diff --git a/syncthingwidgets/settings/settingsdialog.cpp b/syncthingwidgets/settings/settingsdialog.cpp index c8a206a9..9f8c17af 100644 --- a/syncthingwidgets/settings/settingsdialog.cpp +++ b/syncthingwidgets/settings/settingsdialog.cpp @@ -536,6 +536,7 @@ bool AppearanceOptionPage::apply() settings.trayMenuSize.setWidth(ui()->widthSpinBox->value()); settings.trayMenuSize.setHeight(ui()->heightSpinBox->value()); settings.showTraffic = ui()->showTrafficCheckBox->isChecked(); + settings.showDownloads = ui()->showDownloadsCheckBox->isChecked(); settings.showTabTexts = ui()->showTabTextsCheckBox->isChecked(); v.icons.preferIconsFromTheme = ui()->preferIconsFromThemeCheckBox->isChecked(); int style; @@ -588,6 +589,7 @@ void AppearanceOptionPage::reset() resetPositioningSettings(); ui()->windowTypeComboBox->setCurrentIndex(settings.windowType); ui()->showTrafficCheckBox->setChecked(settings.showTraffic); + ui()->showDownloadsCheckBox->setChecked(settings.showDownloads); ui()->showTabTextsCheckBox->setChecked(settings.showTabTexts); ui()->preferIconsFromThemeCheckBox->setChecked(v.icons.preferIconsFromTheme); auto index = int(); diff --git a/tray/gui/traywidget.cpp b/tray/gui/traywidget.cpp index 6a1833c8..c3698280 100644 --- a/tray/gui/traywidget.cpp +++ b/tray/gui/traywidget.cpp @@ -603,6 +603,7 @@ void TrayWidget::applySettings(const QString &connectionConfig) } } } + m_ui->tabWidget->setTabVisible(3, settings.appearance.showDownloads); if (m_menu) { m_menu->setWindowType(settings.appearance.windowType); } diff --git a/tray/gui/traywidget.ui b/tray/gui/traywidget.ui index 2be706cd..d96d77c9 100644 --- a/tray/gui/traywidget.ui +++ b/tray/gui/traywidget.ui @@ -2,6 +2,11 @@ QtGui::TrayWidget + + + Noto Sans + + Syncthing Tray @@ -357,8 +362,7 @@ For <i>all</i> notifications, checkout the log New notifications - - .. + true @@ -445,15 +449,15 @@ For <i>all</i> notifications, checkout the log - + - download.fadownload.fa + history.fahistory.fa - Downloads + Recent changes - + 0 @@ -470,19 +474,23 @@ For <i>all</i> notifications, checkout the log 0 - + + + false + + - + - history.fahistory.fa + download.fadownload.fa - Recent changes + Downloads - + 0 @@ -499,11 +507,7 @@ For <i>all</i> notifications, checkout the log 0 - - - false - - +