Compatible with static build

This commit is contained in:
朱子楚\zhuzi 2023-09-09 20:09:20 +08:00
parent ef40e3b109
commit 618b21854f
12 changed files with 345 additions and 212 deletions

View File

@ -1,5 +1,6 @@
include(CMakeParseArguments)
find_package(Qt5 REQUIRED COMPONENTS Core)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
function(FindQmlPluginDump)
get_target_property (QT_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION)
@ -35,7 +36,6 @@ function(add_qmlplugin TARGET)
${QMLPLUGIN_SOURCES}
)
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/lib)
add_custom_target("${TARGET}-qmlfiles" SOURCES ${QMLPLUGIN_QMLFILES})
if(QMLPLUGIN_NO_AUTORCC)
set_target_properties(${TARGET} PROPERTIES AUTOMOC OFF)

View File

@ -1,5 +1,3 @@
// 应用程序版本信息
// 请勿修改此头文件,因为这个文件是自动生成的
#ifndef VERSION_H
#define VERSION_H

View File

@ -122,7 +122,7 @@ else()
target_include_directories(example PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
)
target_sources(example PRIVATE resource.qrc)
target_sources(example PRIVATE example.qrc)
endif()
#component,QML_NAMED_ELEMENTc++
@ -130,6 +130,13 @@ target_include_directories(example PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/component
)
#FluentUI.h
if(FLUENTUI_BUILD_STATIC_LIB)
target_include_directories(example PRIVATE
${CMAKE_SOURCE_DIR}/src
)
endif()
#
set_target_properties(example PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
@ -139,18 +146,6 @@ set_target_properties(example PROPERTIES
WIN32_EXECUTABLE TRUE
)
#
if (FLUENTUI_BUILD_STATIC_LIB)
target_link_libraries(example PRIVATE
Qt${QT_VERSION_MAJOR}::Quick
Qt${QT_VERSION_MAJOR}::Svg
Qt${QT_VERSION_MAJOR}::Network
fluentui
fluentuiplugin
FramelessHelper::Core
FramelessHelper::Quick
)
else()
target_link_libraries(example PRIVATE
Qt${QT_VERSION_MAJOR}::Quick
Qt${QT_VERSION_MAJOR}::Svg
@ -159,7 +154,6 @@ else()
FramelessHelper::Core
FramelessHelper::Quick
)
endif()
#
install(TARGETS example

View File

@ -8,10 +8,17 @@
#include <QProcess>
#include <FramelessHelper/Quick/framelessquickmodule.h>
#include <FramelessHelper/Core/private/framelessconfig_p.h>
#include <QtQml/qqmlextensionplugin.h>
#include "AppInfo.h"
#include "src/component/CircularReveal.h"
#include "src/component/FileWatcher.h"
#include "src/component/FpsItem.h"
#ifdef FLUENTUI_BUILD_STATIC_LIB
#if (QT_VERSION > QT_VERSION_CHECK(6, 2, 0))
Q_IMPORT_QML_PLUGIN(FluentUIPlugin)
#endif
#include <FluentUI.h>
#endif
FRAMELESSHELPER_USE_NAMESPACE
@ -24,7 +31,6 @@ int main(int argc, char *argv[])
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endif
#endif
//将样式设置为Basic不然会导致组件显示异常
qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
FramelessHelper::Quick::initialize();
QGuiApplication::setOrganizationName("ZhuZiChu");
@ -35,7 +41,7 @@ int main(int argc, char *argv[])
FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow);
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur);
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
#ifdef Q_OS_WIN // 此设置仅在Windows下生效
#ifdef Q_OS_WIN
FramelessConfig::instance()->set(Global::Option::ForceHideWindowFrameBorder);
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow,false);
#endif
@ -46,8 +52,9 @@ int main(int argc, char *argv[])
QQmlApplicationEngine engine;
FramelessHelper::Quick::registerTypes(&engine);
#ifdef FLUENTUI_BUILD_STATIC_LIB
engine.addImportPath("qrc:/"); // 让静态资源可以被QML引擎搜索到
FluentUI::getInstance()->registerTypes(&engine);
#endif
qDebug()<<engine.importPathList();
qmlRegisterType<CircularReveal>("example", 1, 0, "CircularReveal");
qmlRegisterType<FileWatcher>("example", 1, 0, "FileWatcher");
qmlRegisterType<FpsItem>("example", 1, 0, "FpsItem");

View File

@ -1,16 +1,21 @@
cmake_minimum_required(VERSION 3.20)
if (FLUENTUI_BUILD_STATIC_LIB)
if (FLUENTUI_BUILD_STATIC_LIB AND (QT_VERSION VERSION_GREATER_EQUAL "6.2"))
project(fluentui LANGUAGES CXX)
else()
project(fluentuiplugin LANGUAGES CXX)
endif()
#
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(APPLE)
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
endif()
if (FLUENTUI_BUILD_STATIC_LIB)
add_definitions(-DFLUENTUI_BUILD_STATIC_LIB)
endif()
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Quick Qml)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Quick Qml)
@ -63,6 +68,7 @@ if (FLUENTUI_BUILD_STATIC_LIB)
set(LIB_TYPE "STATIC")
else()
set(LIB_TYPE "SHARED")
list(REMOVE_ITEM sources_files FluentUI.h FluentUI.cpp)
endif()
if (FLUENTUI_BUILD_STATIC_LIB)
@ -83,6 +89,9 @@ if(WIN32)
endif()
if(QT_VERSION VERSION_GREATER_EQUAL "6.2")
if(FLUENTUI_BUILD_STATIC_LIB)
set(FLUENTUI_QML_PLUGIN_DIRECTORY ${CMAKE_BINARY_DIR}/FluentUI)
endif()
qt_add_library(${PROJECT_NAME} ${LIB_TYPE})
qt_add_qml_module(${PROJECT_NAME}
PLUGIN_TARGET ${PLUGIN_TARGET_NAME}
@ -94,14 +103,14 @@ if(QT_VERSION VERSION_GREATER_EQUAL "6.2")
SOURCES ${sources_files} ${FLUENTUI_VERSION_RC_PATH}
QML_FILES ${qml_files}
RESOURCES ${resource_files}
RESOURCE_PREFIX "/"
RESOURCE_PREFIX "/qt/qml"
)
else()
include(QmlPlugin)
add_qmlplugin(${PROJECT_NAME}
URI "FluentUI"
VERSION 1.0
SOURCES ${sources_files} ${FLUENTUI_VERSION_RC_PATH} resource.qrc
SOURCES ${sources_files} ${FLUENTUI_VERSION_RC_PATH} Qt5/imports/fluentui.qrc
QMLFILES ${qml_files}
QMLDIR imports/FluentUI
BINARY_DIR ${FLUENTUI_QML_PLUGIN_DIRECTORY}

182
src/FluentUI.cpp Normal file
View File

@ -0,0 +1,182 @@
#include "FluentUI.h"
#include <QGuiApplication>
#include "WindowHelper.h"
#include "Def.h"
#include "FluApp.h"
#include "FluColors.h"
#include "FluTheme.h"
#include "FluTools.h"
#include "FluTextStyle.h"
#include "FluHttp.h"
#include "FluHttpInterceptor.h"
#include "FluWatermark.h"
#include "FluCaptcha.h"
#include "Screenshot.h"
#include "QRCode.h"
int major = 1;
int minor = 0;
auto uri = "FluentUI";
FluentUI* FluentUI::m_instance = nullptr;
FluentUI *FluentUI::getInstance()
{
if(FluentUI::m_instance == nullptr){
FluentUI::m_instance = new FluentUI;
}
return FluentUI::m_instance;
}
void FluentUI::registerTypes(QQmlEngine *engine){
initializeEngine(engine,uri);
registerTypes(uri);
}
void FluentUI::registerTypes(const char *uri){
#if (QT_VERSION < QT_VERSION_CHECK(6, 2, 0))
Q_INIT_RESOURCE(fluentui);
#endif
qmlRegisterType<WindowHelper>(uri,major,minor,"WindowHelper");
qmlRegisterType<QRCode>(uri,major,minor,"QRCode");
qmlRegisterType<FluCaptcha>(uri,major,minor,"FluCaptcha");
qmlRegisterType<FluWatermark>(uri,major,minor,"FluWatermark");
qmlRegisterType<ScreenshotBackground>(uri,major,minor,"ScreenshotBackground");
qmlRegisterType<Screenshot>(uri,major,minor,"Screenshot");
qmlRegisterType<FluColorSet>(uri,major,minor,"FluColorSet");
qmlRegisterType<FluHttpInterceptor>(uri,major,minor,"FluHttpInterceptor");
qmlRegisterType<FluHttp>(uri,major,minor,"FluHttp");
qmlRegisterType<HttpCallable>(uri,major,minor,"HttpCallable");
qmlRegisterType<HttpRequest>(uri,major,minor,"HttpRequest");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/ColorPicker/ColorPicker.qml"),uri,major,minor,"ColorPicker");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/ColorPicker/Content/Checkerboard.qml"),uri,major,minor,"Checkerboard");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/ColorPicker/Content/ColorSlider.qml"),uri,major,minor,"ColorSlider");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/ColorPicker/Content/NumberBox.qml"),uri,major,minor,"NumberBox");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/ColorPicker/Content/PanelBorder.qml"),uri,major,minor,"PanelBorder");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/ColorPicker/Content/SBPicker.qml"),uri,major,minor,"SBPicker");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluAcrylic.qml"),uri,major,minor,"FluAcrylic");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluAppBar.qml"),uri,major,minor,"FluAppBar");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluArea.qml"),uri,major,minor,"FluArea");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluAutoSuggestBox.qml"),uri,major,minor,"FluAutoSuggestBox");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluBadge.qml"),uri,major,minor,"FluBadge");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluBreadcrumbBar.qml"),uri,major,minor,"FluBreadcrumbBar");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluButton.qml"),uri,major,minor,"FluButton");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluCalendarPicker.qml"),uri,major,minor,"FluCalendarPicker");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluCalendarView.qml"),uri,major,minor,"FluCalendarView");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluCarousel.qml"),uri,major,minor,"FluCarousel");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluChart.qml"),uri,major,minor,"FluChart");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluCheckBox.qml"),uri,major,minor,"FluCheckBox");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluColorPicker.qml"),uri,major,minor,"FluColorPicker");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluColorView.qml"),uri,major,minor,"FluColorView");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluComboBox.qml"),uri,major,minor,"FluComboBox");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluContentDialog.qml"),uri,major,minor,"FluContentDialog");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluContentPage.qml"),uri,major,minor,"FluContentPage");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluControl.qml"),uri,major,minor,"FluControl");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluCopyableText.qml"),uri,major,minor,"FluCopyableText");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluDatePicker.qml"),uri,major,minor,"FluDatePicker");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluDivider.qml"),uri,major,minor,"FluDivider");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluDropDownButton.qml"),uri,major,minor,"FluDropDownButton");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluExpander.qml"),uri,major,minor,"FluExpander");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluFilledButton.qml"),uri,major,minor,"FluFilledButton");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluFlipView.qml"),uri,major,minor,"FluFlipView");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluFocusRectangle.qml"),uri,major,minor,"FluFocusRectangle");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluIcon.qml"),uri,major,minor,"FluIcon");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluIconButton.qml"),uri,major,minor,"FluIconButton");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluImage.qml"),uri,major,minor,"FluImage");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluInfoBar.qml"),uri,major,minor,"FluInfoBar");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluItem.qml"),uri,major,minor,"FluItem");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluItemDelegate.qml"),uri,major,minor,"FluItemDelegate");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluMenu.qml"),uri,major,minor,"FluMenu");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluMenuBar.qml"),uri,major,minor,"FluMenuBar");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluMenuBarItem.qml"),uri,major,minor,"FluMenuBarItem");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluMenuItem.qml"),uri,major,minor,"FluMenuItem");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluMenuSeparator.qml"),uri,major,minor,"FluMenuSeparator");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluMultilineTextBox.qml"),uri,major,minor,"FluMultilineTextBox");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluNavigationView.qml"),uri,major,minor,"FluNavigationView");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluObject.qml"),uri,major,minor,"FluObject");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluPage.qml"),uri,major,minor,"FluPage");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluPagination.qml"),uri,major,minor,"FluPagination");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluPaneItem.qml"),uri,major,minor,"FluPaneItem");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluPaneItemEmpty.qml"),uri,major,minor,"FluPaneItemEmpty");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluPaneItemExpander.qml"),uri,major,minor,"FluPaneItemExpander");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluPaneItemHeader.qml"),uri,major,minor,"FluPaneItemHeader");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluPaneItemSeparator.qml"),uri,major,minor,"FluPaneItemSeparator");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluPasswordBox.qml"),uri,major,minor,"FluPasswordBox");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluPivot.qml"),uri,major,minor,"FluPivot");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluPivotItem.qml"),uri,major,minor,"FluPivotItem");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluPopup.qml"),uri,major,minor,"FluPopup");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluProgressBar.qml"),uri,major,minor,"FluProgressBar");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluProgressRing.qml"),uri,major,minor,"FluProgressRing");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluQRCode.qml"),uri,major,minor,"FluQRCode");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluRadioButton.qml"),uri,major,minor,"FluRadioButton");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluRadioButtons.qml"),uri,major,minor,"FluRadioButtons");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluRatingControl.qml"),uri,major,minor,"FluRatingControl");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluRectangle.qml"),uri,major,minor,"FluRectangle");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluRemoteLoader.qml"),uri,major,minor,"FluRemoteLoader");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluScreenshot.qml"),uri,major,minor,"FluScreenshot");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluScrollBar.qml"),uri,major,minor,"FluScrollBar");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluScrollIndicator.qml"),uri,major,minor,"FluScrollIndicator");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluScrollablePage.qml"),uri,major,minor,"FluScrollablePage");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluShadow.qml"),uri,major,minor,"FluShadow");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluSlider.qml"),uri,major,minor,"FluSlider");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluSpinBox.qml"),uri,major,minor,"FluSpinBox");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluStatusView.qml"),uri,major,minor,"FluStatusView");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluTabView.qml"),uri,major,minor,"FluTabView");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluTableModelColumn.qml"),uri,major,minor,"FluTableModelColumn");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluTableView.qml"),uri,major,minor,"FluTableView");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluText.qml"),uri,major,minor,"FluText");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluTextBox.qml"),uri,major,minor,"FluTextBox");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluTextBoxBackground.qml"),uri,major,minor,"FluTextBoxBackground");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluTextBoxMenu.qml"),uri,major,minor,"FluTextBoxMenu");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluTextButton.qml"),uri,major,minor,"FluTextButton");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluTimePicker.qml"),uri,major,minor,"FluTimePicker");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluTimeline.qml"),uri,major,minor,"FluTimeline");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluToggleButton.qml"),uri,major,minor,"FluToggleButton");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluToggleSwitch.qml"),uri,major,minor,"FluToggleSwitch");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluTooltip.qml"),uri,major,minor,"FluTooltip");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluTour.qml"),uri,major,minor,"FluTour");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluTreeView.qml"),uri,major,minor,"FluTreeView");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluWindow.qml"),uri,major,minor,"FluWindow");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluRangeSlider.qml"),uri,major,minor,"FluRangeSlider");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluStaggeredView.qml"),uri,major,minor,"FluStaggeredView");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluProgressButton.qml"),uri,major,minor,"FluProgressButton");
qmlRegisterUncreatableMetaObject(Fluent_Awesome::staticMetaObject, uri,major,minor,"FluentIcons", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluHttpType::staticMetaObject, uri,major,minor,"FluHttpType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluThemeType::staticMetaObject, uri,major,minor,"FluThemeType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluPageType::staticMetaObject, uri,major,minor,"FluPageType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluWindowType::staticMetaObject, uri,major,minor,"FluWindowType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluTreeViewType::staticMetaObject, uri,major,minor,"FluTreeViewType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluStatusViewType::staticMetaObject, uri,major,minor,"FluStatusViewType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluContentDialogType::staticMetaObject, uri,major,minor,"FluContentDialogType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluTimePickerType::staticMetaObject, uri,major,minor,"FluTimePickerType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluCalendarViewType::staticMetaObject, uri,major,minor,"FluCalendarViewType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluTabViewType::staticMetaObject, uri,major,minor,"FluTabViewType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluNavigationViewType::staticMetaObject, uri,major,minor,"FluNavigationViewType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluTimelineType::staticMetaObject, uri,major,minor,"FluTimelineType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluScreenshotType::staticMetaObject, uri,major,minor,"FluScreenshotType", "Access to enums & flags only");
qmlRegisterModule(uri,major,minor);
}
void FluentUI::initializeEngine(QQmlEngine *engine, const char *uri){
#ifdef Q_OS_WIN
QFont font;
font.setFamily("Microsoft YaHei");
QGuiApplication::setFont(font);
#endif
FluApp* app = FluApp::getInstance();
engine->rootContext()->setContextProperty("FluApp",app);
FluColors* colors = FluColors::getInstance();
engine->rootContext()->setContextProperty("FluColors",colors);
FluTheme* theme = FluTheme::getInstance();
engine->rootContext()->setContextProperty("FluTheme",theme);
FluTools* tools = FluTools::getInstance();
engine->rootContext()->setContextProperty("FluTools",tools);
FluTextStyle* textStyle = FluTextStyle::getInstance();
engine->rootContext()->setContextProperty("FluTextStyle",textStyle);
engine->addImportPath("qrc:/qt/qml");
}

19
src/FluentUI.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef FLUENTUI_H
#define FLUENTUI_H
#include <QObject>
#include <QQmlEngine>
class FluentUI : public QObject
{
Q_OBJECT
public:
static FluentUI *getInstance();
Q_DECL_EXPORT void registerTypes(QQmlEngine *engine);
void registerTypes(const char *uri);
void initializeEngine(QQmlEngine *engine, const char *uri);
private:
static FluentUI* m_instance;
};
#endif // FLUENTUI_H

View File

@ -0,0 +1,99 @@
<RCC>
<qresource prefix="/qt/qml">
<file>FluentUI/JS/Chart.js</file>
<file>FluentUI/Image/noise.png</file>
<file>FluentUI/Font/Segoe_Fluent_Icons.ttf</file>
<file>FluentUI/Controls/FluAcrylic.qml</file>
<file>FluentUI/Controls/FluAppBar.qml</file>
<file>FluentUI/Controls/FluArea.qml</file>
<file>FluentUI/Controls/FluAutoSuggestBox.qml</file>
<file>FluentUI/Controls/FluBadge.qml</file>
<file>FluentUI/Controls/FluBreadcrumbBar.qml</file>
<file>FluentUI/Controls/FluButton.qml</file>
<file>FluentUI/Controls/FluCalendarPicker.qml</file>
<file>FluentUI/Controls/FluCalendarView.qml</file>
<file>FluentUI/Controls/FluCarousel.qml</file>
<file>FluentUI/Controls/FluChart.qml</file>
<file>FluentUI/Controls/FluCheckBox.qml</file>
<file>FluentUI/Controls/FluColorPicker.qml</file>
<file>FluentUI/Controls/FluColorView.qml</file>
<file>FluentUI/Controls/FluComboBox.qml</file>
<file>FluentUI/Controls/FluContentDialog.qml</file>
<file>FluentUI/Controls/FluContentPage.qml</file>
<file>FluentUI/Controls/FluControl.qml</file>
<file>FluentUI/Controls/FluCopyableText.qml</file>
<file>FluentUI/Controls/FluDatePicker.qml</file>
<file>FluentUI/Controls/FluDivider.qml</file>
<file>FluentUI/Controls/FluDropDownButton.qml</file>
<file>FluentUI/Controls/FluExpander.qml</file>
<file>FluentUI/Controls/FluFilledButton.qml</file>
<file>FluentUI/Controls/FluFlipView.qml</file>
<file>FluentUI/Controls/FluFocusRectangle.qml</file>
<file>FluentUI/Controls/FluIcon.qml</file>
<file>FluentUI/Controls/FluIconButton.qml</file>
<file>FluentUI/Controls/FluImage.qml</file>
<file>FluentUI/Controls/FluInfoBar.qml</file>
<file>FluentUI/Controls/FluItem.qml</file>
<file>FluentUI/Controls/FluItemDelegate.qml</file>
<file>FluentUI/Controls/FluMenu.qml</file>
<file>FluentUI/Controls/FluMenuBar.qml</file>
<file>FluentUI/Controls/FluMenuBarItem.qml</file>
<file>FluentUI/Controls/FluMenuItem.qml</file>
<file>FluentUI/Controls/FluMenuSeparator.qml</file>
<file>FluentUI/Controls/FluMultilineTextBox.qml</file>
<file>FluentUI/Controls/FluNavigationView.qml</file>
<file>FluentUI/Controls/FluObject.qml</file>
<file>FluentUI/Controls/FluPage.qml</file>
<file>FluentUI/Controls/FluPagination.qml</file>
<file>FluentUI/Controls/FluPaneItem.qml</file>
<file>FluentUI/Controls/FluPaneItemEmpty.qml</file>
<file>FluentUI/Controls/FluPaneItemExpander.qml</file>
<file>FluentUI/Controls/FluPaneItemHeader.qml</file>
<file>FluentUI/Controls/FluPaneItemSeparator.qml</file>
<file>FluentUI/Controls/FluPasswordBox.qml</file>
<file>FluentUI/Controls/FluPivot.qml</file>
<file>FluentUI/Controls/FluPivotItem.qml</file>
<file>FluentUI/Controls/FluPopup.qml</file>
<file>FluentUI/Controls/FluProgressBar.qml</file>
<file>FluentUI/Controls/FluProgressButton.qml</file>
<file>FluentUI/Controls/FluProgressRing.qml</file>
<file>FluentUI/Controls/FluQRCode.qml</file>
<file>FluentUI/Controls/FluRadioButton.qml</file>
<file>FluentUI/Controls/FluRadioButtons.qml</file>
<file>FluentUI/Controls/FluRangeSlider.qml</file>
<file>FluentUI/Controls/FluRatingControl.qml</file>
<file>FluentUI/Controls/FluRectangle.qml</file>
<file>FluentUI/Controls/FluRemoteLoader.qml</file>
<file>FluentUI/Controls/FluScreenshot.qml</file>
<file>FluentUI/Controls/FluScrollablePage.qml</file>
<file>FluentUI/Controls/FluScrollBar.qml</file>
<file>FluentUI/Controls/FluScrollIndicator.qml</file>
<file>FluentUI/Controls/FluShadow.qml</file>
<file>FluentUI/Controls/FluSlider.qml</file>
<file>FluentUI/Controls/FluSpinBox.qml</file>
<file>FluentUI/Controls/FluStaggeredView.qml</file>
<file>FluentUI/Controls/FluStatusView.qml</file>
<file>FluentUI/Controls/FluTableModelColumn.qml</file>
<file>FluentUI/Controls/FluTableView.qml</file>
<file>FluentUI/Controls/FluTabView.qml</file>
<file>FluentUI/Controls/FluText.qml</file>
<file>FluentUI/Controls/FluTextBox.qml</file>
<file>FluentUI/Controls/FluTextBoxBackground.qml</file>
<file>FluentUI/Controls/FluTextBoxMenu.qml</file>
<file>FluentUI/Controls/FluTextButton.qml</file>
<file>FluentUI/Controls/FluTimeline.qml</file>
<file>FluentUI/Controls/FluTimePicker.qml</file>
<file>FluentUI/Controls/FluToggleButton.qml</file>
<file>FluentUI/Controls/FluToggleSwitch.qml</file>
<file>FluentUI/Controls/FluTooltip.qml</file>
<file>FluentUI/Controls/FluTour.qml</file>
<file>FluentUI/Controls/FluTreeView.qml</file>
<file>FluentUI/Controls/FluWindow.qml</file>
<file>FluentUI/Controls/ColorPicker/ColorPicker.qml</file>
<file>FluentUI/Controls/ColorPicker/Content/Checkerboard.qml</file>
<file>FluentUI/Controls/ColorPicker/Content/ColorSlider.qml</file>
<file>FluentUI/Controls/ColorPicker/Content/NumberBox.qml</file>
<file>FluentUI/Controls/ColorPicker/Content/PanelBorder.qml</file>
<file>FluentUI/Controls/ColorPicker/Content/SBPicker.qml</file>
</qresource>
</RCC>

View File

@ -1,90 +1,19 @@
#include "fluentuiplugin.h"
#include <QtQml/QQmlExtensionPlugin>
#include <QGuiApplication>
#include <qdebug.h>
#include "WindowHelper.h"
#include "Def.h"
#include "FluApp.h"
#include "FluColors.h"
#include "FluTheme.h"
#include "FluTools.h"
#include "FluTextStyle.h"
#include "FluHttp.h"
#include "FluHttpInterceptor.h"
#include "FluWatermark.h"
#include "FluCaptcha.h"
#include "Screenshot.h"
#include "QRCode.h"
int major = 1;
int minor = 0;
static FluentUIPlugin instance;
#include "FluentUI.h"
FluentUIPlugin::FluentUIPlugin()
{
#ifdef FLUENTUI_BUILD_STATIC_LIB
Q_INIT_RESOURCE(fluentui);
#endif
}
void FluentUIPlugin::registerTypes(const char *uri)
{
qmlRegisterType<WindowHelper>(uri,major,minor,"WindowHelper");
qmlRegisterType<QRCode>(uri,major,minor,"QRCode");
qmlRegisterType<FluCaptcha>(uri,major,minor,"FluCaptcha");
qmlRegisterType<FluWatermark>(uri,major,minor,"FluWatermark");
qmlRegisterType<ScreenshotBackground>(uri,major,minor,"ScreenshotBackground");
qmlRegisterType<Screenshot>(uri,major,minor,"Screenshot");
qmlRegisterType<FluColorSet>(uri,major,minor,"FluColorSet");
qmlRegisterType<FluHttpInterceptor>(uri,major,minor,"FluHttpInterceptor");
qmlRegisterType<FluHttp>(uri,major,minor,"FluHttp");
qmlRegisterType<HttpCallable>(uri,major,minor,"HttpCallable");
qmlRegisterType<HttpRequest>(uri,major,minor,"HttpRequest");
qmlRegisterUncreatableMetaObject(Fluent_Awesome::staticMetaObject, uri,major,minor,"FluentIcons", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluHttpType::staticMetaObject, uri,major,minor,"FluHttpType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluThemeType::staticMetaObject, uri,major,minor,"FluThemeType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluPageType::staticMetaObject, uri,major,minor,"FluPageType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluWindowType::staticMetaObject, uri,major,minor,"FluWindowType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluTreeViewType::staticMetaObject, uri,major,minor,"FluTreeViewType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluStatusViewType::staticMetaObject, uri,major,minor,"FluStatusViewType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluContentDialogType::staticMetaObject, uri,major,minor,"FluContentDialogType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluTimePickerType::staticMetaObject, uri,major,minor,"FluTimePickerType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluCalendarViewType::staticMetaObject, uri,major,minor,"FluCalendarViewType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluTabViewType::staticMetaObject, uri,major,minor,"FluTabViewType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluNavigationViewType::staticMetaObject, uri,major,minor,"FluNavigationViewType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluTimelineType::staticMetaObject, uri,major,minor,"FluTimelineType", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluScreenshotType::staticMetaObject, uri,major,minor,"FluScreenshotType", "Access to enums & flags only");
FluentUI::getInstance()->registerTypes(uri);
}
#ifdef FLUENTUI_BUILD_STATIC_LIB
void FluentUIPlugin::registerTypes()
{
instance()->registerTypes("FluentUI");
}
FluentUIPlugin* FluentUIPlugin::instance()
{
static FluentUIPlugin instance;
return &instance;
}
#endif
void FluentUIPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
{
Q_UNUSED(uri)
#ifdef Q_OS_WIN
QFont font;
font.setFamily("Microsoft YaHei");
QGuiApplication::setFont(font);
#endif
FluApp* app = FluApp::getInstance();
engine->rootContext()->setContextProperty("FluApp",app);
FluColors* colors = FluColors::getInstance();
engine->rootContext()->setContextProperty("FluColors",colors);
FluTheme* theme = FluTheme::getInstance();
engine->rootContext()->setContextProperty("FluTheme",theme);
FluTools* tools = FluTools::getInstance();
engine->rootContext()->setContextProperty("FluTools",tools);
FluTextStyle* textStyle = FluTextStyle::getInstance();
engine->rootContext()->setContextProperty("FluTextStyle",textStyle);
engine->addImportPath("qrc:/FluentUI/imports/");
FluentUI::getInstance()->initializeEngine(engine,uri);
}

View File

@ -7,14 +7,9 @@ class FluentUIPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
FluentUIPlugin();
void registerTypes(const char *uri) Q_DECL_OVERRIDE;
#ifdef FLUENTUI_BUILD_STATIC_LIB
static void registerTypes();
static FluentUIPlugin* instance();
#endif
void initializeEngine(QQmlEngine *engine, const char *uri) Q_DECL_OVERRIDE;
};

View File

@ -1,99 +0,0 @@
<RCC>
<qresource prefix="/FluentUI">
<file>Qt5/imports/FluentUI/JS/Chart.js</file>
<file>Qt5/imports/FluentUI/Image/noise.png</file>
<file>Qt5/imports/FluentUI/Controls/FluAcrylic.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluAppBar.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluArea.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluAutoSuggestBox.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluBadge.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluBreadcrumbBar.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluButton.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluCalendarPicker.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluCalendarView.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluCarousel.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluChart.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluCheckBox.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluColorPicker.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluColorView.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluComboBox.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluContentDialog.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluContentPage.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluControl.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluCopyableText.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluDatePicker.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluDivider.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluDropDownButton.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluExpander.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluFilledButton.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluFlipView.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluFocusRectangle.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluIcon.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluIconButton.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluImage.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluInfoBar.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluItem.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluItemDelegate.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluMenu.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluMenuBar.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluMenuBarItem.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluMenuItem.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluMenuSeparator.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluMultilineTextBox.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluNavigationView.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluObject.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluPage.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluPagination.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluPaneItem.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluPaneItemEmpty.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluPaneItemExpander.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluPaneItemHeader.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluPaneItemSeparator.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluPasswordBox.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluPivot.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluPivotItem.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluPopup.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluProgressBar.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluProgressRing.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluQRCode.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluRadioButton.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluRadioButtons.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluRatingControl.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluRectangle.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluRemoteLoader.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluScreenshot.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluScrollablePage.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluScrollBar.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluScrollIndicator.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluShadow.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluSlider.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluSpinBox.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluStatusView.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluTableModelColumn.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluTableView.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluTabView.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluText.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluTextBox.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluTextBoxBackground.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluTextBoxMenu.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluTextButton.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluTimeline.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluTimePicker.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluToggleButton.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluToggleSwitch.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluTooltip.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluTour.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluTreeView.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluWindow.qml</file>
<file>Qt5/imports/FluentUI/Font/Segoe_Fluent_Icons.ttf</file>
<file>Qt5/imports/FluentUI/Controls/ColorPicker/ColorPicker.qml</file>
<file>Qt5/imports/FluentUI/Controls/ColorPicker/Content/Checkerboard.qml</file>
<file>Qt5/imports/FluentUI/Controls/ColorPicker/Content/ColorSlider.qml</file>
<file>Qt5/imports/FluentUI/Controls/ColorPicker/Content/NumberBox.qml</file>
<file>Qt5/imports/FluentUI/Controls/ColorPicker/Content/PanelBorder.qml</file>
<file>Qt5/imports/FluentUI/Controls/ColorPicker/Content/SBPicker.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluRangeSlider.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluStaggeredView.qml</file>
<file>Qt5/imports/FluentUI/Controls/FluProgressButton.qml</file>
</qresource>
</RCC>