|
4 | 4 | #include <QPainter> |
5 | 5 | #include "PaletteDialog.h" |
6 | 6 | #include "Convert.h" |
| 7 | +#include "VDPDataStore.h" |
7 | 8 | #include "ranges.h" |
8 | 9 |
|
9 | 10 |
|
@@ -40,14 +41,12 @@ void PalettePatch::setHighlightTest(int colorNr) |
40 | 41 |
|
41 | 42 | void PalettePatch::paintEvent(QPaintEvent* /*event*/) |
42 | 43 | { |
43 | | - QPainter painter(this); |
44 | | - painter.setPen(isSelected ? Qt::white : QColor(myColor)); |
45 | | - painter.setBrush(QBrush(myColor)); |
46 | | - painter.drawRect(0, 0, this->width() - 1, this->height() - 1); |
| 44 | + QPainter painter(this); |
| 45 | + painter.setPen(isSelected ? Qt::white : QColor(myColor)); |
| 46 | + painter.setBrush(QBrush(myColor)); |
| 47 | + painter.drawRect(0, 0, this->width() - 1, this->height() - 1); |
47 | 48 | } |
48 | 49 |
|
49 | | - |
50 | | - |
51 | 50 | PaletteDialog::PaletteDialog(QWidget* parent) |
52 | 51 | : QDialog(parent), ui(std::make_unique<Ui::PaletteDialog>()) |
53 | 52 | { |
@@ -172,6 +171,15 @@ void PaletteDialog::syncToSource() |
172 | 171 | emit paletteSynced(); |
173 | 172 | } |
174 | 173 |
|
| 174 | +void PaletteDialog::restoreDefaultPalette() |
| 175 | +{ |
| 176 | + memcpy(myPal, VDPDataStore::instance().getDefaultPalettePointer(), 32); |
| 177 | + emit paletteChanged(myPal); |
| 178 | + if (autoSync) { |
| 179 | + syncToSource(); |
| 180 | + } |
| 181 | +} |
| 182 | + |
175 | 183 | void PaletteDialog::setAutoSync(bool value) |
176 | 184 | { |
177 | 185 | if (autoSync == value) return; |
@@ -199,8 +207,9 @@ void PaletteDialog::on_horizontalSlider_B_valueChanged(int value) |
199 | 207 |
|
200 | 208 | void PaletteDialog::on_buttonBox_clicked(QAbstractButton* button) |
201 | 209 | { |
202 | | - if (button== ui->buttonBox->button(QDialogButtonBox::Apply) || |
203 | | - button== ui->buttonBox->button(QDialogButtonBox::Ok)) { |
| 210 | + if (button== ui->buttonBox->button(QDialogButtonBox::RestoreDefaults)) { |
| 211 | + restoreDefaultPalette(); |
| 212 | + } else if (button== ui->buttonBox->button(QDialogButtonBox::Ok)) { |
204 | 213 | syncToSource(); |
205 | 214 | } else if (button== ui->buttonBox->button(QDialogButtonBox::Reset) || |
206 | 215 | button== ui->buttonBox->button(QDialogButtonBox::Cancel)) { |
|
0 commit comments