diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bitcoinrpc.cpp | 2 | ||||
-rw-r--r-- | src/makefile.osx | 2 | ||||
-rw-r--r-- | src/net.cpp | 2 | ||||
-rw-r--r-- | src/qt/forms/overviewpage.ui | 44 | ||||
-rw-r--r-- | src/qt/forms/rpcconsole.ui | 8 | ||||
-rw-r--r-- | src/qt/messagepage.cpp | 12 | ||||
-rw-r--r-- | src/qt/messagepage.h | 3 | ||||
-rw-r--r-- | src/qt/optionsdialog.cpp | 289 | ||||
-rw-r--r-- | src/qt/optionsdialog.h | 10 | ||||
-rw-r--r-- | src/qt/optionsmodel.cpp | 9 | ||||
-rw-r--r-- | src/qt/optionsmodel.h | 3 | ||||
-rw-r--r-- | src/qt/overviewpage.cpp | 14 | ||||
-rw-r--r-- | src/qt/qvaluecombobox.cpp | 6 | ||||
-rw-r--r-- | src/qt/qvaluecombobox.h | 9 | ||||
-rw-r--r-- | src/qt/rpcconsole.cpp | 38 | ||||
-rw-r--r-- | src/qt/rpcconsole.h | 3 | ||||
-rw-r--r-- | src/util.cpp | 75 | ||||
-rw-r--r-- | src/util.h | 3 |
18 files changed, 333 insertions, 199 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index a189b2b2b0..5c78656fcd 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -1525,7 +1525,7 @@ Value listtransactions(const Array& params, bool fHelp) if (pacentry != 0) AcentryToJSON(*pacentry, strAccount, ret); - if (ret.size() >= (nCount+nFrom)) break; + if ((int)ret.size() >= (nCount+nFrom)) break; } // ret is newest to oldest diff --git a/src/makefile.osx b/src/makefile.osx index 7582da0472..eb9ae4ba7f 100644 --- a/src/makefile.osx +++ b/src/makefile.osx @@ -65,7 +65,7 @@ CFLAGS = -g endif # ppc doesn't work because we don't support big-endian -CFLAGS += -Wall -Wextra -Wformat -Wformat-security -Wno-unused-paramter \ +CFLAGS += -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter \ $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) OBJS= \ diff --git a/src/net.cpp b/src/net.cpp index 7efe304fb6..8603514f91 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -716,7 +716,7 @@ void ThreadSocketHandler2(void* parg) if (nSelect == SOCKET_ERROR) { int nErr = WSAGetLastError(); - if (hSocketMax > (SOCKET) -1) + if (hSocketMax != INVALID_SOCKET) { printf("socket select error %d\n", nErr); for (unsigned int i = 0; i <= hSocketMax; i++) diff --git a/src/qt/forms/overviewpage.ui b/src/qt/forms/overviewpage.ui index 3cf7dd0ed3..aeace9f30d 100644 --- a/src/qt/forms/overviewpage.ui +++ b/src/qt/forms/overviewpage.ui @@ -43,8 +43,23 @@ </item> <item row="2" column="1"> <widget class="QLabel" name="labelBalance"> + <property name="font"> + <font> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="cursor"> + <cursorShape>IBeamCursor</cursorShape> + </property> + <property name="toolTip"> + <string>Your current balance</string> + </property> <property name="text"> - <string>123.456 BTC</string> + <string notr="true">123.456 BTC</string> + </property> + <property name="textInteractionFlags"> + <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> </property> </widget> </item> @@ -57,6 +72,9 @@ </item> <item row="4" column="1"> <widget class="QLabel" name="labelNumTransactions"> + <property name="toolTip"> + <string>Total number of transactions in wallet</string> + </property> <property name="text"> <string>0</string> </property> @@ -71,8 +89,23 @@ </item> <item row="3" column="1"> <widget class="QLabel" name="labelUnconfirmed"> + <property name="font"> + <font> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="cursor"> + <cursorShape>IBeamCursor</cursorShape> + </property> + <property name="toolTip"> + <string>Total of transactions that have yet to be confirmed, and do not yet count toward the current balance</string> + </property> <property name="text"> - <string>0 BTC</string> + <string notr="true">0 BTC</string> + </property> + <property name="textInteractionFlags"> + <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> </property> </widget> </item> @@ -81,6 +114,7 @@ <property name="font"> <font> <pointsize>11</pointsize> + <weight>75</weight> <bold>true</bold> </font> </property> @@ -127,6 +161,9 @@ </item> <item> <widget class="QListView" name="listTransactions"> + <property name="styleSheet"> + <string notr="true">QListView { background:transparent }</string> + </property> <property name="frameShape"> <enum>QFrame::NoFrame</enum> </property> @@ -136,6 +173,9 @@ <property name="horizontalScrollBarPolicy"> <enum>Qt::ScrollBarAlwaysOff</enum> </property> + <property name="selectionMode"> + <enum>QAbstractItemView::NoSelection</enum> + </property> </widget> </item> </layout> diff --git a/src/qt/forms/rpcconsole.ui b/src/qt/forms/rpcconsole.ui index bde607c527..7e496a5ce7 100644 --- a/src/qt/forms/rpcconsole.ui +++ b/src/qt/forms/rpcconsole.ui @@ -19,9 +19,9 @@ <property name="currentIndex"> <number>0</number> </property> - <widget class="QWidget" name="tab"> + <widget class="QWidget" name="tab_info"> <attribute name="title"> - <string>Information</string> + <string>&Information</string> </attribute> <layout class="QGridLayout" name="gridLayout" columnstretch="0,1"> <property name="horizontalSpacing"> @@ -232,9 +232,9 @@ </item> </layout> </widget> - <widget class="QWidget" name="tab_2"> + <widget class="QWidget" name="tab_console"> <attribute name="title"> - <string>Console</string> + <string>&Console</string> </attribute> <layout class="QVBoxLayout" name="verticalLayout_3"> <property name="spacing"> diff --git a/src/qt/messagepage.cpp b/src/qt/messagepage.cpp index 57ad8292dc..236b67bf37 100644 --- a/src/qt/messagepage.cpp +++ b/src/qt/messagepage.cpp @@ -31,6 +31,7 @@ MessagePage::MessagePage(QWidget *parent) : #endif GUIUtil::setupAddressWidget(ui->signFrom, this); + ui->signature->installEventFilter(this); } MessagePage::~MessagePage() @@ -117,3 +118,14 @@ void MessagePage::on_clearButton_clicked() ui->message->clear(); ui->signature->clear(); } + +bool MessagePage::eventFilter(QObject *object, QEvent *event) +{ + if(object == ui->signature && (event->type() == QEvent::MouseButtonPress || + event->type() == QEvent::FocusIn)) + { + ui->signature->selectAll(); + return true; + } + return QDialog::eventFilter(object, event); +} diff --git a/src/qt/messagepage.h b/src/qt/messagepage.h index b5a38166da..d668ae98d0 100644 --- a/src/qt/messagepage.h +++ b/src/qt/messagepage.h @@ -23,6 +23,9 @@ public: void setAddress(QString); +protected: + bool eventFilter(QObject *object, QEvent *event); + private: Ui::MessagePage *ui; WalletModel *model; diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 0c43647b10..6b4e037cc5 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -19,73 +19,103 @@ #include <QDoubleValidator> #include <QRegExpValidator> #include <QDialogButtonBox> +#include <QDir> +#include <QMessageBox> -/* First page of options */ -class MainOptionsPage : public QWidget +class OptionsPage: public QWidget +{ + Q_OBJECT +public: + explicit OptionsPage(QWidget *parent=0): QWidget(parent) {} + + virtual void setMapper(MonitoredDataMapper *mapper) = 0; +}; + +class MainOptionsPage: public OptionsPage { Q_OBJECT public: explicit MainOptionsPage(QWidget *parent=0); - void setMapper(MonitoredDataMapper *mapper); + virtual void setMapper(MonitoredDataMapper *mapper); +private: + QCheckBox *detach_database; + BitcoinAmountField *fee_edit; +}; + +class WindowOptionsPage: public OptionsPage +{ + Q_OBJECT +public: + explicit WindowOptionsPage(QWidget *parent=0); + + virtual void setMapper(MonitoredDataMapper *mapper); private: QCheckBox *bitcoin_at_startup; #ifndef Q_WS_MAC QCheckBox *minimize_to_tray; #endif - QCheckBox *map_port_upnp; #ifndef Q_WS_MAC QCheckBox *minimize_on_close; #endif - QCheckBox *connect_socks4; - QCheckBox *detach_database; - QLineEdit *proxy_ip; - QLineEdit *proxy_port; - BitcoinAmountField *fee_edit; - -signals: - -public slots: - }; -class DisplayOptionsPage : public QWidget +class DisplayOptionsPage: public OptionsPage { Q_OBJECT public: explicit DisplayOptionsPage(QWidget *parent=0); - void setMapper(MonitoredDataMapper *mapper); + virtual void setMapper(MonitoredDataMapper *mapper); private: + QValueComboBox *lang; QValueComboBox *unit; QCheckBox *display_addresses; -signals: + bool restart_warning_displayed; +private slots: + void showRestartWarning(); +}; -public slots: +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; + BitcoinAmountField *fee_edit; }; + #include "optionsdialog.moc" OptionsDialog::OptionsDialog(QWidget *parent): QDialog(parent), contents_widget(0), pages_widget(0), - model(0), main_page(0), display_page(0) + model(0) { contents_widget = new QListWidget(); contents_widget->setMaximumWidth(128); pages_widget = new QStackedWidget(); - pages_widget->setMinimumWidth(300); + pages_widget->setMinimumWidth(500); + pages_widget->setMinimumHeight(300); - QListWidgetItem *item_main = new QListWidgetItem(tr("Main")); - contents_widget->addItem(item_main); - main_page = new MainOptionsPage(this); - pages_widget->addWidget(main_page); + pages.append(new MainOptionsPage(this)); + pages.append(new NetworkOptionsPage(this)); + pages.append(new WindowOptionsPage(this)); + pages.append(new DisplayOptionsPage(this)); - QListWidgetItem *item_display = new QListWidgetItem(tr("Display")); - contents_widget->addItem(item_display); - display_page = new DisplayOptionsPage(this); - pages_widget->addWidget(display_page); + foreach(OptionsPage *page, pages) + { + QListWidgetItem *item = new QListWidgetItem(page->windowTitle()); + contents_widget->addItem(item); + pages_widget->addWidget(page); + } contents_widget->setCurrentRow(0); @@ -125,8 +155,11 @@ void OptionsDialog::setModel(OptionsModel *model) this->model = model; mapper->setModel(model); - main_page->setMapper(mapper); - display_page->setMapper(mapper); + + foreach(OptionsPage *page, pages) + { + page->setMapper(mapper); + } mapper->toFirst(); } @@ -163,10 +196,116 @@ void OptionsDialog::disableApply() apply_button->setEnabled(false); } +/* Main options */ MainOptionsPage::MainOptionsPage(QWidget *parent): - QWidget(parent) + OptionsPage(parent) +{ + QVBoxLayout *layout = new QVBoxLayout(); + setWindowTitle(tr("Main")); + + 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); + + 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) +{ + // Map model to widgets + mapper->addMapping(fee_edit, OptionsModel::Fee); + mapper->addMapping(detach_database, OptionsModel::DetachDatabases); +} + +/* Display options */ +DisplayOptionsPage::DisplayOptionsPage(QWidget *parent): + OptionsPage(parent), restart_warning_displayed(false) +{ + setWindowTitle(tr("Display")); + + 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("(default)", 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) +{ + mapper->addMapping(lang, OptionsModel::Language); + mapper->addMapping(unit, OptionsModel::DisplayUnit); + mapper->addMapping(display_addresses, OptionsModel::DisplayAddresses); +} + +void DisplayOptionsPage::showRestartWarning() +{ + if(!restart_warning_displayed) + { + QMessageBox::warning(this, tr("Warning"), tr("This setting will take effect after restarting Bitcoin."), QMessageBox::Ok); + restart_warning_displayed = true; + } +} + +/* Window options */ +WindowOptionsPage::WindowOptionsPage(QWidget *parent): + OptionsPage(parent) { QVBoxLayout *layout = new QVBoxLayout(); + setWindowTitle(tr("Window")); bitcoin_at_startup = new QCheckBox(tr("&Start Bitcoin on window system startup")); bitcoin_at_startup->setToolTip(tr("Automatically start Bitcoin after the computer is turned on")); @@ -182,6 +321,29 @@ MainOptionsPage::MainOptionsPage(QWidget *parent): layout->addWidget(minimize_on_close); #endif + layout->addStretch(1); // Extra space at bottom + setLayout(layout); +} + +void WindowOptionsPage::setMapper(MonitoredDataMapper *mapper) +{ + // Map model to widgets + mapper->addMapping(bitcoin_at_startup, OptionsModel::StartAtStartup); +#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 */ +NetworkOptionsPage::NetworkOptionsPage(QWidget *parent): + OptionsPage(parent) +{ + QVBoxLayout *layout = new QVBoxLayout(); + setWindowTitle(tr("Network")); + map_port_upnp = new QCheckBox(tr("Map port using &UPnP")); 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); @@ -211,30 +373,9 @@ MainOptionsPage::MainOptionsPage(QWidget *parent): proxy_port_label->setBuddy(proxy_port); proxy_hbox->addWidget(proxy_port); proxy_hbox->addStretch(1); - layout->addLayout(proxy_hbox); - 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); - - 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); connect(connect_socks4, SIGNAL(toggled(bool)), proxy_ip, SLOT(setEnabled(bool))); @@ -245,53 +386,11 @@ MainOptionsPage::MainOptionsPage(QWidget *parent): #endif } -void MainOptionsPage::setMapper(MonitoredDataMapper *mapper) +void NetworkOptionsPage::setMapper(MonitoredDataMapper *mapper) { // Map model to widgets - mapper->addMapping(bitcoin_at_startup, OptionsModel::StartAtStartup); -#ifndef Q_WS_MAC - mapper->addMapping(minimize_to_tray, OptionsModel::MinimizeToTray); -#endif mapper->addMapping(map_port_upnp, OptionsModel::MapPortUPnP); -#ifndef Q_WS_MAC - mapper->addMapping(minimize_on_close, OptionsModel::MinimizeOnClose); -#endif mapper->addMapping(connect_socks4, OptionsModel::ConnectSOCKS4); mapper->addMapping(proxy_ip, OptionsModel::ProxyIP); mapper->addMapping(proxy_port, OptionsModel::ProxyPort); - mapper->addMapping(fee_edit, OptionsModel::Fee); - mapper->addMapping(detach_database, OptionsModel::DetachDatabases); -} - -DisplayOptionsPage::DisplayOptionsPage(QWidget *parent): - QWidget(parent) -{ - QVBoxLayout *layout = new QVBoxLayout(); - - 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) -{ - mapper->addMapping(unit, OptionsModel::DisplayUnit); - mapper->addMapping(display_addresses, OptionsModel::DisplayAddresses); } diff --git a/src/qt/optionsdialog.h b/src/qt/optionsdialog.h index 9e1f87c646..ea0cbb8bfc 100644 --- a/src/qt/optionsdialog.h +++ b/src/qt/optionsdialog.h @@ -2,6 +2,7 @@ #define OPTIONSDIALOG_H #include <QDialog> +#include <QList> QT_BEGIN_NAMESPACE class QStackedWidget; @@ -10,8 +11,7 @@ class QListWidgetItem; class QPushButton; QT_END_NAMESPACE class OptionsModel; -class MainOptionsPage; -class DisplayOptionsPage; +class OptionsPage; class MonitoredDataMapper; /** Preferences dialog. */ @@ -43,11 +43,7 @@ private: MonitoredDataMapper *mapper; QPushButton *apply_button; - // Pages - MainOptionsPage *main_page; - DisplayOptionsPage *display_page; - - void setupMainPage(); + QList<OptionsPage*> pages; }; #endif // OPTIONSDIALOG_H diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 5bba308cf2..78448d3ee1 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -21,6 +21,7 @@ void OptionsModel::Init() fMinimizeToTray = settings.value("fMinimizeToTray", false).toBool(); fMinimizeOnClose = settings.value("fMinimizeOnClose", false).toBool(); nTransactionFee = settings.value("nTransactionFee").toLongLong(); + language = settings.value("language", "").toString(); // These are shared with core bitcoin; we want // command-line options to override the GUI settings: @@ -30,6 +31,8 @@ void OptionsModel::Init() SoftSetArg("-proxy", settings.value("addrProxy").toString().toStdString()); if (settings.contains("detachDB")) SoftSetBoolArg("-detachdb", settings.value("detachDB").toBool()); + if (!language.isEmpty()) + SoftSetArg("-lang", language.toStdString()); } bool OptionsModel::Upgrade() @@ -125,6 +128,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const return QVariant(bDisplayAddresses); case DetachDatabases: return QVariant(fDetachDB); + case Language: + return settings.value("language", ""); default: return QVariant(); } @@ -213,6 +218,10 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in settings.setValue("detachDB", fDetachDB); } break; + case Language: { + settings.setValue("language", value); + } + break; default: break; } diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index da4e86f104..4315a33f8c 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -27,6 +27,7 @@ public: DisplayUnit, // BitcoinUnits::Unit DisplayAddresses, // bool DetachDatabases, // bool + Language, // QString OptionIDRowCount, }; @@ -45,11 +46,13 @@ public: bool getMinimizeOnClose(); int getDisplayUnit(); bool getDisplayAddresses(); + QString getLanguage() { return language; } private: int nDisplayUnit; bool bDisplayAddresses; bool fMinimizeToTray; bool fMinimizeOnClose; + QString language; signals: void displayUnitChanged(int unit); diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 5b5a8f5271..259f819deb 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -98,23 +98,9 @@ OverviewPage::OverviewPage(QWidget *parent) : { ui->setupUi(this); - // Balance: <balance> - ui->labelBalance->setFont(QFont("Monospace", -1, QFont::Bold)); - ui->labelBalance->setToolTip(tr("Your current balance")); - ui->labelBalance->setTextInteractionFlags(Qt::TextSelectableByMouse|Qt::TextSelectableByKeyboard); - - // Unconfirmed balance: <balance> - ui->labelUnconfirmed->setFont(QFont("Monospace", -1, QFont::Bold)); - ui->labelUnconfirmed->setToolTip(tr("Total of transactions that have yet to be confirmed, and do not yet count toward the current balance")); - ui->labelUnconfirmed->setTextInteractionFlags(Qt::TextSelectableByMouse|Qt::TextSelectableByKeyboard); - - ui->labelNumTransactions->setToolTip(tr("Total number of transactions in wallet")); - // Recent transactions - ui->listTransactions->setStyleSheet("QListView { background:transparent }"); ui->listTransactions->setItemDelegate(txdelegate); ui->listTransactions->setIconSize(QSize(DECORATION_SIZE, DECORATION_SIZE)); - ui->listTransactions->setSelectionMode(QAbstractItemView::NoSelection); ui->listTransactions->setMinimumHeight(NUM_ITEMS * (DECORATION_SIZE + 2)); ui->listTransactions->setAttribute(Qt::WA_MacShowFocusRect, false); diff --git a/src/qt/qvaluecombobox.cpp b/src/qt/qvaluecombobox.cpp index c0ad8c12e5..d7ce3d0130 100644 --- a/src/qt/qvaluecombobox.cpp +++ b/src/qt/qvaluecombobox.cpp @@ -6,12 +6,12 @@ QValueComboBox::QValueComboBox(QWidget *parent) : connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(handleSelectionChanged(int))); } -int QValueComboBox::value() const +QVariant QValueComboBox::value() const { - return itemData(currentIndex(), role).toInt(); + return itemData(currentIndex(), role); } -void QValueComboBox::setValue(int value) +void QValueComboBox::setValue(const QVariant &value) { setCurrentIndex(findData(value, role)); } diff --git a/src/qt/qvaluecombobox.h b/src/qt/qvaluecombobox.h index 11f342d71c..1a47bb6565 100644 --- a/src/qt/qvaluecombobox.h +++ b/src/qt/qvaluecombobox.h @@ -2,19 +2,20 @@ #define QVALUECOMBOBOX_H #include <QComboBox> +#include <QVariant> /* QComboBox that can be used with QDataWidgetMapper to select ordinal values from a model. */ class QValueComboBox : public QComboBox { Q_OBJECT - Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged USER true) + Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged USER true) public: explicit QValueComboBox(QWidget *parent = 0); - int value() const; - void setValue(int value); + QVariant value() const; + void setValue(const QVariant &value); - /** Specify model role to use as ordinal value */ + /** Specify model role to use as ordinal value (defaults to Qt::UserRole) */ void setRole(int role); signals: diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index d59f5c6a38..6d983989e9 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -113,27 +113,6 @@ RPCConsole::~RPCConsole() delete ui; } -bool RPCConsole::event(QEvent *event) -{ - int returnValue = QWidget::event(event); - - if (event->type() == QEvent::LayoutRequest && firstLayout) - { - // Work around QTableWidget issue: - // Call resizeRowsToContents on first Layout request with widget visible, - // to make sure multiline messages that were added before the console was shown - // have the right height. - if(ui->messagesWidget->isVisible()) - { - firstLayout = false; - ui->messagesWidget->resizeRowsToContents(); - } - return true; - } - - return returnValue; -} - bool RPCConsole::eventFilter(QObject* obj, QEvent *event) { if(obj == ui->lineEdit) @@ -314,3 +293,20 @@ void RPCConsole::copyMessage() { GUIUtil::copyEntryData(ui->messagesWidget, 1, Qt::EditRole); } + +void RPCConsole::on_tabWidget_currentChanged(int index) +{ + if(ui->tabWidget->widget(index) == ui->tab_console) + { + if(firstLayout) + { + // Work around QTableWidget issue: + // Call resizeRowsToContents on first Layout request with widget visible, + // to make sure multiline messages that were added before the console was shown + // have the right height. + firstLayout = false; + ui->messagesWidget->resizeRowsToContents(); + } + ui->lineEdit->setFocus(); + } +} diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index a0a73bedd3..2ec47b0cf8 100644 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -28,12 +28,13 @@ public: }; protected: - virtual bool event(QEvent *event); virtual bool eventFilter(QObject* obj, QEvent *event); private slots: void on_lineEdit_returnPressed(); + void on_tabWidget_currentChanged(int index); + public slots: void clear(); void message(int category, const QString &message); diff --git a/src/util.cpp b/src/util.cpp index 3d301d21e3..1a57cc6621 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -53,7 +53,6 @@ namespace boost { #endif using namespace std; -using namespace boost; map<string, string> mapArgs; map<string, vector<string> > mapMultiArgs; @@ -328,7 +327,7 @@ bool error(const char *format, ...) va_end(arg_ptr); if (ret < 0 || ret >= limit) { - buffer[limit-1] = 0; + buffer[limit - 1] = 0; } printf("ERROR: %s\n", buffer); return false; @@ -494,7 +493,7 @@ static void InterpretNegativeSetting(string name, map<string, string>& mapSettin } } -void ParseParameters(int argc, const char*const argv[]) +void ParseParameters(int argc, const char* const argv[]) { mapArgs.clear(); mapMultiArgs.clear(); @@ -761,8 +760,7 @@ bool WildcardMatch(const string& str, const string& mask) void FormatException(char* pszMessage, std::exception* pex, const char* pszThread) { #ifdef WIN32 - char pszModule[MAX_PATH]; - pszModule[0] = '\0'; + char pszModule[MAX_PATH] = ""; GetModuleFileNameA(NULL, pszModule, sizeof(pszModule)); #else const char* pszModule = "bitcoin"; @@ -801,38 +799,16 @@ void PrintExceptionContinue(std::exception* pex, const char* pszThread) strMiscWarning = pszMessage; } -#ifdef WIN32 -boost::filesystem::path MyGetSpecialFolderPath(int nFolder, bool fCreate) -{ - namespace fs = boost::filesystem; - - char pszPath[MAX_PATH] = ""; - if(SHGetSpecialFolderPathA(NULL, pszPath, nFolder, fCreate)) - { - return fs::path(pszPath); - } - else if (nFolder == CSIDL_STARTUP) - { - return fs::path(getenv("USERPROFILE")) / "Start Menu" / "Programs" / "Startup"; - } - else if (nFolder == CSIDL_APPDATA) - { - return fs::path(getenv("APPDATA")); - } - return fs::path(""); -} -#endif - boost::filesystem::path GetDefaultDataDir() { namespace fs = boost::filesystem; - - // Windows: C:\Documents and Settings\username\Application Data\Bitcoin + // Windows < Vista: C:\Documents and Settings\Username\Application Data\Bitcoin + // Windows >= Vista: C:\Users\Username\AppData\Roaming\Bitcoin // Mac: ~/Library/Application Support/Bitcoin // Unix: ~/.bitcoin #ifdef WIN32 // Windows - return MyGetSpecialFolderPath(CSIDL_APPDATA, true) / "Bitcoin"; + return GetSpecialFolderPath(CSIDL_APPDATA) / "Bitcoin"; #else fs::path pathRet; char* pszHome = getenv("HOME"); @@ -843,7 +819,7 @@ boost::filesystem::path GetDefaultDataDir() #ifdef MAC_OSX // Mac pathRet /= "Library/Application Support"; - filesystem::create_directory(pathRet); + fs::create_directory(pathRet); return pathRet / "Bitcoin"; #else // Unix @@ -889,9 +865,7 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific) boost::filesystem::path GetConfigFile() { - namespace fs = boost::filesystem; - - fs::path pathConfigFile(GetArg("-conf", "bitcoin.conf")); + boost::filesystem::path pathConfigFile(GetArg("-conf", "bitcoin.conf")); if (!pathConfigFile.is_complete()) pathConfigFile = GetDataDir(false) / pathConfigFile; return pathConfigFile; } @@ -899,24 +873,21 @@ boost::filesystem::path GetConfigFile() void ReadConfigFile(map<string, string>& mapSettingsRet, map<string, vector<string> >& mapMultiSettingsRet) { - namespace fs = boost::filesystem; - namespace pod = boost::program_options::detail; - - fs::ifstream streamConfig(GetConfigFile()); + boost::filesystem::ifstream streamConfig(GetConfigFile()); if (!streamConfig.good()) return; // No bitcoin.conf file is OK set<string> setOptions; setOptions.insert("*"); - for (pod::config_file_iterator it(streamConfig, setOptions), end; it != end; ++it) + for (boost::program_options::detail::config_file_iterator it(streamConfig, setOptions), end; it != end; ++it) { // Don't overwrite existing settings so command line settings override bitcoin.conf string strKey = string("-") + it->string_key; if (mapSettingsRet.count(strKey) == 0) { mapSettingsRet[strKey] = it->value[0]; - // interpret nofoo=1 as foo=0 (and nofoo=0 as foo=1) as long as foo not set) + // interpret nofoo=1 as foo=0 (and nofoo=0 as foo=1) as long as foo not set) InterpretNegativeSetting(strKey, mapSettingsRet); } mapMultiSettingsRet[strKey].push_back(it->value[0]); @@ -925,9 +896,7 @@ void ReadConfigFile(map<string, string>& mapSettingsRet, boost::filesystem::path GetPidFile() { - namespace fs = boost::filesystem; - - fs::path pathPidFile(GetArg("-pid", "bitcoind.pid")); + boost::filesystem::path pathPidFile(GetArg("-pid", "bitcoind.pid")); if (!pathPidFile.is_complete()) pathPidFile = GetDataDir() / pathPidFile; return pathPidFile; } @@ -1095,14 +1064,30 @@ std::string FormatSubVersion(const std::string& name, int nClientVersion, const } #ifdef WIN32 +boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate) +{ + namespace fs = boost::filesystem; + + char pszPath[MAX_PATH] = ""; + + if(SHGetSpecialFolderPathA(NULL, pszPath, nFolder, fCreate)) + { + return fs::path(pszPath); + } + + printf("SHGetSpecialFolderPathA() failed, could not obtain requested path.\n"); + return fs::path(""); +} + boost::filesystem::path static StartupShortcutPath() { - return MyGetSpecialFolderPath(CSIDL_STARTUP, true) / "Bitcoin.lnk"; + return GetSpecialFolderPath(CSIDL_STARTUP) / "Bitcoin.lnk"; } bool GetStartOnSystemStartup() { - return filesystem::exists(StartupShortcutPath()); + // check for Bitcoin.lnk + return boost::filesystem::exists(StartupShortcutPath()); } bool SetStartOnSystemStartup(bool fAutoStart) diff --git a/src/util.h b/src/util.h index 81b36d31fd..ebd574f896 100644 --- a/src/util.h +++ b/src/util.h @@ -163,6 +163,9 @@ boost::filesystem::path GetConfigFile(); boost::filesystem::path GetPidFile(); void CreatePidFile(const boost::filesystem::path &path, pid_t pid); void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet); +#ifdef WIN32 +boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate = true); +#endif bool GetStartOnSystemStartup(); bool SetStartOnSystemStartup(bool fAutoStart); void ShrinkDebugFile(); |