SpinSlider and ScrollSpinBox read-only support

PIVariantEdit - support for read-only for all types
PIValueTreeEdit - drop Parent grouping, default now Groups, full grouping control, global read-only support, fix new label error
This commit is contained in:
2023-04-28 19:51:22 +03:00
parent e7ef97dc6a
commit 46fd68a0fd
13 changed files with 102 additions and 27 deletions

View File

@@ -196,6 +196,7 @@ void PIVariantEditors::NumberBase::retranslate() {
void PIVariantEditors::NumberBase::applyAttributes(const PIVariantMap & a) {
bool ro = a.value(Attribute::readOnly, false).toBool();
Type new_type = static_cast<Type>(a.value(Attribute::widgetType).toEnum().selectedValue());
if (new_type == tInvalid) new_type = tSpinBox;
if (type != new_type) {
@@ -226,6 +227,7 @@ void PIVariantEditors::NumberBase::applyAttributes(const PIVariantMap & a) {
case tSpinBox: {
auto * w = qobject_cast<QDoubleSpinBox *>(widget);
if (!w) return;
w->setReadOnly(ro);
w->setPrefix(PIVariantEditorBase::vtTr(prefix));
w->setSuffix(PIVariantEditorBase::vtTr(suffix));
w->setRange(min, max);
@@ -235,6 +237,7 @@ void PIVariantEditors::NumberBase::applyAttributes(const PIVariantMap & a) {
case tSlider: {
auto * w = qobject_cast<QSlider *>(widget);
if (!w) return;
w->setEnabled(!ro);
w->setTickInterval(piRoundd(piMaxd(1., (max - min) / 100.)));
w->setRange(min, max);
w->setSingleStep(step);
@@ -242,6 +245,7 @@ void PIVariantEditors::NumberBase::applyAttributes(const PIVariantMap & a) {
case tSpinSlider: {
auto * w = qobject_cast<SpinSlider *>(widget);
if (!w) return;
w->setReadOnly(ro);
w->setPrefix(PIVariantEditorBase::vtTr(prefix));
w->setSuffix(PIVariantEditorBase::vtTr(suffix));
w->setMinimum(min);
@@ -252,6 +256,7 @@ void PIVariantEditors::NumberBase::applyAttributes(const PIVariantMap & a) {
case tEvalSpinBox: {
auto * w = qobject_cast<EvalSpinBox *>(widget);
if (!w) return;
w->setReadOnly(ro);
w->setSingleStep(step);
w->setPrecision(dec);
w->setExpression(PI2QString(a.value(Attribute::expression).toString()));
@@ -259,6 +264,7 @@ void PIVariantEditors::NumberBase::applyAttributes(const PIVariantMap & a) {
case tScrollSpinBox: {
auto * w = qobject_cast<ScrollSpinBox *>(widget);
if (!w) return;
w->setReadOnly(ro);
w->setMinimum(min);
w->setMaximum(max);
} break;
@@ -267,6 +273,13 @@ void PIVariantEditors::NumberBase::applyAttributes(const PIVariantMap & a) {
}
// PIVariantEditors::Bool
void PIVariantEditors::Bool::applyAttributes(const PIVariantMap & a) {
widget->setEnabled(!a.value(Attribute::readOnly, !widget->isEnabled()).toBool());
}
// PIVariantEditors::Int