1 #include "Global.h"
2
3 #include "PaintStyleEditor.h"
4 #include "Painter.h"
5 #include "MainWindow.h"
6 #include "Document.h"
7
8 #include "SelectionDialog.h"
9
10 #include <QCheckBox>
11 #include <QColorDialog>
12 #include <QDoubleSpinBox>
13 #include <QIcon>
14 #include <QListWidget>
15 #include <QPainter>
16 #include <QPixmap>
17 #include <QToolButton>
18
makeBoundaryIcon(QToolButton * bt,QColor C)19 static void makeBoundaryIcon(QToolButton* bt, QColor C)
20 {
21 QPixmap pm(36, 18);
22 pm.fill(QColor(255, 255, 255));
23 QPainter p(&pm);
24 p.setPen(C);
25 p.setBrush(C);
26 p.drawRect(0, 6, 36, 6);
27 bt->setIcon(pm);
28 }
29
PaintStyleEditor(QWidget * aParent,const GlobalPainter & aGlobalPainter,const QList<Painter> & aPainters)30 PaintStyleEditor::PaintStyleEditor(QWidget *aParent, const GlobalPainter& aGlobalPainter, const QList<Painter>& aPainters)
31 : QDialog(aParent), theGlobalPainter(aGlobalPainter), thePainters(aPainters), FreezeUpdate(true)
32 {
33 setupUi(this);
34
35 setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
36 setWindowFlags(windowFlags() | Qt::MSWindowsFixedSizeDialogHint);
37
38 BackgroundColor->setIconSize(QSize(36, 18));
39 ForegroundColor->setIconSize(QSize(36, 18));
40 TouchupColor->setIconSize(QSize(36, 18));
41 TrafficDirectionMarksColor->setIconSize(QSize(36, 18));;
42 FillColor->setIconSize(QSize(36, 18));
43 LabelColor->setIconSize(QSize(36, 18));
44 LabelBackgroundlColor->setIconSize(QSize(36, 18));
45 GlobalBackgroundColor->setIconSize(QSize(36, 18));
46 GlobalNodesColor->setIconSize(QSize(36, 18));
47
48 updatePaintList();
49
50 LowerZoomBoundary->setSpecialValueText(tr("Always"));
51 UpperZoomBoundary->setSpecialValueText(tr("Always"));
52
53 DrawGlobalBackground->setChecked(theGlobalPainter.getDrawBackground());
54 makeBoundaryIcon(GlobalBackgroundColor, theGlobalPainter.getBackgroundColor());
55 on_PaintList_itemSelectionChanged();
56
57 DrawGlobalNodes->setChecked(theGlobalPainter.getDrawNodes());
58 makeBoundaryIcon(GlobalNodesColor, theGlobalPainter.getNodesColor());
59 GlobalNodesProportional->setEnabled(theGlobalPainter.getDrawNodes());
60 GlobalNodesFixed->setEnabled(theGlobalPainter.getDrawNodes());
61 GlobalNodesProportional->setValue(theGlobalPainter.NodesProportional);
62 GlobalNodesFixed->setValue(theGlobalPainter.NodesFixed);
63
64 FreezeUpdate = false;
65
66 resize(1, 1);
67 }
68
updatePaintList()69 void PaintStyleEditor::updatePaintList()
70 {
71 QListWidgetItem* it;
72 QString curName;
73 if (PaintList->currentItem())
74 curName = PaintList->currentItem()->text();
75 PaintList->clear();
76 for (int i = 0; i < thePainters.size(); ++i) {
77 it = new QListWidgetItem(thePainters[i].userName());
78 it->setData(Qt::UserRole, i);
79 if (edFilter->text().isEmpty()) {
80 PaintList->addItem(it);
81 } else
82 if (thePainters[i].userName().contains(edFilter->text(), Qt::CaseInsensitive)) {
83 it = new QListWidgetItem(thePainters[i].userName());
84 it->setData(Qt::UserRole, i);
85 PaintList->addItem(it);
86 }
87 if (!curName.isEmpty() && thePainters[i].userName().contains(curName, Qt::CaseInsensitive))
88 PaintList->setCurrentItem(it);
89 }
90 if (curName.isEmpty())
91 PaintList->setCurrentRow(0);
92 }
93
on_AddButton_clicked()94 void PaintStyleEditor::on_AddButton_clicked()
95 {
96 thePainters.push_back(FeaturePainter());
97 QListWidgetItem* it = new QListWidgetItem(thePainters[thePainters.size()-1].userName());
98 it->setData(Qt::UserRole, thePainters.size()-1);
99 PaintList->addItem(it);
100 PaintList->setCurrentItem(it);
101 on_PaintList_itemSelectionChanged();
102 }
103
on_DuplicateButton_clicked()104 void PaintStyleEditor::on_DuplicateButton_clicked()
105 {
106 QListWidgetItem* it = PaintList->currentItem();
107 int idx = it->data(Qt::UserRole).toInt();
108
109 if (idx < 0 || idx >= thePainters.size())
110 return;
111 //QList<FeaturePainter>::iterator theIterator = thePainters.begin();
112 thePainters.insert(thePainters.begin() + idx, Painter(thePainters[idx]));
113 idx++;
114 it = new QListWidgetItem(thePainters[idx].userName());
115 it->setData(Qt::UserRole, idx);
116 PaintList->insertItem(PaintList->currentRow()+1, it);
117 PaintList->setCurrentItem(it);
118 on_PaintList_itemSelectionChanged();
119 }
120
on_RemoveButton_clicked()121 void PaintStyleEditor::on_RemoveButton_clicked()
122 {
123 FreezeUpdate = true;
124 QListWidgetItem* it = PaintList->currentItem();
125 int idx = it->data(Qt::UserRole).toInt();
126
127 if (idx < 0 || idx >= thePainters.size())
128 return;
129 thePainters.erase(thePainters.begin() + idx);
130 delete PaintList->takeItem(idx);
131
132 if (idx && (idx >= thePainters.size()))
133 --idx;
134 PaintList->setCurrentRow(idx);
135 updatePaintList();
136 on_PaintList_itemSelectionChanged();
137 }
138
on_btUp_clicked()139 void PaintStyleEditor::on_btUp_clicked()
140 {
141 if (PaintList->currentRow() <= 0)
142 return;
143
144 int idx = PaintList->item(PaintList->currentRow())->data(Qt::UserRole).toInt();
145 int idxup = PaintList->item(PaintList->currentRow()-1)->data(Qt::UserRole).toInt();
146
147 Painter fp = thePainters[idxup];
148 thePainters[idxup] = thePainters[idx];
149 thePainters[idx] = fp;
150 PaintList->item(PaintList->currentRow()-1)->setText(thePainters[idxup].userName());
151 PaintList->item(PaintList->currentRow())->setText(thePainters[idx].userName());
152 PaintList->setCurrentRow(PaintList->currentRow()-1);
153 }
154
on_btDown_clicked()155 void PaintStyleEditor::on_btDown_clicked()
156 {
157 if (PaintList->currentRow() >= PaintList->count()-1)
158 return;
159
160 int idx = PaintList->item(PaintList->currentRow())->data(Qt::UserRole).toInt();
161 int idxdn = PaintList->item(PaintList->currentRow()+1)->data(Qt::UserRole).toInt();
162
163 Painter fp = thePainters[idxdn];
164 thePainters[idxdn] = thePainters[idx];
165 thePainters[idx] = fp;
166 PaintList->item(PaintList->currentRow()+1)->setText(thePainters[idxdn].userName());
167 PaintList->item(PaintList->currentRow())->setText(thePainters[idx].userName());
168 PaintList->setCurrentRow(PaintList->currentRow()+1);
169 }
170
on_PaintList_itemSelectionChanged()171 void PaintStyleEditor::on_PaintList_itemSelectionChanged()
172 {
173 QListWidgetItem* it = PaintList->currentItem();
174
175 int idx = -1;
176 if (it)
177 idx = it->data(Qt::UserRole).toInt();
178
179 if (idx < 0) {
180 FreezeUpdate = false;
181
182 editArea->setEnabled(false);
183 DuplicateButton->setEnabled(false);
184 RemoveButton->setEnabled(false);
185 return;
186 } else {
187 editArea->setEnabled(true);
188 DuplicateButton->setEnabled(true);
189 RemoveButton->setEnabled(true);
190 }
191 if (idx >= thePainters.size())
192 return;
193
194 FreezeUpdate = true;
195 Painter& FP(thePainters[idx]);
196 TagSelection->setText(FP.userName());
197 if (FP.zoomBoundaries().first == 0)
198 LowerZoomBoundary->setValue(0);
199 else
200 LowerZoomBoundary->setValue(1 / FP.zoomBoundaries().first);
201 if ((FP.zoomBoundaries().second == 0) || (FP.zoomBoundaries().second > 10e5))
202 UpperZoomBoundary->setValue(0);
203 else
204 UpperZoomBoundary->setValue(1 / FP.zoomBoundaries().second);
205 DrawBackground->setChecked(FP.backgroundBoundary().Draw);
206 ProportionalBackground->setValue(FP.backgroundBoundary().Proportional);
207 FixedBackground->setValue(FP.backgroundBoundary().Fixed);
208 makeBoundaryIcon(BackgroundColor, FP.backgroundBoundary().Color);
209 BackgroundInterior->setChecked(FP.getBackgroundInterior());
210 BackgroundExterior->setChecked(FP.getBackgroundExterior());
211 DrawForeground->setChecked(FP.foregroundBoundary().Draw);
212 ProportionalForeground->setValue(FP.foregroundBoundary().Proportional);
213 FixedForeground->setValue(FP.foregroundBoundary().Fixed);
214 makeBoundaryIcon(ForegroundColor, FP.foregroundBoundary().Color);
215 ForegroundDashed->setChecked(FP.foregroundBoundary().Dashed);
216 ForegroundDashOn->setValue(FP.foregroundBoundary().DashOn);
217 ForegroundDashOff->setValue(FP.foregroundBoundary().DashOff);
218 DrawTouchup->setChecked(FP.touchupBoundary().Draw);
219 ProportionalTouchup->setValue(FP.touchupBoundary().Proportional);
220 FixedTouchup->setValue(FP.touchupBoundary().Fixed);
221 makeBoundaryIcon(TouchupColor, FP.touchupBoundary().Color);
222 TouchupDashed->setChecked(FP.touchupBoundary().Dashed);
223 TouchupDashOn->setValue(FP.touchupBoundary().DashOn);
224 TouchupDashOff->setValue(FP.touchupBoundary().DashOff);
225 DrawTrafficDirectionMarks->setChecked(FP.DrawTrafficDirectionMarks);
226 makeBoundaryIcon(TrafficDirectionMarksColor, FP.TrafficDirectionMarksColor);
227 DrawFill->setChecked(FP.fillColor().isValid());
228 makeBoundaryIcon(FillColor, FP.fillColor());
229 DrawFillIcon->setChecked(FP.ForegroundFillUseIcon);;
230 DrawIcon->setChecked(FP.icon().Draw);
231 IconName->setText(FP.icon().Name);
232 ProportionalIcon->setValue(FP.icon().Proportional);
233 FixedIcon->setValue(FP.icon().Fixed);
234 DrawLabel->setChecked(FP.labelBoundary().Draw);
235 makeBoundaryIcon(LabelColor, FP.labelBoundary().Color);
236 ProportionalLabel->setValue(FP.labelBoundary().Proportional);
237 FixedLabel->setValue(FP.labelBoundary().Fixed);
238 DrawLabelBackground->setChecked(FP.labelBackgroundColor().isValid());
239 makeBoundaryIcon(LabelBackgroundlColor, FP.labelBackgroundColor());
240 LabelFont->setCurrentFont(FP.getLabelFont());
241 LabelTag->setText(FP.getLabelTag());
242 LabelBackgroundTag->setText(FP.getLabelBackgroundTag());
243 LabelHalo->setChecked(FP.getLabelHalo());
244 LabelArea->setChecked(FP.getLabelArea());
245
246 updatePagesIcons();
247
248 FreezeUpdate = false;
249 }
250
updatePagesIcons()251 void PaintStyleEditor::updatePagesIcons()
252 {
253 if (DrawForeground->isChecked() || DrawFill->isChecked())
254 tbStyle->setItemIcon(0, QIcon(":/Icons/actions/software-update-available.png"));
255 else
256 tbStyle->setItemIcon(0, QIcon());
257
258 if (DrawBackground->isChecked())
259 tbStyle->setItemIcon(1, QIcon(":/Icons/actions/software-update-available.png"));
260 else
261 tbStyle->setItemIcon(1, QIcon());
262
263 if (DrawTouchup->isChecked() || DrawIcon->isChecked())
264 tbStyle->setItemIcon(2, QIcon(":/Icons/actions/software-update-available.png"));
265 else
266 tbStyle->setItemIcon(2, QIcon());
267
268 if (DrawLabel->isChecked())
269 tbStyle->setItemIcon(3, QIcon(":/Icons/actions/software-update-available.png"));
270 else
271 tbStyle->setItemIcon(3, QIcon());
272 }
273
on_TagSelection_editingFinished()274 void PaintStyleEditor::on_TagSelection_editingFinished()
275 {
276 refreshPainter();
277 }
278
on_LowerZoomBoundary_valueChanged()279 void PaintStyleEditor::on_LowerZoomBoundary_valueChanged()
280 {
281 if (FreezeUpdate)
282 return;
283 QListWidgetItem* it = PaintList->currentItem();
284 int idx = it->data(Qt::UserRole).toInt();
285
286 if (idx >= thePainters.size())
287 return;
288 Painter& FP(thePainters[idx]);
289 QPair<qreal, qreal> Result(0, 0);
290 if (LowerZoomBoundary->value() > 10e-6)
291 Result.first = 1 / LowerZoomBoundary->value();
292 if (UpperZoomBoundary->value() > 10e-6)
293 Result.second = 1 / UpperZoomBoundary->value();
294 else
295 Result.second = 10e6;
296 FP.zoomBoundary(Result.first, Result.second);
297 }
298
on_UpperZoomBoundary_valueChanged()299 void PaintStyleEditor::on_UpperZoomBoundary_valueChanged()
300 {
301 on_LowerZoomBoundary_valueChanged();
302 }
303
on_DrawGlobalBackground_clicked(bool b)304 void PaintStyleEditor::on_DrawGlobalBackground_clicked(bool b)
305 {
306 theGlobalPainter.backgroundActive(b);
307 }
308
on_GlobalBackgroundColor_clicked()309 void PaintStyleEditor::on_GlobalBackgroundColor_clicked()
310 {
311 QColor rgb = QColorDialog::getColor(theGlobalPainter.getBackgroundColor(), this
312 #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0))
313 , tr("Select Color"), QColorDialog::ShowAlphaChannel
314 #endif
315 );
316 if (rgb.isValid()) {
317 makeBoundaryIcon(GlobalBackgroundColor, rgb);
318 theGlobalPainter.background(rgb);
319 }
320 }
321
on_DrawGlobalNodes_clicked(bool b)322 void PaintStyleEditor::on_DrawGlobalNodes_clicked(bool b)
323 {
324 theGlobalPainter.nodesActive(b);
325 }
326
on_GlobalNodesColor_clicked()327 void PaintStyleEditor::on_GlobalNodesColor_clicked()
328 {
329 QColor rgb = QColorDialog::getColor(theGlobalPainter.getNodesColor(), this
330 #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0))
331 , tr("Select Color"), QColorDialog::ShowAlphaChannel
332 #endif
333 );
334 if (rgb.isValid()) {
335 makeBoundaryIcon(GlobalNodesColor, rgb);
336 theGlobalPainter.nodes(rgb);
337 }
338 }
339
on_GlobalNodesProportional_valueChanged()340 void PaintStyleEditor::on_GlobalNodesProportional_valueChanged()
341 {
342 theGlobalPainter.NodesProportional = GlobalNodesProportional->value();
343 }
344
on_GlobalNodesFixed_valueChanged()345 void PaintStyleEditor::on_GlobalNodesFixed_valueChanged()
346 {
347 theGlobalPainter.NodesFixed = GlobalNodesFixed->value();
348 }
349
on_DrawBackground_clicked(bool b)350 void PaintStyleEditor::on_DrawBackground_clicked(bool b)
351 {
352 QListWidgetItem* it = PaintList->currentItem();
353 int idx = it->data(Qt::UserRole).toInt();
354
355 if (idx >= thePainters.size())
356 return;
357 thePainters[idx].backgroundActive(b);
358
359 updatePagesIcons();
360 }
361
on_BackgroundColor_clicked()362 void PaintStyleEditor::on_BackgroundColor_clicked()
363 {
364 QListWidgetItem* it = PaintList->currentItem();
365 int idx = it->data(Qt::UserRole).toInt();
366
367 if (idx >= thePainters.size())
368 return;
369 Painter& FP(thePainters[idx]);
370 QColor rgb = QColorDialog::getColor(FP.backgroundBoundary().Color, this
371 #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0))
372 , tr("Select Color"), QColorDialog::ShowAlphaChannel
373 #endif
374 );
375 if (rgb.isValid()) {
376 makeBoundaryIcon(BackgroundColor, rgb);
377 FP.background(rgb, ProportionalBackground->value(), FixedBackground->value());
378 }
379 }
380
on_ProportionalBackground_valueChanged()381 void PaintStyleEditor::on_ProportionalBackground_valueChanged()
382 {
383 if (FreezeUpdate)
384 return;
385 QListWidgetItem* it = PaintList->currentItem();
386 int idx = it->data(Qt::UserRole).toInt();
387
388 if (idx >= thePainters.size())
389 return;
390 Painter& FP(thePainters[idx]);
391 FP.background(FP.backgroundBoundary().Color, ProportionalBackground->value(), FixedBackground->value());
392 }
393
on_FixedBackground_valueChanged()394 void PaintStyleEditor::on_FixedBackground_valueChanged()
395 {
396 on_ProportionalBackground_valueChanged();
397 }
398
on_DrawForeground_clicked(bool b)399 void PaintStyleEditor::on_DrawForeground_clicked(bool b)
400 {
401 QListWidgetItem* it = PaintList->currentItem();
402 int idx = it->data(Qt::UserRole).toInt();
403
404 if (idx >= thePainters.size())
405 return;
406 thePainters[idx].foregroundActive(b);
407
408 updatePagesIcons();
409 }
410
on_BackgroundInterior_clicked(bool b)411 void PaintStyleEditor::on_BackgroundInterior_clicked(bool b)
412 {
413 QListWidgetItem* it = PaintList->currentItem();
414 int idx = it->data(Qt::UserRole).toInt();
415
416 if (idx >= thePainters.size())
417 return;
418 thePainters[idx].BackgroundInterior = b;
419
420 if (b) {
421 BackgroundExterior->blockSignals(true);
422 BackgroundExterior->setChecked(false);
423 thePainters[idx].BackgroundExterior = false;
424 BackgroundExterior->blockSignals(false);
425 }
426 }
427
on_BackgroundExterior_clicked(bool b)428 void PaintStyleEditor::on_BackgroundExterior_clicked(bool b)
429 {
430 QListWidgetItem* it = PaintList->currentItem();
431 int idx = it->data(Qt::UserRole).toInt();
432
433 if (idx >= thePainters.size())
434 return;
435 thePainters[idx].BackgroundExterior = b;
436
437 if (b) {
438 BackgroundInterior->blockSignals(true);
439 BackgroundInterior->setChecked(false);
440 thePainters[idx].BackgroundInterior = false;
441 BackgroundInterior->blockSignals(false);
442 }
443 }
444
on_ForegroundColor_clicked()445 void PaintStyleEditor::on_ForegroundColor_clicked()
446 {
447 QListWidgetItem* it = PaintList->currentItem();
448 int idx = it->data(Qt::UserRole).toInt();
449
450 if (idx >= thePainters.size())
451 return;
452 Painter& FP(thePainters[idx]);
453 QColor rgb = QColorDialog::getColor(FP.foregroundBoundary().Color, this
454 #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0))
455 , tr("Select Color"), QColorDialog::ShowAlphaChannel
456 #endif
457 );
458 if (rgb.isValid()) {
459 makeBoundaryIcon(ForegroundColor, rgb);
460 FP.foreground(rgb, ProportionalForeground->value(), FixedForeground->value());
461 }
462 }
463
on_DrawFillIcon_clicked(bool b)464 void PaintStyleEditor::on_DrawFillIcon_clicked(bool b)
465 {
466 QListWidgetItem* it = PaintList->currentItem();
467 int idx = it->data(Qt::UserRole).toInt();
468
469 if (idx >= thePainters.size())
470 return;
471 Painter& FP(thePainters[idx]);
472
473 FP.ForegroundFillUseIcon = b;
474 }
475
on_ProportionalForeground_valueChanged()476 void PaintStyleEditor::on_ProportionalForeground_valueChanged()
477 {
478 if (FreezeUpdate)
479 return;
480 QListWidgetItem* it = PaintList->currentItem();
481 int idx = it->data(Qt::UserRole).toInt();
482
483 if (idx >= thePainters.size())
484 return;
485 Painter& FP(thePainters[idx]);
486 FP.foreground(FP.foregroundBoundary().Color, ProportionalForeground->value(), FixedForeground->value());
487 }
488
on_FixedForeground_valueChanged()489 void PaintStyleEditor::on_FixedForeground_valueChanged()
490 {
491 on_ProportionalForeground_valueChanged();
492 }
493
494
on_ForegroundDashed_clicked()495 void PaintStyleEditor::on_ForegroundDashed_clicked()
496 {
497 if (FreezeUpdate)
498 return;
499 QListWidgetItem* it = PaintList->currentItem();
500 int idx = it->data(Qt::UserRole).toInt();
501
502 if (idx >= thePainters.size())
503 return;
504 Painter& FP(thePainters[idx]);
505 if (ForegroundDashed->isChecked())
506 FP.foregroundDash(ForegroundDashOn->value(), ForegroundDashOff->value());
507 else
508 FP.clearForegroundDash();
509 }
510
on_ForegroundDashOff_valueChanged()511 void PaintStyleEditor::on_ForegroundDashOff_valueChanged()
512 {
513 on_ForegroundDashed_clicked();
514 }
515
on_ForegroundDashOn_valueChanged()516 void PaintStyleEditor::on_ForegroundDashOn_valueChanged()
517 {
518 on_ForegroundDashed_clicked();
519 }
520
on_DrawTouchup_clicked(bool b)521 void PaintStyleEditor::on_DrawTouchup_clicked(bool b)
522 {
523 QListWidgetItem* it = PaintList->currentItem();
524 int idx = it->data(Qt::UserRole).toInt();
525
526 if (idx >= thePainters.size())
527 return;
528 thePainters[idx].touchupActive(b);
529
530 updatePagesIcons();
531 }
532
on_TouchupColor_clicked()533 void PaintStyleEditor::on_TouchupColor_clicked()
534 {
535 QListWidgetItem* it = PaintList->currentItem();
536 int idx = it->data(Qt::UserRole).toInt();
537
538 if (idx >= thePainters.size())
539 return;
540 Painter& FP(thePainters[idx]);
541 QColor rgb = QColorDialog::getColor(FP.touchupBoundary().Color, this
542 #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0))
543 , tr("Select Color"), QColorDialog::ShowAlphaChannel
544 #endif
545 );
546 if (rgb.isValid()) {
547 makeBoundaryIcon(TouchupColor, rgb);
548 FP.touchup(rgb, ProportionalTouchup->value(), FixedTouchup->value());
549 }
550 }
551
on_DrawTrafficDirectionMarks_clicked(bool b)552 void PaintStyleEditor::on_DrawTrafficDirectionMarks_clicked(bool b)
553 {
554 QListWidgetItem* it = PaintList->currentItem();
555 int idx = it->data(Qt::UserRole).toInt();
556
557 if (idx >= thePainters.size())
558 return;
559 thePainters[idx].drawTrafficDirectionMarks(b);
560
561 updatePagesIcons();
562 }
563
on_TrafficDirectionMarksColor_clicked()564 void PaintStyleEditor::on_TrafficDirectionMarksColor_clicked()
565 {
566 QListWidgetItem* it = PaintList->currentItem();
567 int idx = it->data(Qt::UserRole).toInt();
568
569 if (idx >= thePainters.size())
570 return;
571 Painter& FP(thePainters[idx]);
572 QColor rgb = QColorDialog::getColor(FP.TrafficDirectionMarksColor, this
573 #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0))
574 , tr("Select Color"), QColorDialog::ShowAlphaChannel
575 #endif
576 );
577 if (rgb.isValid()) {
578 makeBoundaryIcon(TrafficDirectionMarksColor, rgb);
579 FP.TrafficDirectionMarksColor = rgb;
580 }
581 }
582
on_ProportionalTouchup_valueChanged()583 void PaintStyleEditor::on_ProportionalTouchup_valueChanged()
584 {
585 if (FreezeUpdate)
586 return;
587 QListWidgetItem* it = PaintList->currentItem();
588 int idx = it->data(Qt::UserRole).toInt();
589
590 if (idx >= thePainters.size())
591 return;
592 Painter& FP(thePainters[idx]);
593 FP.touchup(FP.touchupBoundary().Color, ProportionalTouchup->value(), FixedTouchup->value());
594 }
595
on_FixedTouchup_valueChanged()596 void PaintStyleEditor::on_FixedTouchup_valueChanged()
597 {
598 on_ProportionalTouchup_valueChanged();
599 }
600
601
on_TouchupDashed_clicked()602 void PaintStyleEditor::on_TouchupDashed_clicked()
603 {
604 if (FreezeUpdate)
605 return;
606 QListWidgetItem* it = PaintList->currentItem();
607 int idx = it->data(Qt::UserRole).toInt();
608
609 if (idx >= thePainters.size())
610 return;
611 Painter& FP(thePainters[idx]);
612 if (TouchupDashed->isChecked())
613 FP.touchupDash(TouchupDashOn->value(), TouchupDashOff->value());
614 else
615 FP.clearTouchupDash();
616 }
617
on_TouchupDashOff_valueChanged()618 void PaintStyleEditor::on_TouchupDashOff_valueChanged()
619 {
620 on_TouchupDashed_clicked();
621 }
622
on_TouchupDashOn_valueChanged()623 void PaintStyleEditor::on_TouchupDashOn_valueChanged()
624 {
625 on_TouchupDashed_clicked();
626 }
627
on_DrawFill_clicked(bool b)628 void PaintStyleEditor::on_DrawFill_clicked(bool b)
629 {
630 QListWidgetItem* it = PaintList->currentItem();
631 int idx = it->data(Qt::UserRole).toInt();
632
633 if (idx >= thePainters.size())
634 return;
635 thePainters[idx].fillActive(b);
636
637 updatePagesIcons();
638 }
639
on_FillColor_clicked()640 void PaintStyleEditor::on_FillColor_clicked()
641 {
642 QListWidgetItem* it = PaintList->currentItem();
643 int idx = it->data(Qt::UserRole).toInt();
644
645 if (idx >= thePainters.size())
646 return;
647 Painter& FP(thePainters[idx]);
648 QColor rgb = QColorDialog::getColor(FP.fillColor(), this
649 #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0))
650 , tr("Select Color"), QColorDialog::ShowAlphaChannel
651 #endif
652 );
653 if (rgb.isValid()) {
654 makeBoundaryIcon(FillColor, rgb);
655 FP.foregroundFill(rgb);
656 }
657 }
658
on_DrawIcon_clicked(bool b)659 void PaintStyleEditor::on_DrawIcon_clicked(bool b)
660 {
661 QListWidgetItem* it = PaintList->currentItem();
662 int idx = it->data(Qt::UserRole).toInt();
663
664 if (idx >= thePainters.size())
665 return;
666 thePainters[idx].iconActive(b);
667
668 updatePagesIcons();
669 }
670
on_IconName_textEdited()671 void PaintStyleEditor::on_IconName_textEdited()
672 {
673 if (FreezeUpdate)
674 return;
675 QListWidgetItem* it = PaintList->currentItem();
676 int idx = it->data(Qt::UserRole).toInt();
677
678 if (idx >= thePainters.size())
679 return;
680 Painter& FP(thePainters[idx]);
681 FP.setIcon(IconName->text(), ProportionalIcon->value(), FixedIcon->value());
682 }
683
on_ProportionalIcon_valueChanged()684 void PaintStyleEditor::on_ProportionalIcon_valueChanged()
685 {
686 on_IconName_textEdited();
687 }
688
on_FixedIcon_valueChanged()689 void PaintStyleEditor::on_FixedIcon_valueChanged()
690 {
691 on_IconName_textEdited();
692 }
693
on_DrawLabel_clicked(bool b)694 void PaintStyleEditor::on_DrawLabel_clicked(bool b)
695 {
696 QListWidgetItem* it = PaintList->currentItem();
697 int idx = it->data(Qt::UserRole).toInt();
698
699 if (idx >= thePainters.size())
700 return;
701 thePainters[idx].labelActive(b);
702
703 updatePagesIcons();
704 }
705
on_LabelHalo_clicked(bool b)706 void PaintStyleEditor::on_LabelHalo_clicked(bool b)
707 {
708 QListWidgetItem* it = PaintList->currentItem();
709 int idx = it->data(Qt::UserRole).toInt();
710
711 if (idx >= thePainters.size())
712 return;
713 thePainters[idx].labelHalo(b);
714 }
715
on_LabelArea_clicked(bool b)716 void PaintStyleEditor::on_LabelArea_clicked(bool b)
717 {
718 QListWidgetItem* it = PaintList->currentItem();
719 int idx = it->data(Qt::UserRole).toInt();
720
721 if (idx >= thePainters.size())
722 return;
723 thePainters[idx].labelArea(b);
724 }
725
on_LabelTag_textEdited()726 void PaintStyleEditor::on_LabelTag_textEdited()
727 {
728 QListWidgetItem* it = PaintList->currentItem();
729 int idx = it->data(Qt::UserRole).toInt();
730
731 if (idx >= thePainters.size())
732 return;
733 thePainters[idx].labelTag(LabelTag->text());
734 }
735
on_LabelBackgroundTag_textEdited()736 void PaintStyleEditor::on_LabelBackgroundTag_textEdited()
737 {
738 QListWidgetItem* it = PaintList->currentItem();
739 int idx = it->data(Qt::UserRole).toInt();
740
741 if (idx >= thePainters.size())
742 return;
743 thePainters[idx].labelBackgroundTag(LabelBackgroundTag->text());
744 }
745
on_LabelColor_clicked()746 void PaintStyleEditor::on_LabelColor_clicked()
747 {
748 QListWidgetItem* it = PaintList->currentItem();
749 int idx = it->data(Qt::UserRole).toInt();
750
751 if (idx >= thePainters.size())
752 return;
753 Painter& FP(thePainters[idx]);
754 QColor rgb = QColorDialog::getColor(FP.labelBoundary().Color, this
755 #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0))
756 , tr("Select Color"), QColorDialog::ShowAlphaChannel
757 #endif
758 );
759 if (rgb.isValid()) {
760 makeBoundaryIcon(LabelColor, rgb);
761 FP.label(rgb, ProportionalLabel->value(), FixedLabel->value());
762 }
763 }
764
on_ProportionalLabel_valueChanged()765 void PaintStyleEditor::on_ProportionalLabel_valueChanged()
766 {
767 if (FreezeUpdate)
768 return;
769 QListWidgetItem* it = PaintList->currentItem();
770 int idx = it->data(Qt::UserRole).toInt();
771
772 if (idx >= thePainters.size())
773 return;
774 Painter& FP(thePainters[idx]);
775 FP.label(FP.labelBoundary().Color, ProportionalLabel->value(), FixedLabel->value());
776 }
777
on_FixedLabel_valueChanged()778 void PaintStyleEditor::on_FixedLabel_valueChanged()
779 {
780 on_ProportionalLabel_valueChanged();
781 }
782
on_DrawLabelBackground_clicked(bool b)783 void PaintStyleEditor::on_DrawLabelBackground_clicked(bool b)
784 {
785 QListWidgetItem* it = PaintList->currentItem();
786 int idx = it->data(Qt::UserRole).toInt();
787
788 if (idx >= thePainters.size())
789 return;
790 thePainters[idx].labelBackgroundActive(b);
791 }
792
on_LabelBackgroundlColor_clicked()793 void PaintStyleEditor::on_LabelBackgroundlColor_clicked()
794 {
795 QListWidgetItem* it = PaintList->currentItem();
796 int idx = it->data(Qt::UserRole).toInt();
797
798 if (idx >= thePainters.size())
799 return;
800 Painter& FP(thePainters[idx]);
801 QColor rgb = QColorDialog::getColor(FP.labelBackgroundColor(), this
802 #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0))
803 , tr("Select Color"), QColorDialog::ShowAlphaChannel
804 #endif
805 );
806 if (rgb.isValid()) {
807 makeBoundaryIcon(LabelBackgroundlColor, rgb);
808 FP.labelBackground(rgb);
809 }
810 }
811
on_LabelFont_currentFontChanged(const QFont & font)812 void PaintStyleEditor::on_LabelFont_currentFontChanged(const QFont & font)
813 {
814 QListWidgetItem* it = PaintList->currentItem();
815 int idx = it->data(Qt::UserRole).toInt();
816
817 if (idx >= thePainters.size())
818 return;
819 thePainters[idx].setLabelFont(font.toString());
820 }
821
refreshPainter()822 void PaintStyleEditor::refreshPainter()
823 {
824 QListWidgetItem* it = PaintList->currentItem();
825 int idx = it->data(Qt::UserRole).toInt();
826 if (idx >= thePainters.size())
827 return;
828 Painter& FP(thePainters[idx]);
829 FP.setSelector(TagSelection->text());
830 PaintList->currentItem()->setText(FP.userName());
831 }
832
on_buttonBox_clicked(QAbstractButton * button)833 void PaintStyleEditor::on_buttonBox_clicked(QAbstractButton * button)
834 {
835 if (buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole) {
836 emit(stylesApplied(&theGlobalPainter, &thePainters));
837 }
838 }
839
on_edFilter_textChanged(const QString &)840 void PaintStyleEditor::on_edFilter_textChanged(const QString &/*text*/)
841 {
842 updatePaintList();
843 }
844
on_btSelectorHelper_clicked()845 void PaintStyleEditor::on_btSelectorHelper_clicked()
846 {
847 SelectionDialog* Sel = new SelectionDialog(g_Merk_MainWindow, false);
848 if (!Sel)
849 return;
850
851 Sel->edTagQuery->setText(TagSelection->text());
852 if (Sel->exec() == QDialog::Accepted) {
853 TagSelection->setText(Sel->edTagQuery->text());
854 }
855 }
856