1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-13 10:32:11 +01:00

[PasswordManager] Give user feedback when importing/exporting passwords.

This commit is contained in:
nowrep 2013-05-23 18:16:20 +02:00
parent 7e2b631f34
commit 30594f2480
2 changed files with 27 additions and 9 deletions

View File

@ -276,12 +276,30 @@ void AutoFillManager::showExceptions()
void AutoFillManager::importPasswords() void AutoFillManager::importPasswords()
{ {
const QString &fileName = QFileDialog::getOpenFileName(this, tr("Choose file..."), QDir::homePath() + "/passwords.xml", "*.xml"); m_fileName = QFileDialog::getOpenFileName(this, tr("Choose file..."), QDir::homePath() + "/passwords.xml", "*.xml");
if (fileName.isEmpty()) {
if (m_fileName.isEmpty()) {
return; return;
} }
QFile file(fileName); QTimer::singleShot(0, this, SLOT(slotImportPasswords()));
}
void AutoFillManager::exportPasswords()
{
m_fileName = QFileDialog::getSaveFileName(this, tr("Choose file..."), QDir::homePath() + "/passwords.xml", "*.xml");
if (m_fileName.isEmpty()) {
return;
}
QTimer::singleShot(0, this, SLOT(slotExportPasswords()));
}
void AutoFillManager::slotImportPasswords()
{
QFile file(m_fileName);
if (!file.open(QFile::ReadOnly)) { if (!file.open(QFile::ReadOnly)) {
ui->importExportLabel->setText(tr("Cannot read file!")); ui->importExportLabel->setText(tr("Cannot read file!"));
return; return;
@ -298,14 +316,10 @@ void AutoFillManager::importPasswords()
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} }
void AutoFillManager::exportPasswords() void AutoFillManager::slotExportPasswords()
{ {
const QString &fileName = QFileDialog::getSaveFileName(this, tr("Choose file..."), QDir::homePath() + "/passwords.xml", "*.xml"); QFile file(m_fileName);
if (fileName.isEmpty()) {
return;
}
QFile file(fileName);
if (!file.open(QFile::WriteOnly)) { if (!file.open(QFile::WriteOnly)) {
ui->importExportLabel->setText(tr("Cannot write to file!")); ui->importExportLabel->setText(tr("Cannot write to file!"));
return; return;

View File

@ -55,10 +55,14 @@ private slots:
void importPasswords(); void importPasswords();
void exportPasswords(); void exportPasswords();
void slotImportPasswords();
void slotExportPasswords();
private: private:
Ui::AutoFillManager* ui; Ui::AutoFillManager* ui;
PasswordManager* m_passwordManager; PasswordManager* m_passwordManager;
QString m_fileName;
bool m_passwordsShown; bool m_passwordsShown;
}; };