-
Notifications
You must be signed in to change notification settings - Fork 124
GUI: Visually move and rephrase port mapping checkboxes #197
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
base: 29.x-knots
Are you sure you want to change the base?
Changes from all commits
e338aec
1d3cb22
b16faeb
07b3d87
4324e84
49fd570
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,6 +100,7 @@ void OptionsDialog::FixTabOrder(QWidget * const o) | |
struct CreateOptionUIOpts { | ||
QBoxLayout *horizontal_layout{nullptr}; | ||
int stretch{1}; | ||
int insert_at{-1}; | ||
int indent{0}; | ||
}; | ||
|
||
|
@@ -153,7 +154,7 @@ void OptionsDialog::CreateOptionUI(QBoxLayout * const layout, const QString& tex | |
|
||
if (opts.stretch) horizontalLayout->addStretch(opts.stretch); | ||
|
||
layout->addLayout(horizontalLayout); | ||
layout->insertLayout(opts.insert_at, horizontalLayout); | ||
|
||
for (auto& o : objs) { | ||
o->setProperty("L", QVariant::fromValue((QLayout*)horizontalLayout)); | ||
|
@@ -266,10 +267,6 @@ OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet) | |
connect(ui->networkPort, SIGNAL(textChanged(const QString&)), this, SLOT(checkLineEdit())); | ||
|
||
/* Network elements init */ | ||
#ifndef USE_UPNP | ||
ui->mapPortUpnp->setEnabled(false); | ||
#endif | ||
|
||
ui->proxyIp->setEnabled(false); | ||
ui->proxyPort->setEnabled(false); | ||
ui->proxyPort->setValidator(new QIntValidator(1, 65535, this)); | ||
|
@@ -298,8 +295,29 @@ OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet) | |
ui->verticalLayout_Wallet->insertWidget(0, walletrbf); | ||
FixTabOrder(walletrbf); | ||
|
||
QStyleOptionButton styleoptbtn; | ||
const auto checkbox_indent = ui->allowIncoming->style()->subElementRect(QStyle::SE_CheckBoxIndicator, &styleoptbtn, ui->allowIncoming).width(); | ||
|
||
/* Network tab */ | ||
QLayoutItem *spacer = ui->verticalLayout_Network->takeAt(ui->verticalLayout_Network->count() - 1); | ||
|
||
prevwidget = ui->allowIncoming; | ||
ui->verticalLayout_Network->removeWidget(ui->mapPortNatpmp); | ||
luke-jr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
int insert_at = ui->verticalLayout_Network->indexOf(ui->connectSocks); | ||
// NOTE: Re-inserted in bottom-to-top order | ||
CreateOptionUI(ui->verticalLayout_Network, QStringLiteral("%1"), {ui->mapPortNatpmp}, { .insert_at=insert_at, .indent=checkbox_indent, }); | ||
upnp = new QCheckBox(ui->tabNetwork); | ||
upnp->setText(tr("Automatically configure router(s) that support &UPnP")); | ||
upnp->setToolTip(tr("Automatically open the Bitcoin client port on the router. This only works when your router supports UPnP and it is enabled.")); | ||
#ifndef USE_UPNP | ||
upnp->setEnabled(false); | ||
#endif | ||
CreateOptionUI(ui->verticalLayout_Network, QStringLiteral("%1"), {upnp}, { .insert_at=insert_at, .indent=checkbox_indent, }); | ||
connect(ui->allowIncoming, &QPushButton::toggled, upnp, &QWidget::setEnabled); | ||
connect(ui->allowIncoming, &QPushButton::toggled, ui->mapPortNatpmp, &QWidget::setEnabled); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lines 316, 317 - allowIncoming is a QCheckBox not a QPushButton. code for the signal works fine of course, but may be better to just use QCheckBox::toggled to be correct. |
||
upnp->setEnabled(ui->allowIncoming->isChecked()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i believe line 318 will override the #ifndef USE_UPNP behavior here - not sure that is the intended behavior. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line 316 also.. since again, this would allow it to be enabled even if USE_UPNP is 0. I wonder if it makes sense to SHOW this checkbox if no USE_UPNP... could do something altogether like this:
|
||
ui->mapPortNatpmp->setEnabled(ui->allowIncoming->isChecked()); | ||
|
||
prevwidget = dynamic_cast<QWidgetItem*>(ui->verticalLayout_Network->itemAt(ui->verticalLayout_Network->count() - 1))->widget(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this is NOT code changed by the PR... line 321 - but stared at it for a while as it comes right after a big block of changed code. first, this code seems potentially very fragile... seems to require assumptions as to what comes previously. I may be wrong here. just jumps out to me as fragile. plus, doesn't seem to do anything useful here. prevwidget is just set here on line 321, not used, and then set again on line 336 to an explicit widget. might be out-of-scope for this PR... but me no likey There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's used in |
||
|
||
blockreconstructionextratxn = new QSpinBox(ui->tabNetwork); | ||
|
@@ -552,9 +570,6 @@ OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet) | |
dustdynamic_multiplier->setValue(DEFAULT_DUST_RELAY_MULTIPLIER / 1000.0); | ||
CreateOptionUI(verticalLayout_Spamfiltering, tr("%1 Automatically adjust the dust limit upward to %2 times:"), {dustdynamic_enable, dustdynamic_multiplier}); | ||
|
||
QStyleOptionButton styleoptbtn; | ||
const auto checkbox_indent = dustdynamic_enable->style()->subElementRect(QStyle::SE_CheckBoxIndicator, &styleoptbtn, dustdynamic_enable).width(); | ||
|
||
dustdynamic_target = new QRadioButton(groupBox_Spamfiltering); | ||
dustdynamic_target_blocks = new QSpinBox(groupBox_Spamfiltering); | ||
dustdynamic_target_blocks->setMinimum(2); | ||
|
@@ -851,7 +866,7 @@ void OptionsDialog::setMapper() | |
|
||
/* Network */ | ||
mapper->addMapping(ui->networkPort, OptionsModel::NetworkPort); | ||
mapper->addMapping(ui->mapPortUpnp, OptionsModel::MapPortUPnP); | ||
mapper->addMapping(upnp, OptionsModel::MapPortUPnP); | ||
mapper->addMapping(ui->mapPortNatpmp, OptionsModel::MapPortNatpmp); | ||
mapper->addMapping(ui->allowIncoming, OptionsModel::Listen); | ||
mapper->addMapping(ui->enableServer, OptionsModel::Server); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not
false
, why"0"
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ForceSetArg
only accepts strings.