-
Notifications
You must be signed in to change notification settings - Fork 9
/
mainwindow.h
306 lines (253 loc) · 7.79 KB
/
mainwindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
// ---------------------------------------------------------------------
//
// Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
//
// This file is part of the deal.II library.
//
// The deal.II library is free software; you can use it, redistribute
// it, and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// The full text of the license can be found in the file LICENSE at
// the top level of the deal.II distribution.
//
// ---------------------------------------------------------------------
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QTreeWidget>
#include <QDialog>
#include <QSettings>
#include <QToolBar>
#include <QToolButton>
#include "info_message.h"
#include "settings_dialog.h"
namespace dealii
{
/*! @addtogroup ParameterGui
*@{
*/
namespace ParameterGui
{
/**
* The MainWindow class of the the parameterGUI.
* The parameterGUI is a graphical user interface for editing parameter files based on the XML format,
* created by the @ref ParameterHandler::print_parameters() function with @ref ParameterHandler::XML as second argument.
* Please see <tt>Representation of Parameters</tt> in the documentation of the @ref ParameterHandler class for more details.
* The MainWindow class provides the basic functionality of the GUI as save- and load-file-actions and documentation.
* The parameterGUI provides special editors for the different types of parameters defined in the ParameterHandler class.
*
* @note This class is used in the graphical user interface for the @ref ParameterHandler class.
* It is not compiled into the deal.II libraries and can not be used by applications using deal.II.
*
* @ingroup ParameterGui
* @author Martin Steigemann, Wolfgang Bangerth, 2010
*/
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
/**
* Constructor.
* If a @p filename is given,
* the MainWindow tries to open
* and parse the file.
*/
MainWindow(const QString &filename = "");
protected:
/**
* Reimplemented from QMainWindow.
* We ask, if changes should be saved.
*/
void closeEvent(QCloseEvent *event);
private slots:
/**
* Open a parameter file.
*/
void open();
/**
* Save the parameter file.
*/
bool save();
/**
* Open a file dialog to save the parameter file.
*/
bool save_as();
/**
* Show some information on the parameterGUI
*/
void about();
/**
* A <tt>slot</tt> that should be always called,
* if parameter values were changed.
*/
void tree_was_modified();
/**
* A <tt>slot</tt> that is called when the active
* item has changed. It updates the documentation
* text in the documentation panel.
*/
void set_documentation_text(QTreeWidgetItem *selected_item,
QTreeWidgetItem *previous_item);
/**
* A <tt>slot</tt> that is called when the active
* tree item should be set to its default value.
*/
void set_to_default();
/**
* A <tt>slot</tt> that is called when any
* item value has changed. It updates the font depending
* on whether the item has a default value or not.
*/
void item_changed(QTreeWidgetItem *item,
int column);
/**
* Show an information dialog, how
* parameters can be edited.
*/
void show_settings ();
/**
* Apply the new settings to this window.
*/
void apply_settings ();
/**
* Hide all default items in tree_widget if set in gui_settings.
* Otherwise restores all default values.
*/
void update_visible_items();
/**
* Reads the font from gui_settings and applies it.
*/
void update_font();
/**
* Changes whether default items should be displayed in the tree widget
* and calls update_visible_items() to apply the changes.
*/
void toggle_visible_default_items();
/**
* Function that displays a font selection dialog, stores the result
* in gui_settings, and displays the new font.
*/
void select_font();
private:
/**
* Show an information dialog, how
* parameters can be edited.
*/
void show_message ();
/**
* This function creates all actions.
*/
void create_actions();
/**
* This function creates all menus.
*/
void create_menus();
/**
* This function creates the toolbar.
*/
void create_toolbar();
/**
* This function checks, if parameters were changed
* and show a dialog, if changes should be saved.
* This function should be always called,
* before open a new parameter file or before closing the GUI
*/
bool maybe_save ();
/**
* Save parameters to @p filename in XML format.
*/
bool save_file (const QString &filename);
/**
* Load parameters from @p filename in XML format.
*/
void load_file (const QString &filename);
/**
* This functions writes the current @p filename to the window title.
*/
void set_current_file (const QString &filename);
/**
* Determine if the item and all of its children have the default value,
* and hide all default items. Returns true if the item and all of its
* children have default values.
*/
bool hide_item_with_default_value(QTreeWidgetItem *item);
/**
* This is the tree structure in which we store all parameters.
*/
QTreeWidget *tree_widget;
/**
* This is the documentation text area.
*/
QTextEdit *documentation_text_widget;
/** A tool button that allows to toggle between showing/hiding parameters
* with default values.
*/
QToolButton *hide_default;
/**
* This menu provides all file actions as <tt>open</tt>, <tt>save</tt>, <tt>save as</tt>
* and <tt>exit</tt>
*/
QMenu *file_menu;
/**
* This menu provides some informations <tt>about</tt> the parameterGUI
* and <tt>about Qt</tt>
*/
QMenu *help_menu;
/**
* This menu provides context menu options for the active tree item.
*/
QMenu *context_menu;
/**
* QAction <tt>open</tt> a file.
*/
QAction *open_act;
/**
* QAction <tt>save</tt> a file.
*/
QAction *save_act;
/**
* QAction <tt>save as</tt> a file.
*/
QAction *save_as_act;
/**
* QAction <tt>save as</tt> a file.
*/
QAction *settings_act;
/**
* QAction <tt>exit</tt> the GUI.
*/
QAction *exit_act;
/**
* QAction <tt>about</tt> the parameterGUI.
*/
QAction *about_act;
/**
* QAction <tt>about</tt> Qt.
*/
QAction *about_qt_act;
/**
* QAction <tt>set_to_default</tt>.
*/
QAction *set_to_default_act;
/**
* This value stores the current <tt>filename</tt> we work on.
*/
QString current_file;
/**
* This dialog shows a short information message after loading a file.
*/
InfoMessage *info_message;
/**
* This dialog shows the available settings.
*/
SettingsDialog *settings_dialog;
/**
* An object for storing user settings.
*/
QSettings *gui_settings;
};
}
/**@}*/
}
#endif