fix(@refactoring/base_01): button `I have a Keycard` displayed when it's not enabled

This commit is contained in:
Sale Djenic 2021-11-02 09:26:48 +01:00 committed by Iuri Matias
parent cdecd82e3f
commit f788242c95
4 changed files with 30 additions and 21 deletions

View File

@ -24,8 +24,6 @@ const LSS_KEY_EXPAND_USERS_LIST* = "expandUsersList"
const DEFAULT_EXPAND_USERS_LIST = false const DEFAULT_EXPAND_USERS_LIST = false
const LSS_KEY_IS_GIF_WIDGET_ENABLED* = "isGifWidgetEnabled" const LSS_KEY_IS_GIF_WIDGET_ENABLED* = "isGifWidgetEnabled"
const DEFAULT_IS_GIF_WIDGET_ENABLED = false const DEFAULT_IS_GIF_WIDGET_ENABLED = false
const LSS_KEY_IS_KEYCARD_ENABLED* = "isKeycardEnabled"
const DEFAULT_IS_KEYCARD_ENABLED = false
const LSS_KEY_IS_TENOR_WARNING_ACCEPTED* = "isTenorWarningAccepted" const LSS_KEY_IS_TENOR_WARNING_ACCEPTED* = "isTenorWarningAccepted"
const DEFAULT_IS_TENOR_WARNING_ACCEPTED = false const DEFAULT_IS_TENOR_WARNING_ACCEPTED = false
const LSS_KEY_DISPLAY_CHAT_IMAGES* = "displayChatImages" const LSS_KEY_DISPLAY_CHAT_IMAGES* = "displayChatImages"
@ -320,19 +318,6 @@ QtObject:
notify = isGifWidgetEnabledChanged notify = isGifWidgetEnabledChanged
proc isKeycardEnabledChanged*(self: LocalAccountSensitiveSettings) {.signal.}
proc getIsKeycardEnabled*(self: LocalAccountSensitiveSettings): bool {.slot.} =
getSettingsProp[bool](self, LSS_KEY_IS_KEYCARD_ENABLED, newQVariant(DEFAULT_IS_KEYCARD_ENABLED))
proc setIsKeycardEnabled*(self: LocalAccountSensitiveSettings, value: bool) {.slot.} =
setSettingsProp(self, LSS_KEY_IS_KEYCARD_ENABLED, newQVariant(value)):
self.isKeycardEnabledChanged()
QtProperty[bool] isKeycardEnabled:
read = getIsKeycardEnabled
write = setIsKeycardEnabled
notify = isKeycardEnabledChanged
proc isTenorWarningAcceptedChanged*(self: LocalAccountSensitiveSettings) {.signal.} proc isTenorWarningAcceptedChanged*(self: LocalAccountSensitiveSettings) {.signal.}
proc getIsTenorWarningAccepted*(self: LocalAccountSensitiveSettings): bool {.slot.} = proc getIsTenorWarningAccepted*(self: LocalAccountSensitiveSettings): bool {.slot.} =
getSettingsProp[bool](self, LSS_KEY_IS_TENOR_WARNING_ACCEPTED, newQVariant(DEFAULT_IS_TENOR_WARNING_ACCEPTED)) getSettingsProp[bool](self, LSS_KEY_IS_TENOR_WARNING_ACCEPTED, newQVariant(DEFAULT_IS_TENOR_WARNING_ACCEPTED))
@ -896,7 +881,6 @@ QtObject:
of LSS_KEY_SHOW_ONLINE_USERS: self.showOnlineUsersChanged() of LSS_KEY_SHOW_ONLINE_USERS: self.showOnlineUsersChanged()
of LSS_KEY_EXPAND_USERS_LIST: self.expandUsersListChanged() of LSS_KEY_EXPAND_USERS_LIST: self.expandUsersListChanged()
of LSS_KEY_IS_GIF_WIDGET_ENABLED: self.isGifWidgetEnabledChanged() of LSS_KEY_IS_GIF_WIDGET_ENABLED: self.isGifWidgetEnabledChanged()
of LSS_KEY_IS_KEYCARD_ENABLED: self.isKeycardEnabledChanged()
of LSS_KEY_IS_TENOR_WARNING_ACCEPTED: self.isTenorWarningAcceptedChanged() of LSS_KEY_IS_TENOR_WARNING_ACCEPTED: self.isTenorWarningAcceptedChanged()
of LSS_KEY_DISPLAY_CHAT_IMAGES: self.displayChatImagesChanged() of LSS_KEY_DISPLAY_CHAT_IMAGES: self.displayChatImagesChanged()
of LSS_KEY_USE_COMPACT_MODE: self.useCompactModeChanged() of LSS_KEY_USE_COMPACT_MODE: self.useCompactModeChanged()

View File

@ -4,6 +4,9 @@ import ../../constants
# Local Account Settings keys: # Local Account Settings keys:
const LS_KEY_STORE_TO_KEYCHAIN* = "storeToKeychain" const LS_KEY_STORE_TO_KEYCHAIN* = "storeToKeychain"
const DEFAULT_STORE_TO_KEYCHAIN = "notNow"
const LS_KEY_IS_KEYCARD_ENABLED* = "isKeycardEnabled"
const DEFAULT_IS_KEYCARD_ENABLED = false
# Local Account Settings values: # Local Account Settings values:
const LS_VALUE_STORE* = "store" const LS_VALUE_STORE* = "store"
const LS_VALUE_NOTNOW* = "notNow" const LS_VALUE_NOTNOW* = "notNow"
@ -37,6 +40,7 @@ QtObject:
self.settings = newQSettings(filePath, QSettingsFormat.IniFormat) self.settings = newQSettings(filePath, QSettingsFormat.IniFormat)
proc storeToKeychainValueChanged*(self: LocalAccountSettings) {.signal.} proc storeToKeychainValueChanged*(self: LocalAccountSettings) {.signal.}
proc isKeycardEnabledChanged*(self: LocalAccountSettings) {.signal.}
proc removeKey*(self: LocalAccountSettings, key: string) = proc removeKey*(self: LocalAccountSettings, key: string) =
if(self.settings.isNil): if(self.settings.isNil):
@ -46,10 +50,12 @@ QtObject:
if(key == LS_KEY_STORE_TO_KEYCHAIN): if(key == LS_KEY_STORE_TO_KEYCHAIN):
self.storeToKeychainValueChanged() self.storeToKeychainValueChanged()
elif(key == LS_KEY_IS_KEYCARD_ENABLED):
self.isKeycardEnabledChanged()
proc getStoreToKeychainValue*(self: LocalAccountSettings): string {.slot.} = proc getStoreToKeychainValue*(self: LocalAccountSettings): string {.slot.} =
if(self.settings.isNil): if(self.settings.isNil):
return "" return DEFAULT_STORE_TO_KEYCHAIN
self.settings.value(LS_KEY_STORE_TO_KEYCHAIN).stringVal self.settings.value(LS_KEY_STORE_TO_KEYCHAIN).stringVal
@ -63,4 +69,23 @@ QtObject:
QtProperty[string] storeToKeychainValue: QtProperty[string] storeToKeychainValue:
read = getStoreToKeychainValue read = getStoreToKeychainValue
write = setStoreToKeychainValue write = setStoreToKeychainValue
notify = storeToKeychainValueChanged notify = storeToKeychainValueChanged
proc getIsKeycardEnabled*(self: LocalAccountSettings): bool {.slot.} =
if(self.settings.isNil):
return DEFAULT_IS_KEYCARD_ENABLED
self.settings.value(LS_KEY_IS_KEYCARD_ENABLED).boolVal
proc setIsKeycardEnabled*(self: LocalAccountSettings, value: bool) {.slot.} =
if(self.settings.isNil):
return
self.settings.setValue(LS_KEY_IS_KEYCARD_ENABLED, newQVariant(value))
self.isKeycardEnabledChanged()
QtProperty[bool] isKeycardEnabled:
read = getIsKeycardEnabled
write = setIsKeycardEnabled
notify = isKeycardEnabledChanged

View File

@ -109,7 +109,7 @@ Page {
anchors.top: btnExistingKey.bottom anchors.top: btnExistingKey.bottom
anchors.topMargin: Style.current.padding anchors.topMargin: Style.current.padding
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
visible: isExperimental === "1" || localAccountSensitiveSettings.isKeycardEnabled visible: isExperimental === "1" || localAccountSettings.isKeycardEnabled
} }
} }
} }

View File

@ -227,9 +227,9 @@ ScrollView {
//% "Keycard" //% "Keycard"
text: qsTr("Keycard") text: qsTr("Keycard")
isSwitch: true isSwitch: true
switchChecked: localAccountSensitiveSettings.isKeycardEnabled switchChecked: localAccountSettings.isKeycardEnabled
onClicked: { onClicked: {
localAccountSensitiveSettings.isKeycardEnabled = !localAccountSensitiveSettings.isKeycardEnabled localAccountSettings.isKeycardEnabled = !localAccountSettings.isKeycardEnabled
} }
} }