GODT-1982: updated gRPC and GUI for disk cache.

Other: modified bridge-gui-tester for new cache related gRPC interface.
Other: bridge-gui-tester has buttons for cache related errors.
This commit is contained in:
Xavier Michelon
2022-10-27 18:59:42 +02:00
committed by James Houlahan
parent 93d9ae32fc
commit d9762010fa
27 changed files with 2662 additions and 3947 deletions

View File

@ -55,7 +55,7 @@ QtObject {
Connections {
target: Backend
function onCacheUnavailable() {
function onDiskCacheUnavailable() {
mainWindow.showAndRise()
}
function onColorSchemeNameChanged(scheme) { root.setColorScheme() }

View File

@ -29,8 +29,12 @@ SettingsView {
fillHeight: false
property var notifications
property bool _diskCacheEnabled: true
property url _diskCachePath: pathDialog.shortcuts.home
property url diskCachePath: pathDialog.shortcuts.home
function refresh() {
diskCacheSetting.description = Backend.nativePath(root.diskCachePath)
submitButton.enabled = !Backend.areSameFileOrFolder(Backend.diskCachePath, root.diskCachePath)
}
Label {
colorScheme: root.colorScheme
@ -49,26 +53,12 @@ SettingsView {
}
SettingsItem {
colorScheme: root.colorScheme
text: qsTr("Enable local cache")
description: qsTr("Recommended for optimal performance.")
type: SettingsItem.Toggle
checked: root._diskCacheEnabled
onClicked: root._diskCacheEnabled = !root._diskCacheEnabled
Layout.fillWidth: true
}
SettingsItem {
id: diskCacheSetting
colorScheme: root.colorScheme
text: qsTr("Current cache location")
actionText: qsTr("Change location")
description: Backend.goos === "windows" ?
root._diskCachePath.toString().replace("file:///", "").replace(new RegExp("/", 'g'), "\\") + "\\" :
root._diskCachePath.toString().replace("file://", "") + "/"
descriptionWrap: Text.WrapAnywhere
type: SettingsItem.Button
enabled: root._diskCacheEnabled
onClicked: {
pathDialog.open()
}
@ -78,8 +68,11 @@ SettingsView {
FolderDialog {
id: pathDialog
title: qsTr("Select cache location")
currentFolder: root._diskCachePath
onAccepted: root._diskCachePath = pathDialog.selectedFolder
currentFolder: root.diskCachePath
onAccepted: {
root.diskCachePath = pathDialog.selectedFolder
root.refresh()
}
}
}
@ -89,11 +82,7 @@ SettingsView {
Button {
id: submitButton
colorScheme: root.colorScheme
text: qsTr("Save and restart")
enabled: (
Backend.diskCachePath != root._diskCachePath ||
Backend.isDiskCacheEnabled != root._diskCacheEnabled
)
text: qsTr("Save")
onClicked: {
root.submit()
}
@ -109,7 +98,7 @@ SettingsView {
Connections {
target: Backend
function onChangeLocalCacheFinished() {
function onDiskCachePathChangeFinished() {
submitButton.loading = false
root.setDefaultValues()
}
@ -120,25 +109,14 @@ SettingsView {
root.setDefaultValues()
}
function submit(){
if (!root._diskCacheEnabled && Backend.isDiskCacheEnabled) {
root.notifications.askDisableLocalCache()
return
}
if (root._diskCacheEnabled && !Backend.isDiskCacheEnabled) {
root.notifications.askEnableLocalCache(root._diskCachePath)
return
}
// Not asking, only changing path
function submit() {
submitButton.loading = true
Backend.changeLocalCache(Backend.isDiskCacheEnabled, root._diskCachePath)
Backend.setDiskCachePath(root.diskCachePath)
}
function setDefaultValues(){
root._diskCacheEnabled = Backend.isDiskCacheEnabled
root._diskCachePath = Backend.diskCachePath
root.diskCachePath = Backend.diskCachePath
root.refresh();
}
onVisibleChanged: {

View File

@ -94,16 +94,6 @@ Item {
notification: root.notifications.enableSplitMode
}
NotificationDialog {
colorScheme: root.colorScheme
notification: root.notifications.disableLocalCache
}
NotificationDialog {
colorScheme: root.colorScheme
notification: root.notifications.enableLocalCache
}
NotificationDialog {
colorScheme: root.colorScheme
notification: root.notifications.resetBridge

View File

@ -29,8 +29,6 @@ QtObject {
signal askEnableBeta()
signal askEnableSplitMode(var user)
signal askDisableLocalCache()
signal askEnableLocalCache(var path)
signal askResetBridge()
signal askChangeAllMailVisibility(var isVisibleNow)
signal askDeleteAccount(var user)
@ -70,8 +68,6 @@ QtObject {
root.diskFull,
root.cacheLocationChangeSuccess,
root.enableSplitMode,
root.disableLocalCache,
root.enableLocalCache,
root.resetBridge,
root.changeAllMailVisibility,
root.deleteAccount,
@ -558,7 +554,7 @@ QtObject {
Connections {
target: Backend
function onCacheUnavailable() {
function onDiskCacheUnavailable() {
root.cacheUnavailable.active = true
}
}
@ -591,7 +587,7 @@ QtObject {
Connections {
target: Backend
function onCacheCantMove() {
function onCantMoveDiskCache() {
root.cacheCantMove.active = true
}
}
@ -622,8 +618,8 @@ QtObject {
Connections {
target: Backend
function onCacheLocationChangeSuccess() {
console.log("notify location changed succesfully")
function onDiskCachePathChanged() {
console.log("notify location changed successfully")
root.cacheLocationChangeSuccess.active = true
}
}
@ -736,99 +732,6 @@ QtObject {
]
}
property Notification disableLocalCache: Notification {
title: qsTr("Disable local cache?")
brief: title
description: qsTr("This action will clear your local cache, including locally stored messages. Bridge will restart.")
icon: "/qml/icons/ic-question-circle.svg"
type: Notification.NotificationType.Warning
group: Notifications.Group.Configuration | Notifications.Group.Dialogs
Connections {
target: root
function onAskDisableLocalCache() {
root.disableLocalCache.active = true
}
}
Connections {
target: Backend
function onChangeLocalCacheFinished() {
root.disableLocalCache.active = false
disableLocalCache_disable.loading = false
disableLocalCache_cancel.enabled = true
}
}
action: [
Action {
id: disableLocalCache_cancel
text: qsTr("Cancel")
onTriggered: {
root.disableLocalCache.active = false
}
},
Action {
id: disableLocalCache_disable
text: qsTr("Disable and restart")
onTriggered: {
disableLocalCache_disable.loading = true
disableLocalCache_cancel.enabled = false
Backend.changeLocalCache(false, Backend.diskCachePath)
}
}
]
}
property Notification enableLocalCache: Notification {
title: qsTr("Enable local cache")
brief: title
description: qsTr("Bridge will restart.")
icon: "/qml/icons/ic-question-circle.svg"
type: Notification.NotificationType.Warning
group: Notifications.Group.Configuration | Notifications.Group.Dialogs
property url path
Connections {
target: root
function onAskEnableLocalCache(path) {
root.enableLocalCache.active = true
root.enableLocalCache.path = path
}
}
Connections {
target: Backend
function onChangeLocalCacheFinished() {
root.enableLocalCache.active = false
enableLocalCache_enable.loading = false
enableLocalCache_cancel.enabled = true
}
}
action: [
Action {
id: enableLocalCache_enable
text: qsTr("Enable and restart")
onTriggered: {
enableLocalCache_enable.loading = true
enableLocalCache_cancel.enabled = false
Backend.changeLocalCache(true, root.enableLocalCache.path)
}
},
Action {
id: enableLocalCache_cancel
text: qsTr("Cancel")
onTriggered: {
root.enableLocalCache.active = false
}
}
]
}
property Notification resetBridge: Notification {
title: qsTr("Reset Bridge?")
brief: title