Use idle status icon for button to open Syncthing web UI

That looks more consistent, especially when using a dark color theme
where the default Syncthing icon doesn't fit in very well.
This commit is contained in:
Martchus 2020-04-12 23:16:26 +02:00
parent 159255441e
commit ed4d1fc213
11 changed files with 37 additions and 31 deletions

View File

@ -11,7 +11,7 @@ set(META_APP_CATEGORIES "Network;FileTransfer")
set(META_GUI_OPTIONAL false) set(META_GUI_OPTIONAL false)
set(META_VERSION_MAJOR 0) set(META_VERSION_MAJOR 0)
set(META_VERSION_MINOR 10) set(META_VERSION_MINOR 10)
set(META_VERSION_PATCH 8) set(META_VERSION_PATCH 9)
set(META_VERSION_EXACT_SONAME ON) set(META_VERSION_EXACT_SONAME ON)
set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON) set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON)

View File

@ -132,6 +132,11 @@ QIcon SyncthingApplet::statusIcon() const
return m_statusInfo.statusIcon(); return m_statusInfo.statusIcon();
} }
QIcon SyncthingApplet::syncthingIcon() const
{
return statusIcons().idling;
}
QString SyncthingApplet::incomingTraffic() const QString SyncthingApplet::incomingTraffic() const
{ {
return trafficString(m_connection.totalIncomingTraffic(), m_connection.totalIncomingRate()); return trafficString(m_connection.totalIncomingTraffic(), m_connection.totalIncomingRate());

View File

@ -47,6 +47,7 @@ class SyncthingApplet : public Plasma::Applet {
Q_PROPERTY(QString statusText READ statusText NOTIFY connectionStatusChanged) Q_PROPERTY(QString statusText READ statusText NOTIFY connectionStatusChanged)
Q_PROPERTY(QString additionalStatusText READ additionalStatusText NOTIFY connectionStatusChanged) Q_PROPERTY(QString additionalStatusText READ additionalStatusText NOTIFY connectionStatusChanged)
Q_PROPERTY(QIcon statusIcon READ statusIcon NOTIFY connectionStatusChanged) Q_PROPERTY(QIcon statusIcon READ statusIcon NOTIFY connectionStatusChanged)
Q_PROPERTY(QIcon syncthingIcon READ syncthingIcon NOTIFY settingsChanged)
Q_PROPERTY(QString incomingTraffic READ incomingTraffic NOTIFY trafficChanged) Q_PROPERTY(QString incomingTraffic READ incomingTraffic NOTIFY trafficChanged)
Q_PROPERTY(bool hasIncomingTraffic READ hasIncomingTraffic NOTIFY trafficChanged) Q_PROPERTY(bool hasIncomingTraffic READ hasIncomingTraffic NOTIFY trafficChanged)
Q_PROPERTY(QString outgoingTraffic READ outgoingTraffic NOTIFY trafficChanged) Q_PROPERTY(QString outgoingTraffic READ outgoingTraffic NOTIFY trafficChanged)
@ -79,6 +80,7 @@ public:
QString statusText() const; QString statusText() const;
QString additionalStatusText() const; QString additionalStatusText() const;
QIcon statusIcon() const; QIcon statusIcon() const;
QIcon syncthingIcon() const;
QString incomingTraffic() const; QString incomingTraffic() const;
bool hasIncomingTraffic() const; bool hasIncomingTraffic() const;
QString outgoingTraffic() const; QString outgoingTraffic() const;

View File

@ -56,7 +56,7 @@ Item {
} }
TinyButton { TinyButton {
id: resumePauseButton id: resumePauseButton
iconSource: paused ? "media-playback-start" : "media-playback-pause" icon: paused ? "media-playback-start" : "media-playback-pause"
tooltip: paused ? qsTr("Resume") : qsTr("Pause") tooltip: paused ? qsTr("Resume") : qsTr("Pause")
onClicked: { onClicked: {
paused ? plasmoid.nativeInterface.connection.resumeDevice( paused ? plasmoid.nativeInterface.connection.resumeDevice(

View File

@ -71,7 +71,7 @@ ColumnLayout {
} }
TinyButton { TinyButton {
id: errorsButton id: errorsButton
iconSource: ":/icons/hicolor/scalable/emblems/emblem-important-old.svg" icon: ":/icons/hicolor/scalable/emblems/emblem-important-old.svg"
tooltip: qsTr("Show errors") tooltip: qsTr("Show errors")
visible: pullErrorCount > 0 visible: pullErrorCount > 0
onClicked: { onClicked: {
@ -82,7 +82,7 @@ ColumnLayout {
} }
TinyButton { TinyButton {
id: rescanButton id: rescanButton
iconSource: "view-refresh" icon: "view-refresh"
tooltip: qsTr("Rescan") tooltip: qsTr("Rescan")
enabled: !paused enabled: !paused
onClicked: plasmoid.nativeInterface.connection.rescan( onClicked: plasmoid.nativeInterface.connection.rescan(
@ -90,7 +90,7 @@ ColumnLayout {
} }
TinyButton { TinyButton {
id: resumePauseButton id: resumePauseButton
iconSource: paused ? "media-playback-start" : "media-playback-pause" icon: paused ? "media-playback-start" : "media-playback-pause"
tooltip: paused ? qsTr("Resume") : qsTr("Pause") tooltip: paused ? qsTr("Resume") : qsTr("Pause")
onClicked: { onClicked: {
paused ? plasmoid.nativeInterface.connection.resumeDirectories( paused ? plasmoid.nativeInterface.connection.resumeDirectories(
@ -100,7 +100,7 @@ ColumnLayout {
} }
TinyButton { TinyButton {
id: openButton id: openButton
iconSource: "folder" icon: "folder"
tooltip: qsTr("Open in file browser") tooltip: qsTr("Open in file browser")
onClicked: { onClicked: {
Qt.openUrlExternally(path) Qt.openUrlExternally(path)

View File

@ -60,7 +60,7 @@ Item {
} }
TinyButton { TinyButton {
id: openButton id: openButton
iconSource: "folder" icon: "folder"
tooltip: qsTr("Open in file browser") tooltip: qsTr("Open in file browser")
enabled: path !== undefined enabled: path !== undefined
onClicked: { onClicked: {
@ -116,7 +116,7 @@ Item {
} }
} }
TinyButton { TinyButton {
iconSource: "folder" icon: "folder"
tooltip: qsTr("Open in file browser") tooltip: qsTr("Open in file browser")
onClicked: { onClicked: {
Qt.openUrlExternally(path + "/..") Qt.openUrlExternally(path + "/..")

View File

@ -186,7 +186,7 @@ ColumnLayout {
PropertyChanges { PropertyChanges {
target: connectButton target: connectButton
text: qsTr("Connect") text: qsTr("Connect")
iconSource: "view-refresh" icon: "view-refresh"
} }
}, },
State { State {
@ -194,7 +194,7 @@ ColumnLayout {
PropertyChanges { PropertyChanges {
target: connectButton target: connectButton
text: qsTr("Resume") text: qsTr("Resume")
iconSource: "media-playback-start" icon: "media-playback-start"
} }
}, },
State { State {
@ -202,7 +202,7 @@ ColumnLayout {
PropertyChanges { PropertyChanges {
target: connectButton target: connectButton
text: qsTr("Pause") text: qsTr("Pause")
iconSource: "media-playback-pause" icon: "media-playback-pause"
} }
} }
] ]
@ -249,7 +249,7 @@ ColumnLayout {
text: qsTr("Stop") text: qsTr("Stop")
tooltip: (plasmoid.nativeInterface.service.userScope ? "systemctl --user stop " : "systemctl stop ") tooltip: (plasmoid.nativeInterface.service.userScope ? "systemctl --user stop " : "systemctl stop ")
+ plasmoid.nativeInterface.service.unitName + plasmoid.nativeInterface.service.unitName
iconSource: "process-stop" icon: "process-stop"
} }
}, },
State { State {
@ -260,7 +260,7 @@ ColumnLayout {
text: qsTr("Start") text: qsTr("Start")
tooltip: (plasmoid.nativeInterface.service.userScope ? "systemctl --user start " : "systemctl start ") tooltip: (plasmoid.nativeInterface.service.userScope ? "systemctl --user start " : "systemctl start ")
+ plasmoid.nativeInterface.service.unitName + plasmoid.nativeInterface.service.unitName
iconSource: "system-run" icon: "system-run"
} }
}, },
State { State {
@ -286,8 +286,7 @@ ColumnLayout {
return service.running ? "running" : "stopped" return service.running ? "running" : "stopped"
} }
onClicked: plasmoid.nativeInterface.service.toggleRunning() onClicked: plasmoid.nativeInterface.service.toggleRunning()
style: TinyButtonStyle { style: TinyButtonStyle {}
}
Shortcut { Shortcut {
sequence: "Ctrl+Shift+S" sequence: "Ctrl+Shift+S"
onActivated: { onActivated: {
@ -320,7 +319,7 @@ ColumnLayout {
} }
TinyButton { TinyButton {
tooltip: qsTr("About Syncthing Tray") tooltip: qsTr("About Syncthing Tray")
iconSource: "help-about" icon: "help-about"
onClicked: { onClicked: {
plasmoid.nativeInterface.showAboutDialog() plasmoid.nativeInterface.showAboutDialog()
plasmoid.expanded = false plasmoid.expanded = false
@ -329,7 +328,7 @@ ColumnLayout {
TinyButton { TinyButton {
id: showOwnIdButton id: showOwnIdButton
tooltip: qsTr("Show own device ID") tooltip: qsTr("Show own device ID")
iconSource: "view-barcode" icon: "view-barcode"
onClicked: { onClicked: {
plasmoid.nativeInterface.showOwnDeviceId() plasmoid.nativeInterface.showOwnDeviceId()
plasmoid.expanded = false plasmoid.expanded = false
@ -342,7 +341,7 @@ ColumnLayout {
TinyButton { TinyButton {
id: showLogButton id: showLogButton
tooltip: qsTr("Show Syncthing log") tooltip: qsTr("Show Syncthing log")
iconSource: "text-x-generic" icon: "text-x-generic"
onClicked: { onClicked: {
plasmoid.nativeInterface.showLog() plasmoid.nativeInterface.showLog()
plasmoid.expanded = false plasmoid.expanded = false
@ -355,7 +354,7 @@ ColumnLayout {
TinyButton { TinyButton {
id: rescanAllDirsButton id: rescanAllDirsButton
tooltip: qsTr("Rescan all directories") tooltip: qsTr("Rescan all directories")
iconSource: "folder-sync" icon: "folder-sync"
onClicked: plasmoid.nativeInterface.connection.rescanAllDirs() onClicked: plasmoid.nativeInterface.connection.rescanAllDirs()
Shortcut { Shortcut {
sequence: "Ctrl+Shift+R" sequence: "Ctrl+Shift+R"
@ -365,7 +364,7 @@ ColumnLayout {
TinyButton { TinyButton {
id: settingsButton id: settingsButton
tooltip: qsTr("Settings") tooltip: qsTr("Settings")
iconSource: "preferences-other" icon: "preferences-other"
onClicked: { onClicked: {
plasmoid.nativeInterface.showSettingsDlg() plasmoid.nativeInterface.showSettingsDlg()
plasmoid.expanded = false plasmoid.expanded = false
@ -378,7 +377,7 @@ ColumnLayout {
TinyButton { TinyButton {
id: webUIButton id: webUIButton
tooltip: qsTr("Open Syncthing") tooltip: qsTr("Open Syncthing")
iconSource: ":/icons/hicolor/scalable/status/syncthing-default.svg" icon: plasmoid.nativeInterface.syncthingIcon
onClicked: { onClicked: {
plasmoid.nativeInterface.showWebUI() plasmoid.nativeInterface.showWebUI()
plasmoid.expanded = false plasmoid.expanded = false
@ -390,7 +389,7 @@ ColumnLayout {
} }
TinyButton { TinyButton {
text: plasmoid.nativeInterface.currentConnectionConfigName text: plasmoid.nativeInterface.currentConnectionConfigName
iconSource: "network-connect" icon: "network-connect"
paddingEnabled: true paddingEnabled: true
// FIXME: figure out why menu doesn't work in plasmoidviewer using NVIDIA driver // FIXME: figure out why menu doesn't work in plasmoidviewer using NVIDIA driver
// (works with plasmawindowed and plasmashell or always when using Intel graphics) // (works with plasmawindowed and plasmashell or always when using Intel graphics)
@ -529,14 +528,13 @@ ColumnLayout {
iconSource: "document-open-recent-symbolic" iconSource: "document-open-recent-symbolic"
tab: recentChangesPage tab: recentChangesPage
} }
} }
Item { Item {
Layout.fillHeight: true Layout.fillHeight: true
} }
TinyButton { TinyButton {
id: searchButton id: searchButton
iconSource: "search" icon: "search"
enabled: mainTabGroup.currentTab === dirsPage enabled: mainTabGroup.currentTab === dirsPage
tooltip: qsTr("Toggle filter") tooltip: qsTr("Toggle filter")
onClicked: { onClicked: {

View File

@ -4,6 +4,10 @@ PlasmaComponents.ToolButton {
property int iconSize: units.iconSizes.small property int iconSize: units.iconSizes.small
property bool paddingEnabled: false property bool paddingEnabled: false
style: TinyButtonStyle { // define our own icon property and use that within the style to be able to set QIcon a directly
} // note: The iconSource alias defined in org/kde/plasma/components/ToolButton.qml seems to break
// passing a QIcon as iconSource (instead of just the name of an icon) so it can not be used.
property var icon
style: TinyButtonStyle {}
} }

View File

@ -32,7 +32,7 @@ QtQuickControlStyle.ButtonStyle {
PlasmaCore.IconItem { PlasmaCore.IconItem {
id: icon id: icon
source: control.iconName || control.iconSource source: control.icon
Layout.preferredWidth: control.iconSize Layout.preferredWidth: control.iconSize
Layout.preferredHeight: control.iconSize Layout.preferredHeight: control.iconSize
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter

View File

@ -485,6 +485,7 @@ void TrayWidget::applySettings(const QString &connectionConfig)
m_dlModel.setBrightColors(brightColors); m_dlModel.setBrightColors(brightColors);
m_recentChangesModel.setBrightColors(brightColors); m_recentChangesModel.setBrightColors(brightColors);
IconManager::instance().applySettings(&settings.icons.status, settings.icons.distinguishTrayIcons ? &settings.icons.tray : nullptr); IconManager::instance().applySettings(&settings.icons.status, settings.icons.distinguishTrayIcons ? &settings.icons.tray : nullptr);
m_ui->webUiPushButton->setIcon(statusIcons().idling);
// update status icon and text of tray icon because reconnect interval might have changed // update status icon and text of tray icon because reconnect interval might have changed
if (m_menu && m_menu->icon()) { if (m_menu && m_menu->icon()) {

View File

@ -126,10 +126,6 @@
<property name="toolTip"> <property name="toolTip">
<string>Open Syncthing</string> <string>Open Syncthing</string>
</property> </property>
<property name="icon">
<iconset resource="../../model/resources/syncthingmodelicons.qrc">
<normaloff>:/icons/hicolor/scalable/status/syncthing-default.svg</normaloff>:/icons/hicolor/scalable/status/syncthing-default.svg</iconset>
</property>
<property name="flat"> <property name="flat">
<bool>true</bool> <bool>true</bool>
</property> </property>