|
@@ -840,6 +840,41 @@ void setQLayoutItemProperties(QScriptValue, QScriptEngine *)
|
840
|
840
|
/* Nothing needs to be done here. */
|
841
|
841
|
}
|
842
|
842
|
|
|
843
|
+@* Timers.
|
|
844
|
+
|
|
845
|
+\noindent Some features in Typica require access to functionality similar to
|
|
846
|
+what |QTimer| provides from the host environment. This includes allowing
|
|
847
|
+script devices to periodically poll connected hardware and allowing a safety
|
|
848
|
+delay on profile translation.
|
|
849
|
+
|
|
850
|
+<@Function prototypes for scripting@>=
|
|
851
|
+void setQTimerProperties(QScriptValue value, QScriptEngine *engine);
|
|
852
|
+QScriptValue constructQTimer(QScriptContext *context, QScriptEngine *engine);
|
|
853
|
+
|
|
854
|
+@ The host environment is informed of the constructor.
|
|
855
|
+
|
|
856
|
+@<Set up the scripting engine@>=
|
|
857
|
+constructor = engine->newFunction(constructQTimer);
|
|
858
|
+value = engine->newQMetaObject(&QTimer::staticMetaObject, constructor);
|
|
859
|
+engine->globalObject().setProperty("Timer", value);
|
|
860
|
+
|
|
861
|
+@ Everything that we are interested in here is a signal, slot, or property so
|
|
862
|
+there is little else to do.
|
|
863
|
+
|
|
864
|
+@<Functions for scripting@>=
|
|
865
|
+void setQTimerProperties(QScriptValue value, QScriptEngine *engine)
|
|
866
|
+{
|
|
867
|
+ setQObjectProperties(value, engine);
|
|
868
|
+}
|
|
869
|
+
|
|
870
|
+QScriptValue constructQTimer(QScriptContext *, QScriptEngine *engine)
|
|
871
|
+{
|
|
872
|
+ QScriptValue object = engine->newQObject(new QTimer);
|
|
873
|
+ setQTimerProperties(object, engine);
|
|
874
|
+ return object;
|
|
875
|
+}
|
|
876
|
+
|
|
877
|
+
|
843
|
878
|
@* Scripting QWidget.
|
844
|
879
|
|
845
|
880
|
\noindent The first interesting class in this hierarchy is |QWidget|. This is
|
|
@@ -19917,9 +19952,11 @@ class TranslationConfWidget : public BasicDeviceConfigurationWidget
|
19917
|
19952
|
@[private slots@]:@/
|
19918
|
19953
|
void updateMatchingColumn(const QString &column);
|
19919
|
19954
|
void updateTemperature();
|
|
19955
|
+ void updateDelay();
|
19920
|
19956
|
private:@/
|
19921
|
19957
|
QDoubleSpinBox *temperatureValue;
|
19922
|
19958
|
QComboBox *unitSelector;
|
|
19959
|
+ QSpinBox *delaySelector;
|
19923
|
19960
|
};
|
19924
|
19961
|
|
19925
|
19962
|
@ The constructor sets up our user interface.
|
|
@@ -19927,7 +19964,8 @@ class TranslationConfWidget : public BasicDeviceConfigurationWidget
|
19927
|
19964
|
@<TranslationConfWidget implementation@>=
|
19928
|
19965
|
TranslationConfWidget::TranslationConfWidget(DeviceTreeModel *model, const QModelIndex &index)
|
19929
|
19966
|
: BasicDeviceConfigurationWidget(model, index),
|
19930
|
|
- temperatureValue(new QDoubleSpinBox), unitSelector(new QComboBox)
|
|
19967
|
+ temperatureValue(new QDoubleSpinBox), unitSelector(new QComboBox),
|
|
19968
|
+ delaySelector(new QSpinBox)
|
19931
|
19969
|
{
|
19932
|
19970
|
unitSelector->addItem("Fahrenheit");
|
19933
|
19971
|
unitSelector->addItem("Celsius");
|
|
@@ -19938,6 +19976,7 @@ TranslationConfWidget::TranslationConfWidget(DeviceTreeModel *model, const QMode
|
19938
|
19976
|
layout->addRow(tr("Column to match:"), column);
|
19939
|
19977
|
layout->addRow(tr("Unit:"), unitSelector);
|
19940
|
19978
|
layout->addRow(tr("Value:"), temperatureValue);
|
|
19979
|
+ layout->addRow(tr("Start of batch safety delay:"), delaySelector);
|
19941
|
19980
|
@<Get device configuration data for current node@>@;
|
19942
|
19981
|
for(int i = 0; i < configData.size(); i++)
|
19943
|
19982
|
{
|
|
@@ -19954,12 +19993,18 @@ TranslationConfWidget::TranslationConfWidget(DeviceTreeModel *model, const QMode
|
19954
|
19993
|
{
|
19955
|
19994
|
temperatureValue->setValue(node.attribute("value").toDouble());
|
19956
|
19995
|
}
|
|
19996
|
+ else if(node.attribute("name") == "delay")
|
|
19997
|
+ {
|
|
19998
|
+ delaySelector->setValue(node.attribute("value").toInt());
|
|
19999
|
+ }
|
19957
|
20000
|
}
|
19958
|
20001
|
updateMatchingColumn(column->text());
|
19959
|
20002
|
updateTemperature();
|
|
20003
|
+ updateDelay();
|
19960
|
20004
|
connect(column, SIGNAL(textEdited(QString)), this, SLOT(updateMatchingColumn(QString)));
|
19961
|
20005
|
connect(unitSelector, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateTemperature()));
|
19962
|
20006
|
connect(temperatureValue, SIGNAL(valueChanged(double)), this, SLOT(updateTemperature()));
|
|
20007
|
+ connect(delaySelector, SIGNAL(valueChanged(int)), this, SLOT(updateDelay()));
|
19963
|
20008
|
setLayout(layout);
|
19964
|
20009
|
}
|
19965
|
20010
|
|
|
@@ -19987,6 +20032,11 @@ void TranslationConfWidget::updateMatchingColumn(const QString &column)
|
19987
|
20032
|
updateAttribute("column", column);
|
19988
|
20033
|
}
|
19989
|
20034
|
|
|
20035
|
+void TranslationConfWidget::updateDelay()
|
|
20036
|
+{
|
|
20037
|
+ updateAttribute("delay", QString("%1").arg(delaySelector->value()));
|
|
20038
|
+}
|
|
20039
|
+
|
19990
|
20040
|
@ This is registered with the configuration system.
|
19991
|
20041
|
|
19992
|
20042
|
@<Register device configuration widgets@>=
|