mirror of
https://github.com/Lurkki14/tuxclocker.git
synced 2025-02-25 18:55:24 -06:00
qt: add checkbox for selecting if value should be applied
This commit is contained in:
parent
825e448589
commit
b09f5e3848
@ -84,10 +84,18 @@ QStandardItem *DeviceModel::createAssignable(TC::TreeNode<TCDBus::DeviceNode> no
|
||||
|
||||
connect(ifaceItem, &AssignableItem::assignableDataChanged,
|
||||
[=](QVariant v) {
|
||||
// Only show checkbox when value has been changed
|
||||
ifaceItem->setCheckable(true);
|
||||
ifaceItem->setCheckState(Qt::Checked);
|
||||
proxy->setValue(v);
|
||||
ifaceItem->setData(unappliedColor(), Qt::BackgroundRole);
|
||||
});
|
||||
|
||||
connect(ifaceItem, &AssignableItem::committalChanged, [=](bool on) {
|
||||
QVariant colorData = (on) ? unappliedColor() : QVariant();
|
||||
ifaceItem->setData(colorData, Qt::BackgroundRole);
|
||||
});
|
||||
|
||||
connect(proxy, &AssignableProxy::applied, [=](auto err) {
|
||||
// Fade out result color
|
||||
auto startColor = (err.has_value()) ? errorColor()
|
||||
@ -112,7 +120,14 @@ QStandardItem *DeviceModel::createAssignable(TC::TreeNode<TCDBus::DeviceNode> no
|
||||
});
|
||||
|
||||
connect(this, &DeviceModel::changesApplied, [=] {
|
||||
proxy->apply();
|
||||
// Don't apply if unchecked
|
||||
if (ifaceItem->checkState() == Qt::Checked) {
|
||||
ifaceItem->setCheckState(Qt::Unchecked);
|
||||
ifaceItem->setCheckable(false);
|
||||
// What the fuck do I need to this for?
|
||||
ifaceItem->setData(QVariant(), Qt::CheckStateRole);
|
||||
proxy->apply();
|
||||
}
|
||||
});
|
||||
return ifaceItem;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user