forked from github_mirror/framelesshelper
quick demo: minor tweaks
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
3a97e712fb
commit
16479be799
|
@ -22,8 +22,8 @@
|
|||
SOFTWARE.
|
||||
]]
|
||||
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Qml Quick QuickControls2)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Qml Quick QuickControls2)
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Quick)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Quick)
|
||||
|
||||
set(SOURCES
|
||||
../shared/log.h
|
||||
|
@ -50,22 +50,25 @@ endif()
|
|||
add_executable(Quick ${SOURCES})
|
||||
|
||||
if(${QT_VERSION} VERSION_GREATER_EQUAL 6.2)
|
||||
set(QML_SOURCES
|
||||
"Window.qml"
|
||||
"ApplicationWindow.qml"
|
||||
"HomePage.qml"
|
||||
)
|
||||
set_source_files_properties(${QML_SOURCES}
|
||||
PROPERTIES QT_DISCARD_FILE_CONTENTS TRUE
|
||||
)
|
||||
qt_add_qml_module(Quick
|
||||
URI Demo
|
||||
VERSION 1.0
|
||||
IMPORT_PATH "${PROJECT_BINARY_DIR}/imports"
|
||||
IMPORT_PATH "${PROJECT_BINARY_DIR}/qml"
|
||||
RESOURCE_PREFIX "/"
|
||||
IMPORTS
|
||||
QtQml/auto
|
||||
QtQuick/auto
|
||||
QtQuick.Controls.Basic/auto
|
||||
DEPENDENCIES
|
||||
org.wangwenx190.FramelessHelper/auto
|
||||
QML_FILES
|
||||
Window.qml
|
||||
ApplicationWindow.qml
|
||||
HomePage.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.
|
||||
QML_FILES ${QML_SOURCES}
|
||||
#ENABLE_TYPE_COMPILER
|
||||
)
|
||||
qt_add_resources(Quick resources
|
||||
PREFIX
|
||||
|
@ -76,9 +79,7 @@ if(${QT_VERSION} VERSION_GREATER_EQUAL 6.2)
|
|||
endif()
|
||||
|
||||
target_link_libraries(Quick PRIVATE
|
||||
Qt${QT_VERSION_MAJOR}::QmlPrivate
|
||||
Qt${QT_VERSION_MAJOR}::QuickPrivate
|
||||
Qt${QT_VERSION_MAJOR}::QuickControls2Private
|
||||
FramelessHelper::Quick
|
||||
)
|
||||
|
||||
|
|
|
@ -23,14 +23,12 @@
|
|||
*/
|
||||
|
||||
#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
|
||||
# define QMLTC_ENABLED 0
|
||||
#endif
|
||||
|
||||
#include <QtGui/qguiapplication.h>
|
||||
#include <QtQml/qqmlapplicationengine.h>
|
||||
#include <QtQuick/qquickwindow.h>
|
||||
#include <QtQuickControls2/qquickstyle.h>
|
||||
#include <framelessquickmodule.h>
|
||||
#include <framelessconfig_p.h>
|
||||
#include <clocale>
|
||||
|
@ -82,10 +80,21 @@ int main(int argc, char *argv[])
|
|||
#endif
|
||||
}
|
||||
|
||||
const auto engine = std::make_unique<QQmlApplicationEngine>();
|
||||
#if (!QMLTC_ENABLED && !defined(QUICK_USE_QMAKE))
|
||||
engine->addImportPath(FRAMELESSHELPER_STRING_LITERAL("../imports"));
|
||||
if (!qEnvironmentVariableIsSet("QT_QUICK_CONTROLS_STYLE")) {
|
||||
// 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.
|
||||
qputenv("QT_QUICK_CONTROLS_STYLE", []() -> QByteArray {
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
return FRAMELESSHELPER_BYTEARRAY_LITERAL("Basic");
|
||||
#else
|
||||
return FRAMELESSHELPER_BYTEARRAY_LITERAL("Default");
|
||||
#endif
|
||||
}());
|
||||
}
|
||||
|
||||
const auto engine = std::make_unique<QQmlApplicationEngine>();
|
||||
|
||||
#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!
|
||||
|
@ -99,18 +108,6 @@ int main(int argc, char *argv[])
|
|||
});
|
||||
#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))
|
||||
QQuickStyle::setStyle(FRAMELESSHELPER_STRING_LITERAL("Basic"));
|
||||
# else
|
||||
QQuickStyle::setStyle(FRAMELESSHELPER_STRING_LITERAL("Default"));
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !QMLTC_ENABLED
|
||||
const QUrl mainUrl(FRAMELESSHELPER_STRING_LITERAL("qrc:///Demo/HomePage.qml"));
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue