diff --git a/example/App.qml b/example/App.qml
index d71c1313..3d380c0d 100644
--- a/example/App.qml
+++ b/example/App.qml
@@ -12,9 +12,9 @@ Window {
FluApp.init(app,properties)
FluTheme.isDark = false
FluApp.routes = {
- "/":"qrc:/MainPage.qml",
- "/Setting":"qrc:/SettingPage.qml",
- "/About":"qrc:/AboutPage.qml",
+ "/":"qrc:/page/MainPage.qml",
+ "/about":"qrc:/page/AboutPage.qml",
+ "/login":"qrc:/page/LoginPage.qml",
}
FluApp.initialRoute = "/"
FluApp.run()
diff --git a/example/SettingPage.qml b/example/SettingPage.qml
deleted file mode 100644
index ad986c71..00000000
--- a/example/SettingPage.qml
+++ /dev/null
@@ -1,29 +0,0 @@
-import QtQuick 2.15
-import FluentUI 1.0
-
-FluWindow {
-
- width: 500
- height: 600
- title:"设置"
-
- FluAppBar{
- id:appbar
- title:"设置"
- }
-
- FluText{
- text:"设置"
- fontStyle: FluText.Display
- anchors.centerIn: parent
-
- MouseArea{
- anchors.fill: parent
- onClicked: {
- FluApp.navigate("/About")
- }
- }
-
- }
-
-}
diff --git a/example/T_Menu.qml b/example/T_Menu.qml
new file mode 100644
index 00000000..6da702ac
--- /dev/null
+++ b/example/T_Menu.qml
@@ -0,0 +1,54 @@
+import QtQuick 2.15
+import QtQuick.Layouts 1.15
+import QtQuick.Window 2.15
+import QtQuick.Controls 2.15
+import QtGraphicalEffects 1.15
+import FluentUI 1.0
+
+FluScrollablePage{
+
+ title:"Menu"
+
+ FluButton{
+ text:"左击菜单"
+ Layout.topMargin: 20
+ Layout.leftMargin: 15
+ onClicked:{
+ menu.popup()
+ }
+ }
+
+
+ FluButton{
+ text:"右击菜单"
+ Layout.topMargin: 20
+ Layout.leftMargin: 15
+ onClicked: {
+ showSuccess("请按鼠标右击")
+ }
+ MouseArea{
+ anchors.fill: parent
+ acceptedButtons: Qt.RightButton
+ onClicked: {
+ menu.popup()
+ }
+ }
+ }
+
+ FluMenu{
+ id:menu
+ FluMenuItem{
+ text:"删除"
+ onClicked: {
+ showError("删除")
+ }
+ }
+ FluMenuItem{
+ text:"修改"
+ onClicked: {
+ showError("修改")
+ }
+ }
+ }
+
+}
diff --git a/example/T_Multiwindow.qml b/example/T_Multiwindow.qml
new file mode 100644
index 00000000..7f930d6a
--- /dev/null
+++ b/example/T_Multiwindow.qml
@@ -0,0 +1,65 @@
+import QtQuick 2.15
+import QtQuick.Layouts 1.15
+import QtQuick.Window 2.15
+import QtQuick.Controls 2.15
+import QtGraphicalEffects 1.15
+import FluentUI 1.0
+
+FluScrollablePage{
+
+ title:"MultiWindow"
+
+ FluArea{
+ width: parent.width
+ height: 68
+ paddings: 10
+ Layout.topMargin: 20
+
+ Column{
+ spacing: 5
+ anchors{
+ verticalCenter: parent.verticalCenter
+ left: parent.left
+ }
+ FluText{
+ text:"页面跳转,不携带任何参数"
+ }
+ FluButton{
+ text:"点击跳转"
+ onClicked: {
+ FluApp.navigate("/about")
+ }
+ }
+ }
+ }
+
+
+
+
+ FluArea{
+ width: parent.width
+ height: 68
+ paddings: 10
+ Layout.topMargin: 20
+
+ Column{
+ spacing: 5
+ anchors{
+ verticalCenter: parent.verticalCenter
+ left: parent.left
+ }
+ FluText{
+ text:"页面跳转,并携带参数"
+ }
+ FluButton{
+ text:"点击跳转"
+ onClicked: {
+ FluApp.navigate("/login",{username:"zhuzichu"})
+ }
+ }
+ }
+ }
+
+
+
+}
diff --git a/example/AboutPage.qml b/example/page/AboutPage.qml
similarity index 100%
rename from example/AboutPage.qml
rename to example/page/AboutPage.qml
diff --git a/example/page/LoginPage.qml b/example/page/LoginPage.qml
new file mode 100644
index 00000000..d0d0c676
--- /dev/null
+++ b/example/page/LoginPage.qml
@@ -0,0 +1,71 @@
+import QtQuick 2.15
+import QtQuick.Layouts 1.15
+import FluentUI 1.0
+
+FluWindow {
+
+ id:window
+ width: 400
+ height: 400
+ minimumWidth: 400
+ minimumHeight: 400
+ maximumWidth: 400
+ maximumHeight: 400
+ modality:2
+
+ title:"登录"
+
+ onInitArgument:
+ (argument)=>{
+ textbox_uesrname.text = argument.username
+ textbox_password.focus = true
+ }
+
+ FluAppBar{
+ id:appbar
+ title:"登录"
+ }
+
+ ColumnLayout{
+ anchors{
+ left: parent.left
+ right: parent.right
+ verticalCenter: parent.verticalCenter
+ }
+
+
+ FluAutoSuggestBox{
+ id:textbox_uesrname
+ values:["Admin","User"]
+ placeholderText: "请输入账号"
+ Layout.preferredWidth: 260
+ Layout.alignment: Qt.AlignHCenter
+ }
+
+ FluTextBox{
+ id:textbox_password
+ Layout.topMargin: 20
+ Layout.preferredWidth: 260
+ placeholderText: "请输入密码"
+ echoMode:TextInput.Password
+ Layout.alignment: Qt.AlignHCenter
+ }
+
+ FluFilledButton{
+ text:"登录"
+ Layout.alignment: Qt.AlignHCenter
+ Layout.topMargin: 20
+ onClicked:{
+ if(textbox_password.text === ""){
+ showError("请随便输入一个密码")
+ return
+ }
+ window.close()
+ }
+ }
+
+ }
+
+
+
+}
diff --git a/example/MainPage.qml b/example/page/MainPage.qml
similarity index 91%
rename from example/MainPage.qml
rename to example/page/MainPage.qml
index 20408f39..9a2e7000 100644
--- a/example/MainPage.qml
+++ b/example/page/MainPage.qml
@@ -9,7 +9,7 @@ import FluentUI 1.0
FluWindow {
id:rootwindow
width: 860
- height: 680
+ height: 600
title: "FluentUI"
minimumWidth: 500
minimumHeight: 400
@@ -59,6 +59,13 @@ FluWindow {
}
}
+ FluPaneItem{
+ title:"Menu"
+ onTap:{
+ nav_view.push("qrc:/T_Menu.qml")
+ }
+ }
+
FluPaneItem{
title:"TimePicker"
onTap:{
@@ -126,6 +133,14 @@ FluWindow {
}
}
+
+ FluPaneItem{
+ title:"MultiWindow"
+ onTap:{
+ nav_view.push("qrc:/T_MultiWindow.qml")
+ }
+ }
+
FluPaneItemHeader{
title:"Theming"
}
@@ -164,7 +179,7 @@ FluWindow {
FluPaneItem{
title:"关于"
onTap:{
- FluApp.navigate("/About")
+ FluApp.navigate("/about")
}
}
}
diff --git a/example/qml.qrc b/example/qml.qrc
index 2f611d48..ecf3dfc9 100644
--- a/example/qml.qrc
+++ b/example/qml.qrc
@@ -3,8 +3,6 @@
T_ToggleSwitch.qml
T_Typography.qml
App.qml
- SettingPage.qml
- AboutPage.qml
T_Buttons.qml
T_Rectangle.qml
T_InfoBar.qml
@@ -29,8 +27,12 @@
T_Dialog.qml
T_TreeView.qml
T_Expander.qml
- MainPage.qml
T_TimePicker.qml
T_DatePicker.qml
+ T_Menu.qml
+ page/AboutPage.qml
+ page/MainPage.qml
+ T_MultiWindow.qml
+ page/LoginPage.qml
diff --git a/src/FluApp.cpp b/src/FluApp.cpp
index 68e9e0f6..2ea23bb2 100644
--- a/src/FluApp.cpp
+++ b/src/FluApp.cpp
@@ -33,14 +33,14 @@ void FluApp::run(){
navigate(initialRoute());
}
-void FluApp::navigate(const QString& route){
+void FluApp::navigate(const QString& route,const QJsonObject& argument){
if(!routes().contains(route)){
qErrnoWarning("没有找到当前路由");
return;
}
bool isAppWindow = route == initialRoute();
FramelessView *view = new FramelessView();
-
+ view->setProperty("argument",argument);
QMapIterator iterator(properties);
while (iterator.hasNext()) {
iterator.next();
@@ -59,7 +59,7 @@ void FluApp::navigate(const QString& route){
view->setSource((routes().value(route).toString()));
if(isAppWindow){
QObject::connect(view->engine(), &QQmlEngine::quit, qApp, &QCoreApplication::quit);
-// QObject::connect(qApp, &QGuiApplication::aboutToQuit, qApp, [&view](){view->setSource({});});
+ // QObject::connect(qApp, &QGuiApplication::aboutToQuit, qApp, [&view](){view->setSource({});});
}else{
view->closeDeleteLater();
}
diff --git a/src/FluApp.h b/src/FluApp.h
index 6e4d0068..047ea7b1 100644
--- a/src/FluApp.h
+++ b/src/FluApp.h
@@ -24,7 +24,7 @@ public:
Q_INVOKABLE void run();
- Q_INVOKABLE void navigate(const QString& route);
+ Q_INVOKABLE void navigate(const QString& route,const QJsonObject& argument = {});
Q_INVOKABLE void init(QWindow *window,QMap properties);
diff --git a/src/WindowHelper.cpp b/src/WindowHelper.cpp
index 35e86870..4ee2aa77 100644
--- a/src/WindowHelper.cpp
+++ b/src/WindowHelper.cpp
@@ -10,9 +10,9 @@ void WindowHelper::setTitle(const QString& text){
window->setTitle(text);
}
-
-void WindowHelper::initWindow(FramelessView* window){
+QJsonObject WindowHelper::initWindow(FramelessView* window){
this->window = window;
+ return window->property("argument").toJsonObject();
}
void WindowHelper::setMinimumWidth(int width){
@@ -27,3 +27,19 @@ void WindowHelper::setMinimumHeight(int height){
void WindowHelper::setMaximumHeight(int height){
this->window->setMaximumHeight(height);
}
+void WindowHelper::updateWindow(){
+ this->window->setFlag(Qt::Window,false);
+ this->window->setFlag(Qt::Window,true);
+}
+
+void WindowHelper::setModality(int type){
+ if(type == 0){
+ this->window->setModality(Qt::NonModal);
+ }else if(type == 1){
+ this->window->setModality(Qt::WindowModal);
+ }else if(type == 2){
+ this->window->setModality(Qt::ApplicationModal);
+ }else{
+ this->window->setModality(Qt::NonModal);
+ }
+}
diff --git a/src/WindowHelper.h b/src/WindowHelper.h
index cf532fd7..639cb5b6 100644
--- a/src/WindowHelper.h
+++ b/src/WindowHelper.h
@@ -5,6 +5,7 @@
#include
#include
#include
+#include
#include "FramelessView.h"
class WindowHelper : public QObject
@@ -14,12 +15,14 @@ class WindowHelper : public QObject
public:
explicit WindowHelper(QObject *parent = nullptr);
- Q_INVOKABLE void initWindow(FramelessView* window);
+ Q_INVOKABLE QJsonObject initWindow(FramelessView* window);
Q_INVOKABLE void setTitle(const QString& text);
Q_INVOKABLE void setMinimumWidth(int width);
Q_INVOKABLE void setMaximumWidth(int width);
Q_INVOKABLE void setMinimumHeight(int height);
Q_INVOKABLE void setMaximumHeight(int height);
+ Q_INVOKABLE void updateWindow();
+ Q_INVOKABLE void setModality(int type);
private:
FramelessView* window;
diff --git a/src/controls/FluAutoSuggestBox.qml b/src/controls/FluAutoSuggestBox.qml
index 6712c59a..3c25eddf 100644
--- a/src/controls/FluAutoSuggestBox.qml
+++ b/src/controls/FluAutoSuggestBox.qml
@@ -7,7 +7,7 @@ TextField{
property var values:[]
property int fontStyle: FluText.Body
property int pixelSize : FluTheme.textSize
- property int iconSource: -1
+ property int iconSource: 0
signal itemClicked(string data)
id:input
@@ -112,7 +112,7 @@ TextField{
iconSource: input.iconSource
iconSize: 15
opacity: 0.5
- visible: input.iconSource != -1
+ visible: input.iconSource != 0
anchors{
verticalCenter: parent.verticalCenter
right: parent.right
diff --git a/src/controls/FluMenu.qml b/src/controls/FluMenu.qml
index 18b1436a..629d4674 100644
--- a/src/controls/FluMenu.qml
+++ b/src/controls/FluMenu.qml
@@ -2,9 +2,9 @@
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
-Popup {
+Menu {
id: popup
- default property alias content: container.children
+ default property alias content: container.data
background: Rectangle {
implicitWidth: 140
diff --git a/src/controls/FluWindow.qml b/src/controls/FluWindow.qml
index 3d046c4d..5ee23915 100644
--- a/src/controls/FluWindow.qml
+++ b/src/controls/FluWindow.qml
@@ -26,6 +26,9 @@ Item {
property int maximumWidth
property int minimumHeight
property int maximumHeight
+ property int modality:0
+
+ signal initArgument(var argument)
property int borderless:{
if(!FluTheme.isFrameless){
@@ -76,8 +79,8 @@ Item {
target: FluApp
function onWindowReady(view){
if(FluApp.equalsWindow(view,window)){
- helper.initWindow(view);
- helper.setTitle(title);
+ initArgument(helper.initWindow(view))
+ helper.setTitle(title)
if(minimumWidth){
helper.setMinimumWidth(minimumWidth)
}
@@ -90,6 +93,8 @@ Item {
if(maximumHeight){
helper.setMaximumHeight(maximumHeight)
}
+ helper.setModality(root.modality);
+ helper.updateWindow()
}
}
}
@@ -119,4 +124,8 @@ Item {
window.close()
}
+ function onResult(data){
+
+ }
+
}