mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-29 13:32:33 +02:00
Merge branch 'qt_fontsel_qrcodes-27+knots' into qtnetworkport-28+knots
This commit is contained in:
commit
87dbf38e9e
@ -796,6 +796,41 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_qrFont">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="qrFontLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Font in QR Codes: </string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>qrFont</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="qrFont"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="qrFont_preview">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">1NS17iag9jJgT…
|
||||||
|
bc1p2q3rvn3gp…</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="peersTabAlternatingRowColors">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Alternate the row colors for the "Peers" and "Banned peers" tables in the Peers tab.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Alternate row colors in the Peers tab</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_Display">
|
<spacer name="verticalSpacer_Display">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -206,6 +206,12 @@ OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet)
|
|||||||
}
|
}
|
||||||
|
|
||||||
setupFontOptions(ui->moneyFont, ui->moneyFont_preview);
|
setupFontOptions(ui->moneyFont, ui->moneyFont_preview);
|
||||||
|
setupFontOptions(ui->qrFont, ui->qrFont_preview);
|
||||||
|
#ifndef USE_QRCODE
|
||||||
|
ui->qrFontLabel->setVisible(false);
|
||||||
|
ui->qrFont->setVisible(false);
|
||||||
|
ui->qrFont_preview->setVisible(false);
|
||||||
|
#endif
|
||||||
|
|
||||||
GUIUtil::handleCloseWindowShortcut(this);
|
GUIUtil::handleCloseWindowShortcut(this);
|
||||||
}
|
}
|
||||||
@ -246,6 +252,9 @@ void OptionsDialog::setModel(OptionsModel *_model)
|
|||||||
const auto& font_for_money = _model->data(_model->index(OptionsModel::FontForMoney, 0), Qt::EditRole).value<OptionsModel::FontChoice>();
|
const auto& font_for_money = _model->data(_model->index(OptionsModel::FontForMoney, 0), Qt::EditRole).value<OptionsModel::FontChoice>();
|
||||||
setFontChoice(ui->moneyFont, font_for_money);
|
setFontChoice(ui->moneyFont, font_for_money);
|
||||||
|
|
||||||
|
const auto& font_for_qrcodes = _model->data(_model->index(OptionsModel::FontForQRCodes, 0), Qt::EditRole).value<OptionsModel::FontChoice>();
|
||||||
|
setFontChoice(ui->qrFont, font_for_qrcodes);
|
||||||
|
|
||||||
updateDefaultProxyNets();
|
updateDefaultProxyNets();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,6 +329,7 @@ void OptionsDialog::setMapper()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Display */
|
/* Display */
|
||||||
|
mapper->addMapping(ui->peersTabAlternatingRowColors, OptionsModel::PeersTabAlternatingRowColors);
|
||||||
mapper->addMapping(ui->lang, OptionsModel::Language);
|
mapper->addMapping(ui->lang, OptionsModel::Language);
|
||||||
mapper->addMapping(ui->unit, OptionsModel::DisplayUnit);
|
mapper->addMapping(ui->unit, OptionsModel::DisplayUnit);
|
||||||
mapper->addMapping(ui->thirdPartyTxUrls, OptionsModel::ThirdPartyTxUrls);
|
mapper->addMapping(ui->thirdPartyTxUrls, OptionsModel::ThirdPartyTxUrls);
|
||||||
@ -385,6 +395,7 @@ void OptionsDialog::on_openBitcoinConfButton_clicked()
|
|||||||
void OptionsDialog::on_okButton_clicked()
|
void OptionsDialog::on_okButton_clicked()
|
||||||
{
|
{
|
||||||
model->setData(model->index(OptionsModel::FontForMoney, 0), ui->moneyFont->itemData(ui->moneyFont->currentIndex()));
|
model->setData(model->index(OptionsModel::FontForMoney, 0), ui->moneyFont->itemData(ui->moneyFont->currentIndex()));
|
||||||
|
model->setData(model->index(OptionsModel::FontForQRCodes, 0), ui->qrFont->itemData(ui->qrFont->currentIndex()));
|
||||||
|
|
||||||
mapper->submit();
|
mapper->submit();
|
||||||
accept();
|
accept();
|
||||||
|
@ -256,6 +256,17 @@ bool OptionsModel::Init(bilingual_str& error)
|
|||||||
}
|
}
|
||||||
Q_EMIT fontForMoneyChanged(getFontForMoney());
|
Q_EMIT fontForMoneyChanged(getFontForMoney());
|
||||||
|
|
||||||
|
if (settings.contains("FontForQRCodes")) {
|
||||||
|
m_font_qrcodes = FontChoiceFromString(settings.value("FontForQRCodes").toString());
|
||||||
|
}
|
||||||
|
Q_EMIT fontForQRCodesChanged(getFontChoiceForQRCodes());
|
||||||
|
|
||||||
|
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();
|
m_mask_values = settings.value("mask_values", false).toBool();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -465,6 +476,10 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con
|
|||||||
return QString::fromStdString(SettingToString(setting(), ""));
|
return QString::fromStdString(SettingToString(setting(), ""));
|
||||||
case FontForMoney:
|
case FontForMoney:
|
||||||
return QVariant::fromValue(m_font_money);
|
return QVariant::fromValue(m_font_money);
|
||||||
|
case FontForQRCodes:
|
||||||
|
return QVariant::fromValue(m_font_qrcodes);
|
||||||
|
case PeersTabAlternatingRowColors:
|
||||||
|
return m_peers_tab_alternating_row_colors;
|
||||||
case CoinControlFeatures:
|
case CoinControlFeatures:
|
||||||
return fCoinControlFeatures;
|
return fCoinControlFeatures;
|
||||||
case EnablePSBTControls:
|
case EnablePSBTControls:
|
||||||
@ -649,6 +664,20 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value, const std::
|
|||||||
Q_EMIT fontForMoneyChanged(getFontForMoney());
|
Q_EMIT fontForMoneyChanged(getFontForMoney());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case FontForQRCodes:
|
||||||
|
{
|
||||||
|
const auto& new_font = value.value<FontChoice>();
|
||||||
|
if (m_font_qrcodes == new_font) break;
|
||||||
|
settings.setValue("FontForQRCodes", FontChoiceToString(new_font));
|
||||||
|
m_font_qrcodes = new_font;
|
||||||
|
Q_EMIT fontForQRCodesChanged(new_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:
|
case CoinControlFeatures:
|
||||||
fCoinControlFeatures = value.toBool();
|
fCoinControlFeatures = value.toBool();
|
||||||
settings.setValue("fCoinControlFeatures", fCoinControlFeatures);
|
settings.setValue("fCoinControlFeatures", fCoinControlFeatures);
|
||||||
|
@ -63,6 +63,8 @@ public:
|
|||||||
ThirdPartyTxUrls, // QString
|
ThirdPartyTxUrls, // QString
|
||||||
Language, // QString
|
Language, // QString
|
||||||
FontForMoney, // FontChoice
|
FontForMoney, // FontChoice
|
||||||
|
FontForQRCodes, // FontChoice
|
||||||
|
PeersTabAlternatingRowColors, // bool
|
||||||
CoinControlFeatures, // bool
|
CoinControlFeatures, // bool
|
||||||
SubFeeFromAmount, // bool
|
SubFeeFromAmount, // bool
|
||||||
ThreadsScriptVerif, // int
|
ThreadsScriptVerif, // int
|
||||||
@ -104,6 +106,8 @@ public:
|
|||||||
BitcoinUnit getDisplayUnit() const { return m_display_bitcoin_unit; }
|
BitcoinUnit getDisplayUnit() const { return m_display_bitcoin_unit; }
|
||||||
QString getThirdPartyTxUrls() const { return strThirdPartyTxUrls; }
|
QString getThirdPartyTxUrls() const { return strThirdPartyTxUrls; }
|
||||||
QFont getFontForMoney() const;
|
QFont getFontForMoney() const;
|
||||||
|
FontChoice getFontChoiceForQRCodes() const { return m_font_qrcodes; }
|
||||||
|
bool getPeersTabAlternatingRowColors() const { return m_peers_tab_alternating_row_colors; }
|
||||||
bool getCoinControlFeatures() const { return fCoinControlFeatures; }
|
bool getCoinControlFeatures() const { return fCoinControlFeatures; }
|
||||||
bool getSubFeeFromAmount() const { return m_sub_fee_from_amount; }
|
bool getSubFeeFromAmount() const { return m_sub_fee_from_amount; }
|
||||||
bool getEnablePSBTControls() const { return m_enable_psbt_controls; }
|
bool getEnablePSBTControls() const { return m_enable_psbt_controls; }
|
||||||
@ -131,6 +135,8 @@ private:
|
|||||||
BitcoinUnit m_display_bitcoin_unit;
|
BitcoinUnit m_display_bitcoin_unit;
|
||||||
QString strThirdPartyTxUrls;
|
QString strThirdPartyTxUrls;
|
||||||
FontChoice m_font_money{FontChoiceAbstract::EmbeddedFont};
|
FontChoice m_font_money{FontChoiceAbstract::EmbeddedFont};
|
||||||
|
FontChoice m_font_qrcodes{FontChoiceAbstract::EmbeddedFont};
|
||||||
|
bool m_peers_tab_alternating_row_colors;
|
||||||
bool fCoinControlFeatures;
|
bool fCoinControlFeatures;
|
||||||
bool m_sub_fee_from_amount;
|
bool m_sub_fee_from_amount;
|
||||||
bool m_enable_psbt_controls;
|
bool m_enable_psbt_controls;
|
||||||
@ -153,6 +159,8 @@ Q_SIGNALS:
|
|||||||
void coinControlFeaturesChanged(bool);
|
void coinControlFeaturesChanged(bool);
|
||||||
void showTrayIconChanged(bool);
|
void showTrayIconChanged(bool);
|
||||||
void fontForMoneyChanged(const QFont&);
|
void fontForMoneyChanged(const QFont&);
|
||||||
|
void fontForQRCodesChanged(const FontChoice&);
|
||||||
|
void peersTabAlternatingRowColorsChanged(bool);
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(OptionsModel::FontChoice)
|
Q_DECLARE_METATYPE(OptionsModel::FontChoice)
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <qt/qrimagewidget.h>
|
#include <qt/qrimagewidget.h>
|
||||||
|
|
||||||
#include <qt/guiutil.h>
|
#include <qt/guiutil.h>
|
||||||
|
#include <qt/optionsmodel.h>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
@ -29,7 +30,7 @@ QRImageWidget::QRImageWidget(QWidget* parent)
|
|||||||
contextMenu->addAction(tr("&Copy Image"), this, &QRImageWidget::copyImage);
|
contextMenu->addAction(tr("&Copy Image"), this, &QRImageWidget::copyImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QRImageWidget::setQR(const QString& data, const QString& text)
|
bool QRImageWidget::setQR(const QString& data, const QString& text, const OptionsModel::FontChoice& fontchoice)
|
||||||
{
|
{
|
||||||
#ifdef USE_QRCODE
|
#ifdef USE_QRCODE
|
||||||
setText("");
|
setText("");
|
||||||
@ -48,36 +49,71 @@ bool QRImageWidget::setQR(const QString& data, const QString& text)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage qrImage = QImage(code->width + 8, code->width + 8, QImage::Format_RGB32);
|
QImage qrImage = QImage(code->width, code->width, QImage::Format_RGB32);
|
||||||
qrImage.fill(0xffffff);
|
|
||||||
unsigned char *p = code->data;
|
unsigned char *p = code->data;
|
||||||
for (int y = 0; y < code->width; ++y) {
|
for (int y = 0; y < code->width; ++y) {
|
||||||
for (int x = 0; x < code->width; ++x) {
|
for (int x = 0; x < code->width; ++x) {
|
||||||
qrImage.setPixel(x + 4, y + 4, ((*p & 1) ? 0x0 : 0xffffff));
|
qrImage.setPixel(x, y, ((*p & 1) ? 0x0 : 0xffffff));
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QRcode_free(code);
|
QRcode_free(code);
|
||||||
|
|
||||||
const int qr_image_size = QR_IMAGE_SIZE + (text.isEmpty() ? 0 : 2 * QR_IMAGE_MARGIN);
|
int qr_image_width = QR_IMAGE_SIZE + (2 * QR_IMAGE_MARGIN);
|
||||||
QImage qrAddrImage(qr_image_size, qr_image_size, QImage::Format_RGB32);
|
int qr_image_height = qr_image_width;
|
||||||
|
int qr_image_x_margin = QR_IMAGE_MARGIN;
|
||||||
|
int text_lines;
|
||||||
|
QFont font;
|
||||||
|
if (text.isEmpty()) {
|
||||||
|
text_lines = 0;
|
||||||
|
} else {
|
||||||
|
const int max_text_width = qr_image_width - (2 * QR_IMAGE_TEXT_MARGIN);
|
||||||
|
|
||||||
|
// Determine font to use
|
||||||
|
if (std::holds_alternative<OptionsModel::FontChoiceAbstract>(fontchoice)) {
|
||||||
|
font = GUIUtil::fixedPitchFont(fontchoice != OptionsModel::UseBestSystemFont);
|
||||||
|
font.setWeight(QFont::Bold);
|
||||||
|
font.setStretch(QFont::SemiCondensed);
|
||||||
|
font.setLetterSpacing(QFont::AbsoluteSpacing, 1);
|
||||||
|
|
||||||
|
const qreal font_size = GUIUtil::calculateIdealFontSize(max_text_width, text, font);
|
||||||
|
font.setPointSizeF(font_size);
|
||||||
|
} else {
|
||||||
|
font = std::get<QFont>(fontchoice);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Plan how many lines are needed
|
||||||
|
QFontMetrics fm(font);
|
||||||
|
const int text_width = GUIUtil::TextWidth(fm, text);
|
||||||
|
if (text_width > max_text_width && text_width < max_text_width * 5 / 4) {
|
||||||
|
// Allow the image to grow up to 25% wider
|
||||||
|
qr_image_width = text_width + (2 * QR_IMAGE_TEXT_MARGIN);
|
||||||
|
qr_image_x_margin = (qr_image_width - QR_IMAGE_SIZE) / 2;
|
||||||
|
text_lines = 1;
|
||||||
|
} else {
|
||||||
|
text_lines = (text_width + max_text_width - 1) / max_text_width;
|
||||||
|
}
|
||||||
|
qr_image_height += (fm.height() * text_lines) + QR_IMAGE_TEXT_MARGIN;
|
||||||
|
}
|
||||||
|
QImage qrAddrImage(qr_image_width, qr_image_height, QImage::Format_RGB32);
|
||||||
qrAddrImage.fill(0xffffff);
|
qrAddrImage.fill(0xffffff);
|
||||||
{
|
{
|
||||||
QPainter painter(&qrAddrImage);
|
QPainter painter(&qrAddrImage);
|
||||||
painter.drawImage(QR_IMAGE_MARGIN, 0, qrImage.scaled(QR_IMAGE_SIZE, QR_IMAGE_SIZE));
|
painter.drawImage(qr_image_x_margin, QR_IMAGE_MARGIN, qrImage.scaled(QR_IMAGE_SIZE, QR_IMAGE_SIZE));
|
||||||
|
|
||||||
if (!text.isEmpty()) {
|
if (!text.isEmpty()) {
|
||||||
QRect paddedRect = qrAddrImage.rect();
|
QRect paddedRect = qrAddrImage.rect();
|
||||||
paddedRect.setHeight(QR_IMAGE_SIZE + QR_IMAGE_TEXT_MARGIN);
|
paddedRect.setHeight(paddedRect.height() - QR_IMAGE_TEXT_MARGIN);
|
||||||
|
|
||||||
QFont font = GUIUtil::fixedPitchFont();
|
QString text_wrapped = text;
|
||||||
font.setStretch(QFont::SemiCondensed);
|
const int char_per_line = (text.size() + text_lines - 1) / text_lines;
|
||||||
font.setLetterSpacing(QFont::AbsoluteSpacing, 1);
|
for (int line = 1, pos = 0; line < text_lines; ++line) {
|
||||||
const qreal font_size = GUIUtil::calculateIdealFontSize(paddedRect.width() - 2 * QR_IMAGE_TEXT_MARGIN, text, font);
|
pos += char_per_line;
|
||||||
font.setPointSizeF(font_size);
|
text_wrapped.insert(pos, QChar{'\n'});
|
||||||
|
}
|
||||||
|
|
||||||
painter.setFont(font);
|
painter.setFont(font);
|
||||||
painter.drawText(paddedRect, Qt::AlignBottom | Qt::AlignCenter, text);
|
painter.drawText(paddedRect, Qt::AlignBottom | Qt::AlignCenter, text_wrapped);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,6 +126,11 @@ bool QRImageWidget::setQR(const QString& data, const QString& text)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QRImageWidget::setQR(const QString& data)
|
||||||
|
{
|
||||||
|
return setQR(data, "", OptionsModel::FontChoiceAbstract::EmbeddedFont);
|
||||||
|
}
|
||||||
|
|
||||||
QImage QRImageWidget::exportImage()
|
QImage QRImageWidget::exportImage()
|
||||||
{
|
{
|
||||||
return GUIUtil::GetImage(this);
|
return GUIUtil::GetImage(this);
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#ifndef BITCOIN_QT_QRIMAGEWIDGET_H
|
#ifndef BITCOIN_QT_QRIMAGEWIDGET_H
|
||||||
#define BITCOIN_QT_QRIMAGEWIDGET_H
|
#define BITCOIN_QT_QRIMAGEWIDGET_H
|
||||||
|
|
||||||
|
#include <qt/optionsmodel.h>
|
||||||
|
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
@ -12,9 +14,9 @@
|
|||||||
static const int MAX_URI_LENGTH = 255;
|
static const int MAX_URI_LENGTH = 255;
|
||||||
|
|
||||||
/* Size of exported QR Code image */
|
/* Size of exported QR Code image */
|
||||||
static constexpr int QR_IMAGE_SIZE = 300;
|
static constexpr int QR_IMAGE_SIZE = 252;
|
||||||
static constexpr int QR_IMAGE_TEXT_MARGIN = 10;
|
static constexpr int QR_IMAGE_TEXT_MARGIN = 8;
|
||||||
static constexpr int QR_IMAGE_MARGIN = 2 * QR_IMAGE_TEXT_MARGIN;
|
static constexpr int QR_IMAGE_MARGIN = 24;
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QMenu;
|
class QMenu;
|
||||||
@ -29,7 +31,8 @@ class QRImageWidget : public QLabel
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit QRImageWidget(QWidget *parent = nullptr);
|
explicit QRImageWidget(QWidget *parent = nullptr);
|
||||||
bool setQR(const QString& data, const QString& text = "");
|
bool setQR(const QString& data);
|
||||||
|
bool setQR(const QString& data, const QString& text, const OptionsModel::FontChoice& fontchoice);
|
||||||
QImage exportImage();
|
QImage exportImage();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
|
@ -47,8 +47,11 @@ void ReceiveRequestDialog::setInfo(const SendCoinsRecipient &_info)
|
|||||||
QString uri = GUIUtil::formatBitcoinURI(info);
|
QString uri = GUIUtil::formatBitcoinURI(info);
|
||||||
|
|
||||||
#ifdef USE_QRCODE
|
#ifdef USE_QRCODE
|
||||||
if (ui->qr_code->setQR(uri, info.address)) {
|
if (ui->qr_code->setQR(uri, info.address, model->getOptionsModel()->getFontChoiceForQRCodes())) {
|
||||||
connect(ui->btnSaveAs, &QPushButton::clicked, ui->qr_code, &QRImageWidget::saveImage);
|
connect(ui->btnSaveAs, &QPushButton::clicked, ui->qr_code, &QRImageWidget::saveImage);
|
||||||
|
connect(model->getOptionsModel(), &OptionsModel::fontForQRCodesChanged, this, [&](const OptionsModel::FontChoice& fontchoice){
|
||||||
|
ui->qr_code->setQR(uri, info.address, fontchoice);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
ui->btnSaveAs->setEnabled(false);
|
ui->btnSaveAs->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <qt/bantablemodel.h>
|
#include <qt/bantablemodel.h>
|
||||||
#include <qt/clientmodel.h>
|
#include <qt/clientmodel.h>
|
||||||
#include <qt/guiutil.h>
|
#include <qt/guiutil.h>
|
||||||
|
#include <qt/optionsmodel.h>
|
||||||
#include <qt/peertablesortproxy.h>
|
#include <qt/peertablesortproxy.h>
|
||||||
#include <qt/platformstyle.h>
|
#include <qt/platformstyle.h>
|
||||||
#include <qt/walletmodel.h>
|
#include <qt/walletmodel.h>
|
||||||
@ -490,6 +491,7 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty
|
|||||||
|
|
||||||
m_peer_widget_header_state = settings.value("PeersTabPeerHeaderState").toByteArray();
|
m_peer_widget_header_state = settings.value("PeersTabPeerHeaderState").toByteArray();
|
||||||
m_banlist_widget_header_state = settings.value("PeersTabBanlistHeaderState").toByteArray();
|
m_banlist_widget_header_state = settings.value("PeersTabBanlistHeaderState").toByteArray();
|
||||||
|
m_alternating_row_colors = settings.value("PeersTabAlternatingRowColors").toBool();
|
||||||
|
|
||||||
constexpr QChar nonbreaking_hyphen(8209);
|
constexpr QChar nonbreaking_hyphen(8209);
|
||||||
const std::vector<QString> CONNECTION_TYPE_DOC{
|
const std::vector<QString> CONNECTION_TYPE_DOC{
|
||||||
@ -686,6 +688,11 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
|
|||||||
|
|
||||||
connect(model, &ClientModel::mempoolSizeChanged, this, &RPCConsole::setMempoolSize);
|
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
|
// set up peer table
|
||||||
ui->peerWidget->setModel(model->peerTableSortProxy());
|
ui->peerWidget->setModel(model->peerTableSortProxy());
|
||||||
ui->peerWidget->verticalHeader()->hide();
|
ui->peerWidget->verticalHeader()->hide();
|
||||||
@ -701,6 +708,7 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
|
|||||||
ui->peerWidget->horizontalHeader()->setSectionResizeMode(PeerTableModel::Age, QHeaderView::ResizeToContents);
|
ui->peerWidget->horizontalHeader()->setSectionResizeMode(PeerTableModel::Age, QHeaderView::ResizeToContents);
|
||||||
ui->peerWidget->horizontalHeader()->setStretchLastSection(true);
|
ui->peerWidget->horizontalHeader()->setStretchLastSection(true);
|
||||||
ui->peerWidget->setItemDelegateForColumn(PeerTableModel::NetNodeId, new PeerIdViewDelegate(this));
|
ui->peerWidget->setItemDelegateForColumn(PeerTableModel::NetNodeId, new PeerIdViewDelegate(this));
|
||||||
|
ui->peerWidget->setAlternatingRowColors(m_alternating_row_colors);
|
||||||
|
|
||||||
// create peer table context menu
|
// create peer table context menu
|
||||||
peersTableContextMenu = new QMenu(this);
|
peersTableContextMenu = new QMenu(this);
|
||||||
@ -733,6 +741,7 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
|
|||||||
}
|
}
|
||||||
ui->banlistWidget->horizontalHeader()->setSectionResizeMode(BanTableModel::Address, QHeaderView::ResizeToContents);
|
ui->banlistWidget->horizontalHeader()->setSectionResizeMode(BanTableModel::Address, QHeaderView::ResizeToContents);
|
||||||
ui->banlistWidget->horizontalHeader()->setStretchLastSection(true);
|
ui->banlistWidget->horizontalHeader()->setStretchLastSection(true);
|
||||||
|
ui->banlistWidget->setAlternatingRowColors(m_alternating_row_colors);
|
||||||
|
|
||||||
// create ban table context menu
|
// create ban table context menu
|
||||||
banTableContextMenu = new QMenu(this);
|
banTableContextMenu = new QMenu(this);
|
||||||
|
@ -177,6 +177,7 @@ private:
|
|||||||
bool m_is_executing{false};
|
bool m_is_executing{false};
|
||||||
QByteArray m_peer_widget_header_state;
|
QByteArray m_peer_widget_header_state;
|
||||||
QByteArray m_banlist_widget_header_state;
|
QByteArray m_banlist_widget_header_state;
|
||||||
|
bool m_alternating_row_colors{false};
|
||||||
|
|
||||||
/** Update UI with latest network info from model. */
|
/** Update UI with latest network info from model. */
|
||||||
void updateNetworkState();
|
void updateNetworkState();
|
||||||
|
Loading…
Reference in New Issue
Block a user