Copy to clipboard even if field is empty (Bug: #2889145)

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@354 b624d157-de02-0410-bad0-e51aec6abb33
master
sniperbeamer 15 years ago
parent cfd3ffe6dd
commit 2275b3351b
  1. 7
      src/lib/EntryView.cpp

@ -427,7 +427,6 @@ void KeepassEntryView::OnEditOpenUrl(){
void KeepassEntryView::OnEditCopyUrl(){ void KeepassEntryView::OnEditCopyUrl(){
if (selectedItems().size() == 0) return; if (selectedItems().size() == 0) return;
QString url = ((EntryViewItem*)selectedItems().first())->EntryHandle->url(); QString url = ((EntryViewItem*)selectedItems().first())->EntryHandle->url();
if (url.trimmed().isEmpty()) return;
if (url.startsWith("cmd://") && url.length()>6) if (url.startsWith("cmd://") && url.length()>6)
url = url.right(url.length()-6); url = url.right(url.length()-6);
@ -440,13 +439,12 @@ void KeepassEntryView::OnEditCopyUrl(){
void KeepassEntryView::OnUsernameToClipboard(){ void KeepassEntryView::OnUsernameToClipboard(){
if (selectedItems().size() == 0) return; if (selectedItems().size() == 0) return;
QString username = ((EntryViewItem*)selectedItems().first())->EntryHandle->username(); QString username = ((EntryViewItem*)selectedItems().first())->EntryHandle->username();
if (username.trimmed().isEmpty()) return;
Clipboard->setText(username, QClipboard::Clipboard); Clipboard->setText(username, QClipboard::Clipboard);
if(Clipboard->supportsSelection()){ if(Clipboard->supportsSelection()){
Clipboard->setText(username, QClipboard::Selection); Clipboard->setText(username, QClipboard::Selection);
} }
if (config->clipboardTimeOut()!=0) { if (config->clipboardTimeOut()!=0 && !username.trimmed().isEmpty()) {
ClipboardTimer.setSingleShot(true); ClipboardTimer.setSingleShot(true);
ClipboardTimer.start(config->clipboardTimeOut()*1000); ClipboardTimer.start(config->clipboardTimeOut()*1000);
} }
@ -457,13 +455,12 @@ void KeepassEntryView::OnPasswordToClipboard(){
SecString password; SecString password;
password=((EntryViewItem*)selectedItems().first())->EntryHandle->password(); password=((EntryViewItem*)selectedItems().first())->EntryHandle->password();
password.unlock(); password.unlock();
if (password.string().isEmpty()) return;
Clipboard->setText(password.string(), QClipboard::Clipboard); Clipboard->setText(password.string(), QClipboard::Clipboard);
if(Clipboard->supportsSelection()){ if(Clipboard->supportsSelection()){
Clipboard->setText(password.string(), QClipboard::Selection); Clipboard->setText(password.string(), QClipboard::Selection);
} }
if (config->clipboardTimeOut()!=0) { if (config->clipboardTimeOut()!=0 && !password.string().isEmpty()) {
ClipboardTimer.setSingleShot(true); ClipboardTimer.setSingleShot(true);
ClipboardTimer.start(config->clipboardTimeOut()*1000); ClipboardTimer.start(config->clipboardTimeOut()*1000);
} }