minimize amount of text in status bar; show only icons, if the user wants explanation...
[novacoin.git] / src / qt / bitcoingui.cpp
index ed687c4..c9feca5 100644 (file)
 #include "aboutdialog.h"
 #include "clientmodel.h"
 #include "walletmodel.h"
-#include "guiutil.h"
 #include "editaddressdialog.h"
 #include "optionsmodel.h"
 #include "transactiondescdialog.h"
 #include "addresstablemodel.h"
 #include "transactionview.h"
 #include "overviewpage.h"
+#include "bitcoinunits.h"
 
 #include <QApplication>
 #include <QMainWindow>
@@ -85,7 +85,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
     QVBoxLayout *vbox = new QVBoxLayout();
 
     transactionView = new TransactionView(this);
-    connect(transactionView, SIGNAL(doubleClicked(const QModelIndex&)), transactionView, SLOT(showDetails()));
+    connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), transactionView, SLOT(showDetails()));
     vbox->addWidget(transactionView);
 
     transactionsPage = new QWidget(this);
@@ -108,34 +108,21 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
     // Create status bar
     statusBar();
 
-    // Status bar "Connections" notification
-    QFrame *frameConnections = new QFrame();
-    frameConnections->setFrameStyle(QFrame::Panel | QFrame::Sunken);
-    frameConnections->setMinimumWidth(150);
-    frameConnections->setMaximumWidth(150);
-    QHBoxLayout *frameConnectionsLayout = new QHBoxLayout(frameConnections);
-    frameConnectionsLayout->setContentsMargins(3,0,3,0);
-    frameConnectionsLayout->setSpacing(3);
-    labelConnectionsIcon = new QLabel();
-    labelConnectionsIcon->setToolTip(tr("Number of connections to other clients"));
-    frameConnectionsLayout->addWidget(labelConnectionsIcon);
-    labelConnections = new QLabel();
-    labelConnections->setToolTip(tr("Number of connections to other clients"));
-    frameConnectionsLayout->addWidget(labelConnections);
-    frameConnectionsLayout->addStretch();
-
     // Status bar "Blocks" notification
     QFrame *frameBlocks = new QFrame();
-    frameBlocks->setFrameStyle(QFrame::Panel | QFrame::Sunken);
-    frameBlocks->setMinimumWidth(150);
-    frameBlocks->setMaximumWidth(150);
+    //frameBlocks->setFrameStyle(QFrame::Panel | QFrame::Sunken);
+    frameBlocks->setContentsMargins(0,0,0,0);
+    frameBlocks->setMinimumWidth(56);
+    frameBlocks->setMaximumWidth(56);
     QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
     frameBlocksLayout->setContentsMargins(3,0,3,0);
     frameBlocksLayout->setSpacing(3);
+    labelConnectionsIcon = new QLabel();
     labelBlocksIcon = new QLabel();
+    frameBlocksLayout->addStretch();
+    frameBlocksLayout->addWidget(labelConnectionsIcon);
+    frameBlocksLayout->addStretch();
     frameBlocksLayout->addWidget(labelBlocksIcon);
-    labelBlocks = new QLabel();
-    frameBlocksLayout->addWidget(labelBlocks);
     frameBlocksLayout->addStretch();
 
     // Progress bar for blocks download
@@ -147,14 +134,16 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
 
     statusBar()->addWidget(progressBarLabel);
     statusBar()->addWidget(progressBar);
-    statusBar()->addPermanentWidget(frameConnections);
     statusBar()->addPermanentWidget(frameBlocks);
 
     createTrayIcon();
 
     syncIconMovie = new QMovie(":/movies/update_spinner", "mng", this);
 
-    gotoOverviewPage();
+    // Clicking on a transaction simply sends you to transaction history page
+    connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), this, SLOT(gotoHistoryPage()));
+
+    gotoOverviewPage();    
 }
 
 void BitcoinGUI::createActions()
@@ -162,10 +151,12 @@ void BitcoinGUI::createActions()
     QActionGroup *tabGroup = new QActionGroup(this);
 
     overviewAction = new QAction(QIcon(":/icons/overview"), tr("&Overview"), this);
+    overviewAction->setToolTip(tr("Show general overview of wallet"));
     overviewAction->setCheckable(true);
     tabGroup->addAction(overviewAction);
 
     historyAction = new QAction(QIcon(":/icons/history"), tr("&Transactions"), this);
+    historyAction->setToolTip(tr("Browse transaction history"));
     historyAction->setCheckable(true);
     tabGroup->addAction(historyAction);
 
@@ -199,7 +190,7 @@ void BitcoinGUI::createActions()
     openBitcoinAction = new QAction(QIcon(":/icons/bitcoin"), tr("Open &Bitcoin"), this);
     openBitcoinAction->setToolTip(tr("Show the Bitcoin window"));
     exportAction = new QAction(QIcon(":/icons/export"), tr("&Export..."), this);
-    exportAction->setToolTip(tr("Export data in current view to a file"));
+    exportAction->setToolTip(tr("Export the current view to a file"));
 
     connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
     connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked()));
@@ -250,8 +241,8 @@ void BitcoinGUI::setWalletModel(WalletModel *walletModel)
     sendCoinsPage->setModel(walletModel);
 
     // Balloon popup for new transaction
-    connect(walletModel->getTransactionTableModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)),
-            this, SLOT(incomingTransaction(const QModelIndex &, int, int)));
+    connect(walletModel->getTransactionTableModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
+            this, SLOT(incomingTransaction(QModelIndex,int,int)));
 }
 
 void BitcoinGUI::createTrayIcon()
@@ -307,7 +298,7 @@ void BitcoinGUI::setNumConnections(int count)
     default: icon = ":/icons/connect_4"; break;
     }
     labelConnectionsIcon->setPixmap(QIcon(icon).pixmap(16,16));
-    labelConnections->setText(tr("%n connection(s)", "", count));
+    labelConnectionsIcon->setToolTip(tr("%n active connections to Bitcoin network", "", count));
 }
 
 void BitcoinGUI::setNumBlocks(int count)
@@ -334,13 +325,11 @@ void BitcoinGUI::setNumBlocks(int count)
     QDateTime lastBlockDate = clientModel->getLastBlockDate();
     int secs = lastBlockDate.secsTo(now);
     QString text;
-    bool spinning = true;
 
-    // "Up to date" icon, and outdated icon
-    if(secs < 30*60)
+    // Represent time from last generated block in human readable text
+    if(secs < 60)
     {
-        text = "Up to date";
-        spinning = false;
+        text = tr("%n second(s) ago","",secs);
     }
     else if(secs < 60*60)
     {
@@ -354,6 +343,19 @@ void BitcoinGUI::setNumBlocks(int count)
     {
         text = tr("%n day(s) ago","",secs/(60*60*24));
     }
+
+    // In the label we want to be less specific
+    bool spinning = true;
+    if(secs < 30*60)
+    {
+        tooltip = tr("Up to date") + QString("\n") + tooltip;
+        spinning = false;
+    }
+    else
+    {
+        tooltip = tr("Catching up...") + QString("\n") + tooltip;
+    }
+
     tooltip += QString("\n");
     tooltip += tr("Last received block was generated %1.").arg(text);
 
@@ -366,10 +368,8 @@ void BitcoinGUI::setNumBlocks(int count)
     {
         labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(16,16));
     }
-    labelBlocks->setText(text);
 
     labelBlocksIcon->setToolTip(tooltip);
-    labelBlocks->setToolTip(tooltip);
     progressBarLabel->setToolTip(tooltip);
     progressBar->setToolTip(tooltip);
 }
@@ -426,7 +426,8 @@ void BitcoinGUI::askFee(qint64 nFeeRequired, bool *payFee)
     QString strMessage =
         tr("This transaction is over the size limit.  You can still send it for a fee of %1, "
           "which goes to the nodes that process your transaction and helps to support the network.  "
-          "Do you want to pay the fee?").arg(GUIUtil::formatMoney(nFeeRequired));
+          "Do you want to pay the fee?").arg(
+                BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nFeeRequired));
     QMessageBox::StandardButton retval = QMessageBox::question(
           this, tr("Sending..."), strMessage,
           QMessageBox::Yes|QMessageBox::Cancel, QMessageBox::Yes);
@@ -452,7 +453,7 @@ void BitcoinGUI::incomingTransaction(const QModelIndex & parent, int start, int
         trayIcon->showMessage((amount)<0 ? tr("Sent transaction") :
                                            tr("Incoming transaction"),
                               tr("Date: ") + date + "\n" +
-                              tr("Amount: ") + GUIUtil::formatMoney(amount, true) + "\n" +
+                              tr("Amount: ") + BitcoinUnits::formatWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), amount, true) + "\n" +
                               tr("Type: ") + type + "\n" +
                               tr("Address: ") + address + "\n",
                               QSystemTrayIcon::Information);