From 18be1a0254d1c1381738cd1d52aaf9a03c34c0aa Mon Sep 17 00:00:00 2001 From: Fonic Date: Thu, 21 Dec 2017 13:52:01 +0100 Subject: [PATCH] Add 'copy-on-doubleclick' feature to entry view table Add 'copy-on-doubleclick' feature to entry view table by extending already existing DatabaseWidget::entryActivationSignalReceived(). Currently, username, password and notes are copyied on doubleclick, while doubleclicking URL still opens browser as before. Can easily be extended to account for other/additional columns (switch-case). --- src/gui/DatabaseWidget.cpp | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 8f4fc9bb3..013818c90 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -908,12 +908,39 @@ void DatabaseWidget::unlockDatabase(bool accepted) } } +/** + * @author Fonic + * Add 'copy-on-doubleclick' functionality for certain columns + * + * TODO: + * If pull request #1298 gets merged, double-clicking column 'Attachments' + * could open the new details view (see second screenshot) + */ void DatabaseWidget::entryActivationSignalReceived(Entry* entry, EntryModel::ModelColumn column) { - if (column == EntryModel::Url && !entry->url().isEmpty()) { - openUrlForEntry(entry); + /* Should never happen */ + if (!entry) { + Q_ASSERT(false); + return; } - else { + + /* Decide what to do based on specified column */ + switch (column) { + case EntryModel::Username: + setClipboardTextAndMinimize(entry->resolveMultiplePlaceholders(entry->username())); + break; + case EntryModel::Password: + setClipboardTextAndMinimize(entry->resolveMultiplePlaceholders(entry->password())); + break; + case EntryModel::Url: + if (!entry->url().isEmpty()) { + openUrlForEntry(entry); + } + break; + case EntryModel::Notes: + setClipboardTextAndMinimize(entry->resolveMultiplePlaceholders(entry->notes())); + break; + default: switchToEntryEdit(entry); } }