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:
authormckeema <mckeema@umich.edu>2021-12-09 01:26:55 +0300
committerJonathan White <support@dmapps.us>2021-12-09 03:39:51 +0300
commit6c4a82bd512ade5589e12a9c6a00f25c14c1aebf (patch)
treea25405af960d21bdbe8acb33e535383e75fe8ad6 /src/gui
parenta0a063b57f6f577bed505ccd652763eeadd1b876 (diff)
Make selected text copyable instead of copying password
* Fixes 7209
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/DatabaseWidget.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp
index 45702d7d7..4e8011a92 100644
--- a/src/gui/DatabaseWidget.cpp
+++ b/src/gui/DatabaseWidget.cpp
@@ -24,6 +24,7 @@
#include <QDesktopServices>
#include <QHostInfo>
#include <QKeyEvent>
+#include <QPlainTextEdit>
#include <QProcess>
#include <QSplitter>
#include <QTextEdit>
@@ -591,11 +592,26 @@ void DatabaseWidget::copyUsername()
void DatabaseWidget::copyPassword()
{
- // QTextEdit does not properly trap Ctrl+C copy shortcut
- // if a text edit has focus pass the copy operation to it
+ // Some platforms do not properly trap Ctrl+C copy shortcut
+ // if a text edit or label has focus pass the copy operation to it
+
+ bool clearClipboard = config()->get(Config::Security_ClearClipboard).toBool();
+
+ auto plainTextEdit = qobject_cast<QPlainTextEdit*>(focusWidget());
+ if (plainTextEdit) {
+ clipboard()->setText(plainTextEdit->textCursor().selectedText(), clearClipboard);
+ return;
+ }
+
+ auto label = qobject_cast<QLabel*>(focusWidget());
+ if (label) {
+ clipboard()->setText(label->selectedText(), clearClipboard);
+ return;
+ }
+
auto textEdit = qobject_cast<QTextEdit*>(focusWidget());
if (textEdit) {
- textEdit->copy();
+ clipboard()->setText(textEdit->textCursor().selectedText(), clearClipboard);
return;
}