Mercurial > hg > bitcoin
annotate src/qt/optionsdialog.cpp @ 2759:1d95bb62c8a3 draft
re-work optionsdialog to a tabbed UI based on an ui-file
- extend network options with a SOCKS version selection
- changing "Unit to show amounts in:" now also updates the unit used in the transaction fee box
- string updates
- link Apply button and OK button when enabling or disabling them
- use LookupNumeric() from netbase to verify proxy address (via an EventFilter)
- change proxy address field to QValidatedLineEdit and add visual feedback
- add a status label used for displaying a message for invalid proxy addresses
- allow usage of IPv6 address as proxy address
- added warning message when enabling / disabling SOCKS proxy
author | Philip Kaufmann <phil.kaufmann@t-online.de> |
---|---|
date | Fri, 08 Jun 2012 15:21:55 +0200 (2012-06-08) |
parents | 2e7f831240f5 |
children | 2e1808aa6010 |
rev | line source |
---|---|
1049
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
1 #include "optionsdialog.h" |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
2 #include "ui_optionsdialog.h" |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
3 |
1086
817dc99730ad
introduce bitcoin amount field with split amount/decimals, to protect against mistakes (https://forum.bitcoin.org/index.php?topic=19168.0)
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
1076
diff
changeset
|
4 #include "bitcoinamountfield.h" |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
5 #include "bitcoinunits.h" |
1049
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
6 #include "monitoreddatamapper.h" |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
7 #include "netbase.h" |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
8 #include "optionsmodel.h" |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
9 #include "qvalidatedlineedit.h" |
1229
fa39b222e5e0
Full support for other units, add configuration option for default unit (used when displaying amounts)
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
1216
diff
changeset
|
10 #include "qvaluecombobox.h" |
1049
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
11 |
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
12 #include <QCheckBox> |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
13 #include <QDir> |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
14 #include <QIntValidator> |
1049
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
15 #include <QLabel> |
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
16 #include <QLineEdit> |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
17 #include <QMessageBox> |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
18 #include <QPushButton> |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
19 #include <QRegExp> |
1049
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
20 #include <QRegExpValidator> |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
21 #include <QTabWidget> |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
22 #include <QWidget> |
1049
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
23 |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
24 OptionsDialog::OptionsDialog(QWidget *parent) : |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
25 QDialog(parent), |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
26 ui(new Ui::OptionsDialog), |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
27 model(0), |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
28 mapper(0), |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
29 fRestartWarningDisplayed_Proxy(false), |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
30 fRestartWarningDisplayed_Lang(false), |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
31 fProxyIpValid(true) |
2425
aa46239b5b09
Organize optionsdialog (split off Window and Network page)
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2423
diff
changeset
|
32 { |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
33 ui->setupUi(this); |
2425
aa46239b5b09
Organize optionsdialog (split off Window and Network page)
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2423
diff
changeset
|
34 |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
35 /* Network elements init */ |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
36 #ifndef USE_UPNP |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
37 ui->mapPortUpnp->setEnabled(false); |
1406
f5bfde96d9c3
Improved Mac experience; QDoubleSpinBox for BitcoinAmountField
p2k <patrick.p2k.schneider@gmail.com>
parents:
1339
diff
changeset
|
38 #endif |
1213
b76439e5e887
preparations for multiple unit (uBTC, mBTC, BTC) support, fix amount entry issue
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
1096
diff
changeset
|
39 |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
40 ui->socksVersion->setEnabled(false); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
41 ui->socksVersion->addItem("5", 5); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
42 ui->socksVersion->addItem("4", 4); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
43 ui->socksVersion->setCurrentIndex(0); |
2425
aa46239b5b09
Organize optionsdialog (split off Window and Network page)
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2423
diff
changeset
|
44 |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
45 ui->proxyIp->setEnabled(false); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
46 ui->proxyPort->setEnabled(false); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
47 ui->proxyPort->setValidator(new QIntValidator(0, 65535, this)); |
1213
b76439e5e887
preparations for multiple unit (uBTC, mBTC, BTC) support, fix amount entry issue
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
1096
diff
changeset
|
48 |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
49 connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->socksVersion, SLOT(setEnabled(bool))); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
50 connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyIp, SLOT(setEnabled(bool))); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
51 connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyPort, SLOT(setEnabled(bool))); |
1213
b76439e5e887
preparations for multiple unit (uBTC, mBTC, BTC) support, fix amount entry issue
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
1096
diff
changeset
|
52 |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
53 ui->proxyIp->installEventFilter(this); |
1339
904c43af509f
put Q_OBJECT everywhere it should be (removes warnings when running lupdate)
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
1258
diff
changeset
|
54 |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
55 /* Window elements init */ |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
56 #ifdef Q_WS_MAC |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
57 ui->tabWindow->setVisible(false); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
58 #endif |
1049
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
59 |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
60 /* Display elements init */ |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
61 QDir translations(":translations"); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
62 ui->lang->addItem(QString("(") + tr("default") + QString(")"), QVariant("")); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
63 foreach(const QString &langStr, translations.entryList()) |
2425
aa46239b5b09
Organize optionsdialog (split off Window and Network page)
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2423
diff
changeset
|
64 { |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
65 ui->lang->addItem(langStr, QVariant(langStr)); |
2425
aa46239b5b09
Organize optionsdialog (split off Window and Network page)
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2423
diff
changeset
|
66 } |
1049
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
67 |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
68 ui->unit->setModel(new BitcoinUnits(this)); |
1049
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
69 |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
70 connect(ui->connectSocks, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning_Proxy())); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
71 connect(ui->lang, SIGNAL(activated(int)), this, SLOT(showRestartWarning_Lang())); |
1049
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
72 |
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
73 /* Widget-to-option mapper */ |
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
74 mapper = new MonitoredDataMapper(this); |
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
75 mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit); |
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
76 mapper->setOrientation(Qt::Vertical); |
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
77 |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
78 /* enable save buttons when data modified */ |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
79 connect(mapper, SIGNAL(viewModified()), this, SLOT(enableSaveButtons())); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
80 /* disable save buttons when new data loaded */ |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
81 connect(mapper, SIGNAL(currentIndexChanged(int)), this, SLOT(disableSaveButtons())); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
82 /* disable/enable save buttons when proxy IP is invalid/valid */ |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
83 connect(this, SIGNAL(proxyIpValid(bool)), this, SLOT(setSaveButtonState(bool))); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
84 } |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
85 |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
86 OptionsDialog::~OptionsDialog() |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
87 { |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
88 delete ui; |
1049
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
89 } |
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
90 |
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
91 void OptionsDialog::setModel(OptionsModel *model) |
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
92 { |
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
93 this->model = model; |
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
94 |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
95 if(model) |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
96 { |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
97 connect(model, SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); |
2425
aa46239b5b09
Organize optionsdialog (split off Window and Network page)
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2423
diff
changeset
|
98 |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
99 mapper->setModel(model); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
100 setMapper(); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
101 mapper->toFirst(); |
2425
aa46239b5b09
Organize optionsdialog (split off Window and Network page)
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2423
diff
changeset
|
102 } |
1049
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
103 |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
104 // update the display unit, to not use the default ("BTC") |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
105 updateDisplayUnit(); |
1049
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
106 } |
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
107 |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
108 void OptionsDialog::setMapper() |
1049
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
109 { |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
110 /* Main */ |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
111 mapper->addMapping(ui->transactionFee, OptionsModel::Fee); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
112 mapper->addMapping(ui->bitcoinAtStartup, OptionsModel::StartAtStartup); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
113 mapper->addMapping(ui->detachDatabases, OptionsModel::DetachDatabases); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
114 |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
115 /* Network */ |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
116 mapper->addMapping(ui->mapPortUpnp, OptionsModel::MapPortUPnP); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
117 mapper->addMapping(ui->connectSocks, OptionsModel::ProxyUse); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
118 mapper->addMapping(ui->socksVersion, OptionsModel::ProxySocksVersion); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
119 mapper->addMapping(ui->proxyIp, OptionsModel::ProxyIP); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
120 mapper->addMapping(ui->proxyPort, OptionsModel::ProxyPort); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
121 |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
122 /* Window */ |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
123 #ifndef Q_WS_MAC |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
124 mapper->addMapping(ui->minimizeToTray, OptionsModel::MinimizeToTray); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
125 mapper->addMapping(ui->minimizeOnClose, OptionsModel::MinimizeOnClose); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
126 #endif |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
127 |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
128 /* Display */ |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
129 mapper->addMapping(ui->lang, OptionsModel::Language); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
130 mapper->addMapping(ui->unit, OptionsModel::DisplayUnit); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
131 mapper->addMapping(ui->displayAddresses, OptionsModel::DisplayAddresses); |
1049
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
132 } |
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
133 |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
134 void OptionsDialog::enableSaveButtons() |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
135 { |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
136 // prevent enabling of the save buttons when data modified, if there is an invalid proxy address present |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
137 if(fProxyIpValid) |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
138 setSaveButtonState(true); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
139 } |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
140 |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
141 void OptionsDialog::disableSaveButtons() |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
142 { |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
143 setSaveButtonState(false); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
144 } |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
145 |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
146 void OptionsDialog::setSaveButtonState(bool fState) |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
147 { |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
148 ui->applyButton->setEnabled(fState); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
149 ui->okButton->setEnabled(fState); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
150 } |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
151 |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
152 void OptionsDialog::on_okButton_clicked() |
1049
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
153 { |
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
154 mapper->submit(); |
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
155 accept(); |
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
156 } |
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
157 |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
158 void OptionsDialog::on_cancelButton_clicked() |
1049
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
159 { |
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
160 reject(); |
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
161 } |
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
162 |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
163 void OptionsDialog::on_applyButton_clicked() |
1049
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
164 { |
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
165 mapper->submit(); |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
166 ui->applyButton->setEnabled(false); |
2425
aa46239b5b09
Organize optionsdialog (split off Window and Network page)
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2423
diff
changeset
|
167 } |
aa46239b5b09
Organize optionsdialog (split off Window and Network page)
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2423
diff
changeset
|
168 |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
169 void OptionsDialog::showRestartWarning_Proxy() |
2425
aa46239b5b09
Organize optionsdialog (split off Window and Network page)
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2423
diff
changeset
|
170 { |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
171 if(!fRestartWarningDisplayed_Proxy) |
2426
58abdd7d008b
Make it possible to set user interface language from options dialog
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2425
diff
changeset
|
172 { |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
173 QMessageBox::warning(this, tr("Warning"), tr("This setting will take effect after restarting Bitcoin."), QMessageBox::Ok); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
174 fRestartWarningDisplayed_Proxy = true; |
2426
58abdd7d008b
Make it possible to set user interface language from options dialog
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2425
diff
changeset
|
175 } |
2425
aa46239b5b09
Organize optionsdialog (split off Window and Network page)
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2423
diff
changeset
|
176 } |
aa46239b5b09
Organize optionsdialog (split off Window and Network page)
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2423
diff
changeset
|
177 |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
178 void OptionsDialog::showRestartWarning_Lang() |
2425
aa46239b5b09
Organize optionsdialog (split off Window and Network page)
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2423
diff
changeset
|
179 { |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
180 if(!fRestartWarningDisplayed_Lang) |
2426
58abdd7d008b
Make it possible to set user interface language from options dialog
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2425
diff
changeset
|
181 { |
58abdd7d008b
Make it possible to set user interface language from options dialog
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2425
diff
changeset
|
182 QMessageBox::warning(this, tr("Warning"), tr("This setting will take effect after restarting Bitcoin."), QMessageBox::Ok); |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
183 fRestartWarningDisplayed_Lang = true; |
2426
58abdd7d008b
Make it possible to set user interface language from options dialog
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2425
diff
changeset
|
184 } |
58abdd7d008b
Make it possible to set user interface language from options dialog
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2425
diff
changeset
|
185 } |
58abdd7d008b
Make it possible to set user interface language from options dialog
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2425
diff
changeset
|
186 |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
187 void OptionsDialog::updateDisplayUnit() |
2425
aa46239b5b09
Organize optionsdialog (split off Window and Network page)
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2423
diff
changeset
|
188 { |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
189 if(model) |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
190 { |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
191 // Update transactionFee with the current unit |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
192 ui->transactionFee->setDisplayUnit(model->getDisplayUnit()); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
193 } |
2425
aa46239b5b09
Organize optionsdialog (split off Window and Network page)
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2423
diff
changeset
|
194 } |
aa46239b5b09
Organize optionsdialog (split off Window and Network page)
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2423
diff
changeset
|
195 |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
196 bool OptionsDialog::eventFilter(QObject *object, QEvent *event) |
2425
aa46239b5b09
Organize optionsdialog (split off Window and Network page)
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2423
diff
changeset
|
197 { |
2759
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
198 if(object == ui->proxyIp && event->type() == QEvent::FocusOut) |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
199 { |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
200 // Check proxyIP for a valid IPv4/IPv6 address |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
201 CService addr; |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
202 if(!LookupNumeric(ui->proxyIp->text().toStdString().c_str(), addr)) |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
203 { |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
204 ui->proxyIp->setValid(false); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
205 fProxyIpValid = false; |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
206 ui->statusLabel->setStyleSheet("QLabel { color: red; }"); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
207 ui->statusLabel->setText(tr("The supplied proxy address is invalid.")); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
208 emit proxyIpValid(false); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
209 } |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
210 else |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
211 { |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
212 fProxyIpValid = true; |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
213 ui->statusLabel->clear(); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
214 emit proxyIpValid(true); |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
215 } |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
216 } |
1d95bb62c8a3
re-work optionsdialog to a tabbed UI based on an ui-file
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
2706
diff
changeset
|
217 return QDialog::eventFilter(object, event); |
1049
e5518d9b9f05
move back to original directory structure
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
diff
changeset
|
218 } |