1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
|
#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>
#include <qtutilities/settingsdialog/qtsettings.h>
#include <QByteArray>
#include <QFrame>
#include <QHash>
#include <QPoint>
#include <QSize>
#include <QString>
#include <QTabWidget>
#include <optional>
#include <tuple>
#include <vector>
namespace QtUtilities {
class QtSettings;
}
namespace Data {
struct SyncthingConfig;
class SyncthingProcess;
class SyncthingLauncher;
class SyncthingNotifier;
class SyncthingConnection;
class SyncthingService;
} // namespace Data
namespace QtGui {
struct ProcessWithConnection;
}
namespace Settings {
struct SYNCTHINGWIDGETS_EXPORT Connection {
Data::SyncthingConnectionSettings primary;
std::vector<Data::SyncthingConnectionSettings> secondary;
bool insecure = false; // not persistent, for testing purposes only
void addConfigFromWizard(const Data::SyncthingConfig &config);
};
struct SYNCTHINGWIDGETS_EXPORT NotifyOn {
bool disconnect = true;
bool internalErrors = true;
bool launcherErrors = true;
bool localSyncComplete = false;
bool remoteSyncComplete = false;
bool syncthingErrors = true;
bool newDeviceConnects = false;
bool newDirectoryShared = false;
};
struct SYNCTHINGWIDGETS_EXPORT Appearance {
bool showTraffic = true;
bool showDownloads = false;
bool showTabTexts = true;
int windowType = 0; // corresponds to TrayMenu::WindowType
QSize trayMenuSize = QSize(575, 475);
int frameStyle = static_cast<int>(QFrame::NoFrame) | static_cast<int>(QFrame::Plain);
int tabPosition = QTabWidget::South;
struct SYNCTHINGWIDGETS_EXPORT Positioning {
QPoint assumedIconPosition;
bool useCursorPosition = true;
bool useAssumedIconPosition = false;
std::optional<QPoint> positionToUse() const;
} positioning;
};
struct SYNCTHINGWIDGETS_EXPORT ToolParameter {
QString path;
QString args;
bool autostart = false;
};
struct SYNCTHINGWIDGETS_EXPORT Launcher {
bool autostartEnabled = false;
bool useLibSyncthing = false;
QString syncthingPath =
#ifdef PLATFORM_WINDOWS
QStringLiteral("syncthing.exe");
#else
QStringLiteral("syncthing");
#endif
QString syncthingArgs = QStringLiteral("serve --no-browser --logflags=3");
QHash<QString, ToolParameter> tools;
bool considerForReconnect = false;
bool showButton = false;
bool stopOnMeteredConnection = false;
#ifdef SYNCTHINGWIDGETS_USE_LIBSYNCTHING
struct SYNCTHINGWIDGETS_EXPORT LibSyncthing {
QString configDir;
QString dataDir;
::LibSyncthing::LogLevel logLevel = ::LibSyncthing::LogLevel::Info;
bool expandPaths = false;
} 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();
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;
};
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
struct SYNCTHINGWIDGETS_EXPORT Systemd {
QString syncthingUnit = QStringLiteral("syncthing.service");
bool systemUnit = false;
bool showButton = false;
bool considerForReconnect = false;
bool stopOnMeteredConnection = false;
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
struct SYNCTHINGWIDGETS_EXPORT WebView {
enum class Mode { Builtin, Browser, Command };
Mode mode;
QString customCommand;
#if defined(SYNCTHINGWIDGETS_USE_WEBENGINE) || defined(SYNCTHINGWIDGETS_USE_WEBKIT)
double zoomFactor = 1.0;
QByteArray geometry;
bool keepRunning = true;
#endif
};
struct SYNCTHINGWIDGETS_EXPORT Settings {
bool firstLaunch = false;
bool fakeFirstLaunch = false; // not persistent, for testing purposes only
bool enableWipFeatures = false; // not persistent, for testing purposes only
bool isPlasmoid = false; // not persistent, set by the Plasmoid
QString error; // not persistent, whether an error occurred on last restore()/save()
Connection connection;
NotifyOn notifyOn;
#ifdef QT_UTILITIES_SUPPORT_DBUS_NOTIFICATIONS
bool dbusNotifications = false;
#endif
unsigned int ignoreInavailabilityAfterStart = 15;
Appearance appearance;
struct SYNCTHINGWIDGETS_EXPORT Icons {
Data::StatusIconSettings status;
Data::StatusIconSettings tray;
bool distinguishTrayIcons = false;
bool preferIconsFromTheme = false;
bool usePaletteForStatus = false;
bool usePaletteForTray = false;
} icons;
Launcher launcher;
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
Systemd systemd;
#endif
WebView webView;
QtUtilities::QtSettings qt;
void apply(Data::SyncthingNotifier ¬ifier) const;
};
SYNCTHINGWIDGETS_EXPORT Settings &values();
SYNCTHINGWIDGETS_EXPORT bool restore();
SYNCTHINGWIDGETS_EXPORT bool save();
} // namespace Settings
#endif // SETTINGS_H
|