1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-04-23 06:32:02 +02:00

backupKeyPage: fix unfunctional export account logic

1. Logic fix - use file url instead of folder url
2. Add informative dialog like it used to have

Gitlab: #540

Change-Id: I73e8335e65d7048294f88988991888ab244b3144
This commit is contained in:
Ming Rui Zhang 2021-09-21 15:59:42 -04:00
parent 42c5de9d3c
commit 9807ed0947
3 changed files with 26 additions and 30 deletions

View file

@ -334,6 +334,7 @@ AccountAdapter::setArchiveHasPassword(bool isHavePassword)
confProps.archiveHasPassword = isHavePassword; confProps.archiveHasPassword = isHavePassword;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
} }
bool bool
AccountAdapter::exportToFile(const QString& accountId, AccountAdapter::exportToFile(const QString& accountId,
const QString& path, const QString& path,
@ -351,13 +352,3 @@ AccountAdapter::setArchivePasswordAsync(const QString& accountID, const QString&
lrcInstance_->accountModel().setAccountConfig(accountID, config); lrcInstance_->accountModel().setAccountConfig(accountID, config);
}); });
} }
void
AccountAdapter::passwordSetStatusMessageBox(bool success, QString title, QString infoToDisplay)
{
if (success) {
QMessageBox::information(0, title, infoToDisplay);
} else {
QMessageBox::critical(0, title, infoToDisplay);
}
}

View file

@ -62,9 +62,6 @@ public:
// Delete current account // Delete current account
Q_INVOKABLE void deleteCurrentAccount(); Q_INVOKABLE void deleteCurrentAccount();
// Setting related
Q_INVOKABLE void passwordSetStatusMessageBox(bool success, QString title, QString infoToDisplay);
// Conf property // Conf property
Q_INVOKABLE bool hasPassword(); Q_INVOKABLE bool hasPassword();
Q_INVOKABLE void setArchiveHasPassword(bool isHavePassword); Q_INVOKABLE void setArchiveHasPassword(bool isHavePassword);

View file

@ -37,6 +37,13 @@ Rectangle {
signal showThisPage signal showThisPage
function showBackupStatusDialog(success) {
var title = success ? JamiStrings.success : JamiStrings.error
var info = success ? JamiStrings.backupSuccessful : JamiStrings.backupFailed
msgDialog.openWithParameters(title, info)
}
Connections { Connections {
target: WizardViewStepModel target: WizardViewStepModel
@ -46,20 +53,25 @@ Rectangle {
} }
} }
SimpleMessageDialog {
id: msgDialog
buttonTitles: [JamiStrings.optionOk]
buttonStyles: [SimpleMessageDialog.ButtonStyle.TintedBlue]
onVisibleChanged: {
if (title === JamiStrings.success && !visible)
WizardViewStepModel.nextStep()
}
}
PasswordDialog { PasswordDialog {
id: passwordDialog id: passwordDialog
visible: false visible: false
purpose: PasswordDialog.ExportAccount purpose: PasswordDialog.ExportAccount
onDoneSignal: { onDoneSignal: showBackupStatusDialog(success)
var title = success ? JamiStrings.success : JamiStrings.error
var info = success ? JamiStrings.backupSuccessful : JamiStrings.backupFailed
AccountAdapter.passwordSetStatusMessageBox(success, title, info)
if (success)
loaderSourceChangeRequested(MainApplicationWindow.LoadedSource.MainView)
}
} }
// JamiFileDialog for exporting account // JamiFileDialog for exporting account
@ -76,20 +88,16 @@ Rectangle {
onAccepted: { onAccepted: {
// Is there password? If so, go to password dialog, else, go to following directly // Is there password? If so, go to password dialog, else, go to following directly
if (AccountAdapter.hasPassword()) { if (AccountAdapter.hasPassword()) {
passwordDialog.path = UtilsAdapter.getAbsPath(folder) passwordDialog.path = UtilsAdapter.getAbsPath(file)
passwordDialog.open() passwordDialog.open()
return
} else { } else {
if (folder.length > 0) { if (file.toString().length > 0)
AccountAdapter.exportToFile( showBackupStatusDialog(AccountAdapter.exportToFile(
LRCInstance.currentAccountId, LRCInstance.currentAccountId,
UtilsAdapter.getAbsPath(folder)) UtilsAdapter.getAbsPath(file)))
} }
} }
WizardViewStepModel.nextStep()
}
onVisibleChanged: { onVisibleChanged: {
if (!visible) { if (!visible) {
rejected() rejected()