main
zhuzihcu 2023-05-17 13:44:38 +08:00
parent 55e668e95e
commit 68cf87dba9
4 changed files with 32 additions and 24 deletions

View File

@ -35,6 +35,7 @@ int main(int argc, char *argv[])
} }
app.setQuitOnLastWindowClosed(false); app.setQuitOnLastWindowClosed(false);
QQmlApplicationEngine engine; QQmlApplicationEngine engine;
FluentUI::initEngine(&engine);
QQmlContext * context = engine.rootContext(); QQmlContext * context = engine.rootContext();
Lang* lang = appInfo->lang(); Lang* lang = appInfo->lang();
context->setContextProperty("lang",lang); context->setContextProperty("lang",lang);

View File

@ -19,3 +19,7 @@ void FluentUI::postInit(){
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial); FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
} }
void FluentUI::initEngine(QQmlApplicationEngine *engine){
FramelessHelper::Quick::registerTypes(engine);
}

View File

@ -2,6 +2,7 @@
#define FLUENTUI_H #define FLUENTUI_H
#include <QObject> #include <QObject>
#include <QQmlApplicationEngine>
#include <QDebug> #include <QDebug>
class Q_DECL_EXPORT FluentUI class Q_DECL_EXPORT FluentUI
@ -10,6 +11,7 @@ class Q_DECL_EXPORT FluentUI
public: public:
static void preInit(); static void preInit();
static void postInit(); static void postInit();
static void initEngine(QQmlApplicationEngine *engine);
}; };
#endif // FLUENTUI_H #endif // FLUENTUI_H

View File

@ -5,7 +5,7 @@ import QtQuick.Layouts
import FluentUI import FluentUI
import org.wangwenx190.FramelessHelper import org.wangwenx190.FramelessHelper
FramelessWindow { Window {
enum LaunchMode { enum LaunchMode {
Standard, Standard,
SingleTask, SingleTask,
@ -25,6 +25,7 @@ FramelessWindow {
event.accepted = false event.accepted = false
} }
} }
visible: true
property color backgroundColor: { property color backgroundColor: {
if(active){ if(active){
return FluTheme.dark ? Qt.rgba(26/255,34/255,40/255,1) : Qt.rgba(238/255,244/255,249/255,1) 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 { // StandardTitleBar {
id: title_bar // id: title_bar
z:999 // z:999
anchors { // anchors {
top: parent.top // top: parent.top
topMargin: window.visibility === Window.Windowed ? 1 : 0 // topMargin: window.visibility === Window.Windowed ? 1 : 0
left: parent.left // left: parent.left
right: parent.right // right: parent.right
} // }
// windowIcon: "qrc:///images/microsoft.svg" // // windowIcon: "qrc:///images/microsoft.svg"
windowIconVisible: false // windowIconVisible: false
} // }
Item{ Item{
id:container id:container
anchors{ anchors{
top: title_bar.bottom top: parent.top
left: parent.left left: parent.left
right: parent.right right: parent.right
bottom: parent.bottom bottom: parent.bottom
@ -77,16 +78,16 @@ FramelessWindow {
WindowHelper{ WindowHelper{
id:helper id:helper
} }
FramelessHelper.onReady: { // FramelessHelper.onReady: {
FramelessHelper.titleBarItem = title_bar // FramelessHelper.titleBarItem = title_bar
FramelessHelper.moveWindowToDesktopCenter() // FramelessHelper.moveWindowToDesktopCenter()
if (Qt.platform.os !== "macos") { // if (Qt.platform.os !== "macos") {
FramelessHelper.setSystemButton(title_bar.minimizeButton, FramelessHelperConstants.Minimize); // FramelessHelper.setSystemButton(title_bar.minimizeButton, FramelessHelperConstants.Minimize);
FramelessHelper.setSystemButton(title_bar.maximizeButton, FramelessHelperConstants.Maximize); // FramelessHelper.setSystemButton(title_bar.maximizeButton, FramelessHelperConstants.Maximize);
FramelessHelper.setSystemButton(title_bar.closeButton, FramelessHelperConstants.Close); // FramelessHelper.setSystemButton(title_bar.closeButton, FramelessHelperConstants.Close);
} // }
window.visible = true // window.visible = true
} // }
function showSuccess(text,duration,moremsg){ function showSuccess(text,duration,moremsg){
infoBar.showSuccess(text,duration,moremsg) infoBar.showSuccess(text,duration,moremsg)
} }