-
Notifications
You must be signed in to change notification settings - Fork 716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Fix toggle lock button #2860
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK 6840431
Nice fix good idea to solve some stuff listed in issues
Wasn't quite happy with the idea of forcibly flipping UTXO lock states when switching from list view to tree view after the Here is a patch based on top of this PR's commit to do just that! Could possibly be further optimized, but feel free to use it/test it/change it as you see fit. Video: https://github.com/PIVX-Project/PIVX/assets/7393257/10530ba9-4e01-4dc4-bd72-7b9fe63a6d1e Patch: Index: src/qt/coincontroldialog.cpp
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp
--- a/src/qt/coincontroldialog.cpp (revision 6840431f9aa3e099b17bbbadd540252507b1daf6)
+++ b/src/qt/coincontroldialog.cpp (date 1683715642755)
@@ -228,27 +228,39 @@
updateLabels();
}
-void CoinControlDialog::toggleCoinLock()
+void CoinControlDialog::toggleItemLock(QTreeWidgetItem* item)
{
- QTreeWidgetItem* item;
- for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++) {
- item = ui->treeWidget->topLevelItem(i);
-
- COutPoint outpt(uint256S(item->text(COLUMN_TXHASH).toStdString()), item->text(COLUMN_VOUT_INDEX).toUInt());
- if (model->isLockedCoin(uint256S(item->text(COLUMN_TXHASH).toStdString()), item->text(COLUMN_VOUT_INDEX).toUInt())) {
- model->unlockCoin(outpt);
- item->setDisabled(false);
- // restore cold-stake snowflake icon for P2CS which were previously locked
- if (item->data(COLUMN_CHECKBOX, Qt::UserRole) == QString("Delegated"))
- item->setIcon(COLUMN_CHECKBOX, QIcon("://ic-check-cold-staking-off"));
- else
- item->setIcon(COLUMN_CHECKBOX, QIcon());
- } else {
- model->lockCoin(outpt);
- item->setDisabled(true);
- item->setIcon(COLUMN_CHECKBOX, QIcon(":/icons/lock_closed"));
- }
- updateLabelLocked();
+ COutPoint outpt(uint256S(item->text(COLUMN_TXHASH).toStdString()), item->text(COLUMN_VOUT_INDEX).toUInt());
+ if (model->isLockedCoin(uint256S(item->text(COLUMN_TXHASH).toStdString()), item->text(COLUMN_VOUT_INDEX).toUInt())) {
+ model->unlockCoin(outpt);
+ item->setDisabled(false);
+ // restore cold-stake snowflake icon for P2CS which were previously locked
+ if (item->data(COLUMN_CHECKBOX, Qt::UserRole) == QString("Delegated"))
+ item->setIcon(COLUMN_CHECKBOX, QIcon("://ic-check-cold-staking-off"));
+ else
+ item->setIcon(COLUMN_CHECKBOX, QIcon());
+ } else {
+ model->lockCoin(outpt);
+ item->setDisabled(true);
+ item->setIcon(COLUMN_CHECKBOX, QIcon(":/icons/lock_closed"));
+ }
+ updateLabelLocked();
+}
+
+void CoinControlDialog::toggleCoinLock()
+{
+ QTreeWidgetItem* item;
+ bool treemode = ui->treeWidget->rootIsDecorated();
+ for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++) {
+ item = ui->treeWidget->topLevelItem(i);
+ if (treemode) {
+ auto subItems = item->takeChildren();
+ for (auto j : subItems) {
+ toggleItemLock(j);
+ }
+ } else {
+ toggleItemLock(item);
+ }
}
}
@@ -261,19 +273,10 @@
}
// Works in list-mode only
- if (ui->radioListMode->isChecked()) {
- ui->treeWidget->setEnabled(false);
- toggleCoinLock();
- ui->treeWidget->setEnabled(true);
- updateLabels();
- } else {
- ui->pushButtonToggleLock->setChecked(false);
- QMessageBox msgBox;
- msgBox.setObjectName("lockMessageBox");
- msgBox.setStyleSheet(GUIUtil::loadStyleSheet());
- msgBox.setText(tr("Please switch to \"List mode\" to use this function."));
- msgBox.exec();
- }
+ ui->treeWidget->setEnabled(false);
+ toggleCoinLock();
+ ui->treeWidget->setEnabled(true);
+ updateView();
}
// context menu
@@ -441,13 +444,8 @@
// toggle tree mode
void CoinControlDialog::radioTreeMode(bool checked)
{
- if (checked && model) {
- if (ui->pushButtonToggleLock->isChecked() && fSelectTransparent) {
- ui->pushButtonToggleLock->setChecked(false);
- toggleCoinLock();
- }
+ if (checked && model)
updateView();
- }
}
// toggle list mode
Index: src/qt/coincontroldialog.h
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/qt/coincontroldialog.h b/src/qt/coincontroldialog.h
--- a/src/qt/coincontroldialog.h (revision 6840431f9aa3e099b17bbbadd540252507b1daf6)
+++ b/src/qt/coincontroldialog.h (date 1683714494344)
@@ -93,6 +93,7 @@
void updatePushButtonSelectAll(bool checked);
void sortView(int, Qt::SortOrder);
void inform(const QString& text);
+ void toggleItemLock(QTreeWidgetItem* item);
void toggleCoinLock();
// Load a row with coin's data
|
patch applied and rebased! Having the functionality available also on tree mode is surely a better solution |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK f0f58b9
there is a leftover stale comment about only working in list mode (my fault, didn't remove it from my diff patch), but that is of little concern right now. would rather merge as-is and eventually do a cleanup later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK f0f58b9
This PR solves issue #2159
The Lock functionality has been extended to tree mode view
(See the picture)