From 15b625a3f80c7c1232243adae397bb9d6bebc275 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sat, 24 May 2025 15:32:35 -0400 Subject: [PATCH] Move certain internal room information to an Advanced settings page This has (as I've seen) confuse some users because we put this information front and center. The internal room ID and it's version isn't relevant for 99% of users, especially since most of them don't even have permission to touch these. Instead, let's do what Element smartly does and put it under an Advanced page you have to intentionally find. This also has the knock-on effect of propping up the importance of room aliases, which now appear higher in the general settings. --- src/settings/CMakeLists.txt | 1 + src/settings/RoomAdvancedPage.qml | 99 +++++++++++++++++++++++++++++++ src/settings/RoomGeneralPage.qml | 77 ------------------------ src/settings/RoomSettingsView.qml | 11 ++++ 4 files changed, 111 insertions(+), 77 deletions(-) create mode 100644 src/settings/RoomAdvancedPage.qml diff --git a/src/settings/CMakeLists.txt b/src/settings/CMakeLists.txt index f41aeb69f..ac315edad 100644 --- a/src/settings/CMakeLists.txt +++ b/src/settings/CMakeLists.txt @@ -49,6 +49,7 @@ ecm_add_qml_module(Settings GENERATE_PLUGIN_SOURCE ExportKeysDialog.qml RoomSortParameterDialog.qml RoomProfile.qml + RoomAdvancedPage.qml SOURCES colorschemer.cpp threepidaddhelper.cpp diff --git a/src/settings/RoomAdvancedPage.qml b/src/settings/RoomAdvancedPage.qml new file mode 100644 index 000000000..58086ce9d --- /dev/null +++ b/src/settings/RoomAdvancedPage.qml @@ -0,0 +1,99 @@ +// SPDX-FileCopyrightText: 2021 Carl Schwan +// SPDX-FileCopyrightText: 2025 Joshua Goins +// SPDX-License-Identifier: GPL-3.0-only + +import QtQuick +import QtQuick.Controls as QQC2 +import QtQuick.Layouts +import QtQuick.Window + +import org.kde.kirigami as Kirigami +import org.kde.kirigamiaddons.formcard as FormCard +import org.kde.kirigamiaddons.labs.components as KirigamiComponents + +import org.kde.neochat + +FormCard.FormCardPage { + id: root + + property NeoChatRoom room + + title: i18nc("@window:title", "Advanced") + + FormCard.FormCard { + Layout.topMargin: Kirigami.Units.gridUnit + + FormCard.FormTextDelegate { + id: roomIdDelegate + text: i18nc("@info:label", "Room ID") + description: room.id + + contentItem.children: QQC2.Button { + visible: roomIdDelegate.hovered + text: i18nc("@action:button", "Copy room ID to clipboard") + icon.name: "edit-copy" + display: QQC2.AbstractButton.IconOnly + + onClicked: { + Clipboard.saveText(room.id); + } + + QQC2.ToolTip.text: text + QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay + QQC2.ToolTip.visible: hovered + } + } + FormCard.FormTextDelegate { + text: i18nc("@info:label", "Room Version") + description: room.version + + contentItem.children: QQC2.Button { + visible: room.canSwitchVersions() + enabled: room.version < room.maxRoomVersion + text: i18nc("@action:button", "Upgrade Room") + icon.name: "arrow-up-double" + + onClicked: { + if (room.canSwitchVersions()) { + roomUpgradeDialog.currentRoomVersion = room.version; + roomUpgradeDialog.open(); + } + } + + QQC2.ToolTip { + text: text + delay: Kirigami.Units.toolTipDelay + } + } + } + } + + property Kirigami.Dialog roomUpgradeDialog: Kirigami.Dialog { + id: roomUpgradeDialog + + property var currentRoomVersion + + width: Kirigami.Units.gridUnit * 16 + + title: i18nc("@title", "Upgrade the Room") + ColumnLayout { + FormCard.FormSpinBoxDelegate { + id: spinBox + label: i18nc("@label:spinbox", "Select new version") + from: room.version + to: room.maxRoomVersion + value: room.version + } + } + customFooterActions: [ + Kirigami.Action { + text: i18nc("@action:button", "Confirm") + icon.name: "dialog-ok" + onTriggered: { + room.switchVersion(spinBox.value); + roomUpgradeDialog.close(); + } + } + ] + } +} diff --git a/src/settings/RoomGeneralPage.qml b/src/settings/RoomGeneralPage.qml index 79626a43c..849fb9f00 100644 --- a/src/settings/RoomGeneralPage.qml +++ b/src/settings/RoomGeneralPage.qml @@ -97,54 +97,6 @@ FormCard.FormCardPage { } } - FormCard.FormCard { - Layout.topMargin: Kirigami.Units.gridUnit - - FormCard.FormTextDelegate { - id: roomIdDelegate - text: i18n("Room ID") - description: room.id - - contentItem.children: QQC2.Button { - visible: roomIdDelegate.hovered - text: i18n("Copy room ID to clipboard") - icon.name: "edit-copy" - display: QQC2.AbstractButton.IconOnly - - onClicked: { - Clipboard.saveText(room.id); - } - - QQC2.ToolTip.text: text - QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay - QQC2.ToolTip.visible: hovered - } - } - FormCard.FormTextDelegate { - text: i18n("Room version") - description: room.version - - contentItem.children: QQC2.Button { - visible: room.canSwitchVersions() - enabled: room.version < room.maxRoomVersion - text: i18n("Upgrade Room") - icon.name: "arrow-up-double" - - onClicked: { - if (room.canSwitchVersions()) { - roomUpgradeDialog.currentRoomVersion = room.version; - roomUpgradeDialog.open(); - } - } - - QQC2.ToolTip { - text: text - delay: Kirigami.Units.toolTipDelay - } - } - } - } - FormCard.FormHeader { title: i18n("Aliases") } @@ -402,33 +354,4 @@ FormCard.FormCardPage { parentWindow: root.Window.window } } - - property Kirigami.Dialog roomUpgradeDialog: Kirigami.Dialog { - id: roomUpgradeDialog - - property var currentRoomVersion - - width: Kirigami.Units.gridUnit * 16 - - title: i18n("Upgrade the Room") - ColumnLayout { - FormCard.FormSpinBoxDelegate { - id: spinBox - label: i18n("Select new version") - from: room.version - to: room.maxRoomVersion - value: room.version - } - } - customFooterActions: [ - Kirigami.Action { - text: i18n("Confirm") - icon.name: "dialog-ok" - onTriggered: { - room.switchVersion(spinBox.value); - roomUpgradeDialog.close(); - } - } - ] - } } diff --git a/src/settings/RoomSettingsView.qml b/src/settings/RoomSettingsView.qml index c072cccbe..ae735a82a 100644 --- a/src/settings/RoomSettingsView.qml +++ b/src/settings/RoomSettingsView.qml @@ -89,6 +89,17 @@ KirigamiSettings.ConfigurationView { room: root._room }; } + }, + KirigamiSettings.ConfigurationModule { + moduleId: "advanced" + text: i18nc("@title", "Advanced") + icon.name: "document-properties-symbolic" + page: () => Qt.createComponent("org.kde.neochat.settings", "RoomAdvancedPage") + initialProperties: () => { + return { + room: root._room + }; + } } ] }