Skip to content

Commit

Permalink
Add ability to hide a protected attribute after reveal
Browse files Browse the repository at this point in the history
  • Loading branch information
ba32107 authored and droidmonkey committed Nov 18, 2019
1 parent 949fd70 commit 6aff51f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/gui/entry/EditEntryWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void EditEntryWidget::setupAdvanced()
connect(m_advancedUi->editAttributeButton, SIGNAL(clicked()), SLOT(editCurrentAttribute()));
connect(m_advancedUi->removeAttributeButton, SIGNAL(clicked()), SLOT(removeCurrentAttribute()));
connect(m_advancedUi->protectAttributeButton, SIGNAL(toggled(bool)), SLOT(protectCurrentAttribute(bool)));
connect(m_advancedUi->revealAttributeButton, SIGNAL(clicked(bool)), SLOT(revealCurrentAttribute()));
connect(m_advancedUi->revealAttributeButton, SIGNAL(clicked(bool)), SLOT(toggleCurrentAttributeVisibility()));
connect(m_advancedUi->attributesView->selectionModel(),
SIGNAL(currentChanged(QModelIndex,QModelIndex)),
SLOT(updateCurrentAttribute()));
Expand Down Expand Up @@ -1297,11 +1297,12 @@ void EditEntryWidget::displayAttribute(QModelIndex index, bool showProtected)
// Block signals to prevent modified being set
m_advancedUi->protectAttributeButton->blockSignals(true);
m_advancedUi->attributesEdit->blockSignals(true);
m_advancedUi->revealAttributeButton->setText(tr("Reveal"));

if (index.isValid()) {
QString key = m_attributesModel->keyByIndex(index);
if (showProtected) {
m_advancedUi->attributesEdit->setPlainText(tr("[PROTECTED] Press reveal to view or edit"));
m_advancedUi->attributesEdit->setPlainText(tr("[PROTECTED] Press Reveal to view or edit"));
m_advancedUi->attributesEdit->setEnabled(false);
m_advancedUi->revealAttributeButton->setEnabled(true);
m_advancedUi->protectAttributeButton->setChecked(true);
Expand Down Expand Up @@ -1348,7 +1349,7 @@ void EditEntryWidget::protectCurrentAttribute(bool state)
}
}

void EditEntryWidget::revealCurrentAttribute()
void EditEntryWidget::toggleCurrentAttributeVisibility()
{
if (!m_advancedUi->attributesEdit->isEnabled()) {
QModelIndex index = m_advancedUi->attributesView->currentIndex();
Expand All @@ -1359,6 +1360,10 @@ void EditEntryWidget::revealCurrentAttribute()
m_advancedUi->attributesEdit->setEnabled(true);
m_advancedUi->attributesEdit->blockSignals(oldBlockSignals);
}
m_advancedUi->revealAttributeButton->setText(tr("Hide"));
} else {
protectCurrentAttribute(true);
m_advancedUi->revealAttributeButton->setText(tr("Reveal"));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/entry/EditEntryWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private slots:
void removeCurrentAttribute();
void updateCurrentAttribute();
void protectCurrentAttribute(bool state);
void revealCurrentAttribute();
void toggleCurrentAttributeVisibility();
void updateAutoTypeEnabled();
void openAutotypeHelp();
void insertAutoTypeAssoc();
Expand Down

0 comments on commit 6aff51f

Please sign in to comment.