From 3a66b4d67ea8ebe29d95ba374fd26b516b9c16d2 Mon Sep 17 00:00:00 2001 From: James Graham Date: Sun, 13 Oct 2024 12:41:56 +0000 Subject: [PATCH] Fix mobile ExploreComponent Make sure that the search filter is removed when another button is pressed. Make sure that the popup closes when one of the other menus is open. Make the separator is at the top on NavigationTabBar --- src/qml/ExploreComponentMobile.qml | 141 +++++++++++++++-------------- 1 file changed, 72 insertions(+), 69 deletions(-) diff --git a/src/qml/ExploreComponentMobile.qml b/src/qml/ExploreComponentMobile.qml index 65ae390ca..8b10e8a29 100644 --- a/src/qml/ExploreComponentMobile.qml +++ b/src/qml/ExploreComponentMobile.qml @@ -10,9 +10,8 @@ import org.kde.kirigamiaddons.delegates as Delegates import org.kde.neochat -ColumnLayout { +Kirigami.NavigationTabBar { id: root - spacing: 0 /** * @brief The connection for the current user. @@ -24,75 +23,72 @@ ColumnLayout { */ signal textChanged(string newText) - Kirigami.Separator { - Layout.fillWidth: true - } - Kirigami.NavigationTabBar { - id: exploreTabBar - Layout.fillWidth: true - actions: [ - Kirigami.Action { - id: infoAction - text: i18n("Search") - icon.name: "search" - onTriggered: { - if (explorePopup.visible && explorePopupLoader.sourceComponent == search) { - explorePopup.close(); - exploreTabBar.currentIndex = -1; - } else if (explorePopup.visible && explorePopupLoader.sourceComponent != search) { - explorePopup.close(); - explorePopup.open(); - } else { - explorePopup.open(); - } - explorePopupLoader.sourceComponent = search; - } - }, - Kirigami.Action { - text: i18n("Explore rooms") - icon.name: "compass" - onTriggered: { - let dialog = pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'ExploreRoomsPage'), { - connection: root.connection - }, { - title: i18nc("@title", "Explore Rooms") - }); - dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => { - RoomManager.resolveResource(roomId.length > 0 ? roomId : alias, isJoined ? "" : "join"); - }); - exploreTabBar.currentIndex = -1; - } - }, - Kirigami.Action { - text: i18n("Find your friends") - icon.name: "list-add-user" - onTriggered: { - pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'UserSearchPage'), { - connection: root.connection - }, { - title: i18nc("@title", "Find your friends") - }); - exploreTabBar.currentIndex = -1; - } - }, - Kirigami.Action { - text: i18n("Create New") - icon.name: "list-add" - onTriggered: { - if (explorePopup.visible && explorePopupLoader.sourceComponent == create) { - explorePopup.close(); - exploreTabBar.currentIndex = -1; - } else if (explorePopup.visible && explorePopupLoader.sourceComponent != create) { - explorePopup.close(); - explorePopup.open(); - } else { - explorePopup.open(); - } - explorePopupLoader.sourceComponent = create; + Layout.fillWidth: true + + actions: [ + Kirigami.Action { + id: infoAction + text: i18n("Search") + icon.name: "search" + onTriggered: { + if (explorePopup.visible && explorePopupLoader.sourceComponent == search) { + explorePopup.close(); + root.currentIndex = -1; + } else if (explorePopup.visible && explorePopupLoader.sourceComponent != search) { + explorePopup.close(); + explorePopup.open(); + } else { + explorePopup.open(); } + explorePopupLoader.switchComponent(search); } - ] - } + }, + Kirigami.Action { + text: i18n("Explore rooms") + icon.name: "compass" + onTriggered: { + explorePopup.close(); + let dialog = pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'ExploreRoomsPage'), { + connection: root.connection + }, { + title: i18nc("@title", "Explore Rooms") + }); + dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => { + RoomManager.resolveResource(roomId.length > 0 ? roomId : alias, isJoined ? "" : "join"); + }); + root.currentIndex = -1; + } + }, + Kirigami.Action { + text: i18n("Find your friends") + icon.name: "list-add-user" + onTriggered: { + explorePopup.close(); + pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'UserSearchPage'), { + connection: root.connection + }, { + title: i18nc("@title", "Find your friends") + }); + root.currentIndex = -1; + } + }, + Kirigami.Action { + text: i18n("Create New") + icon.name: "list-add" + onTriggered: { + if (explorePopup.visible && explorePopupLoader.sourceComponent == create) { + explorePopup.close(); + root.currentIndex = -1; + } else if (explorePopup.visible && explorePopupLoader.sourceComponent != create) { + explorePopup.close(); + explorePopup.open(); + } else { + explorePopup.open(); + } + explorePopupLoader.switchComponent(create); + } + } + ] QQC2.Popup { id: explorePopup @@ -110,6 +106,13 @@ ColumnLayout { contentItem: Loader { id: explorePopupLoader sourceComponent: search + + function switchComponent(newComponent) { + if (sourceComponent == search) { + root.textChanged(""); + } + sourceComponent = newComponent; + } } background: ColumnLayout {