diff --git a/doc/assets-attribution.txt b/doc/assets-attribution.txt index e4a00fa8..d498e8b4 100644 --- a/doc/assets-attribution.txt +++ b/doc/assets-attribution.txt @@ -15,7 +15,7 @@ Designer: FatCow Web Hosting License: Creative Commons Attribution (by) Site: http://findicons.com/icon/163938/book_open -Icon: src/qt/res/icons/connect*.png, src/qt/res/icons/synced.png +Icon: src/qt/res/icons/connect*.png, src/qt/res/icons/synced.png, src/qt/res/icons/lock_*.png Icon Pack: Human-O2 Designer: schollidesign License: GNU/GPL diff --git a/src/qt/bitcoin.qrc b/src/qt/bitcoin.qrc index 629349c6..1d5a58a4 100644 --- a/src/qt/bitcoin.qrc +++ b/src/qt/bitcoin.qrc @@ -34,6 +34,8 @@ res/icons/tx_input.png res/icons/tx_output.png res/icons/tx_inout.png + res/icons/lock_closed.png + res/icons/lock_open.png res/images/about.png diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index dd94652e..22987267 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -18,6 +18,7 @@ #include "transactionview.h" #include "overviewpage.h" #include "bitcoinunits.h" +#include "guiconstants.h" #include #include @@ -118,9 +119,12 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks); frameBlocksLayout->setContentsMargins(3,0,3,0); frameBlocksLayout->setSpacing(3); + labelEncryptionIcon = new QLabel(); labelConnectionsIcon = new QLabel(); labelBlocksIcon = new QLabel(); frameBlocksLayout->addStretch(); + frameBlocksLayout->addWidget(labelEncryptionIcon); + frameBlocksLayout->addStretch(); frameBlocksLayout->addWidget(labelConnectionsIcon); frameBlocksLayout->addStretch(); frameBlocksLayout->addWidget(labelBlocksIcon); @@ -244,6 +248,9 @@ void BitcoinGUI::setWalletModel(WalletModel *walletModel) receiveCoinsPage->setModel(walletModel->getAddressTableModel()); sendCoinsPage->setModel(walletModel); + setEncryptionStatus(walletModel->getEncryptionStatus()); + connect(walletModel, SIGNAL(encryptionStatusChanged(int)), this, SLOT(setEncryptionStatus(int))); + // Balloon popup for new transaction connect(walletModel->getTransactionTableModel(), SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(incomingTransaction(QModelIndex,int,int))); @@ -300,7 +307,7 @@ void BitcoinGUI::setNumConnections(int count) case 7: case 8: case 9: icon = ":/icons/connect_3"; break; default: icon = ":/icons/connect_4"; break; } - labelConnectionsIcon->setPixmap(QIcon(icon).pixmap(16,16)); + labelConnectionsIcon->setPixmap(QIcon(icon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); labelConnectionsIcon->setToolTip(tr("%n active connection(s) to Bitcoin network", "", count)); } @@ -351,7 +358,7 @@ void BitcoinGUI::setNumBlocks(int count) if(secs < 30*60) { tooltip = tr("Up to date") + QString("\n") + tooltip; - labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(16,16)); + labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); } else { @@ -531,3 +538,22 @@ void BitcoinGUI::dropEvent(QDropEvent *event) event->acceptProposedAction(); } +void BitcoinGUI::setEncryptionStatus(int status) +{ + switch(status) + { + case WalletModel::Unencrypted: + labelEncryptionIcon->hide(); + break; + case WalletModel::Unlocked: + labelEncryptionIcon->show(); + labelEncryptionIcon->setPixmap(QIcon(":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); + labelEncryptionIcon->setToolTip(tr("Wallet is encrypted and currently unlocked")); + break; + case WalletModel::Locked: + labelEncryptionIcon->show(); + labelEncryptionIcon->setPixmap(QIcon(":/icons/lock_closed").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); + labelEncryptionIcon->setToolTip(tr("Wallet is encrypted and currently locked")); + break; + } +} diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 377da726..4b713171 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -57,6 +57,7 @@ private: AddressBookPage *receiveCoinsPage; SendCoinsDialog *sendCoinsPage; + QLabel *labelEncryptionIcon; QLabel *labelConnectionsIcon; QLabel *labelBlocksIcon; QLabel *progressBarLabel; @@ -85,6 +86,8 @@ private: public slots: void setNumConnections(int count); void setNumBlocks(int count); + void setEncryptionStatus(int status); + void error(const QString &title, const QString &message); /* It is currently not possible to pass a return value to another thread through BlockingQueuedConnection, so use an indirected pointer. diff --git a/src/qt/guiconstants.h b/src/qt/guiconstants.h index 7fbf7fcd..b7870199 100644 --- a/src/qt/guiconstants.h +++ b/src/qt/guiconstants.h @@ -1,9 +1,12 @@ #ifndef GUICONSTANTS_H #define GUICONSTANTS_H -/* milliseconds between model updates */ +/* Milliseconds between model updates */ static const int MODEL_UPDATE_DELAY = 500; +/* Size of icons in status bar */ +static const int STATUSBAR_ICONSIZE = 16; + /* Invalid field background style */ #define STYLE_INVALID "background:#FF8080" diff --git a/src/qt/res/icons/lock_closed.png b/src/qt/res/icons/lock_closed.png new file mode 100644 index 00000000..ce8da0be Binary files /dev/null and b/src/qt/res/icons/lock_closed.png differ diff --git a/src/qt/res/icons/lock_open.png b/src/qt/res/icons/lock_open.png new file mode 100644 index 00000000..6a3a8edb Binary files /dev/null and b/src/qt/res/icons/lock_open.png differ diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 10b3738c..9a7b56d3 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -12,7 +12,8 @@ WalletModel::WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *parent) : QObject(parent), wallet(wallet), optionsModel(optionsModel), addressTableModel(0), transactionTableModel(0), - cachedBalance(0), cachedUnconfirmedBalance(0), cachedNumTransactions(0) + cachedBalance(0), cachedUnconfirmedBalance(0), cachedNumTransactions(0), + cachedEncryptionStatus(Unencrypted) { // Until signal notifications is built into the bitcoin core, // simply update everything after polling using a timer. @@ -49,6 +50,7 @@ void WalletModel::update() qint64 newBalance = getBalance(); qint64 newUnconfirmedBalance = getUnconfirmedBalance(); int newNumTransactions = getNumTransactions(); + EncryptionStatus newEncryptionStatus = getEncryptionStatus(); if(cachedBalance != newBalance || cachedUnconfirmedBalance != newUnconfirmedBalance) emit balanceChanged(newBalance, newUnconfirmedBalance); @@ -56,6 +58,9 @@ void WalletModel::update() if(cachedNumTransactions != newNumTransactions) emit numTransactionsChanged(newNumTransactions); + if(cachedEncryptionStatus != newEncryptionStatus) + emit encryptionStatusChanged(newEncryptionStatus); + cachedBalance = newBalance; cachedUnconfirmedBalance = newUnconfirmedBalance; cachedNumTransactions = newNumTransactions; @@ -179,4 +184,18 @@ TransactionTableModel *WalletModel::getTransactionTableModel() return transactionTableModel; } - +WalletModel::EncryptionStatus WalletModel::getEncryptionStatus() const +{ + if(!wallet->IsCrypted()) + { + return Unencrypted; + } + else if(wallet->IsLocked()) + { + return Locked; + } + else + { + return Unlocked; + } +} diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index bb1c6e85..a585f8d8 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -36,6 +36,13 @@ public: MiscError }; + enum EncryptionStatus + { + Unencrypted, // !wallet->IsCrypted() + Locked, // wallet->IsCrypted() && wallet->IsLocked() + Unlocked // wallet->IsCrypted() && !wallet->IsLocked() + }; + OptionsModel *getOptionsModel(); AddressTableModel *getAddressTableModel(); TransactionTableModel *getTransactionTableModel(); @@ -43,6 +50,9 @@ public: qint64 getBalance() const; qint64 getUnconfirmedBalance() const; int getNumTransactions() const; + EncryptionStatus getEncryptionStatus() const; + + bool isEncrypted() const; // Check address for validity bool validateAddress(const QString &address); @@ -74,10 +84,12 @@ private: qint64 cachedBalance; qint64 cachedUnconfirmedBalance; qint64 cachedNumTransactions; + EncryptionStatus cachedEncryptionStatus; signals: void balanceChanged(qint64 balance, qint64 unconfirmedBalance); void numTransactionsChanged(int count); + void encryptionStatusChanged(int status); // Asynchronous error notification void error(const QString &title, const QString &message);