Merge remote-tracking branch 'upstream/develop' into feature/import-csv-format

This commit is contained in:
seatedscribe 2017-03-16 21:25:38 +01:00
commit 3fcf342fbc
157 changed files with 2325 additions and 519 deletions

View file

@ -87,6 +87,11 @@ Application::Application(int& argc, char** argv)
#endif
}
QWidget* Application::mainWindow() const
{
return m_mainWindow;
}
void Application::setMainWindow(QWidget* mainWindow)
{
m_mainWindow = mainWindow;
@ -96,7 +101,7 @@ bool Application::event(QEvent* event)
{
// Handle Apple QFileOpenEvent from finder (double click on .kdbx file)
if (event->type() == QEvent::FileOpen) {
Q_EMIT openFile(static_cast<QFileOpenEvent*>(event)->file());
emit openFile(static_cast<QFileOpenEvent*>(event)->file());
return true;
}
#ifdef Q_OS_MAC
@ -148,7 +153,7 @@ void Application::handleUnixSignal(int sig)
case SIGTERM:
{
char buf = 0;
::write(unixSignalSocket[0], &buf, sizeof(buf));
Q_UNUSED(::write(unixSignalSocket[0], &buf, sizeof(buf)));
return;
}
case SIGHUP:
@ -160,7 +165,7 @@ void Application::quitBySignal()
{
m_unixSignalNotifier->setEnabled(false);
char buf;
::read(unixSignalSocket[1], &buf, sizeof(buf));
Q_UNUSED(::read(unixSignalSocket[1], &buf, sizeof(buf)));
if (nullptr != m_mainWindow)
static_cast<MainWindow*>(m_mainWindow)->appExit();

View file

@ -29,14 +29,15 @@ class Application : public QApplication
public:
Application(int& argc, char** argv);
QWidget* mainWindow() const;
void setMainWindow(QWidget* mainWindow);
bool event(QEvent* event) override;
Q_SIGNALS:
signals:
void openFile(const QString& filename);
private Q_SLOTS:
private slots:
#if defined(Q_OS_UNIX)
void quitBySignal();
#endif

View file

@ -21,8 +21,16 @@
#include "core/FilePath.h"
#include "keys/FileKey.h"
#include "keys/PasswordKey.h"
#include "keys/YkChallengeResponseKey.h"
#include "gui/FileDialog.h"
#include "gui/MessageBox.h"
#include "crypto/Random.h"
#include "MainWindow.h"
#include "config-keepassx.h"
#include <QtConcurrentRun>
#include <QSharedPointer>
ChangeMasterKeyWidget::ChangeMasterKeyWidget(QWidget* parent)
: DialogyWidget(parent)
@ -32,13 +40,35 @@ ChangeMasterKeyWidget::ChangeMasterKeyWidget(QWidget* parent)
m_ui->messageWidget->setHidden(true);
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(generateKey()));
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(reject()));
m_ui->togglePasswordButton->setIcon(filePath()->onOffIcon("actions", "password-show"));
connect(m_ui->togglePasswordButton, SIGNAL(toggled(bool)), m_ui->enterPasswordEdit, SLOT(setShowPassword(bool)));
m_ui->repeatPasswordEdit->enableVerifyMode(m_ui->enterPasswordEdit);
connect(m_ui->passwordGroup, SIGNAL(clicked(bool)), SLOT(setOkEnabled()));
connect(m_ui->togglePasswordButton, SIGNAL(toggled(bool)), m_ui->enterPasswordEdit, SLOT(setShowPassword(bool)));
connect(m_ui->keyFileGroup, SIGNAL(clicked(bool)), SLOT(setOkEnabled()));
connect(m_ui->createKeyFileButton, SIGNAL(clicked()), SLOT(createKeyFile()));
connect(m_ui->browseKeyFileButton, SIGNAL(clicked()), SLOT(browseKeyFile()));
connect(m_ui->keyFileCombo, SIGNAL(editTextChanged(QString)), SLOT(setOkEnabled()));
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(generateKey()));
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(reject()));
#ifdef WITH_XC_YUBIKEY
m_ui->yubikeyProgress->setVisible(false);
QSizePolicy sp = m_ui->yubikeyProgress->sizePolicy();
sp.setRetainSizeWhenHidden(true);
m_ui->yubikeyProgress->setSizePolicy(sp);
connect(m_ui->challengeResponseGroup, SIGNAL(clicked(bool)), SLOT(challengeResponseGroupToggled(bool)));
connect(m_ui->challengeResponseGroup, SIGNAL(clicked(bool)), SLOT(setOkEnabled()));
connect(m_ui->buttonRedetectYubikey, SIGNAL(clicked()), SLOT(pollYubikey()));
connect(YubiKey::instance(), SIGNAL(detected(int,bool)), SLOT(yubikeyDetected(int,bool)), Qt::QueuedConnection);
connect(YubiKey::instance(), SIGNAL(notFound()), SLOT(noYubikeyFound()), Qt::QueuedConnection);
#else
m_ui->challengeResponseGroup->setVisible(false);
#endif
}
ChangeMasterKeyWidget::~ChangeMasterKeyWidget()
@ -81,7 +111,11 @@ void ChangeMasterKeyWidget::clearForms()
m_ui->repeatPasswordEdit->setText("");
m_ui->keyFileGroup->setChecked(false);
m_ui->togglePasswordButton->setChecked(false);
// TODO: clear m_ui->keyFileCombo
#ifdef WITH_XC_YUBIKEY
m_ui->challengeResponseGroup->setChecked(false);
m_ui->comboChallengeResponse->clear();
#endif
m_ui->enterPasswordEdit->setFocus();
}
@ -103,9 +137,9 @@ void ChangeMasterKeyWidget::generateKey()
if (m_ui->passwordGroup->isChecked()) {
if (m_ui->enterPasswordEdit->text() == m_ui->repeatPasswordEdit->text()) {
if (m_ui->enterPasswordEdit->text().isEmpty()) {
if (MessageBox::question(this, tr("Question"),
tr("Do you really want to use an empty string as password?"),
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) {
if (MessageBox::warning(this, tr("Empty password"),
tr("Do you really want to use an empty string as password?"),
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) {
return;
}
}
@ -130,14 +164,78 @@ void ChangeMasterKeyWidget::generateKey()
m_key.addKey(fileKey);
}
#ifdef WITH_XC_YUBIKEY
if (m_ui->challengeResponseGroup->isChecked()) {
int selectionIndex = m_ui->comboChallengeResponse->currentIndex();
int comboPayload = m_ui->comboChallengeResponse->itemData(selectionIndex).toInt();
if (0 == comboPayload) {
m_ui->messageWidget->showMessage(tr("Changing master key failed: no YubiKey inserted."),
MessageWidget::Error);
return;
}
// read blocking mode from LSB and slot index number from second LSB
bool blocking = comboPayload & 1;
int slot = comboPayload >> 1;
auto key = QSharedPointer<YkChallengeResponseKey>(new YkChallengeResponseKey(slot, blocking));
m_key.addChallengeResponseKey(key);
}
#endif
m_ui->messageWidget->hideMessage();
Q_EMIT editFinished(true);
emit editFinished(true);
}
void ChangeMasterKeyWidget::reject()
{
Q_EMIT editFinished(false);
emit editFinished(false);
}
void ChangeMasterKeyWidget::challengeResponseGroupToggled(bool checked)
{
if (checked)
pollYubikey();
}
void ChangeMasterKeyWidget::pollYubikey()
{
m_ui->buttonRedetectYubikey->setEnabled(false);
m_ui->comboChallengeResponse->setEnabled(false);
m_ui->comboChallengeResponse->clear();
m_ui->yubikeyProgress->setVisible(true);
setOkEnabled();
// YubiKey init is slow, detect asynchronously to not block the UI
QtConcurrent::run(YubiKey::instance(), &YubiKey::detect);
}
void ChangeMasterKeyWidget::yubikeyDetected(int slot, bool blocking)
{
YkChallengeResponseKey yk(slot, blocking);
// add detected YubiKey to combo box and encode blocking mode in LSB, slot number in second LSB
m_ui->comboChallengeResponse->addItem(yk.getName(), QVariant((slot << 1) | blocking));
m_ui->comboChallengeResponse->setEnabled(m_ui->challengeResponseGroup->isChecked());
m_ui->buttonRedetectYubikey->setEnabled(m_ui->challengeResponseGroup->isChecked());
m_ui->yubikeyProgress->setVisible(false);
setOkEnabled();
}
void ChangeMasterKeyWidget::noYubikeyFound()
{
m_ui->buttonRedetectYubikey->setEnabled(m_ui->challengeResponseGroup->isChecked());
m_ui->yubikeyProgress->setVisible(false);
setOkEnabled();
}
void ChangeMasterKeyWidget::setOkEnabled()
{
bool ok = m_ui->passwordGroup->isChecked() ||
(m_ui->challengeResponseGroup->isChecked() && !m_ui->comboChallengeResponse->currentText().isEmpty()) ||
(m_ui->keyFileGroup->isChecked() && !m_ui->keyFileCombo->currentText().isEmpty());
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ok);
}
void ChangeMasterKeyWidget::setCancelEnabled(bool enabled)

View file

@ -38,16 +38,23 @@ public:
void clearForms();
CompositeKey newMasterKey();
QLabel* headlineLabel();
public slots:
void setOkEnabled();
void setCancelEnabled(bool enabled);
Q_SIGNALS:
signals:
void editFinished(bool accepted);
private Q_SLOTS:
private slots:
void generateKey();
void reject();
void createKeyFile();
void browseKeyFile();
void yubikeyDetected(int slot, bool blocking);
void noYubikeyFound();
void challengeResponseGroupToggled(bool checked);
void pollYubikey();
private:
const QScopedPointer<Ui::ChangeMasterKeyWidget> m_ui;

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>818</width>
<height>397</height>
<height>471</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@ -90,7 +90,7 @@
<item>
<widget class="QGroupBox" name="keyFileGroup">
<property name="title">
<string>Key file</string>
<string>&amp;Key file</string>
</property>
<property name="checkable">
<bool>true</bool>
@ -126,6 +126,67 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="challengeResponseGroup">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Cha&amp;llenge Response</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_4">
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="1">
<widget class="QPushButton" name="buttonRedetectYubikey">
<property name="text">
<string>Refresh</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QComboBox" name="comboChallengeResponse">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QProgressBar" name="yubikeyProgress">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>2</height>
</size>
</property>
<property name="maximum">
<number>0</number>
</property>
<property name="value">
<number>-1</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View file

@ -31,10 +31,10 @@ public:
static Clipboard* instance();
public Q_SLOTS:
public slots:
void clearCopiedText();
private Q_SLOTS:
private slots:
void clearClipboard();
private:

View file

@ -39,7 +39,7 @@ public:
private:
QScopedPointer<Ui::CloneDialog> m_ui;
private Q_SLOTS:
private slots:
void cloneEntry();
protected:

View file

@ -27,6 +27,14 @@
#include "format/KeePass2Reader.h"
#include "keys/FileKey.h"
#include "keys/PasswordKey.h"
#include "crypto/Random.h"
#include "keys/YkChallengeResponseKey.h"
#include "config-keepassx.h"
#include <QtConcurrentRun>
#include <QSharedPointer>
DatabaseOpenWidget::DatabaseOpenWidget(QWidget* parent)
: DialogyWidget(parent)
@ -42,8 +50,6 @@ DatabaseOpenWidget::DatabaseOpenWidget(QWidget* parent)
font.setPointSize(font.pointSize() + 2);
m_ui->labelHeadline->setFont(font);
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
m_ui->buttonTogglePassword->setIcon(filePath()->onOffIcon("actions", "password-show"));
connect(m_ui->buttonTogglePassword, SIGNAL(toggled(bool)),
m_ui->editPassword, SLOT(setShowPassword(bool)));
@ -54,7 +60,25 @@ DatabaseOpenWidget::DatabaseOpenWidget(QWidget* parent)
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(openDatabase()));
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(reject()));
#ifdef WITH_XC_YUBIKEY
m_ui->yubikeyProgress->setVisible(false);
QSizePolicy sp = m_ui->yubikeyProgress->sizePolicy();
sp.setRetainSizeWhenHidden(true);
m_ui->yubikeyProgress->setSizePolicy(sp);
connect(m_ui->buttonRedetectYubikey, SIGNAL(clicked()), SLOT(pollYubikey()));
connect(m_ui->comboChallengeResponse, SIGNAL(activated(int)), SLOT(activateChallengeResponse()));
connect(YubiKey::instance(), SIGNAL(detected(int,bool)), SLOT(yubikeyDetected(int,bool)), Qt::QueuedConnection);
connect(YubiKey::instance(), SIGNAL(notFound()), SLOT(noYubikeyFound()), Qt::QueuedConnection);
#else
m_ui->checkChallengeResponse->setVisible(false);
m_ui->buttonRedetectYubikey->setVisible(false);
m_ui->comboChallengeResponse->setVisible(false);
m_ui->yubikeyProgress->setVisible(false);
#endif
#ifdef Q_OS_MACOS
// add random padding to layouts to align widgets properly
m_ui->dialogButtonsLayout->setContentsMargins(10, 0, 15, 0);
@ -71,6 +95,10 @@ void DatabaseOpenWidget::showEvent(QShowEvent* event)
{
DialogyWidget::showEvent(event);
m_ui->editPassword->setFocus();
#ifdef WITH_XC_YUBIKEY
pollYubikey();
#endif
}
void DatabaseOpenWidget::load(const QString& filename)
@ -87,7 +115,6 @@ void DatabaseOpenWidget::load(const QString& filename)
}
}
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
m_ui->editPassword->setFocus();
}
@ -130,7 +157,7 @@ void DatabaseOpenWidget::openDatabase()
if (m_ui->messageWidget->isVisible()) {
m_ui->messageWidget->animatedHide();
}
Q_EMIT editFinished(true);
emit editFinished(true);
}
else {
m_ui->messageWidget->showMessage(tr("Unable to open the database.")
@ -148,6 +175,7 @@ CompositeKey DatabaseOpenWidget::databaseKey()
}
QHash<QString, QVariant> lastKeyFiles = config()->get("LastKeyFiles").toHash();
QHash<QString, QVariant> lastChallengeResponse = config()->get("LastChallengeResponse").toHash();
if (m_ui->checkKeyFile->isChecked()) {
FileKey key;
@ -160,21 +188,43 @@ CompositeKey DatabaseOpenWidget::databaseKey()
}
masterKey.addKey(key);
lastKeyFiles[m_filename] = keyFilename;
}
else {
} else {
lastKeyFiles.remove(m_filename);
}
if (m_ui->checkChallengeResponse->isChecked()) {
lastChallengeResponse[m_filename] = true;
} else {
lastChallengeResponse.remove(m_filename);
}
if (config()->get("RememberLastKeyFiles").toBool()) {
config()->set("LastKeyFiles", lastKeyFiles);
}
#ifdef WITH_XC_YUBIKEY
if (config()->get("RememberLastKeyFiles").toBool()) {
config()->set("LastChallengeResponse", lastChallengeResponse);
}
if (m_ui->checkChallengeResponse->isChecked()) {
int selectionIndex = m_ui->comboChallengeResponse->currentIndex();
int comboPayload = m_ui->comboChallengeResponse->itemData(selectionIndex).toInt();
// read blocking mode from LSB and slot index number from second LSB
bool blocking = comboPayload & 1;
int slot = comboPayload >> 1;
auto key = QSharedPointer<YkChallengeResponseKey>(new YkChallengeResponseKey(slot, blocking));
masterKey.addChallengeResponseKey(key);
}
#endif
return masterKey;
}
void DatabaseOpenWidget::reject()
{
Q_EMIT editFinished(false);
emit editFinished(false);
}
void DatabaseOpenWidget::activatePassword()
@ -187,6 +237,11 @@ void DatabaseOpenWidget::activateKeyFile()
m_ui->checkKeyFile->setChecked(true);
}
void DatabaseOpenWidget::activateChallengeResponse()
{
m_ui->checkChallengeResponse->setChecked(true);
}
void DatabaseOpenWidget::browseKeyFile()
{
QString filters = QString("%1 (*);;%2 (*.key)").arg(tr("All files"), tr("Key files"));
@ -196,3 +251,40 @@ void DatabaseOpenWidget::browseKeyFile()
m_ui->comboKeyFile->lineEdit()->setText(filename);
}
}
void DatabaseOpenWidget::pollYubikey()
{
m_ui->buttonRedetectYubikey->setEnabled(false);
m_ui->checkChallengeResponse->setEnabled(false);
m_ui->checkChallengeResponse->setChecked(false);
m_ui->comboChallengeResponse->setEnabled(false);
m_ui->comboChallengeResponse->clear();
m_ui->yubikeyProgress->setVisible(true);
// YubiKey init is slow, detect asynchronously to not block the UI
QtConcurrent::run(YubiKey::instance(), &YubiKey::detect);
}
void DatabaseOpenWidget::yubikeyDetected(int slot, bool blocking)
{
YkChallengeResponseKey yk(slot, blocking);
// add detected YubiKey to combo box and encode blocking mode in LSB, slot number in second LSB
m_ui->comboChallengeResponse->addItem(yk.getName(), QVariant((slot << 1) | blocking));
m_ui->comboChallengeResponse->setEnabled(true);
m_ui->checkChallengeResponse->setEnabled(true);
m_ui->buttonRedetectYubikey->setEnabled(true);
m_ui->yubikeyProgress->setVisible(false);
if (config()->get("RememberLastKeyFiles").toBool()) {
QHash<QString, QVariant> lastChallengeResponse = config()->get("LastChallengeResponse").toHash();
if (lastChallengeResponse.contains(m_filename)) {
m_ui->checkChallengeResponse->setChecked(true);
}
}
}
void DatabaseOpenWidget::noYubikeyFound()
{
m_ui->buttonRedetectYubikey->setEnabled(true);
m_ui->yubikeyProgress->setVisible(false);
}

View file

@ -41,21 +41,27 @@ public:
void enterKey(const QString& pw, const QString& keyFile);
Database* database();
Q_SIGNALS:
public slots:
void pollYubikey();
signals:
void editFinished(bool accepted);
protected:
void showEvent(QShowEvent* event) override;
CompositeKey databaseKey();
protected Q_SLOTS:
protected slots:
virtual void openDatabase();
void reject();
private Q_SLOTS:
private slots:
void activatePassword();
void activateKeyFile();
void activateChallengeResponse();
void browseKeyFile();
void yubikeyDetected(int slot, bool blocking);
void noYubikeyFound();
protected:
const QScopedPointer<Ui::DatabaseOpenWidget> m_ui;

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>596</width>
<height>250</height>
<height>302</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,1,0,1,0,0,3">
@ -85,7 +85,7 @@
</property>
</widget>
</item>
<item row="1" column="1">
<item row="1" column="2">
<layout class="QHBoxLayout" name="keyFileLayout">
<property name="leftMargin">
<number>5</number>
@ -118,7 +118,7 @@
</item>
</layout>
</item>
<item row="0" column="1">
<item row="0" column="2">
<layout class="QHBoxLayout" name="passwordLayout">
<property name="leftMargin">
<number>5</number>
@ -142,6 +142,87 @@
</item>
</layout>
</item>
<item row="5" column="2">
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="1" column="1">
<widget class="QPushButton" name="buttonRedetectYubikey">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Refresh</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QComboBox" name="comboChallengeResponse">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QProgressBar" name="yubikeyProgress">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>2</height>
</size>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>0</number>
</property>
<property name="value">
<number>-1</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QCheckBox" name="checkChallengeResponse">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Challenge Response:</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>

View file

@ -50,7 +50,7 @@ void DatabaseRepairWidget::openDatabase()
QString errorMsg;
if (!key.load(keyFilename, &errorMsg)) {
MessageBox::warning(this, tr("Error"), tr("Can't open key file").append(":\n").append(errorMsg));
Q_EMIT editFinished(false);
emit editFinished(false);
return;
}
masterKey.addKey(key);
@ -62,7 +62,7 @@ void DatabaseRepairWidget::openDatabase()
if (!file.open(QIODevice::ReadOnly)) {
MessageBox::warning(this, tr("Error"), tr("Unable to open the database.").append("\n")
.append(file.errorString()));
Q_EMIT editFinished(false);
emit editFinished(false);
return;
}
if (m_db) {
@ -75,21 +75,21 @@ void DatabaseRepairWidget::openDatabase()
switch (repairResult) {
case KeePass2Repair::NothingTodo:
MessageBox::information(this, tr("Error"), tr("Database opened fine. Nothing to do."));
Q_EMIT editFinished(false);
emit editFinished(false);
return;
case KeePass2Repair::UnableToOpen:
MessageBox::warning(this, tr("Error"), tr("Unable to open the database.").append("\n")
.append(repair.errorString()));
Q_EMIT editFinished(false);
emit editFinished(false);
return;
case KeePass2Repair::RepairSuccess:
m_db = repair.database();
MessageBox::warning(this, tr("Success"), tr("The database has been successfully repaired\nYou can now save it."));
Q_EMIT editFinished(true);
emit editFinished(true);
return;
case KeePass2Repair::RepairFailed:
MessageBox::warning(this, tr("Error"), tr("Unable to repair the database."));
Q_EMIT editFinished(false);
emit editFinished(false);
return;
}
}
@ -97,9 +97,9 @@ void DatabaseRepairWidget::openDatabase()
void DatabaseRepairWidget::processEditFinished(bool result)
{
if (result) {
Q_EMIT success();
emit success();
}
else {
Q_EMIT error();
emit error();
}
}

View file

@ -27,14 +27,14 @@ class DatabaseRepairWidget : public DatabaseOpenWidget
public:
explicit DatabaseRepairWidget(QWidget* parent = nullptr);
Q_SIGNALS:
signals:
void success();
void error();
protected:
void openDatabase() override;
private Q_SLOTS:
private slots:
void processEditFinished(bool result);
};

View file

@ -124,12 +124,12 @@ void DatabaseSettingsWidget::save()
truncateHistories();
}
Q_EMIT editFinished(true);
emit editFinished(true);
}
void DatabaseSettingsWidget::reject()
{
Q_EMIT editFinished(false);
emit editFinished(false);
}
void DatabaseSettingsWidget::transformRoundsBenchmark()

View file

@ -38,10 +38,10 @@ public:
void load(Database* db);
Q_SIGNALS:
signals:
void editFinished(bool accepted);
private Q_SLOTS:
private slots:
void save();
void reject();
void transformRoundsBenchmark();

View file

@ -54,7 +54,7 @@ const int DatabaseTabWidget::LastDatabasesCount = 5;
DatabaseTabWidget::DatabaseTabWidget(QWidget* parent)
: QTabWidget(parent)
, m_dbWidgetSateSync(new DatabaseWidgetStateSync(this))
, m_dbWidgetStateSync(new DatabaseWidgetStateSync(this))
{
DragTabBar* tabBar = new DragTabBar(this);
setTabBar(tabBar);
@ -62,7 +62,7 @@ DatabaseTabWidget::DatabaseTabWidget(QWidget* parent)
connect(this, SIGNAL(tabCloseRequested(int)), SLOT(closeDatabase(int)));
connect(this, SIGNAL(currentChanged(int)), SLOT(emitActivateDatabaseChanged()));
connect(this, SIGNAL(activateDatabaseChanged(DatabaseWidget*)), m_dbWidgetSateSync, SLOT(setActive(DatabaseWidget*)));
connect(this, SIGNAL(activateDatabaseChanged(DatabaseWidget*)), m_dbWidgetStateSync, SLOT(setActive(DatabaseWidget*)));
connect(autoType(), SIGNAL(globalShortcutTriggered()), SLOT(performGlobalAutoType()));
}
@ -120,7 +120,7 @@ void DatabaseTabWidget::openDatabase(const QString& fileName, const QString& pw,
QFileInfo fileInfo(fileName);
QString canonicalFilePath = fileInfo.canonicalFilePath();
if (canonicalFilePath.isEmpty()) {
Q_EMIT messageGlobal(tr("File not found!"), MessageWidget::Error);
emit messageGlobal(tr("File not found!"), MessageWidget::Error);
return;
}
@ -141,7 +141,7 @@ void DatabaseTabWidget::openDatabase(const QString& fileName, const QString& pw,
if (!file.open(QIODevice::ReadWrite)) {
if (!file.open(QIODevice::ReadOnly)) {
// can't open
Q_EMIT messageGlobal(
emit messageGlobal(
tr("Unable to open the database.").append("\n").append(file.errorString()), MessageWidget::Error);
return;
}
@ -198,7 +198,7 @@ void DatabaseTabWidget::openDatabase(const QString& fileName, const QString& pw,
insertDatabase(db, dbStruct);
if (dbStruct.readOnly) {
Q_EMIT messageTab(tr("File opened in read only mode."), MessageWidget::Warning);
emit messageTab(tr("File opened in read only mode."), MessageWidget::Warning);
}
updateLastDatabases(dbStruct.filePath);
@ -209,7 +209,7 @@ void DatabaseTabWidget::openDatabase(const QString& fileName, const QString& pw,
else {
dbStruct.dbWidget->switchToOpenDatabase(dbStruct.filePath);
}
Q_EMIT messageDismissGlobal();
emit messageDismissGlobal();
}
void DatabaseTabWidget::importCsv()
@ -331,7 +331,7 @@ void DatabaseTabWidget::deleteDatabase(Database* db)
delete db;
if (emitDatabaseWithFileClosed) {
Q_EMIT databaseWithFileClosed(filePath);
emit databaseWithFileClosed(filePath);
}
}
@ -348,17 +348,18 @@ bool DatabaseTabWidget::closeAllDatabases()
bool DatabaseTabWidget::saveDatabase(Database* db)
{
DatabaseManagerStruct& dbStruct = m_dbList[db];
// temporarily disable autoreload
dbStruct.dbWidget->ignoreNextAutoreload();
if (dbStruct.saveToFilename) {
QSaveFile saveFile(dbStruct.canonicalFilePath);
if (saveFile.open(QIODevice::WriteOnly)) {
// write the database to the file
dbStruct.dbWidget->blockAutoReload(true);
m_writer.writeDatabase(&saveFile, db);
dbStruct.dbWidget->blockAutoReload(false);
if (m_writer.hasError()) {
Q_EMIT messageTab(tr("Writing the database failed.").append("\n")
.append(m_writer.errorString()), MessageWidget::Error);
emit messageTab(tr("Writing the database failed.").append("\n")
.append(m_writer.errorString()), MessageWidget::Error);
return false;
}
@ -367,22 +368,19 @@ bool DatabaseTabWidget::saveDatabase(Database* db)
dbStruct.modified = false;
dbStruct.dbWidget->databaseSaved();
updateTabName(db);
Q_EMIT messageDismissTab();
emit messageDismissTab();
return true;
}
else {
Q_EMIT messageTab(tr("Writing the database failed.").append("\n")
.append(saveFile.errorString()), MessageWidget::Error);
} else {
emit messageTab(tr("Writing the database failed.").append("\n")
.append(saveFile.errorString()), MessageWidget::Error);
return false;
}
}
else {
Q_EMIT messageTab(tr("Writing the database failed.").append("\n")
.append(saveFile.errorString()), MessageWidget::Error);
} else {
emit messageTab(tr("Writing the database failed.").append("\n")
.append(saveFile.errorString()), MessageWidget::Error);
return false;
}
}
else {
} else {
return saveDatabaseAs(db);
}
}
@ -520,7 +518,7 @@ void DatabaseTabWidget::exportToCsv()
CsvExporter csvExporter;
if (!csvExporter.exportDatabase(fileName, db)) {
Q_EMIT messageGlobal(
emit messageGlobal(
tr("Writing the CSV file failed.").append("\n")
.append(csvExporter.errorString()), MessageWidget::Error);
}
@ -582,7 +580,7 @@ void DatabaseTabWidget::updateTabName(Database* db)
}
setTabText(index, tabName);
Q_EMIT tabNameChanged();
emit tabNameChanged();
}
void DatabaseTabWidget::updateTabNameFromDbSender()
@ -762,7 +760,7 @@ void DatabaseTabWidget::lockDatabases()
// database has changed so we can't use the db variable anymore
updateTabName(dbWidget->database());
Q_EMIT databaseLocked(dbWidget);
emit databaseLocked(dbWidget);
}
}
@ -820,12 +818,12 @@ void DatabaseTabWidget::changeDatabase(Database* newDb, bool unsavedChanges)
void DatabaseTabWidget::emitActivateDatabaseChanged()
{
Q_EMIT activateDatabaseChanged(currentDatabaseWidget());
emit activateDatabaseChanged(currentDatabaseWidget());
}
void DatabaseTabWidget::emitDatabaseUnlockedFromDbWidgetSender()
{
Q_EMIT databaseUnlocked(static_cast<DatabaseWidget*>(sender()));
emit databaseUnlocked(static_cast<DatabaseWidget*>(sender()));
}
void DatabaseTabWidget::connectDatabase(Database* newDb, Database* oldDb)

View file

@ -63,7 +63,7 @@ public:
static const int LastDatabasesCount;
public Q_SLOTS:
public slots:
void newDatabase();
void openDatabase();
void importCsv();
@ -81,7 +81,7 @@ public Q_SLOTS:
void performGlobalAutoType();
void lockDatabases();
Q_SIGNALS:
signals:
void tabNameChanged();
void databaseWithFileClosed(QString filePath);
void activateDatabaseChanged(DatabaseWidget* dbWidget);
@ -92,7 +92,7 @@ Q_SIGNALS:
void messageDismissGlobal();
void messageDismissTab();
private Q_SLOTS:
private slots:
void updateTabName(Database* db);
void updateTabNameFromDbSender();
void updateTabNameFromDbWidgetSender();
@ -117,7 +117,7 @@ private:
KeePass2Writer m_writer;
QHash<Database*, DatabaseManagerStruct> m_dbList;
DatabaseWidgetStateSync* m_dbWidgetSateSync;
DatabaseWidgetStateSync* m_dbWidgetStateSync;
};
#endif // KEEPASSX_DATABASETABWIDGET_H

View file

@ -173,14 +173,14 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
connect(m_unlockDatabaseDialog, SIGNAL(unlockDone(bool)), SLOT(unlockDatabase(bool)));
connect(&m_fileWatcher, SIGNAL(fileChanged(QString)), this, SLOT(onWatchedFileChanged()));
connect(&m_fileWatchTimer, SIGNAL(timeout()), this, SLOT(reloadDatabaseFile()));
connect(&m_ignoreWatchTimer, SIGNAL(timeout()), this, SLOT(onWatchedFileChanged()));
connect(&m_fileWatchUnblockTimer, SIGNAL(timeout()), this, SLOT(unblockAutoReload()));
connect(this, SIGNAL(currentChanged(int)), this, SLOT(emitCurrentModeChanged()));
m_databaseModified = false;
m_fileWatchTimer.setSingleShot(true);
m_ignoreWatchTimer.setSingleShot(true);
m_ignoreNextAutoreload = false;
m_fileWatchUnblockTimer.setSingleShot(true);
m_ignoreAutoReload = false;
m_searchCaseSensitive = false;
@ -270,7 +270,7 @@ void DatabaseWidget::clearAllWidgets()
void DatabaseWidget::emitCurrentModeChanged()
{
Q_EMIT currentModeChanged(currentMode());
emit currentModeChanged(currentMode());
}
Database* DatabaseWidget::database()
@ -316,7 +316,7 @@ void DatabaseWidget::replaceDatabase(Database* db)
Database* oldDb = m_db;
m_db = db;
m_groupView->changeDatabase(m_db);
Q_EMIT databaseChanged(m_db, m_databaseModified);
emit databaseChanged(m_db, m_databaseModified);
delete oldDb;
}
@ -414,7 +414,7 @@ void DatabaseWidget::copyTitle()
return;
}
setClipboardTextAndMinimize(currentEntry->resolvePlaceholder(currentEntry->title()));
setClipboardTextAndMinimize(currentEntry->resolveMultiplePlaceholders(currentEntry->title()));
}
void DatabaseWidget::copyUsername()
@ -425,7 +425,7 @@ void DatabaseWidget::copyUsername()
return;
}
setClipboardTextAndMinimize(currentEntry->resolvePlaceholder(currentEntry->username()));
setClipboardTextAndMinimize(currentEntry->resolveMultiplePlaceholders(currentEntry->username()));
}
void DatabaseWidget::copyPassword()
@ -436,7 +436,7 @@ void DatabaseWidget::copyPassword()
return;
}
setClipboardTextAndMinimize(currentEntry->resolvePlaceholder(currentEntry->password()));
setClipboardTextAndMinimize(currentEntry->resolveMultiplePlaceholders(currentEntry->password()));
}
void DatabaseWidget::copyURL()
@ -447,7 +447,7 @@ void DatabaseWidget::copyURL()
return;
}
setClipboardTextAndMinimize(currentEntry->resolvePlaceholder(currentEntry->url()));
setClipboardTextAndMinimize(currentEntry->resolveMultiplePlaceholders(currentEntry->url()));
}
void DatabaseWidget::copyNotes()
@ -458,7 +458,7 @@ void DatabaseWidget::copyNotes()
return;
}
setClipboardTextAndMinimize(currentEntry->resolvePlaceholder(currentEntry->notes()));
setClipboardTextAndMinimize(currentEntry->resolveMultiplePlaceholders(currentEntry->notes()));
}
void DatabaseWidget::copyAttribute(QAction* action)
@ -469,7 +469,7 @@ void DatabaseWidget::copyAttribute(QAction* action)
return;
}
setClipboardTextAndMinimize(currentEntry->attributes()->value(action->text()));
setClipboardTextAndMinimize(currentEntry->resolveMultiplePlaceholders(currentEntry->attributes()->value(action->text())));
}
void DatabaseWidget::setClipboardTextAndMinimize(const QString& text)
@ -717,7 +717,7 @@ void DatabaseWidget::updateMasterKey(bool accepted)
}
}
else if (!m_db->hasKey()) {
Q_EMIT closeRequest();
emit closeRequest();
return;
}
@ -729,7 +729,7 @@ void DatabaseWidget::openDatabase(bool accepted)
if (accepted) {
replaceDatabase(static_cast<DatabaseOpenWidget*>(sender())->database());
setCurrentWidget(m_mainWidget);
Q_EMIT unlockedDatabase();
emit unlockedDatabase();
// We won't need those anymore and KeePass1OpenWidget closes
// the file in its dtor.
@ -744,7 +744,7 @@ void DatabaseWidget::openDatabase(bool accepted)
if (m_databaseOpenWidget->database()) {
delete m_databaseOpenWidget->database();
}
Q_EMIT closeRequest();
emit closeRequest();
}
}
@ -767,13 +767,13 @@ void DatabaseWidget::mergeDatabase(bool accepted)
}
setCurrentWidget(m_mainWidget);
Q_EMIT databaseMerged(m_db);
emit databaseMerged(m_db);
}
void DatabaseWidget::unlockDatabase(bool accepted)
{
if (!accepted) {
Q_EMIT closeRequest();
emit closeRequest();
return;
}
@ -792,7 +792,7 @@ void DatabaseWidget::unlockDatabase(bool accepted)
setCurrentWidget(m_mainWidget);
m_unlockDatabaseWidget->clearForms();
Q_EMIT unlockedDatabase();
emit unlockedDatabase();
if (sender() == m_unlockDatabaseDialog) {
QList<Database*> dbList;
@ -914,7 +914,7 @@ void DatabaseWidget::search(const QString& searchtext)
return;
}
Q_EMIT searchModeAboutToActivate();
emit searchModeAboutToActivate();
Qt::CaseSensitivity caseSensitive = m_searchCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive;
@ -933,7 +933,7 @@ void DatabaseWidget::search(const QString& searchtext)
m_searchingLabel->setVisible(true);
Q_EMIT searchModeActivated();
emit searchModeActivated();
}
void DatabaseWidget::setSearchCaseSensitive(bool state)
@ -960,12 +960,12 @@ void DatabaseWidget::endSearch()
{
if (isInSearchMode())
{
Q_EMIT listModeAboutToActivate();
emit listModeAboutToActivate();
// Show the normal entry view of the current group
m_entryView->setGroup(currentGroup());
Q_EMIT listModeActivated();
emit listModeActivated();
}
m_searchingLabel->setVisible(false);
@ -976,12 +976,12 @@ void DatabaseWidget::endSearch()
void DatabaseWidget::emitGroupContextMenuRequested(const QPoint& pos)
{
Q_EMIT groupContextMenuRequested(m_groupView->viewport()->mapToGlobal(pos));
emit groupContextMenuRequested(m_groupView->viewport()->mapToGlobal(pos));
}
void DatabaseWidget::emitEntryContextMenuRequested(const QPoint& pos)
{
Q_EMIT entryContextMenuRequested(m_entryView->viewport()->mapToGlobal(pos));
emit entryContextMenuRequested(m_entryView->viewport()->mapToGlobal(pos));
}
bool DatabaseWidget::dbHasKey() const
@ -1030,7 +1030,7 @@ void DatabaseWidget::lock()
void DatabaseWidget::updateFilename(const QString& fileName)
{
if (! m_filename.isEmpty()) {
if (!m_filename.isEmpty()) {
m_fileWatcher.removePath(m_filename);
}
@ -1038,26 +1038,31 @@ void DatabaseWidget::updateFilename(const QString& fileName)
m_filename = fileName;
}
void DatabaseWidget::ignoreNextAutoreload()
void DatabaseWidget::blockAutoReload(bool block)
{
m_ignoreNextAutoreload = true;
m_ignoreWatchTimer.start(100);
if (block) {
m_ignoreAutoReload = true;
m_fileWatchTimer.stop();
} else {
m_fileWatchUnblockTimer.start(500);
}
}
void DatabaseWidget::unblockAutoReload()
{
m_ignoreAutoReload = false;
updateFilename(m_filename);
}
void DatabaseWidget::onWatchedFileChanged()
{
if (m_ignoreNextAutoreload) {
// Reset the watch
m_ignoreNextAutoreload = false;
m_ignoreWatchTimer.stop();
m_fileWatcher.addPath(m_filename);
if (m_ignoreAutoReload) {
return;
}
else {
if (m_fileWatchTimer.isActive())
return;
if (m_fileWatchTimer.isActive())
return;
m_fileWatchTimer.start(500);
}
m_fileWatchTimer.start(500);
}
void DatabaseWidget::reloadDatabaseFile()
@ -1197,7 +1202,7 @@ bool DatabaseWidget::currentEntryHasUsername()
Q_ASSERT(false);
return false;
}
return !currentEntry->resolvePlaceholder(currentEntry->username()).isEmpty();
return !currentEntry->resolveMultiplePlaceholders(currentEntry->username()).isEmpty();
}
bool DatabaseWidget::currentEntryHasPassword()
@ -1207,7 +1212,7 @@ bool DatabaseWidget::currentEntryHasPassword()
Q_ASSERT(false);
return false;
}
return !currentEntry->resolvePlaceholder(currentEntry->password()).isEmpty();
return !currentEntry->resolveMultiplePlaceholders(currentEntry->password()).isEmpty();
}
bool DatabaseWidget::currentEntryHasUrl()
@ -1217,7 +1222,7 @@ bool DatabaseWidget::currentEntryHasUrl()
Q_ASSERT(false);
return false;
}
return !currentEntry->resolvePlaceholder(currentEntry->url()).isEmpty();
return !currentEntry->resolveMultiplePlaceholders(currentEntry->url()).isEmpty();
}
bool DatabaseWidget::currentEntryHasNotes()
@ -1227,7 +1232,7 @@ bool DatabaseWidget::currentEntryHasNotes()
Q_ASSERT(false);
return false;
}
return !currentEntry->resolvePlaceholder(currentEntry->notes()).isEmpty();
return !currentEntry->resolveMultiplePlaceholders(currentEntry->notes()).isEmpty();
}
GroupView* DatabaseWidget::groupView() {

View file

@ -100,10 +100,10 @@ public:
EntryView* entryView();
void showUnlockDialog();
void closeUnlockDialog();
void ignoreNextAutoreload();
void blockAutoReload(bool block = true);
void refreshSearch();
Q_SIGNALS:
signals:
void closeRequest();
void currentModeChanged(DatabaseWidget::Mode mode);
void groupChanged();
@ -121,7 +121,7 @@ Q_SIGNALS:
void entryColumnSizesChanged();
void updateSearch(QString text);
public Q_SLOTS:
public slots:
void createEntry();
void cloneEntry();
void deleteEntries();
@ -161,7 +161,7 @@ public Q_SLOTS:
void showMessage(const QString& text, MessageWidget::MessageType type);
void hideMessage();
private Q_SLOTS:
private slots:
void entryActivationSignalReceived(Entry* entry, EntryModel::ModelColumn column);
void switchBackToEntryEdit();
void switchToHistoryView(Entry* entry);
@ -179,6 +179,7 @@ private Q_SLOTS:
void onWatchedFileChanged();
void reloadDatabaseFile();
void restoreGroupEntryFocus(Uuid groupUuid, Uuid EntryUuid);
void unblockAutoReload();
private:
void setClipboardTextAndMinimize(const QString& text);
@ -217,8 +218,8 @@ private:
// Autoreload
QFileSystemWatcher m_fileWatcher;
QTimer m_fileWatchTimer;
bool m_ignoreNextAutoreload;
QTimer m_ignoreWatchTimer;
QTimer m_fileWatchUnblockTimer;
bool m_ignoreAutoReload;
bool m_databaseModified;
};

View file

@ -29,12 +29,12 @@ public:
explicit DatabaseWidgetStateSync(QObject* parent = nullptr);
~DatabaseWidgetStateSync();
public Q_SLOTS:
public slots:
void setActive(DatabaseWidget* dbWidget);
void restoreListView();
void restoreSearchView();
private Q_SLOTS:
private slots:
void blockUpdates();
void updateSplitterSizes();
void updateColumnSizes();

View file

@ -34,7 +34,7 @@ protected:
void dropEvent(QDropEvent* event) override;
void tabLayoutChange() override;
private Q_SLOTS:
private slots:
void dragSwitchTab();
private:

View file

@ -48,9 +48,9 @@ EditWidgetIcons::EditWidgetIcons(QWidget* parent)
, m_defaultIconModel(new DefaultIconModel(this))
, m_customIconModel(new CustomIconModel(this))
#ifdef WITH_XC_HTTP
, m_httpClient(nullptr)
, m_fallbackToGoogle(true)
, m_redirectCount(0)
, m_httpClient(nullptr)
#endif
{
m_ui->setupUi(this);
@ -149,6 +149,7 @@ void EditWidgetIcons::setUrl(const QString& url)
m_ui->faviconButton->setVisible(!url.isEmpty());
resetFaviconDownload();
#else
Q_UNUSED(url);
m_ui->faviconButton->setVisible(false);
#endif
}
@ -275,7 +276,7 @@ void EditWidgetIcons::addCustomIcon()
m_ui->customIconsView->setCurrentIndex(index);
}
else {
Q_EMIT messageEditEntry(tr("Can't read icon"), MessageWidget::Error);
emit messageEditEntry(tr("Can't read icon"), MessageWidget::Error);
}
}
}

View file

@ -63,14 +63,14 @@ public:
void reset();
void load(const Uuid& currentUuid, Database* database, const IconStruct& iconStruct, const QString& url = "");
public Q_SLOTS:
public slots:
void setUrl(const QString& url);
Q_SIGNALS:
signals:
void messageEditEntry(QString, MessageWidget::MessageType);
void messageEditEntryDismiss();
private Q_SLOTS:
private slots:
void downloadFavicon();
#ifdef WITH_XC_HTTP
void fetchFavicon(const QUrl& url);

View file

@ -21,6 +21,7 @@
#include "KMessageWidget.h"
#include "core/FilePath.h"
#include "core/Global.h"
#include <QAction>
#include <QEvent>
@ -117,7 +118,8 @@ void KMessageWidgetPrivate::createLayout()
qDeleteAll(buttons);
buttons.clear();
Q_FOREACH (QAction *action, q->actions()) {
const auto actions = q->actions();
for (QAction *action: actions) {
QToolButton *button = new QToolButton(content);
button->setDefaultAction(action);
button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
@ -137,7 +139,7 @@ void KMessageWidgetPrivate::createLayout()
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addStretch();
Q_FOREACH (QToolButton *button, buttons) {
for (QToolButton* button: asConst(buttons)) {
// For some reason, calling show() is necessary if wordwrap is true,
// otherwise the buttons do not show up. It is not needed if
// wordwrap is false.
@ -151,7 +153,7 @@ void KMessageWidgetPrivate::createLayout()
layout->addWidget(iconLabel);
layout->addWidget(textLabel);
Q_FOREACH (QToolButton *button, buttons) {
for (QToolButton* button: asConst(buttons)) {
layout->addWidget(button);
}

View file

@ -224,7 +224,7 @@ public:
*/
bool isShowAnimationRunning() const;
public Q_SLOTS:
public slots:
/**
* Set the text of the message widget to @p text.
* If the message widget is already visible, the text changes on the fly.
@ -277,7 +277,7 @@ public Q_SLOTS:
*/
void setIcon(const QIcon &icon);
Q_SIGNALS:
signals:
/**
* This signal is emitted when the user clicks a link in the text label.
* The URL referred to by the href anchor is passed in contents.

View file

@ -62,7 +62,7 @@ void KeePass1OpenWidget::openDatabase()
if (m_db) {
m_db->metadata()->setName(QFileInfo(m_filename).completeBaseName());
Q_EMIT editFinished(true);
emit editFinished(true);
}
else {
m_ui->messageWidget->showMessage(tr("Unable to open the database.").append("\n")

View file

@ -34,7 +34,7 @@ public:
protected:
void resizeEvent(QResizeEvent* event) override;
private Q_SLOTS:
private slots:
void updateCloseButton(const QString& text);
private:

View file

@ -874,13 +874,15 @@ bool MainWindow::isTrayIconEnabled() const
#endif
}
void MainWindow::displayGlobalMessage(const QString& text, MessageWidget::MessageType type)
void MainWindow::displayGlobalMessage(const QString& text, MessageWidget::MessageType type, bool showClosebutton)
{
m_ui->globalMessageWidget->setCloseButtonVisible(showClosebutton);
m_ui->globalMessageWidget->showMessage(text, type);
}
void MainWindow::displayTabMessage(const QString& text, MessageWidget::MessageType type)
void MainWindow::displayTabMessage(const QString& text, MessageWidget::MessageType type, bool showClosebutton)
{
m_ui->globalMessageWidget->setCloseButtonVisible(showClosebutton);
m_ui->tabWidget->currentDatabaseWidget()->showMessage(text, type);
}
@ -896,3 +898,14 @@ void MainWindow::hideTabMessage()
}
}
void MainWindow::showYubiKeyPopup()
{
displayGlobalMessage(tr("Please touch the button on your YubiKey!"), MessageWidget::Information, false);
setEnabled(false);
}
void MainWindow::hideYubiKeyPopup()
{
hideGlobalMessage();
setEnabled(true);
}

View file

@ -24,6 +24,7 @@
#include "core/SignalMultiplexer.h"
#include "gui/DatabaseWidget.h"
#include "gui/Application.h"
namespace Ui {
class MainWindow;
@ -39,16 +40,21 @@ public:
MainWindow();
~MainWindow();
public Q_SLOTS:
public slots:
void openDatabase(const QString& fileName, const QString& pw = QString(),
const QString& keyFile = QString());
void appExit();
void displayGlobalMessage(const QString& text, MessageWidget::MessageType type, bool showClosebutton = true);
void displayTabMessage(const QString& text, MessageWidget::MessageType type, bool showClosebutton = true);
void hideGlobalMessage();
void showYubiKeyPopup();
void hideYubiKeyPopup();
protected:
void closeEvent(QCloseEvent* event) override;
void changeEvent(QEvent* event) override;
private Q_SLOTS:
private slots:
void setMenuActionState(DatabaseWidget::Mode mode = DatabaseWidget::None);
void updateWindowTitle();
void showAboutDialog();
@ -76,9 +82,6 @@ private Q_SLOTS:
void toggleWindow();
void lockDatabasesAfterInactivity();
void repairDatabase();
void displayGlobalMessage(const QString& text, MessageWidget::MessageType type);
void displayTabMessage(const QString& text, MessageWidget::MessageType type);
void hideGlobalMessage();
void hideTabMessage();
private:
@ -107,4 +110,7 @@ private:
bool appExitCalled;
};
#define KEEPASSXC_MAIN_WINDOW (qobject_cast<Application*>(qApp) ? \
qobject_cast<MainWindow*>(qobject_cast<Application*>(qApp)->mainWindow()) : nullptr)
#endif // KEEPASSX_MAINWINDOW_H

View file

@ -123,9 +123,7 @@
</spacer>
</item>
<item>
<widget class="WelcomeWidget" name="welcomeWidget" native="true">
<zorder>horizontalSpacer_2</zorder>
</widget>
<widget class="WelcomeWidget" name="welcomeWidget" native="true"/>
</item>
<item>
<spacer name="horizontalSpacer_2">

View file

@ -27,7 +27,7 @@ class MessageWidget : public KMessageWidget
public:
explicit MessageWidget(QWidget* parent = 0);
public Q_SLOTS:
public slots:
void showMessage(const QString& text, MessageWidget::MessageType type);
void hideMessage();

View file

@ -35,7 +35,7 @@ public:
void setNumberAlternatives(int alternatives);
void showPopup();
public Q_SLOTS:
public slots:
void setEcho(bool echo);
private:

View file

@ -69,7 +69,7 @@ void PasswordEdit::setShowPassword(bool show)
}
}
updateStylesheet();
Q_EMIT showPasswordChanged(show);
emit showPasswordChanged(show);
}
bool PasswordEdit::passwordsEqual() const

View file

@ -31,13 +31,13 @@ public:
explicit PasswordEdit(QWidget* parent = nullptr);
void enableVerifyMode(PasswordEdit* baseEdit);
public Q_SLOTS:
public slots:
void setShowPassword(bool show);
Q_SIGNALS:
signals:
void showPasswordChanged(bool show);
private Q_SLOTS:
private slots:
void updateStylesheet();
void autocompletePassword(QString password);

View file

@ -145,8 +145,8 @@ void PasswordGeneratorWidget::generatePassword()
void PasswordGeneratorWidget::applyPassword()
{
saveSettings();
Q_EMIT appliedPassword(m_ui->editNewPassword->text());
Q_EMIT dialogTerminated();
emit appliedPassword(m_ui->editNewPassword->text());
emit dialogTerminated();
}
void PasswordGeneratorWidget::sliderMoved()

View file

@ -43,11 +43,11 @@ public:
void setStandaloneMode(bool standalone);
void regeneratePassword();
Q_SIGNALS:
signals:
void appliedPassword(const QString& password);
void dialogTerminated();
private Q_SLOTS:
private slots:
void applyPassword();
void generatePassword();
void updateApplyEnabled(const QString& password);

View file

@ -23,6 +23,7 @@
#include "core/Config.h"
#include "core/Translator.h"
#include "core/FilePath.h"
#include "core/Global.h"
class SettingsWidget::ExtraPage
{
@ -144,8 +145,9 @@ void SettingsWidget::loadSettings()
m_secUi->passwordRepeatCheckBox->setChecked(config()->get("security/passwordsrepeat").toBool());
Q_FOREACH (const ExtraPage& page, m_extraPages)
for (const ExtraPage& page: asConst(m_extraPages)) {
page.loadSettings();
}
setCurrentPage(0);
}
@ -190,10 +192,11 @@ void SettingsWidget::saveSettings()
config()->set("security/passwordscleartext", m_secUi->passwordCleartextCheckBox->isChecked());
config()->set("security/passwordsrepeat", m_secUi->passwordRepeatCheckBox->isChecked());
Q_FOREACH (const ExtraPage& page, m_extraPages)
for (const ExtraPage& page: asConst(m_extraPages)) {
page.saveSettings();
}
Q_EMIT editFinished(true);
emit editFinished(true);
}
void SettingsWidget::reject()
@ -203,7 +206,7 @@ void SettingsWidget::reject()
autoType()->registerGlobalShortcut(m_globalAutoTypeKey, m_globalAutoTypeModifiers);
}
Q_EMIT editFinished(false);
emit editFinished(false);
}
void SettingsWidget::enableAutoSaveOnExit(bool checked)

View file

@ -45,10 +45,10 @@ public:
void addSettingsPage(ISettingsPage * page);
void loadSettings();
Q_SIGNALS:
signals:
void editFinished(bool accepted);
private Q_SLOTS:
private slots:
void saveSettings();
void reject();
void enableAutoSaveOnExit(bool checked);

View file

@ -49,7 +49,7 @@ void UnlockDatabaseDialog::complete(bool r)
{
if (r) {
accept();
Q_EMIT unlockDone(true);
emit unlockDone(true);
} else {
reject();
}

View file

@ -36,10 +36,10 @@ public:
void clearForms();
Database* database();
Q_SIGNALS:
signals:
void unlockDone(bool);
public Q_SLOTS:
public slots:
void complete(bool r);
private:

View file

@ -33,6 +33,7 @@ void UnlockDatabaseWidget::clearForms()
m_ui->comboKeyFile->clear();
m_ui->checkPassword->setChecked(false);
m_ui->checkKeyFile->setChecked(false);
m_ui->checkChallengeResponse->setChecked(false);
m_ui->buttonTogglePassword->setChecked(false);
m_db = nullptr;
}

View file

@ -64,5 +64,5 @@ void WelcomeWidget::openDatabaseFromFile(QListWidgetItem* item)
if (item->text().isEmpty()) {
return;
}
Q_EMIT openDatabaseFile(item->text());
emit openDatabaseFile(item->text());
}

View file

@ -33,13 +33,13 @@ public:
explicit WelcomeWidget(QWidget* parent = nullptr);
~WelcomeWidget();
Q_SIGNALS:
signals:
void newDatabase();
void openDatabase();
void openDatabaseFile(QString);
void importKeePass1Database();
private Q_SLOTS:
private slots:
void openDatabaseFromFile(QListWidgetItem* item);
private:

View file

@ -103,7 +103,7 @@ QVariant AutoTypeAssociationsModel::data(const QModelIndex& index, int role) con
void AutoTypeAssociationsModel::associationChange(int i)
{
Q_EMIT dataChanged(index(i, 0), index(i, columnCount() - 1));
emit dataChanged(index(i, 0), index(i, columnCount() - 1));
}
void AutoTypeAssociationsModel::associationAboutToAdd(int i)

View file

@ -36,7 +36,7 @@ public:
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
public Q_SLOTS:
public slots:
void associationChange(int i);
void associationAboutToAdd(int i);
void associationAdd();

View file

@ -212,7 +212,7 @@ void EditEntryWidget::emitHistoryEntryActivated(const QModelIndex& index)
Q_ASSERT(!m_history);
Entry* entry = m_historyModel->entryFromIndex(index);
Q_EMIT historyEntryActivated(entry);
emit historyEntryActivated(entry);
}
void EditEntryWidget::histEntryActivated(const QModelIndex& index)
@ -407,7 +407,7 @@ void EditEntryWidget::saveEntry()
if (m_history) {
clear();
hideMessage();
Q_EMIT editFinished(false);
emit editFinished(false);
return;
}
@ -442,7 +442,7 @@ void EditEntryWidget::saveEntry()
clear();
Q_EMIT editFinished(true);
emit editFinished(true);
}
void EditEntryWidget::updateEntryData(Entry* entry) const
@ -487,7 +487,7 @@ void EditEntryWidget::cancel()
if (m_history) {
clear();
hideMessage();
Q_EMIT editFinished(false);
emit editFinished(false);
return;
}
@ -498,7 +498,7 @@ void EditEntryWidget::cancel()
clear();
Q_EMIT editFinished(false);
emit editFinished(false);
}
void EditEntryWidget::clear()

View file

@ -63,11 +63,11 @@ public:
void clear();
bool hasBeenModified() const;
Q_SIGNALS:
signals:
void editFinished(bool accepted);
void historyEntryActivated(Entry* entry);
private Q_SLOTS:
private slots:
void saveEntry();
void cancel();
void togglePasswordGeneratorButton(bool checked);

View file

@ -259,11 +259,6 @@
</layout>
</item>
</layout>
<zorder></zorder>
<zorder></zorder>
<zorder></zorder>
<zorder></zorder>
<zorder></zorder>
</widget>
</item>
</layout>

View file

@ -97,7 +97,7 @@ QString EntryAttachmentsModel::keyByIndex(const QModelIndex& index) const
void EntryAttachmentsModel::attachmentChange(const QString& key)
{
int row = m_entryAttachments->keys().indexOf(key);
Q_EMIT dataChanged(index(row, 0), index(row, columnCount()-1));
emit dataChanged(index(row, 0), index(row, columnCount()-1));
}
void EntryAttachmentsModel::attachmentAboutToAdd(const QString& key)

View file

@ -34,7 +34,7 @@ public:
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
QString keyByIndex(const QModelIndex& index) const;
private Q_SLOTS:
private slots:
void attachmentChange(const QString& key);
void attachmentAboutToAdd(const QString& key);
void attachmentAdd();

View file

@ -147,7 +147,7 @@ void EntryAttributesModel::attributeChange(const QString& key)
{
int row = m_attributes.indexOf(key);
Q_ASSERT(row != -1);
Q_EMIT dataChanged(index(row, 0), index(row, columnCount()-1));
emit dataChanged(index(row, 0), index(row, columnCount()-1));
}
void EntryAttributesModel::attributeAboutToAdd(const QString& key)
@ -213,7 +213,7 @@ void EntryAttributesModel::attributeRename(const QString& oldKey, const QString&
m_nextRenameDataChange = false;
QModelIndex keyIndex = index(m_attributes.indexOf(newKey), 0);
Q_EMIT dataChanged(keyIndex, keyIndex);
emit dataChanged(keyIndex, keyIndex);
}
}

View file

@ -38,7 +38,7 @@ public:
QModelIndex indexByKey(const QString& key) const;
QString keyByIndex(const QModelIndex& index) const;
private Q_SLOTS:
private slots:
void attributeChange(const QString& key);
void attributeAboutToAdd(const QString& key);
void attributeAdd();

View file

@ -64,7 +64,7 @@ void EntryModel::setGroup(Group* group)
makeConnections(group);
endResetModel();
Q_EMIT switchedToGroupMode();
emit switchedToGroupMode();
}
void EntryModel::setEntryList(const QList<Entry*>& entries)
@ -101,7 +101,7 @@ void EntryModel::setEntryList(const QList<Entry*>& entries)
}
endResetModel();
Q_EMIT switchedToEntryListMode();
emit switchedToEntryListMode();
}
int EntryModel::rowCount(const QModelIndex& parent) const
@ -139,19 +139,19 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
}
break;
case Title:
result = entry->resolvePlaceholder(entry->title());
result = entry->resolveMultiplePlaceholders(entry->title());
if (attr->isReference(EntryAttributes::TitleKey)) {
result.prepend(tr("Ref: ","Reference abbreviation"));
}
return result;
case Username:
result = entry->resolvePlaceholder(entry->username());
result = entry->resolveMultiplePlaceholders(entry->username());
if (attr->isReference(EntryAttributes::UserNameKey)) {
result.prepend(tr("Ref: ","Reference abbreviation"));
}
return result;
case Url:
result = entry->resolvePlaceholder(entry->url());
result = entry->resolveMultiplePlaceholders(entry->url());
if (attr->isReference(EntryAttributes::URLKey)) {
result.prepend(tr("Ref: ","Reference abbreviation"));
}
@ -315,7 +315,7 @@ void EntryModel::entryRemoved()
void EntryModel::entryDataChanged(Entry* entry)
{
int row = m_entries.indexOf(entry);
Q_EMIT dataChanged(index(row, 0), index(row, columnCount()-1));
emit dataChanged(index(row, 0), index(row, columnCount()-1));
}
void EntryModel::severConnections()

View file

@ -52,14 +52,14 @@ public:
void setEntryList(const QList<Entry*>& entries);
Q_SIGNALS:
signals:
void switchedToEntryListMode();
void switchedToGroupMode();
public Q_SLOTS:
public slots:
void setGroup(Group* group);
private Q_SLOTS:
private slots:
void entryAboutToAdd(Entry* entry);
void entryAdded(Entry* entry);
void entryAboutToRemove(Entry* entry);

View file

@ -57,7 +57,7 @@ void EntryView::keyPressEvent(QKeyEvent* event)
emitEntryActivated(currentIndex());
#ifdef Q_OS_MAC
// Pressing return does not emit the QTreeView::activated signal on mac os
Q_EMIT activated(currentIndex());
emit activated(currentIndex());
#endif
}
@ -83,7 +83,7 @@ void EntryView::setFirstEntryActive()
setCurrentEntry(m_model->entryFromIndex(index));
}
else {
Q_EMIT entrySelectionChanged();
emit entrySelectionChanged();
}
}
@ -96,7 +96,7 @@ void EntryView::emitEntryActivated(const QModelIndex& index)
{
Entry* entry = entryFromIndex(index);
Q_EMIT entryActivated(entry, static_cast<EntryModel::ModelColumn>(m_sortModel->mapToSource(index).column()));
emit entryActivated(entry, static_cast<EntryModel::ModelColumn>(m_sortModel->mapToSource(index).column()));
}
void EntryView::setModel(QAbstractItemModel* model)

View file

@ -42,17 +42,17 @@ public:
int numberOfSelectedEntries();
void setFirstEntryActive();
public Q_SLOTS:
public slots:
void setGroup(Group* group);
Q_SIGNALS:
signals:
void entryActivated(Entry* entry, EntryModel::ModelColumn column);
void entrySelectionChanged();
protected:
void keyPressEvent(QKeyEvent* event) override;
private Q_SLOTS:
private slots:
void emitEntryActivated(const QModelIndex& index);
void switchToEntryListMode();
void switchToGroupMode();

View file

@ -130,7 +130,7 @@ void EditGroupWidget::save()
}
clear();
Q_EMIT editFinished(true);
emit editFinished(true);
}
void EditGroupWidget::cancel()
@ -141,7 +141,7 @@ void EditGroupWidget::cancel()
}
clear();
Q_EMIT editFinished(false);
emit editFinished(false);
}
void EditGroupWidget::clear()

View file

@ -43,12 +43,12 @@ public:
void loadGroup(Group* group, bool create, Database* database);
void clear();
Q_SIGNALS:
signals:
void editFinished(bool accepted);
void messageEditEntry(QString, MessageWidget::MessageType);
void messageEditEntryDismiss();
private Q_SLOTS:
private slots:
void save();
void cancel();

View file

@ -365,7 +365,7 @@ QMimeData* GroupModel::mimeData(const QModelIndexList& indexes) const
void GroupModel::groupDataChanged(Group* group)
{
QModelIndex ix = index(group);
Q_EMIT dataChanged(ix, ix);
emit dataChanged(ix, ix);
}
void GroupModel::groupAboutToRemove(Group* group)

View file

@ -49,7 +49,7 @@ public:
private:
QModelIndex parent(Group* group) const;
private Q_SLOTS:
private slots:
void groupDataChanged(Group* group);
void groupAboutToRemove(Group* group);
void groupRemoved();

View file

@ -112,7 +112,7 @@ void GroupView::expandGroup(Group* group, bool expand)
void GroupView::emitGroupChanged(const QModelIndex& index)
{
Q_EMIT groupChanged(m_model->groupFromIndex(index));
emit groupChanged(m_model->groupFromIndex(index));
}
void GroupView::setModel(QAbstractItemModel* model)
@ -123,7 +123,7 @@ void GroupView::setModel(QAbstractItemModel* model)
void GroupView::emitGroupChanged()
{
Q_EMIT groupChanged(currentGroup());
emit groupChanged(currentGroup());
}
void GroupView::syncExpandedState(const QModelIndex& parent, int start, int end)

View file

@ -36,10 +36,10 @@ public:
void setCurrentGroup(Group* group);
void expandGroup(Group* group, bool expand = true);
Q_SIGNALS:
signals:
void groupChanged(Group* group);
private Q_SLOTS:
private slots:
void expandedChanged(const QModelIndex& index);
void emitGroupChanged(const QModelIndex& index);
void emitGroupChanged();