Browse Source
GUI: re-work current options dialog to a tabbed layout and use an UI-filemiguelfreitas
Wladimir J. van der Laan
13 years ago
5 changed files with 646 additions and 345 deletions
@ -0,0 +1,466 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<ui version="4.0"> |
||||||
|
<class>OptionsDialog</class> |
||||||
|
<widget class="QDialog" name="OptionsDialog"> |
||||||
|
<property name="geometry"> |
||||||
|
<rect> |
||||||
|
<x>0</x> |
||||||
|
<y>0</y> |
||||||
|
<width>540</width> |
||||||
|
<height>380</height> |
||||||
|
</rect> |
||||||
|
</property> |
||||||
|
<property name="windowTitle"> |
||||||
|
<string>Options</string> |
||||||
|
</property> |
||||||
|
<property name="modal"> |
||||||
|
<bool>true</bool> |
||||||
|
</property> |
||||||
|
<layout class="QVBoxLayout" name="verticalLayout"> |
||||||
|
<item> |
||||||
|
<widget class="QTabWidget" name="tabWidget"> |
||||||
|
<property name="tabPosition"> |
||||||
|
<enum>QTabWidget::North</enum> |
||||||
|
</property> |
||||||
|
<property name="currentIndex"> |
||||||
|
<number>0</number> |
||||||
|
</property> |
||||||
|
<widget class="QWidget" name="tabMain"> |
||||||
|
<attribute name="title"> |
||||||
|
<string>&Main</string> |
||||||
|
</attribute> |
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_Main"> |
||||||
|
<item> |
||||||
|
<widget class="QLabel" name="transactionFeeInfoLabel"> |
||||||
|
<property name="text"> |
||||||
|
<string>Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1 kB. Fee 0.01 recommended.</string> |
||||||
|
</property> |
||||||
|
<property name="textFormat"> |
||||||
|
<enum>Qt::PlainText</enum> |
||||||
|
</property> |
||||||
|
<property name="wordWrap"> |
||||||
|
<bool>true</bool> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_Main"> |
||||||
|
<item> |
||||||
|
<widget class="QLabel" name="transactionFeeLabel"> |
||||||
|
<property name="text"> |
||||||
|
<string>Pay transaction &fee</string> |
||||||
|
</property> |
||||||
|
<property name="textFormat"> |
||||||
|
<enum>Qt::PlainText</enum> |
||||||
|
</property> |
||||||
|
<property name="buddy"> |
||||||
|
<cstring>transactionFee</cstring> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="BitcoinAmountField" name="transactionFee"/> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<spacer name="horizontalSpacer_Main"> |
||||||
|
<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="bitcoinAtStartup"> |
||||||
|
<property name="toolTip"> |
||||||
|
<string>Automatically start Bitcoin after logging in to the system.</string> |
||||||
|
</property> |
||||||
|
<property name="text"> |
||||||
|
<string>&Start Bitcoin on system login</string> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QCheckBox" name="detachDatabases"> |
||||||
|
<property name="toolTip"> |
||||||
|
<string>Detach block and address databases at shutdown. This means they can be moved to another data directory, but it slows down shutdown. The wallet is always detached.</string> |
||||||
|
</property> |
||||||
|
<property name="text"> |
||||||
|
<string>&Detach databases at shutdown</string> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<spacer name="verticalSpacer_Main"> |
||||||
|
<property name="orientation"> |
||||||
|
<enum>Qt::Vertical</enum> |
||||||
|
</property> |
||||||
|
<property name="sizeHint" stdset="0"> |
||||||
|
<size> |
||||||
|
<width>20</width> |
||||||
|
<height>40</height> |
||||||
|
</size> |
||||||
|
</property> |
||||||
|
</spacer> |
||||||
|
</item> |
||||||
|
</layout> |
||||||
|
</widget> |
||||||
|
<widget class="QWidget" name="tabNetwork"> |
||||||
|
<attribute name="title"> |
||||||
|
<string>&Network</string> |
||||||
|
</attribute> |
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_Network"> |
||||||
|
<item> |
||||||
|
<widget class="QCheckBox" name="mapPortUpnp"> |
||||||
|
<property name="toolTip"> |
||||||
|
<string>Automatically open the Bitcoin client port on the router. This only works when your router supports UPnP and it is enabled.</string> |
||||||
|
</property> |
||||||
|
<property name="text"> |
||||||
|
<string>Map port using &UPnP</string> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QCheckBox" name="connectSocks"> |
||||||
|
<property name="toolTip"> |
||||||
|
<string>Connect to the Bitcon network through a SOCKS proxy (e.g. when connecting through Tor).</string> |
||||||
|
</property> |
||||||
|
<property name="text"> |
||||||
|
<string>&Connect through SOCKS proxy:</string> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_Network"> |
||||||
|
<item> |
||||||
|
<widget class="QLabel" name="proxyIpLabel"> |
||||||
|
<property name="text"> |
||||||
|
<string>Proxy &IP:</string> |
||||||
|
</property> |
||||||
|
<property name="textFormat"> |
||||||
|
<enum>Qt::PlainText</enum> |
||||||
|
</property> |
||||||
|
<property name="buddy"> |
||||||
|
<cstring>proxyIp</cstring> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QValidatedLineEdit" name="proxyIp"> |
||||||
|
<property name="maximumSize"> |
||||||
|
<size> |
||||||
|
<width>140</width> |
||||||
|
<height>16777215</height> |
||||||
|
</size> |
||||||
|
</property> |
||||||
|
<property name="toolTip"> |
||||||
|
<string>IP address of the proxy (e.g. 127.0.0.1)</string> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QLabel" name="proxyPortLabel"> |
||||||
|
<property name="text"> |
||||||
|
<string>&Port:</string> |
||||||
|
</property> |
||||||
|
<property name="textFormat"> |
||||||
|
<enum>Qt::PlainText</enum> |
||||||
|
</property> |
||||||
|
<property name="buddy"> |
||||||
|
<cstring>proxyPort</cstring> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QLineEdit" name="proxyPort"> |
||||||
|
<property name="maximumSize"> |
||||||
|
<size> |
||||||
|
<width>55</width> |
||||||
|
<height>16777215</height> |
||||||
|
</size> |
||||||
|
</property> |
||||||
|
<property name="toolTip"> |
||||||
|
<string>Port of the proxy (e.g. 9050)</string> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QLabel" name="socksVersionLabel"> |
||||||
|
<property name="text"> |
||||||
|
<string>SOCKS &Version:</string> |
||||||
|
</property> |
||||||
|
<property name="textFormat"> |
||||||
|
<enum>Qt::PlainText</enum> |
||||||
|
</property> |
||||||
|
<property name="buddy"> |
||||||
|
<cstring>socksVersion</cstring> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QValueComboBox" name="socksVersion"> |
||||||
|
<property name="toolTip"> |
||||||
|
<string>SOCKS version of the proxy (e.g. 5)</string> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<spacer name="horizontalSpacer_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> |
||||||
|
<spacer name="verticalSpacer_Network"> |
||||||
|
<property name="orientation"> |
||||||
|
<enum>Qt::Vertical</enum> |
||||||
|
</property> |
||||||
|
<property name="sizeHint" stdset="0"> |
||||||
|
<size> |
||||||
|
<width>20</width> |
||||||
|
<height>40</height> |
||||||
|
</size> |
||||||
|
</property> |
||||||
|
</spacer> |
||||||
|
</item> |
||||||
|
</layout> |
||||||
|
</widget> |
||||||
|
<widget class="QWidget" name="tabWindow"> |
||||||
|
<attribute name="title"> |
||||||
|
<string>&Window</string> |
||||||
|
</attribute> |
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_Window"> |
||||||
|
<item> |
||||||
|
<widget class="QCheckBox" name="minimizeToTray"> |
||||||
|
<property name="toolTip"> |
||||||
|
<string>Show only a tray icon after minimizing the window.</string> |
||||||
|
</property> |
||||||
|
<property name="text"> |
||||||
|
<string>&Minimize to the tray instead of the taskbar</string> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QCheckBox" name="minimizeOnClose"> |
||||||
|
<property name="toolTip"> |
||||||
|
<string>Minimize instead of exit the application when the window is closed. When this option is enabled, the application will be closed only after selecting Quit in the menu.</string> |
||||||
|
</property> |
||||||
|
<property name="text"> |
||||||
|
<string>M&inimize on close</string> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<spacer name="verticalSpacer_Window"> |
||||||
|
<property name="orientation"> |
||||||
|
<enum>Qt::Vertical</enum> |
||||||
|
</property> |
||||||
|
<property name="sizeHint" stdset="0"> |
||||||
|
<size> |
||||||
|
<width>20</width> |
||||||
|
<height>40</height> |
||||||
|
</size> |
||||||
|
</property> |
||||||
|
</spacer> |
||||||
|
</item> |
||||||
|
</layout> |
||||||
|
</widget> |
||||||
|
<widget class="QWidget" name="tabDisplay"> |
||||||
|
<attribute name="title"> |
||||||
|
<string>&Display</string> |
||||||
|
</attribute> |
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_Display"> |
||||||
|
<item> |
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_1_Display"> |
||||||
|
<item> |
||||||
|
<widget class="QLabel" name="langLabel"> |
||||||
|
<property name="text"> |
||||||
|
<string>User Interface &language:</string> |
||||||
|
</property> |
||||||
|
<property name="textFormat"> |
||||||
|
<enum>Qt::PlainText</enum> |
||||||
|
</property> |
||||||
|
<property name="buddy"> |
||||||
|
<cstring>lang</cstring> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QValueComboBox" name="lang"> |
||||||
|
<property name="toolTip"> |
||||||
|
<string>The user interface language can be set here. This setting will take effect after restarting Bitcoin.</string> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
</layout> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2_Display"> |
||||||
|
<item> |
||||||
|
<widget class="QLabel" name="unitLabel"> |
||||||
|
<property name="text"> |
||||||
|
<string>&Unit to show amounts in:</string> |
||||||
|
</property> |
||||||
|
<property name="textFormat"> |
||||||
|
<enum>Qt::PlainText</enum> |
||||||
|
</property> |
||||||
|
<property name="buddy"> |
||||||
|
<cstring>unit</cstring> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QValueComboBox" name="unit"> |
||||||
|
<property name="toolTip"> |
||||||
|
<string>Choose the default subdivision unit to show in the interface and when sending coins.</string> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
</layout> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QCheckBox" name="displayAddresses"> |
||||||
|
<property name="toolTip"> |
||||||
|
<string>Whether to show Bitcoin addresses in the transaction list or not.</string> |
||||||
|
</property> |
||||||
|
<property name="text"> |
||||||
|
<string>&Display addresses in transaction list</string> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<spacer name="verticalSpacer_Display"> |
||||||
|
<property name="orientation"> |
||||||
|
<enum>Qt::Vertical</enum> |
||||||
|
</property> |
||||||
|
<property name="sizeHint" stdset="0"> |
||||||
|
<size> |
||||||
|
<width>20</width> |
||||||
|
<height>40</height> |
||||||
|
</size> |
||||||
|
</property> |
||||||
|
</spacer> |
||||||
|
</item> |
||||||
|
</layout> |
||||||
|
</widget> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_Buttons"> |
||||||
|
<item> |
||||||
|
<spacer name="horizontalSpacer_1"> |
||||||
|
<property name="orientation"> |
||||||
|
<enum>Qt::Horizontal</enum> |
||||||
|
</property> |
||||||
|
<property name="sizeHint" stdset="0"> |
||||||
|
<size> |
||||||
|
<width>40</width> |
||||||
|
<height>48</height> |
||||||
|
</size> |
||||||
|
</property> |
||||||
|
</spacer> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QLabel" name="statusLabel"> |
||||||
|
<property name="font"> |
||||||
|
<font> |
||||||
|
<weight>75</weight> |
||||||
|
<bold>true</bold> |
||||||
|
</font> |
||||||
|
</property> |
||||||
|
<property name="text"> |
||||||
|
<string/> |
||||||
|
</property> |
||||||
|
<property name="textFormat"> |
||||||
|
<enum>Qt::PlainText</enum> |
||||||
|
</property> |
||||||
|
<property name="wordWrap"> |
||||||
|
<bool>true</bool> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<spacer name="horizontalSpacer_2"> |
||||||
|
<property name="orientation"> |
||||||
|
<enum>Qt::Horizontal</enum> |
||||||
|
</property> |
||||||
|
<property name="sizeHint" stdset="0"> |
||||||
|
<size> |
||||||
|
<width>40</width> |
||||||
|
<height>48</height> |
||||||
|
</size> |
||||||
|
</property> |
||||||
|
</spacer> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QPushButton" name="okButton"> |
||||||
|
<property name="text"> |
||||||
|
<string>&OK</string> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QPushButton" name="cancelButton"> |
||||||
|
<property name="text"> |
||||||
|
<string>&Cancel</string> |
||||||
|
</property> |
||||||
|
<property name="autoDefault"> |
||||||
|
<bool>false</bool> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QPushButton" name="applyButton"> |
||||||
|
<property name="text"> |
||||||
|
<string>&Apply</string> |
||||||
|
</property> |
||||||
|
<property name="autoDefault"> |
||||||
|
<bool>false</bool> |
||||||
|
</property> |
||||||
|
<property name="default"> |
||||||
|
<bool>false</bool> |
||||||
|
</property> |
||||||
|
<property name="flat"> |
||||||
|
<bool>false</bool> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
</layout> |
||||||
|
</item> |
||||||
|
</layout> |
||||||
|
</widget> |
||||||
|
<customwidgets> |
||||||
|
<customwidget> |
||||||
|
<class>BitcoinAmountField</class> |
||||||
|
<extends>QSpinBox</extends> |
||||||
|
<header>bitcoinamountfield.h</header> |
||||||
|
</customwidget> |
||||||
|
<customwidget> |
||||||
|
<class>QValueComboBox</class> |
||||||
|
<extends>QComboBox</extends> |
||||||
|
<header>qvaluecombobox.h</header> |
||||||
|
</customwidget> |
||||||
|
<customwidget> |
||||||
|
<class>QValidatedLineEdit</class> |
||||||
|
<extends>QLineEdit</extends> |
||||||
|
<header>qvalidatedlineedit.h</header> |
||||||
|
</customwidget> |
||||||
|
</customwidgets> |
||||||
|
<resources/> |
||||||
|
<connections/> |
||||||
|
</ui> |
@ -1,396 +1,218 @@ |
|||||||
#include "optionsdialog.h" |
#include "optionsdialog.h" |
||||||
#include "optionsmodel.h" |
#include "ui_optionsdialog.h" |
||||||
|
|
||||||
#include "bitcoinamountfield.h" |
#include "bitcoinamountfield.h" |
||||||
#include "monitoreddatamapper.h" |
|
||||||
#include "guiutil.h" |
|
||||||
#include "bitcoinunits.h" |
#include "bitcoinunits.h" |
||||||
|
#include "monitoreddatamapper.h" |
||||||
|
#include "netbase.h" |
||||||
|
#include "optionsmodel.h" |
||||||
|
#include "qvalidatedlineedit.h" |
||||||
#include "qvaluecombobox.h" |
#include "qvaluecombobox.h" |
||||||
|
|
||||||
#include <QHBoxLayout> |
|
||||||
#include <QVBoxLayout> |
|
||||||
#include <QPushButton> |
|
||||||
#include <QListWidget> |
|
||||||
#include <QStackedWidget> |
|
||||||
|
|
||||||
#include <QCheckBox> |
#include <QCheckBox> |
||||||
|
#include <QDir> |
||||||
|
#include <QIntValidator> |
||||||
#include <QLabel> |
#include <QLabel> |
||||||
#include <QLineEdit> |
#include <QLineEdit> |
||||||
#include <QIntValidator> |
|
||||||
#include <QDoubleValidator> |
|
||||||
#include <QRegExpValidator> |
|
||||||
#include <QDialogButtonBox> |
|
||||||
#include <QDir> |
|
||||||
#include <QMessageBox> |
#include <QMessageBox> |
||||||
|
#include <QPushButton> |
||||||
|
#include <QRegExp> |
||||||
|
#include <QRegExpValidator> |
||||||
|
#include <QTabWidget> |
||||||
|
#include <QWidget> |
||||||
|
|
||||||
class OptionsPage: public QWidget |
OptionsDialog::OptionsDialog(QWidget *parent) : |
||||||
{ |
QDialog(parent), |
||||||
Q_OBJECT |
ui(new Ui::OptionsDialog), |
||||||
public: |
model(0), |
||||||
explicit OptionsPage(QWidget *parent=0): QWidget(parent) {} |
mapper(0), |
||||||
|
fRestartWarningDisplayed_Proxy(false), |
||||||
virtual void setMapper(MonitoredDataMapper *mapper) = 0; |
fRestartWarningDisplayed_Lang(false), |
||||||
}; |
fProxyIpValid(true) |
||||||
|
|
||||||
class MainOptionsPage: public OptionsPage |
|
||||||
{ |
{ |
||||||
Q_OBJECT |
ui->setupUi(this); |
||||||
public: |
|
||||||
explicit MainOptionsPage(QWidget *parent=0); |
|
||||||
|
|
||||||
virtual void setMapper(MonitoredDataMapper *mapper); |
|
||||||
private: |
|
||||||
BitcoinAmountField *fee_edit; |
|
||||||
QCheckBox *bitcoin_at_startup; |
|
||||||
QCheckBox *detach_database; |
|
||||||
}; |
|
||||||
|
|
||||||
class WindowOptionsPage: public OptionsPage |
|
||||||
{ |
|
||||||
Q_OBJECT |
|
||||||
public: |
|
||||||
explicit WindowOptionsPage(QWidget *parent=0); |
|
||||||
|
|
||||||
virtual void setMapper(MonitoredDataMapper *mapper); |
/* Network elements init */ |
||||||
private: |
#ifndef USE_UPNP |
||||||
#ifndef Q_WS_MAC |
ui->mapPortUpnp->setEnabled(false); |
||||||
QCheckBox *minimize_to_tray; |
|
||||||
QCheckBox *minimize_on_close; |
|
||||||
#endif |
#endif |
||||||
}; |
|
||||||
|
|
||||||
class DisplayOptionsPage: public OptionsPage |
ui->socksVersion->setEnabled(false); |
||||||
{ |
ui->socksVersion->addItem("5", 5); |
||||||
Q_OBJECT |
ui->socksVersion->addItem("4", 4); |
||||||
public: |
ui->socksVersion->setCurrentIndex(0); |
||||||
explicit DisplayOptionsPage(QWidget *parent=0); |
|
||||||
|
|
||||||
virtual void setMapper(MonitoredDataMapper *mapper); |
|
||||||
private: |
|
||||||
QValueComboBox *lang; |
|
||||||
QValueComboBox *unit; |
|
||||||
QCheckBox *display_addresses; |
|
||||||
bool restart_warning_displayed; |
|
||||||
private slots: |
|
||||||
void showRestartWarning(); |
|
||||||
}; |
|
||||||
|
|
||||||
class NetworkOptionsPage: public OptionsPage |
|
||||||
{ |
|
||||||
Q_OBJECT |
|
||||||
public: |
|
||||||
explicit NetworkOptionsPage(QWidget *parent=0); |
|
||||||
|
|
||||||
virtual void setMapper(MonitoredDataMapper *mapper); |
|
||||||
private: |
|
||||||
QCheckBox *map_port_upnp; |
|
||||||
QCheckBox *connect_socks4; |
|
||||||
QLineEdit *proxy_ip; |
|
||||||
QLineEdit *proxy_port; |
|
||||||
}; |
|
||||||
|
|
||||||
|
ui->proxyIp->setEnabled(false); |
||||||
|
ui->proxyPort->setEnabled(false); |
||||||
|
ui->proxyPort->setValidator(new QIntValidator(0, 65535, this)); |
||||||
|
|
||||||
#include "optionsdialog.moc" |
connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->socksVersion, SLOT(setEnabled(bool))); |
||||||
|
connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyIp, SLOT(setEnabled(bool))); |
||||||
|
connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyPort, SLOT(setEnabled(bool))); |
||||||
|
|
||||||
OptionsDialog::OptionsDialog(QWidget *parent): |
ui->proxyIp->installEventFilter(this); |
||||||
QDialog(parent), contents_widget(0), pages_widget(0), |
|
||||||
model(0) |
|
||||||
{ |
|
||||||
contents_widget = new QListWidget(); |
|
||||||
contents_widget->setMaximumWidth(128); |
|
||||||
|
|
||||||
pages_widget = new QStackedWidget(); |
|
||||||
pages_widget->setMinimumWidth(500); |
|
||||||
pages_widget->setMinimumHeight(300); |
|
||||||
|
|
||||||
pages.append(new MainOptionsPage(this)); |
/* Window elements init */ |
||||||
pages.append(new NetworkOptionsPage(this)); |
#ifdef Q_WS_MAC |
||||||
#ifndef Q_WS_MAC |
ui->tabWindow->setVisible(false); |
||||||
/* Hide Window options on Mac as there are currently none available */ |
|
||||||
pages.append(new WindowOptionsPage(this)); |
|
||||||
#endif |
#endif |
||||||
pages.append(new DisplayOptionsPage(this)); |
|
||||||
|
|
||||||
foreach(OptionsPage *page, pages) |
/* Display elements init */ |
||||||
|
QDir translations(":translations"); |
||||||
|
ui->lang->addItem(QString("(") + tr("default") + QString(")"), QVariant("")); |
||||||
|
foreach(const QString &langStr, translations.entryList()) |
||||||
{ |
{ |
||||||
QListWidgetItem *item = new QListWidgetItem(page->windowTitle()); |
ui->lang->addItem(langStr, QVariant(langStr)); |
||||||
contents_widget->addItem(item); |
|
||||||
pages_widget->addWidget(page); |
|
||||||
} |
} |
||||||
|
|
||||||
contents_widget->setCurrentRow(0); |
ui->unit->setModel(new BitcoinUnits(this)); |
||||||
|
|
||||||
QHBoxLayout *main_layout = new QHBoxLayout(); |
|
||||||
main_layout->addWidget(contents_widget); |
|
||||||
main_layout->addWidget(pages_widget, 1); |
|
||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout(); |
|
||||||
layout->addLayout(main_layout); |
|
||||||
|
|
||||||
QDialogButtonBox *buttonbox = new QDialogButtonBox(); |
connect(ui->connectSocks, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning_Proxy())); |
||||||
buttonbox->setStandardButtons(QDialogButtonBox::Apply|QDialogButtonBox::Ok|QDialogButtonBox::Cancel); |
connect(ui->lang, SIGNAL(activated(int)), this, SLOT(showRestartWarning_Lang())); |
||||||
apply_button = buttonbox->button(QDialogButtonBox::Apply); |
|
||||||
layout->addWidget(buttonbox); |
|
||||||
|
|
||||||
setLayout(layout); |
|
||||||
setWindowTitle(tr("Options")); |
|
||||||
|
|
||||||
/* Widget-to-option mapper */ |
/* Widget-to-option mapper */ |
||||||
mapper = new MonitoredDataMapper(this); |
mapper = new MonitoredDataMapper(this); |
||||||
mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit); |
mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit); |
||||||
mapper->setOrientation(Qt::Vertical); |
mapper->setOrientation(Qt::Vertical); |
||||||
/* enable apply button when data modified */ |
|
||||||
connect(mapper, SIGNAL(viewModified()), this, SLOT(enableApply())); |
/* enable save buttons when data modified */ |
||||||
/* disable apply button when new data loaded */ |
connect(mapper, SIGNAL(viewModified()), this, SLOT(enableSaveButtons())); |
||||||
connect(mapper, SIGNAL(currentIndexChanged(int)), this, SLOT(disableApply())); |
/* disable save buttons when new data loaded */ |
||||||
|
connect(mapper, SIGNAL(currentIndexChanged(int)), this, SLOT(disableSaveButtons())); |
||||||
/* Event bindings */ |
/* disable/enable save buttons when proxy IP is invalid/valid */ |
||||||
connect(contents_widget, SIGNAL(currentRowChanged(int)), this, SLOT(changePage(int))); |
connect(this, SIGNAL(proxyIpValid(bool)), this, SLOT(setSaveButtonState(bool))); |
||||||
connect(buttonbox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(okClicked())); |
} |
||||||
connect(buttonbox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(cancelClicked())); |
|
||||||
connect(buttonbox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(applyClicked())); |
OptionsDialog::~OptionsDialog() |
||||||
|
{ |
||||||
|
delete ui; |
||||||
} |
} |
||||||
|
|
||||||
void OptionsDialog::setModel(OptionsModel *model) |
void OptionsDialog::setModel(OptionsModel *model) |
||||||
{ |
{ |
||||||
this->model = model; |
this->model = model; |
||||||
|
|
||||||
mapper->setModel(model); |
if(model) |
||||||
|
|
||||||
foreach(OptionsPage *page, pages) |
|
||||||
{ |
{ |
||||||
page->setMapper(mapper); |
connect(model, SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); |
||||||
} |
|
||||||
|
|
||||||
|
mapper->setModel(model); |
||||||
|
setMapper(); |
||||||
mapper->toFirst(); |
mapper->toFirst(); |
||||||
} |
} |
||||||
|
|
||||||
void OptionsDialog::changePage(int index) |
// update the display unit, to not use the default ("BTC")
|
||||||
{ |
updateDisplayUnit(); |
||||||
pages_widget->setCurrentIndex(index); |
|
||||||
} |
} |
||||||
|
|
||||||
void OptionsDialog::okClicked() |
void OptionsDialog::setMapper() |
||||||
{ |
{ |
||||||
mapper->submit(); |
/* Main */ |
||||||
accept(); |
mapper->addMapping(ui->transactionFee, OptionsModel::Fee); |
||||||
} |
mapper->addMapping(ui->bitcoinAtStartup, OptionsModel::StartAtStartup); |
||||||
|
mapper->addMapping(ui->detachDatabases, OptionsModel::DetachDatabases); |
||||||
|
|
||||||
void OptionsDialog::cancelClicked() |
/* Network */ |
||||||
{ |
mapper->addMapping(ui->mapPortUpnp, OptionsModel::MapPortUPnP); |
||||||
reject(); |
mapper->addMapping(ui->connectSocks, OptionsModel::ProxyUse); |
||||||
} |
mapper->addMapping(ui->socksVersion, OptionsModel::ProxySocksVersion); |
||||||
|
mapper->addMapping(ui->proxyIp, OptionsModel::ProxyIP); |
||||||
|
mapper->addMapping(ui->proxyPort, OptionsModel::ProxyPort); |
||||||
|
|
||||||
void OptionsDialog::applyClicked() |
/* Window */ |
||||||
{ |
#ifndef Q_WS_MAC |
||||||
mapper->submit(); |
mapper->addMapping(ui->minimizeToTray, OptionsModel::MinimizeToTray); |
||||||
apply_button->setEnabled(false); |
mapper->addMapping(ui->minimizeOnClose, OptionsModel::MinimizeOnClose); |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Display */ |
||||||
|
mapper->addMapping(ui->lang, OptionsModel::Language); |
||||||
|
mapper->addMapping(ui->unit, OptionsModel::DisplayUnit); |
||||||
|
mapper->addMapping(ui->displayAddresses, OptionsModel::DisplayAddresses); |
||||||
} |
} |
||||||
|
|
||||||
void OptionsDialog::enableApply() |
void OptionsDialog::enableSaveButtons() |
||||||
{ |
{ |
||||||
apply_button->setEnabled(true); |
// prevent enabling of the save buttons when data modified, if there is an invalid proxy address present
|
||||||
|
if(fProxyIpValid) |
||||||
|
setSaveButtonState(true); |
||||||
} |
} |
||||||
|
|
||||||
void OptionsDialog::disableApply() |
void OptionsDialog::disableSaveButtons() |
||||||
{ |
{ |
||||||
apply_button->setEnabled(false); |
setSaveButtonState(false); |
||||||
} |
} |
||||||
|
|
||||||
/* Main options */ |
void OptionsDialog::setSaveButtonState(bool fState) |
||||||
MainOptionsPage::MainOptionsPage(QWidget *parent): |
|
||||||
OptionsPage(parent) |
|
||||||
{ |
{ |
||||||
QVBoxLayout *layout = new QVBoxLayout(); |
ui->applyButton->setEnabled(fState); |
||||||
setWindowTitle(tr("Main")); |
ui->okButton->setEnabled(fState); |
||||||
|
|
||||||
QLabel *fee_help = new QLabel(tr("Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1 kB. Fee 0.01 recommended.")); |
|
||||||
fee_help->setWordWrap(true); |
|
||||||
layout->addWidget(fee_help); |
|
||||||
|
|
||||||
QHBoxLayout *fee_hbox = new QHBoxLayout(); |
|
||||||
fee_hbox->addSpacing(18); |
|
||||||
QLabel *fee_label = new QLabel(tr("Pay transaction &fee")); |
|
||||||
fee_hbox->addWidget(fee_label); |
|
||||||
fee_edit = new BitcoinAmountField(); |
|
||||||
|
|
||||||
fee_label->setBuddy(fee_edit); |
|
||||||
fee_hbox->addWidget(fee_edit); |
|
||||||
fee_hbox->addStretch(1); |
|
||||||
|
|
||||||
layout->addLayout(fee_hbox); |
|
||||||
|
|
||||||
bitcoin_at_startup = new QCheckBox(tr("&Start Bitcoin on system login")); |
|
||||||
bitcoin_at_startup->setToolTip(tr("Automatically start Bitcoin after logging in to the system")); |
|
||||||
layout->addWidget(bitcoin_at_startup); |
|
||||||
|
|
||||||
detach_database = new QCheckBox(tr("&Detach databases at shutdown")); |
|
||||||
detach_database->setToolTip(tr("Detach block and address databases at shutdown. This means they can be moved to another data directory, but it slows down shutdown. The wallet is always detached.")); |
|
||||||
layout->addWidget(detach_database); |
|
||||||
|
|
||||||
layout->addStretch(1); // Extra space at bottom
|
|
||||||
setLayout(layout); |
|
||||||
} |
} |
||||||
|
|
||||||
void MainOptionsPage::setMapper(MonitoredDataMapper *mapper) |
void OptionsDialog::on_okButton_clicked() |
||||||
{ |
{ |
||||||
// Map model to widgets
|
mapper->submit(); |
||||||
mapper->addMapping(fee_edit, OptionsModel::Fee); |
accept(); |
||||||
mapper->addMapping(bitcoin_at_startup, OptionsModel::StartAtStartup); |
|
||||||
mapper->addMapping(detach_database, OptionsModel::DetachDatabases); |
|
||||||
} |
} |
||||||
|
|
||||||
/* Display options */ |
void OptionsDialog::on_cancelButton_clicked() |
||||||
DisplayOptionsPage::DisplayOptionsPage(QWidget *parent): |
|
||||||
OptionsPage(parent), restart_warning_displayed(false) |
|
||||||
{ |
{ |
||||||
setWindowTitle(tr("Display")); |
reject(); |
||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout(); |
|
||||||
|
|
||||||
QHBoxLayout *lang_hbox = new QHBoxLayout(); |
|
||||||
lang_hbox->addSpacing(18); |
|
||||||
QLabel *lang_label = new QLabel(tr("User Interface &Language:")); |
|
||||||
lang_hbox->addWidget(lang_label); |
|
||||||
lang = new QValueComboBox(this); |
|
||||||
// Make list of languages
|
|
||||||
QDir translations(":translations"); |
|
||||||
lang->addItem(QString("(") + tr("default") + QString(")"), QVariant("")); |
|
||||||
foreach(const QString &langStr, translations.entryList()) |
|
||||||
{ |
|
||||||
lang->addItem(langStr, QVariant(langStr)); |
|
||||||
} |
|
||||||
|
|
||||||
lang->setToolTip(tr("The user interface language can be set here. This setting will only take effect after restarting Bitcoin.")); |
|
||||||
connect(lang, SIGNAL(activated(int)), this, SLOT(showRestartWarning())); |
|
||||||
|
|
||||||
lang_label->setBuddy(lang); |
|
||||||
lang_hbox->addWidget(lang); |
|
||||||
|
|
||||||
layout->addLayout(lang_hbox); |
|
||||||
|
|
||||||
QHBoxLayout *unit_hbox = new QHBoxLayout(); |
|
||||||
unit_hbox->addSpacing(18); |
|
||||||
QLabel *unit_label = new QLabel(tr("&Unit to show amounts in:")); |
|
||||||
unit_hbox->addWidget(unit_label); |
|
||||||
unit = new QValueComboBox(this); |
|
||||||
unit->setModel(new BitcoinUnits(this)); |
|
||||||
unit->setToolTip(tr("Choose the default subdivision unit to show in the interface, and when sending coins")); |
|
||||||
|
|
||||||
unit_label->setBuddy(unit); |
|
||||||
unit_hbox->addWidget(unit); |
|
||||||
|
|
||||||
layout->addLayout(unit_hbox); |
|
||||||
|
|
||||||
display_addresses = new QCheckBox(tr("&Display addresses in transaction list"), this); |
|
||||||
display_addresses->setToolTip(tr("Whether to show Bitcoin addresses in the transaction list")); |
|
||||||
layout->addWidget(display_addresses); |
|
||||||
|
|
||||||
layout->addStretch(); |
|
||||||
setLayout(layout); |
|
||||||
} |
} |
||||||
|
|
||||||
void DisplayOptionsPage::setMapper(MonitoredDataMapper *mapper) |
void OptionsDialog::on_applyButton_clicked() |
||||||
{ |
{ |
||||||
mapper->addMapping(lang, OptionsModel::Language); |
mapper->submit(); |
||||||
mapper->addMapping(unit, OptionsModel::DisplayUnit); |
ui->applyButton->setEnabled(false); |
||||||
mapper->addMapping(display_addresses, OptionsModel::DisplayAddresses); |
|
||||||
} |
} |
||||||
|
|
||||||
void DisplayOptionsPage::showRestartWarning() |
void OptionsDialog::showRestartWarning_Proxy() |
||||||
{ |
{ |
||||||
if(!restart_warning_displayed) |
if(!fRestartWarningDisplayed_Proxy) |
||||||
{ |
{ |
||||||
QMessageBox::warning(this, tr("Warning"), tr("This setting will take effect after restarting Bitcoin."), QMessageBox::Ok); |
QMessageBox::warning(this, tr("Warning"), tr("This setting will take effect after restarting Bitcoin."), QMessageBox::Ok); |
||||||
restart_warning_displayed = true; |
fRestartWarningDisplayed_Proxy = true; |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
/* Window options */ |
void OptionsDialog::showRestartWarning_Lang() |
||||||
WindowOptionsPage::WindowOptionsPage(QWidget *parent): |
|
||||||
OptionsPage(parent) |
|
||||||
{ |
{ |
||||||
QVBoxLayout *layout = new QVBoxLayout(); |
if(!fRestartWarningDisplayed_Lang) |
||||||
setWindowTitle(tr("Window")); |
{ |
||||||
|
QMessageBox::warning(this, tr("Warning"), tr("This setting will take effect after restarting Bitcoin."), QMessageBox::Ok); |
||||||
#ifndef Q_WS_MAC |
fRestartWarningDisplayed_Lang = true; |
||||||
minimize_to_tray = new QCheckBox(tr("&Minimize to the tray instead of the taskbar")); |
} |
||||||
minimize_to_tray->setToolTip(tr("Show only a tray icon after minimizing the window")); |
|
||||||
layout->addWidget(minimize_to_tray); |
|
||||||
|
|
||||||
minimize_on_close = new QCheckBox(tr("M&inimize on close")); |
|
||||||
minimize_on_close->setToolTip(tr("Minimize instead of exit the application when the window is closed. When this option is enabled, the application will be closed only after selecting Quit in the menu.")); |
|
||||||
layout->addWidget(minimize_on_close); |
|
||||||
#endif |
|
||||||
|
|
||||||
layout->addStretch(1); // Extra space at bottom
|
|
||||||
setLayout(layout); |
|
||||||
} |
|
||||||
|
|
||||||
void WindowOptionsPage::setMapper(MonitoredDataMapper *mapper) |
|
||||||
{ |
|
||||||
// Map model to widgets
|
|
||||||
#ifndef Q_WS_MAC |
|
||||||
mapper->addMapping(minimize_to_tray, OptionsModel::MinimizeToTray); |
|
||||||
#endif |
|
||||||
#ifndef Q_WS_MAC |
|
||||||
mapper->addMapping(minimize_on_close, OptionsModel::MinimizeOnClose); |
|
||||||
#endif |
|
||||||
} |
} |
||||||
|
|
||||||
/* Network options */ |
void OptionsDialog::updateDisplayUnit() |
||||||
NetworkOptionsPage::NetworkOptionsPage(QWidget *parent): |
|
||||||
OptionsPage(parent) |
|
||||||
{ |
{ |
||||||
QVBoxLayout *layout = new QVBoxLayout(); |
if(model) |
||||||
setWindowTitle(tr("Network")); |
{ |
||||||
|
// Update transactionFee with the current unit
|
||||||
map_port_upnp = new QCheckBox(tr("Map port using &UPnP")); |
ui->transactionFee->setDisplayUnit(model->getDisplayUnit()); |
||||||
map_port_upnp->setToolTip(tr("Automatically open the Bitcoin client port on the router. This only works when your router supports UPnP and it is enabled.")); |
} |
||||||
layout->addWidget(map_port_upnp); |
|
||||||
|
|
||||||
connect_socks4 = new QCheckBox(tr("&Connect through SOCKS4 proxy:")); |
|
||||||
connect_socks4->setToolTip(tr("Connect to the Bitcon network through a SOCKS4 proxy (e.g. when connecting through Tor)")); |
|
||||||
layout->addWidget(connect_socks4); |
|
||||||
|
|
||||||
QHBoxLayout *proxy_hbox = new QHBoxLayout(); |
|
||||||
proxy_hbox->addSpacing(18); |
|
||||||
QLabel *proxy_ip_label = new QLabel(tr("Proxy &IP:")); |
|
||||||
proxy_hbox->addWidget(proxy_ip_label); |
|
||||||
proxy_ip = new QLineEdit(); |
|
||||||
proxy_ip->setMaximumWidth(140); |
|
||||||
proxy_ip->setEnabled(false); |
|
||||||
proxy_ip->setValidator(new QRegExpValidator(QRegExp("[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}"), this)); |
|
||||||
proxy_ip->setToolTip(tr("IP address of the proxy (e.g. 127.0.0.1)")); |
|
||||||
proxy_ip_label->setBuddy(proxy_ip); |
|
||||||
proxy_hbox->addWidget(proxy_ip); |
|
||||||
QLabel *proxy_port_label = new QLabel(tr("&Port:")); |
|
||||||
proxy_hbox->addWidget(proxy_port_label); |
|
||||||
proxy_port = new QLineEdit(); |
|
||||||
proxy_port->setMaximumWidth(55); |
|
||||||
proxy_port->setValidator(new QIntValidator(0, 65535, this)); |
|
||||||
proxy_port->setEnabled(false); |
|
||||||
proxy_port->setToolTip(tr("Port of the proxy (e.g. 1234)")); |
|
||||||
proxy_port_label->setBuddy(proxy_port); |
|
||||||
proxy_hbox->addWidget(proxy_port); |
|
||||||
proxy_hbox->addStretch(1); |
|
||||||
layout->addLayout(proxy_hbox); |
|
||||||
|
|
||||||
layout->addStretch(1); // Extra space at bottom
|
|
||||||
setLayout(layout); |
|
||||||
|
|
||||||
connect(connect_socks4, SIGNAL(toggled(bool)), proxy_ip, SLOT(setEnabled(bool))); |
|
||||||
connect(connect_socks4, SIGNAL(toggled(bool)), proxy_port, SLOT(setEnabled(bool))); |
|
||||||
|
|
||||||
#ifndef USE_UPNP |
|
||||||
map_port_upnp->setDisabled(true); |
|
||||||
#endif |
|
||||||
} |
} |
||||||
|
|
||||||
void NetworkOptionsPage::setMapper(MonitoredDataMapper *mapper) |
bool OptionsDialog::eventFilter(QObject *object, QEvent *event) |
||||||
{ |
{ |
||||||
// Map model to widgets
|
if(object == ui->proxyIp && event->type() == QEvent::FocusOut) |
||||||
mapper->addMapping(map_port_upnp, OptionsModel::MapPortUPnP); |
{ |
||||||
mapper->addMapping(connect_socks4, OptionsModel::ProxyUse); |
// Check proxyIP for a valid IPv4/IPv6 address
|
||||||
mapper->addMapping(proxy_ip, OptionsModel::ProxyIP); |
CService addr; |
||||||
mapper->addMapping(proxy_port, OptionsModel::ProxyPort); |
if(!LookupNumeric(ui->proxyIp->text().toStdString().c_str(), addr)) |
||||||
|
{ |
||||||
|
ui->proxyIp->setValid(false); |
||||||
|
fProxyIpValid = false; |
||||||
|
ui->statusLabel->setStyleSheet("QLabel { color: red; }"); |
||||||
|
ui->statusLabel->setText(tr("The supplied proxy address is invalid.")); |
||||||
|
emit proxyIpValid(false); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
fProxyIpValid = true; |
||||||
|
ui->statusLabel->clear(); |
||||||
|
emit proxyIpValid(true); |
||||||
|
} |
||||||
|
} |
||||||
|
return QDialog::eventFilter(object, event); |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue