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 + } }