diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui index 9b865ecad2..9957682b5d 100644 --- a/src/qt/forms/optionsdialog.ui +++ b/src/qt/forms/optionsdialog.ui @@ -796,6 +796,16 @@ + + + + Alternate the row colors for the "Peers" and "Banned peers" tables in the Peers tab. + + + Alternate row colors in the Peers tab + + + diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 4db2d6016c..6bef0ea430 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -320,6 +320,7 @@ void OptionsDialog::setMapper() #endif /* Display */ + mapper->addMapping(ui->peersTabAlternatingRowColors, OptionsModel::PeersTabAlternatingRowColors); mapper->addMapping(ui->lang, OptionsModel::Language); mapper->addMapping(ui->unit, OptionsModel::DisplayUnit); mapper->addMapping(ui->thirdPartyTxUrls, OptionsModel::ThirdPartyTxUrls); diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index d15735fa18..9586fb8f29 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -256,6 +256,12 @@ bool OptionsModel::Init(bilingual_str& error) } Q_EMIT fontForMoneyChanged(getFontForMoney()); + if (!settings.contains("PeersTabAlternatingRowColors")) { + settings.setValue("PeersTabAlternatingRowColors", "false"); + } + m_peers_tab_alternating_row_colors = settings.value("PeersTabAlternatingRowColors").toBool(); + Q_EMIT peersTabAlternatingRowColorsChanged(m_peers_tab_alternating_row_colors); + m_mask_values = settings.value("mask_values", false).toBool(); return true; @@ -470,6 +476,8 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con return QString::fromStdString(SettingToString(setting(), "")); case FontForMoney: return QVariant::fromValue(m_font_money); + case PeersTabAlternatingRowColors: + return m_peers_tab_alternating_row_colors; case CoinControlFeatures: return fCoinControlFeatures; case EnablePSBTControls: @@ -654,6 +662,11 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value, const std:: Q_EMIT fontForMoneyChanged(getFontForMoney()); break; } + case PeersTabAlternatingRowColors: + m_peers_tab_alternating_row_colors = value.toBool(); + settings.setValue("PeersTabAlternatingRowColors", m_peers_tab_alternating_row_colors); + Q_EMIT peersTabAlternatingRowColorsChanged(m_peers_tab_alternating_row_colors); + break; case CoinControlFeatures: fCoinControlFeatures = value.toBool(); settings.setValue("fCoinControlFeatures", fCoinControlFeatures); diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index b5ea6c783e..0c45828222 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -63,6 +63,7 @@ public: ThirdPartyTxUrls, // QString Language, // QString FontForMoney, // FontChoice + PeersTabAlternatingRowColors, // bool CoinControlFeatures, // bool SubFeeFromAmount, // bool ThreadsScriptVerif, // int @@ -104,6 +105,7 @@ public: BitcoinUnit getDisplayUnit() const { return m_display_bitcoin_unit; } QString getThirdPartyTxUrls() const { return strThirdPartyTxUrls; } QFont getFontForMoney() const; + bool getPeersTabAlternatingRowColors() const { return m_peers_tab_alternating_row_colors; } bool getCoinControlFeatures() const { return fCoinControlFeatures; } bool getSubFeeFromAmount() const { return m_sub_fee_from_amount; } bool getEnablePSBTControls() const { return m_enable_psbt_controls; } @@ -131,6 +133,7 @@ private: BitcoinUnit m_display_bitcoin_unit; QString strThirdPartyTxUrls; FontChoice m_font_money{FontChoiceAbstract::EmbeddedFont}; + bool m_peers_tab_alternating_row_colors; bool fCoinControlFeatures; bool m_sub_fee_from_amount; bool m_enable_psbt_controls; @@ -153,6 +156,7 @@ Q_SIGNALS: void coinControlFeaturesChanged(bool); void showTrayIconChanged(bool); void fontForMoneyChanged(const QFont&); + void peersTabAlternatingRowColorsChanged(bool); }; Q_DECLARE_METATYPE(OptionsModel::FontChoice) diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index a439170a09..69cf16c42f 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -491,6 +492,7 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty m_peer_widget_header_state = settings.value("PeersTabPeerHeaderState").toByteArray(); m_banlist_widget_header_state = settings.value("PeersTabBanlistHeaderState").toByteArray(); + m_alternating_row_colors = settings.value("PeersTabAlternatingRowColors").toBool(); constexpr QChar nonbreaking_hyphen(8209); const std::vector CONNECTION_TYPE_DOC{ @@ -687,6 +689,11 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_ connect(model, &ClientModel::mempoolSizeChanged, this, &RPCConsole::setMempoolSize); + connect(model->getOptionsModel(), &OptionsModel::peersTabAlternatingRowColorsChanged, [this](bool alternating_row_colors) { + ui->peerWidget->setAlternatingRowColors(alternating_row_colors); + ui->banlistWidget->setAlternatingRowColors(alternating_row_colors); + }); + // set up peer table clientModel->getPeerTableModel()->updatePalette(); ui->peerWidget->setModel(model->peerTableSortProxy()); @@ -711,6 +718,7 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_ } ui->peerWidget->horizontalHeader()->setStretchLastSection(true); ui->peerWidget->setItemDelegateForColumn(PeerTableModel::NetNodeId, new PeerIdViewDelegate(this)); + ui->peerWidget->setAlternatingRowColors(m_alternating_row_colors); // create peer table context menu peersTableContextMenu = new QMenu(this); @@ -745,6 +753,7 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_ ui->banlistWidget->setColumnWidth(BanTableModel::Bantime, BANTIME_COLUMN_WIDTH); } ui->banlistWidget->horizontalHeader()->setStretchLastSection(true); + ui->banlistWidget->setAlternatingRowColors(m_alternating_row_colors); // create ban table context menu banTableContextMenu = new QMenu(this); diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index d88c0d08f1..be5b8377b8 100644 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -180,6 +180,7 @@ private: bool m_is_executing{false}; QByteArray m_peer_widget_header_state; QByteArray m_banlist_widget_header_state; + bool m_alternating_row_colors{false}; /** Update UI with latest network info from model. */ void updateNetworkState();