X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fqt%2Fbitcoingui.cpp;h=4a9b420485f3daeec45ec734842a842382ca05cd;hb=d652709abaccff37c1e5ea36a8334ad643809d23;hp=3d6d7d7344d7d8b08970ac0b046318a51d76e096;hpb=17690ea5a74005bd8c9e99702f75d690e70c7b2f;p=novacoin.git diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 3d6d7d7..4a9b420 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -46,6 +46,9 @@ #include #include #include +#include +#include +#include #include #include @@ -159,6 +162,8 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): BitcoinGUI::~BitcoinGUI() { + if(trayIcon) // Hide tray icon, as deleting will let it linger until quit (on Ubuntu) + trayIcon->hide(); #ifdef Q_WS_MAC delete appMenuBar; #endif @@ -238,6 +243,8 @@ void BitcoinGUI::createActions() encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet"), this); encryptWalletAction->setToolTip(tr("Encrypt or decrypt wallet")); encryptWalletAction->setCheckable(true); + backupWalletAction = new QAction(QIcon(":/icons/filesave"), tr("&Backup Wallet"), this); + backupWalletAction->setToolTip(tr("Backup wallet to another location")); changePassphraseAction = new QAction(QIcon(":/icons/key"), tr("&Change Passphrase"), this); changePassphraseAction->setToolTip(tr("Change the passphrase used for wallet encryption")); @@ -247,6 +254,7 @@ void BitcoinGUI::createActions() connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); connect(openBitcoinAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); connect(encryptWalletAction, SIGNAL(triggered(bool)), this, SLOT(encryptWallet(bool))); + connect(backupWalletAction, SIGNAL(triggered()), this, SLOT(backupWallet())); connect(changePassphraseAction, SIGNAL(triggered()), this, SLOT(changePassphrase())); } @@ -262,11 +270,12 @@ void BitcoinGUI::createMenuBar() // Configure the menus QMenu *file = appMenuBar->addMenu(tr("&File")); + file->addAction(backupWalletAction); file->addAction(exportAction); #ifndef FIRST_CLASS_MESSAGING file->addAction(messageAction); - file->addSeparator(); #endif + file->addSeparator(); file->addAction(quitAction); QMenu *settings = appMenuBar->addMenu(tr("&Settings")); @@ -484,7 +493,11 @@ void BitcoinGUI::setNumBlocks(int count) QString text; // Represent time from last generated block in human readable text - if(secs < 60) + if(secs <= 0) + { + // Fully up to date. Leave text empty. + } + else if(secs < 60) { text = tr("%n second(s) ago","",secs); } @@ -502,9 +515,9 @@ void BitcoinGUI::setNumBlocks(int count) } // Set icon state: spinning if catching up, tick otherwise - if(secs < 30*60) + if(secs < 90*60) { - tooltip = tr("Up to date") + QString("\n") + tooltip; + tooltip = tr("Up to date") + QString(".\n") + tooltip; labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); } else @@ -514,8 +527,11 @@ void BitcoinGUI::setNumBlocks(int count) syncIconMovie->start(); } - tooltip += QString("\n"); - tooltip += tr("Last received block was generated %1.").arg(text); + if(!text.isEmpty()) + { + tooltip += QString("\n"); + tooltip += tr("Last received block was generated %1.").arg(text); + } labelBlocksIcon->setToolTip(tooltip); progressBarLabel->setToolTip(tooltip); @@ -535,37 +551,34 @@ void BitcoinGUI::refreshStatusBar() setNumBlocks(clientModel->getNumBlocks()); } -void BitcoinGUI::error(const QString &title, const QString &message) +void BitcoinGUI::error(const QString &title, const QString &message, bool modal) { // Report errors from network/worker thread - notificator->notify(Notificator::Critical, title, message); + if (modal) + { + QMessageBox::critical(this, title, message, QMessageBox::Ok, QMessageBox::Ok); + } else { + notificator->notify(Notificator::Critical, title, message); + } } void BitcoinGUI::changeEvent(QEvent *e) { + QMainWindow::changeEvent(e); #ifndef Q_WS_MAC // Ignored on Mac if(e->type() == QEvent::WindowStateChange) { if(clientModel && clientModel->getOptionsModel()->getMinimizeToTray()) { QWindowStateChangeEvent *wsevt = static_cast(e); - bool wasMinimized = wsevt->oldState() & Qt::WindowMinimized; - bool isMinimized = windowState() & Qt::WindowMinimized; - if(!wasMinimized && isMinimized) + if(!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized()) { - // Minimized, hide the window from taskbar - setWindowFlags(windowFlags() | Qt::Tool); - return; - } - else if(wasMinimized && !isMinimized) - { - // Unminimized, show the window in taskbar - setWindowFlags(windowFlags() &~ Qt::Tool); + QTimer::singleShot(0, this, SLOT(hide())); + e->ignore(); } } } #endif - QMainWindow::changeEvent(e); } void BitcoinGUI::closeEvent(QCloseEvent *event) @@ -701,7 +714,7 @@ void BitcoinGUI::gotoMessagePage(QString addr) void BitcoinGUI::dragEnterEvent(QDragEnterEvent *event) { - // Accept only URLs + // Accept only URIs if(event->mimeData()->hasUrls()) event->acceptProposedAction(); } @@ -711,21 +724,25 @@ void BitcoinGUI::dropEvent(QDropEvent *event) if(event->mimeData()->hasUrls()) { gotoSendCoinsPage(); - QList urls = event->mimeData()->urls(); - foreach(const QUrl &url, urls) + QList uris = event->mimeData()->urls(); + foreach(const QUrl &uri, uris) { - sendCoinsPage->handleURL(&url); + sendCoinsPage->handleURI(uri.toString()); } } event->acceptProposedAction(); } -void BitcoinGUI::handleURL(QString strURL) +void BitcoinGUI::handleURI(QString strURI) { gotoSendCoinsPage(); - QUrl url = QUrl(strURL); - sendCoinsPage->handleURL(&url); + sendCoinsPage->handleURI(strURI); + + if(!isActiveWindow()) + activateWindow(); + + showNormalIfMinimized(); } void BitcoinGUI::setEncryptionStatus(int status) @@ -769,6 +786,17 @@ void BitcoinGUI::encryptWallet(bool status) setEncryptionStatus(walletModel->getEncryptionStatus()); } +void BitcoinGUI::backupWallet() +{ + QString saveDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation); + QString filename = QFileDialog::getSaveFileName(this, tr("Backup Wallet"), saveDir, tr("Wallet Data (*.dat)")); + if(!filename.isEmpty()) { + if(!walletModel->backupWallet(filename)) { + QMessageBox::warning(this, tr("Backup Failed"), tr("There was an error trying to save the wallet data to the new location.")); + } + } +} + void BitcoinGUI::changePassphrase() { AskPassphraseDialog dlg(AskPassphraseDialog::ChangePass, this);