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); |
|