2016-08-25 00:45:32 +02:00
|
|
|
#ifndef SETTINGS_H
|
|
|
|
#define SETTINGS_H
|
|
|
|
|
2021-02-03 00:01:34 +01:00
|
|
|
#include "../global.h"
|
|
|
|
|
|
|
|
#ifdef SYNCTHINGWIDGETS_USE_LIBSYNCTHING
|
|
|
|
#include <syncthing/interface.h>
|
|
|
|
#endif
|
|
|
|
|
2021-01-25 19:48:11 +01:00
|
|
|
#include <syncthingconnector/syncthingconnectionsettings.h>
|
|
|
|
#include <syncthingmodel/syncthingicons.h>
|
2016-09-29 21:19:54 +02:00
|
|
|
|
2016-11-02 20:03:38 +01:00
|
|
|
#include <qtutilities/settingsdialog/qtsettings.h>
|
|
|
|
|
2016-09-03 20:14:52 +02:00
|
|
|
#include <QByteArray>
|
2016-11-02 20:03:38 +01:00
|
|
|
#include <QFrame>
|
2017-03-17 00:38:42 +01:00
|
|
|
#include <QHash>
|
2019-06-22 17:28:09 +02:00
|
|
|
#include <QPoint>
|
2017-05-01 03:34:43 +02:00
|
|
|
#include <QSize>
|
|
|
|
#include <QString>
|
|
|
|
#include <QTabWidget>
|
2016-09-03 20:14:52 +02:00
|
|
|
|
2022-11-29 23:32:14 +01:00
|
|
|
#include <optional>
|
2018-04-02 20:26:00 +02:00
|
|
|
#include <tuple>
|
2016-09-03 20:14:52 +02:00
|
|
|
#include <vector>
|
2016-08-25 00:45:32 +02:00
|
|
|
|
2019-06-10 22:48:26 +02:00
|
|
|
namespace QtUtilities {
|
2016-08-25 00:45:32 +02:00
|
|
|
class QtSettings;
|
|
|
|
}
|
|
|
|
|
2017-03-17 00:38:42 +01:00
|
|
|
namespace Data {
|
2022-10-02 14:41:28 +02:00
|
|
|
struct SyncthingConfig;
|
2017-03-17 00:38:42 +01:00
|
|
|
class SyncthingProcess;
|
2021-07-15 02:38:26 +02:00
|
|
|
class SyncthingLauncher;
|
2018-03-31 22:31:28 +02:00
|
|
|
class SyncthingNotifier;
|
2018-04-02 20:26:00 +02:00
|
|
|
class SyncthingConnection;
|
2019-12-18 00:18:46 +01:00
|
|
|
class SyncthingService;
|
2018-03-31 22:31:28 +02:00
|
|
|
} // namespace Data
|
2017-03-17 00:38:42 +01:00
|
|
|
|
2021-07-15 02:38:26 +02:00
|
|
|
namespace QtGui {
|
|
|
|
struct ProcessWithConnection;
|
|
|
|
}
|
|
|
|
|
2016-08-25 00:45:32 +02:00
|
|
|
namespace Settings {
|
|
|
|
|
2017-05-01 03:34:43 +02:00
|
|
|
struct SYNCTHINGWIDGETS_EXPORT Connection {
|
2016-11-02 20:03:38 +01:00
|
|
|
Data::SyncthingConnectionSettings primary;
|
|
|
|
std::vector<Data::SyncthingConnectionSettings> secondary;
|
2022-10-02 14:41:28 +02:00
|
|
|
|
|
|
|
void addConfigFromWizard(const Data::SyncthingConfig &config);
|
2016-11-02 20:03:38 +01:00
|
|
|
};
|
|
|
|
|
2017-05-01 03:34:43 +02:00
|
|
|
struct SYNCTHINGWIDGETS_EXPORT NotifyOn {
|
2016-11-02 20:03:38 +01:00
|
|
|
bool disconnect = true;
|
|
|
|
bool internalErrors = true;
|
2019-07-12 20:26:56 +02:00
|
|
|
bool launcherErrors = true;
|
2018-03-31 22:31:28 +02:00
|
|
|
bool localSyncComplete = false;
|
|
|
|
bool remoteSyncComplete = false;
|
2016-11-02 20:03:38 +01:00
|
|
|
bool syncthingErrors = true;
|
2018-05-01 22:27:03 +02:00
|
|
|
bool newDeviceConnects = false;
|
|
|
|
bool newDirectoryShared = false;
|
2016-11-02 20:03:38 +01:00
|
|
|
};
|
|
|
|
|
2017-05-01 03:34:43 +02:00
|
|
|
struct SYNCTHINGWIDGETS_EXPORT Appearance {
|
2016-11-02 20:03:38 +01:00
|
|
|
bool showTraffic = true;
|
2022-09-05 21:56:22 +02:00
|
|
|
bool showTabTexts = true;
|
2023-02-18 21:27:09 +01:00
|
|
|
int windowType = 0; // corresponds to TrayMenu::WindowType
|
2022-09-05 21:19:22 +02:00
|
|
|
QSize trayMenuSize = QSize(575, 475);
|
2021-03-23 15:23:19 +01:00
|
|
|
int frameStyle = static_cast<int>(QFrame::NoFrame) | static_cast<int>(QFrame::Plain);
|
2016-11-02 20:03:38 +01:00
|
|
|
int tabPosition = QTabWidget::South;
|
2019-07-28 21:34:51 +02:00
|
|
|
struct SYNCTHINGWIDGETS_EXPORT Positioning {
|
2019-06-22 17:28:09 +02:00
|
|
|
QPoint assumedIconPosition;
|
|
|
|
bool useCursorPosition = true;
|
2022-11-29 23:32:14 +01:00
|
|
|
bool useAssumedIconPosition = false;
|
|
|
|
std::optional<QPoint> positionToUse() const;
|
2019-06-22 17:28:09 +02:00
|
|
|
} positioning;
|
2016-11-02 20:03:38 +01:00
|
|
|
};
|
|
|
|
|
2017-05-01 03:34:43 +02:00
|
|
|
struct SYNCTHINGWIDGETS_EXPORT ToolParameter {
|
2017-03-17 00:38:42 +01:00
|
|
|
QString path;
|
|
|
|
QString args;
|
|
|
|
bool autostart = false;
|
|
|
|
};
|
|
|
|
|
2017-05-01 03:34:43 +02:00
|
|
|
struct SYNCTHINGWIDGETS_EXPORT Launcher {
|
2019-07-12 20:26:56 +02:00
|
|
|
bool autostartEnabled = false;
|
2018-04-18 23:27:45 +02:00
|
|
|
bool useLibSyncthing = false;
|
2016-11-02 20:03:38 +01:00
|
|
|
QString syncthingPath =
|
|
|
|
#ifdef PLATFORM_WINDOWS
|
2017-05-01 03:34:43 +02:00
|
|
|
QStringLiteral("syncthing.exe");
|
2016-11-02 20:03:38 +01:00
|
|
|
#else
|
2017-05-01 03:34:43 +02:00
|
|
|
QStringLiteral("syncthing");
|
2016-11-02 20:03:38 +01:00
|
|
|
#endif
|
2023-01-25 20:55:57 +01:00
|
|
|
QString syncthingArgs = QStringLiteral("-no-browser -no-restart -logflags=3");
|
2017-03-17 00:38:42 +01:00
|
|
|
QHash<QString, ToolParameter> tools;
|
2018-04-02 20:26:00 +02:00
|
|
|
bool considerForReconnect = false;
|
2019-07-12 20:26:56 +02:00
|
|
|
bool showButton = false;
|
|
|
|
|
2021-02-03 00:01:34 +01:00
|
|
|
#ifdef SYNCTHINGWIDGETS_USE_LIBSYNCTHING
|
2019-07-28 21:34:51 +02:00
|
|
|
struct SYNCTHINGWIDGETS_EXPORT LibSyncthing {
|
2019-07-17 17:53:36 +02:00
|
|
|
QString configDir;
|
2020-05-05 19:01:05 +02:00
|
|
|
QString dataDir;
|
2020-01-20 22:30:42 +01:00
|
|
|
::LibSyncthing::LogLevel logLevel = ::LibSyncthing::LogLevel::Info;
|
2019-07-17 17:53:36 +02:00
|
|
|
} libSyncthing;
|
2021-02-03 00:01:34 +01:00
|
|
|
#endif
|
2019-07-17 17:53:36 +02:00
|
|
|
|
2017-03-17 00:38:42 +01:00
|
|
|
static Data::SyncthingProcess &toolProcess(const QString &tool);
|
2021-07-15 02:38:26 +02:00
|
|
|
static Data::SyncthingConnection *connectionForLauncher(Data::SyncthingLauncher *launcher);
|
|
|
|
static std::vector<QtGui::ProcessWithConnection> allProcesses();
|
2017-03-17 00:38:42 +01:00
|
|
|
void autostart() const;
|
|
|
|
static void terminate();
|
2019-07-28 21:34:51 +02:00
|
|
|
struct SYNCTHINGWIDGETS_EXPORT LauncherStatus {
|
2019-07-12 20:26:56 +02:00
|
|
|
bool relevant = false;
|
|
|
|
bool running = false;
|
|
|
|
bool consideredForReconnect = false;
|
|
|
|
bool showStartStopButton = false;
|
|
|
|
};
|
|
|
|
LauncherStatus apply(Data::SyncthingConnection &connection, const Data::SyncthingConnectionSettings *currentConnectionSettings,
|
|
|
|
bool preventReconnect = false) const;
|
|
|
|
LauncherStatus status(Data::SyncthingConnection &connection) const;
|
2016-11-02 20:03:38 +01:00
|
|
|
};
|
2016-08-25 00:45:32 +02:00
|
|
|
|
2016-12-18 16:50:35 +01:00
|
|
|
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
2017-05-01 03:34:43 +02:00
|
|
|
struct SYNCTHINGWIDGETS_EXPORT Systemd {
|
2016-12-18 16:50:35 +01:00
|
|
|
QString syncthingUnit = QStringLiteral("syncthing.service");
|
2019-12-18 00:18:46 +01:00
|
|
|
bool systemUnit = false;
|
2016-12-27 16:16:12 +01:00
|
|
|
bool showButton = false;
|
|
|
|
bool considerForReconnect = false;
|
2018-04-02 20:26:00 +02:00
|
|
|
|
2019-07-28 21:34:51 +02:00
|
|
|
struct SYNCTHINGWIDGETS_EXPORT ServiceStatus {
|
2019-07-12 20:26:56 +02:00
|
|
|
bool relevant = false;
|
|
|
|
bool running = false;
|
|
|
|
bool consideredForReconnect = false;
|
|
|
|
bool showStartStopButton = false;
|
2020-02-02 19:51:16 +01:00
|
|
|
bool userService = true;
|
2019-07-12 20:26:56 +02:00
|
|
|
};
|
2019-12-18 00:18:46 +01:00
|
|
|
void setupService(Data::SyncthingService &) const;
|
2019-07-12 20:26:56 +02:00
|
|
|
ServiceStatus apply(Data::SyncthingConnection &connection, const Data::SyncthingConnectionSettings *currentConnectionSettings,
|
2018-04-02 20:26:00 +02:00
|
|
|
bool preventReconnect = false) const;
|
2019-07-12 20:26:56 +02:00
|
|
|
ServiceStatus status(Data::SyncthingConnection &connection) const;
|
2016-12-18 16:50:35 +01:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2017-05-01 03:34:43 +02:00
|
|
|
struct SYNCTHINGWIDGETS_EXPORT WebView {
|
2023-03-27 20:13:49 +02:00
|
|
|
enum class Mode { Builtin, Browser, Command };
|
|
|
|
Mode mode;
|
|
|
|
QString customCommand;
|
|
|
|
#if defined(SYNCTHINGWIDGETS_USE_WEBENGINE) || defined(SYNCTHINGWIDGETS_USE_WEBKIT)
|
2016-11-02 20:03:38 +01:00
|
|
|
double zoomFactor = 1.0;
|
|
|
|
QByteArray geometry;
|
|
|
|
bool keepRunning = true;
|
2016-08-25 00:45:32 +02:00
|
|
|
#endif
|
2023-03-27 20:13:49 +02:00
|
|
|
};
|
2016-08-25 00:45:32 +02:00
|
|
|
|
2017-05-01 03:34:43 +02:00
|
|
|
struct SYNCTHINGWIDGETS_EXPORT Settings {
|
2016-11-02 20:03:38 +01:00
|
|
|
bool firstLaunch = false;
|
2022-08-06 21:08:55 +02:00
|
|
|
bool fakeFirstLaunch = false; // not persistent, for testing purposes only
|
2022-08-22 21:59:34 +02:00
|
|
|
bool enableWipFeatures = false; // not persistent, for testing purposes only
|
2022-10-08 22:20:06 +02:00
|
|
|
bool isPlasmoid = false; // not persistent, set by the Plasmoid
|
2023-02-17 19:20:10 +01:00
|
|
|
QString error; // not persistent, whether an error occured on last restore()/save()
|
2016-11-02 20:03:38 +01:00
|
|
|
Connection connection;
|
|
|
|
NotifyOn notifyOn;
|
2016-12-11 17:58:58 +01:00
|
|
|
#ifdef QT_UTILITIES_SUPPORT_DBUS_NOTIFICATIONS
|
|
|
|
bool dbusNotifications = false;
|
|
|
|
#endif
|
2017-01-14 02:12:38 +01:00
|
|
|
unsigned int ignoreInavailabilityAfterStart = 15;
|
2016-11-02 20:03:38 +01:00
|
|
|
Appearance appearance;
|
2019-07-31 20:16:43 +02:00
|
|
|
struct SYNCTHINGWIDGETS_EXPORT Icons {
|
|
|
|
Data::StatusIconSettings status;
|
|
|
|
Data::StatusIconSettings tray;
|
|
|
|
bool distinguishTrayIcons = false;
|
2022-10-03 14:40:14 +02:00
|
|
|
bool preferIconsFromTheme = false;
|
2019-07-31 20:16:43 +02:00
|
|
|
} icons;
|
2016-11-02 20:03:38 +01:00
|
|
|
Launcher launcher;
|
2016-12-18 16:50:35 +01:00
|
|
|
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
|
|
|
Systemd systemd;
|
|
|
|
#endif
|
2016-11-02 20:03:38 +01:00
|
|
|
WebView webView;
|
2019-06-10 22:48:26 +02:00
|
|
|
QtUtilities::QtSettings qt;
|
2018-04-02 20:26:00 +02:00
|
|
|
|
|
|
|
void apply(Data::SyncthingNotifier ¬ifier) const;
|
2016-11-02 20:03:38 +01:00
|
|
|
};
|
2016-08-25 00:45:32 +02:00
|
|
|
|
2020-01-29 18:51:10 +01:00
|
|
|
SYNCTHINGWIDGETS_EXPORT Settings &values();
|
2023-02-17 19:20:10 +01:00
|
|
|
SYNCTHINGWIDGETS_EXPORT bool restore();
|
|
|
|
SYNCTHINGWIDGETS_EXPORT bool save();
|
2017-09-17 21:48:15 +02:00
|
|
|
} // namespace Settings
|
2016-08-25 00:45:32 +02:00
|
|
|
|
|
|
|
#endif // SETTINGS_H
|