Remove duplicate menu entries to copy username and password.

This commit is contained in:
Florian Geyer 2013-11-30 16:05:10 +01:00
parent af98c2636c
commit 34f12ac39c
4 changed files with 21 additions and 8 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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);
}

View File

@ -114,13 +114,13 @@
<property name="title">
<string>Copy attribute to clipboard</string>
</property>
<addaction name="actionEntryCopyUsername"/>
<addaction name="actionEntryCopyPassword"/>
</widget>
<addaction name="actionEntryNew"/>
<addaction name="actionEntryClone"/>
<addaction name="actionEntryEdit"/>
<addaction name="actionEntryDelete"/>
<addaction name="actionEntryCopyUsername"/>
<addaction name="actionEntryCopyPassword"/>
<addaction name="menuEntryCopyAttribute"/>
<addaction name="actionEntryAutoType"/>
<addaction name="actionEntryOpenUrl"/>
@ -306,7 +306,7 @@
<bool>false</bool>
</property>
<property name="text">
<string>Copy username to clipboard</string>
<string>Username</string>
</property>
</action>
<action name="actionEntryCopyPassword">
@ -314,7 +314,7 @@
<bool>false</bool>
</property>
<property name="text">
<string>Copy password to clipboard</string>
<string>Password</string>
</property>
</action>
<action name="actionSettings">