From a15a11f44b591705f40f1af045737d1151142542 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Fri, 31 May 2024 12:33:00 +0200 Subject: [PATCH] Rework config dialog Use new KirigamiAddons ConfigurationsView as a replacement for CategorizedSettings. Fix some issues on desktop when running Qt 6.8 and some less recent issues on mobile. Visually this looks the same. --- src/qml/AccountMenu.qml | 31 +++----- src/qml/ContextMenu.qml | 23 ++---- src/qml/GlobalMenu.qml | 8 +- src/qml/Main.qml | 13 ++- src/qml/RoomDrawer.qml | 15 ++-- src/qml/SpaceDrawer.qml | 6 +- src/qml/SpaceHomePage.qml | 16 ++-- src/qml/SpaceListContextMenu.qml | 24 +++--- src/qml/UserInfo.qml | 27 +++---- src/settings/About.qml | 9 --- src/settings/AboutKDE.qml | 8 -- src/settings/AccountsPage.qml | 8 +- src/settings/CMakeLists.txt | 14 +++- src/settings/NeoChatSettings.qml | 113 --------------------------- src/settings/NeoChatSettingsView.qml | 110 ++++++++++++++++++++++++++ src/settings/RoomSettings.qml | 65 --------------- src/settings/RoomSettingsView.qml | 83 ++++++++++++++++++++ 17 files changed, 271 insertions(+), 302 deletions(-) delete mode 100644 src/settings/About.qml delete mode 100644 src/settings/AboutKDE.qml delete mode 100644 src/settings/NeoChatSettings.qml create mode 100644 src/settings/NeoChatSettingsView.qml delete mode 100644 src/settings/RoomSettings.qml create mode 100644 src/settings/RoomSettingsView.qml diff --git a/src/qml/AccountMenu.qml b/src/qml/AccountMenu.qml index a70b4ef3c..3af80ed59 100644 --- a/src/qml/AccountMenu.qml +++ b/src/qml/AccountMenu.qml @@ -15,13 +15,14 @@ QQC2.Menu { id: root required property NeoChatConnection connection + required property Kirigami.ApplicationWindow window margins: Kirigami.Units.smallSpacing QQC2.MenuItem { text: i18n("Edit this account") icon.name: "document-edit" - onTriggered: pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.settings', 'AccountEditorPage'), { + onTriggered: root.window.pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.settings', 'AccountEditorPage'), { connection: root.connection }, { title: i18n("Account editor") @@ -30,32 +31,22 @@ QQC2.Menu { QQC2.MenuItem { text: i18n("Notification settings") icon.name: "notifications" - onTriggered: pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.settings', 'NeoChatSettings'), { - defaultPage: "notifications", - connection: root.connection - }, { - title: i18n("Configure"), - width: Kirigami.Units.gridUnit * 50, - height: Kirigami.Units.gridUnit * 42 - }) + onTriggered: { + NeoChatSettingsView.open('notifications'); + } } QQC2.MenuItem { text: i18n("Devices") icon.name: "computer-symbolic" - onTriggered: pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.settings', 'NeoChatSettings'), { - defaultPage: "devices", - connection: root.connection - }, { - title: i18n("Configure"), - width: Kirigami.Units.gridUnit * 50, - height: Kirigami.Units.gridUnit * 42 - }) + onTriggered: { + NeoChatSettingsView.open('devices'); + } } QQC2.MenuItem { text: i18n("Open developer tools") icon.name: "tools" visible: Config.developerTools - onTriggered: pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.devtools', 'DevtoolsPage'), { + onTriggered: root.window.pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.devtools', 'DevtoolsPage'), { connection: root.connection }, { title: i18nc("@title:window", "Developer Tools"), @@ -67,7 +58,7 @@ QQC2.Menu { text: i18nc("@action:inmenu", "Open Secret Backup") icon.name: "unlock" visible: Config.secretBackup - onTriggered: pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'UnlockSSSSDialog'), {}, { + onTriggered: root.window.pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'UnlockSSSSDialog'), {}, { title: i18nc("@title:window", "Open Key Backup") }) } @@ -80,7 +71,7 @@ QQC2.Menu { QQC2.MenuItem { text: i18n("Logout") icon.name: "list-remove-user" - onTriggered: confirmLogoutDialogComponent.createObject(applicationWindow().overlay).open() + onTriggered: confirmLogoutDialogComponent.createObject(root.window.overlay).open() } Component { diff --git a/src/qml/ContextMenu.qml b/src/qml/ContextMenu.qml index 4b1c93ab3..d8da9cbb9 100644 --- a/src/qml/ContextMenu.qml +++ b/src/qml/ContextMenu.qml @@ -108,14 +108,11 @@ Loader { } QQC2.MenuItem { - text: i18n("Room Settings") - icon.name: "configure" - onTriggered: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.settings', 'RoomSettings'), { - room: room, - connection: connection - }, { - title: i18n("Room Settings") - }) + text: i18nc("@action:inmenu", "Room Settings") + icon.name: 'settings-configure-symbolic' + onTriggered: { + RoomSettingsView.openRoomSettings(root.room, RoomSettingsView.Room); + } } QQC2.MenuSeparator {} @@ -187,14 +184,10 @@ Loader { } QQC2.ToolButton { - icon.name: 'settings-configure' + text: i18nc("@action:button", "Room Settings") + icon.name: 'settings-configure-symbolic' onClicked: { - QQC2.ApplicationWindow.window.pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.settings', 'RoomSettings'), { - room: room, - connection: root.connection - }, { - title: i18n("Room Settings") - }); + RoomSettingsView.openRoomSettings(root.room, RoomSettingsView.Room); drawer.close(); } } diff --git a/src/qml/GlobalMenu.qml b/src/qml/GlobalMenu.qml index 826de9e40..89140e99a 100644 --- a/src/qml/GlobalMenu.qml +++ b/src/qml/GlobalMenu.qml @@ -25,13 +25,7 @@ Labs.MenuBar { text: i18nc("menu", "Configure NeoChat...") shortcut: StandardKey.Preferences - onTriggered: pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.settings', 'NeoChatSettings'), { - connection: root.connection - }, { - title: i18n("Configure"), - width: Kirigami.Units.gridUnit * 50, - height: Kirigami.Units.gridUnit * 42 - }) + onTriggered: NeoChatSettingsView.open() } Labs.MenuItem { text: i18nc("menu", "Quit NeoChat") diff --git a/src/qml/Main.qml b/src/qml/Main.qml index 90537a20e..b5e3c1910 100644 --- a/src/qml/Main.qml +++ b/src/qml/Main.qml @@ -41,6 +41,7 @@ Kirigami.ApplicationWindow { onConnectionChanged: { CustomEmojiModel.connection = root.connection; SpaceHierarchyCache.connection = root.connection; + NeoChatSettingsView.connection = root.connection; if (ShareHandler.text && root.connection) { root.handleShare(); } @@ -190,6 +191,9 @@ Kirigami.ApplicationWindow { Component.onCompleted: { CustomEmojiModel.connection = root.connection; SpaceHierarchyCache.connection = root.connection; + RoomSettingsView.window = root; + NeoChatSettingsView.window = root; + NeoChatSettingsView.connection = root.connection; WindowController.setBlur(pageStack, Config.blur && !Config.compactLayout); if (ShareHandler.text && root.connection) { root.handleShare() @@ -321,15 +325,10 @@ Kirigami.ApplicationWindow { Shortcut { sequence: "Ctrl+Shift+," onActivated: { - pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.settings', 'NeoChatSettings'), { - connection: root.connection - }, { - title: i18n("Configure"), - width: Kirigami.Units.gridUnit * 50, - height: Kirigami.Units.gridUnit * 42 - }); + NeoChatSettingsView.open(); } } + Connections { target: ShareHandler function onTextChanged(): void { diff --git a/src/qml/RoomDrawer.qml b/src/qml/RoomDrawer.qml index 9b78de883..bcce3c4c5 100644 --- a/src/qml/RoomDrawer.qml +++ b/src/qml/RoomDrawer.qml @@ -100,20 +100,17 @@ Kirigami.OverlayDrawer { QQC2.ToolButton { id: settingsButton - icon.name: "settings-configure" - text: i18n("Room settings") display: QQC2.AbstractButton.IconOnly - - onClicked: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.settings', 'RoomSettings'), { - room: room, - connection: root.connection - }, { - title: i18n("Room Settings") - }) + text: i18nc("@action:button", "Room settings") + icon.name: 'settings-configure-symbolic' QQC2.ToolTip.text: text QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay QQC2.ToolTip.visible: hovered + + onClicked: { + RoomSettingsView.openRoomSettings(root.room, RoomSettingsView.Room); + } } } } diff --git a/src/qml/SpaceDrawer.qml b/src/qml/SpaceDrawer.qml index 6fa05052d..82b73f601 100644 --- a/src/qml/SpaceDrawer.qml +++ b/src/qml/SpaceDrawer.qml @@ -300,7 +300,7 @@ QQC2.Control { } } - function createContextMenu(room) { + function createContextMenu(room: NeoChatRoom): void { let context = spaceListContextMenu.createObject(root, { room: room, connection: root.connection @@ -309,6 +309,8 @@ QQC2.Control { } Component { id: spaceListContextMenu - SpaceListContextMenu {} + SpaceListContextMenu { + window: root.QQC2.ApplicationWindow.window + } } } diff --git a/src/qml/SpaceHomePage.qml b/src/qml/SpaceHomePage.qml index 57b947834..237d7fdac 100644 --- a/src/qml/SpaceHomePage.qml +++ b/src/qml/SpaceHomePage.qml @@ -70,15 +70,15 @@ ColumnLayout { Layout.fillWidth: true } QQC2.Button { - text: i18nc("@button", "Space settings") - icon.name: "settings-configure" + id: settingsButton + display: QQC2.AbstractButton.IconOnly - onClicked: applicationWindow().pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.settings', 'RoomSettings'), { - room: root.currentRoom, - connection: root.currentRoom.connection - }, { - title: i18n("Room Settings") - }) + text: i18nc("'Space' is a matrix space", "Space Settings") + onClicked: { + RoomSettingsView.openRoomSettings(root.currentRoom, RoomSettingsView.Space); + drawer.close(); + } + icon.name: 'settings-configure-symbolic' QQC2.ToolTip.text: text QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay diff --git a/src/qml/SpaceListContextMenu.qml b/src/qml/SpaceListContextMenu.qml index 382b58820..b004677e0 100644 --- a/src/qml/SpaceListContextMenu.qml +++ b/src/qml/SpaceListContextMenu.qml @@ -21,6 +21,7 @@ Loader { property NeoChatRoom room required property NeoChatConnection connection + required property Kirigami.ApplicationWindow window signal closed @@ -45,13 +46,10 @@ Loader { QQC2.MenuItem { text: i18nc("'Space' is a matrix space", "Space Settings") - icon.name: 'settings-configure' - onTriggered: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.settings', 'RoomSettings'), { - room: room, - connection: connection - }, { - title: i18n("Space Settings") - }) + icon.name: 'settings-configure-symbolic' + onTriggered: { + RoomSettingsView.openRoomSettings(root.room, RoomSettingsView.Space); + } } QQC2.MenuSeparator {} @@ -130,13 +128,11 @@ Loader { FormCard.FormButtonDelegate { text: i18nc("'Space' is a matrix space", "Space Settings") - icon.name: 'settings-configure' - onClicked: QQC2.ApplicationWindow.window.pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.settings', 'RoomSettings'), { - room: room, - connection: connection - }, { - title: i18n("Space Settings") - }) + icon.name: 'settings-configure-symbolic' + onClicked: { + RoomSettingsView.openRoomSettings(root.room, RoomSettingsView.Space); + drawer.close(); + } } FormCard.FormButtonDelegate { diff --git a/src/qml/UserInfo.qml b/src/qml/UserInfo.qml index 1d72dfc3b..74908c003 100644 --- a/src/qml/UserInfo.qml +++ b/src/qml/UserInfo.qml @@ -48,21 +48,16 @@ RowLayout { activeFocusOnTab: true - onClicked: pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.settings', 'NeoChatSettings'), { - defaultPage: "accounts", - connection: root.connection, - initialAccount: root.connection - }, { - title: i18nc("@action:button", "Configure"), - width: Kirigami.Units.gridUnit * 50, - height: Kirigami.Units.gridUnit * 42 - }) + onClicked: { + NeoChatSettingsView.open("accounts") + } TapHandler { acceptedButtons: Qt.RightButton onTapped: accountMenu.open() } } + ColumnLayout { Layout.fillWidth: true Layout.maximumWidth: Math.round(root.width * 0.55) @@ -99,15 +94,13 @@ RowLayout { }).open(); }, Kirigami.Action { + id: openSettingsAction + text: i18n("Open Settings") - icon.name: "settings-configure" - onTriggered: pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.settings', 'NeoChatSettings'), { - connection: root.connection - }, { - title: i18n("Configure"), - width: Kirigami.Units.gridUnit * 50, - height: Kirigami.Units.gridUnit * 42 - }) + icon.name: "settings-configure-symbolic" + onTriggered: { + NeoChatSettingsView.open(); + } } ] diff --git a/src/settings/About.qml b/src/settings/About.qml deleted file mode 100644 index aca24d50b..000000000 --- a/src/settings/About.qml +++ /dev/null @@ -1,9 +0,0 @@ -// SPDX-FileCopyrightText: 2020 Tobias Fella -// SPDX-FileCopyrightText: 2021 Carl Schwan -// SPDX-License-Identifier: LGPL-2.0-or-later - -import org.kde.kirigamiaddons.formcard as FormCard - -FormCard.AboutPage { - title: i18nc("@title:window", "About NeoChat") -} diff --git a/src/settings/AboutKDE.qml b/src/settings/AboutKDE.qml deleted file mode 100644 index 45f0448a5..000000000 --- a/src/settings/AboutKDE.qml +++ /dev/null @@ -1,8 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Joshua Goins -// SPDX-License-Identifier: LGPL-2.0-or-later - -import org.kde.kirigamiaddons.formcard as FormCard - -FormCard.AboutKDE { - title: i18nc("@title:window", "About KDE") -} diff --git a/src/settings/AccountsPage.qml b/src/settings/AccountsPage.qml index 82570bfff..6000cee6a 100644 --- a/src/settings/AccountsPage.qml +++ b/src/settings/AccountsPage.qml @@ -28,7 +28,7 @@ FormCard.FormCardPage { id: intialAccountTimer interval: 10 running: false - onTriggered: applicationWindow().pageStack.layers.push(Qt.createComponent('org.kde.neochat.settings', 'AccountEditorPage'), { + onTriggered: root.QQC2.ApplicationWindow.window.pageStack.layers.push(Qt.createComponent('org.kde.neochat.settings', 'AccountEditorPage'), { connection: initialAccount }, { title: i18n("Account editor") @@ -45,7 +45,7 @@ FormCard.FormCardPage { id: accountDelegate required property NeoChatConnection connection Layout.fillWidth: true - onClicked: applicationWindow().pageStack.layers.push(Qt.createComponent('org.kde.neochat.settings', 'AccountEditorPage'), { + onClicked: root.QQC2.ApplicationWindow.window.pageStack.layers.push(Qt.createComponent('org.kde.neochat.settings', 'AccountEditorPage'), { connection: accountDelegate.connection }, { title: i18n("Account editor") @@ -87,7 +87,7 @@ FormCard.FormCardPage { QQC2.ToolButton { text: i18n("Logout") icon.name: "im-kick-user" - onClicked: confirmLogoutDialogComponent.createObject(applicationWindow().overlay).open() + onClicked: confirmLogoutDialogComponent.createObject(root.QQC2.Overlay.overlay).open() } Component { @@ -117,7 +117,7 @@ FormCard.FormCardPage { id: addAccountDelegate text: i18n("Add Account") icon.name: "list-add" - onClicked: applicationWindow().pageStack.layers.push(Qt.createComponent('org.kde.neochat.login', 'WelcomePage')) + onClicked: root.QQC2.ApplicationWindow.window.pageStack.layers.push(Qt.createComponent('org.kde.neochat.login', 'WelcomePage')) } } diff --git a/src/settings/CMakeLists.txt b/src/settings/CMakeLists.txt index f45c4fd19..ecc5cae65 100644 --- a/src/settings/CMakeLists.txt +++ b/src/settings/CMakeLists.txt @@ -2,14 +2,20 @@ # SPDX-License-Identifier: BSD-2-Clause qt_add_library(settings STATIC) + +set_source_files_properties( + RoomSettingsView.qml + NeoChatSettingsView.qml + PROPERTIES + QT_QML_SINGLETON_TYPE TRUE +) + qt_add_qml_module(settings URI org.kde.neochat.settings OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/src/org/kde/neochat/settings QML_FILES - NeoChatSettings.qml - RoomSettings.qml - About.qml - AboutKDE.qml + NeoChatSettingsView.qml + RoomSettingsView.qml AccountsPage.qml AccountEditorPage.qml AppearanceSettingsPage.qml diff --git a/src/settings/NeoChatSettings.qml b/src/settings/NeoChatSettings.qml deleted file mode 100644 index e6dd61799..000000000 --- a/src/settings/NeoChatSettings.qml +++ /dev/null @@ -1,113 +0,0 @@ -// SPDX-FileCopyrightText: 2021 Carl Schwan -// SPDX-License-Identifier: LGPL-2.0-or-later - -import QtQuick -import org.kde.kirigami as Kirigami -import org.kde.kirigamiaddons.settings as KirigamiSettings -import QtQuick.Layouts - -import org.kde.neochat - -KirigamiSettings.CategorizedSettings { - id: root - - property NeoChatConnection connection - - property NeoChatConnection initialAccount - - objectName: "settingsPage" - actions: [ - KirigamiSettings.SettingAction { - actionName: "general" - text: i18n("General") - icon.name: "org.kde.neochat" - page: Qt.resolvedUrl("NeoChatGeneralPage.qml") - }, - KirigamiSettings.SettingAction { - actionName: "appearance" - text: i18n("Appearance") - icon.name: "preferences-desktop-theme-global" - page: Qt.resolvedUrl("AppearanceSettingsPage.qml") - }, - KirigamiSettings.SettingAction { - actionName: "notifications" - text: i18n("Notifications") - icon.name: "preferences-desktop-notification" - page: Qt.resolvedUrl("GlobalNotificationsPage.qml") - initialProperties: { - return { - connection: root.connection - }; - } - }, - KirigamiSettings.SettingAction { - actionName: "security" - text: i18n("Security") - icon.name: "preferences-security" - page: Qt.resolvedUrl("NeoChatSecurityPage.qml") - initialProperties: { - return { - connection: root.connection - }; - } - }, - KirigamiSettings.SettingAction { - actionName: "accounts" - text: i18n("Accounts") - icon.name: "preferences-system-users" - page: Qt.resolvedUrl("AccountsPage.qml") - initialProperties: { - return { - initialAccount: root.initialAccount - }; - } - }, - KirigamiSettings.SettingAction { - actionName: "emoticons" - text: i18n("Stickers & Emojis") - icon.name: "preferences-desktop-emoticons" - page: Qt.resolvedUrl("EmoticonsPage.qml") - initialProperties: { - return { - connection: root.connection - }; - } - }, - KirigamiSettings.SettingAction { - actionName: "spellChecking" - text: i18n("Spell Checking") - icon.name: "tools-check-spelling" - page: Qt.resolvedUrl("SonnetConfigPage.qml") - visible: Qt.platform.os !== "android" - }, - KirigamiSettings.SettingAction { - actionName: "networkProxy" - text: i18n("Network Proxy") - icon.name: "network-connect" - page: Qt.resolvedUrl("NetworkProxyPage.qml") - }, - KirigamiSettings.SettingAction { - actionName: "devices" - text: i18n("Devices") - icon.name: "computer" - page: Qt.resolvedUrl("DevicesPage.qml") - initialProperties: { - return { - connection: root.connection - }; - } - }, - KirigamiSettings.SettingAction { - actionName: "aboutNeochat" - text: i18n("About NeoChat") - icon.name: "help-about" - page: Qt.resolvedUrl("About.qml") - }, - KirigamiSettings.SettingAction { - actionName: "aboutKDE" - text: i18n("About KDE") - icon.name: "kde" - page: Qt.resolvedUrl("AboutKDE.qml") - } - ] -} diff --git a/src/settings/NeoChatSettingsView.qml b/src/settings/NeoChatSettingsView.qml new file mode 100644 index 000000000..6fc468908 --- /dev/null +++ b/src/settings/NeoChatSettingsView.qml @@ -0,0 +1,110 @@ +// SPDX-FileCopyrightText: 2021 Carl Schwan +// SPDX-License-Identifier: LGPL-2.0-or-later + +pragma Singleton + +import QtQuick +import org.kde.kirigami as Kirigami +import org.kde.kirigamiaddons.settings as KirigamiSettings +import QtQuick.Layouts + +import org.kde.neochat + +KirigamiSettings.ConfigurationView { + id: root + + property NeoChatConnection connection + + objectName: "settingsPage" + modules: [ + KirigamiSettings.ConfigurationModule { + moduleId: "general" + text: i18n("General") + icon.name: "org.kde.neochat" + page: () => Qt.createComponent("org.kde.neochat.settings", "NeoChatGeneralPage") + }, + KirigamiSettings.ConfigurationModule { + moduleId: "appearance" + text: i18n("Appearance") + icon.name: "preferences-desktop-theme-global" + page: () => Qt.createComponent("org.kde.neochat.settings", "AppearanceSettingsPage") + }, + KirigamiSettings.ConfigurationModule { + moduleId: "notifications" + text: i18n("Notifications") + icon.name: "preferences-desktop-notification" + page: () => Qt.createComponent("org.kde.neochat.settings", "GlobalNotificationsPage") + initialProperties: () => { + return { + connection: root.connection + }; + } + }, + KirigamiSettings.ConfigurationModule { + moduleId: "security" + text: i18n("Security") + icon.name: "preferences-security" + page: () => Qt.createComponent("org.kde.neochat.settings", "NeoChatSecurityPage") + initialProperties: () => { + return { + connection: root.connection + }; + } + }, + KirigamiSettings.ConfigurationModule { + moduleId: "accounts" + text: i18n("Accounts") + icon.name: "preferences-system-users" + page: () => Qt.createComponent("org.kde.neochat.settings", "AccountsPage") + }, + KirigamiSettings.ConfigurationModule { + moduleId: "emoticons" + text: i18n("Stickers & Emojis") + icon.name: "preferences-desktop-emoticons" + page: () => Qt.createComponent("org.kde.neochat.settings", "EmoticonsPage") + initialProperties: () => { + return { + connection: root.connection + }; + } + }, + KirigamiSettings.ConfigurationModule { + moduleId: "spellChecking" + text: i18n("Spell Checking") + icon.name: "tools-check-spelling" + page: () => Qt.createComponent("org.kde.neochat.settings", "SonnetConfigPage") + visible: Qt.platform.os !== "android" + }, + KirigamiSettings.ConfigurationModule { + moduleId: "networkProxy" + text: i18n("Network Proxy") + icon.name: "network-connect" + page: () => Qt.createComponent("org.kde.neochat.settings", "NetworkProxyPage") + }, + KirigamiSettings.ConfigurationModule { + moduleId: "devices" + text: i18n("Devices") + icon.name: "computer" + page: () => Qt.createComponent("org.kde.neochat.settings", "DevicesPage") + initialProperties: () => { + return { + connection: root.connection + }; + } + }, + KirigamiSettings.ConfigurationModule { + moduleId: "aboutNeochat" + text: i18n("About NeoChat") + icon.name: "help-about" + page: () => Qt.createComponent("org.kde.kirigamiaddons.formcard", "AboutPage") + category: i18nc("@title:group", "About") + }, + KirigamiSettings.ConfigurationModule { + moduleId: "aboutKDE" + text: i18n("About KDE") + icon.name: "kde" + page: () => Qt.createComponent("org.kde.kirigamiaddons.formcard", "AboutKDE") + category: i18nc("@title:group", "About") + } + ] +} diff --git a/src/settings/RoomSettings.qml b/src/settings/RoomSettings.qml deleted file mode 100644 index 9eebce02a..000000000 --- a/src/settings/RoomSettings.qml +++ /dev/null @@ -1,65 +0,0 @@ -// SPDX-FileCopyrightText: 2021 Carl Schwan -// SPDX-License-Identifier: LGPL-2.0-or-later - -import QtQuick -import org.kde.kirigami as Kirigami -import org.kde.kirigamiaddons.settings as KirigamiSettings -import QtQuick.Layouts - -import org.kde.neochat - -KirigamiSettings.CategorizedSettings { - id: root - - property NeoChatRoom room - required property NeoChatConnection connection - - objectName: "settingsPage" - actions: [ - KirigamiSettings.SettingAction { - actionName: "general" - text: i18n("General") - icon.name: "settings-configure" - page: Qt.resolvedUrl("RoomGeneralPage.qml") - initialProperties: { - return { - room: root.room, - connection: root.connection - }; - } - }, - KirigamiSettings.SettingAction { - actionName: "security" - text: i18n("Security") - icon.name: "security-low" - page: Qt.resolvedUrl("RoomSecurityPage.qml") - initialProperties: { - return { - room: root.room - }; - } - }, - KirigamiSettings.SettingAction { - actionName: "permissions" - text: i18n("Permissions") - icon.name: "visibility" - page: Qt.resolvedUrl("Permissions.qml") - initialProperties: { - return { - room: root.room - }; - } - }, - KirigamiSettings.SettingAction { - actionName: "notifications" - text: i18n("Notifications") - icon.name: "notifications" - page: Qt.resolvedUrl("PushNotification.qml") - initialProperties: { - return { - room: root.room - }; - } - } - ] -} diff --git a/src/settings/RoomSettingsView.qml b/src/settings/RoomSettingsView.qml new file mode 100644 index 000000000..cfeac25f0 --- /dev/null +++ b/src/settings/RoomSettingsView.qml @@ -0,0 +1,83 @@ +// SPDX-FileCopyrightText: 2021 Carl Schwan +// SPDX-License-Identifier: LGPL-2.0-or-later + +pragma Singleton + +import QtQuick +import org.kde.kirigami as Kirigami +import org.kde.kirigamiaddons.settings as KirigamiSettings +import QtQuick.Layouts + +import org.kde.neochat + +KirigamiSettings.ConfigurationView { + id: root + + enum Type { + Room, + Space + } + + property NeoChatRoom _room + property NeoChatConnection _connection + + function openRoomSettings(room: NeoChatRoom, type: int): void { + root._room = room; + root._connection = room.connection; + if (type === RoomSettingsView.Type.Space) { + root.title = i18nc("@title:window", "Space Settings"); + } else { + root.title = i18nc("@title:window", "Room Settings"); + } + open(); + } + + objectName: "settingsPage" + modules: [ + KirigamiSettings.ConfigurationModule { + moduleId: "general" + text: i18n("General") + icon.name: "settings-configure" + page: () => Qt.createComponent("org.kde.neochat.settings", "RoomGeneralPage") + initialProperties: () => { + return { + room: root._room, + connection: root._connection + }; + } + }, + KirigamiSettings.ConfigurationModule { + moduleId: "security" + text: i18n("Security") + icon.name: "security-low" + page: () => Qt.createComponent("org.kde.neochat.settings", "RoomSecurityPage") + initialProperties: () => { + return { + room: root._room + }; + } + }, + KirigamiSettings.ConfigurationModule { + moduleId: "permissions" + text: i18n("Permissions") + icon.name: "visibility" + page: () => Qt.createComponent("org.kde.neochat.settings", "Permissions") + initialProperties: () => { + return { + room: root._room + }; + } + }, + KirigamiSettings.ConfigurationModule { + moduleId: "notifications" + text: i18n("Notifications") + icon.name: "notifications" + page: () => Qt.createComponent("org.kde.neochat.settings", "PushNotification") + initialProperties: () => { + return { + room: root._room + }; + } + } + ] +}