syncthingtray/widgets/settings/settings.h

129 lines
3.3 KiB
C
Raw Normal View History

2016-08-25 00:45:32 +02:00
#ifndef SETTINGS_H
#define SETTINGS_H
#include "../../connector/syncthingconnectionsettings.h"
2017-05-01 03:34:43 +02:00
#include "../global.h"
2016-11-02 20:03:38 +01:00
#include <qtutilities/settingsdialog/qtsettings.h>
2016-08-25 00:45:32 +02:00
#include <c++utilities/conversion/types.h>
2016-09-03 20:14:52 +02:00
#include <QByteArray>
2016-11-02 20:03:38 +01:00
#include <QFrame>
#include <QHash>
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
namespace Dialogs {
class QtSettings;
}
namespace Data {
class SyncthingProcess;
class SyncthingNotifier;
class SyncthingConnection;
} // namespace Data
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 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 = QFrame::NoFrame | QFrame::Plain;
2016-11-02 20:03:38 +01:00
int tabPosition = QTabWidget::South;
bool brightTextColors = false;
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 {
2016-11-02 20:03:38 +01:00
bool enabled = 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;
QHash<QString, ToolParameter> tools;
bool considerForReconnect = false;
static Data::SyncthingProcess &toolProcess(const QString &tool);
static std::vector<Data::SyncthingProcess *> allProcesses();
void autostart() const;
static void terminate();
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 showButton = false;
bool considerForReconnect = false;
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
std::tuple<bool, bool> apply(Data::SyncthingConnection &connection, const Data::SyncthingConnectionSettings *currentConnectionSettings,
bool preventReconnect = false) const;
#endif
};
#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;
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
Dialogs::QtSettings qt;
void apply(Data::SyncthingNotifier &notifier) const;
2016-11-02 20:03:38 +01:00
};
2016-08-25 00:45:32 +02:00
Settings SYNCTHINGWIDGETS_EXPORT &values();
void SYNCTHINGWIDGETS_EXPORT restore();
void SYNCTHINGWIDGETS_EXPORT save();
} // namespace Settings
2016-08-25 00:45:32 +02:00
#endif // SETTINGS_H