src/widgets/colorindexinput.cpp

Thu, 09 Jun 2022 11:51:42 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Thu, 09 Jun 2022 11:51:42 +0300
changeset 209
c93e4a1eaadb
parent 205
1a4342d80de7
child 214
8e1fe64ce4e3
permissions
-rw-r--r--

remove more dead code

#include "colorindexinput.h"
#include "ui_colorindexinput.h"
#include "colorselectdialog.h"
#include "uiutilities.h"

ColorIndexInput::ColorIndexInput(EditorTabWidget *document, ColorIndex color, QWidget *parent) :
	QWidget{parent},
	document{document},
	ui{*new Ui_ColorIndexInput}
{
	this->ui.setupUi(this);
	connect(this->ui.button, &QPushButton::clicked, [this]()
	{
		ColorSelectDialog dialog{this->document->colorTable, this->document};
		const int result = dialog.exec();
		if (result == QDialog::Accepted)
		{
			this->ui.index->setValue(dialog.currentColor().index);
		}
	});
	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);
		if (face.has_value()) {
			uiutilities::colorizeWidget(this->ui.button, *face);
		}
		Q_EMIT this->colorChanged({value});
	});
	this->ui.index->setValue(color.index);
}

ColorIndexInput::~ColorIndexInput()
{
	delete &this->ui;
}

ldraw::Color ColorIndexInput::selectedColor() const
{
	return {this->ui.index->value()};
}

void ColorIndexInput::setSelectedColor(ldraw::Color color)
{
	this->ui.index->setValue(color.index);
}

mercurial