Skip to content

Commit

Permalink
Hide "Downloads" tab by default
Browse files Browse the repository at this point in the history
The "Downloads" tab is most of the time empty despite downloads going on,
see #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.
  • Loading branch information
Martchus committed Dec 20, 2024
1 parent 284a2b4 commit 882cd34
Show file tree
Hide file tree
Showing 13 changed files with 125 additions and 67 deletions.
65 changes: 40 additions & 25 deletions plasmoid/lib/appearanceoptionpage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -114,26 +114,6 @@
</item>
</layout>
</item>
<item row="5" column="0">
<widget class="QLabel" name="passiveLabel">
<property name="text">
<string>States to enable passive mode</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QListView" name="passiveListView">
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
</property>
<property name="layoutMode">
<enum>QListView::Batched</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="optionalGuiElementsLabel">
<property name="text">
Expand All @@ -142,9 +122,30 @@
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="showTabTextsCheckBox">
<layout class="QVBoxLayout" name="optionalGuiElementsVerticalLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="showDownloadsCheckBox">
<property name="text">
<string>Downloads</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="showTabTextsCheckBox">
<property name="text">
<string>Show tab texts</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="iconsLabel">
<property name="text">
<string>Show tab texts</string>
<string>Icons</string>
</property>
</widget>
</item>
Expand All @@ -162,10 +163,23 @@
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="iconsLabel">
<item row="5" column="0">
<widget class="QLabel" name="passiveLabel">
<property name="text">
<string>Icons</string>
<string>States to enable passive mode</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QListView" name="passiveListView">
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
</property>
<property name="layoutMode">
<enum>QListView::Batched</enum>
</property>
</widget>
</item>
Expand All @@ -190,6 +204,7 @@
<tabstops>
<tabstop>widthSpinBox</tabstop>
<tabstop>heightSpinBox</tabstop>
<tabstop>showDownloadsCheckBox</tabstop>
<tabstop>showTabTextsCheckBox</tabstop>
<tabstop>preferIconsFromThemeCheckBox</tabstop>
<tabstop>passiveListView</tabstop>
Expand Down
2 changes: 2 additions & 0 deletions plasmoid/lib/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ bool AppearanceOptionPage::apply()
KConfigGroup config = m_applet->config();
config.writeEntry<QSize>("size", QSize(ui()->widthSpinBox->value(), ui()->heightSpinBox->value()));
config.writeEntry<bool>("showTabTexts", ui()->showTabTextsCheckBox->isChecked());
config.writeEntry<bool>("showDownloads", ui()->showDownloadsCheckBox->isChecked());
config.writeEntry<bool>("preferIconsFromTheme", ui()->preferIconsFromThemeCheckBox->isChecked());
config.writeEntry("passiveStates", m_passiveStatusSelection.toVariantList());

Expand All @@ -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()));
}
Expand Down
2 changes: 2 additions & 0 deletions plasmoid/lib/syncthingapplet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -694,6 +695,7 @@ void SyncthingApplet::applySettings(int changeConnectionIndex)
// apply appearance settings
setSize(config.readEntry<QSize>("size", QSize(25, 25)));
setShowingTabTexts(config.readEntry<bool>("showTabTexts", false));
setShowingDownloads(config.readEntry<bool>("showDownloads", false));
IconManager::instance().applySettings(&settings.icons.status, nullptr, settings.icons.usePaletteForStatus, false);

// restore selected states
Expand Down
17 changes: 17 additions & 0 deletions plasmoid/lib/syncthingapplet.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<QtUtilities::ChecklistItem> passiveStates READ passiveStates WRITE setPassiveStates)
Q_PROPERTY(QString faUrl READ faUrl NOTIFY faUrlChanged)
Expand Down Expand Up @@ -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<QtUtilities::ChecklistItem> &passiveStates() const;
void setPassiveStates(const QList<QtUtilities::ChecklistItem> &passiveStates);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -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;
Expand Down
26 changes: 14 additions & 12 deletions plasmoid/package5/contents/ui/FullRepresentation.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}
}

Expand All @@ -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
}
}
Expand Down Expand Up @@ -290,12 +292,12 @@ PlasmaExtras.Representation {
DevicesPage {
id: devicesPage
}
DownloadsPage {
id: downloadsPage
}
RecentChangesPage {
id: recentChangesPage
}
DownloadsPage {
id: downloadsPage
}
}
}
}
Expand Down
26 changes: 14 additions & 12 deletions plasmoid/package6/contents/ui/FullRepresentation.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}
}

Expand All @@ -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
}
}
Expand Down Expand Up @@ -296,12 +298,12 @@ PlasmaExtras.Representation {
DevicesPage {
id: devicesPage
}
DownloadsPage {
id: downloadsPage
}
RecentChangesPage {
id: recentChangesPage
}
DownloadsPage {
id: downloadsPage
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions syncthingwidgets/misc/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions syncthingwidgets/settings/appearanceoptionpage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="showDownloadsCheckBox">
<property name="text">
<string>Downloads</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="showTabTextsCheckBox">
<property name="text">
Expand Down Expand Up @@ -412,6 +419,7 @@
<tabstop>widthSpinBox</tabstop>
<tabstop>heightSpinBox</tabstop>
<tabstop>showTrafficCheckBox</tabstop>
<tabstop>showDownloadsCheckBox</tabstop>
<tabstop>showTabTextsCheckBox</tabstop>
<tabstop>preferIconsFromThemeCheckBox</tabstop>
<tabstop>useCursorPosCheckBox</tabstop>
Expand Down
2 changes: 2 additions & 0 deletions syncthingwidgets/settings/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions syncthingwidgets/settings/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions syncthingwidgets/settings/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions tray/gui/traywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading

0 comments on commit 882cd34

Please sign in to comment.