Tie suppressing notifications to "reconnect integrations" of launcher/service
So suppressing notifications by either the launcher status or service status can be enabled/disabled together with the re-connect tweaking. This makes more sense than having it unconditionally enabled and makes the presence of the feature (and when it is effective) also more visible to users.
This commit is contained in:
parent
525b2c2f94
commit
77cea5aead
|
@ -33,6 +33,7 @@ SyncthingNotifier::SyncthingNotifier(const SyncthingConnection &connection, QObj
|
|||
#endif
|
||||
, m_process(SyncthingProcess::mainInstance())
|
||||
, m_enabledNotifications(SyncthingHighLevelNotification::None)
|
||||
, m_consideredIntegrations(SyncthingStartupIntegration::None)
|
||||
, m_previousStatus(SyncthingStatus::Disconnected)
|
||||
, m_ignoreInavailabilityAfterStart(15)
|
||||
, m_initialized(false)
|
||||
|
@ -132,20 +133,20 @@ bool SyncthingNotifier::isDisconnectRelevant() const
|
|||
}
|
||||
|
||||
// consider process/launcher or systemd unit status
|
||||
if (m_process && m_process->isManuallyStopped()) {
|
||||
if ((m_consideredIntegrations & SyncthingStartupIntegration::Process) && m_process && m_process->isManuallyStopped()) {
|
||||
return false;
|
||||
}
|
||||
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
||||
if (m_service && m_service->isManuallyStopped()) {
|
||||
if ((m_consideredIntegrations & SyncthingStartupIntegration::Service) && m_service && m_service->isManuallyStopped()) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// ignore inavailability after start or standby-wakeup
|
||||
if (m_ignoreInavailabilityAfterStart) {
|
||||
if ((m_process && m_process->isRunning())
|
||||
if (((m_consideredIntegrations & SyncthingStartupIntegration::Process) && m_process && m_process->isRunning())
|
||||
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
||||
&& ((m_service && m_service->isSystemdAvailable()
|
||||
&& (((m_consideredIntegrations & SyncthingStartupIntegration::Service) && m_service && m_service->isSystemdAvailable()
|
||||
&& !m_service->isActiveWithoutSleepFor(m_process->activeSince(), m_ignoreInavailabilityAfterStart))
|
||||
|| !m_process->isActiveFor(m_ignoreInavailabilityAfterStart))
|
||||
#else
|
||||
|
@ -155,7 +156,8 @@ bool SyncthingNotifier::isDisconnectRelevant() const
|
|||
return false;
|
||||
}
|
||||
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
||||
if (m_service && m_service->isRunning() && !m_service->isActiveWithoutSleepFor(m_ignoreInavailabilityAfterStart)) {
|
||||
if ((m_consideredIntegrations & SyncthingStartupIntegration::Service) && m_service && m_service->isRunning()
|
||||
&& !m_service->isActiveWithoutSleepFor(m_ignoreInavailabilityAfterStart)) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -41,9 +41,20 @@ enum class SyncthingHighLevelNotification {
|
|||
SyncthingProcessError = (1 << 5),
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief The SyncthingStartupIntegration enum specifies one or more startup integrations for Syncthing.
|
||||
* \remarks The enum is supposed to be used as flag-enum.
|
||||
*/
|
||||
enum class SyncthingStartupIntegration {
|
||||
None = 0,
|
||||
Process = (1 << 0),
|
||||
Service = (1 << 1),
|
||||
};
|
||||
|
||||
class LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingNotifier : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(SyncthingHighLevelNotification enabledNotifications READ enabledNotifications WRITE setEnabledNotifications)
|
||||
Q_PROPERTY(SyncthingStartupIntegration consideredIntegrations READ consideredIntegrations WRITE setConsideredIntegrations)
|
||||
Q_PROPERTY(bool ignoreInavailabilityAfterStart READ ignoreInavailabilityAfterStart WRITE setIgnoreInavailabilityAfterStart)
|
||||
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
||||
Q_PROPERTY(const SyncthingService *service READ service WRITE setService)
|
||||
|
@ -51,10 +62,11 @@ class LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingNotifier : public QObject {
|
|||
Q_PROPERTY(const SyncthingProcess *process READ process WRITE setProcess)
|
||||
|
||||
public:
|
||||
SyncthingNotifier(const SyncthingConnection &connection, QObject *parent = nullptr);
|
||||
explicit SyncthingNotifier(const SyncthingConnection &connection, QObject *parent = nullptr);
|
||||
|
||||
const SyncthingConnection &connection() const;
|
||||
SyncthingHighLevelNotification enabledNotifications() const;
|
||||
SyncthingStartupIntegration consideredIntegrations() const;
|
||||
unsigned int ignoreInavailabilityAfterStart() const;
|
||||
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
||||
const SyncthingService *service() const;
|
||||
|
@ -63,6 +75,7 @@ public:
|
|||
|
||||
public Q_SLOTS:
|
||||
void setEnabledNotifications(SyncthingHighLevelNotification enabledNotifications);
|
||||
void setConsideredIntegrations(SyncthingStartupIntegration consideredIntegrations);
|
||||
void setIgnoreInavailabilityAfterStart(unsigned int seconds);
|
||||
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
||||
void setService(const SyncthingService *service);
|
||||
|
@ -103,6 +116,7 @@ private:
|
|||
#endif
|
||||
const SyncthingProcess *m_process;
|
||||
SyncthingHighLevelNotification m_enabledNotifications;
|
||||
SyncthingStartupIntegration m_consideredIntegrations;
|
||||
SyncthingStatus m_previousStatus;
|
||||
unsigned int m_ignoreInavailabilityAfterStart;
|
||||
bool m_initialized;
|
||||
|
@ -125,6 +139,14 @@ inline SyncthingHighLevelNotification SyncthingNotifier::enabledNotifications()
|
|||
}
|
||||
|
||||
/*!
|
||||
* \brief Returns which startup integrations are considered for filtering notifications (by default none).
|
||||
*/
|
||||
inline SyncthingStartupIntegration SyncthingNotifier::consideredIntegrations() const
|
||||
{
|
||||
return m_consideredIntegrations;
|
||||
}
|
||||
|
||||
/*!<
|
||||
* \brief Sets which notifications are enabled.
|
||||
*/
|
||||
inline void SyncthingNotifier::setEnabledNotifications(SyncthingHighLevelNotification enabledNotifications)
|
||||
|
@ -132,6 +154,14 @@ inline void SyncthingNotifier::setEnabledNotifications(SyncthingHighLevelNotific
|
|||
m_enabledNotifications = enabledNotifications;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets which startup integrations are considered for filtering notifications.
|
||||
*/
|
||||
inline void SyncthingNotifier::setConsideredIntegrations(SyncthingStartupIntegration consideredIntegrations)
|
||||
{
|
||||
m_consideredIntegrations = consideredIntegrations;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Returns the number of seconds after startup or standby-wakeup to suppress disconnect notifications.
|
||||
*/
|
||||
|
@ -185,5 +215,6 @@ inline void SyncthingNotifier::setProcess(const SyncthingProcess *process)
|
|||
} // namespace Data
|
||||
|
||||
CPP_UTILITIES_MARK_FLAG_ENUM_CLASS(Data, Data::SyncthingHighLevelNotification)
|
||||
CPP_UTILITIES_MARK_FLAG_ENUM_CLASS(Data, Data::SyncthingStartupIntegration)
|
||||
|
||||
#endif // DATA_SYNCTHINGNOTIFIER_H
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
<widget class="QCheckBox" name="enabledCheckBox">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
|
@ -134,9 +133,10 @@
|
|||
<item>
|
||||
<widget class="QCheckBox" name="considerForReconnectCheckBox">
|
||||
<property name="text">
|
||||
<string>Consider process status for reconnect attempts to local instance
|
||||
<string>Consider process status for notifications and reconnect attempts concerning local instance
|
||||
• Don't reconnect when the process is not running
|
||||
• Try to reconnect when starting the process</string>
|
||||
• Try to reconnect when starting the process
|
||||
• Suppress notification about disconnect when Syncthing has been stopped manually</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -159,7 +159,6 @@
|
|||
<widget class="QLabel" name="logLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
|
|
|
@ -528,7 +528,8 @@ void save()
|
|||
*/
|
||||
void Settings::apply(SyncthingNotifier ¬ifier) const
|
||||
{
|
||||
auto notifications(SyncthingHighLevelNotification::None);
|
||||
auto notifications = SyncthingHighLevelNotification::None;
|
||||
auto integrations = SyncthingStartupIntegration::None;
|
||||
if (notifyOn.disconnect) {
|
||||
notifications |= SyncthingHighLevelNotification::ConnectedDisconnected;
|
||||
}
|
||||
|
@ -547,7 +548,14 @@ void Settings::apply(SyncthingNotifier ¬ifier) const
|
|||
if (notifyOn.launcherErrors) {
|
||||
notifications |= SyncthingHighLevelNotification::SyncthingProcessError;
|
||||
}
|
||||
if (launcher.considerForReconnect) {
|
||||
integrations |= SyncthingStartupIntegration::Process;
|
||||
}
|
||||
if (systemd.considerForReconnect) {
|
||||
integrations |= SyncthingStartupIntegration::Service;
|
||||
}
|
||||
notifier.setEnabledNotifications(notifications);
|
||||
notifier.setConsideredIntegrations(integrations);
|
||||
notifier.setIgnoreInavailabilityAfterStart(ignoreInavailabilityAfterStart);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
<string>Systemd</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset theme="preferences-system-services"/>
|
||||
<iconset theme="preferences-system-services">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="showButtonCheckBox">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
|
@ -25,9 +25,10 @@
|
|||
<item>
|
||||
<widget class="QCheckBox" name="considerForReconnectCheckBox">
|
||||
<property name="text">
|
||||
<string>Consider systemd unit status for reconnect attempts to local instance
|
||||
<string>Consider systemd unit status for notifications and reconnect attempts concerning local instance
|
||||
• Don't reconnect when unit not active/running
|
||||
• Try to reconnect when unit becomes active/running</string>
|
||||
• Try to reconnect when unit becomes active/running
|
||||
• Suppress notification about disconnect when Syncthing has been stopped manually</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Reference in New Issue