mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-04-02 04:38:37 +08:00
update
This commit is contained in:
parent
1990203f3b
commit
80dd3ebd35
@ -13,7 +13,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/.cmake/)
|
|||||||
include(GetGitRevisionDescription)
|
include(GetGitRevisionDescription)
|
||||||
|
|
||||||
option(FLUENTUI_BUILD_EXAMPLES "Build FluentUI demo applications." ON)
|
option(FLUENTUI_BUILD_EXAMPLES "Build FluentUI demo applications." ON)
|
||||||
option(FLUENTUI_BUILD_STATIC_LIB "Build static library." OFF)
|
option(FLUENTUI_BUILD_STATIC_LIB "Build static library." ON)
|
||||||
|
|
||||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
|
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
|
||||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
|
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
|
||||||
|
@ -90,7 +90,7 @@ int main(int argc, char *argv[]) {
|
|||||||
engine.rootContext()->setContextProperty("TranslateHelper", TranslateHelper::getInstance());
|
engine.rootContext()->setContextProperty("TranslateHelper", TranslateHelper::getInstance());
|
||||||
engine.rootContext()->setContextProperty("Network", Network::getInstance());
|
engine.rootContext()->setContextProperty("Network", Network::getInstance());
|
||||||
#ifdef FLUENTUI_BUILD_STATIC_LIB
|
#ifdef FLUENTUI_BUILD_STATIC_LIB
|
||||||
FluentUI::getInstance()->registerTypes(&engine);
|
FluentUI::registerTypes(&engine);
|
||||||
#endif
|
#endif
|
||||||
const QUrl url(QStringLiteral("qrc:/example/qml/App.qml"));
|
const QUrl url(QStringLiteral("qrc:/example/qml/App.qml"));
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
|
@ -145,7 +145,7 @@ endif ()
|
|||||||
if (QT_VERSION VERSION_GREATER_EQUAL "6.2")
|
if (QT_VERSION VERSION_GREATER_EQUAL "6.2")
|
||||||
#如果是Qt6.2版本以上,则使用qt_add_library,qt_add_qml_module函数添加资源文件
|
#如果是Qt6.2版本以上,则使用qt_add_library,qt_add_qml_module函数添加资源文件
|
||||||
if (FLUENTUI_BUILD_STATIC_LIB)
|
if (FLUENTUI_BUILD_STATIC_LIB)
|
||||||
set(FLUENTUI_QML_PLUGIN_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/FluentUI)
|
set(FLUENTUI_QML_PLUGIN_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/FluentUI)
|
||||||
endif ()
|
endif ()
|
||||||
qt_add_library(${PROJECT_NAME} ${LIB_TYPE})
|
qt_add_library(${PROJECT_NAME} ${LIB_TYPE})
|
||||||
qt_add_qml_module(${PROJECT_NAME}
|
qt_add_qml_module(${PROJECT_NAME}
|
||||||
|
@ -23,12 +23,14 @@
|
|||||||
#include "qmlcustomplot/ticker.h"
|
#include "qmlcustomplot/ticker.h"
|
||||||
#include "qmlcustomplot/grid.h"
|
#include "qmlcustomplot/grid.h"
|
||||||
|
|
||||||
|
const char* FluentUI::_uri = "FluentUI";
|
||||||
|
|
||||||
void FluentUI::registerTypes(QQmlEngine *engine) {
|
void FluentUI::registerTypes(QQmlEngine *engine) {
|
||||||
initializeEngine(engine, _uri);
|
initializeEngine(engine, _uri);
|
||||||
registerTypes(_uri);
|
registerTypes(_uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FluentUI::registerTypes(const char *uri) const {
|
void FluentUI::registerTypes(const char *uri) {
|
||||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 2, 0))
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 2, 0))
|
||||||
Q_INIT_RESOURCE(fluentui);
|
Q_INIT_RESOURCE(fluentui);
|
||||||
int major = _major;
|
int major = _major;
|
||||||
|
@ -2,25 +2,22 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
#include "singleton.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The FluentUI class
|
* @brief The FluentUI class
|
||||||
*/
|
*/
|
||||||
class FluentUI : public QObject {
|
class FluentUI{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SINGLETON(FluentUI)
|
|
||||||
|
|
||||||
Q_DECL_EXPORT void registerTypes(QQmlEngine *engine);
|
static Q_DECL_EXPORT void registerTypes(QQmlEngine *engine);
|
||||||
|
|
||||||
void registerTypes(const char *uri) const;
|
static void registerTypes(const char *uri);
|
||||||
|
|
||||||
void initializeEngine(QQmlEngine *engine, [[maybe_unused]] const char *uri);
|
static void initializeEngine(QQmlEngine *engine, [[maybe_unused]] const char *uri);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const int _major = 1;
|
static const int _major = 1;
|
||||||
const int _minor = 0;
|
static const int _minor = 0;
|
||||||
const char *_uri = "FluentUI";
|
static const char *_uri;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user