Browse Source

[Qt] add HD enabled/disabled icon to the status bar

0.14
Jonas Schnelli 8 years ago
parent
commit
914154f0cc
No known key found for this signature in database
GPG Key ID: 29D4BCB6416F53EC
  1. 4
      contrib/debian/copyright
  2. 6
      src/Makefile.qt.include
  3. 2
      src/qt/bitcoin.qrc
  4. 32
      src/qt/bitcoingui.cpp
  5. 9
      src/qt/bitcoingui.h
  6. BIN
      src/qt/res/icons/hd_disabled.png
  7. BIN
      src/qt/res/icons/hd_enabled.png
  8. 26
      src/qt/res/src/hd_disabled.svg
  9. 13
      src/qt/res/src/hd_enabled.svg
  10. 5
      src/qt/walletmodel.cpp
  11. 2
      src/qt/walletmodel.h
  12. 6
      src/qt/walletview.cpp
  13. 2
      src/qt/walletview.h
  14. 15
      src/wallet/wallet.cpp
  15. 3
      src/wallet/wallet.h

4
contrib/debian/copyright vendored

@ -59,6 +59,10 @@ Files: src/qt/res/icons/tx_mined.png
src/qt/res/src/mine.svg src/qt/res/src/mine.svg
src/qt/res/icons/fontbigger.png src/qt/res/icons/fontbigger.png
src/qt/res/icons/fontsmaller.png src/qt/res/icons/fontsmaller.png
src/qt/res/icons/hd_disabled.png
src/qt/res/src/hd_disabled.svg
src/qt/res/icons/hd_enabled.png
src/qt/res/src/hd_enabled.svg
Copyright: Jonas Schnelli Copyright: Jonas Schnelli
License: Expat License: Expat
Comment: Comment:

6
src/Makefile.qt.include

@ -257,6 +257,8 @@ RES_ICONS = \
qt/res/icons/filesave.png \ qt/res/icons/filesave.png \
qt/res/icons/fontbigger.png \ qt/res/icons/fontbigger.png \
qt/res/icons/fontsmaller.png \ qt/res/icons/fontsmaller.png \
qt/res/icons/hd_disabled.png \
qt/res/icons/hd_enabled.png \
qt/res/icons/history.png \ qt/res/icons/history.png \
qt/res/icons/info.png \ qt/res/icons/info.png \
qt/res/icons/key.png \ qt/res/icons/key.png \
@ -271,14 +273,14 @@ RES_ICONS = \
qt/res/icons/synced.png \ qt/res/icons/synced.png \
qt/res/icons/transaction0.png \ qt/res/icons/transaction0.png \
qt/res/icons/transaction2.png \ qt/res/icons/transaction2.png \
qt/res/icons/transaction_abandoned.png \
qt/res/icons/transaction_conflicted.png \ qt/res/icons/transaction_conflicted.png \
qt/res/icons/tx_inout.png \ qt/res/icons/tx_inout.png \
qt/res/icons/tx_input.png \ qt/res/icons/tx_input.png \
qt/res/icons/tx_output.png \ qt/res/icons/tx_output.png \
qt/res/icons/tx_mined.png \ qt/res/icons/tx_mined.png \
qt/res/icons/warning.png \ qt/res/icons/warning.png \
qt/res/icons/verify.png \ qt/res/icons/verify.png
qt/res/icons/transaction_abandoned.png
BITCOIN_QT_CPP = \ BITCOIN_QT_CPP = \
qt/bantablemodel.cpp \ qt/bantablemodel.cpp \

2
src/qt/bitcoin.qrc

@ -50,6 +50,8 @@
<file alias="fontsmaller">res/icons/fontsmaller.png</file> <file alias="fontsmaller">res/icons/fontsmaller.png</file>
<file alias="prompticon">res/icons/chevron.png</file> <file alias="prompticon">res/icons/chevron.png</file>
<file alias="transaction_abandoned">res/icons/transaction_abandoned.png</file> <file alias="transaction_abandoned">res/icons/transaction_abandoned.png</file>
<file alias="hd_enabled">res/icons/hd_enabled.png</file>
<file alias="hd_disabled">res/icons/hd_disabled.png</file>
</qresource> </qresource>
<qresource prefix="/movies"> <qresource prefix="/movies">
<file alias="spinner-000">res/movies/spinner-000.png</file> <file alias="spinner-000">res/movies/spinner-000.png</file>

32
src/qt/bitcoingui.cpp

@ -80,7 +80,8 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *platformStyle, const NetworkStyle *n
clientModel(0), clientModel(0),
walletFrame(0), walletFrame(0),
unitDisplayControl(0), unitDisplayControl(0),
labelEncryptionIcon(0), labelWalletEncryptionIcon(0),
labelWalletHDStatusIcon(0),
labelConnectionsIcon(0), labelConnectionsIcon(0),
labelBlocksIcon(0), labelBlocksIcon(0),
progressBarLabel(0), progressBarLabel(0),
@ -194,7 +195,8 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *platformStyle, const NetworkStyle *n
frameBlocksLayout->setContentsMargins(3,0,3,0); frameBlocksLayout->setContentsMargins(3,0,3,0);
frameBlocksLayout->setSpacing(3); frameBlocksLayout->setSpacing(3);
unitDisplayControl = new UnitDisplayStatusBarControl(platformStyle); unitDisplayControl = new UnitDisplayStatusBarControl(platformStyle);
labelEncryptionIcon = new QLabel(); labelWalletEncryptionIcon = new QLabel();
labelWalletHDStatusIcon = new QLabel();
labelConnectionsIcon = new QLabel(); labelConnectionsIcon = new QLabel();
labelBlocksIcon = new QLabel(); labelBlocksIcon = new QLabel();
if(enableWallet) if(enableWallet)
@ -202,7 +204,8 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *platformStyle, const NetworkStyle *n
frameBlocksLayout->addStretch(); frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(unitDisplayControl); frameBlocksLayout->addWidget(unitDisplayControl);
frameBlocksLayout->addStretch(); frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(labelEncryptionIcon); frameBlocksLayout->addWidget(labelWalletEncryptionIcon);
frameBlocksLayout->addWidget(labelWalletHDStatusIcon);
} }
frameBlocksLayout->addStretch(); frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(labelConnectionsIcon); frameBlocksLayout->addWidget(labelConnectionsIcon);
@ -988,28 +991,37 @@ bool BitcoinGUI::handlePaymentRequest(const SendCoinsRecipient& recipient)
return false; return false;
} }
void BitcoinGUI::setHDStatus(int hdEnabled)
{
labelWalletHDStatusIcon->setPixmap(platformStyle->SingleColorIcon(hdEnabled ? ":/icons/hd_enabled" : ":/icons/hd_disabled").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
labelWalletHDStatusIcon->setToolTip(hdEnabled ? tr("HD key generation is <b>enabled</b>") : tr("HD key generation is <b>disabled</b>"));
// eventually disable the QLabel to set its opacity to 50%
labelWalletHDStatusIcon->setEnabled(hdEnabled);
}
void BitcoinGUI::setEncryptionStatus(int status) void BitcoinGUI::setEncryptionStatus(int status)
{ {
switch(status) switch(status)
{ {
case WalletModel::Unencrypted: case WalletModel::Unencrypted:
labelEncryptionIcon->hide(); labelWalletEncryptionIcon->hide();
encryptWalletAction->setChecked(false); encryptWalletAction->setChecked(false);
changePassphraseAction->setEnabled(false); changePassphraseAction->setEnabled(false);
encryptWalletAction->setEnabled(true); encryptWalletAction->setEnabled(true);
break; break;
case WalletModel::Unlocked: case WalletModel::Unlocked:
labelEncryptionIcon->show(); labelWalletEncryptionIcon->show();
labelEncryptionIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); labelWalletEncryptionIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>")); labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
encryptWalletAction->setChecked(true); encryptWalletAction->setChecked(true);
changePassphraseAction->setEnabled(true); changePassphraseAction->setEnabled(true);
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
break; break;
case WalletModel::Locked: case WalletModel::Locked:
labelEncryptionIcon->show(); labelWalletEncryptionIcon->show();
labelEncryptionIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/lock_closed").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); labelWalletEncryptionIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/lock_closed").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>locked</b>")); labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>locked</b>"));
encryptWalletAction->setChecked(true); encryptWalletAction->setChecked(true);
changePassphraseAction->setEnabled(true); changePassphraseAction->setEnabled(true);
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported

9
src/qt/bitcoingui.h

@ -82,7 +82,8 @@ private:
WalletFrame *walletFrame; WalletFrame *walletFrame;
UnitDisplayStatusBarControl *unitDisplayControl; UnitDisplayStatusBarControl *unitDisplayControl;
QLabel *labelEncryptionIcon; QLabel *labelWalletEncryptionIcon;
QLabel *labelWalletHDStatusIcon;
QLabel *labelConnectionsIcon; QLabel *labelConnectionsIcon;
QLabel *labelBlocksIcon; QLabel *labelBlocksIcon;
QLabel *progressBarLabel; QLabel *progressBarLabel;
@ -169,6 +170,12 @@ public Q_SLOTS:
*/ */
void setEncryptionStatus(int status); void setEncryptionStatus(int status);
/** Set the hd-enabled status as shown in the UI.
@param[in] status current hd enabled status
@see WalletModel::EncryptionStatus
*/
void setHDStatus(int hdEnabled);
bool handlePaymentRequest(const SendCoinsRecipient& recipient); bool handlePaymentRequest(const SendCoinsRecipient& recipient);
/** Show incoming transaction notification for new transactions. */ /** Show incoming transaction notification for new transactions. */

BIN
src/qt/res/icons/hd_disabled.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
src/qt/res/icons/hd_enabled.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

26
src/qt/res/src/hd_disabled.svg

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 595.3 841.9" enable-background="new 0 0 595.3 841.9" xml:space="preserve">
<g>
<path d="M81.3,336.5v66.8h70.4v-66.8H190v174h-38.3v-75.1H81.3v75.1H43v-174H81.3z"/>
<path d="M298.7,336.5c11.2,0,21.6,1.8,31.3,5.4c9.7,3.6,18,8.9,25.1,16.1c7.1,7.2,12.6,16.1,16.6,26.8c4,10.7,6,23.3,6,37.8
c0,12.7-1.6,24.4-4.9,35.1c-3.3,10.7-8.2,20-14.7,27.8c-6.6,7.8-14.8,13.9-24.6,18.4c-9.8,4.5-21.4,6.7-34.7,6.7h-75.1v-174H298.7z
M296,478.3c5.5,0,10.9-0.9,16.1-2.7c5.2-1.8,9.8-4.8,13.9-8.9c4.1-4.1,7.3-9.5,9.7-16.2c2.4-6.7,3.7-14.8,3.7-24.4
c0-8.8-0.9-16.7-2.6-23.8s-4.5-13.1-8.4-18.2c-3.9-5-9.1-8.9-15.5-11.6c-6.4-2.7-14.3-4-23.8-4h-27.3v109.7H296z"/>
</g>
<g>
<g>
<line x1="32" y1="555.9" x2="358" y2="293.9"/>
</g>
<g>
<path fill="#FFFFFF" d="M32,580.9c-7.3,0-14.6-3.2-19.5-9.3c-8.6-10.8-6.9-26.5,3.8-35.1l326-262c10.8-8.6,26.5-6.9,35.1,3.8
c8.6,10.8,6.9,26.5-3.8,35.1l-326,262C43,579.1,37.5,580.9,32,580.9z"/>
</g>
<g>
<path d="M32,573.9c-5.3,0-10.5-2.3-14-6.7c-6.2-7.7-5-19.1,2.8-25.3l326-262c7.8-6.2,19.1-5,25.3,2.8c6.2,7.7,5,19.1-2.8,25.3
l-326,262C40,572.6,36,573.9,32,573.9z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

13
src/qt/res/src/hd_enabled.svg

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 595.3 841.9" enable-background="new 0 0 595.3 841.9" xml:space="preserve">
<g>
<path d="M81.3,336.5v66.8h70.4v-66.8H190v174h-38.3v-75.1H81.3v75.1H43v-174H81.3z"/>
<path d="M298.7,336.5c11.2,0,21.6,1.8,31.3,5.4c9.7,3.6,18,8.9,25.1,16.1c7.1,7.2,12.6,16.1,16.6,26.8c4,10.7,6,23.3,6,37.8
c0,12.7-1.6,24.4-4.9,35.1c-3.3,10.7-8.2,20-14.7,27.8c-6.6,7.8-14.8,13.9-24.6,18.4c-9.8,4.5-21.4,6.7-34.7,6.7h-75.1v-174H298.7z
M296,478.3c5.5,0,10.9-0.9,16.1-2.7c5.2-1.8,9.8-4.8,13.9-8.9c4.1-4.1,7.3-9.5,9.7-16.2c2.4-6.7,3.7-14.8,3.7-24.4
c0-8.8-0.9-16.7-2.6-23.8s-4.5-13.1-8.4-18.2c-3.9-5-9.1-8.9-15.5-11.6c-6.4-2.7-14.3-4-23.8-4h-27.3v109.7H296z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

5
src/qt/walletmodel.cpp

@ -683,3 +683,8 @@ bool WalletModel::abandonTransaction(uint256 hash) const
LOCK2(cs_main, wallet->cs_wallet); LOCK2(cs_main, wallet->cs_wallet);
return wallet->AbandonTransaction(hash); return wallet->AbandonTransaction(hash);
} }
bool WalletModel::hdEnabled() const
{
return wallet->IsHDEnabled();
}

2
src/qt/walletmodel.h

@ -203,6 +203,8 @@ public:
bool transactionCanBeAbandoned(uint256 hash) const; bool transactionCanBeAbandoned(uint256 hash) const;
bool abandonTransaction(uint256 hash) const; bool abandonTransaction(uint256 hash) const;
bool hdEnabled() const;
private: private:
CWallet *wallet; CWallet *wallet;
bool fHaveWatchOnly; bool fHaveWatchOnly;

6
src/qt/walletview.cpp

@ -98,6 +98,9 @@ void WalletView::setBitcoinGUI(BitcoinGUI *gui)
// Pass through transaction notifications // Pass through transaction notifications
connect(this, SIGNAL(incomingTransaction(QString,int,CAmount,QString,QString,QString)), gui, SLOT(incomingTransaction(QString,int,CAmount,QString,QString,QString))); connect(this, SIGNAL(incomingTransaction(QString,int,CAmount,QString,QString,QString)), gui, SLOT(incomingTransaction(QString,int,CAmount,QString,QString,QString)));
// Connect HD enabled state signal
connect(this, SIGNAL(hdEnabledStatusChanged(int)), gui, SLOT(setHDStatus(int)));
} }
} }
@ -130,6 +133,9 @@ void WalletView::setWalletModel(WalletModel *walletModel)
connect(walletModel, SIGNAL(encryptionStatusChanged(int)), this, SIGNAL(encryptionStatusChanged(int))); connect(walletModel, SIGNAL(encryptionStatusChanged(int)), this, SIGNAL(encryptionStatusChanged(int)));
updateEncryptionStatus(); updateEncryptionStatus();
// update HD status
Q_EMIT hdEnabledStatusChanged(walletModel->hdEnabled());
// Balloon pop-up for new transaction // Balloon pop-up for new transaction
connect(walletModel->getTransactionTableModel(), SIGNAL(rowsInserted(QModelIndex,int,int)), connect(walletModel->getTransactionTableModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
this, SLOT(processNewTransaction(QModelIndex,int,int))); this, SLOT(processNewTransaction(QModelIndex,int,int)));

2
src/qt/walletview.h

@ -117,6 +117,8 @@ Q_SIGNALS:
void message(const QString &title, const QString &message, unsigned int style); void message(const QString &title, const QString &message, unsigned int style);
/** Encryption status of wallet changed */ /** Encryption status of wallet changed */
void encryptionStatusChanged(int status); void encryptionStatusChanged(int status);
/** HD-Enabled status of wallet changed (only possible during startup) */
void hdEnabledStatusChanged(int hdEnabled);
/** Notify that a new transaction appeared */ /** Notify that a new transaction appeared */
void incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label); void incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label);
}; };

15
src/wallet/wallet.cpp

@ -98,7 +98,7 @@ CPubKey CWallet::GenerateNewKey()
CKeyMetadata metadata(nCreationTime); CKeyMetadata metadata(nCreationTime);
// use HD key derivation if HD was enabled during wallet creation // use HD key derivation if HD was enabled during wallet creation
if (!hdChain.masterKeyID.IsNull()) { if (IsHDEnabled()) {
// for now we use a fixed keypath scheme of m/0'/0'/k // for now we use a fixed keypath scheme of m/0'/0'/k
CKey key; //master key seed (256bit) CKey key; //master key seed (256bit)
CExtKey masterKey; //hd master key CExtKey masterKey; //hd master key
@ -628,7 +628,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
Unlock(strWalletPassphrase); Unlock(strWalletPassphrase);
// if we are using HD, replace the HD master key (seed) with a new one // if we are using HD, replace the HD master key (seed) with a new one
if (!hdChain.masterKeyID.IsNull()) { if (IsHDEnabled()) {
CKey key; CKey key;
CPubKey masterPubKey = GenerateNewHDMasterKey(); CPubKey masterPubKey = GenerateNewHDMasterKey();
if (!SetHDMasterKey(masterPubKey)) if (!SetHDMasterKey(masterPubKey))
@ -1233,6 +1233,11 @@ bool CWallet::SetHDChain(const CHDChain& chain, bool memonly)
return true; return true;
} }
bool CWallet::IsHDEnabled()
{
return !hdChain.masterKeyID.IsNull();
}
int64_t CWalletTx::GetTxTime() const int64_t CWalletTx::GetTxTime() const
{ {
int64_t n = nTimeSmart; int64_t n = nTimeSmart;
@ -3322,7 +3327,7 @@ bool CWallet::InitLoadWallet()
if (fFirstRun) if (fFirstRun)
{ {
// Create new keyUser and set as default key // Create new keyUser and set as default key
if (GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET) && walletInstance->hdChain.masterKeyID.IsNull()) { if (GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET) && !walletInstance->IsHDEnabled()) {
// generate a new master key // generate a new master key
CKey key; CKey key;
CPubKey masterPubKey = walletInstance->GenerateNewHDMasterKey(); CPubKey masterPubKey = walletInstance->GenerateNewHDMasterKey();
@ -3340,9 +3345,9 @@ bool CWallet::InitLoadWallet()
} }
else if (mapArgs.count("-usehd")) { else if (mapArgs.count("-usehd")) {
bool useHD = GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET); bool useHD = GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET);
if (!walletInstance->hdChain.masterKeyID.IsNull() && !useHD) if (walletInstance->IsHDEnabled() && !useHD)
return InitError(strprintf(_("Error loading %s: You can't disable HD on a already existing HD wallet"), walletFile)); return InitError(strprintf(_("Error loading %s: You can't disable HD on a already existing HD wallet"), walletFile));
if (walletInstance->hdChain.masterKeyID.IsNull() && useHD) if (!walletInstance->IsHDEnabled() && useHD)
return InitError(strprintf(_("Error loading %s: You can't enable HD on a already existing non-HD wallet"), walletFile)); return InitError(strprintf(_("Error loading %s: You can't enable HD on a already existing non-HD wallet"), walletFile));
} }

3
src/wallet/wallet.h

@ -902,6 +902,9 @@ public:
bool SetHDChain(const CHDChain& chain, bool memonly); bool SetHDChain(const CHDChain& chain, bool memonly);
const CHDChain& GetHDChain() { return hdChain; } const CHDChain& GetHDChain() { return hdChain; }
/* Returns true if HD is enabled */
bool IsHDEnabled();
/* Generates a new HD master key (will not be activated) */ /* Generates a new HD master key (will not be activated) */
CPubKey GenerateNewHDMasterKey(); CPubKey GenerateNewHDMasterKey();

Loading…
Cancel
Save