Skip to content

Commit 80dd3eb

Browse files
committed
update
1 parent 1990203 commit 80dd3eb

File tree

5 files changed

+13
-14
lines changed

5 files changed

+13
-14
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/.cmake/)
1313
include(GetGitRevisionDescription)
1414

1515
option(FLUENTUI_BUILD_EXAMPLES "Build FluentUI demo applications." ON)
16-
option(FLUENTUI_BUILD_STATIC_LIB "Build static library." OFF)
16+
option(FLUENTUI_BUILD_STATIC_LIB "Build static library." ON)
1717

1818
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
1919
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)

example/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ int main(int argc, char *argv[]) {
9090
engine.rootContext()->setContextProperty("TranslateHelper", TranslateHelper::getInstance());
9191
engine.rootContext()->setContextProperty("Network", Network::getInstance());
9292
#ifdef FLUENTUI_BUILD_STATIC_LIB
93-
FluentUI::getInstance()->registerTypes(&engine);
93+
FluentUI::registerTypes(&engine);
9494
#endif
9595
const QUrl url(QStringLiteral("qrc:/example/qml/App.qml"));
9696
QObject::connect(

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ endif ()
145145
if (QT_VERSION VERSION_GREATER_EQUAL "6.2")
146146
#如果是Qt6.2版本以上,则使用qt_add_library,qt_add_qml_module函数添加资源文件
147147
if (FLUENTUI_BUILD_STATIC_LIB)
148-
set(FLUENTUI_QML_PLUGIN_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/FluentUI)
148+
set(FLUENTUI_QML_PLUGIN_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/FluentUI)
149149
endif ()
150150
qt_add_library(${PROJECT_NAME} ${LIB_TYPE})
151151
qt_add_qml_module(${PROJECT_NAME}

src/FluentUI.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@
2323
#include "qmlcustomplot/ticker.h"
2424
#include "qmlcustomplot/grid.h"
2525

26+
const char* FluentUI::_uri = "FluentUI";
27+
2628
void FluentUI::registerTypes(QQmlEngine *engine) {
2729
initializeEngine(engine, _uri);
2830
registerTypes(_uri);
2931
}
3032

31-
void FluentUI::registerTypes(const char *uri) const {
33+
void FluentUI::registerTypes(const char *uri) {
3234
#if (QT_VERSION < QT_VERSION_CHECK(6, 2, 0))
3335
Q_INIT_RESOURCE(fluentui);
3436
int major = _major;

src/FluentUI.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,22 @@
22

33
#include <QObject>
44
#include <QQmlEngine>
5-
#include "singleton.h"
65

76
/**
87
* @brief The FluentUI class
98
*/
10-
class FluentUI : public QObject {
11-
Q_OBJECT
9+
class FluentUI{
1210

1311
public:
14-
SINGLETON(FluentUI)
1512

16-
Q_DECL_EXPORT void registerTypes(QQmlEngine *engine);
13+
static Q_DECL_EXPORT void registerTypes(QQmlEngine *engine);
1714

18-
void registerTypes(const char *uri) const;
15+
static void registerTypes(const char *uri);
1916

20-
void initializeEngine(QQmlEngine *engine, [[maybe_unused]] const char *uri);
17+
static void initializeEngine(QQmlEngine *engine, [[maybe_unused]] const char *uri);
2118

2219
private:
23-
const int _major = 1;
24-
const int _minor = 0;
25-
const char *_uri = "FluentUI";
20+
static const int _major = 1;
21+
static const int _minor = 0;
22+
static const char *_uri;
2623
};

0 commit comments

Comments
 (0)