From d4ed4f93255e51ed7a7986e6040f240ac6488670 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Wed, 25 May 2016 16:55:06 +0200 Subject: [PATCH 1/2] 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(); From 029da87346518d122fbe7f0c10e73b9ce3644311 Mon Sep 17 00:00:00 2001 From: Daniel Landau Date: Tue, 14 Apr 2015 18:27:49 +0300 Subject: [PATCH 2/2] Save and exit entry editing with Ctrl+Return When the cursor is on most fields, you can use Return to end editing and save, but on the Notes field Return just changes the line. This commit adds a shortcut to the whole widget to save with Ctrl+Return, so that saving and exiting is quick even when editing notes. --- src/gui/entry/EditEntryWidget.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index 00d510cfc..5ad612cfc 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -98,6 +98,11 @@ void EditEntryWidget::setupMain() m_mainUi->expirePresets->setMenu(createPresetsMenu()); connect(m_mainUi->expirePresets->menu(), SIGNAL(triggered(QAction*)), this, SLOT(useExpiryPreset(QAction*))); + QAction *action = new QAction(this); + action->setShortcut(Qt::CTRL | Qt::Key_Return); + connect(action, SIGNAL(triggered()), this, SLOT(saveEntry())); + this->addAction(action); + m_mainUi->passwordGenerator->hide(); m_mainUi->passwordGenerator->reset(); }