Distinguish between local an remote sync in settings
This commit is contained in:
parent
023279142b
commit
d2eb4addd9
|
@ -94,7 +94,8 @@ void SyncthingNotifier::emitSyncComplete(ChronoUtilities::DateTime when, const S
|
|||
VAR_UNUSED(index)
|
||||
|
||||
// discard event if not enabled
|
||||
if ((m_enabledNotifications & SyncthingHighLevelNotification::SyncComplete) == 0 || !m_initialized) {
|
||||
if (!m_initialized || (!remoteDev && (m_enabledNotifications & SyncthingHighLevelNotification::LocalSyncComplete) == 0)
|
||||
|| (remoteDev && (m_enabledNotifications & SyncthingHighLevelNotification::LocalSyncComplete) == 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,8 @@ struct SyncthingDev;
|
|||
enum class SyncthingHighLevelNotification {
|
||||
None = 0x0,
|
||||
ConnectedDisconnected = 0x1,
|
||||
SyncComplete = 0x2,
|
||||
LocalSyncComplete = 0x2,
|
||||
RemoteSyncComplete = 0x4,
|
||||
};
|
||||
|
||||
/// \cond
|
||||
|
|
|
@ -72,14 +72,15 @@ QString syncCompleteString(const std::vector<const SyncthingDir *> &completedDir
|
|||
return QString();
|
||||
case 1:
|
||||
if (devName.isEmpty()) {
|
||||
return QCoreApplication::translate("Data::Utils", "Synchronization of %1 complete").arg(completedDirs.front()->displayName());
|
||||
return QCoreApplication::translate("Data::Utils", "Synchronization of local directory %1 complete")
|
||||
.arg(completedDirs.front()->displayName());
|
||||
}
|
||||
return QCoreApplication::translate("Data::Utils", "Synchronization of %1 on %2 complete").arg(completedDirs.front()->displayName(), devName);
|
||||
default:;
|
||||
}
|
||||
const auto names(things(completedDirs, [](const auto *dir) { return dir->displayName(); }));
|
||||
if (devName.isEmpty()) {
|
||||
return QCoreApplication::translate("Data::Utils", "Synchronization of the following directories complete:\n")
|
||||
return QCoreApplication::translate("Data::Utils", "Synchronization of the following local directories complete:\n")
|
||||
+ names.join(QStringLiteral(", "));
|
||||
}
|
||||
return QCoreApplication::translate("Data::Utils", "Synchronization of the following directories on %1 complete:\n").arg(devName)
|
||||
|
|
|
@ -311,14 +311,7 @@ void SyncthingApplet::handleSettingsChanged()
|
|||
const auto &settings(Settings::values());
|
||||
|
||||
// apply notifiction settings
|
||||
auto notifications(SyncthingHighLevelNotification::None);
|
||||
if (settings.notifyOn.disconnect) {
|
||||
notifications |= SyncthingHighLevelNotification::ConnectedDisconnected;
|
||||
}
|
||||
if (settings.notifyOn.syncComplete) {
|
||||
notifications |= SyncthingHighLevelNotification::SyncComplete;
|
||||
}
|
||||
m_notifier.setEnabledNotifications(notifications);
|
||||
settings.notifyOn.apply(m_notifier);
|
||||
|
||||
// apply appearance settings
|
||||
setSize(config.readEntry<QSize>("size", QSize(25, 25)));
|
||||
|
|
|
@ -365,14 +365,7 @@ void TrayWidget::applySettings(const QString &connectionConfig)
|
|||
const bool reconnectRequired = m_connection.applySettings(*m_selectedConnection);
|
||||
|
||||
// apply notifiction settings
|
||||
auto notifications(SyncthingHighLevelNotification::None);
|
||||
if (settings.notifyOn.disconnect) {
|
||||
notifications |= SyncthingHighLevelNotification::ConnectedDisconnected;
|
||||
}
|
||||
if (settings.notifyOn.syncComplete) {
|
||||
notifications |= SyncthingHighLevelNotification::SyncComplete;
|
||||
}
|
||||
m_notifier.setEnabledNotifications(notifications);
|
||||
settings.notifyOn.apply(m_notifier);
|
||||
|
||||
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
||||
// reconnect to apply settings considering systemd
|
||||
|
|
|
@ -38,9 +38,16 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="notifyOnSyncCompleteCheckBox">
|
||||
<widget class="QCheckBox" name="notifyOnLocalSyncCompleteCheckBox">
|
||||
<property name="text">
|
||||
<string>sync complete</string>
|
||||
<string>sync of local directory complete</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="notifyOnRemoteSyncCompleteCheckBox">
|
||||
<property name="text">
|
||||
<string>sync of remote directory complete</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "./settings.h"
|
||||
#include "../../connector/syncthingnotifier.h"
|
||||
#include "../../connector/syncthingprocess.h"
|
||||
|
||||
// use meta-data of syncthingtray application here
|
||||
|
@ -155,7 +156,8 @@ void restore()
|
|||
auto ¬ifyOn = v.notifyOn;
|
||||
notifyOn.disconnect = settings.value(QStringLiteral("notifyOnDisconnect"), notifyOn.disconnect).toBool();
|
||||
notifyOn.internalErrors = settings.value(QStringLiteral("notifyOnErrors"), notifyOn.internalErrors).toBool();
|
||||
notifyOn.syncComplete = settings.value(QStringLiteral("notifyOnSyncComplete"), notifyOn.syncComplete).toBool();
|
||||
notifyOn.localSyncComplete = settings.value(QStringLiteral("notifyOnLocalSyncComplete"), notifyOn.localSyncComplete).toBool();
|
||||
notifyOn.remoteSyncComplete = settings.value(QStringLiteral("notifyOnRemoteSyncComplete"), notifyOn.remoteSyncComplete).toBool();
|
||||
notifyOn.syncthingErrors = settings.value(QStringLiteral("showSyncthingNotifications"), notifyOn.syncthingErrors).toBool();
|
||||
#ifdef QT_UTILITIES_SUPPORT_DBUS_NOTIFICATIONS
|
||||
v.dbusNotifications = settings.value(QStringLiteral("dbusNotifications"), DBusNotification::isAvailable()).toBool();
|
||||
|
@ -239,7 +241,8 @@ void save()
|
|||
const auto ¬ifyOn = v.notifyOn;
|
||||
settings.setValue(QStringLiteral("notifyOnDisconnect"), notifyOn.disconnect);
|
||||
settings.setValue(QStringLiteral("notifyOnErrors"), notifyOn.internalErrors);
|
||||
settings.setValue(QStringLiteral("notifyOnSyncComplete"), notifyOn.syncComplete);
|
||||
settings.setValue(QStringLiteral("notifyOnLocalSyncComplete"), notifyOn.localSyncComplete);
|
||||
settings.setValue(QStringLiteral("notifyOnRemoteSyncComplete"), notifyOn.remoteSyncComplete);
|
||||
settings.setValue(QStringLiteral("showSyncthingNotifications"), notifyOn.syncthingErrors);
|
||||
#ifdef QT_UTILITIES_SUPPORT_DBUS_NOTIFICATIONS
|
||||
settings.setValue(QStringLiteral("dbusNotifications"), v.dbusNotifications);
|
||||
|
@ -288,4 +291,23 @@ void save()
|
|||
|
||||
v.qt.save(settings);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Applies the notification settings on the specified \a notifier.
|
||||
*/
|
||||
void NotifyOn::apply(SyncthingNotifier ¬ifier) const
|
||||
{
|
||||
auto notifications(SyncthingHighLevelNotification::None);
|
||||
if (disconnect) {
|
||||
notifications |= SyncthingHighLevelNotification::ConnectedDisconnected;
|
||||
}
|
||||
if (localSyncComplete) {
|
||||
notifications |= SyncthingHighLevelNotification::LocalSyncComplete;
|
||||
}
|
||||
if (remoteSyncComplete) {
|
||||
notifications |= SyncthingHighLevelNotification::RemoteSyncComplete;
|
||||
}
|
||||
notifier.setEnabledNotifications(notifications);
|
||||
}
|
||||
|
||||
} // namespace Settings
|
||||
|
|
|
@ -23,7 +23,8 @@ class QtSettings;
|
|||
|
||||
namespace Data {
|
||||
class SyncthingProcess;
|
||||
}
|
||||
class SyncthingNotifier;
|
||||
} // namespace Data
|
||||
|
||||
namespace Settings {
|
||||
|
||||
|
@ -35,8 +36,11 @@ struct SYNCTHINGWIDGETS_EXPORT Connection {
|
|||
struct SYNCTHINGWIDGETS_EXPORT NotifyOn {
|
||||
bool disconnect = true;
|
||||
bool internalErrors = true;
|
||||
bool syncComplete = false;
|
||||
bool localSyncComplete = false;
|
||||
bool remoteSyncComplete = false;
|
||||
bool syncthingErrors = true;
|
||||
|
||||
void apply(Data::SyncthingNotifier ¬ifier) const;
|
||||
};
|
||||
|
||||
struct SYNCTHINGWIDGETS_EXPORT Appearance {
|
||||
|
|
|
@ -355,7 +355,8 @@ bool NotificationsOptionPage::apply()
|
|||
auto ¬ifyOn = values().notifyOn;
|
||||
notifyOn.disconnect = ui()->notifyOnDisconnectCheckBox->isChecked();
|
||||
notifyOn.internalErrors = ui()->notifyOnErrorsCheckBox->isChecked();
|
||||
notifyOn.syncComplete = ui()->notifyOnSyncCompleteCheckBox->isChecked();
|
||||
notifyOn.localSyncComplete = ui()->notifyOnLocalSyncCompleteCheckBox->isChecked();
|
||||
notifyOn.remoteSyncComplete = ui()->notifyOnRemoteSyncCompleteCheckBox->isChecked();
|
||||
notifyOn.syncthingErrors = ui()->showSyncthingNotificationsCheckBox->isChecked();
|
||||
#ifdef QT_UTILITIES_SUPPORT_DBUS_NOTIFICATIONS
|
||||
if ((values().dbusNotifications = ui()->dbusRadioButton->isChecked()) && !DBusNotification::isAvailable()) {
|
||||
|
@ -373,7 +374,8 @@ void NotificationsOptionPage::reset()
|
|||
const auto ¬ifyOn = values().notifyOn;
|
||||
ui()->notifyOnDisconnectCheckBox->setChecked(notifyOn.disconnect);
|
||||
ui()->notifyOnErrorsCheckBox->setChecked(notifyOn.internalErrors);
|
||||
ui()->notifyOnSyncCompleteCheckBox->setChecked(notifyOn.syncComplete);
|
||||
ui()->notifyOnLocalSyncCompleteCheckBox->setChecked(notifyOn.localSyncComplete);
|
||||
ui()->notifyOnRemoteSyncCompleteCheckBox->setChecked(notifyOn.remoteSyncComplete);
|
||||
ui()->showSyncthingNotificationsCheckBox->setChecked(notifyOn.syncthingErrors);
|
||||
#ifdef QT_UTILITIES_SUPPORT_DBUS_NOTIFICATIONS
|
||||
(values().dbusNotifications ? ui()->dbusRadioButton : ui()->qtRadioButton)->setChecked(true);
|
||||
|
|
Loading…
Reference in New Issue