From c8ed6b9ced9d1f8c507aee2a5c829b6e18be335a Mon Sep 17 00:00:00 2001 From: zhuzihcu Date: Wed, 1 Mar 2023 22:06:48 +0800 Subject: [PATCH] update --- example/App.qml | 6 +- example/Installer.qml | 102 ++++++++++++++++++++++++++++++ example/qml.qrc | 1 + src/FluApp.cpp | 18 +++++- src/FramelessView_win.cpp | 3 +- src/WindowHelper.cpp | 4 ++ src/WindowHelper.h | 1 + src/build-preset/plugins.qmltypes | 6 ++ src/controls/FluWindow.qml | 16 +++-- 9 files changed, 148 insertions(+), 9 deletions(-) create mode 100644 example/Installer.qml diff --git a/example/App.qml b/example/App.qml index d71ef1dc..d6447038 100644 --- a/example/App.qml +++ b/example/App.qml @@ -10,13 +10,15 @@ Window { color: "#00000000" Component.onCompleted: { FluApp.isFps = true + FluApp.isDark = false FluApp.setAppWindow(app) FluApp.routes = { "/":"qrc:/MainPage.qml", "/Setting":"qrc:/SettingPage.qml", - "/About":"qrc:/AboutPage.qml" + "/About":"qrc:/AboutPage.qml", + "/Installer":"qrc:/Installer.qml" } - FluApp.initialRoute = "/" + FluApp.initialRoute = "/Installer" FluApp.run() } diff --git a/example/Installer.qml b/example/Installer.qml new file mode 100644 index 00000000..790df3a5 --- /dev/null +++ b/example/Installer.qml @@ -0,0 +1,102 @@ +import QtQuick 2.15 +import QtQuick.Layouts 1.15 +import FluentUI 1.0 + +FluWindow { + + id:window +// width: 800 +// height: 400 +// maximumSize: Qt.size(800,400) +// minimumSize: Qt.size(800,400) + title:"安装向导" + + FluAppBar{ + id:appbar + title: "安装向导" + } + + ColumnLayout{ + + width: parent.width + + anchors{ + top: appbar.bottom + bottom: parent.bottom + topMargin: 20 + } + + RowLayout{ + + width: parent.width + + FluText{ + text:"安装路径:" + Layout.leftMargin: 30 + } + + Rectangle{ + color: FluApp.isDark ? "#323232" : "#FFFFFF" + radius: 4 + Layout.fillWidth: true + height: 40 + border.width: 1 + border.color: FluApp.isDark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(238/255,238/255,238/255,1) + + FluText{ + text:"C:\\Program Files\\RustDesk" + anchors{ + verticalCenter: parent.verticalCenter + left:parent.left + leftMargin: 14 + } + } + } + + FluButton{ + text:"更改路径" + Layout.rightMargin: 30 + } + } + + Item{ + width: 1 + Layout.fillHeight: true + } + + + Rectangle{ + + Layout.fillWidth: true + border.width: 1 + border.color: FluApp.isDark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(238/255,238/255,238/255,1) + + height: 60 + color: FluApp.isDark ? "#323232" : "#FFFFFF" + RowLayout{ + anchors{ + right: parent.right + rightMargin: 30 + verticalCenter: parent.verticalCenter + } + spacing: 14 + FluButton{ + text:"取消" + onClicked: { + window.close() + } + } + FluFilledButton{ + text:"同意并安装" + } + FluButton{ + text:"不安装直接运行" + onClicked: { + FluApp.navigate("/") + window.close() + } + } + } + } + } +} diff --git a/example/qml.qrc b/example/qml.qrc index 47c0b134..bafc44be 100644 --- a/example/qml.qrc +++ b/example/qml.qrc @@ -24,5 +24,6 @@ res/svg/avatar_10.svg res/svg/avatar_11.svg res/svg/avatar_12.svg + Installer.qml diff --git a/src/FluApp.cpp b/src/FluApp.cpp index 2b75b0ae..d48020e1 100644 --- a/src/FluApp.cpp +++ b/src/FluApp.cpp @@ -42,12 +42,23 @@ void FluApp::navigate(const QString& route){ } bool isAppWindow = route==initialRoute(); FramelessView *view = new FramelessView(); + view->setProperty("winId","1234243"); + qDebug()<<"-----FramelessView--------->"; +// view->setWidth(800); +// view->setHeight(500); +// view->setMaximumSize(QSize(800,500)); +// view->setMinimumSize(QSize(800,500)); view->setColor(isDark() ? QColor(0,0,0,1) : QColor(255, 255, 255, 1)); QObject::connect(view, &QQuickView::statusChanged, view, [&](QQuickView::Status status) { + qDebug()<<"-------------->"; if (status == QQuickView::Status::Ready) { Q_EMIT windowReady(view); + + view->moveToScreenCenter(); + view->show(); } }); + qDebug()<<"-----view->setSource((routes().value(route).toString()))--------->"; view->setSource((routes().value(route).toString())); if(isAppWindow){ QObject::connect(view->engine(), &QQmlEngine::quit, qApp, &QCoreApplication::quit); @@ -55,10 +66,13 @@ void FluApp::navigate(const QString& route){ }else{ view->closeDeleteLater(); } - view->moveToScreenCenter(); - view->show(); } bool FluApp::equalsWindow(FramelessView *view,QWindow *window){ + qDebug()<<"-----equalsWindow--------->"; + view->setWidth(800); + view->setHeight(500); + view->setMaximumSize(QSize(800,500)); + view->setMinimumSize(QSize(800,500)); return view->winId() == window->winId(); } diff --git a/src/FramelessView_win.cpp b/src/FramelessView_win.cpp index b117ce63..45d155c1 100644 --- a/src/FramelessView_win.cpp +++ b/src/FramelessView_win.cpp @@ -118,7 +118,8 @@ public: if (oldStyle != newStyle) { borderless = enabled; - ::SetWindowLongPtrW(handle, GWL_STYLE, static_cast(newStyle)); + //todo 有待研究这个 +// ::SetWindowLongPtrW(handle, GWL_STYLE, static_cast(newStyle)); // when switching between borderless and windowed, restore appropriate shadow state setShadow(handle, borderless_shadow && (newStyle != Style::windowed)); diff --git a/src/WindowHelper.cpp b/src/WindowHelper.cpp index 65ad7222..6fc70941 100644 --- a/src/WindowHelper.cpp +++ b/src/WindowHelper.cpp @@ -21,3 +21,7 @@ void WindowHelper::setMinimumSize(const QSize &size){ void WindowHelper::setMaximumSize(const QSize &size){ this->window->setMaximumSize(size); } + +void WindowHelper::setSize(const QSize &size){ + +} diff --git a/src/WindowHelper.h b/src/WindowHelper.h index 8258d2c5..97f7ece8 100644 --- a/src/WindowHelper.h +++ b/src/WindowHelper.h @@ -18,6 +18,7 @@ public: Q_INVOKABLE void setTitle(const QString& text); Q_INVOKABLE void setMinimumSize(const QSize &size); Q_INVOKABLE void setMaximumSize(const QSize &size); + Q_INVOKABLE void setSize(const QSize &size); private: FramelessView* window; diff --git a/src/build-preset/plugins.qmltypes b/src/build-preset/plugins.qmltypes index f4075a3e..6b603f6a 100644 --- a/src/build-preset/plugins.qmltypes +++ b/src/build-preset/plugins.qmltypes @@ -825,6 +825,10 @@ Module { name: "setMaximumSize" Parameter { name: "size"; type: "QSize" } } + Method { + name: "setSize" + Parameter { name: "size"; type: "QSize" } + } } Component { prototype: "QQuickRectangle" @@ -1176,6 +1180,7 @@ Module { defaultProperty: "data" Property { name: "isMax"; type: "bool" } Property { name: "title"; type: "string" } + Property { name: "winId"; type: "string" } Property { name: "minimumSize"; type: "QVariant" } Property { name: "maximumSize"; type: "QVariant" } Property { name: "window"; type: "QVariant" } @@ -1207,5 +1212,6 @@ Module { Parameter { name: "duration"; type: "QVariant" } Parameter { name: "moremsg"; type: "QVariant" } } + Method { name: "close"; type: "QVariant" } } } diff --git a/src/controls/FluWindow.qml b/src/controls/FluWindow.qml index dafb41c1..d537ac0a 100644 --- a/src/controls/FluWindow.qml +++ b/src/controls/FluWindow.qml @@ -12,6 +12,9 @@ Rectangle { return Window.Maximized === Window.window.visibility } property string title: "FluentUI" + + property string winId + property var minimumSize property var maximumSize @@ -40,7 +43,7 @@ Rectangle { color : FluApp.isDark ? "#202020" : "#F3F3F3" Component.onCompleted: { - console.debug("onCompleted") + console.debug("Component.onCompleted:"+root.winId) } Connections{ @@ -55,6 +58,11 @@ Rectangle { if(maximumSize){ helper.setMaximumSize(maximumSize) } + if(maximumSize&&minimumSize){ + if(maximumSize.width === minimumSize.width && maximumSize.height === minimumSize.height){ + helper.disResizable() + } + } } } } @@ -68,7 +76,6 @@ Rectangle { root: root } - function showSuccess(text,duration,moremsg){ infoBar.showSuccess(text,duration,moremsg); } @@ -81,7 +88,8 @@ Rectangle { function showError(text,duration,moremsg){ infoBar.showError(text,duration,moremsg); } - - + function close(){ + window.close() + } }