2024-10-06 01:14:20 -04:00
|
|
|
// Copyright (C) Oleg Shparber, et al. <https://zealdocs.org>
|
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
2015-08-30 23:41:27 -04:00
|
|
|
|
2017-10-31 10:10:17 +02:00
|
|
|
#ifndef ZEAL_CORE_SETTINGS_H
|
|
|
|
|
#define ZEAL_CORE_SETTINGS_H
|
2015-01-12 22:21:44 -08:00
|
|
|
|
2020-04-25 19:59:56 -04:00
|
|
|
#include <QDataStream>
|
2015-01-12 22:21:44 -08:00
|
|
|
#include <QKeySequence>
|
2019-11-17 14:47:43 -05:00
|
|
|
#include <QObject>
|
2015-01-12 22:21:44 -08:00
|
|
|
|
|
|
|
|
class QSettings;
|
|
|
|
|
|
2026-04-03 17:21:06 +03:00
|
|
|
namespace Zeal::Core {
|
2015-01-12 22:21:44 -08:00
|
|
|
|
2019-02-10 14:52:47 -05:00
|
|
|
class Settings final : public QObject
|
2015-01-12 22:21:44 -08:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2025-09-02 11:39:02 -04:00
|
|
|
Q_DISABLE_COPY_MOVE(Settings)
|
2015-01-12 22:21:44 -08:00
|
|
|
public:
|
2016-04-12 22:49:29 -04:00
|
|
|
/* This public members are here just for simplification and should go away
|
|
|
|
|
* once a more advanced settings management come in place.
|
|
|
|
|
*/
|
2015-01-12 22:21:44 -08:00
|
|
|
|
|
|
|
|
// Startup
|
|
|
|
|
bool startMinimized;
|
2015-05-19 21:29:40 -07:00
|
|
|
bool checkForUpdate;
|
2025-09-01 01:19:18 -04:00
|
|
|
bool hideMenuBar;
|
2016-04-12 22:49:29 -04:00
|
|
|
// TODO: bool restoreLastState;
|
2015-01-12 22:21:44 -08:00
|
|
|
|
|
|
|
|
// System Tray
|
|
|
|
|
bool showSystrayIcon;
|
|
|
|
|
bool minimizeToSystray;
|
|
|
|
|
bool hideOnClose;
|
|
|
|
|
|
|
|
|
|
// Global Shortcuts
|
2015-01-13 00:19:54 -08:00
|
|
|
QKeySequence showShortcut;
|
2016-04-12 22:49:29 -04:00
|
|
|
// TODO: QKeySequence searchSelectedTextShortcut;
|
2015-01-12 22:21:44 -08:00
|
|
|
|
2016-04-20 21:45:50 +03:00
|
|
|
// Tabs Behavior
|
|
|
|
|
bool openNewTabAfterActive;
|
2026-04-29 12:29:54 +03:00
|
|
|
bool showTabCloseButton;
|
2016-04-20 21:45:50 +03:00
|
|
|
|
2017-04-26 00:34:26 -04:00
|
|
|
// Search
|
2023-04-12 22:21:03 -04:00
|
|
|
bool isFuzzySearchEnabled;
|
2017-04-26 00:34:26 -04:00
|
|
|
|
2017-03-02 20:15:02 -05:00
|
|
|
// Content
|
2018-01-20 17:46:10 +02:00
|
|
|
QString defaultFontFamily;
|
|
|
|
|
QString serifFontFamily;
|
|
|
|
|
QString sansSerifFontFamily;
|
|
|
|
|
QString fixedFontFamily;
|
|
|
|
|
|
|
|
|
|
int defaultFontSize;
|
|
|
|
|
int defaultFixedFontSize;
|
|
|
|
|
int minimumFontSize;
|
|
|
|
|
|
2018-01-07 16:00:22 +02:00
|
|
|
enum class ExternalLinkPolicy : unsigned int {
|
|
|
|
|
Ask = 0,
|
|
|
|
|
Open,
|
|
|
|
|
OpenInSystemBrowser
|
|
|
|
|
};
|
|
|
|
|
Q_ENUM(ExternalLinkPolicy)
|
|
|
|
|
ExternalLinkPolicy externalLinkPolicy = ExternalLinkPolicy::Ask;
|
|
|
|
|
|
2023-04-30 02:29:03 -04:00
|
|
|
enum class ContentAppearance : unsigned int {
|
|
|
|
|
Automatic = 0,
|
|
|
|
|
Light,
|
|
|
|
|
Dark
|
|
|
|
|
};
|
|
|
|
|
Q_ENUM(ContentAppearance)
|
|
|
|
|
ContentAppearance contentAppearance = ContentAppearance::Automatic;
|
|
|
|
|
|
2023-04-12 22:21:03 -04:00
|
|
|
bool isHighlightOnNavigateEnabled;
|
2017-03-05 21:36:49 -05:00
|
|
|
QString customCssFile;
|
2018-01-07 23:22:01 +02:00
|
|
|
bool isSmoothScrollingEnabled;
|
2017-03-02 22:43:36 -05:00
|
|
|
|
2015-01-12 22:21:44 -08:00
|
|
|
// Network
|
2015-11-18 22:21:33 -05:00
|
|
|
enum ProxyType : unsigned int {
|
2018-11-06 00:09:28 -05:00
|
|
|
None = 0,
|
|
|
|
|
System = 1,
|
|
|
|
|
Http = 3,
|
|
|
|
|
Socks5 = 4
|
2015-01-12 22:21:44 -08:00
|
|
|
};
|
2015-11-19 01:05:46 -05:00
|
|
|
Q_ENUM(ProxyType)
|
2015-01-12 22:21:44 -08:00
|
|
|
|
2015-08-31 00:34:59 -04:00
|
|
|
// Internal
|
|
|
|
|
// --------
|
2024-08-05 16:40:50 -04:00
|
|
|
// InstallId is a UUID used to identify a Zeal installation. Created on first start or after
|
|
|
|
|
// a settings wipe. It is not attached to user hardware or software, and is sent exclusively
|
2015-08-31 00:34:59 -04:00
|
|
|
// to *.zealdocs.org hosts.
|
|
|
|
|
QString installId;
|
|
|
|
|
|
2015-01-12 22:21:44 -08:00
|
|
|
ProxyType proxyType = ProxyType::System;
|
|
|
|
|
QString proxyHost;
|
|
|
|
|
quint16 proxyPort;
|
|
|
|
|
bool proxyAuthenticate;
|
|
|
|
|
QString proxyUserName;
|
|
|
|
|
QString proxyPassword;
|
2023-08-06 14:14:05 -04:00
|
|
|
bool isIgnoreSslErrorsEnabled;
|
2015-01-12 22:21:44 -08:00
|
|
|
|
|
|
|
|
// Other
|
|
|
|
|
QString docsetPath;
|
|
|
|
|
|
|
|
|
|
explicit Settings(QObject *parent = nullptr);
|
|
|
|
|
~Settings() override;
|
|
|
|
|
|
2023-04-30 02:29:03 -04:00
|
|
|
// Helper functions.
|
2024-06-16 02:50:15 -04:00
|
|
|
bool isDarkModeEnabled() const;
|
2026-05-02 16:08:55 +03:00
|
|
|
bool isTrayActive() const;
|
2024-06-16 02:50:15 -04:00
|
|
|
|
2023-04-30 02:29:03 -04:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
2026-04-07 03:24:39 +03:00
|
|
|
using ColorScheme = Qt::ColorScheme;
|
2023-04-30 02:29:03 -04:00
|
|
|
#else
|
|
|
|
|
enum class ColorScheme {
|
|
|
|
|
Unknown,
|
|
|
|
|
Light,
|
|
|
|
|
Dark,
|
|
|
|
|
};
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static ColorScheme colorScheme();
|
|
|
|
|
|
2015-01-12 22:21:44 -08:00
|
|
|
public slots:
|
|
|
|
|
void load();
|
|
|
|
|
void save();
|
|
|
|
|
|
2015-01-14 12:14:26 -08:00
|
|
|
signals:
|
|
|
|
|
void updated();
|
|
|
|
|
|
2015-01-12 22:21:44 -08:00
|
|
|
private:
|
2016-08-07 21:34:29 -04:00
|
|
|
void migrate(QSettings *settings) const;
|
2026-02-27 02:31:27 +02:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
|
|
|
|
void applyColorScheme();
|
|
|
|
|
#endif
|
2016-08-07 21:34:29 -04:00
|
|
|
|
2016-08-07 21:26:47 -04:00
|
|
|
static QSettings *qsettings(QObject *parent = nullptr);
|
2015-01-12 22:21:44 -08:00
|
|
|
};
|
|
|
|
|
|
2026-04-03 17:21:06 +03:00
|
|
|
} // namespace Zeal::Core
|
2015-01-12 22:21:44 -08:00
|
|
|
|
2023-09-17 03:44:25 -04:00
|
|
|
QDataStream &operator<<(QDataStream &out, Zeal::Core::Settings::ContentAppearance policy);
|
|
|
|
|
QDataStream &operator>>(QDataStream &in, Zeal::Core::Settings::ContentAppearance &policy);
|
|
|
|
|
|
2019-01-26 23:30:16 -05:00
|
|
|
QDataStream &operator<<(QDataStream &out, Zeal::Core::Settings::ExternalLinkPolicy policy);
|
2018-01-07 16:00:22 +02:00
|
|
|
QDataStream &operator>>(QDataStream &in, Zeal::Core::Settings::ExternalLinkPolicy &policy);
|
|
|
|
|
|
2023-09-17 03:44:25 -04:00
|
|
|
Q_DECLARE_METATYPE(Zeal::Core::Settings::ContentAppearance)
|
2018-01-07 16:00:22 +02:00
|
|
|
Q_DECLARE_METATYPE(Zeal::Core::Settings::ExternalLinkPolicy)
|
|
|
|
|
|
2017-10-31 10:10:17 +02:00
|
|
|
#endif // ZEAL_CORE_SETTINGS_H
|