diff --git a/connector/syncthingconnection.cpp b/connector/syncthingconnection.cpp index 64e89d0..70789b7 100644 --- a/connector/syncthingconnection.cpp +++ b/connector/syncthingconnection.cpp @@ -54,9 +54,6 @@ SyncthingConnection::SyncthingConnection(const QString &syncthingUrl, const QByt m_keepPolling(false), m_reconnecting(false), m_lastEventId(0), - m_trafficPollTimer(), - m_devStatsPollTimer(), - m_autoReconnectTimer(), m_autoReconnectTries(0), m_totalIncomingTraffic(0), m_totalOutgoingTraffic(0), @@ -80,6 +77,10 @@ SyncthingConnection::SyncthingConnection(const QString &syncthingUrl, const QByt m_devStatsPollTimer.setTimerType(Qt::VeryCoarseTimer); m_devStatsPollTimer.setSingleShot(true); QObject::connect(&m_devStatsPollTimer, &QTimer::timeout, this, &SyncthingConnection::requestDeviceStatistics); + m_errorsPollTimer.setInterval(30000); + m_errorsPollTimer.setTimerType(Qt::VeryCoarseTimer); + m_errorsPollTimer.setSingleShot(true); + QObject::connect(&m_errorsPollTimer, &QTimer::timeout, this, &SyncthingConnection::requestErrors); m_autoReconnectTimer.setTimerType(Qt::VeryCoarseTimer); QObject::connect(&m_autoReconnectTimer, &QTimer::timeout, this, &SyncthingConnection::autoReconnect); } @@ -731,6 +732,7 @@ bool SyncthingConnection::applySettings(SyncthingConnectionSettings &connectionS setTrafficPollInterval(connectionSettings.trafficPollInterval); setDevStatsPollInterval(connectionSettings.devStatsPollInterval); + setErrorsPollInterval(connectionSettings.errorsPollInterval); setAutoReconnectInterval(connectionSettings.reconnectInterval); return reconnectRequired; @@ -941,7 +943,7 @@ void SyncthingConnection::readConnections() m_lastConnectionsUpdate = DateTime::gmtNow(); - // since there seems no event for this data, just request every 2 seconds + // since there seems no event for this data, keep polling if(m_keepPolling && m_trafficPollTimer.interval()) { m_trafficPollTimer.start(); } @@ -1043,7 +1045,7 @@ void SyncthingConnection::readDeviceStatistics() } ++index; } - // since there seems no event for this data, just request every minute + // since there seems no event for this data, keep polling if(m_keepPolling && m_devStatsPollTimer.interval()) { m_devStatsPollTimer.start(); } @@ -1095,15 +1097,15 @@ void SyncthingConnection::readErrors() emit error(tr("Unable to parse errors: ") + jsonError.errorString(), SyncthingErrorCategory::Parsing, QNetworkReply::NoError); } - // since there seems no event for this data, just request every thirty seconds, FIXME: make interval configurable - if(m_keepPolling) { - QTimer::singleShot(30000, Qt::VeryCoarseTimer, this, SLOT(requestErrors())); + // since there seems no event for this data, keep polling + if(m_keepPolling && m_errorsPollTimer.interval()) { + m_errorsPollTimer.start(); } break; } case QNetworkReply::OperationCanceledError: return; // intended, not an error default: - emit error(tr("Unable to request errors: ") + reply->errorString(), SyncthingErrorCategory::OverallConnection, reply->error()); + emit error(tr("Unable to request errors: ") + reply->errorString(), SyncthingErrorCategory::SpecificRequest, reply->error()); } } @@ -1529,6 +1531,7 @@ void SyncthingConnection::setStatus(SyncthingStatus status) // don't consider synchronization finished in this this case m_devStatsPollTimer.stop(); m_trafficPollTimer.stop(); + m_errorsPollTimer.stop(); m_syncedDirs.clear(); break; default: diff --git a/connector/syncthingconnection.h b/connector/syncthingconnection.h index 82e3ba4..ac7f0c2 100644 --- a/connector/syncthingconnection.h +++ b/connector/syncthingconnection.h @@ -91,6 +91,8 @@ public: void setTrafficPollInterval(int trafficPollInterval); int devStatsPollInterval() const; void setDevStatsPollInterval(int devStatsPollInterval); + int errorsPollInterval() const; + void setErrorsPollInterval(int errorsPollInterval); int autoReconnectInterval() const; unsigned int autoReconnectTries() const; void setAutoReconnectInterval(int interval); @@ -204,6 +206,7 @@ private: int m_lastEventId; QTimer m_trafficPollTimer; QTimer m_devStatsPollTimer; + QTimer m_errorsPollTimer; QTimer m_autoReconnectTimer; unsigned int m_autoReconnectTries; QString m_configDir; @@ -364,6 +367,27 @@ inline void SyncthingConnection::setDevStatsPollInterval(int devStatsPollInterva m_devStatsPollTimer.setInterval(devStatsPollInterval); } +/*! + * \brief Returns the interval for polling Syncthing errors (which currently can not be received via event API) in milliseconds. + * \remarks Default value is 30000 milliseconds. + */ +inline int SyncthingConnection::errorsPollInterval() const +{ + return m_errorsPollTimer.interval(); +} + +/*! + * \brief Sets the interval for polling Syncthing errors (which currently can not be received via event API) in milliseconds. + * \remarks Default value is 30000 milliseconds. + */ +inline void SyncthingConnection::setErrorsPollInterval(int errorPollInterval) +{ + if(!errorPollInterval) { + m_errorsPollTimer.stop(); + } + m_errorsPollTimer.setInterval(errorPollInterval); +} + /*! * \brief Returns the reconnect interval in milliseconds. * \remarks Default value is 0 which indicates disabled auto-reconnect. diff --git a/connector/syncthingconnectionsettings.h b/connector/syncthingconnectionsettings.h index 23a1827..5e455d3 100644 --- a/connector/syncthingconnectionsettings.h +++ b/connector/syncthingconnectionsettings.h @@ -18,6 +18,7 @@ struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingConnectionSettings { QByteArray apiKey; int trafficPollInterval = 2000; int devStatsPollInterval = 60000; + int errorsPollInterval = 30000; int reconnectInterval = 0; QString httpsCertPath; QList expectedSslErrors; diff --git a/tray/application/settings.cpp b/tray/application/settings.cpp index fe02936..d1d2b18 100644 --- a/tray/application/settings.cpp +++ b/tray/application/settings.cpp @@ -63,6 +63,7 @@ void restore() connectionSettings->apiKey = settings.value(QStringLiteral("apiKey")).toByteArray(); connectionSettings->trafficPollInterval = settings.value(QStringLiteral("trafficPollInterval"), connectionSettings->trafficPollInterval).toInt(); connectionSettings->devStatsPollInterval = settings.value(QStringLiteral("devStatsPollInterval"), connectionSettings->devStatsPollInterval).toInt(); + connectionSettings->errorsPollInterval = settings.value(QStringLiteral("errorsPollInterval"), connectionSettings->errorsPollInterval).toInt(); connectionSettings->reconnectInterval = settings.value(QStringLiteral("reconnectInterval"), connectionSettings->reconnectInterval).toInt(); connectionSettings->httpsCertPath = settings.value(QStringLiteral("httpsCertPath")).toString(); if(!connectionSettings->loadHttpsCert()) { @@ -138,6 +139,7 @@ void save() settings.setValue(QStringLiteral("apiKey"), connectionSettings->apiKey); settings.setValue(QStringLiteral("trafficPollInterval"), connectionSettings->trafficPollInterval); settings.setValue(QStringLiteral("devStatsPollInterval"), connectionSettings->devStatsPollInterval); + settings.setValue(QStringLiteral("errorsPollInterval"), connectionSettings->errorsPollInterval); settings.setValue(QStringLiteral("reconnectInterval"), connectionSettings->reconnectInterval); settings.setValue(QStringLiteral("httpsCertPath"), connectionSettings->httpsCertPath); } diff --git a/tray/gui/connectionoptionpage.ui b/tray/gui/connectionoptionpage.ui index 1ea19a3..b0c0aeb 100644 --- a/tray/gui/connectionoptionpage.ui +++ b/tray/gui/connectionoptionpage.ui @@ -100,6 +100,16 @@ + + + + + 32 + 32 + + + + @@ -240,31 +250,6 @@ - - - - Status - - - - - - - disconnected - - - - - - - Apply connection settings and try to reconnect with the currently selected config - - - - :/icons/hicolor/scalable/actions/view-refresh.svg:/icons/hicolor/scalable/actions/view-refresh.svg - - - @@ -276,18 +261,14 @@ - - + + 10 - - - - Traffic - - - - + + 0 + + @@ -306,21 +287,28 @@ - - - - Qt::Vertical + + + + Traffic - + Device statistics - + + + + Qt::Vertical + + + + @@ -339,21 +327,40 @@ - - - - Qt::Vertical + + + + Errors - + + + + + 0 + 0 + + + + ms + + + 100 + + + 999999999 + + + + Reconnect - + @@ -372,15 +379,37 @@ + + + + Qt::Vertical + + + - - - - - 32 - 32 - + + + + Status + + + + + + + disconnected + + + + + + + Apply connection settings and try to reconnect with the currently selected config + + + + :/icons/hicolor/scalable/actions/view-refresh.svg:/icons/hicolor/scalable/actions/view-refresh.svg diff --git a/tray/gui/settingsdialog.cpp b/tray/gui/settingsdialog.cpp index 13fcf48..fbbac00 100644 --- a/tray/gui/settingsdialog.cpp +++ b/tray/gui/settingsdialog.cpp @@ -137,6 +137,7 @@ bool ConnectionOptionPage::showConnectionSettings(int index) ui()->certPathSelection->lineEdit()->setText(connectionSettings.httpsCertPath); ui()->pollTrafficSpinBox->setValue(connectionSettings.trafficPollInterval); ui()->pollDevStatsSpinBox->setValue(connectionSettings.devStatsPollInterval); + ui()->pollErrorsSpinBox->setValue(connectionSettings.errorsPollInterval); ui()->reconnectSpinBox->setValue(connectionSettings.reconnectInterval); m_currentIndex = index; } else { @@ -162,6 +163,7 @@ bool ConnectionOptionPage::cacheCurrentSettings(bool applying) connectionSettings.httpsCertPath = ui()->certPathSelection->lineEdit()->text(); connectionSettings.trafficPollInterval = ui()->pollTrafficSpinBox->value(); connectionSettings.devStatsPollInterval = ui()->pollDevStatsSpinBox->value(); + connectionSettings.errorsPollInterval = ui()->pollErrorsSpinBox->value(); connectionSettings.reconnectInterval = ui()->reconnectSpinBox->value(); if(!connectionSettings.loadHttpsCert()) { const QString errorMessage = QCoreApplication::translate("QtGui::ConnectionOptionPage", "Unable to load specified certificate \"%1\".").arg(connectionSettings.httpsCertPath); @@ -740,7 +742,7 @@ SettingsDialog::SettingsDialog(Data::SyncthingConnection *connection, QWidget *p categoryModel()->setCategories(categories); - resize(850, 600); + resize(860, 620); setWindowTitle(tr("Settings") + QStringLiteral(" - " APP_NAME)); setWindowIcon(QIcon::fromTheme(QStringLiteral("preferences-other"), QIcon(QStringLiteral(":/icons/hicolor/scalable/apps/preferences-other.svg")))); diff --git a/tray/translations/syncthingtray_de_DE.ts b/tray/translations/syncthingtray_de_DE.ts index bc9ce03..041b312 100644 --- a/tray/translations/syncthingtray_de_DE.ts +++ b/tray/translations/syncthingtray_de_DE.ts @@ -127,22 +127,22 @@ Tray-Icon beim Starten der Desktopumgebung automatisch starten - + This is achieved by adding a *.desktop file under <i>~/.config/autostart</i> so the setting only affects the current user. Durch das Hinzufügen einer *.desktop-Datei unter <i>~/.config/autostart</i> realisiert - betrifft also nur den aktuellen Benutzer. - + This is achieved by adding a registry key under <i>HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run</i> so the setting only affects the current user. Note that the startup entry is invalidated when moving <i>syncthingtray.exe</i>. Durch das Hinzufügen eines Registry-Schlüssels unter <i>HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run</i> realisiert - betrifft also nur den aktuellen Benutzer. - + This feature has not been implemented for your platform (yet). Diese Funktion wurde für die aktuelle Plattform nicht nicht implementiert. - + unable to modify startup entry Fehler beim aktualisieren des Auto-Start-Eintrags @@ -170,89 +170,95 @@ Sekundäre Konfiguration löschen - + 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. Es ist möglich, mehrere Konfigurationen zu speichern. Zwischen diesen kann anschließend über das Verbindungsmenü rechts oben im Tray schnell hin- und hergewechselt werden. Der Name der Konfiguration muss nicht mit dem Namen des entsprechenden Syncthing-Gerätes übereinstimmen. - + Syncthing URL - + Authentication Authentifizierung - + User Benutzername - + Password Passwort - + API key API-Schlüssel - + HTTPS certificate HTTPS-Zertifikat - + Insert values from local Syncthing configuration Werte aus lokaler Syncthing-Konfiguration einfügen - + + Errors + Fehler + + + Status - + disconnected getrennt - + Apply connection settings and try to reconnect with the currently selected config Verbindungseinstellungen übernehmen und mit neuen Einstellungen verbinden - + Poll interval Abfrageintervall - + Traffic - - - + + + + ms - + Device statistics Gerätestatistiken - + Reconnect Verbindungsveruch - + no nicht neu verbinden @@ -272,12 +278,12 @@ Fehler beim Auslesen der Syncthing-Konfigurationsdatei. - + Unable to load specified certificate "%1". Fehler beim Auslesen des angegebenen Zertifikats: %1 - + Instance %1 Instanz %1 @@ -384,13 +390,13 @@ Log folgen - + Syncthing exited with exit code %1 Syncthing wurde mit dem Statuscode %1 beendet - + Syncthing crashed with exit code %1 Syncthing ist mit dem Statuscode %1 abgestürzt @@ -444,7 +450,7 @@ Methode die von Qt verwendet wird (kann vom QPA-Plugin überschrieben werden) - + Configured to use D-Bus notifications but D-Bus notification daemon seems unavailabe. Benachrichtigungen via D-Bus wurden eingestellt, aber es scheint kein Daemon zu laufen der den Dienst bereitstellt. @@ -452,22 +458,22 @@ QtGui::SettingsDialog - + Tray - + Web view Weboberfläche - + Startup Starten - + Settings Einstellungen @@ -508,8 +514,8 @@ - - + + unknown unbekannt @@ -543,7 +549,7 @@ Stoppen - + specified unit is either inactive or doesn't exist angegebene Unit ist entweder nicht geladen oder existiert nicht @@ -551,133 +557,133 @@ QtGui::TrayIcon - + - internal error - interner Fehler - + Syncthing notification Syncthing-Benachrichtigung - + Web UI Weboberfäche - + Settings Einstellungen - + Rescan all Alle neu scannen - + About Über Syncthing Tray - + Close Beenden - + Error Fehler - + Syncthing notification - click to dismiss Neue Syncthing-Benachrichtigung - + Not connected to Syncthing - trying to reconnect every %1 ms Nicht mit Syncthing verbunden - versuche alle %1 ms zu verbinden - + Not connected to Syncthing Nicht mit Syncthing verbunden - - + + Disconnected from Syncthing Verbindung zu Syncthing getrennt - + Log - + Try to reconnect Versuche Verbindung wieder herzustellen - + Dismiss Ignorieren - + Show Zeigen - + Reconnecting ... Neu verbinden ... - + Synchronization is ongoing but at least one directory is out of sync Synchronisiert, aber mind. ein Verzeichnis hat Fehler - + At least one directory is out of sync Mind. ein Verzeichnis hat Fehler - + Notifications available Es gibt neue Benachrichtigungen - + Syncthing is idling Syncthing ist im Leerlauf - + Syncthing is scanning Syncthing scannt - + At least one device is paused Mind. ein Gerät ist pausiert - + Synchronization is ongoing Syncthing synchronisiert - + Synchronization of %1 complete %1 wurde synchronisiert - + Synchronization of the following devices complete: Folgende Verzeichnisse wurden synchronisiert: @@ -710,7 +716,7 @@ - + Start Starten @@ -742,7 +748,7 @@ - + unknown unbekannt @@ -871,17 +877,17 @@ For <i>all</i> notifications, checkout the log Mind. ein Gerät ist pausiert, klicke um fortzusetzen - + The directory <i>%1</i> does not exist on the local machine. Das Verzeichnis <i>%i</i> existiert nicht (lokal). - + The file <i>%1</i> does not exist on the local machine. Die Datei <i>%1</i> existiert nicht (lokal). - + Stop Stoppen @@ -898,7 +904,7 @@ For <i>all</i> notifications, checkout the log QtGui::WebViewOptionPage - + General Allgemein @@ -928,7 +934,7 @@ For <i>all</i> notifications, checkout the log Lasse Weboberfläche im Hintgergrund weiter offen, wenn Fenster nicht offen - + Syncthing Tray has not been built with vieb view support utilizing either Qt WebKit or Qt WebEngine. The Web UI will be opened in the default web browser instead. Syncthing Tray wurde nicht mit Unterstützung für die eingebaute Anzeige der Weboberfläche unter Verwendung von Qt WebKit oder Qt WebEngine gebaut. @@ -938,7 +944,7 @@ Die Weboberfläche wird stattdessen im Standardwebrowser geöffnet. Settings::restore - + Unable to load certificate "%1" when restoring settings. Fehler beim laden des Zertifikats "%1" beim wiederherstellen der Einstellungen. diff --git a/tray/translations/syncthingtray_en_US.ts b/tray/translations/syncthingtray_en_US.ts index 9353a1a..49fc32b 100644 --- a/tray/translations/syncthingtray_en_US.ts +++ b/tray/translations/syncthingtray_en_US.ts @@ -127,22 +127,22 @@ - + This is achieved by adding a *.desktop file under <i>~/.config/autostart</i> so the setting only affects the current user. - + This is achieved by adding a registry key under <i>HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run</i> so the setting only affects the current user. Note that the startup entry is invalidated when moving <i>syncthingtray.exe</i>. - + This feature has not been implemented for your platform (yet). - + unable to modify startup entry @@ -170,89 +170,95 @@ - + 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. - + Syncthing URL - + Authentication - + User - + Password - + API key - + HTTPS certificate - + Insert values from local Syncthing configuration - + + Errors + + + + Status - + disconnected - + Apply connection settings and try to reconnect with the currently selected config - + Poll interval - + Traffic - - - + + + + ms - + Device statistics - + Reconnect - + no @@ -272,12 +278,12 @@ - + Unable to load specified certificate "%1". - + Instance %1 @@ -384,13 +390,13 @@ - + Syncthing exited with exit code %1 - + Syncthing crashed with exit code %1 @@ -444,7 +450,7 @@ - + Configured to use D-Bus notifications but D-Bus notification daemon seems unavailabe. @@ -452,22 +458,22 @@ QtGui::SettingsDialog - + Tray - + Web view - + Startup - + Settings @@ -508,8 +514,8 @@ - - + + unknown @@ -541,7 +547,7 @@ - + specified unit is either inactive or doesn't exist @@ -549,133 +555,133 @@ QtGui::TrayIcon - + - internal error - + Syncthing notification - + Web UI - + Settings - + Rescan all - + About - + Close - + Error - + Syncthing notification - click to dismiss - + Not connected to Syncthing - trying to reconnect every %1 ms - + Not connected to Syncthing - - + + Disconnected from Syncthing - + Log - + Try to reconnect - + Dismiss - + Show - + Reconnecting ... - + Synchronization is ongoing but at least one directory is out of sync - + At least one directory is out of sync - + Notifications available - + Syncthing is idling - + Syncthing is scanning - + At least one device is paused - + Synchronization is ongoing - + Synchronization of %1 complete - + Synchronization of the following devices complete: @@ -707,7 +713,7 @@ - + Start @@ -739,7 +745,7 @@ - + unknown @@ -867,17 +873,17 @@ For <i>all</i> notifications, checkout the log - + The directory <i>%1</i> does not exist on the local machine. - + The file <i>%1</i> does not exist on the local machine. - + Stop @@ -894,7 +900,7 @@ For <i>all</i> notifications, checkout the log QtGui::WebViewOptionPage - + General @@ -924,7 +930,7 @@ For <i>all</i> notifications, checkout the log - + Syncthing Tray has not been built with vieb view support utilizing either Qt WebKit or Qt WebEngine. The Web UI will be opened in the default web browser instead. @@ -933,7 +939,7 @@ The Web UI will be opened in the default web browser instead. Settings::restore - + Unable to load certificate "%1" when restoring settings.