mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-28 21:12:29 +02:00
[Qt] Adding network port to GUI settings, fixes #7039
Adds Network port input box to the Network tab in the Options dialog. -port takes priority over the GUI setting. If left blank, it will default to the default port
This commit is contained in:
parent
87dbf38e9e
commit
497584d947
@ -315,6 +315,55 @@
|
||||
<string>&Network</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_Network">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_1_Network">
|
||||
<item>
|
||||
<widget class="QLabel" name="networkPortLabel">
|
||||
<property name="text">
|
||||
<string>Network &port</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>networkPort</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="networkPort">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>55</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>55</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Network port (e.g. 8333)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_1_Network">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="mapPortUpnp">
|
||||
<property name="toolTip">
|
||||
@ -356,7 +405,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_1_Network">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2_Network">
|
||||
<item>
|
||||
<widget class="QLabel" name="proxyIpLabel">
|
||||
<property name="text">
|
||||
@ -422,7 +471,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_1_Network">
|
||||
<spacer name="horizontalSpacer_2_Network">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
@ -437,7 +486,7 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2_Network">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3_Network">
|
||||
<item>
|
||||
<widget class="QLabel" name="proxyActiveNets">
|
||||
<property name="text">
|
||||
@ -518,7 +567,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2_Network">
|
||||
<spacer name="horizontalSpacer_3_Network">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
@ -543,7 +592,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3_Network">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4_Network">
|
||||
<item>
|
||||
<widget class="QLabel" name="proxyIpTorLabel">
|
||||
<property name="text">
|
||||
|
@ -105,6 +105,8 @@ OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet)
|
||||
ui->pruneSize->setEnabled(false);
|
||||
connect(ui->prune, &QPushButton::toggled, ui->pruneSize, &QWidget::setEnabled);
|
||||
|
||||
ui->networkPort->setValidator(new QIntValidator(1, 65535, this));
|
||||
|
||||
/* Network elements init */
|
||||
#ifndef USE_UPNP
|
||||
ui->mapPortUpnp->setEnabled(false);
|
||||
@ -270,6 +272,7 @@ void OptionsDialog::setModel(OptionsModel *_model)
|
||||
/* Wallet */
|
||||
connect(ui->spendZeroConfChange, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
|
||||
/* Network */
|
||||
connect(ui->networkPort, SIGNAL(textChanged(const QString &)), this, SLOT(showRestartWarning()));
|
||||
connect(ui->allowIncoming, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
|
||||
connect(ui->enableServer, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
|
||||
connect(ui->connectSocks, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
|
||||
@ -306,6 +309,7 @@ void OptionsDialog::setMapper()
|
||||
mapper->addMapping(ui->m_enable_psbt_controls, OptionsModel::EnablePSBTControls);
|
||||
|
||||
/* Network */
|
||||
mapper->addMapping(ui->networkPort, OptionsModel::NetworkPort);
|
||||
mapper->addMapping(ui->mapPortUpnp, OptionsModel::MapPortUPnP);
|
||||
mapper->addMapping(ui->mapPortNatpmp, OptionsModel::MapPortNatpmp);
|
||||
mapper->addMapping(ui->allowIncoming, OptionsModel::Listen);
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <qt/guiconstants.h>
|
||||
#include <qt/guiutil.h>
|
||||
|
||||
#include <chainparams.h>
|
||||
#include <common/args.h>
|
||||
#include <interfaces/node.h>
|
||||
#include <mapport.h>
|
||||
@ -244,6 +245,12 @@ bool OptionsModel::Init(bilingual_str& error)
|
||||
m_sub_fee_from_amount = settings.value("SubFeeFromAmount", false).toBool();
|
||||
#endif
|
||||
|
||||
// Network
|
||||
if (!settings.contains("nNetworkPort"))
|
||||
settings.setValue("nNetworkPort", (quint16)Params().GetDefaultPort());
|
||||
if (!gArgs.SoftSetArg("-port", settings.value("nNetworkPort").toString().toStdString()))
|
||||
addOverriddenOption("-port");
|
||||
|
||||
// Display
|
||||
if (settings.contains("FontForMoney")) {
|
||||
m_font_money = FontChoiceFromString(settings.value("FontForMoney").toString());
|
||||
@ -418,6 +425,8 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con
|
||||
return m_show_tray_icon;
|
||||
case MinimizeToTray:
|
||||
return fMinimizeToTray;
|
||||
case NetworkPort:
|
||||
return settings.value("nNetworkPort");
|
||||
case MapPortUPnP:
|
||||
#ifdef USE_UPNP
|
||||
return SettingToBool(setting(), DEFAULT_UPNP);
|
||||
@ -544,6 +553,18 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value, const std::
|
||||
fMinimizeToTray = value.toBool();
|
||||
settings.setValue("fMinimizeToTray", fMinimizeToTray);
|
||||
break;
|
||||
case NetworkPort:
|
||||
if (settings.value("nNetworkPort") != value) {
|
||||
// If the port input box is empty, set to default port
|
||||
if (value.toString().isEmpty()) {
|
||||
settings.setValue("nNetworkPort", (quint16)Params().GetDefaultPort());
|
||||
}
|
||||
else {
|
||||
settings.setValue("nNetworkPort", (quint16)value.toInt());
|
||||
}
|
||||
setRestartRequired(true);
|
||||
}
|
||||
break;
|
||||
case MapPortUPnP: // core option - can be changed on-the-fly
|
||||
if (changed()) {
|
||||
update(value.toBool());
|
||||
|
@ -50,6 +50,7 @@ public:
|
||||
StartAtStartup, // bool
|
||||
ShowTrayIcon, // bool
|
||||
MinimizeToTray, // bool
|
||||
NetworkPort, // int
|
||||
MapPortUPnP, // bool
|
||||
MapPortNatpmp, // bool
|
||||
MinimizeOnClose, // bool
|
||||
|
Loading…
Reference in New Issue
Block a user