src/gui.h

changeset 539
72ad83a67165
parent 538
2f85d4d286e5
child 540
0334789cb4d7
equal deleted inserted replaced
538:2f85d4d286e5 539:72ad83a67165
57 #define SHIFT(N) (Qt::SHIFT | Qt::Key_##N) 57 #define SHIFT(N) (Qt::SHIFT | Qt::Key_##N)
58 #define CTRL_SHIFT(N) (Qt::CTRL | Qt::SHIFT | Qt::Key_##N) 58 #define CTRL_SHIFT(N) (Qt::CTRL | Qt::SHIFT | Qt::Key_##N)
59 59
60 // ============================================================================= 60 // =============================================================================
61 class LDQuickColor 61 class LDQuickColor
62 { PROPERTY (LDColor*, color, setColor) 62 { PROPERTY (public, LDColor*, Color, NO_OPS, NO_CB)
63 PROPERTY (QToolButton*, toolButton, setToolButton) 63 PROPERTY (public, QToolButton*, ToolButton, NO_OPS, NO_CB)
64 64
65 public: 65 public:
66 LDQuickColor (LDColor* color, QToolButton* toolButton); 66 LDQuickColor (LDColor* color, QToolButton* toolButton);
67 bool isSeparator() const; 67 bool isSeparator() const;
68 68
178 QList<LDQuickColor> quickColorsFromConfig(); // Make a list of quick colors based on config 178 QList<LDQuickColor> quickColorsFromConfig(); // Make a list of quick colors based on config
179 bool confirm (str title, str msg); // Generic confirm prompt 179 bool confirm (str title, str msg); // Generic confirm prompt
180 bool confirm (str msg); // Generic confirm prompt 180 bool confirm (str msg); // Generic confirm prompt
181 void critical (str msg); // Generic error prompt 181 void critical (str msg); // Generic error prompt
182 QIcon makeColorIcon (LDColor* colinfo, const int size); // Makes an icon for the given color 182 QIcon makeColorIcon (LDColor* colinfo, const int size); // Makes an icon for the given color
183 void makeColorSelector (QComboBox* box); // Fills the given combo-box with color information 183 void makeColorComboBox (QComboBox* box); // Fills the given combo-box with color information
184 QImage imageFromScreencap (uchar* data, int w, int h); 184 QImage imageFromScreencap (uchar* data, int w, int h);
185 185
186 // ============================================================================= 186 // =============================================================================
187 // ----------------------------------------------------------------------------- 187 // -----------------------------------------------------------------------------
188 // Takes in pairs of radio buttons and respective values and returns the value of 188 // Takes in pairs of radio buttons and respective values and returns the value of
189 // the first found radio button that was checked. 189 // the first found radio button that was checked.
190 // ============================================================================= 190 // =============================================================================
191 template<class T> T radioSwitch (const T& defval, QList<pair<QRadioButton*, T>> haystack) 191 template<class T>
192 T radioSwitch (const T& defval, QList<pair<QRadioButton*, T>> haystack)
192 { for (pair<QRadioButton*, const T&> i : haystack) 193 { for (pair<QRadioButton*, const T&> i : haystack)
193 if (i.first->isChecked()) 194 if (i.first->isChecked())
194 return i.second; 195 return i.second;
195 196
196 return defval; 197 return defval;
199 // ============================================================================= 200 // =============================================================================
200 // ----------------------------------------------------------------------------- 201 // -----------------------------------------------------------------------------
201 // Takes in pairs of radio buttons and respective values and checks the first 202 // Takes in pairs of radio buttons and respective values and checks the first
202 // found radio button to have the given value. 203 // found radio button to have the given value.
203 // ============================================================================= 204 // =============================================================================
204 template<class T> void radioDefault (const T& expr, QList<pair<QRadioButton*, T>> haystack) 205 template<class T>
206 void radioDefault (const T& expr, QList<pair<QRadioButton*, T>> haystack)
205 { for (pair<QRadioButton*, const T&> i : haystack) 207 { for (pair<QRadioButton*, const T&> i : haystack)
206 { if (i.second == expr) 208 { if (i.second == expr)
207 { i.first->setChecked (true); 209 { i.first->setChecked (true);
208 return; 210 return;
209 } 211 }

mercurial