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

Commit

Permalink
add limited qmake support
Browse files Browse the repository at this point in the history
Signed-off-by: Yuhang Zhao <[email protected]>
  • Loading branch information
wangwenx190 committed Aug 31, 2022
1 parent abf4b29 commit 7a35b09
Show file tree
Hide file tree
Showing 38 changed files with 352 additions and 77 deletions.
12 changes: 12 additions & 0 deletions examples/example.rc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@

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
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
Expand Down
5 changes: 5 additions & 0 deletions examples/mainwindow/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ int main(int argc, char *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::EnableBlurBehindWindow);

Expand Down
5 changes: 5 additions & 0 deletions examples/openglwidget/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ int main(int argc, char *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::EnableBlurBehindWindow);

Expand Down
6 changes: 4 additions & 2 deletions examples/quick/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ if(${QT_VERSION} VERSION_GREATER_EQUAL 6.2)
# There's some hope to get it supported in Qt 6.5.
)
qt_add_resources(Quick resources
PREFIX "/Demo"
FILES "images/microsoft.svg"
PREFIX
"/Demo"
FILES
"images/microsoft.svg"
)
endif()

Expand Down
9 changes: 7 additions & 2 deletions examples/quick/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ int main(int argc, char *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::EnableBlurBehindWindow);

Expand All @@ -75,11 +80,11 @@ int main(int argc, char *argv[])
}

QQmlApplicationEngine engine;
#if !QMLTC_ENABLED
#if (!QMLTC_ENABLED && !defined(QUICK_USE_QMAKE))
engine.addImportPath(FRAMELESSHELPER_STRING_LITERAL("../imports"));
#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!
FramelessHelper::Quick::registerTypes(&engine);

Expand Down
11 changes: 11 additions & 0 deletions examples/quick/quick.pro
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 5 additions & 0 deletions examples/widget/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ int main(int argc, char *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::EnableBlurBehindWindow);

Expand Down
9 changes: 9 additions & 0 deletions examples/widget/widget.pro
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions include/FramelessHelper/Core/framelesshelpercore_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ FRAMELESSHELPER_CORE_API void uninitialize();
[[nodiscard]] FRAMELESSHELPER_CORE_API Global::VersionInfo version();
FRAMELESSHELPER_CORE_API void registerInitializeHook(const Global::InitializeHookCallback &cb);
FRAMELESSHELPER_CORE_API void registerUninitializeHook(const Global::UninitializeHookCallback &cb);
FRAMELESSHELPER_CORE_API void setApplicationOSThemeAware(const bool enable, const bool pureQuick);
} // namespace FramelessHelper::Core

FRAMELESSHELPER_END_NAMESPACE
Expand Down
3 changes: 1 addition & 2 deletions include/FramelessHelper/Core/private/chromepalette_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@
#pragma once

#include "framelesshelpercore_global.h"
#include "chromepalette.h"
#include <QtCore/qobject.h>
#include <QtCore/qpointer.h>
#include <optional>

FRAMELESSHELPER_BEGIN_NAMESPACE

class ChromePalette;

class FRAMELESSHELPER_CORE_API ChromePalettePrivate : public QObject
{
Q_OBJECT
Expand Down
3 changes: 1 addition & 2 deletions include/FramelessHelper/Core/private/micamaterial_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@
#pragma once

#include "framelesshelpercore_global.h"
#include "micamaterial.h"
#include <QtCore/qobject.h>
#include <QtCore/qpointer.h>
#include <QtGui/qbrush.h>

FRAMELESSHELPER_BEGIN_NAMESPACE

class MicaMaterial;

class FRAMELESSHELPER_CORE_API MicaMaterialPrivate : public QObject
{
Q_OBJECT
Expand Down
11 changes: 11 additions & 0 deletions include/FramelessHelper/Core/private/registrykey_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

#include "framelesshelpercore_global.h"
#include <QtCore/qobject.h>
#include <QtCore/qvariant.h>
#include <optional>

QT_BEGIN_NAMESPACE
class QWinRegistryKey;
Expand All @@ -49,6 +51,15 @@ class FRAMELESSHELPER_CORE_API RegistryKey : public QObject
Q_NODISCARD bool isValid() 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:
Global::RegistryRootKey m_rootKey = Global::RegistryRootKey::CurrentUser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#pragma once

#include "framelesshelperquick_global.h"
#include "framelessquickhelper.h"
#include <QtCore/qobject.h>
#include <QtCore/qpointer.h>

Expand All @@ -35,7 +36,6 @@ QT_END_NAMESPACE
FRAMELESSHELPER_BEGIN_NAMESPACE

struct QuickHelperData;
class FramelessQuickHelper;

class FRAMELESSHELPER_QUICK_API FramelessQuickHelperPrivate : public QObject
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "framelesshelperquick_global.h"
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include "framelessquickwindow_p.h"
#include <QtCore/qobject.h>
#include <QtQuick/qquickwindow.h>
#include <QtQuick/private/qquickanchors_p_p.h>
Expand All @@ -36,8 +37,6 @@ QT_END_NAMESPACE

FRAMELESSHELPER_BEGIN_NAMESPACE

class FramelessQuickWindow;

class FRAMELESSHELPER_QUICK_API FramelessQuickWindowPrivate : public QObject
{
Q_OBJECT
Expand Down
3 changes: 1 addition & 2 deletions include/FramelessHelper/Quick/private/quickimageitem_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@
#pragma once

#include "framelesshelperquick_global.h"
#include "quickimageitem.h"
#include <QtCore/qobject.h>
#include <QtCore/qpointer.h>
#include <QtCore/qvariant.h>

FRAMELESSHELPER_BEGIN_NAMESPACE

class QuickImageItem;

class FRAMELESSHELPER_QUICK_API QuickImageItemPrivate : public QObject
{
Q_OBJECT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
#pragma once

#include "framelesshelperquick_global.h"
#include "quickmicamaterial.h"
#include <QtCore/qobject.h>
#include <QtCore/qpointer.h>

FRAMELESSHELPER_BEGIN_NAMESPACE

class QuickMicaMaterial;
class WallpaperImageNode;

class FRAMELESSHELPER_QUICK_API QuickMicaMaterialPrivate : public QObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "framelesshelperquick_global.h"
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include "quickchromepalette.h"
#include "quickstandardsystembutton_p.h"
#include <QtQuick/private/qquickrectangle_p.h>
#include <QtQuickTemplates2/private/qquicklabel_p.h>

Expand All @@ -36,7 +37,6 @@ QT_END_NAMESPACE

FRAMELESSHELPER_BEGIN_NAMESPACE

class QuickStandardSystemButton;
class QuickImageItem;

class FRAMELESSHELPER_QUICK_API QuickStandardTitleBar : public QQuickRectangle
Expand Down
1 change: 1 addition & 0 deletions include/FramelessHelper/Widgets/framelesswidgetshelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "framelesshelperwidgets_global.h"
#include <QtCore/qobject.h>
#include <QtCore/qloggingcategory.h>
#include <QtWidgets/qwidget.h>

FRAMELESSHELPER_BEGIN_NAMESPACE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
#pragma once

#include "framelesshelperwidgets_global.h"
#include "framelessmainwindow.h"
#include <QtCore/qobject.h>
#include <QtCore/qpointer.h>

FRAMELESSHELPER_BEGIN_NAMESPACE

class FramelessMainWindow;
class WidgetsSharedHelper;

class FRAMELESSHELPER_WIDGETS_API FramelessMainWindowPrivate : public QObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
#pragma once

#include "framelesshelperwidgets_global.h"
#include "framelesswidget.h"
#include <QtCore/qobject.h>
#include <QtCore/qpointer.h>

FRAMELESSHELPER_BEGIN_NAMESPACE

class FramelessWidget;
class WidgetsSharedHelper;

class FRAMELESSHELPER_WIDGETS_API FramelessWidgetPrivate : public QObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
#pragma once

#include "framelesshelperwidgets_global.h"
#include "framelesswidgetshelper.h"
#include <QtCore/qobject.h>
#include <QtCore/qpointer.h>

FRAMELESSHELPER_BEGIN_NAMESPACE

struct WidgetsHelperData;
class FramelessWidgetsHelper;

class FRAMELESSHELPER_WIDGETS_API FramelessWidgetsHelperPrivate : public QObject
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@

#pragma once

#include "framelesshelperwidgets_global.h"
#include "standardsystembutton.h"
#include <QtCore/qobject.h>
#include <QtCore/qpointer.h>
#include "framelesshelperwidgets_global.h"

QT_BEGIN_NAMESPACE
class QEnterEvent;
Expand All @@ -35,8 +36,6 @@ QT_END_NAMESPACE

FRAMELESSHELPER_BEGIN_NAMESPACE

class StandardSystemButton;

class FRAMELESSHELPER_WIDGETS_API StandardSystemButtonPrivate : public QObject
{
Q_OBJECT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#pragma once

#include "framelesshelperwidgets_global.h"
#include "standardtitlebar.h"
#include <QtCore/qobject.h>
#include <QtCore/qpointer.h>

Expand All @@ -34,7 +35,6 @@ QT_END_NAMESPACE

FRAMELESSHELPER_BEGIN_NAMESPACE

class StandardTitleBar;
class StandardSystemButton;
class ChromePalette;

Expand Down
4 changes: 2 additions & 2 deletions include/FramelessHelper/Widgets/standardtitlebar.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@
#pragma once

#include "framelesshelperwidgets_global.h"
#include <QtCore/qloggingcategory.h>
#include "standardsystembutton.h"
#include <chromepalette.h>
#include <QtCore/qloggingcategory.h>
#include <QtWidgets/qwidget.h>

FRAMELESSHELPER_BEGIN_NAMESPACE

Q_DECLARE_LOGGING_CATEGORY(lcStandardTitleBar)

class StandardTitleBarPrivate;
class StandardSystemButton;

class FRAMELESSHELPER_WIDGETS_API StandardTitleBar : public QWidget
{
Expand Down
Loading

0 comments on commit 7a35b09

Please sign in to comment.