Convert to new Kirigami Form

This commit is contained in:
James Graham
2026-02-09 20:09:18 +00:00
parent 3b2df95df7
commit 9fc78c4018

View File

@@ -12,71 +12,63 @@ import org.kde.kirigamiaddons.formcard as FormCard
import org.kde.neochat import org.kde.neochat
import org.kde.neochat.devtools import org.kde.neochat.devtools
FormCard.FormCardPage { Kirigami.ScrollablePage {
id: root id: root
required property NeoChatConnection connection required property NeoChatConnection connection
title: i18nc("@title:window", "General") title: i18nc("@title:window", "General")
FormCard.FormHeader { Kirigami.Form {
title: i18nc("@title:group", "General Settings") Kirigami.FormGroup {
visible: Qt.platform.os !== "android" title: Qt.platform.os === "android" ? "" : i18nc("@title:group", "General Settings")
}
FormCard.FormCard { Kirigami.FormEntry {
FormCard.FormCheckDelegate { visible: Controller.supportSystemTray
id: closeDelegate contentItem: QQC2.CheckBox {
text: i18n("Show in System Tray") text: i18n("Show in System Tray")
checked: NeoChatConfig.systemTray checked: NeoChatConfig.systemTray
visible: Controller.supportSystemTray
enabled: !NeoChatConfig.isSystemTrayImmutable enabled: !NeoChatConfig.isSystemTrayImmutable
onToggled: { onToggled: {
NeoChatConfig.systemTray = checked; NeoChatConfig.systemTray = checked;
NeoChatConfig.save(); NeoChatConfig.save();
} }
} }
FormCard.FormDelegateSeparator {
above: closeDelegate
below: minimizeDelegate
} }
Kirigami.FormSeparator {}
FormCard.FormCheckDelegate { Kirigami.FormEntry {
id: minimizeDelegate id: minimizeDelegate
visible: Controller.supportSystemTray && !Kirigami.Settings.isMobile && NeoChatConfig.systemTray
contentItem: QQC2.CheckBox {
text: i18n("Minimize to system tray on startup") text: i18n("Minimize to system tray on startup")
checked: NeoChatConfig.minimizeToSystemTrayOnStartup checked: NeoChatConfig.minimizeToSystemTrayOnStartup
visible: Controller.supportSystemTray && !Kirigami.Settings.isMobile && NeoChatConfig.systemTray
enabled: NeoChatConfig.systemTray && !NeoChatConfig.isMinimizeToSystemTrayOnStartupImmutable enabled: NeoChatConfig.systemTray && !NeoChatConfig.isMinimizeToSystemTrayOnStartupImmutable
onToggled: { onToggled: {
NeoChatConfig.minimizeToSystemTrayOnStartup = checked; NeoChatConfig.minimizeToSystemTrayOnStartup = checked;
NeoChatConfig.save(); NeoChatConfig.save();
} }
} }
}
FormCard.FormDelegateSeparator { Kirigami.FormSeparator {
above: minimizeDelegate
below: automaticallyDelegate
visible: minimizeDelegate.visible visible: minimizeDelegate.visible
} }
Kirigami.FormEntry {
FormCard.FormCheckDelegate {
id: automaticallyDelegate id: automaticallyDelegate
visible: Qt.platform.os !== "android"
contentItem: QQC2.CheckBox {
text: i18n("Automatically hide/unhide the room information when resizing the window") text: i18n("Automatically hide/unhide the room information when resizing the window")
checked: NeoChatConfig.autoRoomInfoDrawer checked: NeoChatConfig.autoRoomInfoDrawer
enabled: !NeoChatConfig.isAutoRoomInfoDrawerImmutable enabled: !NeoChatConfig.isAutoRoomInfoDrawerImmutable
visible: Qt.platform.os !== "android"
onToggled: { onToggled: {
NeoChatConfig.autoRoomInfoDrawer = checked; NeoChatConfig.autoRoomInfoDrawer = checked;
NeoChatConfig.save(); NeoChatConfig.save();
} }
} }
FormCard.FormDelegateSeparator {
above: automaticallyDelegate
below: categorizeDelegate
} }
FormCard.FormCheckDelegate { Kirigami.FormSeparator {}
Kirigami.FormEntry {
id: categorizeDelegate id: categorizeDelegate
contentItem: QQC2.CheckBox {
text: i18n("Show all rooms in \"Home\" tab") text: i18n("Show all rooms in \"Home\" tab")
checked: NeoChatConfig.allRoomsInHome checked: NeoChatConfig.allRoomsInHome
enabled: !NeoChatConfig.isAllRoomsInHomeImmutable enabled: !NeoChatConfig.isAllRoomsInHomeImmutable
@@ -85,21 +77,18 @@ FormCard.FormCardPage {
NeoChatConfig.save(); NeoChatConfig.save();
} }
} }
} }
FormCard.FormHeader { }
Kirigami.FormGroup {
title: i18nc("@title:group", "Room List Sort Order") title: i18nc("@title:group", "Room List Sort Order")
Kirigami.FormEntry {
title: i18nc("@info:label", "Hidden events are not considered as recent activity when sorting rooms.")
} }
FormCard.FormCard { Kirigami.FormSeparator {}
FormCard.FormTextDelegate { Kirigami.FormEntry {
text: i18nc("@info:label", "Hidden events are not considered as recent activity when sorting rooms.") subtitle: i18nc("@info", "Rooms with unread notifications will be shown first.")
} contentItem: QQC2.RadioButton {
FormCard.FormDelegateSeparator {}
FormCard.FormRadioDelegate {
text: i18nc("As in 'sort something based on last activity'", "Importance") text: i18nc("As in 'sort something based on last activity'", "Importance")
description: i18nc("@info", "Rooms with unread notifications will be shown first.")
checked: NeoChatConfig.sortOrder === 1 checked: NeoChatConfig.sortOrder === 1
enabled: !NeoChatConfig.isSortOrderImmutable enabled: !NeoChatConfig.isSortOrderImmutable
onToggled: { onToggled: {
@@ -108,7 +97,9 @@ FormCard.FormCardPage {
NeoChatConfig.save() NeoChatConfig.save()
} }
} }
FormCard.FormRadioDelegate { }
Kirigami.FormEntry {
contentItem: QQC2.RadioButton {
text: i18nc("As in 'sort something alphabetically'", "Alphabetical") text: i18nc("As in 'sort something alphabetically'", "Alphabetical")
checked: NeoChatConfig.sortOrder === 0 checked: NeoChatConfig.sortOrder === 0
enabled: !NeoChatConfig.isSortOrderImmutable enabled: !NeoChatConfig.isSortOrderImmutable
@@ -118,9 +109,11 @@ FormCard.FormCardPage {
NeoChatConfig.save() NeoChatConfig.save()
} }
} }
FormCard.FormRadioDelegate { }
Kirigami.FormEntry {
subtitle: i18nc("@info", "Rooms with the newest events will be shown first.")
contentItem: QQC2.RadioButton {
text: i18nc("As in 'sort something based on the last event'", "Newest Events") text: i18nc("As in 'sort something based on the last event'", "Newest Events")
description: i18nc("@info", "Rooms with the newest events will be shown first.")
checked: NeoChatConfig.sortOrder === 2 checked: NeoChatConfig.sortOrder === 2
enabled: !NeoChatConfig.isSortOrderImmutable enabled: !NeoChatConfig.isSortOrderImmutable
onToggled: { onToggled: {
@@ -129,8 +122,10 @@ FormCard.FormCardPage {
NeoChatConfig.save() NeoChatConfig.save()
} }
} }
FormCard.FormRadioDelegate { }
Kirigami.FormEntry {
id: openCustomRoomSortButton id: openCustomRoomSortButton
contentItem: QQC2.RadioButton {
text: i18nc("@option:radio", "Custom") text: i18nc("@option:radio", "Custom")
checked: NeoChatConfig.sortOrder === 3 checked: NeoChatConfig.sortOrder === 3
enabled: !NeoChatConfig.isSortOrderImmutable enabled: !NeoChatConfig.isSortOrderImmutable
@@ -139,13 +134,14 @@ FormCard.FormCardPage {
} }
} }
} }
FormCard.FormHeader {
title: i18nc("@title", "Timeline")
} }
FormCard.FormCard { Kirigami.FormGroup {
FormCard.FormComboBoxDelegate { title: i18nc("@title", "Timeline")
Kirigami.FormEntry {
id: markAsReadCombo id: markAsReadCombo
text: i18n("Mark messages as read when:") title: i18n("Mark messages as read when:")
contentItem: QQC2.ComboBox {
textRole: "name" textRole: "name"
valueRole: "value" valueRole: "value"
model: [ model: [
@@ -173,14 +169,11 @@ FormCard.FormCardPage {
Component.onCompleted: currentIndex = NeoChatConfig.markReadCondition Component.onCompleted: currentIndex = NeoChatConfig.markReadCondition
onCurrentValueChanged: NeoChatConfig.markReadCondition = currentValue onCurrentValueChanged: NeoChatConfig.markReadCondition = currentValue
} }
FormCard.FormDelegateSeparator {
above: markAsReadCombo
below: showDeletedMessages
} }
Kirigami.FormSeparator {}
FormCard.FormCheckDelegate { Kirigami.FormEntry {
id: showDeletedMessages id: showDeletedMessages
contentItem: QQC2.CheckBox {
text: i18n("Show deleted messages") text: i18n("Show deleted messages")
checked: NeoChatConfig.showDeletedMessages checked: NeoChatConfig.showDeletedMessages
enabled: !NeoChatConfig.isShowDeletedMessagesImmutable enabled: !NeoChatConfig.isShowDeletedMessagesImmutable
@@ -189,14 +182,11 @@ FormCard.FormCardPage {
NeoChatConfig.save(); NeoChatConfig.save();
} }
} }
FormCard.FormDelegateSeparator {
above: showDeletedMessages
below: showStateEvents
} }
Kirigami.FormSeparator {}
FormCard.FormCheckDelegate { Kirigami.FormEntry {
id: showStateEvents id: showStateEvents
contentItem: QQC2.CheckBox {
text: i18n("Show state events") text: i18n("Show state events")
checked: NeoChatConfig.showStateEvent checked: NeoChatConfig.showStateEvent
enabled: !NeoChatConfig.isShowStateEventImmutable enabled: !NeoChatConfig.isShowStateEventImmutable
@@ -205,16 +195,14 @@ FormCard.FormCardPage {
NeoChatConfig.save(); NeoChatConfig.save();
} }
} }
FormCard.FormDelegateSeparator {
visible: NeoChatConfig.showStateEvent
above: showStateEvents
below: showLeaveJoinEventDelegate
} }
Kirigami.FormSeparator {
FormCard.FormCheckDelegate { visible: NeoChatConfig.showStateEvent
}
Kirigami.FormEntry {
id: showLeaveJoinEventDelegate id: showLeaveJoinEventDelegate
visible: NeoChatConfig.showStateEvent visible: NeoChatConfig.showStateEvent
contentItem: QQC2.CheckBox {
text: i18n("Show leave and join events") text: i18n("Show leave and join events")
checked: NeoChatConfig.showLeaveJoinEvent checked: NeoChatConfig.showLeaveJoinEvent
enabled: !NeoChatConfig.isShowLeaveJoinEventImmutable enabled: !NeoChatConfig.isShowLeaveJoinEventImmutable
@@ -223,16 +211,14 @@ FormCard.FormCardPage {
NeoChatConfig.save(); NeoChatConfig.save();
} }
} }
FormCard.FormDelegateSeparator {
visible: NeoChatConfig.showStateEvent
above: showLeaveJoinEventDelegate
below: showNameDelegate
} }
Kirigami.FormSeparator {
FormCard.FormCheckDelegate { visible: NeoChatConfig.showStateEvent
}
Kirigami.FormEntry {
id: showNameDelegate id: showNameDelegate
visible: NeoChatConfig.showStateEvent visible: NeoChatConfig.showStateEvent
contentItem: QQC2.CheckBox {
text: i18n("Show name change events") text: i18n("Show name change events")
checked: NeoChatConfig.showRename checked: NeoChatConfig.showRename
enabled: !NeoChatConfig.isShowRenameImmutable enabled: !NeoChatConfig.isShowRenameImmutable
@@ -241,17 +227,15 @@ FormCard.FormCardPage {
NeoChatConfig.save(); NeoChatConfig.save();
} }
} }
FormCard.FormDelegateSeparator {
visible: NeoChatConfig.showStateEvent
above: showNameDelegate
below: showAvatarChangeDelegate
} }
Kirigami.FormSeparator {
FormCard.FormCheckDelegate { visible: NeoChatConfig.showStateEvent
}
Kirigami.FormEntry {
id: showAvatarChangeDelegate id: showAvatarChangeDelegate
visible: NeoChatConfig.showStateEvent visible: NeoChatConfig.showStateEvent
text: i18n("Show avatar update events") contentItem: QQC2.CheckBox {
text: i18n("Show name change events")
checked: NeoChatConfig.showAvatarUpdate checked: NeoChatConfig.showAvatarUpdate
enabled: !NeoChatConfig.isShowAvatarUpdateImmutable enabled: !NeoChatConfig.isShowAvatarUpdateImmutable
onToggled: { onToggled: {
@@ -260,38 +244,40 @@ FormCard.FormCardPage {
} }
} }
} }
FormCard.FormHeader {
title: i18nc("Chat Editor", "Editor")
} }
FormCard.FormCard { Kirigami.FormGroup {
FormCard.FormRadioDelegate { title: i18nc("Chat Editor", "Editor")
Kirigami.FormEntry {
visible: !Kirigami.Settings.isMobile
contentItem: QQC2.RadioButton {
text: i18nc("@option:radio", "Send messages with Enter") text: i18nc("@option:radio", "Send messages with Enter")
checked: NeoChatConfig.sendMessageWith === 0 checked: NeoChatConfig.sendMessageWith === 0
visible: !Kirigami.Settings.isMobile
enabled: !NeoChatConfig.isSendMessageWithImmutable enabled: !NeoChatConfig.isSendMessageWithImmutable
onToggled: { onToggled: {
NeoChatConfig.sendMessageWith = 0 NeoChatConfig.sendMessageWith = 0
NeoChatConfig.save() NeoChatConfig.save()
} }
} }
FormCard.FormRadioDelegate { }
id: sendWithEnterRadio Kirigami.FormEntry {
visible: !Kirigami.Settings.isMobile
contentItem: QQC2.RadioButton {
text: i18nc("@option:radio", "Send messages with Ctrl+Enter") text: i18nc("@option:radio", "Send messages with Ctrl+Enter")
checked: NeoChatConfig.sendMessageWith === 1 checked: NeoChatConfig.sendMessageWith === 1
visible: !Kirigami.Settings.isMobile
enabled: !NeoChatConfig.isSendMessageWithImmutable enabled: !NeoChatConfig.isSendMessageWithImmutable
onToggled: { onToggled: {
NeoChatConfig.sendMessageWith = 1 NeoChatConfig.sendMessageWith = 1
NeoChatConfig.save() NeoChatConfig.save()
} }
} }
FormCard.FormDelegateSeparator {
visible: !Kirigami.Settings.isMobile
above: sendWithEnterRadio
below: quickEditCheckbox
} }
FormCard.FormCheckDelegate { Kirigami.FormSeparator {
visible: !Kirigami.Settings.isMobile
}
Kirigami.FormEntry {
id: quickEditCheckbox id: quickEditCheckbox
contentItem: QQC2.CheckBox {
text: i18n("Use s/text/replacement syntax to edit your last message") text: i18n("Use s/text/replacement syntax to edit your last message")
checked: NeoChatConfig.allowQuickEdit checked: NeoChatConfig.allowQuickEdit
enabled: !NeoChatConfig.isAllowQuickEditImmutable enabled: !NeoChatConfig.isAllowQuickEditImmutable
@@ -300,12 +286,11 @@ FormCard.FormCardPage {
NeoChatConfig.save(); NeoChatConfig.save();
} }
} }
FormCard.FormDelegateSeparator {
above: quickEditCheckbox
below: typingNotificationsDelegate
} }
FormCard.FormCheckDelegate { Kirigami.FormSeparator {}
Kirigami.FormEntry {
id: typingNotificationsDelegate id: typingNotificationsDelegate
contentItem: QQC2.CheckBox {
text: i18n("Send typing notifications") text: i18n("Send typing notifications")
checked: NeoChatConfig.typingNotifications checked: NeoChatConfig.typingNotifications
enabled: !NeoChatConfig.isTypingNotificationsImmutable enabled: !NeoChatConfig.isTypingNotificationsImmutable
@@ -315,12 +300,13 @@ FormCard.FormCardPage {
} }
} }
} }
FormCard.FormHeader {
title: i18n("Developer Settings")
} }
FormCard.FormCard { Kirigami.FormGroup {
FormCard.FormCheckDelegate { title: i18n("Developer Settings")
Kirigami.FormEntry {
id: enableDeveloperToolsDelegate id: enableDeveloperToolsDelegate
contentItem: QQC2.CheckBox {
text: i18n("Enable developer tools") text: i18n("Enable developer tools")
checked: NeoChatConfig.developerTools checked: NeoChatConfig.developerTools
enabled: !NeoChatConfig.isDeveloperToolsImmutable enabled: !NeoChatConfig.isDeveloperToolsImmutable
@@ -329,15 +315,19 @@ FormCard.FormCardPage {
NeoChatConfig.save(); NeoChatConfig.save();
} }
} }
FormCard.FormDelegateSeparator {
above: enableDeveloperToolsDelegate
below: openDeveloperToolsDelegate
} }
FormCard.FormButtonDelegate { Kirigami.FormSeparator {}
Kirigami.FormEntry {
id: openDeveloperToolsDelegate id: openDeveloperToolsDelegate
visible: NeoChatConfig.developerTools visible: NeoChatConfig.developerTools
icon.name: "tools" leadingItems: Kirigami.Icon {
text: i18n("Open Developer Tools") implicitWidth: Kirigami.Units.iconSizes.smallMedium
implicitHeight: Kirigami.Units.iconSizes.smallMedium
source: "tools"
}
contentItem: QQC2.Label {
text: i18n("Enable developer tools")
}
onClicked: root.QQC2.ApplicationWindow.window.pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.devtools', 'DevtoolsPage'), { onClicked: root.QQC2.ApplicationWindow.window.pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.devtools', 'DevtoolsPage'), {
connection: root.connection connection: root.connection
}, { }, {
@@ -345,16 +335,22 @@ FormCard.FormCardPage {
}); });
} }
} }
FormCard.FormHeader { Kirigami.FormGroup {
title: i18nc("@title:group", "Default Settings") title: i18nc("@title:group", "Default Settings")
Kirigami.FormEntry {
leadingItems: Kirigami.Icon {
implicitWidth: Kirigami.Units.iconSizes.smallMedium
implicitHeight: Kirigami.Units.iconSizes.smallMedium
source: "kt-restore-defaults-symbolic"
} }
FormCard.FormCard { contentItem: QQC2.Label {
FormCard.FormButtonDelegate {
icon.name: "kt-restore-defaults-symbolic"
text: i18nc("@action:button", "Reset all configuration values to their default…") text: i18nc("@action:button", "Reset all configuration values to their default…")
}
onClicked: resetDialog.open() onClicked: resetDialog.open()
} }
} }
}
Kirigami.PromptDialog { Kirigami.PromptDialog {
id: resetDialog id: resetDialog
title: i18nc("@title:dialog", "Reset Configuration") title: i18nc("@title:dialog", "Reset Configuration")