Skip to content

Commit 18d6ce6

Browse files
committed
refactor: track "Masternodes" tab show/hide in OptionsModel
1 parent c576264 commit 18d6ce6

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

src/qt/bitcoingui.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,10 +1484,8 @@ void BitcoinGUI::updateGovernanceVisibility()
14841484

14851485
void BitcoinGUI::updateMasternodesVisibility()
14861486
{
1487-
const bool fShow = [](){
1488-
QSettings settings;
1489-
return settings.value("fShowMasternodesTab").toBool()
1490-
}();
1487+
if (!clientModel || !clientModel->getOptionsModel()) return;
1488+
const bool fShow = clientModel->getOptionsModel()->getShowMasternodesTab();
14911489

14921490
// Show/hide the underlying QAction, hiding the QToolButton itself doesn't
14931491
// work for the GUI part but is still needed for shortcuts to work properly.

src/qt/optionsmodel.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,10 @@ bool OptionsModel::Init(bilingual_str& error)
344344
settings.setValue("fKeepChangeAddress", false);
345345
fKeepChangeAddress = settings.value("fKeepChangeAddress", false).toBool();
346346

347+
if (!settings.contains("fShowMasternodesTab"))
348+
settings.setValue("fShowMasternodesTab", false);
349+
m_enable_masternodes = settings.value("fShowMasternodesTab", false).toBool();
350+
347351
if (!settings.contains("fShowGovernanceTab"))
348352
settings.setValue("fShowGovernanceTab", false);
349353
m_enable_governance = settings.value("fShowGovernanceTab", false).toBool();
@@ -656,7 +660,7 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con
656660
case SubFeeFromAmount:
657661
return m_sub_fee_from_amount;
658662
case ShowMasternodesTab:
659-
return settings.value("fShowMasternodesTab");
663+
return m_enable_masternodes;
660664
case ShowGovernanceTab:
661665
return m_enable_governance;
662666
case CoinJoinEnabled:
@@ -842,9 +846,10 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value, const std::
842846
}
843847
break;
844848
case ShowMasternodesTab:
845-
if (settings.value("fShowMasternodesTab") != value) {
846-
settings.setValue("fShowMasternodesTab", value);
847-
Q_EMIT showMasternodesChanged(value.toBool());
849+
if (changed()) {
850+
m_enable_masternodes = value.toBool();
851+
settings.setValue("fShowMasternodesTab", m_enable_masternodes);
852+
Q_EMIT showMasternodesChanged();
848853
}
849854
break;
850855
case SubFeeFromAmount:

src/qt/optionsmodel.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ class OptionsModel : public QAbstractListModel
129129
bool getSubFeeFromAmount() const { return m_sub_fee_from_amount; }
130130
bool getEnablePSBTControls() const { return m_enable_psbt_controls; }
131131
bool getKeepChangeAddress() const { return fKeepChangeAddress; }
132+
bool getShowMasternodesTab() const { return m_enable_masternodes; }
132133
bool getShowGovernanceTab() const { return m_enable_governance; }
133134
bool getShowAdvancedCJUI() { return fShowAdvancedCJUI; }
134135
const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; }
@@ -159,6 +160,7 @@ class OptionsModel : public QAbstractListModel
159160
bool m_enable_psbt_controls;
160161
bool m_mask_values;
161162
bool fKeepChangeAddress;
163+
bool m_enable_masternodes;
162164
bool m_enable_governance;
163165
bool fShowAdvancedCJUI;
164166

@@ -183,7 +185,7 @@ class OptionsModel : public QAbstractListModel
183185
void keepChangeAddressChanged(bool);
184186
void showCoinJoinChanged();
185187
void showGovernanceChanged();
186-
void showMasternodesChanged(bool);
188+
void showMasternodesChanged();
187189
void showTrayIconChanged(bool);
188190
void fontForMoneyChanged(const QFont&);
189191
};

0 commit comments

Comments
 (0)