Merge branch 'release/2.6.2' into develop

This commit is contained in:
Jonathan White 2020-10-15 00:13:14 -04:00
commit 0c5dd1556a
No known key found for this signature in database
GPG key ID: 440FC65F2E0C6E01
43 changed files with 291 additions and 469 deletions

View file

@ -809,12 +809,12 @@ void EditEntryWidget::loadEntry(Entry* entry,
connect(m_entry, &Entry::entryModified, this, [this] { m_entryModifiedTimer.start(); });
if (history) {
setHeadline(QString("%1 \u2B29 %2").arg(parentName, tr("Entry history")));
setHeadline(QString("%1 \u2022 %2").arg(parentName, tr("Entry history")));
} else {
if (create) {
setHeadline(QString("%1 \u2B29 %2").arg(parentName, tr("Add entry")));
setHeadline(QString("%1 \u2022 %2").arg(parentName, tr("Add entry")));
} else {
setHeadline(QString("%1 \u2B29 %2 \u2B29 %3").arg(parentName, entry->title(), tr("Edit entry")));
setHeadline(QString("%1 \u2022 %2 \u2022 %3").arg(parentName, entry->title(), tr("Edit entry")));
}
}
@ -1013,6 +1013,11 @@ bool EditEntryWidget::commitEntry()
return true;
}
// Check Auto-Type validity early
if (!AutoType::verifyAutoTypeSyntax(m_autoTypeUi->sequenceEdit->text())) {
return false;
}
if (m_advancedUi->attributesView->currentIndex().isValid() && m_advancedUi->attributesEdit->isEnabled()) {
QString key = m_attributesModel->keyByIndex(m_advancedUi->attributesView->currentIndex());
m_entryAttributes->set(key, m_advancedUi->attributesEdit->toPlainText(), m_entryAttributes->isProtected(key));
@ -1111,7 +1116,7 @@ void EditEntryWidget::updateEntryData(Entry* entry) const
entry->setAutoTypeEnabled(m_autoTypeUi->enableButton->isChecked());
if (m_autoTypeUi->inheritSequenceButton->isChecked()) {
entry->setDefaultAutoTypeSequence(QString());
} else if (AutoType::verifyAutoTypeSyntax(m_autoTypeUi->sequenceEdit->text())) {
} else {
entry->setDefaultAutoTypeSequence(m_autoTypeUi->sequenceEdit->text());
}
@ -1380,6 +1385,7 @@ void EditEntryWidget::removeAutoTypeAssoc()
void EditEntryWidget::loadCurrentAssoc(const QModelIndex& current)
{
bool modified = isModified();
if (current.isValid() && current.row() < m_autoTypeAssoc->size()) {
AutoTypeAssociations::Association assoc = m_autoTypeAssoc->get(current.row());
m_autoTypeUi->windowTitleCombo->setEditText(assoc.window);
@ -1395,6 +1401,7 @@ void EditEntryWidget::loadCurrentAssoc(const QModelIndex& current)
} else {
clearCurrentAssoc();
}
setModified(modified);
}
void EditEntryWidget::clearCurrentAssoc()

View file

@ -37,11 +37,10 @@
EntryModel::EntryModel(QObject* parent)
: QAbstractTableModel(parent)
, m_group(nullptr)
, m_hideUsernames(false)
, m_hidePasswords(true)
, HiddenContentDisplay(QString("\u25cf").repeated(6))
, DateFormat(Qt::DefaultLocaleShortDate)
{
connect(config(), &Config::changed, this, &EntryModel::onConfigChanged);
}
Entry* EntryModel::entryFromIndex(const QModelIndex& index) const
@ -156,7 +155,7 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
}
return result;
case Username:
if (m_hideUsernames) {
if (config()->get(Config::GUI_HideUsernames).toBool()) {
result = EntryModel::HiddenContentDisplay;
} else {
result = entry->resolveMultiplePlaceholders(entry->username());
@ -164,9 +163,12 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
if (attr->isReference(EntryAttributes::UserNameKey)) {
result.prepend(tr("Ref: ", "Reference abbreviation"));
}
if (entry->username().isEmpty() && !config()->get(Config::Security_PasswordEmptyPlaceholder).toBool()) {
result = "";
}
return result;
case Password:
if (m_hidePasswords) {
if (config()->get(Config::GUI_HidePasswords).toBool()) {
result = EntryModel::HiddenContentDisplay;
} else {
result = entry->resolveMultiplePlaceholders(entry->password());
@ -537,6 +539,20 @@ void EntryModel::entryDataChanged(Entry* entry)
emit dataChanged(index(row, 0), index(row, columnCount() - 1));
}
void EntryModel::onConfigChanged(Config::ConfigKey key)
{
switch (key) {
case Config::GUI_HideUsernames:
emit dataChanged(index(0, Username), index(rowCount() - 1, Username), {Qt::DisplayRole});
break;
case Config::GUI_HidePasswords:
emit dataChanged(index(0, Password), index(rowCount() - 1, Password), {Qt::DisplayRole});
break;
default:
break;
}
}
void EntryModel::severConnections()
{
if (m_group) {
@ -560,39 +576,3 @@ void EntryModel::makeConnections(const Group* group)
connect(group, SIGNAL(entryMovedDown()), SLOT(entryMovedDown()));
connect(group, SIGNAL(entryDataChanged(Entry*)), SLOT(entryDataChanged(Entry*)));
}
/**
* Get current state of 'Hide Usernames' setting
*/
bool EntryModel::isUsernamesHidden() const
{
return m_hideUsernames;
}
/**
* Set state of 'Hide Usernames' setting and signal change
*/
void EntryModel::setUsernamesHidden(bool hide)
{
m_hideUsernames = hide;
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
emit usernamesHiddenChanged();
}
/**
* Get current state of 'Hide Passwords' setting
*/
bool EntryModel::isPasswordsHidden() const
{
return m_hidePasswords;
}
/**
* Set state of 'Hide Passwords' setting and signal change
*/
void EntryModel::setPasswordsHidden(bool hide)
{
m_hidePasswords = hide;
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
emit passwordsHiddenChanged();
}

View file

@ -21,6 +21,8 @@
#include <QAbstractTableModel>
#include <QPixmap>
#include "core/Config.h"
class Entry;
class Group;
@ -64,15 +66,6 @@ public:
void setGroup(Group* group);
void setEntries(const QList<Entry*>& entries);
bool isUsernamesHidden() const;
void setUsernamesHidden(bool hide);
bool isPasswordsHidden() const;
void setPasswordsHidden(bool hide);
signals:
void usernamesHiddenChanged();
void passwordsHiddenChanged();
private slots:
void entryAboutToAdd(Entry* entry);
void entryAdded(Entry* entry);
@ -84,6 +77,8 @@ private slots:
void entryMovedDown();
void entryDataChanged(Entry* entry);
void onConfigChanged(Config::ConfigKey key);
private:
void severConnections();
void makeConnections(const Group* group);
@ -93,9 +88,6 @@ private:
QList<Entry*> m_orgEntries;
QList<const Group*> m_allGroups;
bool m_hideUsernames;
bool m_hidePasswords;
const QString HiddenContentDisplay;
const Qt::DateFormat DateFormat;
};

View file

@ -32,7 +32,7 @@ EntryView::EntryView(QWidget* parent)
, m_sortModel(new SortFilterHideProxyModel(this))
, m_lastIndex(-1)
, m_lastOrder(Qt::AscendingOrder)
, m_inSearchMode(false)
, m_headerMenu(new QMenu(this))
{
m_sortModel->setSourceModel(m_model);
m_sortModel->setDynamicSortFilter(true);
@ -55,22 +55,10 @@ EntryView::EntryView(QWidget* parent)
// clang-format off
connect(this, SIGNAL(doubleClicked(QModelIndex)), SLOT(emitEntryActivated(QModelIndex)));
connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(emitEntrySelectionChanged()));
connect(m_model, SIGNAL(usernamesHiddenChanged()), SIGNAL(viewStateChanged()));
connect(m_model, SIGNAL(passwordsHiddenChanged()), SIGNAL(viewStateChanged()));
// clang-format on
new QShortcut(Qt::CTRL + Qt::Key_F10, this, SLOT(contextMenuShortcutPressed()), nullptr, Qt::WidgetShortcut);
m_headerMenu = new QMenu(this);
m_headerMenu->setTitle(tr("Customize View"));
m_headerMenu->addSection(tr("Customize View"));
m_hideUsernamesAction = m_headerMenu->addAction(tr("Hide Usernames"), this, SLOT(setUsernamesHidden(bool)));
m_hideUsernamesAction->setCheckable(true);
m_hidePasswordsAction = m_headerMenu->addAction(tr("Hide Passwords"), this, SLOT(setPasswordsHidden(bool)));
m_hidePasswordsAction->setCheckable(true);
m_headerMenu->addSeparator();
resetViewToDefaults();
// Actions to toggle column visibility, each carrying the corresponding
@ -292,50 +280,6 @@ int EntryView::currentEntryIndex()
}
}
/**
* Get current state of 'Hide Usernames' setting (NOTE: just pass-through for
* m_model)
*/
bool EntryView::isUsernamesHidden() const
{
return m_model->isUsernamesHidden();
}
/**
* Set state of 'Hide Usernames' setting (NOTE: just pass-through for m_model)
*/
void EntryView::setUsernamesHidden(bool hide)
{
bool block = m_hideUsernamesAction->signalsBlocked();
m_hideUsernamesAction->blockSignals(true);
m_hideUsernamesAction->setChecked(hide);
m_hideUsernamesAction->blockSignals(block);
m_model->setUsernamesHidden(hide);
}
/**
* Get current state of 'Hide Passwords' setting (NOTE: just pass-through for
* m_model)
*/
bool EntryView::isPasswordsHidden() const
{
return m_model->isPasswordsHidden();
}
/**
* Set state of 'Hide Passwords' setting (NOTE: just pass-through for m_model)
*/
void EntryView::setPasswordsHidden(bool hide)
{
bool block = m_hidePasswordsAction->signalsBlocked();
m_hidePasswordsAction->blockSignals(true);
m_hidePasswordsAction->setChecked(hide);
m_hidePasswordsAction->blockSignals(block);
m_model->setPasswordsHidden(hide);
}
/**
* Get current view state
*/
@ -363,8 +307,6 @@ bool EntryView::setViewState(const QByteArray& state)
*/
void EntryView::showHeaderMenu(const QPoint& position)
{
m_hideUsernamesAction->setChecked(m_model->isUsernamesHidden());
m_hidePasswordsAction->setChecked(m_model->isPasswordsHidden());
const QList<QAction*> actions = m_columnActions->actions();
for (auto& action : actions) {
Q_ASSERT(static_cast<QMetaType::Type>(action->data().type()) == QMetaType::Int);
@ -469,9 +411,6 @@ void EntryView::resetFixedColumns()
*/
void EntryView::resetViewToDefaults()
{
m_model->setUsernamesHidden(false);
m_model->setPasswordsHidden(true);
// Reduce number of columns that are shown by default
if (m_inSearchMode) {
header()->showSection(EntryModel::ParentGroup);

View file

@ -44,8 +44,6 @@ public:
bool isSorted();
int numberOfSelectedEntries();
void setFirstEntryActive();
bool isUsernamesHidden() const;
bool isPasswordsHidden() const;
QByteArray viewState() const;
bool setViewState(const QByteArray& state);
@ -57,10 +55,6 @@ signals:
void entrySelectionChanged(Entry* entry);
void viewStateChanged();
public slots:
void setUsernamesHidden(bool hide);
void setPasswordsHidden(bool hide);
protected:
void keyPressEvent(QKeyEvent* event) override;
void focusInEvent(QFocusEvent* event) override;
@ -86,12 +80,10 @@ private:
SortFilterHideProxyModel* const m_sortModel;
int m_lastIndex;
Qt::SortOrder m_lastOrder;
bool m_inSearchMode;
bool m_inSearchMode = false;
bool m_columnsNeedRelayout = true;
QMenu* m_headerMenu;
QAction* m_hideUsernamesAction;
QAction* m_hidePasswordsAction;
QActionGroup* m_columnActions;
};