keepassxc/src/gui/WelcomeWidget.cpp

68 lines
2.4 KiB
C++
Raw Normal View History

2012-05-27 14:06:03 -04:00
/*
* Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 or (at your option)
* version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "WelcomeWidget.h"
#include "ui_WelcomeWidget.h"
2017-02-11 13:04:37 -05:00
#include "config-keepassx.h"
#include "core/FilePath.h"
#include "core/Config.h"
2012-05-27 14:06:03 -04:00
WelcomeWidget::WelcomeWidget(QWidget* parent)
: QWidget(parent)
, m_ui(new Ui::WelcomeWidget())
{
m_ui->setupUi(this);
2017-02-11 13:04:37 -05:00
m_ui->welcomeLabel->setText(m_ui->welcomeLabel->text() + " " + KEEPASSX_VERSION);
QFont welcomeLabelFont = m_ui->welcomeLabel->font();
welcomeLabelFont.setBold(true);
welcomeLabelFont.setPointSize(welcomeLabelFont.pointSize() + 4);
m_ui->welcomeLabel->setFont(welcomeLabelFont);
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);
}
2017-02-11 17:56:26 -05:00
bool recent_visibility = (m_ui->recentListWidget->count() > 0);
m_ui->startLabel->setVisible(!recent_visibility);
m_ui->recentListWidget->setVisible(recent_visibility);
m_ui->recentLabel->setVisible(recent_visibility);
2017-02-11 13:04:37 -05:00
connect(m_ui->buttonNewDatabase, SIGNAL(clicked()), SIGNAL(newDatabase()));
connect(m_ui->buttonOpenDatabase, SIGNAL(clicked()), SIGNAL(openDatabase()));
connect(m_ui->buttonImportKeePass1, SIGNAL(clicked()), SIGNAL(importKeePass1Database()));
connect(m_ui->recentListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this,
SLOT(openDatabaseFromFile(QListWidgetItem*)));
2012-05-27 14:06:03 -04:00
}
WelcomeWidget::~WelcomeWidget()
{
}
2017-02-11 13:04:37 -05:00
void WelcomeWidget::openDatabaseFromFile(QListWidgetItem* item)
{
if (item->text().isEmpty()) {
return;
}
Q_EMIT openDatabaseFile(item->text());
}