-
Notifications
You must be signed in to change notification settings - Fork 780
/
settings.h
163 lines (132 loc) · 4.03 KB
/
settings.h
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
/****************************************************************************
**
** Copyright (C) 2015-2016 Oleg Shparber
** Contact: https://go.zealdocs.org/l/contact
**
** This file is part of Zeal.
**
** Zeal is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Zeal is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Zeal. If not, see <https://www.gnu.org/licenses/>.
**
****************************************************************************/
#ifndef ZEAL_CORE_SETTINGS_H
#define ZEAL_CORE_SETTINGS_H
#include <QDataStream>
#include <QKeySequence>
#include <QObject>
class QSettings;
namespace Zeal {
namespace Core {
class Settings final : public QObject
{
Q_OBJECT
Q_DISABLE_COPY(Settings)
public:
/* This public members are here just for simplification and should go away
* once a more advanced settings management come in place.
*/
// Startup
bool startMinimized;
bool checkForUpdate;
// TODO: bool restoreLastState;
// System Tray
bool showSystrayIcon;
bool minimizeToSystray;
bool hideOnClose;
// Global Shortcuts
QKeySequence showShortcut;
// TODO: QKeySequence searchSelectedTextShortcut;
// Tabs Behavior
bool openNewTabAfterActive;
// Search
bool isFuzzySearchEnabled;
// Content
QString defaultFontFamily;
QString serifFontFamily;
QString sansSerifFontFamily;
QString fixedFontFamily;
int defaultFontSize;
int defaultFixedFontSize;
int minimumFontSize;
enum class ExternalLinkPolicy : unsigned int {
Ask = 0,
Open,
OpenInSystemBrowser
};
Q_ENUM(ExternalLinkPolicy)
ExternalLinkPolicy externalLinkPolicy = ExternalLinkPolicy::Ask;
enum class ContentAppearance : unsigned int {
Automatic = 0,
Light,
Dark
};
Q_ENUM(ContentAppearance)
ContentAppearance contentAppearance = ContentAppearance::Automatic;
bool isHighlightOnNavigateEnabled;
QString customCssFile;
bool isSmoothScrollingEnabled;
// Network
enum ProxyType : unsigned int {
None = 0,
System = 1,
Http = 3,
Socks5 = 4
};
Q_ENUM(ProxyType)
bool isIgnoreSSLErrorsEnabled;
// Internal
// --------
// InstallId is a UUID used to indentify a Zeal installation. Created on first start or after
// a settings wipe. It is not attached to user hardware or software, and is sent exclusevely
// to *.zealdocs.org hosts.
QString installId;
ProxyType proxyType = ProxyType::System;
QString proxyHost;
quint16 proxyPort;
bool proxyAuthenticate;
QString proxyUserName;
QString proxyPassword;
// Other
QString docsetPath;
// State
QByteArray windowGeometry;
QByteArray verticalSplitterGeometry;
QByteArray tocSplitterState;
explicit Settings(QObject *parent = nullptr);
~Settings() override;
// Helper functions.
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
typedef Qt::ColorScheme ColorScheme;
#else
enum class ColorScheme {
Unknown,
Light,
Dark,
};
#endif
static ColorScheme colorScheme();
public slots:
void load();
void save();
signals:
void updated();
private:
void migrate(QSettings *settings) const;
static QSettings *qsettings(QObject *parent = nullptr);
};
} // namespace Core
} // namespace Zeal
QDataStream &operator<<(QDataStream &out, Zeal::Core::Settings::ExternalLinkPolicy policy);
QDataStream &operator>>(QDataStream &in, Zeal::Core::Settings::ExternalLinkPolicy &policy);
Q_DECLARE_METATYPE(Zeal::Core::Settings::ExternalLinkPolicy)
#endif // ZEAL_CORE_SETTINGS_H