add limited qmake support

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2022-08-31 16:34:30 +08:00
parent abf4b29dca
commit 7a35b09a74
38 changed files with 352 additions and 77 deletions

View File

@ -26,6 +26,18 @@
IDI_ICON1 ICON "example.ico" IDI_ICON1 ICON "example.ico"
#if 0
#if (defined(WIDGET_USE_QMAKE) || defined(QUICK_USE_QMAKE))
#ifndef CREATEPROCESS_MANIFEST_RESOURCE_ID
#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1
#endif
#ifndef RT_MANIFEST
#define RT_MANIFEST 24
#endif
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "example.manifest"
#endif
#endif
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0 FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0 PRODUCTVERSION 1,0,0,0

View File

@ -39,6 +39,11 @@ int main(int argc, char *argv[])
QApplication application(argc, argv); QApplication application(argc, argv);
// Must be called after QGuiApplication has been constructed, we are using
// some private functions from QPA which won't be available until there's
// a QGuiApplication instance.
FramelessHelper::Core::setApplicationOSThemeAware(true, false);
FramelessConfig::instance()->set(Global::Option::WindowUseRoundCorners); FramelessConfig::instance()->set(Global::Option::WindowUseRoundCorners);
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);

View File

@ -76,6 +76,11 @@ int main(int argc, char *argv[])
QApplication application(argc, argv); QApplication application(argc, argv);
// Must be called after QGuiApplication has been constructed, we are using
// some private functions from QPA which won't be available until there's
// a QGuiApplication instance.
FramelessHelper::Core::setApplicationOSThemeAware(true, false);
FramelessConfig::instance()->set(Global::Option::WindowUseRoundCorners); FramelessConfig::instance()->set(Global::Option::WindowUseRoundCorners);
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);

View File

@ -57,8 +57,10 @@ if(${QT_VERSION} VERSION_GREATER_EQUAL 6.2)
# There's some hope to get it supported in Qt 6.5. # There's some hope to get it supported in Qt 6.5.
) )
qt_add_resources(Quick resources qt_add_resources(Quick resources
PREFIX "/Demo" PREFIX
FILES "images/microsoft.svg" "/Demo"
FILES
"images/microsoft.svg"
) )
endif() endif()

View File

@ -51,6 +51,11 @@ int main(int argc, char *argv[])
QGuiApplication application(argc, argv); QGuiApplication application(argc, argv);
// Must be called after QGuiApplication has been constructed, we are using
// some private functions from QPA which won't be available until there's
// a QGuiApplication instance.
FramelessHelper::Core::setApplicationOSThemeAware(true, true);
FramelessConfig::instance()->set(Global::Option::WindowUseRoundCorners); FramelessConfig::instance()->set(Global::Option::WindowUseRoundCorners);
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
@ -75,11 +80,11 @@ int main(int argc, char *argv[])
} }
QQmlApplicationEngine engine; QQmlApplicationEngine engine;
#if !QMLTC_ENABLED #if (!QMLTC_ENABLED && !defined(QUICK_USE_QMAKE))
engine.addImportPath(FRAMELESSHELPER_STRING_LITERAL("../imports")); engine.addImportPath(FRAMELESSHELPER_STRING_LITERAL("../imports"));
#endif #endif
#if (QT_VERSION < QT_VERSION_CHECK(6, 2, 0)) && !QMLTC_ENABLED #if (((QT_VERSION < QT_VERSION_CHECK(6, 2, 0)) || defined(QUICK_USE_QMAKE)) && !QMLTC_ENABLED)
// Don't forget to register our own custom QML types! // Don't forget to register our own custom QML types!
FramelessHelper::Quick::registerTypes(&engine); FramelessHelper::Quick::registerTypes(&engine);

11
examples/quick/quick.pro Normal file
View File

@ -0,0 +1,11 @@
TEMPLATE = app
TARGET = Quick
QT += qml quick quickcontrols2
CONFIG -= embed_manifest_exe
DEFINES += QUICK_USE_QMAKE
HEADERS += settings.h
SOURCES += settings.cpp main.cpp
RESOURCES += resources.qrc
win32: RC_FILE = ../example.rc
include(../../qmake/core.pri)
include(../../qmake/quick.pri)

View File

@ -39,6 +39,11 @@ int main(int argc, char *argv[])
QApplication application(argc, argv); QApplication application(argc, argv);
// Must be called after QGuiApplication has been constructed, we are using
// some private functions from QPA which won't be available until there's
// a QGuiApplication instance.
FramelessHelper::Core::setApplicationOSThemeAware(true, false);
FramelessConfig::instance()->set(Global::Option::WindowUseRoundCorners); FramelessConfig::instance()->set(Global::Option::WindowUseRoundCorners);
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);

View File

@ -0,0 +1,9 @@
TEMPLATE = app
TARGET = Widget
QT += widgets
CONFIG -= embed_manifest_exe
HEADERS += widget.h
SOURCES += widget.cpp main.cpp
win32: RC_FILE = ../example.rc
include(../../qmake/core.pri)
include(../../qmake/widgets.pri)

View File

@ -566,6 +566,7 @@ FRAMELESSHELPER_CORE_API void uninitialize();
[[nodiscard]] FRAMELESSHELPER_CORE_API Global::VersionInfo version(); [[nodiscard]] FRAMELESSHELPER_CORE_API Global::VersionInfo version();
FRAMELESSHELPER_CORE_API void registerInitializeHook(const Global::InitializeHookCallback &cb); FRAMELESSHELPER_CORE_API void registerInitializeHook(const Global::InitializeHookCallback &cb);
FRAMELESSHELPER_CORE_API void registerUninitializeHook(const Global::UninitializeHookCallback &cb); FRAMELESSHELPER_CORE_API void registerUninitializeHook(const Global::UninitializeHookCallback &cb);
FRAMELESSHELPER_CORE_API void setApplicationOSThemeAware(const bool enable, const bool pureQuick);
} // namespace FramelessHelper::Core } // namespace FramelessHelper::Core
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

@ -25,14 +25,13 @@
#pragma once #pragma once
#include "framelesshelpercore_global.h" #include "framelesshelpercore_global.h"
#include "chromepalette.h"
#include <QtCore/qobject.h> #include <QtCore/qobject.h>
#include <QtCore/qpointer.h> #include <QtCore/qpointer.h>
#include <optional> #include <optional>
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class ChromePalette;
class FRAMELESSHELPER_CORE_API ChromePalettePrivate : public QObject class FRAMELESSHELPER_CORE_API ChromePalettePrivate : public QObject
{ {
Q_OBJECT Q_OBJECT

View File

@ -25,14 +25,13 @@
#pragma once #pragma once
#include "framelesshelpercore_global.h" #include "framelesshelpercore_global.h"
#include "micamaterial.h"
#include <QtCore/qobject.h> #include <QtCore/qobject.h>
#include <QtCore/qpointer.h> #include <QtCore/qpointer.h>
#include <QtGui/qbrush.h> #include <QtGui/qbrush.h>
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class MicaMaterial;
class FRAMELESSHELPER_CORE_API MicaMaterialPrivate : public QObject class FRAMELESSHELPER_CORE_API MicaMaterialPrivate : public QObject
{ {
Q_OBJECT Q_OBJECT

View File

@ -26,6 +26,8 @@
#include "framelesshelpercore_global.h" #include "framelesshelpercore_global.h"
#include <QtCore/qobject.h> #include <QtCore/qobject.h>
#include <QtCore/qvariant.h>
#include <optional>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QWinRegistryKey; class QWinRegistryKey;
@ -49,6 +51,15 @@ public:
Q_NODISCARD bool isValid() const; Q_NODISCARD bool isValid() const;
Q_NODISCARD QVariant value(const QString &name) const; Q_NODISCARD QVariant value(const QString &name) const;
template<typename T>
Q_NODISCARD std::optional<T> value(const QString &name) const
{
const QVariant var = value(name);
if (var.isValid()) {
return qvariant_cast<T>(var);
}
return std::nullopt;
}
private: private:
Global::RegistryRootKey m_rootKey = Global::RegistryRootKey::CurrentUser; Global::RegistryRootKey m_rootKey = Global::RegistryRootKey::CurrentUser;

View File

@ -25,6 +25,7 @@
#pragma once #pragma once
#include "framelesshelperquick_global.h" #include "framelesshelperquick_global.h"
#include "framelessquickhelper.h"
#include <QtCore/qobject.h> #include <QtCore/qobject.h>
#include <QtCore/qpointer.h> #include <QtCore/qpointer.h>
@ -35,7 +36,6 @@ QT_END_NAMESPACE
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
struct QuickHelperData; struct QuickHelperData;
class FramelessQuickHelper;
class FRAMELESSHELPER_QUICK_API FramelessQuickHelperPrivate : public QObject class FRAMELESSHELPER_QUICK_API FramelessQuickHelperPrivate : public QObject
{ {

View File

@ -26,6 +26,7 @@
#include "framelesshelperquick_global.h" #include "framelesshelperquick_global.h"
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include "framelessquickwindow_p.h"
#include <QtCore/qobject.h> #include <QtCore/qobject.h>
#include <QtQuick/qquickwindow.h> #include <QtQuick/qquickwindow.h>
#include <QtQuick/private/qquickanchors_p_p.h> #include <QtQuick/private/qquickanchors_p_p.h>
@ -36,8 +37,6 @@ QT_END_NAMESPACE
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class FramelessQuickWindow;
class FRAMELESSHELPER_QUICK_API FramelessQuickWindowPrivate : public QObject class FRAMELESSHELPER_QUICK_API FramelessQuickWindowPrivate : public QObject
{ {
Q_OBJECT Q_OBJECT

View File

@ -25,14 +25,13 @@
#pragma once #pragma once
#include "framelesshelperquick_global.h" #include "framelesshelperquick_global.h"
#include "quickimageitem.h"
#include <QtCore/qobject.h> #include <QtCore/qobject.h>
#include <QtCore/qpointer.h> #include <QtCore/qpointer.h>
#include <QtCore/qvariant.h> #include <QtCore/qvariant.h>
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class QuickImageItem;
class FRAMELESSHELPER_QUICK_API QuickImageItemPrivate : public QObject class FRAMELESSHELPER_QUICK_API QuickImageItemPrivate : public QObject
{ {
Q_OBJECT Q_OBJECT

View File

@ -25,12 +25,12 @@
#pragma once #pragma once
#include "framelesshelperquick_global.h" #include "framelesshelperquick_global.h"
#include "quickmicamaterial.h"
#include <QtCore/qobject.h> #include <QtCore/qobject.h>
#include <QtCore/qpointer.h> #include <QtCore/qpointer.h>
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class QuickMicaMaterial;
class WallpaperImageNode; class WallpaperImageNode;
class FRAMELESSHELPER_QUICK_API QuickMicaMaterialPrivate : public QObject class FRAMELESSHELPER_QUICK_API QuickMicaMaterialPrivate : public QObject

View File

@ -27,6 +27,7 @@
#include "framelesshelperquick_global.h" #include "framelesshelperquick_global.h"
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include "quickchromepalette.h" #include "quickchromepalette.h"
#include "quickstandardsystembutton_p.h"
#include <QtQuick/private/qquickrectangle_p.h> #include <QtQuick/private/qquickrectangle_p.h>
#include <QtQuickTemplates2/private/qquicklabel_p.h> #include <QtQuickTemplates2/private/qquicklabel_p.h>
@ -36,7 +37,6 @@ QT_END_NAMESPACE
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class QuickStandardSystemButton;
class QuickImageItem; class QuickImageItem;
class FRAMELESSHELPER_QUICK_API QuickStandardTitleBar : public QQuickRectangle class FRAMELESSHELPER_QUICK_API QuickStandardTitleBar : public QQuickRectangle

View File

@ -27,6 +27,7 @@
#include "framelesshelperwidgets_global.h" #include "framelesshelperwidgets_global.h"
#include <QtCore/qobject.h> #include <QtCore/qobject.h>
#include <QtCore/qloggingcategory.h> #include <QtCore/qloggingcategory.h>
#include <QtWidgets/qwidget.h>
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE

View File

@ -25,12 +25,12 @@
#pragma once #pragma once
#include "framelesshelperwidgets_global.h" #include "framelesshelperwidgets_global.h"
#include "framelessmainwindow.h"
#include <QtCore/qobject.h> #include <QtCore/qobject.h>
#include <QtCore/qpointer.h> #include <QtCore/qpointer.h>
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class FramelessMainWindow;
class WidgetsSharedHelper; class WidgetsSharedHelper;
class FRAMELESSHELPER_WIDGETS_API FramelessMainWindowPrivate : public QObject class FRAMELESSHELPER_WIDGETS_API FramelessMainWindowPrivate : public QObject

View File

@ -25,12 +25,12 @@
#pragma once #pragma once
#include "framelesshelperwidgets_global.h" #include "framelesshelperwidgets_global.h"
#include "framelesswidget.h"
#include <QtCore/qobject.h> #include <QtCore/qobject.h>
#include <QtCore/qpointer.h> #include <QtCore/qpointer.h>
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class FramelessWidget;
class WidgetsSharedHelper; class WidgetsSharedHelper;
class FRAMELESSHELPER_WIDGETS_API FramelessWidgetPrivate : public QObject class FRAMELESSHELPER_WIDGETS_API FramelessWidgetPrivate : public QObject

View File

@ -25,13 +25,13 @@
#pragma once #pragma once
#include "framelesshelperwidgets_global.h" #include "framelesshelperwidgets_global.h"
#include "framelesswidgetshelper.h"
#include <QtCore/qobject.h> #include <QtCore/qobject.h>
#include <QtCore/qpointer.h> #include <QtCore/qpointer.h>
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
struct WidgetsHelperData; struct WidgetsHelperData;
class FramelessWidgetsHelper;
class FRAMELESSHELPER_WIDGETS_API FramelessWidgetsHelperPrivate : public QObject class FRAMELESSHELPER_WIDGETS_API FramelessWidgetsHelperPrivate : public QObject
{ {

View File

@ -24,9 +24,10 @@
#pragma once #pragma once
#include "framelesshelperwidgets_global.h"
#include "standardsystembutton.h"
#include <QtCore/qobject.h> #include <QtCore/qobject.h>
#include <QtCore/qpointer.h> #include <QtCore/qpointer.h>
#include "framelesshelperwidgets_global.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QEnterEvent; class QEnterEvent;
@ -35,8 +36,6 @@ QT_END_NAMESPACE
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class StandardSystemButton;
class FRAMELESSHELPER_WIDGETS_API StandardSystemButtonPrivate : public QObject class FRAMELESSHELPER_WIDGETS_API StandardSystemButtonPrivate : public QObject
{ {
Q_OBJECT Q_OBJECT

View File

@ -25,6 +25,7 @@
#pragma once #pragma once
#include "framelesshelperwidgets_global.h" #include "framelesshelperwidgets_global.h"
#include "standardtitlebar.h"
#include <QtCore/qobject.h> #include <QtCore/qobject.h>
#include <QtCore/qpointer.h> #include <QtCore/qpointer.h>
@ -34,7 +35,6 @@ QT_END_NAMESPACE
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
class StandardTitleBar;
class StandardSystemButton; class StandardSystemButton;
class ChromePalette; class ChromePalette;

View File

@ -25,8 +25,9 @@
#pragma once #pragma once
#include "framelesshelperwidgets_global.h" #include "framelesshelperwidgets_global.h"
#include <QtCore/qloggingcategory.h> #include "standardsystembutton.h"
#include <chromepalette.h> #include <chromepalette.h>
#include <QtCore/qloggingcategory.h>
#include <QtWidgets/qwidget.h> #include <QtWidgets/qwidget.h>
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
@ -34,7 +35,6 @@ FRAMELESSHELPER_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(lcStandardTitleBar) Q_DECLARE_LOGGING_CATEGORY(lcStandardTitleBar)
class StandardTitleBarPrivate; class StandardTitleBarPrivate;
class StandardSystemButton;
class FRAMELESSHELPER_WIDGETS_API StandardTitleBar : public QWidget class FRAMELESSHELPER_WIDGETS_API StandardTitleBar : public QWidget
{ {

71
qmake/core.pri Normal file
View File

@ -0,0 +1,71 @@
QT += core core-private gui gui-private
CORE_PUB_INC_DIR = $$PWD/../include/FramelessHelper/Core
CORE_PRIV_INC_DIR = $$CORE_PUB_INC_DIR/private
CORE_EXTRA_INC_DIR = $$PWD/inc/core
CORE_SRC_DIR = $$PWD/../src/core
DEFINES += \
FRAMELESSHELPER_CORE_STATIC
INCLUDEPATH += \
$$CORE_PUB_INC_DIR \
$$CORE_PRIV_INC_DIR \
$$CORE_EXTRA_INC_DIR
DEPENDPATH += \
$$CORE_PUB_INC_DIR \
$$CORE_PRIV_INC_DIR \
$$CORE_EXTRA_INC_DIR
HEADERS += \
$$CORE_EXTRA_INC_DIR/framelesshelper.version \
$$CORE_PUB_INC_DIR/chromepalette.h \
$$CORE_PUB_INC_DIR/framelesshelper_qt.h \
$$CORE_PUB_INC_DIR/framelesshelpercore_global.h \
$$CORE_PUB_INC_DIR/framelessmanager.h \
$$CORE_PUB_INC_DIR/micamaterial.h \
$$CORE_PUB_INC_DIR/utils.h \
$$CORE_PRIV_INC_DIR/chromepalette_p.h \
$$CORE_PRIV_INC_DIR/framelessconfig_p.h \
$$CORE_PRIV_INC_DIR/framelessmanager_p.h \
$$CORE_PRIV_INC_DIR/micamaterial_p.h \
$$CORE_PRIV_INC_DIR/registrykey_p.h \
$$CORE_PRIV_INC_DIR/sysapiloader_p.h
SOURCES += \
$$CORE_SRC_DIR/chromepalette.cpp \
$$CORE_SRC_DIR/framelessconfig.cpp \
$$CORE_SRC_DIR/framelesshelper_qt.cpp \
$$CORE_SRC_DIR/framelessmanager.cpp \
$$CORE_SRC_DIR/framelesshelpercore_global.cpp \
$$CORE_SRC_DIR/micamaterial.cpp \
$$CORE_SRC_DIR/registrykey.cpp \
$$CORE_SRC_DIR/sysapiloader.cpp \
$$CORE_SRC_DIR/utils.cpp
RESOURCES += \
$$CORE_SRC_DIR/framelesshelpercore.qrc
win32 {
HEADERS += \
$$CORE_PUB_INC_DIR/framelesshelper_win.h \
$$CORE_PUB_INC_DIR/framelesshelper_windows.h
SOURCES += \
$$CORE_SRC_DIR/framelesshelper_win.cpp \
$$CORE_SRC_DIR/utils_win.cpp
LIBS += -luser32 -lgdi32
}
unix:!macx {
CONFIG += link_pkgconfig
PKGCONFIG += gtk+-3.0
DEFINES += GDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_6
SOURCES += $$CORE_SRC_DIR/utils_linux.cpp
#LIBS += -lxcb # TODO
}
macx {
SOURCES += $$CORE_SRC_DIR/utils_mac.mm
#LIBS += "-framework AppKit" "-framework Cocoa" "-framework Foundation" # TODO
}

View File

@ -0,0 +1,44 @@
/*
* MIT License
*
* Copyright (C) 2022 by wangwenx190 (Yuhang Zhao)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// Generated automatically by QMake.
// WARNING! DO NOT EDIT THIS FILE MANUALLY!
// ALL CHANGES WILL BE LOST AFTER RE-CONFIGURING!
// Also please do not include this file directly,
// it's designed to be included by FramelessHelper's own headers.
#ifndef _FRAMELESSHELPER_VERSION_DEFINED_
#define _FRAMELESSHELPER_VERSION_DEFINED_
#pragma once
[[maybe_unused]] static constexpr const int FRAMELESSHELPER_VERSION_MAJOR = 2;
[[maybe_unused]] static constexpr const int FRAMELESSHELPER_VERSION_MINOR = 2;
[[maybe_unused]] static constexpr const int FRAMELESSHELPER_VERSION_PATCH = 0;
[[maybe_unused]] static constexpr const int FRAMELESSHELPER_VERSION_TWEAK = 0;
[[maybe_unused]] static constexpr const char FRAMELESSHELPER_VERSION_STR[] = "2.2.0.0\0";
[[maybe_unused]] static constexpr const char FRAMELESSHELPER_COMMIT_STR[] = "UNKNOWN\0";
[[maybe_unused]] static constexpr const char FRAMELESSHELPER_COMPILE_DATETIME_STR[] = "UNKNOWN\0";
#endif // _FRAMELESSHELPER_VERSION_DEFINED_

47
qmake/quick.pri Normal file
View File

@ -0,0 +1,47 @@
QT += \
quick quick-private \
quicktemplates2 quicktemplates2-private \
quickcontrols2 quickcontrols2-private
QUICK_PUB_INC_DIR = $$PWD/../include/FramelessHelper/Quick
QUICK_PRIV_INC_DIR = $$QUICK_PUB_INC_DIR/private
QUICK_SRC_DIR = $$PWD/../src/quick
DEFINES += \
FRAMELESSHELPER_QUICK_STATIC
INCLUDEPATH += \
$$QUICK_PUB_INC_DIR \
$$QUICK_PRIV_INC_DIR
DEPENDPATH += \
$$QUICK_PUB_INC_DIR \
$$QUICK_PRIV_INC_DIR
HEADERS += \
$$QUICK_PUB_INC_DIR/framelesshelperquick_global.h \
$$QUICK_PUB_INC_DIR/framelessquickmodule.h \
$$QUICK_PUB_INC_DIR/framelessquickhelper.h \
$$QUICK_PUB_INC_DIR/framelessquickutils.h \
$$QUICK_PUB_INC_DIR/quickchromepalette.h \
$$QUICK_PUB_INC_DIR/quickmicamaterial.h \
$$QUICK_PUB_INC_DIR/quickimageitem.h \
$$QUICK_PRIV_INC_DIR/quickstandardsystembutton_p.h \
$$QUICK_PRIV_INC_DIR/quickstandardtitlebar_p.h \
$$QUICK_PRIV_INC_DIR/framelessquickhelper_p.h \
$$QUICK_PRIV_INC_DIR/framelessquickwindow_p.h \
$$QUICK_PRIV_INC_DIR/framelessquickwindow_p_p.h \
$$QUICK_PRIV_INC_DIR/quickmicamaterial_p.h \
$$QUICK_PRIV_INC_DIR/quickimageitem_p.h
SOURCES += \
$$QUICK_SRC_DIR/quickstandardsystembutton.cpp \
$$QUICK_SRC_DIR/quickstandardtitlebar.cpp \
$$QUICK_SRC_DIR/framelessquickutils.cpp \
$$QUICK_SRC_DIR/framelessquickmodule.cpp \
$$QUICK_SRC_DIR/framelessquickwindow.cpp \
$$QUICK_SRC_DIR/framelessquickhelper.cpp \
$$QUICK_SRC_DIR/quickchromepalette.cpp \
$$QUICK_SRC_DIR/framelesshelperquick_global.cpp \
$$QUICK_SRC_DIR/quickmicamaterial.cpp \
$$QUICK_SRC_DIR/quickimageitem.cpp

39
qmake/widgets.pri Normal file
View File

@ -0,0 +1,39 @@
QT += widgets widgets-private
WIDGETS_PUB_INC_DIR = $$PWD/../include/FramelessHelper/Widgets
WIDGETS_PRIV_INC_DIR = $$WIDGETS_PUB_INC_DIR/private
WIDGETS_SRC_DIR = $$PWD/../src/widgets
DEFINES += \
FRAMELESSHELPER_WIDGETS_STATIC
INCLUDEPATH += \
$$WIDGETS_PUB_INC_DIR \
$$WIDGETS_PRIV_INC_DIR
DEPENDPATH += \
$$WIDGETS_PUB_INC_DIR \
$$WIDGETS_PRIV_INC_DIR
HEADERS += \
$$WIDGETS_PUB_INC_DIR/framelesshelperwidgets_global.h \
$$WIDGETS_PUB_INC_DIR/framelesswidget.h \
$$WIDGETS_PUB_INC_DIR/framelessmainwindow.h \
$$WIDGETS_PUB_INC_DIR/standardsystembutton.h \
$$WIDGETS_PUB_INC_DIR/framelesswidgetshelper.h \
$$WIDGETS_PUB_INC_DIR/standardtitlebar.h \
$$WIDGETS_PRIV_INC_DIR/framelesswidgetshelper_p.h \
$$WIDGETS_PRIV_INC_DIR/standardsystembutton_p.h \
$$WIDGETS_PRIV_INC_DIR/standardtitlebar_p.h \
$$WIDGETS_PRIV_INC_DIR/framelesswidget_p.h \
$$WIDGETS_PRIV_INC_DIR/framelessmainwindow_p.h \
$$WIDGETS_PRIV_INC_DIR/widgetssharedhelper_p.h
SOURCES += \
$$WIDGETS_SRC_DIR/framelessmainwindow.cpp \
$$WIDGETS_SRC_DIR/framelesswidgetshelper.cpp \
$$WIDGETS_SRC_DIR/framelesswidget.cpp \
$$WIDGETS_SRC_DIR/standardsystembutton.cpp \
$$WIDGETS_SRC_DIR/standardtitlebar.cpp \
$$WIDGETS_SRC_DIR/widgetssharedhelper.cpp \
$$WIDGETS_SRC_DIR/framelesshelperwidgets_global.cpp

View File

@ -65,14 +65,13 @@ set(PRIVATE_HEADERS
) )
set(SOURCES set(SOURCES
framelesshelpercore.qrc
utils.cpp utils.cpp
framelesshelper_qt.cpp framelesshelper_qt.cpp
framelessmanager.cpp framelessmanager.cpp
framelessconfig.cpp framelessconfig.cpp
sysapiloader.cpp sysapiloader.cpp
chromepalette.cpp chromepalette.cpp
global.cpp framelesshelpercore_global.cpp
micamaterial.cpp micamaterial.cpp
) )
@ -119,6 +118,20 @@ endif()
add_library(${PROJECT_NAME}::${SUB_PROJ_NAME} ALIAS ${SUB_PROJ_NAME}) add_library(${PROJECT_NAME}::${SUB_PROJ_NAME} ALIAS ${SUB_PROJ_NAME})
add_library(${PROJECT_NAME}::${SUB_MOD_NAME} ALIAS ${SUB_PROJ_NAME}) add_library(${PROJECT_NAME}::${SUB_MOD_NAME} ALIAS ${SUB_PROJ_NAME})
if(${QT_VERSION} VERSION_GREATER_EQUAL 6.2)
qt_add_resources(${SUB_PROJ_NAME} framelesshelpercore
PREFIX
"/org.wangwenx190.${PROJECT_NAME}"
FILES
"resources/fonts/Micon.ttf"
"resources/images/noise.png"
)
else()
target_sources(${SUB_PROJ_NAME} PRIVATE
framelesshelpercore.qrc
)
endif()
if(FRAMELESSHELPER_BUILD_STATIC) if(FRAMELESSHELPER_BUILD_STATIC)
target_compile_definitions(${SUB_PROJ_NAME} PUBLIC target_compile_definitions(${SUB_PROJ_NAME} PUBLIC
FRAMELESSHELPER_CORE_STATIC FRAMELESSHELPER_CORE_STATIC

View File

@ -95,12 +95,11 @@ void FramelessHelperQt::addWindow(const SystemParameters &params)
params.setWindowFlags(params.getWindowFlags() | Qt::FramelessWindowHint); params.setWindowFlags(params.getWindowFlags() | Qt::FramelessWindowHint);
} }
window->installEventFilter(data.eventFilter); window->installEventFilter(data.eventFilter);
#if (defined(Q_OS_LINUX) && (QT_VERSION < QT_VERSION_CHECK(6, 4, 0)))
Utils::registerThemeChangeNotification();
#endif
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
Utils::setSystemTitleBarVisible(windowId, false); Utils::setSystemTitleBarVisible(windowId, false);
#endif #endif
static const bool isQtQuickApplication = (params.getCurrentApplicationType() == ApplicationType::Quick);
FramelessHelper::Core::setApplicationOSThemeAware(true, isQtQuickApplication);
} }
bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event) bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event)

View File

@ -133,22 +133,23 @@ Q_GLOBAL_STATIC(Win32Helper, g_win32Helper)
((uMsg >= WM_NCMOUSEMOVE) && (uMsg <= WM_NCXBUTTONDBLCLK))); ((uMsg >= WM_NCMOUSEMOVE) && (uMsg <= WM_NCXBUTTONDBLCLK)));
const auto releaseButtons = [&data](const std::optional<SystemButtonType> exclude) -> void { const auto releaseButtons = [&data](const std::optional<SystemButtonType> exclude) -> void {
static constexpr const auto defaultButtonState = ButtonState::Unspecified; static constexpr const auto defaultButtonState = ButtonState::Unspecified;
if (!exclude.has_value() || (exclude.value() != SystemButtonType::WindowIcon)) { const SystemButtonType button = exclude.value_or(SystemButtonType::Unknown);
if (button != SystemButtonType::WindowIcon) {
data.params.setSystemButtonState(SystemButtonType::WindowIcon, defaultButtonState); data.params.setSystemButtonState(SystemButtonType::WindowIcon, defaultButtonState);
} }
if (!exclude.has_value() || (exclude.value() != SystemButtonType::Help)) { if (button != SystemButtonType::Help) {
data.params.setSystemButtonState(SystemButtonType::Help, defaultButtonState); data.params.setSystemButtonState(SystemButtonType::Help, defaultButtonState);
} }
if (!exclude.has_value() || (exclude.value() != SystemButtonType::Minimize)) { if (button != SystemButtonType::Minimize) {
data.params.setSystemButtonState(SystemButtonType::Minimize, defaultButtonState); data.params.setSystemButtonState(SystemButtonType::Minimize, defaultButtonState);
} }
if (!exclude.has_value() || (exclude.value() != SystemButtonType::Maximize)) { if (button != SystemButtonType::Maximize) {
data.params.setSystemButtonState(SystemButtonType::Maximize, defaultButtonState); data.params.setSystemButtonState(SystemButtonType::Maximize, defaultButtonState);
} }
if (!exclude.has_value() || (exclude.value() != SystemButtonType::Restore)) { if (button != SystemButtonType::Restore) {
data.params.setSystemButtonState(SystemButtonType::Restore, defaultButtonState); data.params.setSystemButtonState(SystemButtonType::Restore, defaultButtonState);
} }
if (!exclude.has_value() || (exclude.value() != SystemButtonType::Close)) { if (button != SystemButtonType::Close) {
data.params.setSystemButtonState(SystemButtonType::Close, defaultButtonState); data.params.setSystemButtonState(SystemButtonType::Close, defaultButtonState);
} }
}; };
@ -521,13 +522,7 @@ void FramelessHelperWin::addWindow(const SystemParameters &params)
const bool dark = Utils::shouldAppsUseDarkMode(); const bool dark = Utils::shouldAppsUseDarkMode();
static const bool isQtQuickApplication = (params.getCurrentApplicationType() == ApplicationType::Quick); static const bool isQtQuickApplication = (params.getCurrentApplicationType() == ApplicationType::Quick);
// Tell DWM we may need dark theme non-client area (title bar & frame border). // Tell DWM we may need dark theme non-client area (title bar & frame border).
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) FramelessHelper::Core::setApplicationOSThemeAware(true, isQtQuickApplication);
static bool darkModeAwareSet = false;
if (!darkModeAwareSet) {
darkModeAwareSet = true;
Utils::setQtDarkModeAwareEnabled(true, isQtQuickApplication);
}
#endif
Utils::updateWindowFrameBorderColor(windowId, dark); Utils::updateWindowFrameBorderColor(windowId, dark);
static const bool isWin10RS5OrGreater = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1809); static const bool isWin10RS5OrGreater = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1809);
if (isWin10RS5OrGreater) { if (isWin10RS5OrGreater) {

View File

@ -274,6 +274,26 @@ void registerUninitializeHook(const UninitializeHookCallback &cb)
coreData()->uninitHooks.append(cb); coreData()->uninitHooks.append(cb);
} }
void setApplicationOSThemeAware(const bool enable, const bool pureQuick)
{
Q_UNUSED(enable);
Q_UNUSED(pureQuick);
static bool set = false;
if (set) {
return;
}
set = true;
#if (defined(Q_OS_WINDOWS) && (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)))
Utils::setQtDarkModeAwareEnabled(enable, pureQuick);
#endif
#if (defined(Q_OS_LINUX) && (QT_VERSION < QT_VERSION_CHECK(6, 4, 0)))
Utils::registerThemeChangeNotification();
#endif
}
} }
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

@ -24,7 +24,6 @@
#include "registrykey_p.h" #include "registrykey_p.h"
#include <QtCore/qdebug.h> #include <QtCore/qdebug.h>
#include <QtCore/qvariant.h>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
# include <QtCore/private/qwinregistry_p.h> # include <QtCore/private/qwinregistry_p.h>
#else #else

View File

@ -576,9 +576,8 @@ bool Utils::isDwmCompositionEnabled()
if (!registry.isValid()) { if (!registry.isValid()) {
return false; return false;
} }
bool ok = false; const DWORD value = registry.value<DWORD>(kComposition).value_or(0);
const DWORD value = registry.value(kComposition).toULongLong(&ok); return (value != 0);
return (ok && (value != 0));
}; };
if (!API_DWM_AVAILABLE(DwmIsCompositionEnabled)) { if (!API_DWM_AVAILABLE(DwmIsCompositionEnabled)) {
return resultFromRegistry(); return resultFromRegistry();
@ -702,9 +701,8 @@ QColor Utils::getDwmColorizationColor()
if (!registry.isValid()) { if (!registry.isValid()) {
return kDefaultDarkGrayColor; return kDefaultDarkGrayColor;
} }
bool ok = false; const DWORD value = registry.value<DWORD>(kColorizationColor).value_or(0);
const DWORD value = registry.value(kColorizationColor).toULongLong(&ok); return QColor::fromRgba(value);
return (ok ? QColor::fromRgba(value) : kDefaultDarkGrayColor);
}; };
if (!API_DWM_AVAILABLE(DwmGetColorizationColor)) { if (!API_DWM_AVAILABLE(DwmGetColorizationColor)) {
return resultFromRegistry(); return resultFromRegistry();
@ -727,13 +725,11 @@ DwmColorizationArea Utils::getDwmColorizationArea()
return DwmColorizationArea::None_; return DwmColorizationArea::None_;
} }
const RegistryKey themeRegistry(RegistryRootKey::CurrentUser, personalizeRegistryKey()); const RegistryKey themeRegistry(RegistryRootKey::CurrentUser, personalizeRegistryKey());
bool themeOk = false; const DWORD themeValue = themeRegistry.isValid() ? themeRegistry.value<DWORD>(qDwmColorKeyName).value_or(0) : 0;
const DWORD themeValue = themeRegistry.isValid() ? themeRegistry.value(qDwmColorKeyName).toULongLong(&themeOk) : 0;
const RegistryKey dwmRegistry(RegistryRootKey::CurrentUser, dwmRegistryKey()); const RegistryKey dwmRegistry(RegistryRootKey::CurrentUser, dwmRegistryKey());
bool dwmOk = false; const DWORD dwmValue = dwmRegistry.isValid() ? dwmRegistry.value<DWORD>(qDwmColorKeyName).value_or(0) : 0;
const DWORD dwmValue = dwmRegistry.isValid() ? dwmRegistry.value(qDwmColorKeyName).toULongLong(&dwmOk) : 0; const bool theme = (themeValue != 0);
const bool theme = (themeOk && (themeValue != 0)); const bool dwm = (dwmValue != 0);
const bool dwm = (dwmOk && (dwmValue != 0));
if (theme && dwm) { if (theme && dwm) {
return DwmColorizationArea::All; return DwmColorizationArea::All;
} else if (theme) { } else if (theme) {
@ -1518,9 +1514,8 @@ bool Utils::shouldAppsUseDarkMode_windows()
if (!registry.isValid()) { if (!registry.isValid()) {
return false; return false;
} }
bool ok = false; const DWORD value = registry.value<DWORD>(kAppsUseLightTheme).value_or(0);
const DWORD value = registry.value(kAppsUseLightTheme).toULongLong(&ok); return (value == 0);
return (ok && (value == 0));
}; };
// Starting from Windows 10 1903, "ShouldAppsUseDarkMode()" (exported by UXTHEME.DLL, // Starting from Windows 10 1903, "ShouldAppsUseDarkMode()" (exported by UXTHEME.DLL,
// ordinal number 132) always return "TRUE" (actually, a random non-zero number at // ordinal number 132) always return "TRUE" (actually, a random non-zero number at
@ -1752,11 +1747,7 @@ QColor Utils::getDwmAccentColor()
if (!registry.isValid()) { if (!registry.isValid()) {
return kDefaultDarkGrayColor; return kDefaultDarkGrayColor;
} }
bool ok = false; const DWORD value = registry.value<DWORD>(kAccentColor).value_or(0);
const DWORD value = registry.value(kAccentColor).toULongLong(&ok);
if (!ok) {
return kDefaultDarkGrayColor;
}
// The retrieved value is in the #AABBGGRR format, we need to // The retrieved value is in the #AABBGGRR format, we need to
// convert it to the #AARRGGBB format that Qt accepts. // convert it to the #AARRGGBB format that Qt accepts.
const QColor abgr = QColor::fromRgba(value); const QColor abgr = QColor::fromRgba(value);
@ -1780,16 +1771,11 @@ WallpaperAspectStyle Utils::getWallpaperAspectStyle()
if (!registry.isValid()) { if (!registry.isValid()) {
return defaultStyle; return defaultStyle;
} }
bool ok = false; const DWORD wallpaperStyle = registry.value<DWORD>(kWallpaperStyle).value_or(0);
const DWORD wallpaperStyle = registry.value(kWallpaperStyle).toULongLong(&ok);
if (!ok) {
return defaultStyle;
}
switch (wallpaperStyle) { switch (wallpaperStyle) {
case 0: { case 0: {
ok = false; const DWORD tileWallpaper = registry.value<DWORD>(kTileWallpaper).value_or(0);
const DWORD tileWallpaper = registry.value(kTileWallpaper).toULongLong(&ok); if (tileWallpaper != 0) {
if (ok && (tileWallpaper != 0)) {
return WallpaperAspectStyle::Tile; return WallpaperAspectStyle::Tile;
} }
return WallpaperAspectStyle::Center; return WallpaperAspectStyle::Center;
@ -1860,22 +1846,22 @@ void Utils::setQtDarkModeAwareEnabled(const bool enable, const bool pureQuick)
// There's no global dark theme for Qt Quick applications, so setting this // There's no global dark theme for Qt Quick applications, so setting this
// flag has no effect for pure Qt Quick applications. // flag has no effect for pure Qt Quick applications.
return {App::DarkModeWindowFrames | App::DarkModeStyle}; return {App::DarkModeWindowFrames | App::DarkModeStyle};
#else #else // (QT_VERSION < QT_VERSION_CHECK(6, 5, 0))
if (pureQuick) { if (pureQuick) {
// Pure Qt Quick application, it's OK to enable the DarkModeStyle flag. // Pure Qt Quick application, it's OK to enable the DarkModeStyle flag.
return {App::DarkModeWindowFrames | App::DarkModeStyle}; return {App::DarkModeWindowFrames | App::DarkModeStyle};
} }
// Don't try to use the broken dark theme for Qt Widgets applications. // Don't try to use the broken dark theme for Qt Widgets applications.
return {App::DarkModeWindowFrames}; return {App::DarkModeWindowFrames};
#endif #endif // (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
}()); }());
} else { } else {
WARNING << "QWindowsApplication is not available."; WARNING << "QWindowsApplication is not available.";
} }
#else #else // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
Q_UNUSED(enable); Q_UNUSED(enable);
Q_UNUSED(pureQuick); Q_UNUSED(pureQuick);
#endif #endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
} }
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

@ -69,7 +69,7 @@ set(SOURCES
framelessquickwindow.cpp framelessquickwindow.cpp
framelessquickhelper.cpp framelessquickhelper.cpp
quickchromepalette.cpp quickchromepalette.cpp
global.cpp framelesshelperquick_global.cpp
quickmicamaterial.cpp quickmicamaterial.cpp
quickimageitem.cpp quickimageitem.cpp
) )

View File

@ -62,7 +62,7 @@ set(SOURCES
standardsystembutton.cpp standardsystembutton.cpp
standardtitlebar.cpp standardtitlebar.cpp
widgetssharedhelper.cpp widgetssharedhelper.cpp
global.cpp framelesshelperwidgets_global.cpp
) )
if(WIN32 AND NOT FRAMELESSHELPER_BUILD_STATIC) if(WIN32 AND NOT FRAMELESSHELPER_BUILD_STATIC)