From a964d955f41ee36ba12a1a5db615f71ced7f5c83 Mon Sep 17 00:00:00 2001 From: ronoaer Date: Mon, 11 Sep 2023 23:49:50 +0800 Subject: [PATCH 1/4] fixed scroll stuck on textarea in page OpenVpnSettings --- client/ui/qml/Controls2/TextAreaType.qml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/client/ui/qml/Controls2/TextAreaType.qml b/client/ui/qml/Controls2/TextAreaType.qml index a75ea55d..9b9921f8 100644 --- a/client/ui/qml/Controls2/TextAreaType.qml +++ b/client/ui/qml/Controls2/TextAreaType.qml @@ -15,6 +15,9 @@ Rectangle { radius: 16 FlickableType { + id: fl + interactive: false + anchors.top: parent.top anchors.bottom: parent.bottom contentHeight: textArea.implicitHeight @@ -46,12 +49,23 @@ Rectangle { } } + onCursorVisibleChanged: { + if (textArea.cursorVisible) { + fl.interactive = true + } else { + fl.interactive = false + } + } + wrapMode: Text.Wrap MouseArea { anchors.fill: parent acceptedButtons: Qt.RightButton - onClicked: contextMenu.open() + onClicked: { + fl.interactive = true + contextMenu.open() + } } ContextMenuType { From 8a3bdf136bb8e0d30f9d3e363b987ca98b0a313f Mon Sep 17 00:00:00 2001 From: ronoaer Date: Sat, 16 Sep 2023 08:05:43 +0800 Subject: [PATCH 2/4] added close button when drawer shown in the topright corner --- client/resources.qrc | 1 + client/ui/controllers/pageController.cpp | 30 ++++++++++++++++ client/ui/controllers/pageController.h | 11 ++++++ client/ui/qml/Controls2/DrawerType.qml | 21 +++++++++++ .../ui/qml/Controls2/TopCloseButtonType.qml | 35 +++++++++++++++++++ client/ui/qml/Pages2/PageShare.qml | 6 ++++ client/ui/qml/Pages2/PageStart.qml | 20 +++++++++++ 7 files changed, 124 insertions(+) create mode 100644 client/ui/qml/Controls2/TopCloseButtonType.qml diff --git a/client/resources.qrc b/client/resources.qrc index d0ff176f..16372e07 100644 --- a/client/resources.qrc +++ b/client/resources.qrc @@ -213,5 +213,6 @@ images/controls/trash.svg images/controls/more-vertical.svg ui/qml/Controls2/ListViewWithLabelsType.qml + ui/qml/Controls2/TopCloseButtonType.qml diff --git a/client/ui/controllers/pageController.cpp b/client/ui/controllers/pageController.cpp index 46a1b1fd..6501aea8 100644 --- a/client/ui/controllers/pageController.cpp +++ b/client/ui/controllers/pageController.cpp @@ -115,3 +115,33 @@ void PageController::showOnStartup() #endif } } + +void PageController::updateDrawerRootPage(PageLoader::PageEnum page) +{ + m_drwaerLayer = 0; + m_currentRootPage = page; +} + +void PageController::goToDrawerRootPage() +{ + + m_drwaerLayer = 0; + + emit showTopCloseButton(false); + emit forceCloseDrawer(); +} + +void PageController::drawerOpen() +{ + m_drwaerLayer = m_drwaerLayer + 1; + emit showTopCloseButton(true); +} + +void PageController::drawerClose() +{ + m_drwaerLayer = m_drwaerLayer -1; + if (m_drwaerLayer <= 0) { + emit showTopCloseButton(false); + m_drwaerLayer = 0; + } +} diff --git a/client/ui/controllers/pageController.h b/client/ui/controllers/pageController.h index 07e77283..f4cac427 100644 --- a/client/ui/controllers/pageController.h +++ b/client/ui/controllers/pageController.h @@ -78,6 +78,11 @@ public slots: void showOnStartup(); + void updateDrawerRootPage(PageLoader::PageEnum page); + void goToDrawerRootPage(); + void drawerOpen(); + void drawerClose(); + signals: void goToPage(PageLoader::PageEnum page, bool slide = true); void goToStartPage(); @@ -104,10 +109,16 @@ signals: void showPassphraseRequestDrawer(); void passphraseRequestDrawerClosed(QString passphrase); + void showTopCloseButton(bool visible); + void forceCloseDrawer(); + private: QSharedPointer m_serversModel; std::shared_ptr m_settings; + + PageLoader::PageEnum m_currentRootPage; + int m_drwaerLayer; }; #endif // PAGECONTROLLER_H diff --git a/client/ui/qml/Controls2/DrawerType.qml b/client/ui/qml/Controls2/DrawerType.qml index 35d03449..2b70ef3c 100644 --- a/client/ui/qml/Controls2/DrawerType.qml +++ b/client/ui/qml/Controls2/DrawerType.qml @@ -2,6 +2,16 @@ import QtQuick import QtQuick.Controls Drawer { + property bool needCloseButton: true + + Connections { + target: PageController + + function onForceCloseDrawer() { + visible = false + } + } + edge: Qt.BottomEdge clip: true @@ -40,7 +50,18 @@ Drawer { } } + onOpened: { + if (needCloseButton) { + PageController.drawerOpen() + } + } + + onClosed: { + if (needCloseButton) { + PageController.drawerClose() + } + var initialPageNavigationBarColor = PageController.getInitialPageNavigationBarColor() if (initialPageNavigationBarColor !== 0xFF1C1D21) { PageController.updateNavigationBarColor(initialPageNavigationBarColor) diff --git a/client/ui/qml/Controls2/TopCloseButtonType.qml b/client/ui/qml/Controls2/TopCloseButtonType.qml new file mode 100644 index 00000000..cd1406c4 --- /dev/null +++ b/client/ui/qml/Controls2/TopCloseButtonType.qml @@ -0,0 +1,35 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Shapes + +Popup { + id: root + + modal: false + closePolicy: Popup.NoAutoClose + width: 40 + height: 40 + padding: 4 + + visible: false + + Overlay.modal: Rectangle { + color: Qt.rgba(14/255, 14/255, 17/255, 0.8) + } + + background: Rectangle { + color: "transparent" + } + + ImageButtonType { + image: "qrc:/images/svg/close_black_24dp.svg" + imageColor: "#D7D8DB" + + implicitWidth: 32 + implicitHeight: 32 + + onClicked: { + PageController.goToDrawerRootPage() + } + } +} diff --git a/client/ui/qml/Pages2/PageShare.qml b/client/ui/qml/Pages2/PageShare.qml index 135c7fbc..623ceebf 100644 --- a/client/ui/qml/Pages2/PageShare.qml +++ b/client/ui/qml/Pages2/PageShare.qml @@ -27,6 +27,8 @@ PageType { target: ExportController function onGenerateConfig(type) { + shareConnectionDrawer.needCloseButton = false + shareConnectionDrawer.open() shareConnectionDrawer.contentVisible = false PageController.showBusyIndicator(true) @@ -58,6 +60,10 @@ PageType { } PageController.showBusyIndicator(false) + + shareConnectionDrawer.needCloseButton = true + PageController.showTopCloseButton(true) + shareConnectionDrawer.contentVisible = true } diff --git a/client/ui/qml/Pages2/PageStart.qml b/client/ui/qml/Pages2/PageStart.qml index 7f9cb212..e497c455 100644 --- a/client/ui/qml/Pages2/PageStart.qml +++ b/client/ui/qml/Pages2/PageStart.qml @@ -19,16 +19,22 @@ PageType { function onGoToPageHome() { tabBar.currentIndex = 0 tabBarStackView.goToTabBarPage(PageEnum.PageHome) + + PageController.updateDrawerRootPage(PageEnum.PageHome) } function onGoToPageSettings() { tabBar.currentIndex = 2 tabBarStackView.goToTabBarPage(PageEnum.PageSettings) + + PageController.updateDrawerRootPage(PageEnum.PageSettings) } function onGoToPageViewConfig() { var pagePath = PageController.getPagePath(PageEnum.PageSetupWizardViewConfig) tabBarStackView.push(pagePath, { "objectName" : pagePath }, StackView.PushTransition) + + PageController.updateDrawerRootPage(PageEnum.PageSetupWizardViewConfig) } function onShowBusyIndicator(visible) { @@ -37,6 +43,10 @@ PageType { tabBar.enabled = !visible } + function onShowTopCloseButton(visible) { + topCloseButton.visible = visible + } + function onEnableTabBar(enabled) { tabBar.enabled = enabled } @@ -55,6 +65,8 @@ PageType { } else { tabBarStackView.push(pagePath, { "objectName" : pagePath }, StackView.Immediate) } + + PageController.updateDrawerRootPage(page) } function onGoToStartPage() { @@ -99,6 +111,8 @@ PageType { var pagePath = PageController.getPagePath(page) tabBarStackView.clear(StackView.Immediate) tabBarStackView.replace(pagePath, { "objectName" : pagePath }, StackView.Immediate) + + PageController.updateDrawerRootPage(page) } Component.onCompleted: { @@ -183,4 +197,10 @@ PageType { anchors.centerIn: parent z: 1 } + + TopCloseButtonType { + id: topCloseButton + x: tabBarStackView.width - topCloseButton.width + z: 1 + } } From 8965b1fbba6debeb53195c1791e83490d5c353bb Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Sun, 17 Sep 2023 23:21:00 +0500 Subject: [PATCH 3/4] fixed the size of the drawer close button --- client/ui/qml/Controls2/DrawerType.qml | 7 +++---- client/ui/qml/Controls2/TopCloseButtonType.qml | 5 ----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/client/ui/qml/Controls2/DrawerType.qml b/client/ui/qml/Controls2/DrawerType.qml index 2b70ef3c..34b141b4 100644 --- a/client/ui/qml/Controls2/DrawerType.qml +++ b/client/ui/qml/Controls2/DrawerType.qml @@ -48,20 +48,19 @@ Drawer { if (PageController.getInitialPageNavigationBarColor() !== 0xFF1C1D21) { PageController.updateNavigationBarColor(0xFF1C1D21) } - } - onOpened: { if (needCloseButton) { PageController.drawerOpen() } } - - onClosed: { + onAboutToHide: { if (needCloseButton) { PageController.drawerClose() } + } + onClosed: { var initialPageNavigationBarColor = PageController.getInitialPageNavigationBarColor() if (initialPageNavigationBarColor !== 0xFF1C1D21) { PageController.updateNavigationBarColor(initialPageNavigationBarColor) diff --git a/client/ui/qml/Controls2/TopCloseButtonType.qml b/client/ui/qml/Controls2/TopCloseButtonType.qml index cd1406c4..ed89b5a6 100644 --- a/client/ui/qml/Controls2/TopCloseButtonType.qml +++ b/client/ui/qml/Controls2/TopCloseButtonType.qml @@ -7,8 +7,6 @@ Popup { modal: false closePolicy: Popup.NoAutoClose - width: 40 - height: 40 padding: 4 visible: false @@ -25,9 +23,6 @@ Popup { image: "qrc:/images/svg/close_black_24dp.svg" imageColor: "#D7D8DB" - implicitWidth: 32 - implicitHeight: 32 - onClicked: { PageController.goToDrawerRootPage() } From ad236baa8686b12f7330df52a8cea4ecb9ef620b Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Sun, 17 Sep 2023 23:24:21 +0500 Subject: [PATCH 4/4] fixed a typo in the variable name --- client/ui/controllers/pageController.cpp | 12 ++++++------ client/ui/controllers/pageController.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/client/ui/controllers/pageController.cpp b/client/ui/controllers/pageController.cpp index 6501aea8..7b8f74ab 100644 --- a/client/ui/controllers/pageController.cpp +++ b/client/ui/controllers/pageController.cpp @@ -118,14 +118,14 @@ void PageController::showOnStartup() void PageController::updateDrawerRootPage(PageLoader::PageEnum page) { - m_drwaerLayer = 0; + m_drawerLayer = 0; m_currentRootPage = page; } void PageController::goToDrawerRootPage() { - m_drwaerLayer = 0; + m_drawerLayer = 0; emit showTopCloseButton(false); emit forceCloseDrawer(); @@ -133,15 +133,15 @@ void PageController::goToDrawerRootPage() void PageController::drawerOpen() { - m_drwaerLayer = m_drwaerLayer + 1; + m_drawerLayer = m_drawerLayer + 1; emit showTopCloseButton(true); } void PageController::drawerClose() { - m_drwaerLayer = m_drwaerLayer -1; - if (m_drwaerLayer <= 0) { + m_drawerLayer = m_drawerLayer -1; + if (m_drawerLayer <= 0) { emit showTopCloseButton(false); - m_drwaerLayer = 0; + m_drawerLayer = 0; } } diff --git a/client/ui/controllers/pageController.h b/client/ui/controllers/pageController.h index f4cac427..e047e6d6 100644 --- a/client/ui/controllers/pageController.h +++ b/client/ui/controllers/pageController.h @@ -118,7 +118,7 @@ private: std::shared_ptr m_settings; PageLoader::PageEnum m_currentRootPage; - int m_drwaerLayer; + int m_drawerLayer; }; #endif // PAGECONTROLLER_H