src/widgets/colorindexinput.cpp

changeset 205
1a4342d80de7
parent 200
ca23936b455b
child 214
8e1fe64ce4e3
equal deleted inserted replaced
204:52e10e8d88cc 205:1a4342d80de7
1 #include "colorindexinput.h" 1 #include "colorindexinput.h"
2 #include "ui_colorindexinput.h" 2 #include "ui_colorindexinput.h"
3 #include "colorselectdialog.h" 3 #include "colorselectdialog.h"
4 #include "uiutilities.h" 4 #include "uiutilities.h"
5 5
6 ColorIndexInput::ColorIndexInput(EditorTabWidget *document, ldraw::Color color, QWidget *parent) : 6 ColorIndexInput::ColorIndexInput(EditorTabWidget *document, ColorIndex color, QWidget *parent) :
7 QWidget{parent}, 7 QWidget{parent},
8 document{document}, 8 document{document},
9 ui{*new Ui_ColorIndexInput} 9 ui{*new Ui_ColorIndexInput}
10 { 10 {
11 this->ui.setupUi(this); 11 this->ui.setupUi(this);
18 this->ui.index->setValue(dialog.currentColor().index); 18 this->ui.index->setValue(dialog.currentColor().index);
19 } 19 }
20 }); 20 });
21 connect(this->ui.index, qOverload<int>(&QSpinBox::valueChanged), [this](int value) 21 connect(this->ui.index, qOverload<int>(&QSpinBox::valueChanged), [this](int value)
22 { 22 {
23 this->ui.button->setText(ldraw::colorDisplayName({value}, this->document->colorTable)); 23 this->ui.button->setText(colorDisplayName({value}, this->document->colorTable).value_or("???"));
24 uiutilities::colorizeWidget(this->ui.button, ldraw::colorFace({value}, this->document->colorTable)); 24 const opt<QColor> face = colorFace({value}, this->document->colorTable);
25 if (face.has_value()) {
26 uiutilities::colorizeWidget(this->ui.button, *face);
27 }
25 Q_EMIT this->colorChanged({value}); 28 Q_EMIT this->colorChanged({value});
26 }); 29 });
27 this->ui.index->setValue(color.index); 30 this->ui.index->setValue(color.index);
28 } 31 }
29 32

mercurial