src/gui.h

changeset 335
30c11cff511d
parent 328
b6a814a608c6
child 344
55fcf67230fd
equal deleted inserted replaced
334:bb3a0e5ebe53 335:30c11cff511d
20 #define GUI_H 20 #define GUI_H
21 21
22 #include <QMainWindow> 22 #include <QMainWindow>
23 #include <QAction> 23 #include <QAction>
24 #include <QListWidget> 24 #include <QListWidget>
25 #include <QRadioButton>
25 #include "config.h" 26 #include "config.h"
26 #include "ldtypes.h" 27 #include "ldtypes.h"
27 28
28 class MessageManager; 29 class MessageManager;
29 class ForgeWindow; 30 class ForgeWindow;
173 void slot_lastSecondCleanup (); 174 void slot_lastSecondCleanup ();
174 void slot_editObject (QListWidgetItem* listitem); 175 void slot_editObject (QListWidgetItem* listitem);
175 }; 176 };
176 177
177 // ----------------------------------------------------------------------------- 178 // -----------------------------------------------------------------------------
179 // Pointer to the instance of ForgeWindow.
180 extern ForgeWindow* g_win;
181
182 // -----------------------------------------------------------------------------
178 // Other GUI-related stuff not directly part of ForgeWindow: 183 // Other GUI-related stuff not directly part of ForgeWindow:
179 QPixmap getIcon (str iconName); 184 QPixmap getIcon (str iconName);
180 vector<quickColor> parseQuickColorMeta (); 185 vector<quickColor> parseQuickColorMeta ();
181 bool confirm (str title, str msg); 186 bool confirm (str title, str msg);
182 bool confirm (str msg); 187 bool confirm (str msg);
186 void makeColorSelector (QComboBox* box); 191 void makeColorSelector (QComboBox* box);
187 QDialogButtonBox* makeButtonBox (QDialog& dlg); 192 QDialogButtonBox* makeButtonBox (QDialog& dlg);
188 CheckBoxGroup* makeAxesBox (); 193 CheckBoxGroup* makeAxesBox ();
189 QImage imageFromScreencap (uchar* data, ushort w, ushort h); 194 QImage imageFromScreencap (uchar* data, ushort w, ushort h);
190 195
191 // ----------------------------------------------------------------------------- 196 // =============================================================================
192 // Pointer to the instance of ForgeWindow. 197 // -----------------------------------------------------------------------------
193 extern ForgeWindow* g_win; 198 // Takes in pairs of radio buttons and respective values and returns the value of
199 // the first found radio button that was checked.
200 // =============================================================================
201 template<class T> T radioSwitch( const T& defval, vector<pair<QRadioButton*, T>> haystack )
202 {
203 for( pair<QRadioButton*, const T&> i : haystack )
204 if( i.first->isChecked() )
205 return i.second;
206
207 return defval;
208 }
209
210 // =============================================================================
211 // -----------------------------------------------------------------------------
212 // Takes in pairs of radio buttons and respective values and checks the first
213 // found radio button to have the given value.
214 // =============================================================================
215 template<class T> void radioDefault( const T& expr, vector<pair<QRadioButton*, T>> haystack )
216 {
217 for( pair<QRadioButton*, const T&> i : haystack )
218 {
219 if( i.second == expr )
220 {
221 i.first->setChecked( true );
222 return;
223 }
224 }
225 }
194 226
195 // ============================================================================= 227 // =============================================================================
196 // ActionAdder 228 // ActionAdder
197 // 229 //
198 // The MAKE_ACTION macro expands into - among other stuff - into an instance 230 // The MAKE_ACTION macro expands into - among other stuff - into an instance

mercurial