update: text and some fixes

This commit is contained in:
MrMirDan
2025-12-23 14:10:19 +02:00
parent 4c082654f9
commit 452150bfff
10 changed files with 119 additions and 56 deletions
@@ -123,8 +123,6 @@ void SettingsController::exportLogsFile(const QString &fileName)
AndroidController::instance()->exportLogsFile(fileName); AndroidController::instance()->exportLogsFile(fileName);
#else #else
SystemController::saveFile(fileName, Logger::getLogFile()); SystemController::saveFile(fileName, Logger::getLogFile());
if (m_settings->isFileEncryption())
SystemController::encryptFile(fileName, m_settings->getPassword(), m_settings->getHint());
#endif #endif
} }
@@ -134,8 +132,6 @@ void SettingsController::exportServiceLogsFile(const QString &fileName)
AndroidController::instance()->exportLogsFile(fileName); AndroidController::instance()->exportLogsFile(fileName);
#else #else
SystemController::saveFile(fileName, Logger::getServiceLogFile()); SystemController::saveFile(fileName, Logger::getServiceLogFile());
if (m_settings->isFileEncryption())
SystemController::encryptFile(fileName, m_settings->getPassword(), m_settings->getHint());
#endif #endif
} }
@@ -7,12 +7,13 @@ import Style 1.0
import "../Controls2" import "../Controls2"
import "../Controls2/TextTypes" import "../Controls2/TextTypes"
import "../Config" import "../Config"
Rectangle { Rectangle {
id: root id: root
property bool linkEnabled: false
property string textColor: AmneziaStyle.color.paleGray property string textColor: AmneziaStyle.color.paleGray
property string textString property string textString
@@ -33,23 +34,15 @@ Rectangle {
RowLayout { RowLayout {
id: content id: content
width: parent.width anchors.centerIn: parent
anchors.fill: parent
anchors.leftMargin: content.width / 4
anchors.rightMargin: content.width / 4
anchors.topMargin: 4
anchors.bottomMargin: 4
spacing: 0 spacing: 0
Image { Image {
Layout.alignment: Qt.AlignTop width: root.iconWidth
height: root.iconHeight
width: iconWidth source: root.iconPath
height: iconHeight
source: iconPath
} }
CaptionTextType { CaptionTextType {
@@ -58,9 +51,17 @@ Rectangle {
Layout.fillWidth: true Layout.fillWidth: true
Layout.leftMargin: 8 Layout.leftMargin: 8
text: textString text: root.linkEnabled ? root.textString
textFormat: root.textFormat + qsTr(" <a href=\"learnMore\" style=\"text-decoration:none; color:%1\">Learn more</a>").arg(AmneziaStyle.color.goldenApricot)
color: textColor : root.textString
textFormat: Text.RichText
color: root.textColor
onLinkActivated: function(link) {
if (link === "learnMore") {
console.log("Learn more pressed")
}
}
} }
} }
} }
+3 -3
View File
@@ -54,7 +54,7 @@ DrawerType2 {
Layout.fillWidth: true Layout.fillWidth: true
Layout.bottomMargin: 8 Layout.bottomMargin: 8
text: qsTr("Enter password to continue") text: qsTr("Password required")
} }
TextFieldWithHeaderType { TextFieldWithHeaderType {
@@ -110,12 +110,12 @@ DrawerType2 {
clickedFunc: function() { clickedFunc: function() {
if (fromOutside) { if (fromOutside) {
if (!SystemController.isPasswordValid(fileName, passwordField.textField.text)) { if (!SystemController.isPasswordValid(fileName, passwordField.textField.text)) {
passwordField.errorText = qsTr("Incorrect password") passwordField.errorText = qsTr("Invalid password")
return return
} }
} else { } else {
if (passwordField.textField.text !== SettingsController.getPassword()) { if (passwordField.textField.text !== SettingsController.getPassword()) {
passwordField.errorText = qsTr("Incorrect password") passwordField.errorText = qsTr("Invalid password")
return return
} }
} }
@@ -65,6 +65,7 @@ PageType {
id: indicator id: indicator
visible: SettingsController.isFileEncryptionEnabled() visible: SettingsController.isFileEncryptionEnabled()
linkEnabled: true
textString: qsTr("Encryption enabled. Learn more") textString: qsTr("Encryption enabled. Learn more")
iconPath: "qrc:/images/controls/lock-locked.svg" iconPath: "qrc:/images/controls/lock-locked.svg"
@@ -22,8 +22,9 @@ PageType {
function onFileEncryptionStateChanged() { function onFileEncryptionStateChanged() {
PageController.showBusyIndicator(true) PageController.showBusyIndicator(true)
PageController.closePage() PageController.closePage()
PageController.goToPage(PageEnum.PageSettingsAppEncryption) SettingsController.isFileEncryptionEnabled() ? PageController.goToPage(PageEnum.PageSettingsAppEncryption) : PageController.goToPage(PageEnum.PageSettingsAppPassword)
PageController.showBusyIndicator(false) PageController.showBusyIndicator(false)
PageController.showNotificationMessage(SettingsController.isFileEncryptionEnabled() ? qsTr("Encryption enabled") : qsTr("Encryption disabled"))
} }
} }
@@ -64,33 +65,56 @@ PageType {
Layout.fillWidth: true Layout.fillWidth: true
Layout.leftMargin: 16 Layout.leftMargin: 16
Layout.rightMargin: 16 Layout.rightMargin: 16
Layout.bottomMargin: 16
headerText: qsTr("File encryption") headerText: qsTr("Password & Encryption")
descriptionText: qsTr("For encrypting backups, configuration files, subscription keys, and logs") descriptionText: qsTr("Password protection for backups and configuration files.\nRequired to restore or import encrypted files.")
}
BasicButtonType {
Layout.leftMargin: 8
Layout.bottomMargin: 16
implicitHeight: 16
defaultColor: AmneziaStyle.color.transparent
hoveredColor: AmneziaStyle.color.translucentWhite
pressedColor: AmneziaStyle.color.sheerWhite
disabledColor: AmneziaStyle.color.mutedGray
textColor: AmneziaStyle.color.goldenApricot
text: qsTr("Learn more")
clickedFunc: function() {
// TODO: add link
}
} }
EncryptionIndicator { EncryptionIndicator {
id: indicator id: indicator
textString: SettingsController.isFileEncryptionEnabled() ? qsTr("Password set. Encryption on") : qsTr("Password not set. Encryption off") textString: qsTr("Password set. Encryption enabled")
iconPath: SettingsController.isFileEncryptionEnabled() ? "qrc:/images/controls/lock-locked.svg" : "qrc:/images/controls/lock-unlocked.svg" iconPath: "qrc:/images/controls/lock-locked.svg"
} }
BasicButtonType { BasicButtonType {
id: switchEncryptionButton id: disableEncryptionButton
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 16 Layout.topMargin: 16
Layout.leftMargin: 16 Layout.leftMargin: 16
Layout.rightMargin: 16 Layout.rightMargin: 16
text: SettingsController.isFileEncryptionEnabled() ? qsTr("Turn off encryption") : qsTr("Turn on encryption") text: qsTr("Disable encryption")
clickedFunc: function() { clickedFunc: function() {
SettingsController.isFileEncryptionEnabled() ? SettingsController.toggleFileEncryption(false) passwordDrawer.securedFunc = function() {
: SettingsController.toggleFileEncryption(true) PageController.showBusyIndicator(true)
SettingsController.toggleFileEncryption(false)
SettingsController.setPassword("")
SettingsController.setHint("")
PageController.showBusyIndicator(false)
}
passwordDrawer.openTriggered()
} }
} }
@@ -109,9 +133,17 @@ PageType {
text: qsTr("Change password") text: qsTr("Change password")
signal changingPassword
clickedFunc: function() { clickedFunc: function() {
passwordDrawer.securedFunc = function() {
root.isChangingPassword = true
PageController.showBusyIndicator(true)
PageController.closePage()
PageController.goToPage(PageEnum.PageSettingsAppPassword)
PageController.showBusyIndicator(false)
SettingsController.changingPassword()
}
passwordDrawer.openTriggered() passwordDrawer.openTriggered()
} }
} }
@@ -125,17 +157,6 @@ PageType {
anchors.fill: parent anchors.fill: parent
expandedHeight: root.height * 0.45 expandedHeight: root.height * 0.45
securedFunc: function() {
root.isChangingPassword = true
PageController.showBusyIndicator(true)
PageController.closePage()
PageController.goToPage(PageEnum.PageSettingsAppPassword)
PageController.showBusyIndicator(false)
SettingsController.changingPassword()
}
} }
} }
@@ -143,8 +164,24 @@ PageType {
footer: ColumnLayout { footer: ColumnLayout {
width: listView.width width: listView.width
CaptionTextType {
Layout.fillWidth: true
Layout.topMargin: 16
// TODO: add text horizontalAlignment: Text.AlignHCenter
textFormat: Text.RichText
text: qsTr("If the password is forgotten, it can be recovered. To reset the password, "
+ "<a href=\"appSettings\" style=\"text-decoration:none; color:%1;\">settings must be reset</a>."
+ "\nEncrypted files can only be opened with password used to encrypt them").arg(AmneziaStyle.color.goldenApricot)
color: AmneziaStyle.color.mutedGray
onLinkActivated: function(link) {
if (link === "appSettings") {
PageController.closePage()
}
}
}
} }
} }
} }
@@ -61,11 +61,37 @@ PageType {
Layout.fillWidth: true Layout.fillWidth: true
Layout.leftMargin: 16 Layout.leftMargin: 16
Layout.rightMargin: 16 Layout.rightMargin: 16
Layout.bottomMargin: 16
headerText: root.isChangingPassword ? qsTr("Password changing") : qsTr("File encryption") headerText: root.isChangingPassword ? qsTr("Change password") : qsTr("Password & Encryption")
descriptionText: root.isChangingPassword ? qsTr("Files encrypted with old password will stay encrypted with old password") descriptionText: root.isChangingPassword ? qsTr("Existing encrypted files will still require the old password.\nThe new password will be used for new encrypted files.")
: qsTr("For encrypting backups, configuration files, subscription keys, and logs") : qsTr("Password protection for backups and configuration files.\nRequired to restore or import encrypted files.")
}
BasicButtonType {
Layout.leftMargin: 8
Layout.bottomMargin: 16
implicitHeight: 16
defaultColor: AmneziaStyle.color.transparent
hoveredColor: AmneziaStyle.color.translucentWhite
pressedColor: AmneziaStyle.color.sheerWhite
disabledColor: AmneziaStyle.color.mutedGray
textColor: AmneziaStyle.color.goldenApricot
text: qsTr("Learn more")
clickedFunc: function() {
// TODO: add link
}
}
EncryptionIndicator {
id: indicator
visible: !root.isChangingPassword
textString: qsTr("Password not set. Encryption disabled")
iconPath: "qrc:/images/controls/lock-unlocked.svg"
} }
} }
@@ -55,8 +55,8 @@ PageType {
Layout.rightMargin: 16 Layout.rightMargin: 16
headerText: root.isChangingPassword ? qsTr("Confirm new password") : qsTr("Confirm password") headerText: root.isChangingPassword ? qsTr("Confirm new password") : qsTr("Confirm password")
descriptionText: qsTr("If you forget your password, you'll have to reset all app settings to reset it." descriptionText: root.isChangingPassword ? qsTr("") : qsTr("If you forget your password, you'll have to reset all app settings to reset it."
+ " Encrypted files will remain encrypted") + " Encrypted files will remain encrypted")
} }
} }
@@ -195,8 +195,8 @@ PageType {
Layout.fillWidth: true Layout.fillWidth: true
text: qsTr("File encryption") text: qsTr("Password & Encryption")
descriptionText: qsTr("For encrypting backups, configuration files, subscription keys, and logs") descriptionText: qsTr("Password protection for backups and configuration files")
rightImageSource: "qrc:/images/controls/chevron-right.svg" rightImageSource: "qrc:/images/controls/chevron-right.svg"
clickedFunction: function() { clickedFunction: function() {
+2 -1
View File
@@ -76,8 +76,9 @@ PageType {
id: indicator id: indicator
visible: SettingsController.isFileEncryptionEnabled() visible: SettingsController.isFileEncryptionEnabled()
linkEnabled: true
textString: qsTr("Encryption enabled. Learn more") textString: qsTr("Encryption enabled.")
iconPath: "qrc:/images/controls/lock-locked.svg" iconPath: "qrc:/images/controls/lock-locked.svg"
} }
} }
+1
View File
@@ -298,6 +298,7 @@ PageType {
id: indicator id: indicator
visible: SettingsController.isFileEncryptionEnabled() visible: SettingsController.isFileEncryptionEnabled()
linkEnabled: true
textString: qsTr("Encryption enabled. Learn more") textString: qsTr("Encryption enabled. Learn more")
iconPath: "qrc:/images/controls/lock-locked.svg" iconPath: "qrc:/images/controls/lock-locked.svg"