Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Commit

Permalink
cleanup core module
Browse files Browse the repository at this point in the history
Core mostly done. TODO: Widgets & Quick module
  • Loading branch information
wangwenx190 committed Jul 29, 2023
1 parent d9ce1c4 commit 4ed2158
Show file tree
Hide file tree
Showing 24 changed files with 355 additions and 395 deletions.
39 changes: 27 additions & 12 deletions include/FramelessHelper/Core/framelesshelpercore_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,26 @@ QT_END_NAMESPACE
# endif
#endif

#ifndef FRAMELESSHELPER_BYTEARRAY_VIEW
# define FRAMELESSHELPER_BYTEARRAY_VIEW(ba) ba
#endif

#ifndef FRAMELESSHELPER_STRING_VIEW
# if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
# define FRAMELESSHELPER_STRING_VIEW(str) str##_L1
# else
# define FRAMELESSHELPER_STRING_VIEW(str) QLatin1String(str)
# endif
#endif

#ifndef FRAMELESSHELPER_STRING_VIEW_TYPE
# if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
# define FRAMELESSHELPER_STRING_VIEW_TYPE QLatin1StringView
# else
# define FRAMELESSHELPER_STRING_VIEW_TYPE QLatin1String
# endif
#endif

#ifndef Q_UNREACHABLE_RETURN // Since 6.5
# define Q_UNREACHABLE_RETURN(...) \
do { \
Expand All @@ -142,12 +162,12 @@ QT_END_NAMESPACE

#ifndef FRAMELESSHELPER_BYTEARRAY_CONSTANT2
# define FRAMELESSHELPER_BYTEARRAY_CONSTANT2(name, ba) \
[[maybe_unused]] static const auto k##name = FRAMELESSHELPER_BYTEARRAY_LITERAL(ba);
[[maybe_unused]] static constexpr const auto k##name = FRAMELESSHELPER_BYTEARRAY_VIEW(ba);
#endif

#ifndef FRAMELESSHELPER_STRING_CONSTANT2
# define FRAMELESSHELPER_STRING_CONSTANT2(name, str) \
[[maybe_unused]] static const auto k##name = FRAMELESSHELPER_STRING_LITERAL(str);
[[maybe_unused]] static constexpr const auto k##name = FRAMELESSHELPER_STRING_VIEW(str);
#endif

#ifndef FRAMELESSHELPER_BYTEARRAY_CONSTANT
Expand Down Expand Up @@ -248,16 +268,11 @@ Q_NAMESPACE_EXPORT(FRAMELESSHELPER_CORE_API)
[[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultSystemButtonBackgroundColor = {204, 204, 204}; // #CCCCCC
[[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultSystemCloseButtonBackgroundColor = {232, 17, 35}; // #E81123

[[maybe_unused]] inline const QByteArray kDontOverrideCursorVar
= FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_DONT_OVERRIDE_CURSOR");
[[maybe_unused]] inline const QByteArray kDontToggleMaximizeVar
= FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_DONT_TOGGLE_MAXIMIZE");
[[maybe_unused]] inline const QByteArray kSysMenuDisableMinimizeVar
= FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_SYSTEM_MENU_DISABLE_MINIMIZE");
[[maybe_unused]] inline const QByteArray kSysMenuDisableMaximizeVar
= FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_SYSTEM_MENU_DISABLE_MAXIMIZE");
[[maybe_unused]] inline const QByteArray kSysMenuDisableRestoreVar
= FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_SYSTEM_MENU_DISABLE_RESTORE");
[[maybe_unused]] inline constexpr const char kDontOverrideCursorVar[] = "FRAMELESSHELPER_DONT_OVERRIDE_CURSOR";
[[maybe_unused]] inline constexpr const char kDontToggleMaximizeVar[] = "FRAMELESSHELPER_DONT_TOGGLE_MAXIMIZE";
[[maybe_unused]] inline constexpr const char kSysMenuDisableMinimizeVar[] = "FRAMELESSHELPER_SYSTEM_MENU_DISABLE_MINIMIZE";
[[maybe_unused]] inline constexpr const char kSysMenuDisableMaximizeVar[] = "FRAMELESSHELPER_SYSTEM_MENU_DISABLE_MAXIMIZE";
[[maybe_unused]] inline constexpr const char kSysMenuDisableRestoreVar[] = "FRAMELESSHELPER_SYSTEM_MENU_DISABLE_RESTORE";

enum class Option : quint8
{
Expand Down
7 changes: 4 additions & 3 deletions include/FramelessHelper/Core/framelessmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ class FRAMELESSHELPER_CORE_API FramelessManager : public QObject
Q_PROPERTY(Global::WallpaperAspectStyle wallpaperAspectStyle READ wallpaperAspectStyle NOTIFY wallpaperChanged FINAL)

public:
explicit FramelessManager(QObject *parent = nullptr);
~FramelessManager() override;

Q_NODISCARD static FramelessManager *instance();

Q_NODISCARD Global::SystemTheme systemTheme() const;
Expand All @@ -61,6 +58,10 @@ public Q_SLOTS:
void systemThemeChanged();
void wallpaperChanged();

private:
explicit FramelessManager(QObject *parent = nullptr);
~FramelessManager() override;

private:
QScopedPointer<FramelessManagerPrivate> d_ptr;
};
Expand Down
7 changes: 4 additions & 3 deletions include/FramelessHelper/Core/private/framelessconfig_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ class FRAMELESSHELPER_CORE_API FramelessConfig : public QObject
Q_DISABLE_COPY_MOVE(FramelessConfig)

public:
explicit FramelessConfig(QObject *parent = nullptr);
~FramelessConfig() override;

Q_NODISCARD static FramelessConfig *instance();

void reload(const bool force = false);
Expand All @@ -46,6 +43,10 @@ class FRAMELESSHELPER_CORE_API FramelessConfig : public QObject

static void setLoadFromEnvironmentVariablesDisabled(const bool on = true);
static void setLoadFromConfigurationFileDisabled(const bool on = true);

private:
explicit FramelessConfig(QObject *parent = nullptr);
~FramelessConfig() override;
};

FRAMELESSHELPER_END_NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ using SetSystemButtonStateCallback = std::function<void(const Global::SystemButt
using GetWindowIdCallback = std::function<WId()>;
using ShouldIgnoreMouseEventsCallback = std::function<bool(const QPoint &)>;
using ShowSystemMenuCallback = std::function<void(const QPoint &)>;
using SetPropertyCallback = std::function<void(const QByteArray &, const QVariant &)>;
using GetPropertyCallback = std::function<QVariant(const QByteArray &, const QVariant &)>;
using SetPropertyCallback = std::function<void(const char *, const QVariant &)>;
using GetPropertyCallback = std::function<QVariant(const char *, const QVariant &)>;
using SetCursorCallback = std::function<void(const QCursor &)>;
using UnsetCursorCallback = std::function<void()>;
using GetWidgetHandleCallback = std::function<QObject *()>;
Expand Down
8 changes: 4 additions & 4 deletions include/FramelessHelper/Core/private/sysapiloader_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,13 @@ class FRAMELESSHELPER_CORE_API SysApiLoader : public QObject
Q_DISABLE_COPY_MOVE(SysApiLoader)

public:
explicit SysApiLoader(QObject *parent = nullptr);
~SysApiLoader() override;

Q_NODISCARD static SysApiLoader *instance();

Q_NODISCARD static QString platformSharedLibrarySuffixName();
Q_NODISCARD static QString platformSystemLibraryDirectory();
Q_NODISCARD static QString generateUniqueKey(const QString &library, const QString &function);

Q_NODISCARD static QFunctionPointer resolve(const QString &library, const char *function);
Q_NODISCARD static QFunctionPointer resolve(const QString &library, const QByteArray &function);
Q_NODISCARD static QFunctionPointer resolve(const QString &library, const QString &function);

Q_NODISCARD bool isAvailable(const QString &library, const QString &function);
Expand All @@ -56,6 +52,10 @@ class FRAMELESSHELPER_CORE_API SysApiLoader : public QObject
{
return reinterpret_cast<T>(get(library, function));
}

private:
explicit SysApiLoader(QObject *parent = nullptr);
~SysApiLoader() override;
};

FRAMELESSHELPER_END_NAMESPACE
Expand Down
56 changes: 28 additions & 28 deletions include/FramelessHelper/Core/private/versionnumber_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,35 +88,35 @@ struct VersionNumber
};

#ifdef Q_OS_WINDOWS
[[maybe_unused]] inline constexpr const VersionNumber WindowsVersions[] =
[[maybe_unused]] inline constexpr const std::array<VersionNumber, 27> WindowsVersions =
{
{ 5, 0, 2195}, // Windows 2000
{ 5, 1, 2600}, // Windows XP
{ 5, 2, 3790}, // Windows XP x64 Edition or Windows Server 2003
{ 6, 0, 6000}, // Windows Vista
{ 6, 0, 6001}, // Windows Vista with Service Pack 1 or Windows Server 2008
{ 6, 0, 6002}, // Windows Vista with Service Pack 2
{ 6, 1, 7600}, // Windows 7 or Windows Server 2008 R2
{ 6, 1, 7601}, // Windows 7 with Service Pack 1 or Windows Server 2008 R2 with Service Pack 1
{ 6, 2, 9200}, // Windows 8 or Windows Server 2012
{ 6, 3, 9200}, // Windows 8.1 or Windows Server 2012 R2
{ 6, 3, 9600}, // Windows 8.1 with Update 1
{10, 0, 10240}, // Windows 10 Version 1507 (TH1)
{10, 0, 10586}, // Windows 10 Version 1511 (November Update) (TH2)
{10, 0, 14393}, // Windows 10 Version 1607 (Anniversary Update) (RS1) or Windows Server 2016
{10, 0, 15063}, // Windows 10 Version 1703 (Creators Update) (RS2)
{10, 0, 16299}, // Windows 10 Version 1709 (Fall Creators Update) (RS3)
{10, 0, 17134}, // Windows 10 Version 1803 (April 2018 Update) (RS4)
{10, 0, 17763}, // Windows 10 Version 1809 (October 2018 Update) (RS5) or Windows Server 2019
{10, 0, 18362}, // Windows 10 Version 1903 (May 2019 Update) (19H1)
{10, 0, 18363}, // Windows 10 Version 1909 (November 2019 Update) (19H2)
{10, 0, 19041}, // Windows 10 Version 2004 (May 2020 Update) (20H1)
{10, 0, 19042}, // Windows 10 Version 20H2 (October 2020 Update) (20H2)
{10, 0, 19043}, // Windows 10 Version 21H1 (May 2021 Update) (21H1)
{10, 0, 19044}, // Windows 10 Version 21H2 (November 2021 Update) (21H2)
{10, 0, 19045}, // Windows 10 Version 22H2 (October 2022 Update) (22H2)
{10, 0, 22000}, // Windows 11 Version 21H2 (21H2)
{10, 0, 22621} // Windows 11 Version 22H2 (October 2022 Update) (22H2)
VersionNumber{ 5, 0, 2195 }, // Windows 2000
VersionNumber{ 5, 1, 2600 }, // Windows XP
VersionNumber{ 5, 2, 3790 }, // Windows XP x64 Edition or Windows Server 2003
VersionNumber{ 6, 0, 6000 }, // Windows Vista
VersionNumber{ 6, 0, 6001 }, // Windows Vista with Service Pack 1 or Windows Server 2008
VersionNumber{ 6, 0, 6002 }, // Windows Vista with Service Pack 2
VersionNumber{ 6, 1, 7600 }, // Windows 7 or Windows Server 2008 R2
VersionNumber{ 6, 1, 7601 }, // Windows 7 with Service Pack 1 or Windows Server 2008 R2 with Service Pack 1
VersionNumber{ 6, 2, 9200 }, // Windows 8 or Windows Server 2012
VersionNumber{ 6, 3, 9200 }, // Windows 8.1 or Windows Server 2012 R2
VersionNumber{ 6, 3, 9600 }, // Windows 8.1 with Update 1
VersionNumber{ 10, 0, 10240 }, // Windows 10 Version 1507 (TH1)
VersionNumber{ 10, 0, 10586 }, // Windows 10 Version 1511 (November Update) (TH2)
VersionNumber{ 10, 0, 14393 }, // Windows 10 Version 1607 (Anniversary Update) (RS1) or Windows Server 2016
VersionNumber{ 10, 0, 15063 }, // Windows 10 Version 1703 (Creators Update) (RS2)
VersionNumber{ 10, 0, 16299 }, // Windows 10 Version 1709 (Fall Creators Update) (RS3)
VersionNumber{ 10, 0, 17134 }, // Windows 10 Version 1803 (April 2018 Update) (RS4)
VersionNumber{ 10, 0, 17763 }, // Windows 10 Version 1809 (October 2018 Update) (RS5) or Windows Server 2019
VersionNumber{ 10, 0, 18362 }, // Windows 10 Version 1903 (May 2019 Update) (19H1)
VersionNumber{ 10, 0, 18363 }, // Windows 10 Version 1909 (November 2019 Update) (19H2)
VersionNumber{ 10, 0, 19041 }, // Windows 10 Version 2004 (May 2020 Update) (20H1)
VersionNumber{ 10, 0, 19042 }, // Windows 10 Version 20H2 (October 2020 Update) (20H2)
VersionNumber{ 10, 0, 19043 }, // Windows 10 Version 21H1 (May 2021 Update) (21H1)
VersionNumber{ 10, 0, 19044 }, // Windows 10 Version 21H2 (November 2021 Update) (21H2)
VersionNumber{ 10, 0, 19045 }, // Windows 10 Version 22H2 (October 2022 Update) (22H2)
VersionNumber{ 10, 0, 22000 }, // Windows 11 Version 21H2 (21H2)
VersionNumber{ 10, 0, 22621 } // Windows 11 Version 22H2 (October 2022 Update) (22H2)
};
#endif // Q_OS_WINDOWS

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ class FRAMELESSHELPER_QUICK_API FramelessQuickHelperPrivate : public QObject
Q_NODISCARD bool isWindowFixedSize() const;
void setWindowFixedSize(const bool value);

void emitSignalForAllInstances(const QByteArray &signal);
void emitSignalForAllInstances(const char *signal);

Q_NODISCARD bool isBlurBehindWindowEnabled() const;
void setBlurBehindWindowEnabled(const bool value, const QColor &color);

void setProperty(const QByteArray &name, const QVariant &value);
Q_NODISCARD QVariant getProperty(const QByteArray &name, const QVariant &defaultValue = {});
void setProperty(const char *name, const QVariant &value);
Q_NODISCARD QVariant getProperty(const char *name, const QVariant &defaultValue = {});

Q_NODISCARD QuickMicaMaterial *findOrCreateMicaMaterial() const;
Q_NODISCARD QuickWindowBorder *findOrCreateWindowBorder() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ class FRAMELESSHELPER_WIDGETS_API FramelessWidgetsHelperPrivate : public QObject
Q_NODISCARD bool isWindowFixedSize() const;
void setWindowFixedSize(const bool value);

void emitSignalForAllInstances(const QByteArray &signal);
void emitSignalForAllInstances(const char *signal);

Q_NODISCARD bool isBlurBehindWindowEnabled() const;
void setBlurBehindWindowEnabled(const bool enable, const QColor &color);

void setProperty(const QByteArray &name, const QVariant &value);
Q_NODISCARD QVariant getProperty(const QByteArray &name, const QVariant &defaultValue = {});
void setProperty(const char *name, const QVariant &value);
Q_NODISCARD QVariant getProperty(const char *name, const QVariant &defaultValue = {});

Q_NODISCARD QWidget *window() const;

Expand Down
9 changes: 5 additions & 4 deletions src/core/chromepalette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,11 @@ void ChromePalettePrivate::refresh()
// Calculate the most appropriate foreground color, based on the
// current background color.
const qreal grayF = (
(0.299 * titleBarActiveBackgroundColor_sys.redF()) +
(0.587 * titleBarActiveBackgroundColor_sys.greenF()) +
(0.114 * titleBarActiveBackgroundColor_sys.blueF()));
if (grayF <= 0.5) {
(qreal(0.299) * titleBarActiveBackgroundColor_sys.redF()) +
(qreal(0.587) * titleBarActiveBackgroundColor_sys.greenF()) +
(qreal(0.114) * titleBarActiveBackgroundColor_sys.blueF()));
static constexpr const auto kFlag = qreal(0.5);
if ((grayF < kFlag) || qFuzzyCompare(grayF, kFlag)) {
return kDefaultWhiteColor;
}
}
Expand Down
76 changes: 34 additions & 42 deletions src/core/framelessconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,46 +49,37 @@ using namespace Global;

FRAMELESSHELPER_STRING_CONSTANT2(ConfigFileName, ".framelesshelper.ini")

static const struct
struct FramelessConfigEntry
{
const QByteArray env = {};
const QByteArray cfg = {};
} OptionsTable[] = {
{FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_USE_CROSS_PLATFORM_QT_IMPLEMENTATION"),
FRAMELESSHELPER_BYTEARRAY_LITERAL("Options/UseCrossPlatformQtImplementation")},
{FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_FORCE_HIDE_WINDOW_FRAME_BORDER"),
FRAMELESSHELPER_BYTEARRAY_LITERAL("Options/ForceHideWindowFrameBorder")},
{FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_FORCE_SHOW_WINDOW_FRAME_BORDER"),
FRAMELESSHELPER_BYTEARRAY_LITERAL("Options/ForceShowWindowFrameBorder")},
{FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_DISABLE_WINDOWS_SNAP_LAYOUT"),
FRAMELESSHELPER_BYTEARRAY_LITERAL("Options/DisableWindowsSnapLayout")},
{FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_WINDOW_USE_ROUND_CORNERS"),
FRAMELESSHELPER_BYTEARRAY_LITERAL("Options/WindowUseRoundCorners")},
{FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_CENTER_WINDOW_BEFORE_SHOW"),
FRAMELESSHELPER_BYTEARRAY_LITERAL("Options/CenterWindowBeforeShow")},
{FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_ENABLE_BLUR_BEHIND_WINDOW"),
FRAMELESSHELPER_BYTEARRAY_LITERAL("Options/EnableBlurBehindWindow")},
{FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_FORCE_NON_NATIVE_BACKGROUND_BLUR"),
FRAMELESSHELPER_BYTEARRAY_LITERAL("Options/ForceNonNativeBackgroundBlur")},
{FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_DISABLE_LAZY_INITIALIZATION_FOR_MICA_MATERIAL"),
FRAMELESSHELPER_BYTEARRAY_LITERAL("Options/DisableLazyInitializationForMicaMaterial")},
{FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_FORCE_NATIVE_BACKGROUND_BLUR"),
FRAMELESSHELPER_BYTEARRAY_LITERAL("Options/ForceNativeBackgroundBlur")}
const char *env = nullptr;
const char *cfg = nullptr;
};

static constexpr const auto OptionCount = std::size(OptionsTable);
static constexpr const std::array<FramelessConfigEntry, 10> FramelessOptionsTable =
{
FramelessConfigEntry{ "FRAMELESSHELPER_USE_CROSS_PLATFORM_QT_IMPLEMENTATION", "Options/UseCrossPlatformQtImplementation" },
FramelessConfigEntry{ "FRAMELESSHELPER_FORCE_HIDE_WINDOW_FRAME_BORDER", "Options/ForceHideWindowFrameBorder" },
FramelessConfigEntry{ "FRAMELESSHELPER_FORCE_SHOW_WINDOW_FRAME_BORDER", "Options/ForceShowWindowFrameBorder" },
FramelessConfigEntry{ "FRAMELESSHELPER_DISABLE_WINDOWS_SNAP_LAYOUT", "Options/DisableWindowsSnapLayout" },
FramelessConfigEntry{ "FRAMELESSHELPER_WINDOW_USE_ROUND_CORNERS", "Options/WindowUseRoundCorners" },
FramelessConfigEntry{ "FRAMELESSHELPER_CENTER_WINDOW_BEFORE_SHOW", "Options/CenterWindowBeforeShow" },
FramelessConfigEntry{ "FRAMELESSHELPER_ENABLE_BLUR_BEHIND_WINDOW", "Options/EnableBlurBehindWindow" },
FramelessConfigEntry{ "FRAMELESSHELPER_FORCE_NON_NATIVE_BACKGROUND_BLUR", "Options/ForceNonNativeBackgroundBlur" },
FramelessConfigEntry{ "FRAMELESSHELPER_DISABLE_LAZY_INITIALIZATION_FOR_MICA_MATERIAL", "Options/DisableLazyInitializationForMicaMaterial" },
FramelessConfigEntry{ "FRAMELESSHELPER_FORCE_NATIVE_BACKGROUND_BLUR", "Options/ForceNativeBackgroundBlur" }
};

struct ConfigData
static constexpr const auto OptionCount = std::size(FramelessOptionsTable);

struct FramelessConfigData
{
bool loaded = false;
bool options[OptionCount] = {};
bool disableEnvVar = false;
bool disableCfgFile = false;
};

Q_GLOBAL_STATIC(ConfigData, g_data)

Q_GLOBAL_STATIC(FramelessConfig, g_config)
Q_GLOBAL_STATIC(FramelessConfigData, g_framelessConfigData)

static inline void warnInappropriateOptions()
{
Expand Down Expand Up @@ -127,12 +118,13 @@ FramelessConfig::~FramelessConfig() = default;

FramelessConfig *FramelessConfig::instance()
{
return g_config();
static FramelessConfig config;
return &config;
}

void FramelessConfig::reload(const bool force)
{
if (g_data()->loaded && !force) {
if (g_framelessConfigData()->loaded && !force) {
return;
}
const auto configFile = []() -> std::unique_ptr<QSettings> {
Expand All @@ -143,36 +135,36 @@ void FramelessConfig::reload(const bool force)
return std::make_unique<QSettings>(appDir.filePath(kConfigFileName), QSettings::IniFormat);
}();
for (int i = 0; i != OptionCount; ++i) {
const bool envVar = (!g_data()->disableEnvVar
&& qEnvironmentVariableIsSet(OptionsTable[i].env.constData())
&& (qEnvironmentVariableIntValue(OptionsTable[i].env.constData()) > 0));
const bool cfgFile = (!g_data()->disableCfgFile && configFile
&& configFile->value(QUtf8String(OptionsTable[i].cfg), false).toBool());
g_data()->options[i] = (envVar || cfgFile);
const bool envVar = (!g_framelessConfigData()->disableEnvVar
&& qEnvironmentVariableIsSet(FramelessOptionsTable.at(i).env)
&& (qEnvironmentVariableIntValue(FramelessOptionsTable.at(i).env) > 0));
const bool cfgFile = (!g_framelessConfigData()->disableCfgFile && configFile
&& configFile->value(QUtf8String(FramelessOptionsTable.at(i).cfg), false).toBool());
g_framelessConfigData()->options[i] = (envVar || cfgFile);
}
g_data()->loaded = true;
g_framelessConfigData()->loaded = true;

QTimer::singleShot(0, this, [](){ warnInappropriateOptions(); });
}

void FramelessConfig::set(const Option option, const bool on)
{
g_data()->options[static_cast<int>(option)] = on;
g_framelessConfigData()->options[static_cast<int>(option)] = on;
}

bool FramelessConfig::isSet(const Option option) const
{
return g_data()->options[static_cast<int>(option)];
return g_framelessConfigData()->options[static_cast<int>(option)];
}

void FramelessConfig::setLoadFromEnvironmentVariablesDisabled(const bool on)
{
g_data()->disableEnvVar = on;
g_framelessConfigData()->disableEnvVar = on;
}

void FramelessConfig::setLoadFromConfigurationFileDisabled(const bool on)
{
g_data()->disableCfgFile = on;
g_framelessConfigData()->disableCfgFile = on;
}

FRAMELESSHELPER_END_NAMESPACE
Loading

0 comments on commit 4ed2158

Please sign in to comment.