From c917096d3cfd5159630397bb6cf51b017f85a39e Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Sat, 26 Apr 2014 18:33:09 +0200 Subject: [PATCH] Show the inherited value in EditGroupWidget. --- src/gui/group/EditGroupWidget.cpp | 25 ++++++++++++++++++++----- src/gui/group/EditGroupWidget.h | 2 +- src/gui/group/EditGroupWidgetMain.ui | 2 +- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/gui/group/EditGroupWidget.cpp b/src/gui/group/EditGroupWidget.cpp index c24afb98b..b26fe4c97 100644 --- a/src/gui/group/EditGroupWidget.cpp +++ b/src/gui/group/EditGroupWidget.cpp @@ -37,9 +37,6 @@ EditGroupWidget::EditGroupWidget(QWidget* parent) add(tr("Icon"), m_editGroupWidgetIcons); add(tr("Properties"), m_editWidgetProperties); - addTriStateItems(m_mainUi->searchComboBox); - addTriStateItems(m_mainUi->autotypeComboBox); - connect(m_mainUi->expireCheck, SIGNAL(toggled(bool)), m_mainUi->expireDatePicker, SLOT(setEnabled(bool))); connect(this, SIGNAL(accepted()), SLOT(save())); @@ -62,6 +59,15 @@ void EditGroupWidget::loadGroup(Group* group, bool create, Database* database) setHeadline(tr("Edit group")); } + if (m_group->parentGroup()) { + addTriStateItems(m_mainUi->searchComboBox, m_group->parentGroup()->resolveSearchingEnabled()); + addTriStateItems(m_mainUi->autotypeComboBox, m_group->parentGroup()->resolveAutoTypeEnabled()); + } + else { + addTriStateItems(m_mainUi->searchComboBox, true); + addTriStateItems(m_mainUi->autotypeComboBox, true); + } + m_mainUi->editName->setText(m_group->name()); m_mainUi->editNotes->setPlainText(m_group->notes()); m_mainUi->expireCheck->setChecked(group->timeInfo().expires()); @@ -120,9 +126,18 @@ void EditGroupWidget::cancel() Q_EMIT editFinished(false); } -void EditGroupWidget::addTriStateItems(QComboBox* comboBox) +void EditGroupWidget::addTriStateItems(QComboBox* comboBox, bool inheritDefault) { - comboBox->addItem(tr("Inherit")); + QString inheritDefaultString; + if (inheritDefault) { + inheritDefaultString = tr("Enable"); + } + else { + inheritDefaultString = tr("Disable"); + } + + comboBox->clear(); + comboBox->addItem(tr("Inherit from parent group (%1)").arg(inheritDefaultString)); comboBox->addItem(tr("Enable")); comboBox->addItem(tr("Disable")); } diff --git a/src/gui/group/EditGroupWidget.h b/src/gui/group/EditGroupWidget.h index de075be87..971b6de20 100644 --- a/src/gui/group/EditGroupWidget.h +++ b/src/gui/group/EditGroupWidget.h @@ -50,7 +50,7 @@ private Q_SLOTS: void cancel(); private: - void addTriStateItems(QComboBox* comboBox); + void addTriStateItems(QComboBox* comboBox, bool inheritValue); int indexFromTriState(Group::TriState triState); Group::TriState triStateFromIndex(int index); diff --git a/src/gui/group/EditGroupWidgetMain.ui b/src/gui/group/EditGroupWidgetMain.ui index c528c18ad..fdbf054d0 100644 --- a/src/gui/group/EditGroupWidgetMain.ui +++ b/src/gui/group/EditGroupWidgetMain.ui @@ -66,7 +66,7 @@ - Autotype + Auto-type