UI: button to toggle lock-state for all inputs in coin-control dialog

This commit is contained in:
crowning- 2015-08-30 23:40:04 +02:00
parent 2c14877c6e
commit aeb9a7d5ea
4 changed files with 60 additions and 1 deletions

View File

@ -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,39 @@ 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.setText(tr("Please switch to \"List mode\" to use this."));
msgBox.exec();
}
}
// context menu
void CoinControlDialog::showMenu(const QPoint &point)
{

View File

@ -122,6 +122,7 @@ private slots:
void headerSectionClicked(int);
void buttonBoxClicked(QAbstractButton*);
void buttonSelectAllClicked();
void buttonToggleLockClicked();
void updateLabelLocked();
};

View File

@ -348,7 +348,7 @@
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayoutPanel" stretch="0,0,0,0,0">
<layout class="QHBoxLayout" name="horizontalLayoutPanel" stretch="0,0,0,0,0,0">
<property name="spacing">
<number>14</number>
</property>
@ -368,6 +368,22 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonToggleLock">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>toggle lock state</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioTreeMode">
<property name="sizePolicy">

View File

@ -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 */
}