fix RecentDatabases, closes #386

This commit is contained in:
thez3ro 2017-03-26 22:55:56 +02:00
parent 1418712b4c
commit 7ca13b3d51
No known key found for this signature in database
GPG Key ID: F628F9E41DD7C073
3 changed files with 20 additions and 8 deletions

View File

@ -378,6 +378,11 @@ void MainWindow::openRecentDatabase(QAction* action)
void MainWindow::clearLastDatabases()
{
config()->set("LastDatabases", QVariant());
bool inWelcomeWidget = (m_ui->stackedWidget->currentIndex() == 2);
if (inWelcomeWidget) {
m_ui->welcomeWidget->refreshLastDatabases();
}
}
void MainWindow::openDatabase(const QString& fileName, const QString& pw, const QString& keyFile)

View File

@ -36,13 +36,8 @@ WelcomeWidget::WelcomeWidget(QWidget* parent)
m_ui->iconLabel->setPixmap(filePath()->applicationIcon().pixmap(64));
m_ui->recentListWidget->clear();
const QStringList lastDatabases = config()->get("LastDatabases", QVariant()).toStringList();
for (const QString& database : lastDatabases) {
QListWidgetItem *itm = new QListWidgetItem;
itm->setText(database);
m_ui->recentListWidget->addItem(itm);
}
refreshLastDatabases();
bool recent_visibility = (m_ui->recentListWidget->count() > 0);
m_ui->startLabel->setVisible(!recent_visibility);
m_ui->recentListWidget->setVisible(recent_visibility);
@ -52,7 +47,7 @@ WelcomeWidget::WelcomeWidget(QWidget* parent)
connect(m_ui->buttonOpenDatabase, SIGNAL(clicked()), SIGNAL(openDatabase()));
connect(m_ui->buttonImportKeePass1, SIGNAL(clicked()), SIGNAL(importKeePass1Database()));
connect(m_ui->buttonImportCSV, SIGNAL(clicked()), SIGNAL(importCsv()));
connect(m_ui->recentListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this,
connect(m_ui->recentListWidget, SIGNAL(itemActivated(QListWidgetItem*)), this,
SLOT(openDatabaseFromFile(QListWidgetItem*)));
}
@ -67,3 +62,14 @@ void WelcomeWidget::openDatabaseFromFile(QListWidgetItem* item)
}
emit openDatabaseFile(item->text());
}
void WelcomeWidget::refreshLastDatabases()
{
m_ui->recentListWidget->clear();
const QStringList lastDatabases = config()->get("LastDatabases", QVariant()).toStringList();
for (const QString& database : lastDatabases) {
QListWidgetItem *itm = new QListWidgetItem;
itm->setText(database);
m_ui->recentListWidget->addItem(itm);
}
}

View File

@ -32,6 +32,7 @@ class WelcomeWidget : public QWidget
public:
explicit WelcomeWidget(QWidget* parent = nullptr);
~WelcomeWidget();
void refreshLastDatabases();
signals:
void newDatabase();