Skip to content

Commit

Permalink
Adding option to hide/ unhide RAP Addresses page manualy (#1208)
Browse files Browse the repository at this point in the history
* Adding option to hide/ unhide RAP Addresses page manualy

* Code cleanup and build fix
  • Loading branch information
firstcryptoman authored and levonpetrosyan93 committed May 17, 2023
1 parent c7067b6 commit d966b8d
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,10 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *
progressBar->setStyleSheet("QProgressBar { background-color: #e8e8e8; border: 1px solid grey; border-radius: 7px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #FF8000, stop: 1 orange); border-radius: 7px; margin: 0px; }");
}

statusBar()->addWidget(framePending);
statusBar()->addWidget(progressBarLabel);
statusBar()->addWidget(progressBar);
statusBar()->addPermanentWidget(frameBlocks);
statusBar()->addWidget(framePending);

// Install event filter to be able to catch status tip events (QEvent::StatusTip)
this->installEventFilter(this);
Expand Down Expand Up @@ -653,6 +653,10 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel)
// update lelantus page if option is changed.
connect(optionsModel, &OptionsModel::lelantusPageChanged, this, &BitcoinGUI::updateLelantusPage);

// update RAP Addresses page if option is changed.
connect(optionsModel, &OptionsModel::enableRapAddressesChanged, this, &BitcoinGUI::setRapAddressesVisible);
createPcodeAction->setVisible(optionsModel->getRapAddresses());

// initialize the disable state of the tray icon with the current value in the model.
setTrayIconVisible(optionsModel->getHideTrayIcon());
}
Expand Down Expand Up @@ -1461,6 +1465,12 @@ void BitcoinGUI::updateLelantusPage()
checkLelantusVisibility(blocks);
}

void BitcoinGUI::setRapAddressesVisible(bool checked)
{
gotoOverviewPage();
createPcodeAction->setVisible(checked);
}

static bool ThreadSafeMessageBox(BitcoinGUI *gui, const std::string& message, const std::string& caption, unsigned int style)
{
bool modal = (style & CClientUIInterface::MODAL);
Expand Down
3 changes: 3 additions & 0 deletions src/qt/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ public Q_SLOTS:

/** Update Lelantus page visibility */
void updateLelantusPage();

/** Update RAP Addresses page visibility */
void setRapAddressesVisible(bool);
};

class UnitDisplayStatusBarControl : public QLabel
Expand Down
14 changes: 12 additions & 2 deletions src/qt/forms/optionsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>560</width>
<height>440</height>
<width>660</width>
<height>540</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -173,6 +173,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="enableRapAddresses">
<property name="toolTip">
<string>Whether to show RAP addresses or not.</string>
</property>
<property name="text">
<string>Display RAP addresses</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
1 change: 1 addition & 0 deletions src/qt/optionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ void OptionsDialog::setMapper()
mapper->addMapping(ui->spendZeroConfChange, OptionsModel::SpendZeroConfChange);
mapper->addMapping(ui->reindexLelantus, OptionsModel::ReindexLelantus);
mapper->addMapping(ui->coinControlFeatures, OptionsModel::CoinControlFeatures);
mapper->addMapping(ui->enableRapAddresses, OptionsModel::enableRapAddresses);

/* Lelantus */
mapper->addMapping(ui->autoAnonymize, OptionsModel::AutoAnonymize);
Expand Down
11 changes: 11 additions & 0 deletions src/qt/optionsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ void OptionsModel::Init(bool resetSettings)
settings.setValue("fCoinControlFeatures", false);
fCoinControlFeatures = settings.value("fCoinControlFeatures", false).toBool();

if (!settings.contains("fenableRapAddresses"))
settings.setValue("fenableRapAddresses", false);
fenableRapAddresses = settings.value("fenableRapAddresses", false).toBool();

if (!settings.contains("fAutoAnonymize"))
settings.setValue("fAutoAnonymize", false);
fAutoAnonymize = settings.value("fAutoAnonymize", false).toBool();
Expand Down Expand Up @@ -277,6 +281,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
return settings.value("language");
case CoinControlFeatures:
return fCoinControlFeatures;
case enableRapAddresses:
return fenableRapAddresses;
case AutoAnonymize:
return fAutoAnonymize;
case LelantusPage:
Expand Down Expand Up @@ -424,6 +430,11 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
settings.setValue("fCoinControlFeatures", fCoinControlFeatures);
Q_EMIT coinControlFeaturesChanged(fCoinControlFeatures);
break;
case enableRapAddresses:
fenableRapAddresses = value.toBool();
settings.setValue("fenableRapAddresses", fenableRapAddresses);
Q_EMIT enableRapAddressesChanged(fenableRapAddresses);
break;
case AutoAnonymize:
fAutoAnonymize = value.toBool();
settings.setValue("fAutoAnonymize", fAutoAnonymize);
Expand Down
4 changes: 4 additions & 0 deletions src/qt/optionsmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class OptionsModel : public QAbstractListModel
TorSetup, // bool
AutoAnonymize, // bool
LelantusPage, // bool
enableRapAddresses, // bool
OptionIDRowCount,
};

Expand All @@ -70,6 +71,7 @@ class OptionsModel : public QAbstractListModel
QString getThirdPartyTxUrls() { return strThirdPartyTxUrls; }
bool getProxySettings(QNetworkProxy& proxy) const;
bool getCoinControlFeatures() { return fCoinControlFeatures; }
bool getRapAddresses() { return fenableRapAddresses; }
const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; }
bool getAutoAnonymize() { return fAutoAnonymize; }
bool getLelantusPage() {return fLelantusPage; }
Expand All @@ -89,6 +91,7 @@ class OptionsModel : public QAbstractListModel
bool fCoinControlFeatures;
bool fAutoAnonymize;
bool fLelantusPage;
bool fenableRapAddresses;

/* settings that were overridden by command-line */
QString strOverriddenByCommandLine;
Expand All @@ -101,6 +104,7 @@ class OptionsModel : public QAbstractListModel
Q_SIGNALS:
void displayUnitChanged(int unit);
void coinControlFeaturesChanged(bool);
void enableRapAddressesChanged(bool);
void autoAnonymizeChanged(bool);
void lelantusPageChanged(bool);
void hideTrayIconChanged(bool);
Expand Down

0 comments on commit d966b8d

Please sign in to comment.