34 if (json_object_object_get_ex(originalDetails,
"isDark", &o))
35 isDark = json_object_get_boolean(o);
38 dialog.setFont(getDefaultFont());
43 QPoint topLeftMargin = QPoint(margin.left(),margin.top());
44 foreach (QObject *widget, dialog.children())
45 static_cast<QWidget *
>(widget)->move(
static_cast<QWidget *
>(widget)->pos() + topLeftMargin);
48 dialog.resize(margin.left() + dialog.childrenRect().width() + margin.right(), margin.top() + dialog.childrenRect().height() + margin.bottom());
51 QPoint dialogTopLeft = portLeftCenter - QPoint(dialog.width() - margin.right(), dialog.height()/2.);
52 dialog.move(dialogTopLeft);
57 return (dialog.result() == QDialog::Accepted ?
getAcceptedValue() : originalDetails);
66 const int decimalPrecision = 6;
68 QValidator *validator = ((this->type->
getModuleKey() ==
"VuoReal")?
69 static_cast<QValidator *
>(
new QDoubleValidator(NULL)) :
70 static_cast<QValidator *
>(
new QIntValidator(NULL)));
80 json_object_object_get_ex(originalDetails,
"suggestedMin", &suggestedMinValue);
83 json_object_object_get_ex(originalDetails,
"suggestedMax", &suggestedMaxValue);
86 json_object_object_get_ex(originalDetails,
"suggestedStep", &suggestedStepValue);
90 const int widgetVerticalSpacing = 10;
91 const int widgetHorizontalSpacing = 8;
93 labelForDetail[suggestedMin] =
new QLabel(&dialog);
94 labelForDetail[suggestedMin]->setText(tr(
"Suggested Min"));
95 labelForDetail[suggestedMin]->adjustSize();
97 labelForDetail[suggestedMax] =
new QLabel(&dialog);
98 labelForDetail[suggestedMax]->setText(tr(
"Suggested Max"));
99 labelForDetail[suggestedMax]->adjustSize();
101 labelForDetail[suggestedStep] =
new QLabel(&dialog);
102 labelForDetail[suggestedStep]->setText(tr(
"Suggested Step"));
103 labelForDetail[suggestedStep]->adjustSize();
105 if (
dynamic_cast<QDoubleValidator *
>(validator))
106 static_cast<QDoubleValidator *
>(validator)->setDecimals(decimalPrecision);
109 lineEditForDetail[suggestedMin] =
new QLineEdit(&dialog);
110 setUpLineEdit(lineEditForDetail[suggestedMin], suggestedMinValue);
111 lineEditForDetail[suggestedMin]->setValidator(validator);
114 lineEditForDetail[suggestedMax] =
new QLineEdit(&dialog);
115 setUpLineEdit(lineEditForDetail[suggestedMax], suggestedMaxValue);
116 lineEditForDetail[suggestedMax]->setValidator(validator);
119 lineEditForDetail[suggestedStep] =
new QLineEdit(&dialog);
120 setUpLineEdit(lineEditForDetail[suggestedStep], suggestedStepValue);
121 lineEditForDetail[suggestedStep]->setValidator(validator);
123 lineEditForDetail[suggestedMin]->move(labelForDetail[suggestedMin]->pos().x()+labelForDetail[suggestedMin]->width()+2*widgetHorizontalSpacing, lineEditForDetail[suggestedMin]->pos().y());
124 labelForDetail[suggestedMin]->show();
126 labelForDetail[suggestedMax]->move(0, labelForDetail[suggestedMin]->pos().y() + labelForDetail[suggestedMin]->height() + widgetVerticalSpacing);
127 lineEditForDetail[suggestedMax]->move(labelForDetail[suggestedMin]->pos().x()+labelForDetail[suggestedMin]->width()+2*widgetHorizontalSpacing, labelForDetail[suggestedMin]->pos().y() + labelForDetail[suggestedMin]->height() + widgetVerticalSpacing);
128 labelForDetail[suggestedMax]->show();
130 labelForDetail[suggestedStep]->move(0, labelForDetail[suggestedMax]->pos().y() + labelForDetail[suggestedMax]->height() + widgetVerticalSpacing);
131 lineEditForDetail[suggestedStep]->move(labelForDetail[suggestedMin]->pos().x()+labelForDetail[suggestedMin]->width()+2*widgetHorizontalSpacing, labelForDetail[suggestedMax]->pos().y() + labelForDetail[suggestedMax]->height() + widgetVerticalSpacing);
132 labelForDetail[suggestedStep]->show();
137 lineEditForDetail[suggestedMin]->setFocus();
138 lineEditForDetail[suggestedMin]->selectAll();
150 lineEdit->setFocus();
151 lineEdit->selectAll();
153 lineEdit->adjustSize();
162 lineEditForDetail[suggestedMax]->text(),
163 lineEditForDetail[suggestedStep]->text());
174 QString valueAsStringInDefaultLocale = json_object_to_json_string_ext(value, JSON_C_TO_STRING_PLAIN);
175 double realValue = ((this->type->
getModuleKey() ==
"VuoReal")?
176 QLocale(QLocale::C).toDouble(valueAsStringInDefaultLocale) :
177 QLocale(QLocale::C).toInt(valueAsStringInDefaultLocale));
178 QString valueAsStringInUserLocale = QLocale::system().toString(realValue);
180 if (qAbs(realValue) >= 1000.0)
181 valueAsStringInUserLocale.remove(QLocale::system().groupSeparator());
183 return valueAsStringInUserLocale;
190 const QString &suggestedMaxValueAsString,
191 const QString &suggestedStepValueAsString)
194 double suggestedMinValue = ((this->type->
getModuleKey() ==
"VuoReal")?
195 QLocale::system().toDouble(suggestedMinValueAsString) :
196 QLocale::system().toInt(suggestedMinValueAsString));
197 QString suggestedMinValueAsStringInDefaultLocale = QLocale(QLocale::C).toString(suggestedMinValue);
199 if (qAbs(suggestedMinValue) >= 1000.0)
200 suggestedMinValueAsStringInDefaultLocale.remove(QLocale(QLocale::C).groupSeparator());
202 if (! suggestedMinValueAsStringInDefaultLocale.isEmpty() && suggestedMinValueAsStringInDefaultLocale[0] ==
'.')
203 suggestedMinValueAsStringInDefaultLocale =
"0" + suggestedMinValueAsStringInDefaultLocale;
206 double suggestedMaxValue = ((this->type->
getModuleKey() ==
"VuoReal")?
207 QLocale::system().toDouble(suggestedMaxValueAsString) :
208 QLocale::system().toInt(suggestedMaxValueAsString));
209 QString suggestedMaxValueAsStringInDefaultLocale = QLocale(QLocale::C).toString(suggestedMaxValue);
211 if (qAbs(suggestedMaxValue) >= 1000.0)
212 suggestedMaxValueAsStringInDefaultLocale.remove(QLocale(QLocale::C).groupSeparator());
214 if (! suggestedMaxValueAsStringInDefaultLocale.isEmpty() && suggestedMaxValueAsStringInDefaultLocale[0] ==
'.')
215 suggestedMaxValueAsStringInDefaultLocale =
"0" + suggestedMaxValueAsStringInDefaultLocale;
218 double suggestedStepValue = ((this->type->
getModuleKey() ==
"VuoReal")?
219 QLocale::system().toDouble(suggestedStepValueAsString) :
220 QLocale::system().toInt(suggestedStepValueAsString));
221 QString suggestedStepValueAsStringInDefaultLocale = QLocale(QLocale::C).toString(suggestedStepValue);
223 if (qAbs(suggestedStepValue) >= 1000.0)
224 suggestedStepValueAsStringInDefaultLocale.remove(QLocale(QLocale::C).groupSeparator());
226 if (! suggestedStepValueAsStringInDefaultLocale.isEmpty() && suggestedStepValueAsStringInDefaultLocale[0] ==
'.')
227 suggestedStepValueAsStringInDefaultLocale =
"0" + suggestedStepValueAsStringInDefaultLocale;
230 struct json_object *details = json_object_new_object();
234 if (!suggestedMinValueAsString.isEmpty())
237 if (!suggestedMaxValueAsString.isEmpty())
240 if (!suggestedStepValueAsString.isEmpty())
245 if (!suggestedMinValueAsString.isEmpty())
248 if (!suggestedMaxValueAsString.isEmpty())
251 if (!suggestedStepValueAsString.isEmpty())
261 QFont VuoDetailsEditorNumeric::getDefaultFont(
void)