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.
|
SOFTWARE.
|
||||||
]]
|
]]
|
||||||
|
|
||||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Qml Quick QuickControls2)
|
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Quick)
|
||||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Qml Quick QuickControls2)
|
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Quick)
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
../shared/log.h
|
../shared/log.h
|
||||||
|
@ -50,22 +50,25 @@ endif()
|
||||||
add_executable(Quick ${SOURCES})
|
add_executable(Quick ${SOURCES})
|
||||||
|
|
||||||
if(${QT_VERSION} VERSION_GREATER_EQUAL 6.2)
|
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
|
qt_add_qml_module(Quick
|
||||||
URI Demo
|
URI Demo
|
||||||
VERSION 1.0
|
VERSION 1.0
|
||||||
IMPORT_PATH "${PROJECT_BINARY_DIR}/imports"
|
IMPORT_PATH "${PROJECT_BINARY_DIR}/qml"
|
||||||
RESOURCE_PREFIX "/"
|
RESOURCE_PREFIX "/"
|
||||||
IMPORTS
|
IMPORTS
|
||||||
QtQml/auto
|
|
||||||
QtQuick/auto
|
QtQuick/auto
|
||||||
QtQuick.Controls.Basic/auto
|
DEPENDENCIES
|
||||||
org.wangwenx190.FramelessHelper/auto
|
org.wangwenx190.FramelessHelper/auto
|
||||||
QML_FILES
|
QML_FILES ${QML_SOURCES}
|
||||||
Window.qml
|
#ENABLE_TYPE_COMPILER
|
||||||
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.
|
|
||||||
)
|
)
|
||||||
qt_add_resources(Quick resources
|
qt_add_resources(Quick resources
|
||||||
PREFIX
|
PREFIX
|
||||||
|
@ -76,9 +79,7 @@ if(${QT_VERSION} VERSION_GREATER_EQUAL 6.2)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(Quick PRIVATE
|
target_link_libraries(Quick PRIVATE
|
||||||
Qt${QT_VERSION_MAJOR}::QmlPrivate
|
|
||||||
Qt${QT_VERSION_MAJOR}::QuickPrivate
|
Qt${QT_VERSION_MAJOR}::QuickPrivate
|
||||||
Qt${QT_VERSION_MAJOR}::QuickControls2Private
|
|
||||||
FramelessHelper::Quick
|
FramelessHelper::Quick
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -23,14 +23,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef QMLTC_ENABLED
|
#ifndef QMLTC_ENABLED
|
||||||
# define QMLTC_ENABLED 0 // We disable it for now, because currently (6.4) it can't process singletons yet.
|
# define QMLTC_ENABLED 0
|
||||||
// There's some hope to get it supported in Qt 6.5
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QtGui/qguiapplication.h>
|
#include <QtGui/qguiapplication.h>
|
||||||
#include <QtQml/qqmlapplicationengine.h>
|
#include <QtQml/qqmlapplicationengine.h>
|
||||||
#include <QtQuick/qquickwindow.h>
|
#include <QtQuick/qquickwindow.h>
|
||||||
#include <QtQuickControls2/qquickstyle.h>
|
|
||||||
#include <framelessquickmodule.h>
|
#include <framelessquickmodule.h>
|
||||||
#include <framelessconfig_p.h>
|
#include <framelessconfig_p.h>
|
||||||
#include <clocale>
|
#include <clocale>
|
||||||
|
@ -82,10 +80,21 @@ int main(int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto engine = std::make_unique<QQmlApplicationEngine>();
|
if (!qEnvironmentVariableIsSet("QT_QUICK_CONTROLS_STYLE")) {
|
||||||
#if (!QMLTC_ENABLED && !defined(QUICK_USE_QMAKE))
|
// This line is not relevant to FramelessHelper, we change the default
|
||||||
engine->addImportPath(FRAMELESSHELPER_STRING_LITERAL("../imports"));
|
// 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
|
#endif
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto engine = std::make_unique<QQmlApplicationEngine>();
|
||||||
|
|
||||||
#if (((QT_VERSION < QT_VERSION_CHECK(6, 2, 0)) || defined(QUICK_USE_QMAKE)) && !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!
|
||||||
|
@ -99,18 +108,6 @@ int main(int argc, char *argv[])
|
||||||
});
|
});
|
||||||
#endif
|
#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
|
#if !QMLTC_ENABLED
|
||||||
const QUrl mainUrl(FRAMELESSHELPER_STRING_LITERAL("qrc:///Demo/HomePage.qml"));
|
const QUrl mainUrl(FRAMELESSHELPER_STRING_LITERAL("qrc:///Demo/HomePage.qml"));
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue