Wed, 20 Jul 2022 21:48:46 +0300
Delete unused code
Remove Model legacy type alias, QTextDocument is used now instead
264
76a025db4948
Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
258
diff
changeset
|
1 | #include <ui_colorindexinput.h> |
76a025db4948
Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
258
diff
changeset
|
2 | #include "src/uiutilities.h" |
76a025db4948
Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
258
diff
changeset
|
3 | #include "src/widgets/colorindexinput.h" |
76a025db4948
Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
258
diff
changeset
|
4 | #include "src/widgets/colorselectdialog.h" |
178 | 5 | |
258
fe094d0687ad
Add widgets to object editor
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
6 | ColorIndexInput::ColorIndexInput(QWidget *parent) : |
178 | 7 | QWidget{parent}, |
8 | ui{*new Ui_ColorIndexInput} | |
9 | { | |
258
fe094d0687ad
Add widgets to object editor
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
10 | static const ColorTable emptyColorTable; |
fe094d0687ad
Add widgets to object editor
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
11 | this->colorTable = &emptyColorTable; |
178 | 12 | this->ui.setupUi(this); |
13 | connect(this->ui.button, &QPushButton::clicked, [this]() | |
14 | { | |
214
8e1fe64ce4e3
begin refactor of gl side
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
205
diff
changeset
|
15 | ColorSelectDialog dialog{*this->colorTable, this}; |
178 | 16 | const int result = dialog.exec(); |
17 | if (result == QDialog::Accepted) | |
18 | { | |
19 | this->ui.index->setValue(dialog.currentColor().index); | |
20 | } | |
21 | }); | |
22 | connect(this->ui.index, qOverload<int>(&QSpinBox::valueChanged), [this](int value) | |
23 | { | |
214
8e1fe64ce4e3
begin refactor of gl side
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
205
diff
changeset
|
24 | const opt<QString> displayName = colorDisplayName({value}, *this->colorTable); |
8e1fe64ce4e3
begin refactor of gl side
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
205
diff
changeset
|
25 | const opt<QColor> face = colorFace({value}, *this->colorTable); |
8e1fe64ce4e3
begin refactor of gl side
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
205
diff
changeset
|
26 | this->ui.button->setText(displayName.value_or(tr("???"))); |
205 | 27 | if (face.has_value()) { |
28 | uiutilities::colorizeWidget(this->ui.button, *face); | |
29 | } | |
178 | 30 | Q_EMIT this->colorChanged({value}); |
31 | }); | |
258
fe094d0687ad
Add widgets to object editor
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
214
diff
changeset
|
32 | this->ui.index->setValue(MAIN_COLOR.index); |
178 | 33 | } |
34 | ||
35 | ColorIndexInput::~ColorIndexInput() | |
36 | { | |
37 | delete &this->ui; | |
38 | } | |
39 | ||
40 | ldraw::Color ColorIndexInput::selectedColor() const | |
41 | { | |
42 | return {this->ui.index->value()}; | |
43 | } | |
44 | ||
45 | void ColorIndexInput::setSelectedColor(ldraw::Color color) | |
46 | { | |
47 | this->ui.index->setValue(color.index); | |
48 | } |