src/widgets/colorindexinput.cpp

changeset 214
8e1fe64ce4e3
parent 205
1a4342d80de7
child 258
fe094d0687ad
--- a/src/widgets/colorindexinput.cpp	Sat Jun 11 15:20:24 2022 +0300
+++ b/src/widgets/colorindexinput.cpp	Sun Jun 12 20:47:04 2022 +0300
@@ -3,15 +3,15 @@
 #include "colorselectdialog.h"
 #include "uiutilities.h"
 
-ColorIndexInput::ColorIndexInput(EditorTabWidget *document, ColorIndex color, QWidget *parent) :
+ColorIndexInput::ColorIndexInput(ColorTable *colorTable, ColorIndex color, QWidget *parent) :
 	QWidget{parent},
-	document{document},
+	colorTable{colorTable},
 	ui{*new Ui_ColorIndexInput}
 {
 	this->ui.setupUi(this);
 	connect(this->ui.button, &QPushButton::clicked, [this]()
 	{
-		ColorSelectDialog dialog{this->document->colorTable, this->document};
+		ColorSelectDialog dialog{*this->colorTable, this};
 		const int result = dialog.exec();
 		if (result == QDialog::Accepted)
 		{
@@ -20,8 +20,9 @@
 	});
 	connect(this->ui.index, qOverload<int>(&QSpinBox::valueChanged), [this](int value)
 	{
-		this->ui.button->setText(colorDisplayName({value}, this->document->colorTable).value_or("???"));
-		const opt<QColor> face = colorFace({value}, this->document->colorTable);
+		const opt<QString> displayName = colorDisplayName({value}, *this->colorTable);
+		const opt<QColor> face = colorFace({value}, *this->colorTable);
+		this->ui.button->setText(displayName.value_or(tr("???")));
 		if (face.has_value()) {
 			uiutilities::colorizeWidget(this->ui.button, *face);
 		}

mercurial