add support for qmltc tool
Also remove one useless enum. Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
5b852b3d6c
commit
f90b49538a
|
@ -22,16 +22,19 @@
|
|||
SOFTWARE.
|
||||
]]
|
||||
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS QuickControls2)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS QuickControls2)
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Qml Quick QuickControls2)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Qml Quick QuickControls2)
|
||||
|
||||
set(SOURCES
|
||||
qml.qrc
|
||||
main.cpp
|
||||
settings.h
|
||||
settings.cpp
|
||||
)
|
||||
|
||||
if(${QT_VERSION} VERSION_LESS 6.2)
|
||||
list(APPEND SOURCES qml.qrc)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
enable_language(RC)
|
||||
list(APPEND SOURCES ../example.rc ../example.manifest)
|
||||
|
@ -39,6 +42,22 @@ endif()
|
|||
|
||||
add_executable(Quick ${SOURCES})
|
||||
|
||||
if(${QT_VERSION} VERSION_GREATER_EQUAL 6.2)
|
||||
qt_add_qml_module(Quick
|
||||
URI Demo
|
||||
VERSION 1.0
|
||||
IMPORT_PATH ${PROJECT_BINARY_DIR}/imports
|
||||
IMPORTS
|
||||
QtQml
|
||||
QtQuick
|
||||
QtQuick.Controls.Basic
|
||||
org.wangwenx190.FramelessHelper
|
||||
QML_FILES MainWindow.qml
|
||||
#ENABLE_TYPE_COMPILER # We can't use it for now due to it still can't compile singletons.
|
||||
# There's some hope to get it supported in Qt 6.5.
|
||||
)
|
||||
endif()
|
||||
|
||||
set_target_properties(Quick PROPERTIES
|
||||
WIN32_EXECUTABLE TRUE
|
||||
MACOSX_BUNDLE TRUE
|
||||
|
@ -48,8 +67,9 @@ set_target_properties(Quick PROPERTIES
|
|||
)
|
||||
|
||||
target_link_libraries(Quick PRIVATE
|
||||
Qt${QT_VERSION_MAJOR}::Quick
|
||||
Qt${QT_VERSION_MAJOR}::QuickControls2
|
||||
Qt${QT_VERSION_MAJOR}::QmlPrivate
|
||||
Qt${QT_VERSION_MAJOR}::QuickPrivate
|
||||
Qt${QT_VERSION_MAJOR}::QuickControls2Private
|
||||
FramelessHelper::Quick
|
||||
)
|
||||
|
||||
|
|
|
@ -22,11 +22,10 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Window 2.0
|
||||
import QtQuick.Controls 2.0
|
||||
import org.wangwenx190.FramelessHelper 1.0
|
||||
import Demo 1.0
|
||||
import QtQuick
|
||||
import QtQuick.Controls.Basic
|
||||
import org.wangwenx190.FramelessHelper
|
||||
import Demo
|
||||
|
||||
FramelessWindow {
|
||||
id: window
|
||||
|
|
|
@ -22,12 +22,20 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef QMLTC_ENABLED
|
||||
# define QMLTC_ENABLED 0 // We disable it for now, because currently (6.4) it can't process singletons yet.
|
||||
// There's some hope to get it supported in Qt 6.5
|
||||
#endif
|
||||
|
||||
#include <QtGui/qguiapplication.h>
|
||||
#include <QtQml/qqmlapplicationengine.h>
|
||||
#include <QtQuick/qquickwindow.h>
|
||||
#include <QtQuickControls2/qquickstyle.h>
|
||||
#include <framelessquickmodule.h>
|
||||
#include "settings.h"
|
||||
#if QMLTC_ENABLED
|
||||
# include <mainwindow.h>
|
||||
#endif
|
||||
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
|
||||
|
@ -60,7 +68,11 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
#if !QMLTC_ENABLED
|
||||
engine.addImportPath(FRAMELESSHELPER_STRING_LITERAL("../imports"));
|
||||
#endif
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 2, 0)) && !QMLTC_ENABLED
|
||||
// Don't forget to register our own custom QML types!
|
||||
FramelessHelper::Quick::registerTypes(&engine);
|
||||
|
||||
|
@ -70,18 +82,23 @@ int main(int argc, char *argv[])
|
|||
Q_UNUSED(scriptEngine);
|
||||
return new Settings;
|
||||
});
|
||||
#endif
|
||||
|
||||
#if !QMLTC_ENABLED
|
||||
// This line is not relevant to FramelessHelper, we change the default
|
||||
// Qt Quick Controls theme to "Basic" (Qt6) or "Default" (Qt5) just
|
||||
// because other themes will make our homemade system buttons look
|
||||
// not good. This line has nothing to do with FramelessHelper itself.
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
# if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
QQuickStyle::setStyle(FRAMELESSHELPER_STRING_LITERAL("Basic"));
|
||||
#else
|
||||
# else
|
||||
QQuickStyle::setStyle(FRAMELESSHELPER_STRING_LITERAL("Default"));
|
||||
# endif
|
||||
#endif
|
||||
|
||||
const QUrl mainUrl(FRAMELESSHELPER_STRING_LITERAL("qrc:///Demo/qml/MainWindow.qml"));
|
||||
#if !QMLTC_ENABLED
|
||||
const QUrl mainUrl(FRAMELESSHELPER_STRING_LITERAL("qrc:///Demo/MainWindow.qml"));
|
||||
#endif
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed, &application,
|
||||
|
@ -89,7 +106,7 @@ int main(int argc, char *argv[])
|
|||
qCritical() << "The QML engine failed to create component:" << url;
|
||||
QCoreApplication::exit(-1);
|
||||
}, Qt::QueuedConnection);
|
||||
#else
|
||||
#elif !QMLTC_ENABLED
|
||||
const QMetaObject::Connection connection = QObject::connect(
|
||||
&engine, &QQmlApplicationEngine::objectCreated, &application,
|
||||
[&mainUrl, &connection](QObject *object, const QUrl &url) {
|
||||
|
@ -104,7 +121,14 @@ int main(int argc, char *argv[])
|
|||
}, Qt::QueuedConnection);
|
||||
#endif
|
||||
|
||||
#if !QMLTC_ENABLED
|
||||
engine.load(mainUrl);
|
||||
#endif
|
||||
|
||||
#if QMLTC_ENABLED
|
||||
QScopedPointer<MainWindow> mainWindow(new MainWindow(&engine));
|
||||
mainWindow->show();
|
||||
#endif
|
||||
|
||||
return QCoreApplication::exec();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<RCC>
|
||||
<qresource prefix="/Demo/qml">
|
||||
<qresource prefix="/Demo">
|
||||
<file>MainWindow.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include <QtCore/qfileinfo.h>
|
||||
#include <QtCore/qdir.h>
|
||||
#include <QtCore/qdatastream.h>
|
||||
#include <QtGui/qwindow.h>
|
||||
|
||||
FRAMELESSHELPER_STRING_CONSTANT2(IniKeyPath, "Window/Geometry")
|
||||
|
||||
|
|
|
@ -25,16 +25,27 @@
|
|||
#pragma once
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtGui/qwindow.h>
|
||||
#include <framelesshelpercore_global.h>
|
||||
#if __has_include(<QtQml/qqmlregistration.h>)
|
||||
# include <QtQml/qqmlregistration.h>
|
||||
#else
|
||||
# include <QtQml/qqml.h>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QWindow;
|
||||
class QSettings;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class Settings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
#ifdef QML_ELEMENT
|
||||
QML_ELEMENT
|
||||
#endif
|
||||
#ifdef QML_SINGLETON
|
||||
QML_SINGLETON
|
||||
#endif
|
||||
Q_DISABLE_COPY_MOVE(Settings)
|
||||
|
||||
public:
|
||||
|
|
|
@ -240,14 +240,6 @@ enum class SystemButtonType
|
|||
};
|
||||
Q_ENUM_NS(SystemButtonType)
|
||||
|
||||
enum class ResourceType
|
||||
{
|
||||
Image = 0,
|
||||
Pixmap = 1,
|
||||
Icon = 2
|
||||
};
|
||||
Q_ENUM_NS(ResourceType)
|
||||
|
||||
enum class DwmColorizationArea
|
||||
{
|
||||
None_ = 0, // Avoid name conflicts with X11 headers.
|
||||
|
@ -305,7 +297,8 @@ enum class WindowsVersion
|
|||
_10_21H1 = 22,
|
||||
_10_21H2 = 23,
|
||||
_11_21H2 = 24,
|
||||
_11_22H2 = 25
|
||||
_11_22H2 = 25,
|
||||
Latest = _11_22H2
|
||||
};
|
||||
Q_ENUM_NS(WindowsVersion)
|
||||
|
||||
|
@ -491,7 +484,7 @@ struct SystemParameters
|
|||
{10, 0, 22000}, // Windows 11 Version 21H2 (21H2)
|
||||
{10, 0, 22621}, // Windows 11 Version 22H2 (22H2)
|
||||
};
|
||||
static_assert(std::size(WindowsVersions) == (static_cast<int>(WindowsVersion::_11_22H2) + 1));
|
||||
static_assert(std::size(WindowsVersions) == (static_cast<int>(WindowsVersion::Latest) + 1));
|
||||
|
||||
struct VersionInfo
|
||||
{
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#include <framelesshelpercore_global.h>
|
||||
#if __has_include(<QtQml/qqmlregistration.h>)
|
||||
# include <QtQml/qqmlregistration.h>
|
||||
#else
|
||||
# include <QtQml/qqml.h>
|
||||
#endif
|
||||
|
||||
#ifndef FRAMELESSHELPER_QUICK_API
|
||||
|
@ -97,14 +99,6 @@ struct FRAMELESSHELPER_QUICK_API QuickGlobal
|
|||
};
|
||||
Q_ENUM(SystemButtonType)
|
||||
|
||||
enum class ResourceType
|
||||
{
|
||||
FRAMELESSHELPER_QUICK_ENUM_VALUE(ResourceType, Image)
|
||||
FRAMELESSHELPER_QUICK_ENUM_VALUE(ResourceType, Pixmap)
|
||||
FRAMELESSHELPER_QUICK_ENUM_VALUE(ResourceType, Icon)
|
||||
};
|
||||
Q_ENUM(ResourceType)
|
||||
|
||||
enum class DwmColorizationArea
|
||||
{
|
||||
FRAMELESSHELPER_QUICK_ENUM_VALUE(DwmColorizationArea, None_)
|
||||
|
@ -162,8 +156,11 @@ struct FRAMELESSHELPER_QUICK_API QuickGlobal
|
|||
FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _10_21H1)
|
||||
FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _10_21H2)
|
||||
FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _11_21H2)
|
||||
FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _11_22H2)
|
||||
FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, Latest)
|
||||
};
|
||||
Q_ENUM(WindowsVersion)
|
||||
static_assert(static_cast<int>(WindowsVersion::Latest) == static_cast<int>(Global::WindowsVersion::Latest));
|
||||
|
||||
enum class ApplicationType
|
||||
{
|
||||
|
@ -176,10 +173,10 @@ struct FRAMELESSHELPER_QUICK_API QuickGlobal
|
|||
private:
|
||||
Q_GADGET
|
||||
#ifdef QML_NAMED_ELEMENT
|
||||
QML_NAMED_ELEMENT(FramelessHelper)
|
||||
QML_NAMED_ELEMENT(FramelessHelperConstants)
|
||||
#endif
|
||||
#ifdef QML_UNCREATABLE
|
||||
QML_UNCREATABLE("The FramelessHelper namespace is not creatable, you can only use it to access it's enums.")
|
||||
QML_UNCREATABLE("The FramelessHelperConstants namespace is not creatable, you can only use it to access it's enums.")
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -36,6 +36,9 @@ class FRAMELESSHELPER_QUICK_API FramelessQuickHelper : public QQuickItem
|
|||
Q_OBJECT
|
||||
#ifdef QML_NAMED_ELEMENT
|
||||
QML_NAMED_ELEMENT(FramelessHelper)
|
||||
#endif
|
||||
#ifdef QML_ATTACHED
|
||||
QML_ATTACHED(FramelessQuickHelper)
|
||||
#endif
|
||||
Q_DECLARE_PRIVATE(FramelessQuickHelper)
|
||||
Q_DISABLE_COPY_MOVE(FramelessQuickHelper)
|
||||
|
|
|
@ -341,7 +341,6 @@ void FramelessHelper::Core::initialize()
|
|||
qRegisterMetaType<Option>();
|
||||
qRegisterMetaType<SystemTheme>();
|
||||
qRegisterMetaType<SystemButtonType>();
|
||||
qRegisterMetaType<ResourceType>();
|
||||
qRegisterMetaType<DwmColorizationArea>();
|
||||
qRegisterMetaType<Anchor>();
|
||||
qRegisterMetaType<ButtonState>();
|
||||
|
|
|
@ -65,6 +65,24 @@ else()
|
|||
endif()
|
||||
add_library(${PROJECT_NAME}::${SUB_MOD_NAME} ALIAS ${SUB_PROJ_NAME})
|
||||
|
||||
set(_import_dir ${PROJECT_BINARY_DIR}/imports)
|
||||
if(${FRAMELESSHELPER_IMPORT_DIR})
|
||||
set(_import_dir ${FRAMELESSHELPER_IMPORT_DIR})
|
||||
endif()
|
||||
string(APPEND _import_dir /org/wangwenx190/${PROJECT_NAME})
|
||||
|
||||
if(${QT_VERSION} VERSION_GREATER_EQUAL 6.2)
|
||||
qt_add_qml_module(${SUB_PROJ_NAME}
|
||||
URI org.wangwenx190.${PROJECT_NAME}
|
||||
VERSION 1.0
|
||||
OUTPUT_DIRECTORY ${_import_dir}
|
||||
IMPORTS
|
||||
QtQml
|
||||
QtQuick
|
||||
QtQuick.Controls.Basic
|
||||
)
|
||||
endif()
|
||||
|
||||
if(FRAMELESSHELPER_BUILD_STATIC)
|
||||
target_compile_definitions(${SUB_PROJ_NAME} PUBLIC
|
||||
FRAMELESSHELPER_QUICK_STATIC
|
||||
|
|
|
@ -55,7 +55,6 @@ void FramelessHelper::Quick::registerTypes(QQmlEngine *engine)
|
|||
}
|
||||
qRegisterMetaType<QuickGlobal::SystemTheme>();
|
||||
qRegisterMetaType<QuickGlobal::SystemButtonType>();
|
||||
qRegisterMetaType<QuickGlobal::ResourceType>();
|
||||
qRegisterMetaType<QuickGlobal::DwmColorizationArea>();
|
||||
qRegisterMetaType<QuickGlobal::Anchor>();
|
||||
qRegisterMetaType<QuickGlobal::ButtonState>();
|
||||
|
|
Loading…
Reference in New Issue