forked from Silverfish/proton-bridge
GODT-1412: Refactor paths and links
This commit is contained in:
@ -23,6 +23,8 @@ import QtQuick.Controls 2.13
|
|||||||
|
|
||||||
import QtQml.Models 2.12
|
import QtQml.Models 2.12
|
||||||
|
|
||||||
|
import Qt.labs.platform 1.1
|
||||||
|
|
||||||
import Proton 4.0
|
import Proton 4.0
|
||||||
|
|
||||||
import "./BridgeTest"
|
import "./BridgeTest"
|
||||||
@ -630,11 +632,13 @@ Window {
|
|||||||
TextField {
|
TextField {
|
||||||
colorScheme:root.colorScheme
|
colorScheme:root.colorScheme
|
||||||
label: "Path"
|
label: "Path"
|
||||||
text: root.diskCachePath
|
text: root.diskCachePath.toString().replace("file://", "")
|
||||||
implicitWidth: 160
|
implicitWidth: 160
|
||||||
onEditingFinished: root.diskCachePath = this.text
|
onEditingFinished: {
|
||||||
|
root.diskCachePath = Qt.resolvedUrl("file://"+text)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Button {colorScheme: root.colorScheme; text: "Change finished:"; onClicked: root.changeLocalCacheFinished()}
|
Button {colorScheme: root.colorScheme; text: "Change finished"; onClicked: root.changeLocalCacheFinished()}
|
||||||
}
|
}
|
||||||
RowLayout {
|
RowLayout {
|
||||||
Label {colorScheme: root.colorScheme; text: "Reset:"}
|
Label {colorScheme: root.colorScheme; text: "Reset:"}
|
||||||
@ -686,7 +690,8 @@ Window {
|
|||||||
|
|
||||||
|
|
||||||
property bool isDiskCacheEnabled: true
|
property bool isDiskCacheEnabled: true
|
||||||
property string diskCachePath: "/home/bridge"
|
// Qt.resolvedUrl("file:///C:/Users/user/AppData/Roaming/protonmail/bridge/cache/c11/messages")
|
||||||
|
property url diskCachePath: StandardPaths.standardLocations(StandardPaths.HomeLocation)[0]
|
||||||
signal cacheUnavailable()
|
signal cacheUnavailable()
|
||||||
signal cacheCantMove()
|
signal cacheCantMove()
|
||||||
signal cacheLocationChangeSuccess()
|
signal cacheLocationChangeSuccess()
|
||||||
@ -749,10 +754,11 @@ Window {
|
|||||||
}
|
}
|
||||||
signal resetFinished()
|
signal resetFinished()
|
||||||
|
|
||||||
property string logsPath: "/home/cuto" // StandardPaths.locate(StandardPaths.DesktopLocation)
|
|
||||||
property string version: "2.0.X-BridePreview"
|
property string version: "2.0.X-BridePreview"
|
||||||
property string licensePath: "/home/cuto" // StandardPaths.locate(StandardPaths.DesktopLocation)
|
property url logsPath: StandardPaths.standardLocations(StandardPaths.HomeLocation)[0]
|
||||||
property string releaseNotesLink: "https://protonmail.com/download/bridge/early_releases.html"
|
property url licensePath: StandardPaths.standardLocations(StandardPaths.HomeLocation)[0]
|
||||||
|
property url releaseNotesLink: Qt.resolvedUrl("https://protonmail.com/download/bridge/early_releases.html")
|
||||||
|
property url landingPageLink: Qt.resolvedUrl("https://protonmail.com/bridge")
|
||||||
|
|
||||||
property string currentEmailClient: "" // "Apple Mail 14.0"
|
property string currentEmailClient: "" // "Apple Mail 14.0"
|
||||||
function updateCurrentMailClient(){
|
function updateCurrentMailClient(){
|
||||||
|
|||||||
@ -122,7 +122,7 @@ SettingsView {
|
|||||||
text: qsTr("View logs")
|
text: qsTr("View logs")
|
||||||
secondary: true
|
secondary: true
|
||||||
colorScheme: root.colorScheme
|
colorScheme: root.colorScheme
|
||||||
onClicked: Qt.openUrlExternally("file://"+root.backend.logsPath)
|
onClicked: Qt.openUrlExternally(root.backend.logsPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -70,7 +70,7 @@ SettingsView {
|
|||||||
actionText: qsTr("View logs")
|
actionText: qsTr("View logs")
|
||||||
description: qsTr("Open and review logs to troubleshoot.")
|
description: qsTr("Open and review logs to troubleshoot.")
|
||||||
type: SettingsItem.Button
|
type: SettingsItem.Button
|
||||||
onClicked: {Qt.openUrlExternally("file://"+root.backend.logsPath)}
|
onClicked: Qt.openUrlExternally(root.backend.logsPath)
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ SettingsView {
|
|||||||
|
|
||||||
text: qsTr("Proton Mail Bridge v%1<br>© 2021 Proton AG<br>%2 %3").
|
text: qsTr("Proton Mail Bridge v%1<br>© 2021 Proton AG<br>%2 %3").
|
||||||
arg(root.backend.version).
|
arg(root.backend.version).
|
||||||
arg(link("file://"+root.backend.licensePath, qsTr("License"))).
|
arg(link(root.backend.licensePath, qsTr("License"))).
|
||||||
arg(link(root.backend.releaseNotesLink, qsTr("Release notes")))
|
arg(link(root.backend.releaseNotesLink, qsTr("Release notes")))
|
||||||
|
|
||||||
onLinkActivated: Qt.openUrlExternally(link)
|
onLinkActivated: Qt.openUrlExternally(link)
|
||||||
|
|||||||
@ -30,7 +30,7 @@ SettingsView {
|
|||||||
|
|
||||||
property var notifications
|
property var notifications
|
||||||
property bool _diskCacheEnabled: true
|
property bool _diskCacheEnabled: true
|
||||||
property string _diskCachePath: "/home"
|
property url _diskCachePath: pathDialog.shortcuts.home
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
colorScheme: root.colorScheme
|
colorScheme: root.colorScheme
|
||||||
@ -64,7 +64,10 @@ SettingsView {
|
|||||||
colorScheme: root.colorScheme
|
colorScheme: root.colorScheme
|
||||||
text: qsTr("Current cache location")
|
text: qsTr("Current cache location")
|
||||||
actionText: qsTr("Change location")
|
actionText: qsTr("Change location")
|
||||||
description: root._diskCachePath
|
description: root.backend.goos === "windows" ?
|
||||||
|
root._diskCachePath.toString().replace("file:///", "").replace(new RegExp("/", 'g'), "\\") + "\\" :
|
||||||
|
root._diskCachePath.toString().replace("file://", "") + "/"
|
||||||
|
descriptionWrap: Text.WrapAnywhere
|
||||||
type: SettingsItem.Button
|
type: SettingsItem.Button
|
||||||
enabled: root._diskCacheEnabled
|
enabled: root._diskCacheEnabled
|
||||||
onClicked: {
|
onClicked: {
|
||||||
@ -76,8 +79,8 @@ SettingsView {
|
|||||||
FileDialog {
|
FileDialog {
|
||||||
id: pathDialog
|
id: pathDialog
|
||||||
title: qsTr("Select cache location")
|
title: qsTr("Select cache location")
|
||||||
folder: shortcuts.home
|
folder: root._diskCachePath
|
||||||
onAccepted: root.sanitizePath(pathDialog.fileUrl.toString())
|
onAccepted: root._diskCachePath = pathDialog.fileUrl
|
||||||
selectFolder: true
|
selectFolder: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,7 +123,6 @@ SettingsView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function submit(){
|
function submit(){
|
||||||
console.log("submit")
|
|
||||||
if (!root._diskCacheEnabled && root.backend.isDiskCacheEnabled) {
|
if (!root._diskCacheEnabled && root.backend.isDiskCacheEnabled) {
|
||||||
root.notifications.askDisableLocalCache()
|
root.notifications.askDisableLocalCache()
|
||||||
return
|
return
|
||||||
@ -141,12 +143,6 @@ SettingsView {
|
|||||||
root._diskCachePath = root.backend.diskCachePath
|
root._diskCachePath = root.backend.diskCachePath
|
||||||
}
|
}
|
||||||
|
|
||||||
function sanitizePath(path) {
|
|
||||||
var pattern = "file://"
|
|
||||||
if (root.backend.goos=="windows") pattern+="/"
|
|
||||||
root._diskCachePath = path.replace(pattern, "")
|
|
||||||
}
|
|
||||||
|
|
||||||
onVisibleChanged: {
|
onVisibleChanged: {
|
||||||
root.setDefaultValues()
|
root.setDefaultValues()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -689,7 +689,7 @@ QtObject {
|
|||||||
type: Notification.NotificationType.Warning
|
type: Notification.NotificationType.Warning
|
||||||
group: Notifications.Group.Configuration | Notifications.Group.Dialogs
|
group: Notifications.Group.Configuration | Notifications.Group.Dialogs
|
||||||
|
|
||||||
property var path
|
property url path
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: root
|
target: root
|
||||||
|
|||||||
@ -29,6 +29,7 @@ Item {
|
|||||||
property string actionText: "Action"
|
property string actionText: "Action"
|
||||||
property string actionIcon: ""
|
property string actionIcon: ""
|
||||||
property string description: "Lorem ipsum dolor sit amet"
|
property string description: "Lorem ipsum dolor sit amet"
|
||||||
|
property alias descriptionWrap: descriptionLabel.wrapMode
|
||||||
property var type: SettingsItem.ActionType.Toggle
|
property var type: SettingsItem.ActionType.Toggle
|
||||||
|
|
||||||
property bool checked: true
|
property bool checked: true
|
||||||
@ -67,6 +68,7 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
|
id: descriptionLabel
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
|||||||
@ -141,8 +141,8 @@ func (f *FrontendQt) NotifyManualUpdate(version updater.VersionInfo, canInstall
|
|||||||
|
|
||||||
func (f *FrontendQt) SetVersion(version updater.VersionInfo) {
|
func (f *FrontendQt) SetVersion(version updater.VersionInfo) {
|
||||||
f.newVersionInfo = version
|
f.newVersionInfo = version
|
||||||
f.qml.SetReleaseNotesLink(version.ReleaseNotesPage)
|
f.qml.SetReleaseNotesLink(core.NewQUrl3(version.ReleaseNotesPage, core.QUrl__TolerantMode))
|
||||||
f.qml.SetLandingPageLink(version.LandingPage)
|
f.qml.SetLandingPageLink(core.NewQUrl3(version.LandingPage, core.QUrl__TolerantMode))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FrontendQt) NotifySilentUpdateInstalled() {
|
func (f *FrontendQt) NotifySilentUpdateInstalled() {
|
||||||
|
|||||||
@ -15,11 +15,14 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with ProtonMail Bridge. If not, see <https://www.gnu.org/licenses/>.
|
// along with ProtonMail Bridge. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//go:build build_qt
|
||||||
// +build build_qt
|
// +build build_qt
|
||||||
|
|
||||||
package qt
|
package qt
|
||||||
|
|
||||||
import "github.com/therecipe/qt/core"
|
import (
|
||||||
|
"github.com/therecipe/qt/core"
|
||||||
|
)
|
||||||
|
|
||||||
func (f *FrontendQt) setVersion() {
|
func (f *FrontendQt) setVersion() {
|
||||||
f.qml.SetVersion(f.programVersion)
|
f.qml.SetVersion(f.programVersion)
|
||||||
@ -31,11 +34,12 @@ func (f *FrontendQt) setLogsPath() {
|
|||||||
f.log.WithError(err).Error("Cannot update path folder")
|
f.log.WithError(err).Error("Cannot update path folder")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
f.qml.SetLogsPath(path)
|
|
||||||
|
f.qml.SetLogsPath(core.QUrl_FromLocalFile(path))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FrontendQt) setLicensePath() {
|
func (f *FrontendQt) setLicensePath() {
|
||||||
f.qml.SetLicensePath(f.locations.GetLicenseFilePath())
|
f.qml.SetLicensePath(core.QUrl_FromLocalFile(f.locations.GetLicenseFilePath()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FrontendQt) setCurrentEmailClient() {
|
func (f *FrontendQt) setCurrentEmailClient() {
|
||||||
|
|||||||
@ -21,12 +21,14 @@
|
|||||||
package qt
|
package qt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ProtonMail/proton-bridge/internal/config/settings"
|
"github.com/ProtonMail/proton-bridge/internal/config/settings"
|
||||||
"github.com/ProtonMail/proton-bridge/internal/frontend/clientconfig"
|
"github.com/ProtonMail/proton-bridge/internal/frontend/clientconfig"
|
||||||
"github.com/ProtonMail/proton-bridge/pkg/keychain"
|
"github.com/ProtonMail/proton-bridge/pkg/keychain"
|
||||||
"github.com/ProtonMail/proton-bridge/pkg/ports"
|
"github.com/ProtonMail/proton-bridge/pkg/ports"
|
||||||
|
"github.com/therecipe/qt/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (f *FrontendQt) setIsDiskCacheEnabled() {
|
func (f *FrontendQt) setIsDiskCacheEnabled() {
|
||||||
@ -34,10 +36,10 @@ func (f *FrontendQt) setIsDiskCacheEnabled() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *FrontendQt) setDiskCachePath() {
|
func (f *FrontendQt) setDiskCachePath() {
|
||||||
f.qml.SetDiskCachePath(f.settings.Get(settings.CacheLocationKey))
|
f.qml.SetDiskCachePath(core.QUrl_FromLocalFile(f.settings.Get(settings.CacheLocationKey)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FrontendQt) changeLocalCache(enableDiskCache bool, diskCachePath string) {
|
func (f *FrontendQt) changeLocalCache(enableDiskCache bool, diskCachePath *core.QUrl) {
|
||||||
defer f.qml.ChangeLocalCacheFinished()
|
defer f.qml.ChangeLocalCacheFinished()
|
||||||
defer f.setIsDiskCacheEnabled()
|
defer f.setIsDiskCacheEnabled()
|
||||||
defer f.setDiskCachePath()
|
defer f.setDiskCachePath()
|
||||||
@ -54,18 +56,23 @@ func (f *FrontendQt) changeLocalCache(enableDiskCache bool, diskCachePath string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_diskCachePath := diskCachePath.Path(core.QUrl__FullyDecoded)
|
||||||
|
if (runtime.GOOS == "windows") && (_diskCachePath[0] == '/') {
|
||||||
|
_diskCachePath = _diskCachePath[1:]
|
||||||
|
}
|
||||||
|
|
||||||
// If disk cache not enabled, or path not changed then no need to change location
|
// If disk cache not enabled, or path not changed then no need to change location
|
||||||
if !enableDiskCache || diskCachePath == f.settings.Get(settings.CacheLocationKey) {
|
if !enableDiskCache || _diskCachePath == f.settings.Get(settings.CacheLocationKey) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := f.bridge.MigrateCache(f.settings.Get(settings.CacheLocationKey), diskCachePath); err != nil {
|
if err := f.bridge.MigrateCache(f.settings.Get(settings.CacheLocationKey), _diskCachePath); err != nil {
|
||||||
f.log.WithError(err).Error("The local cache location could not be changed.")
|
f.log.WithError(err).Error("The local cache location could not be changed.")
|
||||||
f.qml.CacheCantMove()
|
f.qml.CacheCantMove()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
f.settings.Set(settings.CacheLocationKey, diskCachePath)
|
f.settings.Set(settings.CacheLocationKey, _diskCachePath)
|
||||||
f.qml.CacheLocationChangeSuccess()
|
f.qml.CacheLocationChangeSuccess()
|
||||||
f.restart()
|
f.restart()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,14 +80,14 @@ type QMLBackend struct {
|
|||||||
_ func() `slot:"checkUpdates"`
|
_ func() `slot:"checkUpdates"`
|
||||||
_ func() `signal:"checkUpdatesFinished"`
|
_ func() `signal:"checkUpdatesFinished"`
|
||||||
|
|
||||||
_ bool `property:"isDiskCacheEnabled"`
|
_ bool `property:"isDiskCacheEnabled"`
|
||||||
_ string `property:"diskCachePath"`
|
_ core.QUrl `property:"diskCachePath"`
|
||||||
_ func() `signal:"cacheUnavailable"`
|
_ func() `signal:"cacheUnavailable"`
|
||||||
_ func() `signal:"cacheCantMove"`
|
_ func() `signal:"cacheCantMove"`
|
||||||
_ func() `signal:"cacheLocationChangeSuccess"`
|
_ func() `signal:"cacheLocationChangeSuccess"`
|
||||||
_ func() `signal:"diskFull"`
|
_ func() `signal:"diskFull"`
|
||||||
_ func(enableDiskCache bool, diskCachePath string) `slot:"changeLocalCache"`
|
_ func(enableDiskCache bool, diskCachePath core.QUrl) `slot:"changeLocalCache"`
|
||||||
_ func() `signal:"changeLocalCacheFinished"`
|
_ func() `signal:"changeLocalCacheFinished"`
|
||||||
|
|
||||||
_ bool `property:"isAutomaticUpdateOn"`
|
_ bool `property:"isAutomaticUpdateOn"`
|
||||||
_ func(makeItActive bool) `slot:"toggleAutomaticUpdate"`
|
_ func(makeItActive bool) `slot:"toggleAutomaticUpdate"`
|
||||||
@ -118,11 +118,11 @@ type QMLBackend struct {
|
|||||||
_ func() `slot:"triggerReset"`
|
_ func() `slot:"triggerReset"`
|
||||||
_ func() `signal:"resetFinished"`
|
_ func() `signal:"resetFinished"`
|
||||||
|
|
||||||
_ string `property:"version"`
|
_ string `property:"version"`
|
||||||
_ string `property:"logsPath"`
|
_ core.QUrl `property:"logsPath"`
|
||||||
_ string `property:"licensePath"`
|
_ core.QUrl `property:"licensePath"`
|
||||||
_ string `property:"releaseNotesLink"`
|
_ core.QUrl `property:"releaseNotesLink"`
|
||||||
_ string `property:"landingPageLink"`
|
_ core.QUrl `property:"landingPageLink"`
|
||||||
|
|
||||||
_ string `property:"currentEmailClient"`
|
_ string `property:"currentEmailClient"`
|
||||||
_ func() `slot:"updateCurrentMailClient"`
|
_ func() `slot:"updateCurrentMailClient"`
|
||||||
@ -207,7 +207,7 @@ func (q *QMLBackend) setup(f *FrontendQt) {
|
|||||||
|
|
||||||
f.setIsDiskCacheEnabled()
|
f.setIsDiskCacheEnabled()
|
||||||
f.setDiskCachePath()
|
f.setDiskCachePath()
|
||||||
q.ConnectChangeLocalCache(func(e bool, d string) {
|
q.ConnectChangeLocalCache(func(e bool, d *core.QUrl) {
|
||||||
go func() {
|
go func() {
|
||||||
defer f.panicHandler.HandlePanic()
|
defer f.panicHandler.HandlePanic()
|
||||||
f.changeLocalCache(e, d)
|
f.changeLocalCache(e, d)
|
||||||
|
|||||||
Reference in New Issue
Block a user