X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fqt%2Fbitcoingui.cpp;h=815d8728572fdfee5047f143e8b79a5f5b174067;hb=6af93ee2ea58fe513647a6fdf007561d196a0e72;hp=d77279d42bcd5f27c641f4078c201e9184b6fba2;hpb=b2a967cd0b158f40787cc1acb4f1e245b5066cdf;p=novacoin.git diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index d77279d..815d872 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -1,13 +1,14 @@ /* * Qt4 bitcoin GUI. * - * W.J. van der Laan 2011 - * The Bitcoin Developers 2011 + * W.J. van der Laan 20011-2012 + * The Bitcoin Developers 20011-2012 */ #include "bitcoingui.h" #include "transactiontablemodel.h" #include "addressbookpage.h" #include "sendcoinsdialog.h" +#include "messagepage.h" #include "optionsdialog.h" #include "aboutdialog.h" #include "clientmodel.h" @@ -55,6 +56,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): QMainWindow(parent), clientModel(0), walletModel(0), + dummyWidget(0), encryptWalletAction(0), changePassphraseAction(0), aboutQtAction(0), @@ -84,6 +86,9 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): // Create the tray icon (or setup the dock icon) createTrayIcon(); + // Dummy widget used when restoring window state after minimization + dummyWidget = new QWidget(); + // Create tabs overviewPage = new OverviewPage(); @@ -99,12 +104,17 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): sendCoinsPage = new SendCoinsDialog(this); + messagePage = new MessagePage(this); + centralWidget = new QStackedWidget(this); centralWidget->addWidget(overviewPage); centralWidget->addWidget(transactionsPage); centralWidget->addWidget(addressBookPage); centralWidget->addWidget(receiveCoinsPage); centralWidget->addWidget(sendCoinsPage); +#ifdef FIRST_CLASS_MESSAGING + centralWidget->addWidget(messagePage); +#endif setCentralWidget(centralWidget); // Create status bar @@ -156,6 +166,7 @@ BitcoinGUI::~BitcoinGUI() #ifdef Q_WS_MAC delete appMenuBar; #endif + delete dummyWidget; } void BitcoinGUI::createActions() @@ -192,16 +203,25 @@ void BitcoinGUI::createActions() sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2)); tabGroup->addAction(sendCoinsAction); - connect(overviewAction, SIGNAL(triggered()), this, SLOT(show())); + messageAction = new QAction(QIcon(":/icons/edit"), tr("Sign &message"), this); + messageAction->setToolTip(tr("Prove you control an address")); +#ifdef FIRST_CLASS_MESSAGING + messageAction->setCheckable(true); +#endif + tabGroup->addAction(messageAction); + + connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormal())); connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage())); - connect(historyAction, SIGNAL(triggered()), this, SLOT(show())); + connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormal())); connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage())); - connect(addressBookAction, SIGNAL(triggered()), this, SLOT(show())); + connect(addressBookAction, SIGNAL(triggered()), this, SLOT(showNormal())); connect(addressBookAction, SIGNAL(triggered()), this, SLOT(gotoAddressBookPage())); - connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(show())); + connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(showNormal())); connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage())); - connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(show())); + connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormal())); connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage())); + connect(messageAction, SIGNAL(triggered()), this, SLOT(showNormal())); + connect(messageAction, SIGNAL(triggered()), this, SLOT(gotoMessagePage())); quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit"), this); quitAction->setToolTip(tr("Quit application")); @@ -247,6 +267,10 @@ void BitcoinGUI::createMenuBar() // Configure the menus QMenu *file = appMenuBar->addMenu(tr("&File")); +#ifndef FIRST_CLASS_MESSAGING + file->addAction(messageAction); + file->addSeparator(); +#endif file->addAction(quitAction); QMenu *settings = appMenuBar->addMenu(tr("&Settings")); @@ -269,6 +293,9 @@ void BitcoinGUI::createToolBars() toolbar->addAction(receiveCoinsAction); toolbar->addAction(historyAction); toolbar->addAction(addressBookAction); +#ifdef FIRST_CLASS_MESSAGING + toolbar->addAction(messageAction); +#endif QToolBar *toolbar2 = addToolBar(tr("Actions toolbar")); toolbar2->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); @@ -323,6 +350,7 @@ void BitcoinGUI::setWalletModel(WalletModel *walletModel) addressBookPage->setModel(walletModel->getAddressTableModel()); receiveCoinsPage->setModel(walletModel->getAddressTableModel()); sendCoinsPage->setModel(walletModel); + messagePage->setModel(walletModel); setEncryptionStatus(walletModel->getEncryptionStatus()); connect(walletModel, SIGNAL(encryptionStatusChanged(int)), this, SLOT(setEncryptionStatus(int))); @@ -358,6 +386,10 @@ void BitcoinGUI::createTrayIcon() // Configuration of the tray icon (or dock icon) icon menu trayIconMenu->addAction(openBitcoinAction); trayIconMenu->addSeparator(); + trayIconMenu->addAction(messageAction); +#ifndef FIRST_CLASS_MESSAGING + trayIconMenu->addSeparator(); +#endif trayIconMenu->addAction(receiveCoinsAction); trayIconMenu->addAction(sendCoinsAction); trayIconMenu->addSeparator(); @@ -378,10 +410,17 @@ void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason) // Click on system tray icon triggers "open bitcoin" openBitcoinAction->trigger(); } - } #endif +void BitcoinGUI::showNormal() +{ + // Reparent window to the desktop (in case it was hidden on minimize) + if(parent() != NULL) + setParent(NULL, Qt::Window); + QMainWindow::showNormal(); +} + void BitcoinGUI::optionsClicked() { if(!clientModel || !clientModel->getOptionsModel()) @@ -523,13 +562,13 @@ void BitcoinGUI::changeEvent(QEvent *e) { if(isMinimized()) { - hide(); - e->ignore(); + // Hiding the window from taskbar + setParent(dummyWidget, Qt::SubWindow); + return; } else { - show(); - e->accept(); + showNormal(); } } } @@ -648,6 +687,26 @@ void BitcoinGUI::gotoSendCoinsPage() disconnect(exportAction, SIGNAL(triggered()), 0, 0); } +void BitcoinGUI::gotoMessagePage() +{ +#ifdef FIRST_CLASS_MESSAGING + messageAction->setChecked(true); + centralWidget->setCurrentWidget(messagePage); + + exportAction->setEnabled(false); + disconnect(exportAction, SIGNAL(triggered()), 0, 0); +#else + messagePage->show(); + messagePage->setFocus(); +#endif +} + +void BitcoinGUI::gotoMessagePage(QString addr) +{ + gotoMessagePage(); + messagePage->setAddress(addr); +} + void BitcoinGUI::dragEnterEvent(QDragEnterEvent *event) { // Accept only URLs @@ -670,6 +729,13 @@ void BitcoinGUI::dropEvent(QDropEvent *event) event->acceptProposedAction(); } +void BitcoinGUI::handleURL(QString strURL) +{ + gotoSendCoinsPage(); + QUrl url = QUrl(strURL); + sendCoinsPage->handleURL(&url); +} + void BitcoinGUI::setEncryptionStatus(int status) { switch(status)