mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 21:42:47 +01:00
clipboard handling
This commit is contained in:
parent
d5da2f7b37
commit
3f323a61fe
@ -13,5 +13,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
window.show();
|
window.show();
|
||||||
|
|
||||||
|
/* Depending on settings: QApplication::setQuitOnLastWindowClosed(false); */
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
135
bitcoingui.cpp
135
bitcoingui.cpp
@ -27,24 +27,20 @@
|
|||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
#include <QClipboard>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
BitcoinGUI::BitcoinGUI(QWidget *parent):
|
BitcoinGUI::BitcoinGUI(QWidget *parent):
|
||||||
QMainWindow(parent)
|
QMainWindow(parent), trayIcon(0)
|
||||||
{
|
{
|
||||||
resize(850, 550);
|
resize(850, 550);
|
||||||
setWindowTitle(tr("Bitcoin"));
|
setWindowTitle(tr("Bitcoin"));
|
||||||
setWindowIcon(QIcon(":icons/bitcoin"));
|
setWindowIcon(QIcon(":icons/bitcoin"));
|
||||||
|
|
||||||
QAction *quit = new QAction(QIcon(":/icons/quit"), tr("&Quit"), this);
|
createActions();
|
||||||
QAction *sendcoins = new QAction(QIcon(":/icons/send"), tr("&Send coins"), this);
|
|
||||||
QAction *addressbook = new QAction(QIcon(":/icons/address-book"), tr("&Address Book"), this);
|
|
||||||
QAction *about = new QAction(QIcon(":/icons/bitcoin"), tr("&About"), this);
|
|
||||||
QAction *receiving_addresses = new QAction(QIcon(":/icons/receiving-addresses"), tr("Your &Receiving Addresses..."), this);
|
|
||||||
QAction *options = new QAction(QIcon(":/icons/options"), tr("&Options..."), this);
|
|
||||||
|
|
||||||
/* Menus */
|
/* Menus */
|
||||||
QMenu *file = menuBar()->addMenu("&File");
|
QMenu *file = menuBar()->addMenu("&File");
|
||||||
@ -68,9 +64,10 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
|
|||||||
/* Address: <address>: New... : Paste to clipboard */
|
/* Address: <address>: New... : Paste to clipboard */
|
||||||
QHBoxLayout *hbox_address = new QHBoxLayout();
|
QHBoxLayout *hbox_address = new QHBoxLayout();
|
||||||
hbox_address->addWidget(new QLabel(tr("Your Bitcoin Address:")));
|
hbox_address->addWidget(new QLabel(tr("Your Bitcoin Address:")));
|
||||||
QLineEdit *edit_address = new QLineEdit();
|
address = new QLineEdit();
|
||||||
edit_address->setReadOnly(true);
|
address->setReadOnly(true);
|
||||||
hbox_address->addWidget(edit_address);
|
address->setText("0123456789");
|
||||||
|
hbox_address->addWidget(address);
|
||||||
|
|
||||||
QPushButton *button_new = new QPushButton(tr("&New..."));
|
QPushButton *button_new = new QPushButton(tr("&New..."));
|
||||||
QPushButton *button_clipboard = new QPushButton(tr("&Copy to clipboard"));
|
QPushButton *button_clipboard = new QPushButton(tr("&Copy to clipboard"));
|
||||||
@ -82,19 +79,84 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
|
|||||||
hbox_balance->addWidget(new QLabel(tr("Balance:")));
|
hbox_balance->addWidget(new QLabel(tr("Balance:")));
|
||||||
hbox_balance->addSpacing(5);/* Add some spacing between the label and the text */
|
hbox_balance->addSpacing(5);/* Add some spacing between the label and the text */
|
||||||
|
|
||||||
QLabel *label_balance = new QLabel(QLocale::system().toString(1345.54));
|
labelBalance = new QLabel(QLocale::system().toString(1345.54));
|
||||||
label_balance->setFont(QFont("Teletype"));
|
labelBalance->setFont(QFont("Teletype"));
|
||||||
hbox_balance->addWidget(label_balance);
|
hbox_balance->addWidget(labelBalance);
|
||||||
hbox_balance->addStretch(1);
|
hbox_balance->addStretch(1);
|
||||||
|
|
||||||
/* Tab widget */
|
|
||||||
QVBoxLayout *vbox = new QVBoxLayout();
|
QVBoxLayout *vbox = new QVBoxLayout();
|
||||||
vbox->addLayout(hbox_address);
|
vbox->addLayout(hbox_address);
|
||||||
vbox->addLayout(hbox_balance);
|
vbox->addLayout(hbox_balance);
|
||||||
|
|
||||||
TransactionTableModel *transaction_model = new TransactionTableModel(this);
|
transaction_model = new TransactionTableModel(this);
|
||||||
|
|
||||||
/* setupTabs */
|
vbox->addWidget(createTabs());
|
||||||
|
|
||||||
|
QWidget *centralwidget = new QWidget(this);
|
||||||
|
centralwidget->setLayout(vbox);
|
||||||
|
setCentralWidget(centralwidget);
|
||||||
|
|
||||||
|
/* Create status bar */
|
||||||
|
statusBar();
|
||||||
|
|
||||||
|
QLabel *label_connections = new QLabel("6 connections");
|
||||||
|
label_connections->setFrameStyle(QFrame::Panel | QFrame::Sunken);
|
||||||
|
label_connections->setMinimumWidth(100);
|
||||||
|
|
||||||
|
QLabel *label_blocks = new QLabel("6 blocks");
|
||||||
|
label_blocks->setFrameStyle(QFrame::Panel | QFrame::Sunken);
|
||||||
|
label_blocks->setMinimumWidth(100);
|
||||||
|
|
||||||
|
QLabel *label_transactions = new QLabel("6 transactions");
|
||||||
|
label_transactions->setFrameStyle(QFrame::Panel | QFrame::Sunken);
|
||||||
|
label_transactions->setMinimumWidth(100);
|
||||||
|
|
||||||
|
statusBar()->addPermanentWidget(label_connections);
|
||||||
|
statusBar()->addPermanentWidget(label_blocks);
|
||||||
|
statusBar()->addPermanentWidget(label_transactions);
|
||||||
|
|
||||||
|
/* Action bindings */
|
||||||
|
connect(button_new, SIGNAL(clicked()), this, SLOT(newAddressClicked()));
|
||||||
|
connect(button_clipboard, SIGNAL(clicked()), this, SLOT(copyClipboardClicked()));
|
||||||
|
|
||||||
|
createTrayIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BitcoinGUI::createActions()
|
||||||
|
{
|
||||||
|
quit = new QAction(QIcon(":/icons/quit"), tr("&Exit"), this);
|
||||||
|
sendcoins = new QAction(QIcon(":/icons/send"), tr("&Send coins"), this);
|
||||||
|
addressbook = new QAction(QIcon(":/icons/address-book"), tr("&Address Book"), this);
|
||||||
|
about = new QAction(QIcon(":/icons/bitcoin"), tr("&About"), this);
|
||||||
|
receiving_addresses = new QAction(QIcon(":/icons/receiving-addresses"), tr("Your &Receiving Addresses..."), this);
|
||||||
|
options = new QAction(QIcon(":/icons/options"), tr("&Options..."), this);
|
||||||
|
openBitCoin = new QAction(QIcon(":/icons/bitcoin"), "Open Bitcoin", this);
|
||||||
|
|
||||||
|
connect(quit, SIGNAL(triggered()), qApp, SLOT(quit()));
|
||||||
|
connect(sendcoins, SIGNAL(triggered()), this, SLOT(sendcoinsClicked()));
|
||||||
|
connect(addressbook, SIGNAL(triggered()), this, SLOT(addressbookClicked()));
|
||||||
|
connect(receiving_addresses, SIGNAL(triggered()), this, SLOT(receivingAddressesClicked()));
|
||||||
|
connect(options, SIGNAL(triggered()), this, SLOT(optionsClicked()));
|
||||||
|
connect(about, SIGNAL(triggered()), this, SLOT(aboutClicked()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void BitcoinGUI::createTrayIcon()
|
||||||
|
{
|
||||||
|
QMenu *trayIconMenu = new QMenu(this);
|
||||||
|
trayIconMenu->addAction(openBitCoin);
|
||||||
|
trayIconMenu->addAction(sendcoins);
|
||||||
|
trayIconMenu->addAction(options);
|
||||||
|
trayIconMenu->addSeparator();
|
||||||
|
trayIconMenu->addAction(quit);
|
||||||
|
|
||||||
|
trayIcon = new QSystemTrayIcon(this);
|
||||||
|
trayIcon->setContextMenu(trayIconMenu);
|
||||||
|
trayIcon->setIcon(QIcon(":/icons/bitcoin"));
|
||||||
|
trayIcon->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *BitcoinGUI::createTabs()
|
||||||
|
{
|
||||||
QStringList tab_filters, tab_labels;
|
QStringList tab_filters, tab_labels;
|
||||||
tab_filters << "^."
|
tab_filters << "^."
|
||||||
<< "^[sr]"
|
<< "^[sr]"
|
||||||
@ -133,41 +195,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
|
|||||||
|
|
||||||
tabs->addTab(transaction_table, tab_labels.at(i));
|
tabs->addTab(transaction_table, tab_labels.at(i));
|
||||||
}
|
}
|
||||||
|
return tabs;
|
||||||
vbox->addWidget(tabs);
|
|
||||||
|
|
||||||
QWidget *centralwidget = new QWidget(this);
|
|
||||||
centralwidget->setLayout(vbox);
|
|
||||||
setCentralWidget(centralwidget);
|
|
||||||
|
|
||||||
/* Status bar */
|
|
||||||
statusBar();
|
|
||||||
|
|
||||||
QLabel *label_connections = new QLabel("6 connections");
|
|
||||||
label_connections->setFrameStyle(QFrame::Panel | QFrame::Sunken);
|
|
||||||
label_connections->setMinimumWidth(100);
|
|
||||||
|
|
||||||
QLabel *label_blocks = new QLabel("6 blocks");
|
|
||||||
label_blocks->setFrameStyle(QFrame::Panel | QFrame::Sunken);
|
|
||||||
label_blocks->setMinimumWidth(100);
|
|
||||||
|
|
||||||
QLabel *label_transactions = new QLabel("6 transactions");
|
|
||||||
label_transactions->setFrameStyle(QFrame::Panel | QFrame::Sunken);
|
|
||||||
label_transactions->setMinimumWidth(100);
|
|
||||||
|
|
||||||
statusBar()->addPermanentWidget(label_connections);
|
|
||||||
statusBar()->addPermanentWidget(label_blocks);
|
|
||||||
statusBar()->addPermanentWidget(label_transactions);
|
|
||||||
|
|
||||||
/* Action bindings */
|
|
||||||
connect(quit, SIGNAL(triggered()), qApp, SLOT(quit()));
|
|
||||||
connect(sendcoins, SIGNAL(triggered()), this, SLOT(sendcoinsClicked()));
|
|
||||||
connect(addressbook, SIGNAL(triggered()), this, SLOT(addressbookClicked()));
|
|
||||||
connect(receiving_addresses, SIGNAL(triggered()), this, SLOT(receivingAddressesClicked()));
|
|
||||||
connect(options, SIGNAL(triggered()), this, SLOT(optionsClicked()));
|
|
||||||
connect(button_new, SIGNAL(clicked()), this, SLOT(newAddressClicked()));
|
|
||||||
connect(button_clipboard, SIGNAL(clicked()), this, SLOT(copyClipboardClicked()));
|
|
||||||
connect(about, SIGNAL(triggered()), this, SLOT(aboutClicked()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinGUI::sendcoinsClicked()
|
void BitcoinGUI::sendcoinsClicked()
|
||||||
@ -216,5 +244,6 @@ void BitcoinGUI::newAddressClicked()
|
|||||||
void BitcoinGUI::copyClipboardClicked()
|
void BitcoinGUI::copyClipboardClicked()
|
||||||
{
|
{
|
||||||
qDebug() << "Copy to clipboard";
|
qDebug() << "Copy to clipboard";
|
||||||
/* TODO: copy to clipboard */
|
/* Copy text in address to clipboard */
|
||||||
|
QApplication::clipboard()->setText(address->text());
|
||||||
}
|
}
|
||||||
|
26
bitcoingui.h
26
bitcoingui.h
@ -2,6 +2,12 @@
|
|||||||
#define BITCOINGUI_H
|
#define BITCOINGUI_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include <QSystemTrayIcon>
|
||||||
|
|
||||||
|
/* Forward declarations */
|
||||||
|
class TransactionTableModel;
|
||||||
|
class QLabel;
|
||||||
|
class QLineEdit;
|
||||||
|
|
||||||
class BitcoinGUI : public QMainWindow
|
class BitcoinGUI : public QMainWindow
|
||||||
{
|
{
|
||||||
@ -16,6 +22,26 @@ public:
|
|||||||
Sent = 2,
|
Sent = 2,
|
||||||
Received = 3
|
Received = 3
|
||||||
} TabIndex;
|
} TabIndex;
|
||||||
|
private:
|
||||||
|
TransactionTableModel *transaction_model;
|
||||||
|
|
||||||
|
QLineEdit *address;
|
||||||
|
QLabel *labelBalance;
|
||||||
|
|
||||||
|
QAction *quit;
|
||||||
|
QAction *sendcoins;
|
||||||
|
QAction *addressbook;
|
||||||
|
QAction *about;
|
||||||
|
QAction *receiving_addresses;
|
||||||
|
QAction *options;
|
||||||
|
QAction *openBitCoin;
|
||||||
|
|
||||||
|
QSystemTrayIcon *trayIcon;
|
||||||
|
|
||||||
|
void createActions();
|
||||||
|
QWidget *createTabs();
|
||||||
|
void createTrayIcon();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void sendcoinsClicked();
|
void sendcoinsClicked();
|
||||||
void addressbookClicked();
|
void addressbookClicked();
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
|
|
||||||
#include "addressbookdialog.h"
|
#include "addressbookdialog.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QClipboard>
|
||||||
|
|
||||||
SendCoinsDialog::SendCoinsDialog(QWidget *parent) :
|
SendCoinsDialog::SendCoinsDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::SendCoinsDialog)
|
ui(new Ui::SendCoinsDialog)
|
||||||
@ -27,7 +30,8 @@ void SendCoinsDialog::on_cancelButton_clicked()
|
|||||||
|
|
||||||
void SendCoinsDialog::on_pasteButton_clicked()
|
void SendCoinsDialog::on_pasteButton_clicked()
|
||||||
{
|
{
|
||||||
|
/* Paste text from clipboard into recipient field */
|
||||||
|
ui->payTo->setText(QApplication::clipboard()->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendCoinsDialog::on_addressBookButton_clicked()
|
void SendCoinsDialog::on_addressBookButton_clicked()
|
||||||
|
Loading…
Reference in New Issue
Block a user