dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
dialgadgetconfiguration.cpp
Go to the documentation of this file.
1 
13 /*
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  * for more details.
23  *
24  * You should have received a copy of the GNU General Public License along
25  * with this program; if not, see <http://www.gnu.org/licenses/>
26  */
27 
29 #include "utils/pathutils.h"
30 
35 DialGadgetConfiguration::DialGadgetConfiguration(QString classId, QSettings *qSettings,
36  QObject *parent)
37  : IUAVGadgetConfiguration(classId, parent)
38  , m_defaultDial("Unknown")
39  , dialBackgroundID("background")
40  , dialForegroundID("foreground")
41  , dialNeedleID1("needle")
42  , dialNeedleID2("needle2")
43  , dialNeedleID3("needle3")
44  , needle1MinValue(0)
45  , needle1MaxValue(100)
46  , needle2MinValue(0)
47  , needle2MaxValue(100)
48  , needle3MinValue(0)
49  , needle3MaxValue(100)
50  , needle1Factor(1)
51  , needle2Factor(1)
52  , needle3Factor(1)
53  , needle1Move("Rotate")
54  , needle2Move("Rotate")
55  , needle3Move("Rotate")
56  , beSmooth(true)
57 {
58  // if a saved configuration exists load it
59  if (qSettings != nullptr) {
60  QString dialFile = qSettings->value("dialFile").toString();
61 
62  m_defaultDial = Utils::PathUtils().InsertDataPath(dialFile);
63  dialBackgroundID = qSettings->value("dialBackgroundID").toString();
64  dialForegroundID = qSettings->value("dialForegroundID").toString();
65  dialNeedleID1 = qSettings->value("dialNeedleID1").toString();
66  dialNeedleID2 = qSettings->value("dialNeedleID2").toString();
67  dialNeedleID3 = qSettings->value("dialNeedleID3").toString();
68  needle1MinValue = qSettings->value("needle1MinValue").toDouble();
69  needle1MaxValue = qSettings->value("needle1MaxValue").toDouble();
70  needle2MinValue = qSettings->value("needle2MinValue").toDouble();
71  needle2MaxValue = qSettings->value("needle2MaxValue").toDouble();
72  needle3MinValue = qSettings->value("needle3MinValue").toDouble();
73  needle3MaxValue = qSettings->value("needle3MaxValue").toDouble();
74  needle1DataObject = qSettings->value("needle1DataObject").toString();
75  needle1ObjectField = qSettings->value("needle1ObjectField").toString();
76  needle2DataObject = qSettings->value("needle2DataObject").toString();
77  needle2ObjectField = qSettings->value("needle2ObjectField").toString();
78  needle3DataObject = qSettings->value("needle3DataObject").toString();
79  needle3ObjectField = qSettings->value("needle3ObjectField").toString();
80  needle1Factor = qSettings->value("needle1Factor").toDouble();
81  needle2Factor = qSettings->value("needle2Factor").toDouble();
82  needle3Factor = qSettings->value("needle3Factor").toDouble();
83  needle1Move = qSettings->value("needle1Move").toString();
84  needle2Move = qSettings->value("needle2Move").toString();
85  needle3Move = qSettings->value("needle3Move").toString();
86  font = qSettings->value("font").toString();
87  beSmooth = qSettings->value("beSmooth").toBool();
88  }
89 }
90 
95 IUAVGadgetConfiguration *DialGadgetConfiguration::clone()
96 {
98  m->m_defaultDial = m_defaultDial;
99  m->setDialBackgroundID(dialBackgroundID);
100  m->setDialForegroundID(dialForegroundID);
101  m->setDialNeedleID1(dialNeedleID1);
102  m->setDialNeedleID2(dialNeedleID2);
103  m->setDialNeedleID3(dialNeedleID3);
104  m->setN1Min(needle1MinValue);
105  m->setN1Max(needle1MaxValue);
106  m->setN2Min(needle2MinValue);
107  m->setN2Max(needle2MaxValue);
108  m->setN3Min(needle3MinValue);
109  m->setN3Max(needle3MaxValue);
110  m->setN1DataObject(needle1DataObject);
111  m->setN1ObjField(needle1ObjectField);
112  m->setN2DataObject(needle2DataObject);
113  m->setN2ObjField(needle2ObjectField);
114  m->setN3DataObject(needle3DataObject);
115  m->setN3ObjField(needle3ObjectField);
116  m->setN1Factor(needle1Factor);
117  m->setN2Factor(needle2Factor);
118  m->setN3Factor(needle3Factor);
119  m->setN1Move(needle1Move);
120  m->setN2Move(needle2Move);
121  m->setN3Move(needle3Move);
122  m->setFont(font);
123  m->beSmooth = beSmooth;
124 
125  return m;
126 }
127 
132 void DialGadgetConfiguration::saveConfig(QSettings *settings) const
133 {
134  QString dialFile = Utils::PathUtils().RemoveDataPath(m_defaultDial);
135  settings->setValue("dialFile", dialFile);
136 
137  settings->setValue("dialBackgroundID", dialBackgroundID);
138  settings->setValue("dialForegroundID", dialForegroundID);
139 
140  settings->setValue("dialNeedleID1", dialNeedleID1);
141  settings->setValue("dialNeedleID2", dialNeedleID2);
142  settings->setValue("dialNeedleID3", dialNeedleID3);
143 
144  settings->setValue("needle1MinValue", needle1MinValue);
145  settings->setValue("needle1MaxValue", needle1MaxValue);
146  settings->setValue("needle2MinValue", needle2MinValue);
147  settings->setValue("needle2MaxValue", needle2MaxValue);
148  settings->setValue("needle3MinValue", needle3MinValue);
149  settings->setValue("needle3MaxValue", needle3MaxValue);
150 
151  settings->setValue("needle1DataObject", needle1DataObject);
152  settings->setValue("needle1ObjectField", needle1ObjectField);
153  settings->setValue("needle2DataObject", needle2DataObject);
154  settings->setValue("needle2ObjectField", needle2ObjectField);
155  settings->setValue("needle3DataObject", needle3DataObject);
156  settings->setValue("needle3ObjectField", needle3ObjectField);
157 
158  settings->setValue("needle1Factor", needle1Factor);
159  settings->setValue("needle2Factor", needle2Factor);
160  settings->setValue("needle3Factor", needle3Factor);
161 
162  settings->setValue("needle1Move", needle1Move);
163  settings->setValue("needle2Move", needle2Move);
164  settings->setValue("needle3Move", needle3Move);
165 
166  settings->setValue("font", font);
167 
168  settings->setValue("beSmooth", beSmooth);
169 }
DialGadgetConfiguration(QString classId, QSettings *qSettings=nullptr, QObject *parent=nullptr)
void setDialBackgroundID(QString elementID)
void setDialForegroundID(QString elementID)
void setDialNeedleID3(QString elementID)
void setN2DataObject(QString text)
void setN3DataObject(QString text)
void setDialNeedleID2(QString elementID)
static QString RemoveDataPath(QString path)
Definition: pathutils.cpp:67
void setN2ObjField(QString text)
void setDialNeedleID1(QString elementID)
IUAVGadgetConfiguration * clone()
void setN3ObjField(QString text)
void setN1ObjField(QString text)
void setN1DataObject(QString text)
static QString InsertDataPath(QString path)
Definition: pathutils.cpp:84