31 #include "ui_dialgadgetoptionspage.h"
36 #include <QtAlgorithms>
37 #include <QStringList>
40 : IOptionsPage(parent)
50 options_page =
new Ui::DialGadgetOptionsPage();
52 QWidget *optionsPageWidget =
new QWidget;
54 options_page->setupUi(optionsPageWidget);
60 foreach (QVector<UAVDataObject *> list, objList) {
62 options_page->uavObject1->addItem(obj->
getName());
63 options_page->uavObject2->addItem(obj->
getName());
64 options_page->uavObject3->addItem(obj->
getName());
69 options_page->moveNeedle1->addItem(
"Rotate");
70 options_page->moveNeedle1->addItem(
"Horizontal");
71 options_page->moveNeedle1->addItem(
"Vertical");
73 options_page->moveNeedle2->addItem(
"Rotate");
74 options_page->moveNeedle2->addItem(
"Horizontal");
75 options_page->moveNeedle2->addItem(
"Vertical");
77 options_page->moveNeedle3->addItem(
"Rotate");
78 options_page->moveNeedle3->addItem(
"Horizontal");
79 options_page->moveNeedle3->addItem(
"Vertical");
83 options_page->svgSourceFile->setExpectedKind(Utils::PathChooser::File);
84 options_page->svgSourceFile->setPromptDialogFilter(tr(
"SVG image (*.svg)"));
85 options_page->svgSourceFile->setPromptDialogTitle(tr(
"Choose SVG image"));
86 options_page->svgSourceFile->setPath(m_config->
dialFile());
89 options_page->needle1ID->setText(m_config->
dialNeedle1());
90 options_page->needle2ID->setText(m_config->
dialNeedle2());
91 options_page->needle3ID->setText(m_config->
dialNeedle3());
92 options_page->needle1Min->setValue(m_config->
getN1Min());
93 options_page->needle1Max->setValue(m_config->
getN1Max());
94 options_page->needle2Min->setValue(m_config->
getN2Min());
95 options_page->needle2Max->setValue(m_config->
getN2Max());
96 options_page->needle3Min->setValue(m_config->
getN3Min());
97 options_page->needle3Max->setValue(m_config->
getN3Max());
98 options_page->factor1->setValue(m_config->
getN1Factor());
99 options_page->factor2->setValue(m_config->
getN2Factor());
100 options_page->factor3->setValue(m_config->
getN3Factor());
101 options_page->moveNeedle1->setCurrentIndex(
102 options_page->moveNeedle1->findText(m_config->
getN1Move()));
103 options_page->moveNeedle2->setCurrentIndex(
104 options_page->moveNeedle2->findText(m_config->
getN2Move()));
105 options_page->moveNeedle3->setCurrentIndex(
106 options_page->moveNeedle3->findText(m_config->
getN3Move()));
108 options_page->smoothUpdates->setChecked(m_config->
getBeSmooth());
111 if (options_page->uavObject1->findText(m_config->
getN1DataObject()) != -1) {
112 options_page->uavObject1->setCurrentIndex(
121 options_page->objectField1->setCurrentIndex(
122 options_page->objectField1->findText(m_config->
getN1ObjField()));
125 connect(options_page->uavObject1,
126 QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
this,
127 [
this](
const QString &val) { uavoChanged(options_page->objectField1, val); });
129 if (options_page->uavObject2->findText(m_config->getN2DataObject()) != -1) {
130 options_page->uavObject2->setCurrentIndex(
131 options_page->uavObject2->findText(m_config->getN2DataObject()));
134 dynamic_cast<UAVDataObject *
>(objManager->getObject(m_config->getN2DataObject()));
136 uavoChanged(options_page->objectField2, m_config->getN2DataObject());
137 options_page->objectField2->setCurrentIndex(
138 options_page->objectField2->findText(m_config->getN2ObjField()));
141 connect(options_page->uavObject2,
142 QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
this,
143 [
this](
const QString &val) { uavoChanged(options_page->objectField2, val); });
145 if (options_page->uavObject3->findText(m_config->getN3DataObject()) != -1) {
146 options_page->uavObject3->setCurrentIndex(
147 options_page->uavObject3->findText(m_config->getN3DataObject()));
150 dynamic_cast<UAVDataObject *
>(objManager->getObject(m_config->getN3DataObject()));
152 uavoChanged(options_page->objectField3, m_config->getN3DataObject());
153 options_page->objectField3->setCurrentIndex(
154 options_page->objectField3->findText(m_config->getN3ObjField()));
157 connect(options_page->uavObject3,
158 QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
this,
159 [
this](
const QString &val) { uavoChanged(options_page->objectField3, val); });
161 connect(options_page->fontPicker, &QAbstractButton::clicked,
this,
162 &DialGadgetOptionsPage::on_fontPicker_clicked);
164 return optionsPageWidget;
175 m_config->
setDialFile(options_page->svgSourceFile->path());
181 m_config->
setN1Min(options_page->needle1Min->value());
182 m_config->
setN1Max(options_page->needle1Max->value());
183 m_config->
setN1Factor(options_page->factor1->value());
184 m_config->
setN2Min(options_page->needle2Min->value());
185 m_config->
setN2Max(options_page->needle2Max->value());
186 m_config->
setN2Factor(options_page->factor2->value());
187 m_config->
setN3Min(options_page->needle3Min->value());
188 m_config->
setN3Max(options_page->needle3Max->value());
189 m_config->
setN3Factor(options_page->factor3->value());
193 m_config->
setN1ObjField(options_page->objectField1->currentText());
194 m_config->
setN2ObjField(options_page->objectField2->currentText());
195 m_config->
setN3ObjField(options_page->objectField3->currentText());
196 m_config->
setN1Move(options_page->moveNeedle1->currentText());
197 m_config->
setN2Move(options_page->moveNeedle2->currentText());
198 m_config->
setN3Move(options_page->moveNeedle3->currentText());
199 m_config->
setFont(font.toString());
200 m_config->
setBeSmooth(options_page->smoothUpdates->checkState());
207 void DialGadgetOptionsPage::on_fontPicker_clicked()
210 font = QFontDialog::getFont(&ok, QFont(
"Arial", 12), qobject_cast<QWidget *>(
this));
218 void DialGadgetOptionsPage::uavoChanged(QComboBox *widget,
const QString &uavo)
225 qWarning() <<
"Invalid object" << uavo;
230 for (
auto field : obj->getFields()) {
233 if (field->getElementNames().count() > 1) {
234 for (
const QString &elemName : field->getElementNames())
235 widget->addItem(field->getName() +
"-" + elemName);
237 widget->addItem(field->getName());
void setN2Max(double val)
void setN3Move(QString move)
void setDialBackgroundID(QString elementID)
Core plugin system that manages the plugins, their life cycle and their registered objects...
void setFont(QString text)
void setDialForegroundID(QString elementID)
void setDialNeedleID3(QString elementID)
DialGadgetOptionsPage(DialGadgetConfiguration *config, QObject *parent=nullptr)
void setN2DataObject(QString text)
void setN3Factor(double val)
void setN3DataObject(QString text)
void setDialNeedleID2(QString elementID)
void setN1Factor(double val)
void setN1Max(double val)
void setN2Factor(double val)
void setBeSmooth(bool flag)
void setN2Move(QString move)
void setN1Min(double val)
void setN2ObjField(QString text)
void setDialNeedleID1(QString elementID)
void setN3Min(double val)
void setN1Move(QString move)
void setN3ObjField(QString text)
void setN3Max(double val)
QWidget * createPage(QWidget *parent)
QString getN1DataObject()
void setN1ObjField(QString text)
UAVObject * getObject(const QString &name, quint32 instId=0)
void setDialFile(QString dialFile)
QVector< QVector< UAVDataObject * > > getDataObjectsVector()
void setN1DataObject(QString text)
void setN2Min(double val)