src/widgets/colorindexinput.cpp

changeset 205
1a4342d80de7
parent 200
ca23936b455b
child 214
8e1fe64ce4e3
--- a/src/widgets/colorindexinput.cpp	Wed Jun 08 19:33:00 2022 +0300
+++ b/src/widgets/colorindexinput.cpp	Wed Jun 08 20:41:21 2022 +0300
@@ -3,7 +3,7 @@
 #include "colorselectdialog.h"
 #include "uiutilities.h"
 
-ColorIndexInput::ColorIndexInput(EditorTabWidget *document, ldraw::Color color, QWidget *parent) :
+ColorIndexInput::ColorIndexInput(EditorTabWidget *document, ColorIndex color, QWidget *parent) :
 	QWidget{parent},
 	document{document},
 	ui{*new Ui_ColorIndexInput}
@@ -20,8 +20,11 @@
 	});
 	connect(this->ui.index, qOverload<int>(&QSpinBox::valueChanged), [this](int value)
 	{
-		this->ui.button->setText(ldraw::colorDisplayName({value}, this->document->colorTable));
-		uiutilities::colorizeWidget(this->ui.button, ldraw::colorFace({value}, this->document->colorTable));
+		this->ui.button->setText(colorDisplayName({value}, this->document->colorTable).value_or("???"));
+		const opt<QColor> face = colorFace({value}, this->document->colorTable);
+		if (face.has_value()) {
+			uiutilities::colorizeWidget(this->ui.button, *face);
+		}
 		Q_EMIT this->colorChanged({value});
 	});
 	this->ui.index->setValue(color.index);

mercurial