diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index 770aa4a83..f21483759 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -121,6 +121,9 @@ CoinControlDialog::CoinControlDialog(QWidget *parent) : // (un)select all connect(ui->pushButtonSelectAll, SIGNAL(clicked()), this, SLOT(buttonSelectAllClicked())); + // Toggle lock state + connect(ui->pushButtonToggleLock, SIGNAL(clicked()), this, SLOT(buttonToggleLockClicked())); + // change coin control first column label due Qt4 bug. // see https://github.com/bitcoin/bitcoin/issues/5716 ui->treeWidget->headerItem()->setText(COLUMN_CHECKBOX, QString()); @@ -210,6 +213,40 @@ void CoinControlDialog::buttonSelectAllClicked() CoinControlDialog::updateLabels(model, this); } +// Toggle lock state +void CoinControlDialog::buttonToggleLockClicked() +{ + QTreeWidgetItem *item; + // Works in list-mode only + if(ui->radioListMode->isChecked()){ + ui->treeWidget->setEnabled(false); + for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++){ + item = ui->treeWidget->topLevelItem(i); + COutPoint outpt(uint256(item->text(COLUMN_TXHASH).toStdString()), item->text(COLUMN_VOUT_INDEX).toUInt()); + if (model->isLockedCoin(uint256(item->text(COLUMN_TXHASH).toStdString()), item->text(COLUMN_VOUT_INDEX).toUInt())){ + model->unlockCoin(outpt); + item->setDisabled(false); + item->setIcon(COLUMN_CHECKBOX, QIcon()); + } + else{ + model->lockCoin(outpt); + item->setDisabled(true); + item->setIcon(COLUMN_CHECKBOX, QIcon(":/icons/lock_closed")); + } + updateLabelLocked(); + } + ui->treeWidget->setEnabled(true); + CoinControlDialog::updateLabels(model, this); + } + else{ + QMessageBox msgBox; + msgBox.setObjectName("lockMessageBox"); + msgBox.setStyleSheet(GUIUtil::loadStyleSheet()); + msgBox.setText(tr("Please switch to \"List mode\" to use this function.")); + msgBox.exec(); + } +} + // context menu void CoinControlDialog::showMenu(const QPoint &point) { diff --git a/src/qt/coincontroldialog.h b/src/qt/coincontroldialog.h index 5a6ae0cdf..25c088762 100644 --- a/src/qt/coincontroldialog.h +++ b/src/qt/coincontroldialog.h @@ -122,6 +122,7 @@ private slots: void headerSectionClicked(int); void buttonBoxClicked(QAbstractButton*); void buttonSelectAllClicked(); + void buttonToggleLockClicked(); void updateLabelLocked(); }; diff --git a/src/qt/forms/coincontroldialog.ui b/src/qt/forms/coincontroldialog.ui index c78a2d20a..a80652c3c 100644 --- a/src/qt/forms/coincontroldialog.ui +++ b/src/qt/forms/coincontroldialog.ui @@ -348,7 +348,7 @@ - + 14 @@ -368,6 +368,22 @@ + + + + + 0 + 0 + + + + toggle lock state + + + false + + + diff --git a/src/qt/res/css/drkblue.css b/src/qt/res/css/drkblue.css index b711e1635..965ef42a3 100644 --- a/src/qt/res/css/drkblue.css +++ b/src/qt/res/css/drkblue.css @@ -1328,6 +1328,12 @@ padding-right:10px; min-height:25px; } +QDialog#CoinControlDialog .QFrame#frame .QPushButton#pushButtonToggleLock { /* Toggle lock state button */ +padding-left:10px; +padding-right:10px; +min-height:25px; +} + QDialog#CoinControlDialog .QDialogButtonBox#buttonBox QPushButton { /* Coin Control 'OK' button */ }