Port general settings page to FormCard

This commit is contained in:
Tobias Fella
2023-09-01 18:00:36 +02:00
parent cfd9f36a97
commit 40d2eb5aba

View File

@@ -6,231 +6,199 @@ import QtQuick 2.15
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import org.kde.kirigami 2.15 as Kirigami import org.kde.kirigami 2.15 as Kirigami
import org.kde.kirigamiaddons.labs.mobileform 0.1 as MobileForm import org.kde.kirigamiaddons.formcard 1.0 as FormCard
import org.kde.neochat 1.0 import org.kde.neochat 1.0
Kirigami.ScrollablePage { FormCard.FormCardPage {
title: i18nc("@title:window", "General") title: i18nc("@title:window", "General")
topPadding: 0
leftPadding: 0 FormCard.FormHeader {
rightPadding: 0 title: i18n("General settings")
ColumnLayout { visible: Qt.platform.os !== "android"
spacing: 0 }
MobileForm.FormHeader { FormCard.FormCard {
Layout.fillWidth: true FormCard.FormCheckDelegate {
title: i18n("General settings") id: closeDelegate
text: i18n("Show in System Tray")
checked: Config.systemTray
visible: Controller.supportSystemTray
enabled: !Config.isSystemTrayImmutable
onToggled: {
Config.systemTray = checked
Config.save()
}
}
FormCard.FormDelegateSeparator { above: closeDelegate; below: minimizeDelegate }
FormCard.FormCheckDelegate {
id: minimizeDelegate
text: i18n("Minimize to system tray on startup")
checked: Config.minimizeToSystemTrayOnStartup
visible: Controller.supportSystemTray && !Kirigami.Settings.isMobile
enabled: Config.systemTray && !Config.isMinimizeToSystemTrayOnStartupImmutable
onToggled: {
Config.minimizeToSystemTrayOnStartup = checked
Config.save()
}
}
FormCard.FormDelegateSeparator { above: minimizeDelegate; below: automaticallyDelegate }
FormCard.FormCheckDelegate {
id: automaticallyDelegate
text: i18n("Automatically hide/unhide the room information when resizing the window")
checked: Config.autoRoomInfoDrawer
enabled: !Config.isAutoRoomInfoDrawerImmutable
visible: Qt.platform.os !== "android" visible: Qt.platform.os !== "android"
} onToggled: {
MobileForm.FormCard { Config.autoRoomInfoDrawer = checked
Layout.fillWidth: true Config.save()
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormCheckDelegate {
id: closeDelegate
text: i18n("Show in System Tray")
checked: Config.systemTray
visible: Controller.supportSystemTray
enabled: !Config.isSystemTrayImmutable
onToggled: {
Config.systemTray = checked
Config.save()
}
}
MobileForm.FormDelegateSeparator { above: closeDelegate; below: minimizeDelegate }
MobileForm.FormCheckDelegate {
id: minimizeDelegate
text: i18n("Minimize to system tray on startup")
checked: Config.minimizeToSystemTrayOnStartup
visible: Controller.supportSystemTray && !Kirigami.Settings.isMobile
enabled: Config.systemTray && !Config.isMinimizeToSystemTrayOnStartupImmutable
onToggled: {
Config.minimizeToSystemTrayOnStartup = checked
Config.save()
}
}
MobileForm.FormDelegateSeparator { above: minimizeDelegate; below: automaticallyDelegate }
MobileForm.FormCheckDelegate {
id: automaticallyDelegate
text: i18n("Automatically hide/unhide the room information when resizing the window")
checked: Config.autoRoomInfoDrawer
enabled: !Config.isAutoRoomInfoDrawerImmutable
visible: Qt.platform.os !== "android"
onToggled: {
Config.autoRoomInfoDrawer = checked
Config.save()
}
}
} }
} }
MobileForm.FormHeader { }
Layout.fillWidth: true FormCard.FormHeader {
title: i18n("Timeline Events") title: i18n("Timeline Events")
} }
MobileForm.FormCard { FormCard.FormCard {
Layout.fillWidth: true FormCard.FormCheckDelegate {
contentItem: ColumnLayout { id: showDeletedMessages
spacing: 0 text: i18n("Show deleted messages")
checked: Config.showDeletedMessages
MobileForm.FormCheckDelegate { enabled: !Config.isShowDeletedMessagesImmutable
id: showDeletedMessages onToggled: {
text: i18n("Show deleted messages") Config.showDeletedMessages = checked
checked: Config.showDeletedMessages Config.save()
enabled: !Config.isShowDeletedMessagesImmutable
onToggled: {
Config.showDeletedMessages = checked
Config.save()
}
}
MobileForm.FormDelegateSeparator { above: showDeletedMessages; below: showStateEvents }
MobileForm.FormCheckDelegate {
id: showStateEvents
text: i18n("Show state events")
checked: Config.showStateEvent
enabled: !Config.isShowStateEventImmutable
onToggled: {
Config.showStateEvent = checked
Config.save()
}
}
MobileForm.FormDelegateSeparator {
visible: Config.showStateEvent
above: showStateEvents
below: showLeaveJoinEventDelegate }
MobileForm.FormCheckDelegate {
id: showLeaveJoinEventDelegate
visible: Config.showStateEvent
text: i18n("Show leave and join events")
checked: Config.showLeaveJoinEvent
enabled: !Config.isShowLeaveJoinEventImmutable
onToggled: {
Config.showLeaveJoinEvent = checked
Config.save()
}
}
MobileForm.FormDelegateSeparator {
visible: Config.showStateEvent
above: showLeaveJoinEventDelegate
below: showNameDelegate
}
MobileForm.FormCheckDelegate {
id: showNameDelegate
visible: Config.showStateEvent
text: i18n("Show name change events")
checked: Config.showRename
enabled: !Config.isShowRenameImmutable
onToggled: {
Config.showRename = checked
Config.save()
}
}
MobileForm.FormDelegateSeparator {
visible: Config.showStateEvent
above: showNameDelegate
below: showAvatarChangeDelegate
}
MobileForm.FormCheckDelegate {
id: showAvatarChangeDelegate
visible: Config.showStateEvent
text: i18n("Show avatar update events")
checked: Config.showAvatarUpdate
enabled: !Config.isShowAvatarUpdateImmutable
onToggled: {
Config.showAvatarUpdate = checked
Config.save()
}
}
} }
} }
MobileForm.FormHeader {
Layout.fillWidth: true FormCard.FormDelegateSeparator { above: showDeletedMessages; below: showStateEvents }
title: i18n("Rooms and private chats")
} FormCard.FormCheckDelegate {
MobileForm.FormCard { id: showStateEvents
Layout.fillWidth: true text: i18n("Show state events")
contentItem: ColumnLayout { checked: Config.showStateEvent
spacing: 0 enabled: !Config.isShowStateEventImmutable
MobileForm.FormRadioDelegate { onToggled: {
text: i18n("Separated") Config.showStateEvent = checked
checked: !Config.mergeRoomList Config.save()
enabled: !Config.isMergeRoomListImmutable
onToggled: {
Config.mergeRoomList = false
Config.save()
}
}
MobileForm.FormRadioDelegate {
text: i18n("Intermixed")
checked: Config.mergeRoomList
enabled: !Config.isMergeRoomListImmutable
onToggled: {
Config.mergeRoomList = true
Config.save()
}
}
} }
} }
MobileForm.FormHeader {
Layout.fillWidth: true FormCard.FormDelegateSeparator {
title: i18nc("Chat Editor", "Editor") visible: Config.showStateEvent
} above: showStateEvents
MobileForm.FormCard { below: showLeaveJoinEventDelegate }
Layout.fillWidth: true
contentItem: ColumnLayout { FormCard.FormCheckDelegate {
spacing: 0 id: showLeaveJoinEventDelegate
MobileForm.FormCheckDelegate { visible: Config.showStateEvent
id: quickEditCheckbox text: i18n("Show leave and join events")
text: i18n("Use s/text/replacement syntax to edit your last message") checked: Config.showLeaveJoinEvent
checked: Config.allowQuickEdit enabled: !Config.isShowLeaveJoinEventImmutable
enabled: !Config.isAllowQuickEditImmutable onToggled: {
onToggled: { Config.showLeaveJoinEvent = checked
Config.allowQuickEdit = checked Config.save()
Config.save()
}
}
MobileForm.FormDelegateSeparator { above: quickEditCheckbox; below: typingNotificationsDelegate }
MobileForm.FormCheckDelegate {
id: typingNotificationsDelegate
text: i18n("Send typing notifications")
checked: Config.typingNotifications
enabled: !Config.isTypingNotificationsImmutable
onToggled: {
Config.typingNotifications = checked
Config.save()
}
}
} }
} }
MobileForm.FormHeader {
Layout.fillWidth: true FormCard.FormDelegateSeparator {
title: i18n("Developer Settings") visible: Config.showStateEvent
above: showLeaveJoinEventDelegate
below: showNameDelegate
} }
MobileForm.FormCard {
Layout.fillWidth: true FormCard.FormCheckDelegate {
contentItem: ColumnLayout { id: showNameDelegate
spacing: 0 visible: Config.showStateEvent
MobileForm.FormCheckDelegate { text: i18n("Show name change events")
text: i18n("Enable developer tools") checked: Config.showRename
checked: Config.developerTools enabled: !Config.isShowRenameImmutable
enabled: !Config.isDeveloperToolsImmutable onToggled: {
onToggled: { Config.showRename = checked
Config.developerTools = checked Config.save()
Config.save() }
} }
}
FormCard.FormDelegateSeparator {
visible: Config.showStateEvent
above: showNameDelegate
below: showAvatarChangeDelegate
}
FormCard.FormCheckDelegate {
id: showAvatarChangeDelegate
visible: Config.showStateEvent
text: i18n("Show avatar update events")
checked: Config.showAvatarUpdate
enabled: !Config.isShowAvatarUpdateImmutable
onToggled: {
Config.showAvatarUpdate = checked
Config.save()
}
}
}
FormCard.FormHeader {
title: i18n("Rooms and private chats")
}
FormCard.FormCard {
FormCard.FormRadioDelegate {
text: i18n("Separated")
checked: !Config.mergeRoomList
enabled: !Config.isMergeRoomListImmutable
onToggled: {
Config.mergeRoomList = false
Config.save()
}
}
FormCard.FormRadioDelegate {
text: i18n("Intermixed")
checked: Config.mergeRoomList
enabled: !Config.isMergeRoomListImmutable
onToggled: {
Config.mergeRoomList = true
Config.save()
}
}
}
FormCard.FormHeader {
title: i18nc("Chat Editor", "Editor")
}
FormCard.FormCard {
FormCard.FormCheckDelegate {
id: quickEditCheckbox
text: i18n("Use s/text/replacement syntax to edit your last message")
checked: Config.allowQuickEdit
enabled: !Config.isAllowQuickEditImmutable
onToggled: {
Config.allowQuickEdit = checked
Config.save()
}
}
FormCard.FormDelegateSeparator { above: quickEditCheckbox; below: typingNotificationsDelegate }
FormCard.FormCheckDelegate {
id: typingNotificationsDelegate
text: i18n("Send typing notifications")
checked: Config.typingNotifications
enabled: !Config.isTypingNotificationsImmutable
onToggled: {
Config.typingNotifications = checked
Config.save()
}
}
}
FormCard.FormHeader {
title: i18n("Developer Settings")
}
FormCard.FormCard {
FormCard.FormCheckDelegate {
text: i18n("Enable developer tools")
checked: Config.developerTools
enabled: !Config.isDeveloperToolsImmutable
onToggled: {
Config.developerTools = checked
Config.save()
} }
} }
} }