19 #include "mainwindow.h" 20 #include "parameter_delegate.h" 21 #include "xml_parameter_reader.h" 22 #include "xml_parameter_writer.h" 27 namespace ParameterGui
31 QString settings_file = QDir::currentPath() +
"/settings.ini";
33 gui_settings =
new QSettings (settings_file, QSettings::IniFormat);
40 tree_widget->header()->setResizeMode(QHeaderView::ResizeToContents);
45 tree_widget->setHeaderLabels(QStringList() << tr(
"(Sub)Sections/Parameters")
49 tree_widget->setEditTriggers(QAbstractItemView::DoubleClicked|
50 QAbstractItemView::SelectedClicked|
51 QAbstractItemView::EditKeyPressed);
65 statusBar()->showMessage(tr(
"Ready, start editing by double-clicking or hitting F2!"));
66 setWindowTitle(tr(
"[*]parameterGUI"));
70 if (filename.size() > 3)
81 QFileDialog::getOpenFileName(
this, tr(
"Open XML Parameter File"),
83 tr(
"XML Files (*.xml)"));
84 if (!file_name.isEmpty())
104 QFileDialog::getSaveFileName(
this, tr(
"Save XML Parameter File"),
106 tr(
"XML Files (*.xml)"));
108 if (file_name.isEmpty())
119 static QPointer<QMessageBox> old_msg_box;
124 old_msg_box->raise();
125 old_msg_box->activateWindow();
130 QString title =
"About parameterGUI";
132 QString trAboutparameterGUIcaption;
133 trAboutparameterGUIcaption = QMessageBox::tr(
134 "<h3>parameterGUI: A GraphicalUserInterface for parameter handling in deal.II</h3>" 135 "<p>This program uses Qt version %1.</p>" 136 ).arg(QLatin1String(QT_VERSION_STR));
138 QString trAboutparameterGUItext;
139 trAboutparameterGUItext = QMessageBox::tr(
140 "<p>The parameterGUI is a graphical user interface for editing XML parameter files " 141 "created by the ParameterHandler class of deal.II. Please see " 142 "<a href=\"http://www.dealii.org/7.0.0/doxygen/deal.II/classParameterHandler.html\">dealii.org/doc</a> for more information. " 143 "The parameterGUI parses XML files into a tree structure and provides " 144 " special editors for different types of parameters.</p>" 146 "<p><b>Editing parameter values:</b><br>" 147 "Parameters can be edited by (double-)clicking on the value or " 148 "by pressing the platform edit key (F2 on Linux) over an parameter item.</p>" 150 "<p><b>Editors for parameter values:</b>" 152 " <li>Integer- and Double-type parameters: SpinBox</li>" 153 " <li>Booleans: ComboBox</li>" 154 " <li>Selection: ComboBox</li>" 155 " <li>File- and DirectoryName parameters: BrowseLineEditor</li>" 156 " <li>Anything|MultipleSelection|List: LineEditor</li>" 160 "<p>Please see <a href=\"http://www.dealii.org\">dealii.org</a> for more information</p>" 161 "<p><b>Authors:</b><br> " 162 "Martin Steigemann, <a href=\"mailto:martin.steigemann@mathematik.uni-kassel.de\">martin.steigemann@mathematik.uni-kassel.de</a><br>" 163 "Wolfgang Bangerth, <a href=\"mailto:bangerth@math.tamu.edu\">bangerth@math.tamu.edu</a></p>" 166 QMessageBox *msg_box =
new QMessageBox;
167 msg_box->setAttribute(Qt::WA_DeleteOnClose);
168 msg_box->setWindowTitle(title);
169 msg_box->setText(trAboutparameterGUIcaption);
170 msg_box->setInformativeText(trAboutparameterGUItext);
172 QPixmap pm(QLatin1String(
":/images/logo_dealii_gui_128.png"));
175 msg_box->setIconPixmap(pm);
178 old_msg_box = msg_box;
189 setWindowModified(
true);
199 QString title =
"parameterGUI";
205 " by hitting the platform edit key. For example, on Linux this is the F2-key!"));
225 open_act =
new QAction(tr(
"&Open..."),
this);
226 open_act->setIcon(style->standardPixmap(QStyle::SP_DialogOpenButton));
227 open_act->setShortcut(Qt::CTRL + Qt::Key_O);
228 open_act->setStatusTip(tr(
"Open a XML file"));
229 connect(
open_act, SIGNAL(triggered()),
this, SLOT(
open()));
231 save_act =
new QAction(tr(
"&Save ..."),
this);
232 save_act->setIcon(style->standardPixmap(QStyle::SP_DialogSaveButton));
233 save_act->setShortcut(Qt::CTRL + Qt::Key_S);
234 save_act->setStatusTip(tr(
"Save the current XML file"));
235 connect(
save_act, SIGNAL(triggered()),
this, SLOT(
save()));
237 save_as_act =
new QAction(tr(
"&Save As..."),
this);
238 save_as_act->setIcon(style->standardPixmap(QStyle::SP_DialogSaveButton));
239 save_as_act->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Q);
240 save_as_act->setStatusTip(tr(
"Save the current XML file as"));
243 exit_act =
new QAction(tr(
"E&xit"),
this);
244 exit_act->setIcon(style->standardPixmap(QStyle::SP_DialogCloseButton));
245 exit_act->setShortcut(Qt::CTRL + Qt::Key_Q);
246 exit_act->setStatusTip(tr(
"Exit the parameterGUI application"));
247 connect(
exit_act, SIGNAL(triggered()),
this, SLOT(close()));
249 about_act =
new QAction(tr(
"&About"),
this);
250 about_act->setIcon(style->standardPixmap(QStyle::SP_FileDialogInfoView));
251 about_act->setStatusTip(tr(
"Show the parameterGUI About box"));
255 about_qt_act->setStatusTip(tr(
"Show the Qt library's About box"));
256 connect(
about_qt_act, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
263 file_menu = menuBar()->addMenu(tr(
"&File"));
269 menuBar()->addSeparator();
271 help_menu = menuBar()->addMenu(tr(
"&Help"));
280 if (isWindowModified())
282 QMessageBox::StandardButton ret;
283 ret = QMessageBox::warning(
this, tr(
"parameterGUI"),
284 tr(
"The content has been modified.\n" 285 "Do you want to save your changes?"),
286 QMessageBox::Save | QMessageBox::Discard |QMessageBox::Cancel);
288 if (ret == QMessageBox::Save)
290 else if (ret == QMessageBox::Cancel)
301 QFile file(filename);
303 if (!file.open(QFile::WriteOnly | QFile::Text))
305 QMessageBox::warning(
this, tr(
"parameterGUI"),
306 tr(
"Cannot write file %1:\n%2.")
308 .arg(file.errorString()));
317 statusBar()->showMessage(tr(
"File saved"), 2000);
327 QFile file(filename);
329 if (!file.open(QFile::ReadOnly | QFile::Text))
331 QMessageBox::warning(
this, tr(
"parameterGUI"),
332 tr(
"Cannot read file %1:\n%2.")
334 .arg(file.errorString()));
344 QMessageBox::warning(
this, tr(
"parameterGUI"),
345 tr(
"Parse error in file %1:\n\n%2")
351 statusBar()->showMessage(tr(
"File loaded - Start editing by double-clicking or hitting F2"), 25000);
373 std::string win_title = (filename.toStdString());
376 win_title =
"[*]parameterGUI";
378 win_title +=
"[*] - parameterGUI";
381 setWindowTitle(tr(win_title.c_str()));
382 setWindowModified(
false);
QTreeWidget * tree_widget
void load_file(const QString &filename)
InfoMessage * info_message
MainWindow(const QString &filename="")
bool read_xml_file(QIODevice *device)
void set_current_file(const QString &filename)
QString error_string() const
void setInfoMessage(const QString &message)
void closeEvent(QCloseEvent *event)
bool write_xml_file(QIODevice *device)
bool save_file(const QString &filename)