File tree Expand file tree Collapse file tree 5 files changed +13
-14
lines changed Expand file tree Collapse file tree 5 files changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/.cmake/)
13
13
include (GetGitRevisionDescription )
14
14
15
15
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 )
17
17
18
18
find_package (QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core )
19
19
find_package (Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core )
Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ int main(int argc, char *argv[]) {
90
90
engine.rootContext ()->setContextProperty (" TranslateHelper" , TranslateHelper::getInstance ());
91
91
engine.rootContext ()->setContextProperty (" Network" , Network::getInstance ());
92
92
#ifdef FLUENTUI_BUILD_STATIC_LIB
93
- FluentUI::getInstance ()-> registerTypes (&engine);
93
+ FluentUI::registerTypes (&engine);
94
94
#endif
95
95
const QUrl url (QStringLiteral (" qrc:/example/qml/App.qml" ));
96
96
QObject::connect (
Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ endif ()
145
145
if (QT_VERSION VERSION_GREATER_EQUAL "6.2" )
146
146
#如果是Qt6.2版本以上,则使用qt_add_library,qt_add_qml_module函数添加资源文件
147
147
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 )
149
149
endif ()
150
150
qt_add_library (${PROJECT_NAME} ${LIB_TYPE} )
151
151
qt_add_qml_module (${PROJECT_NAME}
Original file line number Diff line number Diff line change 23
23
#include " qmlcustomplot/ticker.h"
24
24
#include " qmlcustomplot/grid.h"
25
25
26
+ const char * FluentUI::_uri = " FluentUI" ;
27
+
26
28
void FluentUI::registerTypes (QQmlEngine *engine) {
27
29
initializeEngine (engine, _uri);
28
30
registerTypes (_uri);
29
31
}
30
32
31
- void FluentUI::registerTypes (const char *uri) const {
33
+ void FluentUI::registerTypes (const char *uri) {
32
34
#if (QT_VERSION < QT_VERSION_CHECK(6, 2, 0))
33
35
Q_INIT_RESOURCE (fluentui);
34
36
int major = _major;
Original file line number Diff line number Diff line change 2
2
3
3
#include < QObject>
4
4
#include < QQmlEngine>
5
- #include " singleton.h"
6
5
7
6
/* *
8
7
* @brief The FluentUI class
9
8
*/
10
- class FluentUI : public QObject {
11
- Q_OBJECT
9
+ class FluentUI {
12
10
13
11
public:
14
- SINGLETON (FluentUI)
15
12
16
- Q_DECL_EXPORT void registerTypes (QQmlEngine *engine);
13
+ static Q_DECL_EXPORT void registerTypes (QQmlEngine *engine);
17
14
18
- void registerTypes (const char *uri) const ;
15
+ static void registerTypes (const char *uri);
19
16
20
- void initializeEngine (QQmlEngine *engine, [[maybe_unused]] const char *uri);
17
+ static void initializeEngine (QQmlEngine *engine, [[maybe_unused]] const char *uri);
21
18
22
19
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;
26
23
};
You can’t perform that action at this time.
0 commit comments