Backup/restore config
This commit is contained in:
parent
71b57bfed1
commit
1e85b25438
12 changed files with 155 additions and 105 deletions
|
|
@ -74,3 +74,26 @@ void AppSettingsLogic::onPushButtonClearLogsClicked()
|
|||
Debug::clearLogs();
|
||||
Debug::clearServiceLogs();
|
||||
}
|
||||
|
||||
void AppSettingsLogic::onPushButtonBackupAppConfigClicked()
|
||||
{
|
||||
uiLogic()->saveTextFile("Backup application config", "AmneziaVPN.backup", ".backup", m_settings.backupAppConfig());
|
||||
}
|
||||
|
||||
void AppSettingsLogic::onPushButtonRestoreAppConfigClicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(nullptr, tr("Open backup"),
|
||||
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.backup");
|
||||
|
||||
if (fileName.isEmpty()) return;
|
||||
|
||||
QFile file(fileName);
|
||||
file.open(QIODevice::ReadOnly);
|
||||
QByteArray data = file.readAll();
|
||||
|
||||
m_settings.restoreAppConfig(data);
|
||||
|
||||
emit uiLogic()->goToPage(Page::Vpn);
|
||||
emit uiLogic()->setStartPage(Page::Vpn);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@ public:
|
|||
Q_INVOKABLE void onPushButtonExportLogsClicked();
|
||||
Q_INVOKABLE void onPushButtonClearLogsClicked();
|
||||
|
||||
Q_INVOKABLE void onPushButtonBackupAppConfigClicked();
|
||||
Q_INVOKABLE void onPushButtonRestoreAppConfigClicked();
|
||||
|
||||
|
||||
public:
|
||||
explicit AppSettingsLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||
~AppSettingsLogic() = default;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ StartPageLogic::StartPageLogic(UiLogic *logic, QObject *parent):
|
|||
m_labelWaitInfoVisible{true},
|
||||
m_labelWaitInfoText{},
|
||||
m_pushButtonBackFromStartVisible{true},
|
||||
m_pushButtonConnectVisible{true},
|
||||
m_ipAddressPortRegex{Utils::ipAddressPortRegExp()}
|
||||
{
|
||||
|
||||
|
|
@ -41,7 +40,6 @@ void StartPageLogic::onUpdatePage()
|
|||
|
||||
set_labelWaitInfoVisible(false);
|
||||
set_labelWaitInfoText("");
|
||||
set_pushButtonConnectVisible(true);
|
||||
|
||||
set_pushButtonConnectKeyChecked(false);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ class StartPageLogic : public PageLogicBase
|
|||
AUTO_PROPERTY(bool, labelWaitInfoVisible)
|
||||
AUTO_PROPERTY(QString, labelWaitInfoText)
|
||||
AUTO_PROPERTY(bool, pushButtonBackFromStartVisible)
|
||||
AUTO_PROPERTY(bool, pushButtonConnectVisible)
|
||||
|
||||
READONLY_PROPERTY(QRegExp, ipAddressPortRegex)
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ PageBase {
|
|||
|
||||
BlueButtonType {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 15
|
||||
Layout.topMargin: 10
|
||||
Layout.preferredHeight: 41
|
||||
text: qsTr("Export logs")
|
||||
onClicked: {
|
||||
|
|
@ -117,7 +117,7 @@ PageBase {
|
|||
|
||||
BlueButtonType {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 15
|
||||
Layout.topMargin: 10
|
||||
Layout.preferredHeight: 41
|
||||
|
||||
property string start_text: qsTr("Clear logs")
|
||||
|
|
@ -135,6 +135,31 @@ PageBase {
|
|||
AppSettingsLogic.onPushButtonClearLogsClicked()
|
||||
}
|
||||
}
|
||||
|
||||
LabelType {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 30
|
||||
text: qsTr("Backup and restore configuration")
|
||||
}
|
||||
|
||||
BlueButtonType {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 10
|
||||
Layout.preferredHeight: 41
|
||||
text: qsTr("Backup app config")
|
||||
onClicked: {
|
||||
AppSettingsLogic.onPushButtonBackupAppConfigClicked()
|
||||
}
|
||||
}
|
||||
BlueButtonType {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 10
|
||||
Layout.preferredHeight: 41
|
||||
text: qsTr("Restore app config")
|
||||
onClicked: {
|
||||
AppSettingsLogic.onPushButtonRestoreAppConfigClicked()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -119,7 +119,6 @@ PageBase {
|
|||
anchors.topMargin: 40
|
||||
|
||||
text: qsTr("Open file")
|
||||
visible: StartPageLogic.pushButtonConnectVisible
|
||||
onClicked: {
|
||||
StartPageLogic.onPushButtonImportOpenFile()
|
||||
}
|
||||
|
|
@ -133,7 +132,6 @@ PageBase {
|
|||
anchors.topMargin: 10
|
||||
|
||||
text: qsTr("Scan QR code")
|
||||
visible: StartPageLogic.pushButtonConnectVisible
|
||||
onClicked: {
|
||||
if (Qt.platform.os == "ios") {
|
||||
UiLogic.goToPage(PageEnum.QrDecoderIos)
|
||||
|
|
@ -144,7 +142,19 @@ PageBase {
|
|||
enabled: StartPageLogic.pushButtonConnectEnabled
|
||||
}
|
||||
|
||||
BlueButtonType {
|
||||
id: btn_restore_cfg
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: qr_code_import.bottom
|
||||
anchors.topMargin: 30
|
||||
visible: UiLogic.pagesStackDepth == 1
|
||||
enabled: StartPageLogic.pushButtonConnectEnabled
|
||||
|
||||
text: qsTr("Restore app config")
|
||||
onClicked: {
|
||||
AppSettingsLogic.onPushButtonRestoreAppConfigClicked()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -270,7 +280,6 @@ PageBase {
|
|||
anchors.topMargin: 10
|
||||
|
||||
text: StartPageLogic.pushButtonConnectText
|
||||
visible: StartPageLogic.pushButtonConnectVisible
|
||||
onClicked: {
|
||||
StartPageLogic.onPushButtonConnect()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue