Showing the changes to interface/src/Swatch.cpp (1 of 8 files). Show all
Unified · Split
| @@ -4,18 +4,30 @@ · 3 unmodified lines | |||
| 4 | Swatch::Swatch(QAction* action) : Tool(action, 0, -1, -1), | 4 | Swatch::Swatch(QAction* action) : Tool(action, 0, -1, -1), |
| 5 | _selected(1), | 5 | _selected(1), |
| 6 | _margin(4), | 6 | _margin(4), |
| 7 | _textRenderer(SANS_FONT_FAMILY, -1, 100) { | 7 | _textRenderer(MONO_FONT_FAMILY, 10, 100) { |
| 8 | _width = 62; | 8 | _width = 62; |
| 9 | _height = 30; | 9 | _height = 30; |
| 10 | } | ||
| 10 | 11 | ||
| 11 | _colors[0].setRgb(128, 128, 128); | 12 | void Swatch::reset() { |
| 12 | _colors[1].setRgb(255, 0, 0); | 13 | _colors[0].setRgb(237, 175, 0); |
| 13 | _colors[2].setRgb(0, 255, 0); | 14 | _colors[1].setRgb(161, 211, 72); |
| 14 | _colors[3].setRgb(0, 0, 255); | 15 | _colors[2].setRgb(51, 204, 204); |
| 15 | _colors[4].setRgb(255, 0, 255); | 16 | _colors[3].setRgb(63, 169, 245); |
| 16 | _colors[5].setRgb(255, 255, 0); | 17 | _colors[4].setRgb(193, 99, 122); |
| 17 | _colors[6].setRgb(0, 255, 255); | 18 | _colors[5].setRgb(255, 54, 69); |
| 18 | _colors[7].setRgb(0, 0, 0); | 19 | _colors[6].setRgb(124, 36, 36); |
| 20 | _colors[7].setRgb(63, 35, 19); | ||
| 21 | } | ||
| 22 | |||
| 23 | QColor Swatch::getColor() { | ||
| 24 | return _colors[_selected - 1]; | ||
| 25 | } | ||
| 26 | |||
| 27 | void Swatch::checkColor() { | ||
| 28 | if (_action->data().value<QColor>() == _colors[_selected - 1]) { | ||
| 29 | return; | ||
| 30 | } | ||
| 19 | 31 | ||
| 20 | QPixmap map(16, 16); | 32 | QPixmap map(16, 16); |
| 21 | map.fill(_colors[_selected - 1]); | 33 | map.fill(_colors[_selected - 1]); |
| @@ -23,15 +35,11 @@ Swatch::Swatch(QAction* action) : Tool(action, 0, -1, -1), · 1 unmodified line | |||
| 23 | _action->setIcon(map); | 35 | _action->setIcon(map); |
| 24 | } | 36 | } |
| 25 | 37 | ||
| 26 | QColor Swatch::getColor() { | ||
| 27 | return _colors[_selected - 1]; | ||
| 28 | } | ||
| 29 | |||
| 30 | void Swatch::saveData(QSettings* settings) { | 38 | void Swatch::saveData(QSettings* settings) { |
| 31 | settings->beginGroup("Swatch"); | 39 | settings->beginGroup("Swatch"); |
| 32 | 40 | ||
| 33 | for (int i(0); i < SWATCH_SIZE; ++i) { | 41 | for (int i(0); i < SWATCH_SIZE; ++i) { |
| 34 | QString name("R0"); | 42 | QString name("R1"); |
| 35 | name[1] = '1' + i; | 43 | name[1] = '1' + i; |
| 36 | settings->setValue(name, _colors[i].red()); | 44 | settings->setValue(name, _colors[i].red()); |
| 37 | name[0] = 'G'; | 45 | name[0] = 'G'; |
| @@ -45,33 +53,35 @@ void Swatch::saveData(QSettings* settings) { · 7 unmodified lines | |||
| 45 | 53 | ||
| 46 | void Swatch::loadData(QSettings* settings) { | 54 | void Swatch::loadData(QSettings* settings) { |
| 47 | settings->beginGroup("Swatch"); | 55 | settings->beginGroup("Swatch"); |
| 48 | 56 | ||
| 49 | _colors[0].setRgb(settings->value("R1", 128).toInt(), | 57 | _colors[0].setRgb(settings->value("R1", 237).toInt(), |
| 50 | settings->value("G1", 128).toInt(), | 58 | settings->value("G1", 175).toInt(), |
| 51 | settings->value("B1", 128).toInt()); | 59 | settings->value("B1", 0).toInt()); |
| 52 | _colors[1].setRgb(settings->value("R2", 128).toInt(), | 60 | _colors[1].setRgb(settings->value("R2", 161).toInt(), |
| 53 | settings->value("G2", 128).toInt(), | 61 | settings->value("G2", 211).toInt(), |
| 54 | settings->value("B2", 128).toInt()); | 62 | settings->value("B2", 72).toInt()); |
| 55 | _colors[2].setRgb(settings->value("R3", 128).toInt(), | 63 | _colors[2].setRgb(settings->value("R3", 51).toInt(), |
| 56 | settings->value("G3", 128).toInt(), | 64 | settings->value("G3", 204).toInt(), |
| 57 | settings->value("B3", 128).toInt()); | 65 | settings->value("B3", 204).toInt()); |
| 58 | _colors[3].setRgb(settings->value("R4", 128).toInt(), | 66 | _colors[3].setRgb(settings->value("R4", 63).toInt(), |
| 59 | settings->value("G4", 128).toInt(), | 67 | settings->value("G4", 169).toInt(), |
| 60 | settings->value("B4", 128).toInt()); | 68 | settings->value("B4", 245).toInt()); |
| 61 | _colors[4].setRgb(settings->value("R5", 128).toInt(), | 69 | _colors[4].setRgb(settings->value("R5", 193).toInt(), |
| 62 | settings->value("G5", 128).toInt(), | 70 | settings->value("G5", 99).toInt(), |
| 63 | settings->value("B5", 128).toInt()); | 71 | settings->value("B5", 122).toInt()); |
| 64 | _colors[5].setRgb(settings->value("R6", 128).toInt(), | 72 | _colors[5].setRgb(settings->value("R6", 255).toInt(), |
| 65 | settings->value("G6", 128).toInt(), | 73 | settings->value("G6", 54).toInt(), |
| 66 | settings->value("B6", 128).toInt()); | 74 | settings->value("B6", 69).toInt()); |
| 67 | _colors[6].setRgb(settings->value("R7", 128).toInt(), | 75 | _colors[6].setRgb(settings->value("R7", 124).toInt(), |
| 68 | settings->value("G7", 128).toInt(), | 76 | settings->value("G7", 36).toInt(), |
| 69 | settings->value("B7", 128).toInt()); | 77 | settings->value("B7", 36).toInt()); |
| 70 | _colors[7].setRgb(settings->value("R8", 128).toInt(), | 78 | _colors[7].setRgb(settings->value("R8", 63).toInt(), |
| 71 | settings->value("G8", 128).toInt(), | 79 | settings->value("G8", 35).toInt(), |
| 72 | settings->value("B8", 128).toInt()); | 80 | settings->value("B8", 19).toInt()); |
| 73 | 81 | ||
| 74 | settings->endGroup(); | 82 | settings->endGroup(); |
| 83 | |||
| 84 | checkColor(); | ||
| 75 | } | 85 | } |
| 76 | 86 | ||
| 77 | void Swatch::handleEvent(int key, bool getColor) { | 87 | void Swatch::handleEvent(int key, bool getColor) { |