diff --git a/example/src/main.cpp b/example/src/main.cpp index 03da161..01533cd 100644 --- a/example/src/main.cpp +++ b/example/src/main.cpp @@ -35,6 +35,7 @@ int main(int argc, char *argv[]) } app.setQuitOnLastWindowClosed(false); QQmlApplicationEngine engine; + FluentUI::initEngine(&engine); QQmlContext * context = engine.rootContext(); Lang* lang = appInfo->lang(); context->setContextProperty("lang",lang); diff --git a/src/FluentUI.cpp b/src/FluentUI.cpp index ef6e202..258aec8 100644 --- a/src/FluentUI.cpp +++ b/src/FluentUI.cpp @@ -19,3 +19,7 @@ void FluentUI::postInit(){ FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial); } + +void FluentUI::initEngine(QQmlApplicationEngine *engine){ + FramelessHelper::Quick::registerTypes(engine); +} diff --git a/src/FluentUI.h b/src/FluentUI.h index 14d337a..d11b7f6 100644 --- a/src/FluentUI.h +++ b/src/FluentUI.h @@ -2,6 +2,7 @@ #define FLUENTUI_H #include +#include #include class Q_DECL_EXPORT FluentUI @@ -10,6 +11,7 @@ class Q_DECL_EXPORT FluentUI public: static void preInit(); static void postInit(); + static void initEngine(QQmlApplicationEngine *engine); }; #endif // FLUENTUI_H diff --git a/src/imports/FluentUI/Controls/FluWindow.qml b/src/imports/FluentUI/Controls/FluWindow.qml index 0d358d6..76acf3a 100644 --- a/src/imports/FluentUI/Controls/FluWindow.qml +++ b/src/imports/FluentUI/Controls/FluWindow.qml @@ -5,7 +5,7 @@ import QtQuick.Layouts import FluentUI import org.wangwenx190.FramelessHelper -FramelessWindow { +Window { enum LaunchMode { Standard, SingleTask, @@ -25,6 +25,7 @@ FramelessWindow { event.accepted = false } } + visible: true property color backgroundColor: { if(active){ return FluTheme.dark ? Qt.rgba(26/255,34/255,40/255,1) : Qt.rgba(238/255,244/255,249/255,1) @@ -48,22 +49,22 @@ FramelessWindow { } } } - StandardTitleBar { - id: title_bar - z:999 - anchors { - top: parent.top - topMargin: window.visibility === Window.Windowed ? 1 : 0 - left: parent.left - right: parent.right - } - // windowIcon: "qrc:///images/microsoft.svg" - windowIconVisible: false - } +// StandardTitleBar { +// id: title_bar +// z:999 +// anchors { +// top: parent.top +// topMargin: window.visibility === Window.Windowed ? 1 : 0 +// left: parent.left +// right: parent.right +// } +// // windowIcon: "qrc:///images/microsoft.svg" +// windowIconVisible: false +// } Item{ id:container anchors{ - top: title_bar.bottom + top: parent.top left: parent.left right: parent.right bottom: parent.bottom @@ -77,16 +78,16 @@ FramelessWindow { WindowHelper{ id:helper } - FramelessHelper.onReady: { - FramelessHelper.titleBarItem = title_bar - FramelessHelper.moveWindowToDesktopCenter() - if (Qt.platform.os !== "macos") { - FramelessHelper.setSystemButton(title_bar.minimizeButton, FramelessHelperConstants.Minimize); - FramelessHelper.setSystemButton(title_bar.maximizeButton, FramelessHelperConstants.Maximize); - FramelessHelper.setSystemButton(title_bar.closeButton, FramelessHelperConstants.Close); - } - window.visible = true - } +// FramelessHelper.onReady: { +// FramelessHelper.titleBarItem = title_bar +// FramelessHelper.moveWindowToDesktopCenter() +// if (Qt.platform.os !== "macos") { +// FramelessHelper.setSystemButton(title_bar.minimizeButton, FramelessHelperConstants.Minimize); +// FramelessHelper.setSystemButton(title_bar.maximizeButton, FramelessHelperConstants.Maximize); +// FramelessHelper.setSystemButton(title_bar.closeButton, FramelessHelperConstants.Close); +// } +// window.visible = true +// } function showSuccess(text,duration,moremsg){ infoBar.showSuccess(text,duration,moremsg) }