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: 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(); 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() 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(); } 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; } } 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) {