Add ability to hide a protected attribute after reveal

This commit is contained in:
Balazs Gyurak 2019-11-18 06:55:35 +00:00 committed by Jonathan White
parent c0b1c9e106
commit 9363123047
2 changed files with 8 additions and 3 deletions

View File

@ -201,7 +201,7 @@ void EditEntryWidget::setupAdvanced()
connect(m_advancedUi->editAttributeButton, SIGNAL(clicked()), SLOT(editCurrentAttribute())); connect(m_advancedUi->editAttributeButton, SIGNAL(clicked()), SLOT(editCurrentAttribute()));
connect(m_advancedUi->removeAttributeButton, SIGNAL(clicked()), SLOT(removeCurrentAttribute())); connect(m_advancedUi->removeAttributeButton, SIGNAL(clicked()), SLOT(removeCurrentAttribute()));
connect(m_advancedUi->protectAttributeButton, SIGNAL(toggled(bool)), SLOT(protectCurrentAttribute(bool))); 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(), connect(m_advancedUi->attributesView->selectionModel(),
SIGNAL(currentChanged(QModelIndex,QModelIndex)), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
SLOT(updateCurrentAttribute())); SLOT(updateCurrentAttribute()));
@ -1297,6 +1297,7 @@ void EditEntryWidget::displayAttribute(QModelIndex index, bool showProtected)
// Block signals to prevent modified being set // Block signals to prevent modified being set
m_advancedUi->protectAttributeButton->blockSignals(true); m_advancedUi->protectAttributeButton->blockSignals(true);
m_advancedUi->attributesEdit->blockSignals(true); m_advancedUi->attributesEdit->blockSignals(true);
m_advancedUi->revealAttributeButton->setText(tr("Reveal"));
if (index.isValid()) { if (index.isValid()) {
QString key = m_attributesModel->keyByIndex(index); QString key = m_attributesModel->keyByIndex(index);
@ -1348,7 +1349,7 @@ void EditEntryWidget::protectCurrentAttribute(bool state)
} }
} }
void EditEntryWidget::revealCurrentAttribute() void EditEntryWidget::toggleCurrentAttributeVisibility()
{ {
if (!m_advancedUi->attributesEdit->isEnabled()) { if (!m_advancedUi->attributesEdit->isEnabled()) {
QModelIndex index = m_advancedUi->attributesView->currentIndex(); QModelIndex index = m_advancedUi->attributesView->currentIndex();
@ -1359,6 +1360,10 @@ void EditEntryWidget::revealCurrentAttribute()
m_advancedUi->attributesEdit->setEnabled(true); m_advancedUi->attributesEdit->setEnabled(true);
m_advancedUi->attributesEdit->blockSignals(oldBlockSignals); m_advancedUi->attributesEdit->blockSignals(oldBlockSignals);
} }
m_advancedUi->revealAttributeButton->setText(tr("Hide"));
} else {
protectCurrentAttribute(true);
m_advancedUi->revealAttributeButton->setText(tr("Reveal"));
} }
} }

View File

@ -93,7 +93,7 @@ private slots:
void removeCurrentAttribute(); void removeCurrentAttribute();
void updateCurrentAttribute(); void updateCurrentAttribute();
void protectCurrentAttribute(bool state); void protectCurrentAttribute(bool state);
void revealCurrentAttribute(); void toggleCurrentAttributeVisibility();
void updateAutoTypeEnabled(); void updateAutoTypeEnabled();
void openAutotypeHelp(); void openAutotypeHelp();
void insertAutoTypeAssoc(); void insertAutoTypeAssoc();