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 #include #include +#include #include #include #include @@ -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(focusWidget()); + if (plainTextEdit) { + clipboard()->setText(plainTextEdit->textCursor().selectedText(), clearClipboard); + return; + } + + auto label = qobject_cast(focusWidget()); + if (label) { + clipboard()->setText(label->selectedText(), clearClipboard); + return; + } + auto textEdit = qobject_cast(focusWidget()); if (textEdit) { - textEdit->copy(); + clipboard()->setText(textEdit->textCursor().selectedText(), clearClipboard); return; }