mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Merge branch 'attributes'.
This commit is contained in:
commit
4b41dd30e6
@ -185,27 +185,27 @@ const AutoTypeAssociations* Entry::autoTypeAssociations() const
|
||||
|
||||
QString Entry::title() const
|
||||
{
|
||||
return m_attributes->value("Title");
|
||||
return m_attributes->value(EntryAttributes::TitleKey);
|
||||
}
|
||||
|
||||
QString Entry::url() const
|
||||
{
|
||||
return m_attributes->value("URL");
|
||||
return m_attributes->value(EntryAttributes::URLNameKey);
|
||||
}
|
||||
|
||||
QString Entry::username() const
|
||||
{
|
||||
return m_attributes->value("UserName");
|
||||
return m_attributes->value(EntryAttributes::UserNameKey);
|
||||
}
|
||||
|
||||
QString Entry::password() const
|
||||
{
|
||||
return m_attributes->value("Password");
|
||||
return m_attributes->value(EntryAttributes::PasswordKey);
|
||||
}
|
||||
|
||||
QString Entry::notes() const
|
||||
{
|
||||
return m_attributes->value("Notes");
|
||||
return m_attributes->value(EntryAttributes::NotesKey);
|
||||
}
|
||||
|
||||
bool Entry::isExpired() const
|
||||
@ -311,27 +311,27 @@ void Entry::setDefaultAutoTypeSequence(const QString& sequence)
|
||||
|
||||
void Entry::setTitle(const QString& title)
|
||||
{
|
||||
m_attributes->set("Title", title, m_attributes->isProtected("Title"));
|
||||
m_attributes->set(EntryAttributes::TitleKey, title, m_attributes->isProtected(EntryAttributes::TitleKey));
|
||||
}
|
||||
|
||||
void Entry::setUrl(const QString& url)
|
||||
{
|
||||
m_attributes->set("URL", url, m_attributes->isProtected("URL"));
|
||||
m_attributes->set(EntryAttributes::URLNameKey, url, m_attributes->isProtected(EntryAttributes::URLNameKey));
|
||||
}
|
||||
|
||||
void Entry::setUsername(const QString& username)
|
||||
{
|
||||
m_attributes->set("UserName", username, m_attributes->isProtected("UserName"));
|
||||
m_attributes->set(EntryAttributes::UserNameKey, username, m_attributes->isProtected(EntryAttributes::UserNameKey));
|
||||
}
|
||||
|
||||
void Entry::setPassword(const QString& password)
|
||||
{
|
||||
m_attributes->set("Password", password, m_attributes->isProtected("Password"));
|
||||
m_attributes->set(EntryAttributes::PasswordKey, password, m_attributes->isProtected(EntryAttributes::PasswordKey));
|
||||
}
|
||||
|
||||
void Entry::setNotes(const QString& notes)
|
||||
{
|
||||
m_attributes->set("Notes", notes, m_attributes->isProtected("Notes"));
|
||||
m_attributes->set(EntryAttributes::NotesKey, notes, m_attributes->isProtected(EntryAttributes::NotesKey));
|
||||
}
|
||||
|
||||
void Entry::setExpires(const bool& value)
|
||||
|
@ -17,8 +17,13 @@
|
||||
|
||||
#include "EntryAttributes.h"
|
||||
|
||||
const QStringList EntryAttributes::DefaultAttributes(QStringList() << "Title" << "UserName"
|
||||
<< "Password" << "URL" << "Notes");
|
||||
const QString EntryAttributes::TitleKey = "Title";
|
||||
const QString EntryAttributes::UserNameKey = "UserName";
|
||||
const QString EntryAttributes::PasswordKey = "Password";
|
||||
const QString EntryAttributes::URLNameKey = "URL";
|
||||
const QString EntryAttributes::NotesKey = "Notes";
|
||||
const QStringList EntryAttributes::DefaultAttributes(QStringList() << TitleKey << UserNameKey
|
||||
<< PasswordKey << URLNameKey << NotesKey);
|
||||
|
||||
EntryAttributes::EntryAttributes(QObject* parent)
|
||||
: QObject(parent)
|
||||
|
@ -46,6 +46,11 @@ public:
|
||||
bool operator==(const EntryAttributes& other) const;
|
||||
bool operator!=(const EntryAttributes& other) const;
|
||||
|
||||
static const QString TitleKey;
|
||||
static const QString UserNameKey;
|
||||
static const QString PasswordKey;
|
||||
static const QString URLNameKey;
|
||||
static const QString NotesKey;
|
||||
static const QStringList DefaultAttributes;
|
||||
static bool isDefaultAttribute(const QString& key);
|
||||
|
||||
|
@ -288,6 +288,17 @@ void DatabaseWidget::deleteEntries()
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWidget::copyTitle()
|
||||
{
|
||||
Entry* currentEntry = m_entryView->currentEntry();
|
||||
if (!currentEntry) {
|
||||
Q_ASSERT(false);
|
||||
return;
|
||||
}
|
||||
|
||||
setClipboardTextAndMinimize(currentEntry->title());
|
||||
}
|
||||
|
||||
void DatabaseWidget::copyUsername()
|
||||
{
|
||||
Entry* currentEntry = m_entryView->currentEntry();
|
||||
@ -296,11 +307,7 @@ void DatabaseWidget::copyUsername()
|
||||
return;
|
||||
}
|
||||
|
||||
clipboard()->setText(currentEntry->username());
|
||||
|
||||
if (config()->get("MinimizeOnCopy").toBool()) {
|
||||
window()->showMinimized();
|
||||
}
|
||||
setClipboardTextAndMinimize(currentEntry->username());
|
||||
}
|
||||
|
||||
void DatabaseWidget::copyPassword()
|
||||
@ -311,11 +318,29 @@ void DatabaseWidget::copyPassword()
|
||||
return;
|
||||
}
|
||||
|
||||
clipboard()->setText(currentEntry->password());
|
||||
setClipboardTextAndMinimize(currentEntry->password());
|
||||
}
|
||||
|
||||
if (config()->get("MinimizeOnCopy").toBool()) {
|
||||
window()->showMinimized();
|
||||
void DatabaseWidget::copyURL()
|
||||
{
|
||||
Entry* currentEntry = m_entryView->currentEntry();
|
||||
if (!currentEntry) {
|
||||
Q_ASSERT(false);
|
||||
return;
|
||||
}
|
||||
|
||||
setClipboardTextAndMinimize(currentEntry->url());
|
||||
}
|
||||
|
||||
void DatabaseWidget::copyNotes()
|
||||
{
|
||||
Entry* currentEntry = m_entryView->currentEntry();
|
||||
if (!currentEntry) {
|
||||
Q_ASSERT(false);
|
||||
return;
|
||||
}
|
||||
|
||||
setClipboardTextAndMinimize(currentEntry->notes());
|
||||
}
|
||||
|
||||
void DatabaseWidget::copyAttribute(QAction* action)
|
||||
@ -326,8 +351,12 @@ void DatabaseWidget::copyAttribute(QAction* action)
|
||||
return;
|
||||
}
|
||||
|
||||
clipboard()->setText(currentEntry->attributes()->value(action->text()));
|
||||
setClipboardTextAndMinimize(currentEntry->attributes()->value(action->text()));
|
||||
}
|
||||
|
||||
void DatabaseWidget::setClipboardTextAndMinimize(const QString& text)
|
||||
{
|
||||
clipboard()->setText(text);
|
||||
if (config()->get("MinimizeOnCopy").toBool()) {
|
||||
window()->showMinimized();
|
||||
}
|
||||
|
@ -86,8 +86,11 @@ public Q_SLOTS:
|
||||
void createEntry();
|
||||
void cloneEntry();
|
||||
void deleteEntries();
|
||||
void copyTitle();
|
||||
void copyUsername();
|
||||
void copyPassword();
|
||||
void copyURL();
|
||||
void copyNotes();
|
||||
void copyAttribute(QAction* action);
|
||||
void performAutoType();
|
||||
void openUrl();
|
||||
@ -125,6 +128,8 @@ private Q_SLOTS:
|
||||
void closeSearch();
|
||||
|
||||
private:
|
||||
void setClipboardTextAndMinimize(const QString& text);
|
||||
|
||||
Database* m_db;
|
||||
const QScopedPointer<Ui::SearchWidget> m_searchUi;
|
||||
QWidget* const m_searchWidget;
|
||||
|
@ -163,10 +163,17 @@ MainWindow::MainWindow()
|
||||
SLOT(switchToEntryEdit()));
|
||||
m_actionMultiplexer.connect(m_ui->actionEntryDelete, SIGNAL(triggered()),
|
||||
SLOT(deleteEntries()));
|
||||
|
||||
m_actionMultiplexer.connect(m_ui->actionEntryCopyTitle, SIGNAL(triggered()),
|
||||
SLOT(copyTitle()));
|
||||
m_actionMultiplexer.connect(m_ui->actionEntryCopyUsername, SIGNAL(triggered()),
|
||||
SLOT(copyUsername()));
|
||||
m_actionMultiplexer.connect(m_ui->actionEntryCopyPassword, SIGNAL(triggered()),
|
||||
SLOT(copyPassword()));
|
||||
m_actionMultiplexer.connect(m_ui->actionEntryCopyURL, SIGNAL(triggered()),
|
||||
SLOT(copyURL()));
|
||||
m_actionMultiplexer.connect(m_ui->actionEntryCopyNotes, SIGNAL(triggered()),
|
||||
SLOT(copyNotes()));
|
||||
m_actionMultiplexer.connect(m_ui->actionEntryAutoType, SIGNAL(triggered()),
|
||||
SLOT(performAutoType()));
|
||||
m_actionMultiplexer.connect(m_ui->actionEntryOpenUrl, SIGNAL(triggered()),
|
||||
@ -214,15 +221,12 @@ void MainWindow::updateCopyAttributesMenu()
|
||||
return;
|
||||
}
|
||||
|
||||
m_ui->menuEntryCopyAttribute->clear();
|
||||
Entry* entry = dbWidget->entryView()->currentEntry();
|
||||
|
||||
Q_FOREACH (const QString& key, EntryAttributes::DefaultAttributes) {
|
||||
QAction* action = m_ui->menuEntryCopyAttribute->addAction(key);
|
||||
m_copyAdditionalAttributeActions->addAction(action);
|
||||
QList<QAction*> actions = m_ui->menuEntryCopyAttribute->actions();
|
||||
for (int i = EntryAttributes::DefaultAttributes.size() + 1; i < actions.size(); i++) {
|
||||
delete actions[i];
|
||||
}
|
||||
|
||||
m_ui->menuEntryCopyAttribute->addSeparator();
|
||||
Entry* entry = dbWidget->entryView()->currentEntry();
|
||||
|
||||
Q_FOREACH (const QString& key, entry->attributes()->customKeys()) {
|
||||
QAction* action = m_ui->menuEntryCopyAttribute->addAction(key);
|
||||
@ -269,8 +273,11 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
|
||||
m_ui->actionEntryClone->setEnabled(singleEntrySelected && !inSearch);
|
||||
m_ui->actionEntryEdit->setEnabled(singleEntrySelected);
|
||||
m_ui->actionEntryDelete->setEnabled(entriesSelected);
|
||||
m_ui->actionEntryCopyTitle->setEnabled(singleEntrySelected);
|
||||
m_ui->actionEntryCopyUsername->setEnabled(singleEntrySelected);
|
||||
m_ui->actionEntryCopyPassword->setEnabled(singleEntrySelected);
|
||||
m_ui->actionEntryCopyURL->setEnabled(singleEntrySelected);
|
||||
m_ui->actionEntryCopyNotes->setEnabled(singleEntrySelected);
|
||||
m_ui->menuEntryCopyAttribute->setEnabled(singleEntrySelected);
|
||||
m_ui->actionEntryAutoType->setEnabled(singleEntrySelected);
|
||||
m_ui->actionEntryOpenUrl->setEnabled(singleEntrySelected);
|
||||
|
@ -114,13 +114,17 @@
|
||||
<property name="title">
|
||||
<string>Copy attribute to clipboard</string>
|
||||
</property>
|
||||
<addaction name="actionEntryCopyTitle"/>
|
||||
<addaction name="actionEntryCopyUsername"/>
|
||||
<addaction name="actionEntryCopyPassword"/>
|
||||
<addaction name="actionEntryCopyURL"/>
|
||||
<addaction name="actionEntryCopyNotes"/>
|
||||
<addaction name="separator"/>
|
||||
</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 +310,7 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Copy username to clipboard</string>
|
||||
<string>Username</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEntryCopyPassword">
|
||||
@ -314,7 +318,7 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Copy password to clipboard</string>
|
||||
<string>Password</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSettings">
|
||||
@ -346,6 +350,30 @@
|
||||
<string>Lock databases</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEntryCopyTitle">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Title</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEntryCopyURL">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>URL</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEntryCopyNotes">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Notes</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
Loading…
Reference in New Issue
Block a user