src/mainwindow.h

changeset 1156
c20ee66b6705
parent 1147
a26568aa3cce
child 1157
1d6d244bdabd
equal deleted inserted replaced
1155:b0e004c8e3a4 1156:c20ee66b6705
27 #include "linetypes/modelobject.h" 27 #include "linetypes/modelobject.h"
28 #include "colors.h" 28 #include "colors.h"
29 #include "doublemap.h" 29 #include "doublemap.h"
30 30
31 class MessageManager; 31 class MessageManager;
32 class MainWindow;
33 class QToolButton; 32 class QToolButton;
34 class QDialogButtonBox;
35 class Canvas; 33 class Canvas;
36 class QComboBox;
37 class QProgressBar;
38 class Toolset; 34 class Toolset;
39 class Configuration; 35 class Configuration;
40 class PrimitiveManager; 36 class PrimitiveManager;
41 class Grid; 37 class Grid;
42 class MathFunctions; 38 class MathFunctions;
174 // TODO: it's going out, slowly but surely. 170 // TODO: it's going out, slowly but surely.
175 extern MainWindow* g_win; 171 extern MainWindow* g_win;
176 172
177 // Get an icon by name from the resources directory. 173 // Get an icon by name from the resources directory.
178 QPixmap GetIcon (QString iconName); 174 QPixmap GetIcon (QString iconName);
179 175 class QSettings* makeSettings(QObject* parent = nullptr);
180 // Asks the user a yes/no question with the given message and the given window title.
181 // Returns true if the user answered yes, false if no.
182 bool Confirm (const QString& title, const QString& message); // Generic confirm prompt
183
184 // An overload of confirm(), this asks the user a yes/no question with the given message.
185 // Returns true if the user answered yes, false if no.
186 bool Confirm (const QString& message);
187
188 // Displays an error prompt with the given message
189 void Critical (const QString& message);
190 void errorPrompt (QWidget *parent, const QString& message);
191
192 // Takes in pairs of radio buttons and respective values and finds the first selected one.
193 // Returns returns the value of the first found radio button that was checked by the user.
194 template<class T>
195 T RadioSwitch (const T& defval, QList<Pair<QRadioButton*, T>> haystack)
196 {
197 for (Pair<QRadioButton*, const T&> i : haystack)
198 {
199 if (i.first->isChecked())
200 return i.second;
201 }
202
203 return defval;
204 }
205
206 // Takes in pairs of radio buttons and respective values and checks the first found radio button whose respsective value
207 // matches expr have the given value.
208 template<class T>
209 void RadioDefault (const T& expr, QList<Pair<QRadioButton*, T>> haystack)
210 {
211 for (Pair<QRadioButton*, const T&> i : haystack)
212 {
213 if (i.second == expr)
214 {
215 i.first->setChecked (true);
216 return;
217 }
218 }
219 }
220
221 QSettings* makeSettings (QObject* parent = nullptr);

mercurial