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

Commit

Permalink
quick: minor code simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
wangwenx190 committed Jul 15, 2023
1 parent d71dc75 commit 27663fc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
11 changes: 11 additions & 0 deletions src/quick/framelesshelperquick_global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include "framelesshelperquick_global.h"
#include <QtCore/qloggingcategory.h>

#define REG_META_TYPE(Type) qRegisterMetaType<Type>(#Type)

FRAMELESSHELPER_BEGIN_NAMESPACE

[[maybe_unused]] static Q_LOGGING_CATEGORY(lcQuickGlobal, "wangwenx190.framelesshelper.quick.global")
Expand Down Expand Up @@ -59,6 +61,15 @@ void initialize()
inited = true;

FramelessHelper::Core::initialize();

// Registering meta types only causes troubles in Qt6.
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
REG_META_TYPE(QuickGlobal::SystemTheme);
REG_META_TYPE(QuickGlobal::SystemButtonType);
REG_META_TYPE(QuickGlobal::ButtonState);
REG_META_TYPE(QuickGlobal::BlurMode);
REG_META_TYPE(QuickGlobal::WindowEdge);
#endif
}

void uninitialize()
Expand Down
10 changes: 3 additions & 7 deletions src/quick/framelessquickmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,16 @@ void FramelessHelper::Quick::registerTypes(QQmlEngine *engine)
// @uri org.wangwenx190.FramelessHelper
qmlRegisterUncreatableType<QuickGlobal>(QUICK_URI_FULL, "FramelessHelperConstants",
FRAMELESSHELPER_STRING_LITERAL("The FramelessHelperConstants namespace is not creatable, you can only use it to access it's enums."));

qmlRegisterSingletonType<FramelessQuickUtils>(QUICK_URI_EXPAND("FramelessUtils"),
[](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * {
Q_UNUSED(engine);
Q_UNUSED(scriptEngine);
return new FramelessQuickUtils;
});

qmlRegisterAnonymousType<QuickChromePalette>(QUICK_URI_SHORT);
#if (QT_VERSION <= QT_VERSION_CHECK(5, 16, 0))
qRegisterMetaType<QuickGlobal::SystemTheme>("QuickGlobal::SystemTheme");
qRegisterMetaType<QuickGlobal::SystemButtonType>("QuickGlobal::SystemButtonType");
qRegisterMetaType<QuickGlobal::ButtonState>("QuickGlobal::ButtonState");
qRegisterMetaType<QuickGlobal::BlurMode>("QuickGlobal::BlurMode");
qRegisterMetaType<QuickGlobal::WindowEdge>("QuickGlobal::WindowEdge");
#endif

qmlRegisterType<FramelessQuickHelper>(QUICK_URI_EXPAND("FramelessHelper"));
qmlRegisterType<QuickMicaMaterial>(QUICK_URI_EXPAND("MicaMaterial"));
qmlRegisterType<QuickImageItem>(QUICK_URI_EXPAND("ImageItem"));
Expand Down

0 comments on commit 27663fc

Please sign in to comment.