syncthingtray/widgets/settings/settings.h

179 lines
5.1 KiB
C
Raw Normal View History

2016-08-25 00:45:32 +02:00
#ifndef SETTINGS_H
#define SETTINGS_H
#include "../global.h"
#ifdef SYNCTHINGWIDGETS_USE_LIBSYNCTHING
#include <syncthing/interface.h>
#endif
#include <syncthingconnector/syncthingconnectionsettings.h>
#include <syncthingmodel/syncthingicons.h>
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>
#include <QHash>
#include <QPoint>
2017-05-01 03:34:43 +02:00
#include <QSize>
#include <QString>
#include <QTabWidget>
2016-09-03 20:14:52 +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;
}
namespace Data {
class SyncthingProcess;
class SyncthingLauncher;
class SyncthingNotifier;
class SyncthingConnection;
class SyncthingService;
} // namespace Data
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;
};
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;
bool launcherErrors = true;
bool localSyncComplete = false;
bool remoteSyncComplete = false;
2016-11-02 20:03:38 +01:00
bool syncthingErrors = true;
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;
QSize trayMenuSize = QSize(450, 400);
int frameStyle = static_cast<int>(QFrame::NoFrame) | static_cast<int>(QFrame::Plain);
2016-11-02 20:03:38 +01:00
int tabPosition = QTabWidget::South;
bool brightTextColors = false;
2019-07-28 21:34:51 +02:00
struct SYNCTHINGWIDGETS_EXPORT Positioning {
QPoint assumedIconPosition;
bool useCursorPosition = true;
QPoint positionToUse() const;
} positioning;
2016-11-02 20:03:38 +01:00
};
2017-05-01 03:34:43 +02:00
struct SYNCTHINGWIDGETS_EXPORT ToolParameter {
QString path;
QString args;
bool autostart = false;
};
2017-05-01 03:34:43 +02:00
struct SYNCTHINGWIDGETS_EXPORT Launcher {
bool autostartEnabled = false;
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
QString syncthingArgs = QStringLiteral("-no-browser -no-console -no-restart -logflags=3");
QHash<QString, ToolParameter> tools;
bool considerForReconnect = false;
bool showButton = false;
#ifdef SYNCTHINGWIDGETS_USE_LIBSYNCTHING
2019-07-28 21:34:51 +02:00
struct SYNCTHINGWIDGETS_EXPORT LibSyncthing {
QString configDir;
QString dataDir;
::LibSyncthing::LogLevel logLevel = ::LibSyncthing::LogLevel::Info;
} libSyncthing;
#endif
static Data::SyncthingProcess &toolProcess(const QString &tool);
static Data::SyncthingConnection *connectionForLauncher(Data::SyncthingLauncher *launcher);
static std::vector<QtGui::ProcessWithConnection> allProcesses();
void autostart() const;
static void terminate();
2019-07-28 21:34:51 +02:00
struct SYNCTHINGWIDGETS_EXPORT LauncherStatus {
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
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
2017-05-01 03:34:43 +02:00
struct SYNCTHINGWIDGETS_EXPORT Systemd {
QString syncthingUnit = QStringLiteral("syncthing.service");
bool systemUnit = false;
bool showButton = false;
bool considerForReconnect = false;
2019-07-28 21:34:51 +02:00
struct SYNCTHINGWIDGETS_EXPORT ServiceStatus {
bool relevant = false;
bool running = false;
bool consideredForReconnect = false;
bool showStartStopButton = false;
bool userService = true;
};
void setupService(Data::SyncthingService &) const;
ServiceStatus apply(Data::SyncthingConnection &connection, const Data::SyncthingConnectionSettings *currentConnectionSettings,
bool preventReconnect = false) const;
ServiceStatus status(Data::SyncthingConnection &connection) const;
};
#endif
#if defined(SYNCTHINGWIDGETS_USE_WEBENGINE) || defined(SYNCTHINGWIDGETS_USE_WEBKIT)
2017-05-01 03:34:43 +02:00
struct SYNCTHINGWIDGETS_EXPORT WebView {
2016-11-02 20:03:38 +01:00
bool disabled = false;
double zoomFactor = 1.0;
QByteArray geometry;
bool keepRunning = true;
};
2016-08-25 00:45:32 +02:00
#endif
2017-05-01 03:34:43 +02:00
struct SYNCTHINGWIDGETS_EXPORT Settings {
2016-11-02 20:03:38 +01:00
bool firstLaunch = false;
Connection connection;
NotifyOn notifyOn;
2016-12-11 17:58:58 +01:00
#ifdef QT_UTILITIES_SUPPORT_DBUS_NOTIFICATIONS
bool dbusNotifications = false;
#endif
unsigned int ignoreInavailabilityAfterStart = 15;
2016-11-02 20:03:38 +01:00
Appearance appearance;
struct SYNCTHINGWIDGETS_EXPORT Icons {
Data::StatusIconSettings status;
Data::StatusIconSettings tray;
bool distinguishTrayIcons = false;
} icons;
2016-11-02 20:03:38 +01:00
Launcher launcher;
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
Systemd systemd;
#endif
#if defined(SYNCTHINGWIDGETS_USE_WEBENGINE) || defined(SYNCTHINGWIDGETS_USE_WEBKIT)
2016-11-02 20:03:38 +01:00
WebView webView;
#endif
2019-06-10 22:48:26 +02:00
QtUtilities::QtSettings qt;
void apply(Data::SyncthingNotifier &notifier) const;
2016-11-02 20:03:38 +01:00
};
2016-08-25 00:45:32 +02:00
SYNCTHINGWIDGETS_EXPORT Settings &values();
SYNCTHINGWIDGETS_EXPORT void restore();
SYNCTHINGWIDGETS_EXPORT void save();
} // namespace Settings
2016-08-25 00:45:32 +02:00
#endif // SETTINGS_H