src/colorSelectDialog.cpp

changeset 538
2f85d4d286e5
parent 498
791c831c8020
child 539
72ad83a67165
equal deleted inserted replaced
537:1add0ee96fb3 538:2f85d4d286e5
32 #include "misc.h" 32 #include "misc.h"
33 #include "ui_colorsel.h" 33 #include "ui_colorsel.h"
34 #include "moc_colorSelectDialog.cpp" 34 #include "moc_colorSelectDialog.cpp"
35 35
36 static const int g_numColumns = 16; 36 static const int g_numColumns = 16;
37 static const short g_squareSize = 32; 37 static const int g_squareSize = 32;
38 38
39 extern_cfg (String, gl_maincolor); 39 extern_cfg (String, gl_maincolor);
40 extern_cfg (Float, gl_maincolor_alpha); 40 extern_cfg (Float, gl_maincolor_alpha);
41 41
42 // ============================================================================= 42 // =============================================================================
43 // ----------------------------------------------------------------------------- 43 // -----------------------------------------------------------------------------
44 ColorSelector::ColorSelector (short defval, QWidget* parent) : QDialog (parent) 44 ColorSelector::ColorSelector (int defval, QWidget* parent) : QDialog (parent)
45 { // Remove the default color if it's invalid 45 { // Remove the default color if it's invalid
46 if (!::getColor (defval)) 46 if (!getColor (defval))
47 defval = -1; 47 defval = -1;
48 48
49 m_firstResize = true; 49 m_firstResize = true;
50 ui = new Ui_ColorSelUI; 50 ui = new Ui_ColorSelUI;
51 ui->setupUi (this); 51 ui->setupUi (this);
52 52
53 m_scene = new QGraphicsScene; 53 m_scene = new QGraphicsScene;
54 ui->viewport->setScene (m_scene); 54 ui->viewport->setScene (m_scene);
55 setSelection (::getColor (defval)); 55 setSelection (getColor (defval));
56 56
57 // not really an icon but eh 57 // not really an icon but eh
58 m_scene->setBackgroundBrush (getIcon ("checkerboard")); 58 m_scene->setBackgroundBrush (getIcon ("checkerboard"));
59 drawScene(); 59 drawScene();
60 60
85 const double penWidth = 1.0f; 85 const double penWidth = 1.0f;
86 86
87 // Draw the color rectangles. 87 // Draw the color rectangles.
88 m_scene->clear(); 88 m_scene->clear();
89 89
90 for (short i = 0; i < MAX_COLORS; ++i) 90 for (int i = 0; i < MAX_COLORS; ++i)
91 { LDColor* info = ::getColor (i); 91 { LDColor* info = ::getColor (i);
92 92
93 if (!info) 93 if (!info)
94 continue; 94 continue;
95 95
181 drawColorInfo(); 181 drawColorInfo();
182 } 182 }
183 183
184 // ============================================================================= 184 // =============================================================================
185 // ----------------------------------------------------------------------------- 185 // -----------------------------------------------------------------------------
186 bool ColorSelector::getColor (short& val, short int defval, QWidget* parent) 186 bool ColorSelector::selectColor (int& val, int defval, QWidget* parent)
187 { ColorSelector dlg (defval, parent); 187 { ColorSelector dlg (defval, parent);
188 188
189 if (dlg.exec() && dlg.sel() != null) 189 if (dlg.exec() && dlg.sel() != null)
190 { val = dlg.sel()->index; 190 { val = dlg.sel()->index;
191 return true; 191 return true;

mercurial