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
diff options
context:
space:
mode:
authorJonathan White <support@dmapps.us>2021-05-16 16:15:31 +0300
committerJonathan White <support@dmapps.us>2021-05-16 20:29:21 +0300
commit8f0e0b6f94f46dc085f7daa13568569cb12a4206 (patch)
treedc0539f34fc35882a2a1a5adb12f790700ec1b76
parentbec7dafa91aca0d27149a83afc3f31fc8d2613d1 (diff)
Backport: Prevent crash and resolve placeholders in Auto-Type dialog
* Modified backport of specific improvements introduced on develop branch. - Prevent crash when multiple screens are at play and QApplication::screenAt returns nullptr. - Resolve username/password when copying to clipboard from Auto-Type selection dialog.
-rw-r--r--src/autotype/AutoTypeSelectDialog.cpp12
-rw-r--r--src/gui/entry/AutoTypeMatchView.cpp14
2 files changed, 19 insertions, 7 deletions
diff --git a/src/autotype/AutoTypeSelectDialog.cpp b/src/autotype/AutoTypeSelectDialog.cpp
index 3b264b7bc..af11fb8f8 100644
--- a/src/autotype/AutoTypeSelectDialog.cpp
+++ b/src/autotype/AutoTypeSelectDialog.cpp
@@ -52,18 +52,24 @@ AutoTypeSelectDialog::AutoTypeSelectDialog(QWidget* parent)
setWindowIcon(resources()->applicationIcon());
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
- QRect screenGeometry = QApplication::screenAt(QCursor::pos())->availableGeometry();
+ auto screen = QApplication::screenAt(QCursor::pos());
+ if (!screen) {
+ // screenAt can return a nullptr, default to the primary screen
+ screen = QApplication::primaryScreen();
+ }
+ QRect screenGeometry = screen->availableGeometry();
#else
QRect screenGeometry = QApplication::desktop()->availableGeometry(QCursor::pos());
#endif
+
+ // Resize to last used size
QSize size = config()->get(Config::GUI_AutoTypeSelectDialogSize).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 = screenGeometry.center();
- move(screenCenter.x() - (size.width() / 2), screenCenter.y() - (size.height() / 2));
+ move(screenGeometry.center().x() - (size.width() / 2), screenGeometry.center().y() - (size.height() / 2));
QVBoxLayout* layout = new QVBoxLayout(this);
diff --git a/src/gui/entry/AutoTypeMatchView.cpp b/src/gui/entry/AutoTypeMatchView.cpp
index 72ee32fde..cdf1f9425 100644
--- a/src/gui/entry/AutoTypeMatchView.cpp
+++ b/src/gui/entry/AutoTypeMatchView.cpp
@@ -64,14 +64,20 @@ AutoTypeMatchView::AutoTypeMatchView(QWidget* parent)
void AutoTypeMatchView::userNameCopied()
{
- clipboard()->setText(currentMatch().entry->username());
- emit matchTextCopied();
+ auto entry = currentMatch().entry;
+ if (entry) {
+ clipboard()->setText(entry->resolvePlaceholder(entry->username()));
+ emit matchTextCopied();
+ }
}
void AutoTypeMatchView::passwordCopied()
{
- clipboard()->setText(currentMatch().entry->password());
- emit matchTextCopied();
+ auto entry = currentMatch().entry;
+ if (entry) {
+ clipboard()->setText(entry->resolvePlaceholder(entry->password()));
+ emit matchTextCopied();
+ }
}
void AutoTypeMatchView::keyPressEvent(QKeyEvent* event)