Files
zeal/src/libs/core/settings.h
T

150 lines
3.5 KiB
C++
Raw Normal View History

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
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
#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
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;
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
QKeySequence showShortcut;
2016-04-12 22:49:29 -04:00
// TODO: QKeySequence searchSelectedTextShortcut;
2015-01-12 22:21:44 -08:00
// Tabs Behavior
bool openNewTabAfterActive;
bool showTabCloseButton;
// Search
2023-04-12 22:21:03 -04:00
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;
2023-04-12 22:21:03 -04:00
bool isHighlightOnNavigateEnabled;
QString customCssFile;
bool isSmoothScrollingEnabled;
2017-03-02 22:43:36 -05:00
2015-01-12 22:21:44 -08:00
// Network
enum ProxyType : unsigned int {
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;
// Helper functions.
bool isDarkModeEnabled() const;
2026-05-02 16:08:55 +03:00
bool isTrayActive() const;
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
2026-04-07 03:24:39 +03:00
using ColorScheme = Qt::ColorScheme;
#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:
void migrate(QSettings *settings) const;
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
void applyColorScheme();
#endif
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
QDataStream &operator<<(QDataStream &out, Zeal::Core::Settings::ContentAppearance policy);
QDataStream &operator>>(QDataStream &in, Zeal::Core::Settings::ContentAppearance &policy);
QDataStream &operator<<(QDataStream &out, Zeal::Core::Settings::ExternalLinkPolicy policy);
QDataStream &operator>>(QDataStream &in, Zeal::Core::Settings::ExternalLinkPolicy &policy);
Q_DECLARE_METATYPE(Zeal::Core::Settings::ContentAppearance)
Q_DECLARE_METATYPE(Zeal::Core::Settings::ExternalLinkPolicy)
2017-10-31 10:10:17 +02:00
#endif // ZEAL_CORE_SETTINGS_H