From 616bcdc497f42d40f21862a724a0a4ac81dc6e83 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sun, 1 Oct 2017 21:42:26 +0200 Subject: [PATCH] plasmoid: Allow showing new notifications via button --- plasmoid/lib/syncthingapplet.cpp | 13 +++++- plasmoid/lib/syncthingapplet.h | 3 ++ .../contents/ui/FullRepresentation.qml | 18 ++++++++ .../translations/syncthingplasmoid_de_DE.ts | 45 ++++++++++--------- .../translations/syncthingplasmoid_en_US.ts | 45 ++++++++++--------- .../translations/syncthingwidgets_en_US.ts | 38 ++++++++-------- 6 files changed, 102 insertions(+), 60 deletions(-) diff --git a/plasmoid/lib/syncthingapplet.cpp b/plasmoid/lib/syncthingapplet.cpp index c36e09e..4f08029 100644 --- a/plasmoid/lib/syncthingapplet.cpp +++ b/plasmoid/lib/syncthingapplet.cpp @@ -170,6 +170,11 @@ bool SyncthingApplet::isStartStopForServiceEnabled() const return Settings::values().systemd.showButton; } +bool SyncthingApplet::areNotificationsAvailable() const +{ + return !m_notifications.empty(); +} + void SyncthingApplet::showSettingsDlg() { if (!m_settingsDlg) { @@ -245,13 +250,16 @@ void SyncthingApplet::showNotificationsDialog() dlg->setAttribute(Qt::WA_DeleteOnClose, true); centerWidget(dlg); dlg->show(); - m_notifications.clear(); dismissNotifications(); } void SyncthingApplet::dismissNotifications() { m_connection.considerAllNotificationsRead(); + if (!m_notifications.empty()) { + m_notifications.clear(); + emit notificationsAvailableChanged(false); + } } void SyncthingApplet::showInternalErrorsDialog() @@ -385,6 +393,9 @@ void SyncthingApplet::handleNewNotification(DateTime when, const QString &msg) if (Settings::values().notifyOn.syncthingErrors) { m_dbusNotifier.showSyncthingNotification(when, msg); } + if (m_notifications.size() == 1) { + emit notificationsAvailableChanged(true); + } } void SyncthingApplet::handleSystemdServiceError(const QString &context, const QString &name, const QString &message) diff --git a/plasmoid/lib/syncthingapplet.h b/plasmoid/lib/syncthingapplet.h index 93f52d0..8e7fc31 100644 --- a/plasmoid/lib/syncthingapplet.h +++ b/plasmoid/lib/syncthingapplet.h @@ -56,6 +56,7 @@ class SyncthingApplet : public Plasma::Applet { currentConnectionConfigIndexChanged) Q_PROPERTY(bool startStopForServiceEnabled READ isStartStopForServiceEnabled NOTIFY settingsChanged) Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY sizeChanged) + Q_PROPERTY(bool notificationsAvailable READ areNotificationsAvailable NOTIFY notificationsAvailableChanged) public: SyncthingApplet(QObject *parent, const QVariantList &data); @@ -82,6 +83,7 @@ public: bool isStartStopForServiceEnabled() const; QSize size() const; void setSize(const QSize &size); + bool areNotificationsAvailable() const; public Q_SLOTS: void init() Q_DECL_OVERRIDE; @@ -113,6 +115,7 @@ Q_SIGNALS: void settingsChanged(); void currentConnectionConfigIndexChanged(int index); void sizeChanged(const QSize &size); + void notificationsAvailableChanged(bool notificationsAvailable); private Q_SLOTS: void handleSettingsChanged(); diff --git a/plasmoid/package/contents/ui/FullRepresentation.qml b/plasmoid/package/contents/ui/FullRepresentation.qml index e3b2f1c..e71c705 100644 --- a/plasmoid/package/contents/ui/FullRepresentation.qml +++ b/plasmoid/package/contents/ui/FullRepresentation.qml @@ -317,6 +317,24 @@ ColumnLayout { Item { Layout.fillWidth: true } + TinyButton { + id: showNewNotifications + tooltip: qsTr("Show new notifications") + iconSource: "emblem-warning" + visible: plasmoid.nativeInterface.notificationsAvailable + onClicked: { + plasmoid.nativeInterface.showNotificationsDialog() + plasmoid.expanded = false + } + Shortcut { + sequence: "Ctrl+N" + onActivated: { + if (showNewNotifications.visible) { + showNewNotifications.clicked() + } + } + } + } TinyButton { id: showOwnIdButton tooltip: qsTr("Show own device ID") diff --git a/plasmoid/translations/syncthingplasmoid_de_DE.ts b/plasmoid/translations/syncthingplasmoid_de_DE.ts index 79807a8..8377385 100644 --- a/plasmoid/translations/syncthingplasmoid_de_DE.ts +++ b/plasmoid/translations/syncthingplasmoid_de_DE.ts @@ -12,12 +12,12 @@ DevicesPage - + Resume Fortsetzen - + Pause Pausieren @@ -25,27 +25,27 @@ DirectoriesPage - + Show errors Zeige Fehler - + Rescan Scannen - + Resume Fortsetzen - + Pause Pausieren - + Open in file browser Im Dateibrowser öffnen @@ -53,8 +53,8 @@ DownloadsPage - - + + Open in file browser Im Dateibrowser öffnen @@ -88,36 +88,41 @@ + Show new notifications + Neue Benachrichtigungen anzeigen + + + Show own device ID Eigene Geräte-ID anzeigen - + Show Syncthing log Syncthing-Log anzeigen - + Rescan all directories Alle Verzeichnisse neu scannen - + Settings Einstellungen - + Web UI Weboberfläche - + In - + Out @@ -199,29 +204,29 @@ Plasmoid::SyncthingApplet - + About Über Syncthing Plasmoid - + New notifications Neue Benachrichtigungen - + Synchronization of %1 complete %1 wurde synchronisiert - + Synchronization of the following devices complete: Die folgenden Geräte wurden synchronisiert: - + D-Bus error - unable to diff --git a/plasmoid/translations/syncthingplasmoid_en_US.ts b/plasmoid/translations/syncthingplasmoid_en_US.ts index 3f74b9e..e09dbd4 100644 --- a/plasmoid/translations/syncthingplasmoid_en_US.ts +++ b/plasmoid/translations/syncthingplasmoid_en_US.ts @@ -12,12 +12,12 @@ DevicesPage - + Resume - + Pause @@ -25,27 +25,27 @@ DirectoriesPage - + Show errors - + Rescan - + Resume - + Pause - + Open in file browser @@ -53,8 +53,8 @@ DownloadsPage - - + + Open in file browser @@ -88,36 +88,41 @@ + Show new notifications + + + + Show own device ID - + Show Syncthing log - + Rescan all directories - + Settings - + Web UI - + In - + Out @@ -199,28 +204,28 @@ Plasmoid::SyncthingApplet - + About - + New notifications - + Synchronization of %1 complete - + Synchronization of the following devices complete: - + D-Bus error - unable to diff --git a/widgets/translations/syncthingwidgets_en_US.ts b/widgets/translations/syncthingwidgets_en_US.ts index 091fecc..082d824 100644 --- a/widgets/translations/syncthingwidgets_en_US.ts +++ b/widgets/translations/syncthingwidgets_en_US.ts @@ -164,6 +164,11 @@ Move currently selected configuration down + + + Move currently selected configuration up + + Add secondary instance @@ -174,11 +179,6 @@ Remove currently selected secondary instance - - - Move currently selected configuration up - - It is possible to save multiple configurations. This allows switching quickly between multiple Syncthing instances using the connection button in the right corner of the tray menu. The config label is an arbitrary name to identify a configuration and does not have to match the name of the corresponding Syncthing device. The first configuration is the primary/default configuration. @@ -353,19 +353,19 @@ Response: - - - %1 error(s) occured - - %1 error occured - %1 errors occured - - Clear errors + + + %1 error(s) occured + + + + + QtGui::LauncherOptionPage @@ -626,9 +626,9 @@ Conntected to %1 devices - - Conntected to %1 device - Conntected to %1 devices + + + @@ -726,9 +726,9 @@ %1 item(s) out-of-sync - - %1 item out of sync - %1 items out of sync + + +