Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make row color alternating in the Peers tab optional #307

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/qt/forms/debugwindow.ui
Original file line number Diff line number Diff line change
@@ -893,9 +893,6 @@
<property name="tabKeyNavigation">
<bool>false</bool>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="textElideMode">
<enum>Qt::ElideMiddle</enum>
</property>
@@ -957,9 +954,6 @@
<property name="tabKeyNavigation">
<bool>false</bool>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
42 changes: 26 additions & 16 deletions src/qt/forms/optionsdialog.ui
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>560</width>
<height>440</height>
<width>646</width>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit

there's not really a reason to change the size here. I guess this is a good place to answer a question:

"When adding new settings, should we maintain a certain level of padding between the last setting option and its enclosing box?"

Use PR Size Use Master Size
size-increase size-normal

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's not really a reason to change the size here. I guess this is a good place to answer a question:

The reason is that successive openings and closings of the optionsdialog.ui in Qt Designer won't suggest size changes.

<height>529</height>
</rect>
</property>
<property name="windowTitle">
@@ -51,20 +51,20 @@
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_Main_Prune">
<item>
<widget class="QCheckBox" name="prune">
<property name="toolTip">
<string>Enabling pruning significantly reduces the disk space required to store transactions. All blocks are still fully validated. Reverting this setting requires re-downloading the entire blockchain.</string>
</property>
<property name="text">
<string>Prune &amp;block storage to</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="pruneSize"/>
</item>
<layout class="QHBoxLayout" name="horizontalLayout_Main_Prune">
<item>
<widget class="QCheckBox" name="prune">
<property name="toolTip">
<string>Enabling pruning significantly reduces the disk space required to store transactions. All blocks are still fully validated. Reverting this setting requires re-downloading the entire blockchain.</string>
</property>
<property name="text">
<string>Prune &amp;block storage to</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="pruneSize"/>
</item>
<item>
<widget class="QLabel" name="pruneSizeUnitLabel">
<property name="text">
@@ -835,6 +835,16 @@
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="peersTabAlternatingRowColors">
<property name="toolTip">
<string>Alternate the row colors for the &quot;Peers&quot; and &quot;Banned peers&quot; tables in the Peers tab.</string>
</property>
<property name="text">
<string>Alternate row colors in the Peers tab</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_Display">
<property name="orientation">
1 change: 1 addition & 0 deletions src/qt/optionsdialog.cpp
Original file line number Diff line number Diff line change
@@ -263,6 +263,7 @@ void OptionsDialog::setMapper()
mapper->addMapping(ui->unit, OptionsModel::DisplayUnit);
mapper->addMapping(ui->thirdPartyTxUrls, OptionsModel::ThirdPartyTxUrls);
mapper->addMapping(ui->embeddedFont_radioButton, OptionsModel::UseEmbeddedMonospacedFont);
mapper->addMapping(ui->peersTabAlternatingRowColors, OptionsModel::PeersTabAlternatingRowColors);
}

void OptionsDialog::setOkButtonState(bool fState)
13 changes: 13 additions & 0 deletions src/qt/optionsmodel.cpp
Original file line number Diff line number Diff line change
@@ -177,6 +177,12 @@ void OptionsModel::Init(bool resetSettings)
}
m_use_embedded_monospaced_font = settings.value("UseEmbeddedMonospacedFont").toBool();
Q_EMIT useEmbeddedMonospacedFontChanged(m_use_embedded_monospaced_font);

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);
}

/** Helper function to copy contents from one QSettings to another.
@@ -344,6 +350,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
return settings.value("language");
case UseEmbeddedMonospacedFont:
return m_use_embedded_monospaced_font;
case PeersTabAlternatingRowColors:
return m_peers_tab_alternating_row_colors;
case CoinControlFeatures:
return fCoinControlFeatures;
case Prune:
@@ -482,6 +490,11 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
settings.setValue("UseEmbeddedMonospacedFont", m_use_embedded_monospaced_font);
Q_EMIT useEmbeddedMonospacedFontChanged(m_use_embedded_monospaced_font);
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);
52 changes: 28 additions & 24 deletions src/qt/optionsmodel.h
Original file line number Diff line number Diff line change
@@ -44,30 +44,31 @@ class OptionsModel : public QAbstractListModel
explicit OptionsModel(QObject *parent = nullptr, bool resetSettings = false);

enum OptionID {
StartAtStartup, // bool
ShowTrayIcon, // bool
MinimizeToTray, // bool
MapPortUPnP, // bool
MapPortNatpmp, // bool
MinimizeOnClose, // bool
ProxyUse, // bool
ProxyIP, // QString
ProxyPort, // int
ProxyUseTor, // bool
ProxyIPTor, // QString
ProxyPortTor, // int
DisplayUnit, // BitcoinUnits::Unit
ThirdPartyTxUrls, // QString
Language, // QString
UseEmbeddedMonospacedFont, // bool
CoinControlFeatures, // bool
ThreadsScriptVerif, // int
Prune, // bool
PruneSize, // int
DatabaseCache, // int
ExternalSignerPath, // QString
SpendZeroConfChange, // bool
Listen, // bool
StartAtStartup, // bool
ShowTrayIcon, // bool
MinimizeToTray, // bool
MapPortUPnP, // bool
MapPortNatpmp, // bool
MinimizeOnClose, // bool
ProxyUse, // bool
ProxyIP, // QString
ProxyPort, // int
ProxyUseTor, // bool
ProxyIPTor, // QString
ProxyPortTor, // int
DisplayUnit, // BitcoinUnits::Unit
ThirdPartyTxUrls, // QString
Language, // QString
UseEmbeddedMonospacedFont, // bool
PeersTabAlternatingRowColors, // bool
CoinControlFeatures, // bool
ThreadsScriptVerif, // int
Prune, // bool
PruneSize, // int
DatabaseCache, // int
ExternalSignerPath, // QString
SpendZeroConfChange, // bool
Listen, // bool
OptionIDRowCount,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit in 217d42b

While here, you could document the type here is int.

Additionally, if you have to retouch, you could rename the commit from:
gui: Add "Alternating Row Color" settings for the Peers Tab

to:

qt: Add "Alternating Row Color" settings for the Peers Tab

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While here, you could document the type here is int.

I don't think it is required to document the type of a counter, as it is not an option id.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, if you have to retouch, you could rename the commit from:
gui: Add "Alternating Row Color" settings for the Peers Tab

to:

qt: Add "Alternating Row Color" settings for the Peers Tab

Done in the recent push.

};

@@ -87,6 +88,7 @@ class OptionsModel : public QAbstractListModel
int getDisplayUnit() const { return nDisplayUnit; }
QString getThirdPartyTxUrls() const { return strThirdPartyTxUrls; }
bool getUseEmbeddedMonospacedFont() const { return m_use_embedded_monospaced_font; }
bool getPeersTabAlternatingRowColors() const { return m_peers_tab_alternating_row_colors; }
bool getCoinControlFeatures() const { return fCoinControlFeatures; }
const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; }

@@ -111,6 +113,7 @@ class OptionsModel : public QAbstractListModel
int nDisplayUnit;
QString strThirdPartyTxUrls;
bool m_use_embedded_monospaced_font;
bool m_peers_tab_alternating_row_colors;
bool fCoinControlFeatures;
/* settings that were overridden by command-line */
QString strOverriddenByCommandLine;
@@ -125,6 +128,7 @@ class OptionsModel : public QAbstractListModel
void coinControlFeaturesChanged(bool);
void showTrayIconChanged(bool);
void useEmbeddedMonospacedFontChanged(bool);
void peersTabAlternatingRowColorsChanged(bool);
};

#endif // BITCOIN_QT_OPTIONSMODEL_H
9 changes: 9 additions & 0 deletions src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
#include <netbase.h>
#include <qt/bantablemodel.h>
#include <qt/clientmodel.h>
#include <qt/optionsmodel.h>
#include <qt/peertablesortproxy.h>
#include <qt/platformstyle.h>
#include <qt/walletmodel.h>
@@ -489,6 +490,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<QString> CONNECTION_TYPE_DOC{
@@ -658,6 +660,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
ui->peerWidget->setModel(model->peerTableSortProxy());
ui->peerWidget->verticalHeader()->hide();
@@ -672,6 +679,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);
@@ -698,6 +706,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);
1 change: 1 addition & 0 deletions src/qt/rpcconsole.h
Original file line number Diff line number Diff line change
@@ -170,6 +170,7 @@ public Q_SLOTS:
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();