Skip to content

Commit

Permalink
Merge branch 'master' of ssh://amethyst/home/orion/projects2/bitcoin/…
Browse files Browse the repository at this point in the history
…bitcoin-qt
  • Loading branch information
laanwj committed Jun 5, 2011
2 parents a4b4cc2 + 467c31e commit 9e05765
Show file tree
Hide file tree
Showing 13 changed files with 260 additions and 48 deletions.
8 changes: 3 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,18 @@ This has been implemented:

- GUI only functionality (copy to clipboard, select address, address/transaction filter proxys)

- Bitcoin core is made compatible with Qt4, and linked against
- Bitcoin core is made compatible with Qt4

- Send coins dialog: address and input validation

- Address book and transactions views and models

- Options dialog

- Sending coins

This has to be done:

- Settings are not remembered between invocations yet

- Minimize to tray / Minimize on close

- Start at system start

- Internationalization (convert WX language files)
Expand Down
3 changes: 2 additions & 1 deletion bitcoin.pro
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ HEADERS += gui/include/bitcoingui.h \
gui/include/transactionrecord.h \
gui/include/guiconstants.h \
gui/include/optionsmodel.h \
gui/include/monitoreddatamapper.h
gui/include/monitoreddatamapper.h \
core/include/externui.h
SOURCES += gui/src/bitcoin.cpp gui/src/bitcoingui.cpp \
gui/src/transactiontablemodel.cpp \
gui/src/addresstablemodel.cpp \
Expand Down
45 changes: 45 additions & 0 deletions core/include/externui.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) 2010 Satoshi Nakamoto
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_EXTERNUI_H
#define BITCOIN_EXTERNUI_H

#include <string>

typedef void wxWindow;
#define wxYES 0x00000002
#define wxOK 0x00000004
#define wxNO 0x00000008
#define wxYES_NO (wxYES|wxNO)
#define wxCANCEL 0x00000010
#define wxAPPLY 0x00000020
#define wxCLOSE 0x00000040
#define wxOK_DEFAULT 0x00000000
#define wxYES_DEFAULT 0x00000000
#define wxNO_DEFAULT 0x00000080
#define wxCANCEL_DEFAULT 0x80000000
#define wxICON_EXCLAMATION 0x00000100
#define wxICON_HAND 0x00000200
#define wxICON_WARNING wxICON_EXCLAMATION
#define wxICON_ERROR wxICON_HAND
#define wxICON_QUESTION 0x00000400
#define wxICON_INFORMATION 0x00000800
#define wxICON_STOP wxICON_HAND
#define wxICON_ASTERISK wxICON_INFORMATION
#define wxICON_MASK (0x00000100|0x00000200|0x00000400|0x00000800)
#define wxFORWARD 0x00001000
#define wxBACKWARD 0x00002000
#define wxRESET 0x00004000
#define wxHELP 0x00008000
#define wxMORE 0x00010000
#define wxSETUP 0x00020000

extern int MyMessageBox(const std::string& message, const std::string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1);
#define wxMessageBox MyMessageBox
extern int ThreadSafeMessageBox(const std::string& message, const std::string& caption, int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1);
extern bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption, wxWindow* parent);
extern void CalledSetStatusBar(const std::string& strText, int nField);
extern void UIThreadCall(boost::function0<void> fn);
extern void MainFrameRepaint();

#endif
2 changes: 1 addition & 1 deletion core/include/headers.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
#include "uibase.h"
#include "ui.h"
#else
#include "noui.h"
#include "externui.h"
#endif
#include "init.h"

Expand Down
18 changes: 13 additions & 5 deletions gui/include/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class ClientModel;
QT_BEGIN_NAMESPACE
class QLabel;
class QLineEdit;
class QTableView;
class QAbstractItemModel;
QT_END_NAMESPACE

class BitcoinGUI : public QMainWindow
Expand All @@ -27,8 +29,12 @@ class BitcoinGUI : public QMainWindow
Sent = 2,
Received = 3
} TabIndex;

protected:
void changeEvent(QEvent *e);
void closeEvent(QCloseEvent *event);

private:
TransactionTableModel *transaction_model;
ClientModel *model;

QLineEdit *address;
Expand All @@ -41,33 +47,35 @@ class BitcoinGUI : public QMainWindow
QAction *sendcoins;
QAction *addressbook;
QAction *about;
QAction *receiving_addresses;
QAction *receivingAddresses;
QAction *options;
QAction *openBitCoin;
QAction *openBitcoin;

QSystemTrayIcon *trayIcon;
QList<QTableView *> transactionViews;

void createActions();
QWidget *createTabs();
void createTrayIcon();
void setTabsModel(QAbstractItemModel *transaction_model);

public slots:
void setBalance(qint64 balance);
void setAddress(const QString &address);
void setNumConnections(int count);
void setNumBlocks(int count);
void setNumTransactions(int count);
void error(const QString &title, const QString &message);

private slots:
void sendcoinsClicked();
void addressbookClicked();
void optionsClicked();
void receivingAddressesClicked();
void aboutClicked();

void newAddressClicked();
void copyClipboardClicked();
void error(const QString &title, const QString &message);
void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
};

#endif
3 changes: 3 additions & 0 deletions gui/include/clientmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

class OptionsModel;
class AddressTableModel;
class TransactionTableModel;

class ClientModel : public QObject
{
Expand All @@ -25,6 +26,7 @@ class ClientModel : public QObject

OptionsModel *getOptionsModel();
AddressTableModel *getAddressTableModel();
TransactionTableModel *getTransactionTableModel();

qint64 getBalance();
QString getAddress();
Expand All @@ -39,6 +41,7 @@ class ClientModel : public QObject
private:
OptionsModel *optionsModel;
AddressTableModel *addressTableModel;
TransactionTableModel *transactionTableModel;

signals:
void balanceChanged(qint64 balance);
Expand Down
7 changes: 6 additions & 1 deletion gui/include/optionsmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@

#include <QAbstractListModel>

/* Interface from QT to configuration data structure for bitcoin client */
/* Interface from QT to configuration data structure for bitcoin client.
To QT, the options are presented as a list with the different options
laid out vertically.
This can be changed to a tree once the settings become sufficiently
complex.
*/
class OptionsModel : public QAbstractListModel
{
Q_OBJECT
Expand Down
3 changes: 3 additions & 0 deletions gui/src/aboutdialog.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#include "aboutdialog.h"
#include "ui_aboutdialog.h"

#include "util.h"

AboutDialog::AboutDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::AboutDialog)
{
ui->setupUi(this);
ui->versionLabel->setText(QString::fromStdString(FormatFullVersion()));
}

AboutDialog::~AboutDialog()
Expand Down
66 changes: 65 additions & 1 deletion gui/src/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,85 @@
#include "clientmodel.h"
#include "util.h"
#include "init.h"
#include "externui.h"

#include <QApplication>
#include <QMessageBox>

// Need a global reference to process net thread
BitcoinGUI *guiref;

int MyMessageBox(const std::string& message, const std::string& caption, int style, wxWindow* parent, int x, int y)
{
// Message from main thread
printf("MyMessageBox\n");
if(guiref)
{
guiref->error(QString::fromStdString(caption),
QString::fromStdString(message));
}
else
{
QMessageBox::critical(0, QString::fromStdString(caption),
QString::fromStdString(message),
QMessageBox::Ok, QMessageBox::Ok);
}
return 4;
}

int ThreadSafeMessageBox(const std::string& message, const std::string& caption, int style, wxWindow* parent, int x, int y)
{
// Message from network thread
if(guiref)
{
QMetaObject::invokeMethod(guiref, "error", Qt::QueuedConnection,
Q_ARG(QString, QString::fromStdString(caption)),
Q_ARG(QString, QString::fromStdString(message)));
}
else
{
printf("%s: %s\n", caption.c_str(), message.c_str());
fprintf(stderr, "%s: %s\n", caption.c_str(), message.c_str());
}
return 4;
}

bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption, wxWindow* parent)
{
// Query from network thread
// TODO
return true;
}

void CalledSetStatusBar(const std::string& strText, int nField)
{
// Only used for built-in mining, which is disabled, simple ignore
}

void UIThreadCall(boost::function0<void> fn)
{
// Only used for built-in mining, which is disabled, simple ignore
}

void MainFrameRepaint()
{
}

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
app.setQuitOnLastWindowClosed(false);
BitcoinGUI window;
guiref = &window;

try {
if(AppInit2(argc, argv))
{
ClientModel model;
BitcoinGUI window;
window.setModel(&model);

window.show();
guiref = 0;

/* Depending on settings: QApplication::setQuitOnLastWindowClosed(false); */
int retval = app.exec();
Expand Down
Loading

0 comments on commit 9e05765

Please sign in to comment.