Use let kconfig register the config class

This commit is contained in:
Tobias Fella
2024-07-20 23:11:04 +02:00
parent 8ae7141851
commit d43aa169c3
33 changed files with 218 additions and 231 deletions

View File

@@ -202,7 +202,7 @@ FormCard.FormCardPage {
medium: "email"
}
ThreePIdCard {
visible: Config.phone3PId
visible: NeoChatConfig.phone3PId
connection: root.connection
title: i18n("Phone Numbers")
medium: "msisdn"

View File

@@ -41,8 +41,8 @@ FormCard.FormCardPage {
KirigamiComponents.Avatar {
color: "#4a5bcc"
Layout.alignment: Qt.AlignTop
visible: Config.showAvatarInTimeline
Layout.preferredWidth: Config.showAvatarInTimeline ? Kirigami.Units.largeSpacing * 2 : 0
visible: NeoChatConfig.showAvatarInTimeline
Layout.preferredWidth: NeoChatConfig.showAvatarInTimeline ? Kirigami.Units.largeSpacing * 2 : 0
Layout.preferredHeight: Kirigami.Units.largeSpacing * 2
}
QQC2.Control {
@@ -78,8 +78,8 @@ FormCard.FormCardPage {
KirigamiComponents.Avatar {
color: "#9f244b"
Layout.alignment: Qt.AlignTop
visible: Config.showAvatarInTimeline
Layout.preferredWidth: Config.showAvatarInTimeline ? Kirigami.Units.largeSpacing * 2 : 0
visible: NeoChatConfig.showAvatarInTimeline
Layout.preferredWidth: NeoChatConfig.showAvatarInTimeline ? Kirigami.Units.largeSpacing * 2 : 0
Layout.preferredHeight: Kirigami.Units.largeSpacing * 2
}
QQC2.Control {
@@ -113,13 +113,13 @@ FormCard.FormCardPage {
]
text: i18n("Bubbles")
checked: !Config.compactLayout
checked: !NeoChatConfig.compactLayout
QQC2.ButtonGroup.group: themeGroup
enabled: !Config.isCompactLayoutImmutable
enabled: !NeoChatConfig.isCompactLayoutImmutable
onToggled: {
Config.compactLayout = !checked;
Config.save();
NeoChatConfig.compactLayout = !checked;
NeoChatConfig.save();
}
}
ThemeRadioButton {
@@ -131,8 +131,8 @@ FormCard.FormCardPage {
KirigamiComponents.Avatar {
color: "#4a5bcc"
Layout.alignment: Qt.AlignTop
visible: Config.showAvatarInTimeline
Layout.preferredWidth: Config.showAvatarInTimeline ? Kirigami.Units.largeSpacing * 2 : 0
visible: NeoChatConfig.showAvatarInTimeline
Layout.preferredWidth: NeoChatConfig.showAvatarInTimeline ? Kirigami.Units.largeSpacing * 2 : 0
Layout.preferredHeight: Kirigami.Units.largeSpacing * 2
}
ColumnLayout {
@@ -158,8 +158,8 @@ FormCard.FormCardPage {
KirigamiComponents.Avatar {
color: "#9f244b"
Layout.alignment: Qt.AlignTop
visible: Config.showAvatarInTimeline
Layout.preferredWidth: Config.showAvatarInTimeline ? Kirigami.Units.largeSpacing * 2 : 0
visible: NeoChatConfig.showAvatarInTimeline
Layout.preferredWidth: NeoChatConfig.showAvatarInTimeline ? Kirigami.Units.largeSpacing * 2 : 0
Layout.preferredHeight: Kirigami.Units.largeSpacing * 2
}
ColumnLayout {
@@ -182,13 +182,13 @@ FormCard.FormCardPage {
}
]
text: i18n("Compact")
checked: Config.compactLayout
checked: NeoChatConfig.compactLayout
QQC2.ButtonGroup.group: themeGroup
enabled: !Config.isCompactLayoutImmutable
enabled: !NeoChatConfig.isCompactLayoutImmutable
onToggled: {
Config.compactLayout = checked;
Config.save();
NeoChatConfig.compactLayout = checked;
NeoChatConfig.save();
}
}
Item {
@@ -204,10 +204,10 @@ FormCard.FormCardPage {
FormCard.FormCheckDelegate {
id: compactRoomListDelegate
text: i18n("Use compact room list")
checked: Config.compactRoomList
checked: NeoChatConfig.compactRoomList
onToggled: {
Config.compactRoomList = checked;
Config.save();
NeoChatConfig.compactRoomList = checked;
NeoChatConfig.save();
}
}
@@ -231,11 +231,11 @@ FormCard.FormCardPage {
id: hasWindowSystemDelegate
visible: WindowController.hasWindowSystem
text: i18n("Use transparent chat page")
enabled: !Config.compactLayout && !Config.isBlurImmutable
checked: Config.blur
enabled: !NeoChatConfig.compactLayout && !NeoChatConfig.isBlurImmutable
checked: NeoChatConfig.blur
onToggled: {
Config.blur = checked;
Config.save();
NeoChatConfig.blur = checked;
NeoChatConfig.save();
}
}
@@ -246,8 +246,8 @@ FormCard.FormCardPage {
FormCard.AbstractFormDelegate {
id: transparencyDelegate
visible: WindowController.hasWindowSystem && Config.blur
enabled: !Config.isTransparancyImmutable
visible: WindowController.hasWindowSystem && NeoChatConfig.blur
enabled: !NeoChatConfig.isTransparancyImmutable
background: Item {}
contentItem: ColumnLayout {
QQC2.Label {
@@ -255,14 +255,14 @@ FormCard.FormCardPage {
Layout.fillWidth: true
}
QQC2.Slider {
enabled: !Config.compactLayout && Config.blur
enabled: !NeoChatConfig.compactLayout && NeoChatConfig.blur
from: 0
to: 1
stepSize: 0.05
value: Config.transparency
value: NeoChatConfig.transparency
onMoved: {
Config.transparency = value;
Config.save();
NeoChatConfig.transparency = value;
NeoChatConfig.save();
}
Layout.fillWidth: true
@@ -273,7 +273,7 @@ FormCard.FormCardPage {
QQC2.ToolTip.text: i18n("Only enabled if the transparent chat page is enabled.")
}
QQC2.Label {
text: Math.round(Config.transparency * 100) + "%"
text: Math.round(NeoChatConfig.transparency * 100) + "%"
Layout.fillWidth: true
}
}
@@ -288,11 +288,11 @@ FormCard.FormCardPage {
FormCard.FormCheckDelegate {
id: showLocalMessagesOnRightDelegate
text: i18n("Show your messages on the right")
checked: Config.showLocalMessagesOnRight
enabled: !Config.isShowLocalMessagesOnRightImmutable && !Config.compactLayout
checked: NeoChatConfig.showLocalMessagesOnRight
enabled: !NeoChatConfig.isShowLocalMessagesOnRightImmutable && !NeoChatConfig.compactLayout
onToggled: {
Config.showLocalMessagesOnRight = checked;
Config.save();
NeoChatConfig.showLocalMessagesOnRight = checked;
NeoChatConfig.save();
}
}
@@ -304,10 +304,10 @@ FormCard.FormCardPage {
FormCard.FormCheckDelegate {
id: showLinkPreviewDelegate
text: i18n("Show links preview in the chat messages")
checked: Config.showLinkPreview
checked: NeoChatConfig.showLinkPreview
onToggled: {
Config.showLinkPreview = checked;
Config.save();
NeoChatConfig.showLinkPreview = checked;
NeoChatConfig.save();
}
}
}
@@ -318,21 +318,21 @@ FormCard.FormCardPage {
FormCard.FormCard {
FormCard.FormCheckDelegate {
text: i18n("In chat")
checked: Config.showAvatarInTimeline
checked: NeoChatConfig.showAvatarInTimeline
onToggled: {
Config.showAvatarInTimeline = checked;
Config.save();
NeoChatConfig.showAvatarInTimeline = checked;
NeoChatConfig.save();
}
enabled: !Config.isShowAvatarInTimelineImmutable
enabled: !NeoChatConfig.isShowAvatarInTimelineImmutable
}
FormCard.FormCheckDelegate {
text: i18n("In sidebar")
checked: Config.showAvatarInRoomDrawer
enabled: !Config.isShowAvatarInRoomDrawerImmutable
checked: NeoChatConfig.showAvatarInRoomDrawer
enabled: !NeoChatConfig.isShowAvatarInRoomDrawerImmutable
onToggled: {
Config.showAvatarInRoomDrawer = checked;
Config.save();
NeoChatConfig.showAvatarInRoomDrawer = checked;
NeoChatConfig.save();
}
}
}

View File

@@ -15,10 +15,10 @@ FormCard.FormComboBoxDelegate {
textRole: "display"
valueRole: "display"
model: ColorSchemer.model
Component.onCompleted: currentIndex = ColorSchemer.indexForScheme(Config.colorScheme)
Component.onCompleted: currentIndex = ColorSchemer.indexForScheme(NeoChatConfig.colorScheme)
onCurrentValueChanged: {
ColorSchemer.apply(currentIndex);
Config.colorScheme = ColorSchemer.nameForIndex(currentIndex);
Config.save();
NeoChatConfig.colorScheme = ColorSchemer.nameForIndex(currentIndex);
NeoChatConfig.save();
}
}

View File

@@ -99,7 +99,7 @@ FormCard.AbstractFormDelegate {
}
QQC2.ToolButton {
display: QQC2.AbstractButton.IconOnly
visible: root.showVerifyButton && (root.type !== DevicesModel.Verified || Config.alwaysVerifyDevice)
visible: root.showVerifyButton && (root.type !== DevicesModel.Verified || NeoChatConfig.alwaysVerifyDevice)
action: Kirigami.Action {
id: verifyDeviceAction
text: i18n("Verify device")

View File

@@ -27,12 +27,12 @@ FormCard.FormCardPage {
FormCard.FormCheckDelegate {
id: closeDelegate
text: i18n("Show in System Tray")
checked: Config.systemTray
checked: NeoChatConfig.systemTray
visible: Controller.supportSystemTray
enabled: !Config.isSystemTrayImmutable
enabled: !NeoChatConfig.isSystemTrayImmutable
onToggled: {
Config.systemTray = checked;
Config.save();
NeoChatConfig.systemTray = checked;
NeoChatConfig.save();
}
}
@@ -44,12 +44,12 @@ FormCard.FormCardPage {
FormCard.FormCheckDelegate {
id: minimizeDelegate
text: i18n("Minimize to system tray on startup")
checked: Config.minimizeToSystemTrayOnStartup
checked: NeoChatConfig.minimizeToSystemTrayOnStartup
visible: Controller.supportSystemTray && !Kirigami.Settings.isMobile
enabled: Config.systemTray && !Config.isMinimizeToSystemTrayOnStartupImmutable
enabled: NeoChatConfig.systemTray && !NeoChatConfig.isMinimizeToSystemTrayOnStartupImmutable
onToggled: {
Config.minimizeToSystemTrayOnStartup = checked;
Config.save();
NeoChatConfig.minimizeToSystemTrayOnStartup = checked;
NeoChatConfig.save();
}
}
@@ -61,12 +61,12 @@ FormCard.FormCardPage {
FormCard.FormCheckDelegate {
id: automaticallyDelegate
text: i18n("Automatically hide/unhide the room information when resizing the window")
checked: Config.autoRoomInfoDrawer
enabled: !Config.isAutoRoomInfoDrawerImmutable
checked: NeoChatConfig.autoRoomInfoDrawer
enabled: !NeoChatConfig.isAutoRoomInfoDrawerImmutable
visible: Qt.platform.os !== "android"
onToggled: {
Config.autoRoomInfoDrawer = checked;
Config.save();
NeoChatConfig.autoRoomInfoDrawer = checked;
NeoChatConfig.save();
}
}
@@ -77,11 +77,11 @@ FormCard.FormCardPage {
FormCard.FormCheckDelegate {
id: categorizeDelegate
text: i18n("Show all rooms in \"Home\" tab")
checked: Config.allRoomsInHome
enabled: !Config.isAllRoomsInHomeImmutable
checked: NeoChatConfig.allRoomsInHome
enabled: !NeoChatConfig.isAllRoomsInHomeImmutable
onToggled: {
Config.allRoomsInHome = checked;
Config.save();
NeoChatConfig.allRoomsInHome = checked;
NeoChatConfig.save();
}
}
@@ -92,20 +92,20 @@ FormCard.FormCardPage {
FormCard.FormCard {
FormCard.FormRadioDelegate {
text: i18nc("As in 'sort something based on last activity'", "Activity")
checked: Config.sortOrder === 1
enabled: !Config.isSortOrderImmutable
checked: NeoChatConfig.sortOrder === 1
enabled: !NeoChatConfig.isSortOrderImmutable
onToggled: {
Config.sortOrder = 1
Config.save()
NeoChatConfig.sortOrder = 1
NeoChatConfig.save()
}
}
FormCard.FormRadioDelegate {
text: i18nc("As in 'sort something alphabetically'", "Alphabetical")
checked: Config.sortOrder === 0
enabled: !Config.isSortOrderImmutable
checked: NeoChatConfig.sortOrder === 0
enabled: !NeoChatConfig.isSortOrderImmutable
onToggled: {
Config.sortOrder = 0
Config.save()
NeoChatConfig.sortOrder = 0
NeoChatConfig.save()
}
}
}
@@ -116,11 +116,11 @@ FormCard.FormCardPage {
FormCard.FormCheckDelegate {
id: showDeletedMessages
text: i18n("Show deleted messages")
checked: Config.showDeletedMessages
enabled: !Config.isShowDeletedMessagesImmutable
checked: NeoChatConfig.showDeletedMessages
enabled: !NeoChatConfig.isShowDeletedMessagesImmutable
onToggled: {
Config.showDeletedMessages = checked;
Config.save();
NeoChatConfig.showDeletedMessages = checked;
NeoChatConfig.save();
}
}
@@ -132,65 +132,65 @@ FormCard.FormCardPage {
FormCard.FormCheckDelegate {
id: showStateEvents
text: i18n("Show state events")
checked: Config.showStateEvent
enabled: !Config.isShowStateEventImmutable
checked: NeoChatConfig.showStateEvent
enabled: !NeoChatConfig.isShowStateEventImmutable
onToggled: {
Config.showStateEvent = checked;
Config.save();
NeoChatConfig.showStateEvent = checked;
NeoChatConfig.save();
}
}
FormCard.FormDelegateSeparator {
visible: Config.showStateEvent
visible: NeoChatConfig.showStateEvent
above: showStateEvents
below: showLeaveJoinEventDelegate
}
FormCard.FormCheckDelegate {
id: showLeaveJoinEventDelegate
visible: Config.showStateEvent
visible: NeoChatConfig.showStateEvent
text: i18n("Show leave and join events")
checked: Config.showLeaveJoinEvent
enabled: !Config.isShowLeaveJoinEventImmutable
checked: NeoChatConfig.showLeaveJoinEvent
enabled: !NeoChatConfig.isShowLeaveJoinEventImmutable
onToggled: {
Config.showLeaveJoinEvent = checked;
Config.save();
NeoChatConfig.showLeaveJoinEvent = checked;
NeoChatConfig.save();
}
}
FormCard.FormDelegateSeparator {
visible: Config.showStateEvent
visible: NeoChatConfig.showStateEvent
above: showLeaveJoinEventDelegate
below: showNameDelegate
}
FormCard.FormCheckDelegate {
id: showNameDelegate
visible: Config.showStateEvent
visible: NeoChatConfig.showStateEvent
text: i18n("Show name change events")
checked: Config.showRename
enabled: !Config.isShowRenameImmutable
checked: NeoChatConfig.showRename
enabled: !NeoChatConfig.isShowRenameImmutable
onToggled: {
Config.showRename = checked;
Config.save();
NeoChatConfig.showRename = checked;
NeoChatConfig.save();
}
}
FormCard.FormDelegateSeparator {
visible: Config.showStateEvent
visible: NeoChatConfig.showStateEvent
above: showNameDelegate
below: showAvatarChangeDelegate
}
FormCard.FormCheckDelegate {
id: showAvatarChangeDelegate
visible: Config.showStateEvent
visible: NeoChatConfig.showStateEvent
text: i18n("Show avatar update events")
checked: Config.showAvatarUpdate
enabled: !Config.isShowAvatarUpdateImmutable
checked: NeoChatConfig.showAvatarUpdate
enabled: !NeoChatConfig.isShowAvatarUpdateImmutable
onToggled: {
Config.showAvatarUpdate = checked;
Config.save();
NeoChatConfig.showAvatarUpdate = checked;
NeoChatConfig.save();
}
}
}
@@ -201,11 +201,11 @@ FormCard.FormCardPage {
FormCard.FormCheckDelegate {
id: quickEditCheckbox
text: i18n("Use s/text/replacement syntax to edit your last message")
checked: Config.allowQuickEdit
enabled: !Config.isAllowQuickEditImmutable
checked: NeoChatConfig.allowQuickEdit
enabled: !NeoChatConfig.isAllowQuickEditImmutable
onToggled: {
Config.allowQuickEdit = checked;
Config.save();
NeoChatConfig.allowQuickEdit = checked;
NeoChatConfig.save();
}
}
FormCard.FormDelegateSeparator {
@@ -215,11 +215,11 @@ FormCard.FormCardPage {
FormCard.FormCheckDelegate {
id: typingNotificationsDelegate
text: i18n("Send typing notifications")
checked: Config.typingNotifications
enabled: !Config.isTypingNotificationsImmutable
checked: NeoChatConfig.typingNotifications
enabled: !NeoChatConfig.isTypingNotificationsImmutable
onToggled: {
Config.typingNotifications = checked;
Config.save();
NeoChatConfig.typingNotifications = checked;
NeoChatConfig.save();
}
}
}
@@ -229,15 +229,15 @@ FormCard.FormCardPage {
FormCard.FormCard {
FormCard.FormCheckDelegate {
text: i18n("Enable developer tools")
checked: Config.developerTools
enabled: !Config.isDeveloperToolsImmutable
checked: NeoChatConfig.developerTools
enabled: !NeoChatConfig.isDeveloperToolsImmutable
onToggled: {
Config.developerTools = checked;
Config.save();
NeoChatConfig.developerTools = checked;
NeoChatConfig.save();
}
}
FormCard.FormButtonDelegate {
visible: Config.developerTools
visible: NeoChatConfig.developerTools
text: i18n("Open developer tools")
onClicked: root.QQC2.ApplicationWindow.window.pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat.devtools', 'DevtoolsPage'), {
connection: root.connection

View File

@@ -24,7 +24,7 @@ FormCard.FormCardPage {
FormCard.FormRadioDelegate {
text: i18n("System Default")
checked: currentType === 0
enabled: !Config.isProxyTypeImmutable
enabled: !NeoChatConfig.isProxyTypeImmutable
onToggled: {
currentType = 0;
}
@@ -32,7 +32,7 @@ FormCard.FormCardPage {
FormCard.FormRadioDelegate {
text: i18n("No Proxy")
checked: currentType === 3
enabled: !Config.isProxyTypeImmutable
enabled: !NeoChatConfig.isProxyTypeImmutable
onToggled: {
currentType = 3;
}
@@ -40,7 +40,7 @@ FormCard.FormCardPage {
FormCard.FormRadioDelegate {
text: i18n("HTTP")
checked: currentType === 1
enabled: !Config.isProxyTypeImmutable
enabled: !NeoChatConfig.isProxyTypeImmutable
onToggled: {
currentType = 1;
}
@@ -48,7 +48,7 @@ FormCard.FormCardPage {
FormCard.FormRadioDelegate {
text: i18n("Socks5")
checked: currentType === 2
enabled: !Config.isProxyTypeImmutable
enabled: !NeoChatConfig.isProxyTypeImmutable
onToggled: {
currentType = 2;
}
@@ -62,7 +62,7 @@ FormCard.FormCardPage {
FormCard.FormTextFieldDelegate {
id: hostField
label: i18n("Host")
text: Config.proxyHost
text: NeoChatConfig.proxyHost
inputMethodHints: Qt.ImhUrlCharactersOnly
onEditingFinished: {
proxyConfigChanged = true;
@@ -71,7 +71,7 @@ FormCard.FormCardPage {
FormCard.FormSpinBoxDelegate {
id: portField
label: i18n("Port")
value: Config.proxyPort
value: NeoChatConfig.proxyPort
from: 0
to: 65536
textFromValue: function (value, locale) {
@@ -84,7 +84,7 @@ FormCard.FormCardPage {
FormCard.FormTextFieldDelegate {
id: userField
label: i18n("User")
text: Config.proxyUser
text: NeoChatConfig.proxyUser
inputMethodHints: Qt.ImhUrlCharactersOnly
onEditingFinished: {
proxyConfigChanged = true;
@@ -93,7 +93,7 @@ FormCard.FormCardPage {
FormCard.FormTextFieldDelegate {
id: passwordField
label: i18n("Password")
text: Config.proxyPassword
text: NeoChatConfig.proxyPassword
echoMode: TextInput.Password
inputMethodHints: Qt.ImhUrlCharactersOnly
onEditingFinished: {
@@ -111,14 +111,14 @@ FormCard.FormCardPage {
QQC2.Button {
text: i18n("Apply")
enabled: currentType !== Config.proxyType || proxyConfigChanged
enabled: currentType !== NeoChatConfig.proxyType || proxyConfigChanged
onClicked: {
Config.proxyType = currentType;
Config.proxyHost = hostField.text;
Config.proxyPort = portField.value;
Config.proxyUser = userField.text;
Config.proxyPassword = passwordField.text;
Config.save();
NeoChatConfig.proxyType = currentType;
NeoChatConfig.proxyHost = hostField.text;
NeoChatConfig.proxyPort = portField.value;
NeoChatConfig.proxyUser = userField.text;
NeoChatConfig.proxyPassword = passwordField.text;
NeoChatConfig.save();
proxyConfigChanged = false;
ProxyController.setApplicationProxy();
}
@@ -127,6 +127,6 @@ FormCard.FormCardPage {
}
Component.onCompleted: {
currentType = Config.proxyType;
currentType = NeoChatConfig.proxyType;
}
}