diff --git a/src/core/EntryAttributes.cpp b/src/core/EntryAttributes.cpp index 5425c38f2..becf0ecae 100644 --- a/src/core/EntryAttributes.cpp +++ b/src/core/EntryAttributes.cpp @@ -17,8 +17,10 @@ #include "EntryAttributes.h" -const QStringList EntryAttributes::DefaultAttributes(QStringList() << "Title" << "UserName" - << "Password" << "URL" << "Notes"); +const QString EntryAttributes::UserNameKey = "UserName"; +const QString EntryAttributes::PasswordKey = "Password"; +const QStringList EntryAttributes::DefaultAttributes(QStringList() << "Title" << UserNameKey + << PasswordKey << "URL" << "Notes"); EntryAttributes::EntryAttributes(QObject* parent) : QObject(parent) diff --git a/src/core/EntryAttributes.h b/src/core/EntryAttributes.h index 420c085fa..a7bdcad45 100644 --- a/src/core/EntryAttributes.h +++ b/src/core/EntryAttributes.h @@ -46,6 +46,8 @@ public: bool operator==(const EntryAttributes& other) const; bool operator!=(const EntryAttributes& other) const; + static const QString UserNameKey; + static const QString PasswordKey; static const QStringList DefaultAttributes; static bool isDefaultAttribute(const QString& key); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 3f956a638..67c4647a4 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -214,10 +214,19 @@ void MainWindow::updateCopyAttributesMenu() return; } - m_ui->menuEntryCopyAttribute->clear(); + Q_FOREACH (QAction* action, m_ui->menuEntryCopyAttribute->actions()) { + if (action != m_ui->actionEntryCopyPassword && action != m_ui->actionEntryCopyUsername) { + m_ui->menuEntryCopyAttribute->removeAction(action); + } + } + Entry* entry = dbWidget->entryView()->currentEntry(); - Q_FOREACH (const QString& key, EntryAttributes::DefaultAttributes) { + QStringList defaultAttributesWithoutPasswordAndUsername = EntryAttributes::DefaultAttributes; + defaultAttributesWithoutPasswordAndUsername.removeOne(EntryAttributes::PasswordKey); + defaultAttributesWithoutPasswordAndUsername.removeOne(EntryAttributes::UserNameKey); + + Q_FOREACH (const QString& key, defaultAttributesWithoutPasswordAndUsername) { QAction* action = m_ui->menuEntryCopyAttribute->addAction(key); m_copyAdditionalAttributeActions->addAction(action); } diff --git a/src/gui/MainWindow.ui b/src/gui/MainWindow.ui index 74f04b530..18c8346c8 100644 --- a/src/gui/MainWindow.ui +++ b/src/gui/MainWindow.ui @@ -114,13 +114,13 @@ Copy attribute to clipboard + + - - @@ -306,7 +306,7 @@ false - Copy username to clipboard + Username @@ -314,7 +314,7 @@ false - Copy password to clipboard + Password