From 9b8912c4831034840c4dcd2b2f83536fe05f3de9 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Sat, 13 Feb 2016 11:13:15 +0100 Subject: [PATCH 1/6] Print libXtst instead of libXtest in the feature summary. The protocol is called XTEST but the library libxtst. Closes #440 # Conflicts: # src/autotype/CMakeLists.txt --- src/autotype/CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/autotype/CMakeLists.txt b/src/autotype/CMakeLists.txt index 707edf910..1e33dd494 100644 --- a/src/autotype/CMakeLists.txt +++ b/src/autotype/CMakeLists.txt @@ -1,12 +1,14 @@ if(UNIX AND NOT APPLE) find_package(X11) find_package(Qt5X11Extras 5.2) - add_feature_info(libXi X11_Xi_FOUND "The X11 Xi Protocol library is required for auto-type") - add_feature_info(libXtest X11_XTest_FOUND "The X11 XTEST Protocol library is required for auto-type") - add_feature_info(Qt5X11Extras Qt5X11Extras_FOUND "The Qt5X11Extras library is required for auto-type") + if(PRINT_SUMMARY) + add_feature_info(libXi X11_Xi_FOUND "The X11 Xi Protocol library is required for auto-type") + add_feature_info(libXtst X11_XTest_FOUND "The X11 XTEST Protocol library is required for auto-type") + add_feature_info(Qt5X11Extras Qt5X11Extras_FOUND "The Qt5X11Extras library is required for auto-type") + endif() if(X11_FOUND AND X11_Xi_FOUND AND X11_XTest_FOUND AND Qt5X11Extras_FOUND) - add_subdirectory(xcb) + add_subdirectory(x11) endif() endif() From d61e4d69b5048a648831ae9f9c2428ccfbeea8b8 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Sat, 13 Feb 2016 11:24:11 +0100 Subject: [PATCH 2/6] Update optional dependencies in the README. # Conflicts: # README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bf64cd611..d791123bd 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ The following libraries are required: * zlib * libmicrohttpd * libxtst (optional for auto-type on X11) -* libxtst, qtx11extras (optional for auto-type on X11) +* libxi, libxtst, qtx11extras (optional for auto-type on X11) On Debian you can install them with: From 8a7e98820a0ce058c01555405c42a5640e34ed2b Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Sat, 9 Apr 2016 16:02:49 +0200 Subject: [PATCH 3/6] Fix typo. # Conflicts: # src/format/KeePass2Reader.cpp --- src/format/KeePass2Reader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/format/KeePass2Reader.cpp b/src/format/KeePass2Reader.cpp index 00ebc0708..b0247f788 100644 --- a/src/format/KeePass2Reader.cpp +++ b/src/format/KeePass2Reader.cpp @@ -191,7 +191,7 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke if (!xmlReader.headerHash().isEmpty()) { QByteArray headerHash = CryptoHash::hash(headerStream.storedData(), CryptoHash::Sha256); if (headerHash != xmlReader.headerHash()) { - raiseError("Head doesn't match hash"); + raiseError("Header doesn't match hash"); return nullptr; } } From ba68e0a4a18e2f2cfa72237529714af5cffd360a Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Sat, 9 Apr 2016 16:03:03 +0200 Subject: [PATCH 4/6] Show proper error message when key is wrong for .kdb files. --- src/format/KeePass1Reader.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/format/KeePass1Reader.cpp b/src/format/KeePass1Reader.cpp index 89775b507..27c6d1469 100644 --- a/src/format/KeePass1Reader.cpp +++ b/src/format/KeePass1Reader.cpp @@ -380,6 +380,10 @@ SymmetricCipherStream* KeePass1Reader::testKeys(const QString& password, const Q } } + if (!cipherStream) { + raiseError(tr("Wrong key or database file is corrupt.")); + } + return cipherStream.take(); } From 34150730518e4d307d618d025505b2a0d1afb97a Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Fri, 20 May 2016 16:49:32 +0200 Subject: [PATCH 5/6] Display an error message when opening the database fails. Closes #462 --- src/gui/DatabaseOpenWidget.cpp | 3 ++- src/gui/DatabaseRepairWidget.cpp | 3 ++- src/gui/DatabaseTabWidget.cpp | 5 ++--- src/gui/KeePass1OpenWidget.cpp | 3 ++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/gui/DatabaseOpenWidget.cpp b/src/gui/DatabaseOpenWidget.cpp index beb8d54c6..a4b22074f 100644 --- a/src/gui/DatabaseOpenWidget.cpp +++ b/src/gui/DatabaseOpenWidget.cpp @@ -100,7 +100,8 @@ void DatabaseOpenWidget::openDatabase() QFile file(m_filename); if (!file.open(QIODevice::ReadOnly)) { - // TODO: error message + MessageBox::warning(this, tr("Error"), tr("Unable to open the database.").append("\n") + .append(file.errorString())); return; } if (m_db) { diff --git a/src/gui/DatabaseRepairWidget.cpp b/src/gui/DatabaseRepairWidget.cpp index f1b760f99..e48e0f1f6 100644 --- a/src/gui/DatabaseRepairWidget.cpp +++ b/src/gui/DatabaseRepairWidget.cpp @@ -60,7 +60,8 @@ void DatabaseRepairWidget::openDatabase() QFile file(m_filename); if (!file.open(QIODevice::ReadOnly)) { - // TODO: error message + MessageBox::warning(this, tr("Error"), tr("Unable to open the database.").append("\n") + .append(file.errorString())); Q_EMIT editFinished(false); return; } diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp index 69b4f7e72..78a3a12a1 100644 --- a/src/gui/DatabaseTabWidget.cpp +++ b/src/gui/DatabaseTabWidget.cpp @@ -132,11 +132,10 @@ void DatabaseTabWidget::openDatabase(const QString& fileName, const QString& pw, // test if we can read/write or read the file QFile file(fileName); - // TODO: error handling if (!file.open(QIODevice::ReadWrite)) { if (!file.open(QIODevice::ReadOnly)) { - // can't open - // TODO: error message + MessageBox::warning(this, tr("Error"), tr("Unable to open the database.").append("\n") + .append(file.errorString())); return; } else { diff --git a/src/gui/KeePass1OpenWidget.cpp b/src/gui/KeePass1OpenWidget.cpp index 96ddf13f2..4f70a9787 100644 --- a/src/gui/KeePass1OpenWidget.cpp +++ b/src/gui/KeePass1OpenWidget.cpp @@ -49,7 +49,8 @@ void KeePass1OpenWidget::openDatabase() QFile file(m_filename); if (!file.open(QIODevice::ReadOnly)) { - // TODO: error message + MessageBox::warning(this, tr("Error"), tr("Unable to open the database.").append("\n") + .append(file.errorString())); return; } if (m_db) { From c2a80ce570e79deb88d6da803057f21ae17f86ae Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Wed, 25 May 2016 16:55:06 +0200 Subject: [PATCH 6/6] Remember auto-type window size. Resize columns once when the entry list is set. Based on https://github.com/keepassx/keepassx/pull/158 Closes #478 --- src/autotype/AutoTypeSelectDialog.cpp | 18 ++++++++++++++++-- src/autotype/AutoTypeSelectDialog.h | 3 +++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/autotype/AutoTypeSelectDialog.cpp b/src/autotype/AutoTypeSelectDialog.cpp index 3e7a24768..61b534b9d 100644 --- a/src/autotype/AutoTypeSelectDialog.cpp +++ b/src/autotype/AutoTypeSelectDialog.cpp @@ -20,10 +20,12 @@ #include #include #include +#include #include #include #include "autotype/AutoTypeSelectView.h" +#include "core/Config.h" #include "core/FilePath.h" #include "gui/entry/EntryModel.h" @@ -39,11 +41,14 @@ AutoTypeSelectDialog::AutoTypeSelectDialog(QWidget* parent) setWindowTitle(tr("Auto-Type - KeePassX")); setWindowIcon(filePath()->applicationIcon()); - QSize size(400, 250); + QRect screenGeometry = QApplication::desktop()->availableGeometry(QCursor::pos()); + QSize size = config()->get("GUI/AutoTypeSelectDialogSize", QSize(400, 250)).toSize(); + size.setWidth(qMin(size.width(), screenGeometry.width())); + size.setHeight(qMin(size.height(), screenGeometry.height())); resize(size); // move dialog to the center of the screen - QPoint screenCenter = QApplication::desktop()->availableGeometry(QCursor::pos()).center(); + QPoint screenCenter = screenGeometry.center(); move(screenCenter.x() - (size.width() / 2), screenCenter.y() - (size.height() / 2)); QVBoxLayout* layout = new QVBoxLayout(this); @@ -65,6 +70,15 @@ void AutoTypeSelectDialog::setEntries(const QList& entries, const QHash< { m_sequences = sequences; m_view->setEntryList(entries); + + m_view->header()->resizeSections(QHeaderView::ResizeToContents); +} + +void AutoTypeSelectDialog::done(int r) +{ + config()->set("GUI/AutoTypeSelectDialogSize", size()); + + QDialog::done(r); } void AutoTypeSelectDialog::emitEntryActivated(const QModelIndex& index) diff --git a/src/autotype/AutoTypeSelectDialog.h b/src/autotype/AutoTypeSelectDialog.h index c0dbfe473..7b3909a19 100644 --- a/src/autotype/AutoTypeSelectDialog.h +++ b/src/autotype/AutoTypeSelectDialog.h @@ -36,6 +36,9 @@ public: Q_SIGNALS: void entryActivated(Entry* entry, const QString& sequence); +public Q_SLOTS: + void done(int r) override; + private Q_SLOTS: void emitEntryActivated(const QModelIndex& index); void entryRemoved();