Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/DatabaseOpenWidget.cpp18
-rw-r--r--src/gui/DatabaseOpenWidget.h1
-rw-r--r--src/gui/DatabaseRepairWidget.cpp6
-rw-r--r--src/gui/DatabaseTabWidget.cpp16
-rw-r--r--src/gui/DatabaseWidget.cpp2
-rw-r--r--src/gui/MainWindow.cpp2
-rw-r--r--src/gui/PasswordEdit.cpp13
-rw-r--r--src/gui/entry/EditEntryWidget.cpp4
-rw-r--r--src/gui/entry/EditEntryWidget.h1
9 files changed, 44 insertions, 19 deletions
diff --git a/src/gui/DatabaseOpenWidget.cpp b/src/gui/DatabaseOpenWidget.cpp
index ee0e9de26..e487f97ca 100644
--- a/src/gui/DatabaseOpenWidget.cpp
+++ b/src/gui/DatabaseOpenWidget.cpp
@@ -95,11 +95,16 @@ void DatabaseOpenWidget::showEvent(QShowEvent* event)
m_ui->editPassword->setFocus();
#ifdef WITH_XC_YUBIKEY
- connect(YubiKey::instance(), SIGNAL(detected(int,bool)), SLOT(yubikeyDetected(int,bool)), Qt::QueuedConnection);
- connect(YubiKey::instance(), SIGNAL(detectComplete()), SLOT(yubikeyDetectComplete()), Qt::QueuedConnection);
- connect(YubiKey::instance(), SIGNAL(notFound()), SLOT(noYubikeyFound()), Qt::QueuedConnection);
-
- pollYubikey();
+ // showEvent() may be called twice, so make sure we are only polling once
+ if (!m_yubiKeyBeingPolled) {
+ connect(YubiKey::instance(), SIGNAL(detected(int, bool)), SLOT(yubikeyDetected(int, bool)),
+ Qt::QueuedConnection);
+ connect(YubiKey::instance(), SIGNAL(detectComplete()), SLOT(yubikeyDetectComplete()), Qt::QueuedConnection);
+ connect(YubiKey::instance(), SIGNAL(notFound()), SLOT(noYubikeyFound()), Qt::QueuedConnection);
+
+ pollYubikey();
+ m_yubiKeyBeingPolled = true;
+ }
#endif
}
@@ -110,6 +115,7 @@ void DatabaseOpenWidget::hideEvent(QHideEvent* event)
#ifdef WITH_XC_YUBIKEY
// Don't listen to any Yubikey events if we are hidden
disconnect(YubiKey::instance(), 0, this, 0);
+ m_yubiKeyBeingPolled = false;
#endif
}
@@ -311,10 +317,12 @@ void DatabaseOpenWidget::yubikeyDetectComplete()
m_ui->checkChallengeResponse->setEnabled(true);
m_ui->buttonRedetectYubikey->setEnabled(true);
m_ui->yubikeyProgress->setVisible(false);
+ m_yubiKeyBeingPolled = false;
}
void DatabaseOpenWidget::noYubikeyFound()
{
m_ui->buttonRedetectYubikey->setEnabled(true);
m_ui->yubikeyProgress->setVisible(false);
+ m_yubiKeyBeingPolled = false;
}
diff --git a/src/gui/DatabaseOpenWidget.h b/src/gui/DatabaseOpenWidget.h
index a7691a91e..aade111c3 100644
--- a/src/gui/DatabaseOpenWidget.h
+++ b/src/gui/DatabaseOpenWidget.h
@@ -73,6 +73,7 @@ protected:
QString m_filename;
private:
+ bool m_yubiKeyBeingPolled = false;
Q_DISABLE_COPY(DatabaseOpenWidget)
};
diff --git a/src/gui/DatabaseRepairWidget.cpp b/src/gui/DatabaseRepairWidget.cpp
index 2b0039408..d3dddf14f 100644
--- a/src/gui/DatabaseRepairWidget.cpp
+++ b/src/gui/DatabaseRepairWidget.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 Felix Geyer <debfx@fobos.de>
+ * Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
*
* 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
@@ -69,7 +70,8 @@ void DatabaseRepairWidget::openDatabase()
delete m_db;
}
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
- KeePass2Repair::RepairResult repairResult = repair.repairDatabase(&file, masterKey);
+ auto repairOutcome = repair.repairDatabase(&file, masterKey);
+ KeePass2Repair::RepairResult repairResult = repairOutcome.first;
QApplication::restoreOverrideCursor();
switch (repairResult) {
@@ -83,7 +85,7 @@ void DatabaseRepairWidget::openDatabase()
emit editFinished(false);
return;
case KeePass2Repair::RepairSuccess:
- m_db = repair.database();
+ m_db = repairOutcome.second;
MessageBox::warning(this, tr("Success"), tr("The database has been successfully repaired\nYou can now save it."));
emit editFinished(true);
return;
diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp
index 4c9445ccc..f70df4c79 100644
--- a/src/gui/DatabaseTabWidget.cpp
+++ b/src/gui/DatabaseTabWidget.cpp
@@ -298,8 +298,7 @@ bool DatabaseTabWidget::closeDatabase(Database* db)
if (!saveDatabase(db)) {
return false;
}
- }
- else {
+ } else if (dbStruct.dbWidget->currentMode() != DatabaseWidget::LockedMode) {
QMessageBox::StandardButton result =
MessageBox::question(
this, tr("Save changes?"),
@@ -307,10 +306,9 @@ bool DatabaseTabWidget::closeDatabase(Database* db)
QMessageBox::Yes | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Yes);
if (result == QMessageBox::Yes) {
if (!saveDatabase(db)) {
- return false;
+ return false;
}
- }
- else if (result == QMessageBox::Cancel) {
+ } else if (result == QMessageBox::Cancel) {
return false;
}
}
@@ -355,8 +353,13 @@ bool DatabaseTabWidget::saveDatabase(Database* db)
{
DatabaseManagerStruct& dbStruct = m_dbList[db];
- if (dbStruct.saveToFilename) {
+ if (dbStruct.dbWidget->currentMode() == DatabaseWidget::LockedMode) {
+ // Never allow saving a locked database; it causes corruption
+ // We return true since a save is not required
+ return true;
+ }
+ if (dbStruct.saveToFilename) {
dbStruct.dbWidget->blockAutoReload(true);
QString errorMessage = db->saveToFile(dbStruct.canonicalFilePath);
dbStruct.dbWidget->blockAutoReload(false);
@@ -375,7 +378,6 @@ bool DatabaseTabWidget::saveDatabase(Database* db)
MessageWidget::Error);
return false;
}
-
} else {
return saveDatabaseAs(db);
}
diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp
index 3a39bddcf..453b2009b 100644
--- a/src/gui/DatabaseWidget.cpp
+++ b/src/gui/DatabaseWidget.cpp
@@ -1125,7 +1125,7 @@ void DatabaseWidget::onWatchedFileChanged()
void DatabaseWidget::reloadDatabaseFile()
{
- if (m_db == nullptr)
+ if (m_db == nullptr || currentMode() == DatabaseWidget::LockedMode)
return;
if (! config()->get("AutoReloadOnChange").toBool()) {
diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp
index f1d5f866c..e37a7d28c 100644
--- a/src/gui/MainWindow.cpp
+++ b/src/gui/MainWindow.cpp
@@ -881,7 +881,7 @@ void MainWindow::toggleWindow()
raise();
activateWindow();
-#if defined(Q_OS_LINUX) && ! defined(QT_NO_DBUS)
+#if defined(Q_OS_LINUX) && ! defined(QT_NO_DBUS) && (QT_VERSION < QT_VERSION_CHECK(5, 9, 0))
// re-register global D-Bus menu (needed on Ubuntu with Unity)
// see https://github.com/keepassxreboot/keepassxc/issues/271
// and https://bugreports.qt.io/browse/QTBUG-58723
diff --git a/src/gui/PasswordEdit.cpp b/src/gui/PasswordEdit.cpp
index 54b0ca288..ad736bf20 100644
--- a/src/gui/PasswordEdit.cpp
+++ b/src/gui/PasswordEdit.cpp
@@ -31,9 +31,18 @@ PasswordEdit::PasswordEdit(QWidget* parent)
{
setEchoMode(QLineEdit::Password);
updateStylesheet();
-
- // set font to system monospace font and increase letter spacing
+
+ // use a monospace font for the password field
QFont passwordFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
+#ifdef Q_OS_WIN
+ // try to use Consolas on Windows, because the default Courier New has too many similar characters
+ QFont consolasFont = QFontDatabase().font("Consolas", passwordFont.styleName(), passwordFont.pointSize());
+ const QFont defaultFont;
+ if (passwordFont != defaultFont) {
+ passwordFont = consolasFont;
+ }
+#endif
+
passwordFont.setLetterSpacing(QFont::PercentageSpacing, 110);
setFont(passwordFont);
}
diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp
index 809ac95eb..5a058bda4 100644
--- a/src/gui/entry/EditEntryWidget.cpp
+++ b/src/gui/entry/EditEntryWidget.cpp
@@ -278,6 +278,7 @@ void EditEntryWidget::loadEntry(Entry* entry, bool create, bool history, const Q
m_database = database;
m_create = create;
m_history = history;
+ m_saved = false;
if (history) {
setHeadline(QString("%1 > %2").arg(parentName, tr("Entry history")));
@@ -438,6 +439,7 @@ void EditEntryWidget::saveEntry()
}
updateEntryData(m_entry);
+ m_saved = true;
if (!m_create) {
m_entry->endUpdate();
@@ -510,7 +512,7 @@ void EditEntryWidget::cancel()
clear();
- emit editFinished(false);
+ emit editFinished(m_saved);
}
void EditEntryWidget::clear()
diff --git a/src/gui/entry/EditEntryWidget.h b/src/gui/entry/EditEntryWidget.h
index 2888d43a8..628f8f8ed 100644
--- a/src/gui/entry/EditEntryWidget.h
+++ b/src/gui/entry/EditEntryWidget.h
@@ -121,6 +121,7 @@ private:
bool m_create;
bool m_history;
+ bool m_saved;
const QScopedPointer<Ui::EditEntryWidgetMain> m_mainUi;
const QScopedPointer<Ui::EditEntryWidgetAdvanced> m_advancedUi;
const QScopedPointer<Ui::EditEntryWidgetAutoType> m_autoTypeUi;