13 * |
13 * |
14 * You should have received a copy of the GNU General Public License |
14 * You should have received a copy of the GNU General Public License |
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 */ |
16 */ |
17 #include "Setup.h" |
17 #include "Setup.h" |
18 #include "../ui/ui_Setup.h" |
|
19 #include "config.h" |
18 #include "config.h" |
20 #include "bmsapp.h" |
19 #include "bmsapp.h" |
21 |
20 |
22 |
21 |
23 |
22 |
24 Setup::Setup(QWidget *parent) : QDialog(parent), ui(new Ui::Setup) |
23 Setup::Setup(QWidget *parent) : QDialog(parent) |
25 { |
24 { |
26 QSqlQuery query; |
25 QSqlQuery query; |
|
26 QGridLayout *gridLayout; |
|
27 QWidget *topWidget; |
|
28 QFrame *line; |
27 |
29 |
28 qDebug() << "Setup start"; |
30 qDebug() << "Setup start"; |
29 ui->setupUi(this); |
31 |
30 setWindowTitle( QString("BMSapp - %1 - Setup").arg(VERSIONSTRING) ); |
32 gridLayout = new QGridLayout(this); |
|
33 gridLayout->setObjectName(QString::fromUtf8("gridLayout")); |
|
34 topWidget = new QWidget(this); |
|
35 topWidget->setObjectName(QString::fromUtf8("topWidget")); |
|
36 |
|
37 breweryLabel = new QLabel(topWidget); |
|
38 breweryLabel->setObjectName(QString::fromUtf8("breweryLabel")); |
|
39 breweryLabel->setGeometry(QRect(60, 20, 131, 20)); |
|
40 breweryLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
41 breweryLabel->setText(tr("Brewery name:")); |
|
42 breweryEdit = new QLineEdit(topWidget); |
|
43 breweryEdit->setObjectName(QString::fromUtf8("breweryEdit")); |
|
44 breweryEdit->setGeometry(QRect(212, 20, 941, 23)); |
|
45 breweryEdit->setToolTip(tr("The name for this brewery.")); |
|
46 |
|
47 line = new QFrame(topWidget); |
|
48 line->setObjectName(QString::fromUtf8("line")); |
|
49 line->setGeometry(QRect(0, 60, 1251, 20)); |
|
50 line->setFrameShape(QFrame::HLine); |
|
51 line->setFrameShadow(QFrame::Sunken); |
|
52 |
|
53 fwhLabel = new QLabel(topWidget); |
|
54 fwhLabel->setObjectName(QString::fromUtf8("fwhLabel")); |
|
55 fwhLabel->setGeometry(QRect(60, 120, 131, 20)); |
|
56 fwhLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
57 fwhLabel->setText(tr("First Wort Hop factor:")); |
|
58 |
|
59 mashhopLabel = new QLabel(topWidget); |
|
60 mashhopLabel->setObjectName(QString::fromUtf8("mashhopLabel")); |
|
61 mashhopLabel->setGeometry(QRect(60, 150, 131, 20)); |
|
62 mashhopLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
63 mashhopLabel->setText(tr("Mash Hop factor:")); |
|
64 |
|
65 pelletLabel = new QLabel(topWidget); |
|
66 pelletLabel->setObjectName(QString::fromUtf8("pelletLabel")); |
|
67 pelletLabel->setGeometry(QRect(60, 180, 131, 20)); |
|
68 pelletLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
69 pelletLabel->setText(tr("Pellet Hop factor:")); |
|
70 |
|
71 hopplugLabel = new QLabel(topWidget); |
|
72 hopplugLabel->setObjectName(QString::fromUtf8("hopplugLabel")); |
|
73 hopplugLabel->setGeometry(QRect(60, 210, 131, 20)); |
|
74 hopplugLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
75 hopplugLabel->setText(tr("Hop Plugs factor:")); |
|
76 |
|
77 wethopLabel = new QLabel(topWidget); |
|
78 wethopLabel->setObjectName(QString::fromUtf8("wethopLabel")); |
|
79 wethopLabel->setGeometry(QRect(60, 240, 131, 20)); |
|
80 wethopLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
81 wethopLabel->setText(tr("Wet Hop factor:")); |
|
82 |
|
83 cryohopLabel = new QLabel(topWidget); |
|
84 cryohopLabel->setObjectName(QString::fromUtf8("cryohopLabel")); |
|
85 cryohopLabel->setGeometry(QRect(60, 270, 131, 20)); |
|
86 cryohopLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
87 cryohopLabel->setText(tr("Cryo Hop\302\256 factor:")); |
|
88 |
|
89 fwhEdit = new QSpinBox(topWidget); |
|
90 fwhEdit->setObjectName(QString::fromUtf8("fwhEdit")); |
|
91 fwhEdit->setGeometry(QRect(210, 120, 81, 24)); |
|
92 fwhEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
93 fwhEdit->setAccelerated(true); |
|
94 fwhEdit->setMinimum(-50); |
|
95 fwhEdit->setMaximum(50); |
|
96 fwhEdit->setToolTip(tr("The efficiency for First Wort Hopping.")); |
|
97 fwhEdit->setSuffix(tr("%")); |
|
98 |
|
99 mashhopEdit = new QSpinBox(topWidget); |
|
100 mashhopEdit->setObjectName(QString::fromUtf8("mashhopEdit")); |
|
101 mashhopEdit->setGeometry(QRect(210, 150, 81, 24)); |
|
102 mashhopEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
103 mashhopEdit->setAccelerated(true); |
|
104 mashhopEdit->setMinimum(-50); |
|
105 mashhopEdit->setMaximum(50); |
|
106 mashhopEdit->setToolTip(tr("The efficiency for Mash hopping.")); |
|
107 mashhopEdit->setSuffix(tr("%")); |
|
108 |
|
109 pelletEdit = new QSpinBox(topWidget); |
|
110 pelletEdit->setObjectName(QString::fromUtf8("pelletEdit")); |
|
111 pelletEdit->setGeometry(QRect(210, 180, 81, 24)); |
|
112 pelletEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
113 pelletEdit->setAccelerated(true); |
|
114 pelletEdit->setMinimum(0); |
|
115 pelletEdit->setMaximum(20); |
|
116 pelletEdit->setToolTip(tr("The efficiency for hop pellets.")); |
|
117 pelletEdit->setSuffix(tr("%")); |
|
118 |
|
119 hopplugEdit = new QSpinBox(topWidget); |
|
120 hopplugEdit->setObjectName(QString::fromUtf8("hopplugEdit")); |
|
121 hopplugEdit->setGeometry(QRect(210, 210, 81, 24)); |
|
122 hopplugEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
123 hopplugEdit->setAccelerated(true); |
|
124 hopplugEdit->setMaximum(20); |
|
125 hopplugEdit->setToolTip(tr("The efficiency for hop plugs.")); |
|
126 hopplugEdit->setSuffix(tr("%")); |
|
127 |
|
128 wethopEdit = new QSpinBox(topWidget); |
|
129 wethopEdit->setObjectName(QString::fromUtf8("wethopEdit")); |
|
130 wethopEdit->setGeometry(QRect(210, 240, 81, 24)); |
|
131 wethopEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
132 wethopEdit->setAccelerated(true); |
|
133 wethopEdit->setMinimum(-98); |
|
134 wethopEdit->setMaximum(-20); |
|
135 wethopEdit->setToolTip(tr("The efficiency for fresh hops.")); |
|
136 wethopEdit->setSuffix(tr("%")); |
|
137 |
|
138 cryohopEdit = new QSpinBox(topWidget); |
|
139 cryohopEdit->setObjectName(QString::fromUtf8("cryohopEdit")); |
|
140 cryohopEdit->setGeometry(QRect(210, 270, 81, 24)); |
|
141 cryohopEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
142 cryohopEdit->setAccelerated(true); |
|
143 cryohopEdit->setMinimum(-20); |
|
144 cryohopEdit->setMaximum(150); |
|
145 cryohopEdit->setToolTip(tr("The efficiency for using Cryo Hop\302\256.")); |
|
146 cryohopEdit->setSuffix(tr("%")); |
|
147 |
|
148 grainLabel = new QLabel(topWidget); |
|
149 grainLabel->setObjectName(QString::fromUtf8("grainLabel")); |
|
150 grainLabel->setGeometry(QRect(400, 120, 161, 20)); |
|
151 grainLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
152 grainLabel->setText(tr("Grain Absorbtion:")); |
|
153 |
|
154 brixLabel = new QLabel(topWidget); |
|
155 brixLabel->setObjectName(QString::fromUtf8("brixLabel")); |
|
156 brixLabel->setGeometry(QRect(400, 150, 161, 20)); |
|
157 brixLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
158 brixLabel->setText(tr("Brix Correction factor:")); |
|
159 |
|
160 titleLabel = new QLabel(topWidget); |
|
161 titleLabel->setObjectName(QString::fromUtf8("titleLabel")); |
|
162 titleLabel->setGeometry(QRect(5, 80, 1251, 20)); |
|
163 QFont font; |
|
164 font.setFamily(QString::fromUtf8("DejaVu Sans")); |
|
165 font.setPointSize(12); |
|
166 font.setBold(true); |
|
167 font.setWeight(75); |
|
168 titleLabel->setFont(font); |
|
169 titleLabel->setAlignment(Qt::AlignCenter); |
|
170 titleLabel->setText(tr("Brew settings.")); |
|
171 |
|
172 colorLabel = new QLabel(topWidget); |
|
173 colorLabel->setObjectName(QString::fromUtf8("colorLabel")); |
|
174 colorLabel->setGeometry(QRect(800, 120, 121, 16)); |
|
175 colorLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
176 colorLabel->setText(tr("Color Calculation:")); |
|
177 |
|
178 ibuLabel = new QLabel(topWidget); |
|
179 ibuLabel->setObjectName(QString::fromUtf8("ibuLabel")); |
|
180 ibuLabel->setGeometry(QRect(800, 150, 121, 16)); |
|
181 ibuLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
182 ibuLabel->setText(tr("IBU Calculation:")); |
|
183 |
|
184 waterLabel = new QLabel(topWidget); |
|
185 waterLabel->setObjectName(QString::fromUtf8("waterLabel")); |
|
186 waterLabel->setGeometry(QRect(800, 180, 121, 16)); |
|
187 waterLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
188 waterLabel->setText(tr("Default Water:")); |
|
189 |
|
190 yeastLabel = new QLabel(topWidget); |
|
191 yeastLabel->setObjectName(QString::fromUtf8("yeastLabel")); |
|
192 yeastLabel->setGeometry(QRect(800, 210, 121, 16)); |
|
193 yeastLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
194 yeastLabel->setText(tr("Private Yeast bank:")); |
|
195 |
|
196 grainEdit = new QDoubleSpinBox(topWidget); |
|
197 grainEdit->setObjectName(QString::fromUtf8("grainEdit")); |
|
198 grainEdit->setGeometry(QRect(580, 120, 101, 24)); |
|
199 grainEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
200 grainEdit->setAccelerated(true); |
|
201 grainEdit->setMinimum(0.500000000000000); |
|
202 grainEdit->setMaximum(1.100000000000000); |
|
203 grainEdit->setSingleStep(0.010000000000000); |
|
204 grainEdit->setStepType(QAbstractSpinBox::DefaultStepType); |
|
205 grainEdit->setValue(1.000000000000000); |
|
206 grainEdit->setToolTip(tr("Absorbtion with water by the grain (L/Kg)")); |
|
207 grainEdit->setSuffix(tr(" L/Kg")); |
|
208 |
|
209 brixEdit = new QDoubleSpinBox(topWidget); |
|
210 brixEdit->setObjectName(QString::fromUtf8("brixEdit")); |
|
211 brixEdit->setGeometry(QRect(580, 150, 101, 24)); |
|
212 brixEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
213 brixEdit->setAccelerated(true); |
|
214 brixEdit->setMinimum(1.000000000000000); |
|
215 brixEdit->setMaximum(1.090000000000000); |
|
216 brixEdit->setSingleStep(0.010000000000000); |
|
217 brixEdit->setStepType(QAbstractSpinBox::DefaultStepType); |
|
218 brixEdit->setValue(1.000000000000000); |
|
219 brixEdit->setToolTip(tr("Plato to Brix conversion factor.")); |
|
220 |
|
221 colorEdit = new QComboBox(topWidget); |
|
222 colorEdit->setObjectName(QString::fromUtf8("colorEdit")); |
|
223 colorEdit->setGeometry(QRect(940, 120, 161, 23)); |
|
224 colorEdit->setMinimumContentsLength(4); |
|
225 colorEdit->setIconSize(QSize(0, 0)); |
|
226 colorEdit->setCurrentText(QString()); |
|
227 colorEdit->setPlaceholderText(tr("Choose color")); |
|
228 |
|
229 ibuEdit = new QComboBox(topWidget); |
|
230 ibuEdit->setObjectName(QString::fromUtf8("ibuEdit")); |
|
231 ibuEdit->setGeometry(QRect(940, 150, 161, 23)); |
|
232 ibuEdit->setMinimumContentsLength(4); |
|
233 ibuEdit->setIconSize(QSize(0, 0)); |
|
234 ibuEdit->setCurrentText(QString()); |
|
235 ibuEdit->setPlaceholderText(tr("Choose color")); |
|
236 |
|
237 waterEdit = new QComboBox(topWidget); |
|
238 waterEdit->setObjectName(QString::fromUtf8("waterEdit")); |
|
239 waterEdit->setGeometry(QRect(940, 180, 211, 23)); |
|
240 waterEdit->setMinimumContentsLength(4); |
|
241 waterEdit->setIconSize(QSize(0, 0)); |
|
242 waterEdit->setCurrentText(QString()); |
|
243 waterEdit->setPlaceholderText(tr("Choose color")); |
|
244 |
|
245 yeastEdit = new QComboBox(topWidget); |
|
246 yeastEdit->setObjectName(QString::fromUtf8("yeastEdit")); |
|
247 yeastEdit->setGeometry(QRect(940, 210, 211, 23)); |
|
248 yeastEdit->setMinimumContentsLength(4); |
|
249 yeastEdit->setIconSize(QSize(0, 0)); |
|
250 yeastEdit->setCurrentText(QString()); |
|
251 yeastEdit->setPlaceholderText(tr("Choose color")); |
|
252 |
|
253 logoLabel = new QLabel(topWidget); |
|
254 logoLabel->setObjectName(QString::fromUtf8("logoLabel")); |
|
255 logoLabel->setGeometry(QRect(940, 260, 211, 211)); |
|
256 logoLabel->setAlignment(Qt::AlignCenter); |
|
257 logoLabel->setText(tr("Logo here")); |
|
258 |
|
259 quitButton = new QPushButton(topWidget); |
|
260 quitButton->setObjectName(QString::fromUtf8("quitButton")); |
|
261 quitButton->setGeometry(QRect(50, 520, 80, 23)); |
|
262 QIcon icon; |
|
263 icon.addFile(QString::fromUtf8(":icons/silk/door_out.png"), QSize(), QIcon::Normal, QIcon::Off); |
|
264 quitButton->setIcon(icon); |
|
265 quitButton->setText(tr("Quit")); |
|
266 |
|
267 saveButton = new QPushButton(topWidget); |
|
268 saveButton->setObjectName(QString::fromUtf8("saveButton")); |
|
269 saveButton->setGeometry(QRect(200, 520, 80, 23)); |
|
270 QIcon icon1; |
|
271 icon1.addFile(QString::fromUtf8(":icons/silk/disk.png"), QSize(), QIcon::Normal, QIcon::Off); |
|
272 saveButton->setIcon(icon1); |
|
273 saveButton->setText(tr("Save")); |
|
274 saveButton->setEnabled(false); |
|
275 |
|
276 openButton = new QPushButton(topWidget); |
|
277 openButton->setObjectName(QString::fromUtf8("openButton")); |
|
278 openButton->setGeometry(QRect(810, 260, 111, 23)); |
|
279 QIcon icon2; |
|
280 icon2.addFile(QString::fromUtf8(":/icons/silk/folder_picture.png"), QSize(), QIcon::Normal, QIcon::Off); |
|
281 openButton->setIcon(icon2); |
|
282 openButton->setText(tr("Load logo")); |
|
283 |
|
284 gridLayout->addWidget(topWidget, 0, 0, 1, 1); |
|
285 |
|
286 connect(quitButton, SIGNAL(clicked()), this, SLOT(on_quitButton_clicked())); |
|
287 connect(saveButton, SIGNAL(clicked()), this, SLOT(on_saveButton_clicked())); |
|
288 connect(openButton, SIGNAL(clicked()), this, SLOT(on_openButton_clicked())); |
|
289 connect(this, SIGNAL(firstWindow()), parent, SLOT(fromSetup())); |
|
290 connect(this, SIGNAL(setTitle(QString)), parent, SLOT(windowTitle(QString))); |
|
291 |
|
292 emit setTitle(QString(tr("Setup"))); |
31 |
293 |
32 query.prepare("SELECT * FROM profile_setup WHERE record='1'"); |
294 query.prepare("SELECT * FROM profile_setup WHERE record='1'"); |
33 query.exec(); |
295 query.exec(); |
34 query.next(); |
296 query.next(); |
35 |
297 |
36 ui->breweryEdit->setText(query.value(1).toString()); // max 128 |
298 breweryEdit->setText(query.value(1).toString()); // max 128 |
37 connect(ui->breweryEdit, &QLineEdit::textChanged, this, &Setup::is_changed); |
299 connect(breweryEdit, &QLineEdit::textChanged, this, &Setup::is_changed); |
38 |
300 |
39 ui->fwhEdit->setValue(query.value(4).toInt()); |
301 fwhEdit->setValue(query.value(4).toInt()); |
40 ui->mashhopEdit->setValue(query.value(3).toInt()); |
302 mashhopEdit->setValue(query.value(3).toInt()); |
41 ui->pelletEdit->setValue(query.value(5).toInt()); |
303 pelletEdit->setValue(query.value(5).toInt()); |
42 ui->hopplugEdit->setValue(query.value(6).toInt()); |
304 hopplugEdit->setValue(query.value(6).toInt()); |
43 ui->wethopEdit->setValue(query.value(7).toInt()); |
305 wethopEdit->setValue(query.value(7).toInt()); |
44 ui->cryohopEdit->setValue(query.value(8).toInt()); |
306 cryohopEdit->setValue(query.value(8).toInt()); |
45 connect(ui->fwhEdit, &QSpinBox::textChanged, this, &Setup::is_changed); |
307 connect(fwhEdit, &QSpinBox::textChanged, this, &Setup::is_changed); |
46 connect(ui->mashhopEdit, &QSpinBox::textChanged, this, &Setup::is_changed); |
308 connect(mashhopEdit, &QSpinBox::textChanged, this, &Setup::is_changed); |
47 connect(ui->pelletEdit, &QSpinBox::textChanged, this, &Setup::is_changed); |
309 connect(pelletEdit, &QSpinBox::textChanged, this, &Setup::is_changed); |
48 connect(ui->hopplugEdit, &QSpinBox::textChanged, this, &Setup::is_changed); |
310 connect(hopplugEdit, &QSpinBox::textChanged, this, &Setup::is_changed); |
49 connect(ui->wethopEdit, &QSpinBox::textChanged, this, &Setup::is_changed); |
311 connect(wethopEdit, &QSpinBox::textChanged, this, &Setup::is_changed); |
50 connect(ui->cryohopEdit, &QSpinBox::textChanged, this, &Setup::is_changed); |
312 connect(cryohopEdit, &QSpinBox::textChanged, this, &Setup::is_changed); |
51 |
313 |
52 ui->grainEdit->setValue(query.value(12).toDouble()); |
314 grainEdit->setValue(query.value(12).toDouble()); |
53 ui->brixEdit->setValue(query.value(11).toDouble()); |
315 brixEdit->setValue(query.value(11).toDouble()); |
54 connect(ui->grainEdit, &QDoubleSpinBox::textChanged, this, &Setup::is_changed); |
316 connect(grainEdit, &QDoubleSpinBox::textChanged, this, &Setup::is_changed); |
55 connect(ui->brixEdit, &QDoubleSpinBox::textChanged, this, &Setup::is_changed); |
317 connect(brixEdit, &QDoubleSpinBox::textChanged, this, &Setup::is_changed); |
56 |
318 |
57 ui->colorEdit->addItem("Morey"); |
319 colorEdit->addItem("Morey"); |
58 ui->colorEdit->addItem("Mosher"); |
320 colorEdit->addItem("Mosher"); |
59 ui->colorEdit->addItem("Daniels"); |
321 colorEdit->addItem("Daniels"); |
60 ui->colorEdit->addItem("Halberstadt"); |
322 colorEdit->addItem("Halberstadt"); |
61 ui->colorEdit->addItem("Naudts"); |
323 colorEdit->addItem("Naudts"); |
62 ui->colorEdit->setEditable(true); |
324 colorEdit->setEditable(true); |
63 ui->colorEdit->setCurrentIndex(query.value(10).toInt()); |
325 colorEdit->setCurrentIndex(query.value(10).toInt()); |
64 connect(ui->colorEdit, &QComboBox::currentTextChanged, this, &Setup::is_changed); |
326 connect(colorEdit, &QComboBox::currentTextChanged, this, &Setup::is_changed); |
65 |
327 |
66 ui->ibuEdit->addItem("Tinseth"); |
328 ibuEdit->addItem("Tinseth"); |
67 ui->ibuEdit->addItem("Rager"); |
329 ibuEdit->addItem("Rager"); |
68 ui->ibuEdit->addItem("Daniels"); |
330 ibuEdit->addItem("Daniels"); |
69 ui->ibuEdit->setEditable(true); |
331 ibuEdit->setEditable(true); |
70 ui->ibuEdit->setCurrentIndex(query.value(9).toInt()); |
332 ibuEdit->setCurrentIndex(query.value(9).toInt()); |
71 connect(ui->ibuEdit, &QComboBox::currentTextChanged, this, &Setup::is_changed); |
333 connect(ibuEdit, &QComboBox::currentTextChanged, this, &Setup::is_changed); |
72 |
334 |
73 QSqlQuery query2("SELECT record,name FROM inventory_waters"); |
335 QSqlQuery query2("SELECT record,name FROM inventory_waters"); |
74 query2.first(); |
336 query2.first(); |
75 int pos = -1; |
337 int pos = -1; |
76 ui->waterEdit->setEditable(true); |
338 waterEdit->setEditable(true); |
77 ui->waterEdit->setPlaceholderText(tr("Choose default water")); |
339 waterEdit->setPlaceholderText(tr("Choose default water")); |
78 for (int i = 0 ; i < query2.size() ; i++ ) { |
340 for (int i = 0 ; i < query2.size() ; i++ ) { |
79 ui->waterEdit->addItem(query2.value(1).toString()); |
341 waterEdit->addItem(query2.value(1).toString()); |
80 if (query2.value(0).toInt() == query.value(13).toInt()) { |
342 if (query2.value(0).toInt() == query.value(13).toInt()) { |
81 pos = i; |
343 pos = i; |
82 } |
344 } |
83 query2.next(); |
345 query2.next(); |
84 } |
346 } |
85 if (pos >= 0) |
347 if (pos >= 0) |
86 ui->waterEdit->setCurrentIndex(pos); |
348 waterEdit->setCurrentIndex(pos); |
87 connect(ui->waterEdit, &QComboBox::currentTextChanged, this, &Setup::is_changed); |
349 connect(waterEdit, &QComboBox::currentTextChanged, this, &Setup::is_changed); |
88 |
350 |
89 QSqlQuery query3("SELECT DISTINCT laboratory FROM inventory_yeasts ORDER BY laboratory"); |
351 QSqlQuery query3("SELECT DISTINCT laboratory FROM inventory_yeasts ORDER BY laboratory"); |
90 query3.first(); |
352 query3.first(); |
91 pos = -1; |
353 pos = -1; |
92 ui->yeastEdit->setEditable(true); |
354 yeastEdit->setEditable(true); |
93 ui->yeastEdit->setPlaceholderText(tr("Choose laboratory")); |
355 yeastEdit->setPlaceholderText(tr("Choose laboratory")); |
94 for (int i = 0 ; i < query3.size() ; i++ ) { |
356 for (int i = 0 ; i < query3.size() ; i++ ) { |
95 ui->yeastEdit->addItem(query3.value(0).toString()); |
357 yeastEdit->addItem(query3.value(0).toString()); |
96 if (QString::compare(query.value(14).toString(), query3.value(0).toString(), Qt::CaseSensitive) == 0) |
358 if (QString::compare(query.value(14).toString(), query3.value(0).toString(), Qt::CaseSensitive) == 0) |
97 pos = i; |
359 pos = i; |
98 query3.next(); |
360 query3.next(); |
99 } |
361 } |
100 if (pos >= 0) |
362 if (pos >= 0) |
101 ui->yeastEdit->setCurrentIndex(pos); |
363 yeastEdit->setCurrentIndex(pos); |
102 connect(ui->yeastEdit, &QComboBox::currentTextChanged, this, &Setup::is_changed); |
364 connect(yeastEdit, &QComboBox::currentTextChanged, this, &Setup::is_changed); |
103 |
365 |
104 /* logo */ |
366 /* logo */ |
105 logoByteArray = query.value(2).toByteArray(); |
367 logoByteArray = query.value(2).toByteArray(); |
106 QPixmap outPixmap = QPixmap(); |
368 QPixmap outPixmap = QPixmap(); |
107 outPixmap.loadFromData(logoByteArray); |
369 outPixmap.loadFromData(logoByteArray); |
108 ui->logoLabel->setPixmap(outPixmap); |
370 logoLabel->setPixmap(outPixmap); |
109 ui->logoLabel->adjustSize(); |
371 logoLabel->adjustSize(); |
110 } |
372 } |
111 |
373 |
112 |
374 |
113 Setup::~Setup() |
375 Setup::~Setup() {} |
114 { |
|
115 qDebug() << "Setup done"; |
|
116 delete ui; |
|
117 } |
|
118 |
376 |
119 |
377 |
120 bool Setup::loadFile(const QString &fileName) |
378 bool Setup::loadFile(const QString &fileName) |
121 { |
379 { |
122 QImageReader reader(fileName); |
380 QImageReader reader(fileName); |