Bug Summary

File:OMEdit/OMEditLIB/Options/OptionsDialog.cpp
Warning:line 2945, column 11
Potential leak of memory pointed to by 'pCompositeModelHighlighter'

Annotated Source Code

[?] Use j/k keys for keyboard navigation

1/*
2 * This file is part of OpenModelica.
3 *
4 * Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC),
5 * c/o Linköpings universitet, Department of Computer and Information Science,
6 * SE-58183 Linköping, Sweden.
7 *
8 * All rights reserved.
9 *
10 * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR
11 * THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
12 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
13 * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3,
14 * ACCORDING TO RECIPIENTS CHOICE.
15 *
16 * The OpenModelica software and the Open Source Modelica
17 * Consortium (OSMC) Public License (OSMC-PL) are obtained
18 * from OSMC, either from the above address,
19 * from the URLs: http://www.ida.liu.se/projects/OpenModelica or
20 * http://www.openmodelica.org, and in the OpenModelica distribution.
21 * GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
22 *
23 * This program is distributed WITHOUT ANY WARRANTY; without
24 * even the implied warranty of MERCHANTABILITY or FITNESS
25 * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
26 * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
27 *
28 * See the full OSMC Public License conditions for more details.
29 *
30 */
31/*
32 * @author Adeel Asghar <adeel.asghar@liu.se>
33 */
34
35#include "OptionsDialog.h"
36#include "MainWindow.h"
37#include "OMC/OMCProxy.h"
38#include "OMS/OMSProxy.h"
39#include "Modeling/LibraryTreeWidget.h"
40#include "Modeling/ItemDelegate.h"
41#include "Modeling/ModelWidgetContainer.h"
42#include "Modeling/MessagesWidget.h"
43#include "Plotting/PlotWindowContainer.h"
44#include "Plotting/VariablesWidget.h"
45#include "Debugger/StackFrames/StackFramesWidget.h"
46#include "Editors/HTMLEditor.h"
47#include "Simulation/TranslationFlagsWidget.h"
48#include <limits>
49
50/*!
51 * \class OptionsDialog
52 * \brief Creates an interface with options like Modelica Text, Pen Styles, Libraries etc.
53 */
54
55OptionsDialog *OptionsDialog::mpInstance = 0;
56
57/*!
58 * \brief OptionsDialog::create
59 */
60void OptionsDialog::create()
61{
62 if (!mpInstance) {
63 mpInstance = new OptionsDialog;
64 }
65}
66
67/*!
68 * \brief OptionsDialog::destroy
69 */
70void OptionsDialog::destroy()
71{
72 mpInstance->deleteLater();
73}
74
75/*!
76 * \brief OptionsDialog::OptionsDialog
77 * \param pParent
78 */
79OptionsDialog::OptionsDialog(QWidget *pParent)
80 : QDialog(pParent), mpSettings(Utilities::getApplicationSettings())
81{
82 setWindowTitle(QString(Helper::applicationName).append(" - ").append(Helper::options));
83 setModal(true);
84 mpGeneralSettingsPage = new GeneralSettingsPage(this);
85 mpLibrariesPage = new LibrariesPage(this);
86 mpTextEditorPage = new TextEditorPage(this);
87 mpModelicaEditorPage = new ModelicaEditorPage(this);
88 connect(mpTextEditorPage->getFontFamilyComboBox(), SIGNAL(currentFontChanged(QFont))"2""currentFontChanged(QFont)", mpModelicaEditorPage, SIGNAL(updatePreview())"2""updatePreview()");
89 connect(mpTextEditorPage->getFontSizeSpinBox(), SIGNAL(valueChanged(double))"2""valueChanged(double)", mpModelicaEditorPage, SIGNAL(updatePreview())"2""updatePreview()");
90 mpMetaModelicaEditorPage = new MetaModelicaEditorPage(this);
91 connect(mpTextEditorPage->getFontFamilyComboBox(), SIGNAL(currentFontChanged(QFont))"2""currentFontChanged(QFont)", mpMetaModelicaEditorPage, SIGNAL(updatePreview())"2""updatePreview()");
92 connect(mpTextEditorPage->getFontSizeSpinBox(), SIGNAL(valueChanged(double))"2""valueChanged(double)", mpMetaModelicaEditorPage, SIGNAL(updatePreview())"2""updatePreview()");
93 mpCompositeModelEditorPage = new CompositeModelEditorPage(this);
94 connect(mpTextEditorPage->getFontFamilyComboBox(), SIGNAL(currentFontChanged(QFont))"2""currentFontChanged(QFont)", mpCompositeModelEditorPage, SIGNAL(updatePreview())"2""updatePreview()");
95 connect(mpTextEditorPage->getFontSizeSpinBox(), SIGNAL(valueChanged(double))"2""valueChanged(double)", mpCompositeModelEditorPage, SIGNAL(updatePreview())"2""updatePreview()");
96 mpOMSimulatorEditorPage = new OMSimulatorEditorPage(this);
97 connect(mpTextEditorPage->getFontFamilyComboBox(), SIGNAL(currentFontChanged(QFont))"2""currentFontChanged(QFont)", mpOMSimulatorEditorPage, SIGNAL(updatePreview())"2""updatePreview()");
98 connect(mpTextEditorPage->getFontSizeSpinBox(), SIGNAL(valueChanged(double))"2""valueChanged(double)", mpOMSimulatorEditorPage, SIGNAL(updatePreview())"2""updatePreview()");
99 mpCEditorPage = new CEditorPage(this);
100 connect(mpTextEditorPage->getFontFamilyComboBox(), SIGNAL(currentFontChanged(QFont))"2""currentFontChanged(QFont)", mpCEditorPage, SIGNAL(updatePreview())"2""updatePreview()");
101 connect(mpTextEditorPage->getFontSizeSpinBox(), SIGNAL(valueChanged(double))"2""valueChanged(double)", mpCEditorPage, SIGNAL(updatePreview())"2""updatePreview()");
102 mpHTMLEditorPage = new HTMLEditorPage(this);
103 connect(mpTextEditorPage->getFontFamilyComboBox(), SIGNAL(currentFontChanged(QFont))"2""currentFontChanged(QFont)", mpHTMLEditorPage, SIGNAL(updatePreview())"2""updatePreview()");
104 connect(mpTextEditorPage->getFontSizeSpinBox(), SIGNAL(valueChanged(double))"2""valueChanged(double)", mpHTMLEditorPage, SIGNAL(updatePreview())"2""updatePreview()");
105 mpGraphicalViewsPage = new GraphicalViewsPage(this);
106 mpSimulationPage = new SimulationPage(this);
107 mpMessagesPage = new MessagesPage(this);
108 mpNotificationsPage = new NotificationsPage(this);
109 mpLineStylePage = new LineStylePage(this);
110 mpFillStylePage = new FillStylePage(this);
111 mpPlottingPage = new PlottingPage(this);
112 mpFigaroPage = new FigaroPage(this);
113 mpDebuggerPage = new DebuggerPage(this);
114 mpFMIPage = new FMIPage(this);
115 mpTLMPage = new TLMPage(this);
116 mpOMSimulatorPage = new OMSimulatorPage(this);
117 mpTraceabilityPage = new TraceabilityPage(this);
118 // Get the settings.
119 // Don't read the settings in case we are running the testsuite. We want default OMEdit.
120 if (!MainWindow::instance()->isTestsuiteRunning()) {
121 readSettings();
122 }
123 // set up the Options Dialog
124 setUpDialog();
125}
126
127//! Reads the settings from omedit.ini file.
128void OptionsDialog::readSettings()
129{
130 mpSettings->sync();
131 readGeneralSettings();
132 readLibrariesSettings();
133 readTextEditorSettings();
134 readModelicaEditorSettings();
135 emit modelicaEditorSettingsChanged();
136 mpModelicaEditorPage->emitUpdatePreview();
137 readMetaModelicaEditorSettings();
138 emit metaModelicaEditorSettingsChanged();
139 mpMetaModelicaEditorPage->emitUpdatePreview();
140 readCompositeModelEditorSettings();
141 emit compositeModelEditorSettingsChanged();
142 mpCompositeModelEditorPage->emitUpdatePreview();
143 readOMSimulatorEditorSettings();
144 emit omsimulatorEditorSettingsChanged();
145 mpOMSimulatorEditorPage->emitUpdatePreview();
146 readCEditorSettings();
147 emit cEditorSettingsChanged();
148 mpCEditorPage->emitUpdatePreview();
149 readHTMLEditorSettings();
150 emit HTMLEditorSettingsChanged();
151 mpHTMLEditorPage->emitUpdatePreview();
152 readGraphicalViewsSettings();
153 readSimulationSettings();
154 readMessagesSettings();
155 readNotificationsSettings();
156 readLineStyleSettings();
157 readFillStyleSettings();
158 readPlottingSettings();
159 readFigaroSettings();
160 readDebuggerSettings();
161 readFMISettings();
162 readTLMSettings();
163 readOMSimulatorSettings();
164 readTraceabilitySettings();
165}
166
167//! Reads the General section settings from omedit.ini
168void OptionsDialog::readGeneralSettings()
169{
170 // read the language option
171 if (mpSettings->contains("language")) {
172 /* Handle locale stored both as variant and as QString */
173 QLocale locale = QLocale(mpSettings->value("language").toString());
174 int currentIndex = mpGeneralSettingsPage->getLanguageComboBox()->findData(locale.name() == "C" ? mpSettings->value("language") : QVariant(locale), Qt::UserRole, Qt::MatchExactly);
175 if (currentIndex > -1) {
176 mpGeneralSettingsPage->getLanguageComboBox()->setCurrentIndex(currentIndex);
177 }
178 }
179 // read the working directory
180 if (mpSettings->contains("workingDirectory")) {
181 MainWindow::instance()->getOMCProxy()->changeDirectory(mpSettings->value("workingDirectory").toString());
182 }
183 mpGeneralSettingsPage->setWorkingDirectory(MainWindow::instance()->getOMCProxy()->changeDirectory());
184 // read toolbar icon size
185 if (mpSettings->contains("toolbarIconSize")) {
186 mpGeneralSettingsPage->getToolbarIconSizeSpinBox()->setValue(mpSettings->value("toolbarIconSize").toInt());
187 }
188 // read the user customizations
189 if (mpSettings->contains("userCustomizations")) {
190 mpGeneralSettingsPage->setPreserveUserCustomizations(mpSettings->value("userCustomizations").toBool());
191 }
192 // read the terminal command
193 if (mpSettings->contains("terminalCommand")) {
194 mpGeneralSettingsPage->setTerminalCommand(mpSettings->value("terminalCommand").toString());
195 }
196 // read the terminal command arguments
197 if (mpSettings->contains("terminalCommandArgs")) {
198 mpGeneralSettingsPage->setTerminalCommandArguments(mpSettings->value("terminalCommandArgs").toString());
199 }
200 // read hide variables browser
201 if (mpSettings->contains("hideVariablesBrowser")) {
202 mpGeneralSettingsPage->getHideVariablesBrowserCheckBox()->setChecked(mpSettings->value("hideVariablesBrowser").toBool());
203 }
204 // read activate access annotations
205 if (mpSettings->contains("activateAccessAnnotations")) {
206 bool ok;
207 int currentIndex = mpGeneralSettingsPage->getActivateAccessAnnotationsComboBox()->findData(mpSettings->value("activateAccessAnnotations").toInt(&ok));
208 if (currentIndex > -1 && ok) {
209 mpGeneralSettingsPage->getActivateAccessAnnotationsComboBox()->setCurrentIndex(currentIndex);
210 }
211 }
212 // read create a backup file
213 if (mpSettings->contains("createBackupFile")) {
214 mpGeneralSettingsPage->getCreateBackupFileCheckbox()->setChecked(mpSettings->value("createBackupFile").toBool());
215 }
216 // read library icon size
217 if (mpSettings->contains("libraryIconSize")) {
218 mpGeneralSettingsPage->getLibraryIconSizeSpinBox()->setValue(mpSettings->value("libraryIconSize").toInt());
219 }
220 // read the max. text length to draw on a library icon
221 if (mpSettings->contains("libraryIconMaxTextLength")) {
222 ShapeAnnotation::maxTextLengthToShowOnLibraryIcon = mpSettings->value("libraryIconMaxTextLength").toInt(); // set cached value
223 }
224 mpGeneralSettingsPage->getLibraryIconTextLengthSpinBox()->setValue(ShapeAnnotation::maxTextLengthToShowOnLibraryIcon);
225 // read show protected classes
226 if (mpSettings->contains("showProtectedClasses")) {
227 mpGeneralSettingsPage->setShowProtectedClasses(mpSettings->value("showProtectedClasses").toBool());
228 }
229 // read show hidden classes
230 if (mpSettings->contains("showHiddenClasses")) {
231 mpGeneralSettingsPage->setShowHiddenClasses(mpSettings->value("showHiddenClasses").toBool());
232 }
233 // read the modeling view mode
234 if (mpSettings->contains("modeling/viewmode")) {
235 mpGeneralSettingsPage->setModelingViewMode(mpSettings->value("modeling/viewmode").toString());
236 }
237 // read the default view
238 if (mpSettings->contains("defaultView")) {
239 mpGeneralSettingsPage->setDefaultView(mpSettings->value("defaultView").toString());
240 }
241 // read auto save
242 if (mpSettings->contains("autoSave/enable")) {
243 mpGeneralSettingsPage->getEnableAutoSaveGroupBox()->setChecked(mpSettings->value("autoSave/enable").toBool());
244 }
245 if (mpSettings->contains("autoSave/interval")) {
246 mpGeneralSettingsPage->getAutoSaveIntervalSpinBox()->setValue(mpSettings->value("autoSave/interval").toInt());
247 }
248 // read welcome page
249 if (mpSettings->contains("welcomePage/view")) {
250 mpGeneralSettingsPage->setWelcomePageView(mpSettings->value("welcomePage/view").toInt());
251 }
252 if (mpSettings->contains("welcomePage/showLatestNews")) {
253 mpGeneralSettingsPage->getShowLatestNewsCheckBox()->setChecked(mpSettings->value("welcomePage/showLatestNews").toBool());
254 }
255}
256
257//! Reads the Libraries section settings from omedit.ini
258void OptionsDialog::readLibrariesSettings()
259{
260 // read the system libraries
261 int i = 0;
262 while(i < mpLibrariesPage->getSystemLibrariesTree()->topLevelItemCount()) {
263 qDeleteAll(mpLibrariesPage->getSystemLibrariesTree()->topLevelItem(i)->takeChildren());
264 delete mpLibrariesPage->getSystemLibrariesTree()->topLevelItem(i);
265 i = 0; //Restart iteration
266 }
267 // read the settings and add libraries
268 mpSettings->beginGroup("libraries");
269 QStringList systemLibraries = mpSettings->childKeys();
270 foreach (QString systemLibrary, systemLibraries)for (auto _container_ = QtPrivate::qMakeForeachContainer(systemLibraries
); _container_.control && _container_.i != _container_
.e; ++_container_.i, _container_.control ^= 1) for (QString systemLibrary
= *_container_.i; _container_.control; _container_.control =
0)
{
271 QStringList values;
272 values << systemLibrary << mpSettings->value(systemLibrary).toString();
273 mpLibrariesPage->getSystemLibrariesTree()->addTopLevelItem(new QTreeWidgetItem(values));
274 }
275 mpSettings->endGroup();
276 // read the forceModelicaLoad
277 if (mpSettings->contains("forceModelicaLoad")) {
278 mpLibrariesPage->getForceModelicaLoadCheckBox()->setChecked(mpSettings->value("forceModelicaLoad").toBool());
279 }
280 // read load OpenModelica library on startup
281 if (mpSettings->contains("loadOpenModelicaOnStartup")) {
282 mpLibrariesPage->getLoadOpenModelicaLibraryCheckBox()->setChecked(mpSettings->value("loadOpenModelicaOnStartup").toBool());
283 }
284 // read user libraries
285 i = 0;
286 while(i < mpLibrariesPage->getUserLibrariesTree()->topLevelItemCount()) {
287 qDeleteAll(mpLibrariesPage->getUserLibrariesTree()->topLevelItem(i)->takeChildren());
288 delete mpLibrariesPage->getUserLibrariesTree()->topLevelItem(i);
289 i = 0; //Restart iteration
290 }
291 // read the settings and add libraries
292 mpSettings->beginGroup("userlibraries");
293 QStringList userLibraries = mpSettings->childKeys();
294 foreach (QString userLibrary, userLibraries)for (auto _container_ = QtPrivate::qMakeForeachContainer(userLibraries
); _container_.control && _container_.i != _container_
.e; ++_container_.i, _container_.control ^= 1) for (QString userLibrary
= *_container_.i; _container_.control; _container_.control =
0)
{
295 QStringList values;
296 values << QUrl::fromPercentEncoding(userLibrary.toUtf8()) << mpSettings->value(userLibrary).toString();
297 mpLibrariesPage->getUserLibrariesTree()->addTopLevelItem(new QTreeWidgetItem(values));
298 }
299 mpSettings->endGroup();
300}
301
302/*!
303 * \brief OptionsDialog::readTextEditorSettings
304 * Reads the Text editor settings from omedit.ini
305 */
306void OptionsDialog::readTextEditorSettings()
307{
308 int index;
309 if (mpSettings->contains("textEditor/lineEnding")) {
310 index = mpTextEditorPage->getLineEndingComboBox()->findData(mpSettings->value("textEditor/lineEnding").toInt());
311 if (index > -1) {
312 mpTextEditorPage->getLineEndingComboBox()->setCurrentIndex(index);
313 }
314 }
315 if (mpSettings->contains("textEditor/bom")) {
316 index = mpTextEditorPage->getBOMComboBox()->findData(mpSettings->value("textEditor/bom").toInt());
317 if (index > -1) {
318 mpTextEditorPage->getBOMComboBox()->setCurrentIndex(index);
319 }
320 }
321 if (mpSettings->contains("textEditor/tabPolicy")) {
322 index = mpTextEditorPage->getTabPolicyComboBox()->findData(mpSettings->value("textEditor/tabPolicy").toInt());
323 if (index > -1) {
324 mpTextEditorPage->getTabPolicyComboBox()->setCurrentIndex(index);
325 }
326 }
327 if (mpSettings->contains("textEditor/tabSize")) {
328 mpTextEditorPage->getTabSizeSpinBox()->setValue(mpSettings->value("textEditor/tabSize").toInt());
329 }
330 if (mpSettings->contains("textEditor/indentSize")) {
331 mpTextEditorPage->getIndentSpinBox()->setValue(mpSettings->value("textEditor/indentSize").toInt());
332 }
333 if (mpSettings->contains("textEditor/enableSyntaxHighlighting")) {
334 mpTextEditorPage->getSyntaxHighlightingGroupBox()->setChecked(mpSettings->value("textEditor/enableSyntaxHighlighting").toBool());
335 }
336 if (mpSettings->contains("textEditor/enableCodeFolding")) {
337 mpTextEditorPage->getCodeFoldingCheckBox()->setChecked(mpSettings->value("textEditor/enableCodeFolding").toBool());
338 }
339 if (mpSettings->contains("textEditor/matchParenthesesCommentsQuotes")) {
340 mpTextEditorPage->getMatchParenthesesCommentsQuotesCheckBox()->setChecked(mpSettings->value("textEditor/matchParenthesesCommentsQuotes").toBool());
341 }
342 if (mpSettings->contains("textEditor/enableLineWrapping")) {
343 mpTextEditorPage->getLineWrappingCheckbox()->setChecked(mpSettings->value("textEditor/enableLineWrapping").toBool());
344 }
345 if (mpSettings->contains("textEditor/fontFamily")) {
346 // select font family item
347 index = mpTextEditorPage->getFontFamilyComboBox()->findText(mpSettings->value("textEditor/fontFamily").toString(), Qt::MatchExactly);
348 if (index > -1) {
349 mpTextEditorPage->getFontFamilyComboBox()->setCurrentIndex(index);
350 }
351 }
352 if (mpSettings->contains("textEditor/fontSize")) {
353 // select font size item
354 mpTextEditorPage->getFontSizeSpinBox()->setValue(mpSettings->value("textEditor/fontSize").toDouble());
355 }
356 if (mpSettings->contains("textEditor/enableAutocomplete")) {
357 mpTextEditorPage->getAutoCompleteCheckBox()->setChecked(mpSettings->value("textEditor/enableAutocomplete").toBool());
358 }
359}
360
361/*!
362 * \brief OptionsDialog::readModelicaEditorSettings
363 * Reads the ModelicaEditor settings from omedit.ini
364 */
365void OptionsDialog::readModelicaEditorSettings()
366{
367 if (mpSettings->contains("modelicaEditor/preserveTextIndentation")) {
368 mpModelicaEditorPage->getPreserveTextIndentationCheckBox()->setChecked(mpSettings->value("modelicaEditor/preserveTextIndentation").toBool());
369 }
370 if (mpSettings->contains("modelicaEditor/textRuleColor")) {
371 mpModelicaEditorPage->setColor("Text", QColor(mpSettings->value("modelicaEditor/textRuleColor").toUInt()));
372 }
373 if (mpSettings->contains("modelicaEditor/keywordRuleColor")) {
374 mpModelicaEditorPage->setColor("Keyword", QColor(mpSettings->value("modelicaEditor/keywordRuleColor").toUInt()));
375 }
376 if (mpSettings->contains("modelicaEditor/typeRuleColor")) {
377 mpModelicaEditorPage->setColor("Type", QColor(mpSettings->value("modelicaEditor/typeRuleColor").toUInt()));
378 }
379 if (mpSettings->contains("modelicaEditor/functionRuleColor")) {
380 mpModelicaEditorPage->setColor("Function", QColor(mpSettings->value("modelicaEditor/functionRuleColor").toUInt()));
381 }
382 if (mpSettings->contains("modelicaEditor/quotesRuleColor")) {
383 mpModelicaEditorPage->setColor("Quotes", QColor(mpSettings->value("modelicaEditor/quotesRuleColor").toUInt()));
384 }
385 if (mpSettings->contains("modelicaEditor/commentRuleColor")) {
386 mpModelicaEditorPage->setColor("Comment", QColor(mpSettings->value("modelicaEditor/commentRuleColor").toUInt()));
387 }
388 if (mpSettings->contains("modelicaEditor/numberRuleColor")) {
389 mpModelicaEditorPage->setColor("Number", QColor(mpSettings->value("modelicaEditor/numberRuleColor").toUInt()));
390 }
391}
392
393/*!
394 * \brief OptionsDialog::readMetaModelicaEditorSettings
395 * Reads the MetaModelicaEditor settings from omedit.ini
396 */
397void OptionsDialog::readMetaModelicaEditorSettings()
398{
399 if (mpSettings->contains("metaModelicaEditor/textRuleColor")) {
400 mpMetaModelicaEditorPage->setColor("Text", QColor(mpSettings->value("metaModelicaEditor/textRuleColor").toUInt()));
401 }
402 if (mpSettings->contains("metaModelicaEditor/keywordRuleColor")) {
403 mpMetaModelicaEditorPage->setColor("Keyword", QColor(mpSettings->value("metaModelicaEditor/keywordRuleColor").toUInt()));
404 }
405 if (mpSettings->contains("metaModelicaEditor/typeRuleColor")) {
406 mpMetaModelicaEditorPage->setColor("Type", QColor(mpSettings->value("metaModelicaEditor/typeRuleColor").toUInt()));
407 }
408 if (mpSettings->contains("metaModelicaEditor/quotesRuleColor")) {
409 mpMetaModelicaEditorPage->setColor("Quotes", QColor(mpSettings->value("metaModelicaEditor/quotesRuleColor").toUInt()));
410 }
411 if (mpSettings->contains("metaModelicaEditor/commentRuleColor")) {
412 mpMetaModelicaEditorPage->setColor("Comment", QColor(mpSettings->value("metaModelicaEditor/commentRuleColor").toUInt()));
413 }
414 if (mpSettings->contains("metaModelicaEditor/numberRuleColor")) {
415 mpMetaModelicaEditorPage->setColor("Number", QColor(mpSettings->value("metaModelicaEditor/numberRuleColor").toUInt()));
416 }
417}
418
419/*!
420 * \brief OptionsDialog::readCompositeModelEditorSettings
421 * Reads the CompositeModelEditor settings from omedit.ini
422 */
423void OptionsDialog::readCompositeModelEditorSettings()
424{
425 if (mpSettings->contains("compositeModelEditor/textRuleColor")) {
426 mpCompositeModelEditorPage->setColor("Text", QColor(mpSettings->value("compositeModelEditor/textRuleColor").toUInt()));
427 }
428 if (mpSettings->contains("compositeModelEditor/commentRuleColor")) {
429 mpCompositeModelEditorPage->setColor("Comment", QColor(mpSettings->value("compositeModelEditor/commentRuleColor").toUInt()));
430 }
431 if (mpSettings->contains("compositeModelEditor/tagRuleColor")) {
432 mpCompositeModelEditorPage->setColor("Tag", QColor(mpSettings->value("compositeModelEditor/tagRuleColor").toUInt()));
433 }
434 if (mpSettings->contains("compositeModelEditor/quotesRuleColor")) {
435 mpCompositeModelEditorPage->setColor("Quotes", QColor(mpSettings->value("compositeModelEditor/quotesRuleColor").toUInt()));
436 }
437 if (mpSettings->contains("compositeModelEditor/elementsRuleColor")) {
438 mpCompositeModelEditorPage->setColor("Element", QColor(mpSettings->value("compositeModelEditor/elementsRuleColor").toUInt()));
439 }
440}
441
442/*!
443 * \brief OptionsDialog::readOMSCompositeModelEditorSettings
444 * Reads the OMSCompositeModelEditor settings from omedit.ini
445 */
446void OptionsDialog::readOMSimulatorEditorSettings()
447{
448 if (mpSettings->contains("omsimulatorEditor/textRuleColor")) {
449 mpOMSimulatorEditorPage->setColor("Text", QColor(mpSettings->value("omsimulatorEditor/textRuleColor").toUInt()));
450 }
451 if (mpSettings->contains("omsimulatorEditor/commentRuleColor")) {
452 mpOMSimulatorEditorPage->setColor("Comment", QColor(mpSettings->value("omsimulatorEditor/commentRuleColor").toUInt()));
453 }
454 if (mpSettings->contains("omsimulatorEditor/tagRuleColor")) {
455 mpOMSimulatorEditorPage->setColor("Tag", QColor(mpSettings->value("omsimulatorEditor/tagRuleColor").toUInt()));
456 }
457 if (mpSettings->contains("omsimulatorEditor/quotesRuleColor")) {
458 mpOMSimulatorEditorPage->setColor("Quotes", QColor(mpSettings->value("omsimulatorEditor/quotesRuleColor").toUInt()));
459 }
460 if (mpSettings->contains("omsimulatorEditor/elementsRuleColor")) {
461 mpOMSimulatorEditorPage->setColor("Element", QColor(mpSettings->value("omsimulatorEditor/elementsRuleColor").toUInt()));
462 }
463}
464
465/*!
466 * \brief OptionsDialog::readCEditorSettings
467 * Reads the CEditor settings from omedit.ini
468 */
469void OptionsDialog::readCEditorSettings()
470{
471 if (mpSettings->contains("cEditor/textRuleColor")) {
472 mpCEditorPage->setColor("Text", QColor(mpSettings->value("cEditor/textRuleColor").toUInt()));
473 }
474 if (mpSettings->contains("cEditor/keywordRuleColor")) {
475 mpCEditorPage->setColor("Keyword", QColor(mpSettings->value("cEditor/keywordRuleColor").toUInt()));
476 }
477 if (mpSettings->contains("cEditor/typeRuleColor")) {
478 mpCEditorPage->setColor("Type", QColor(mpSettings->value("cEditor/typeRuleColor").toUInt()));
479 }
480 if (mpSettings->contains("cEditor/quotesRuleColor")) {
481 mpCEditorPage->setColor("Quotes", QColor(mpSettings->value("cEditor/quotesRuleColor").toUInt()));
482 }
483 if (mpSettings->contains("cEditor/commentRuleColor")) {
484 mpCEditorPage->setColor("Comment", QColor(mpSettings->value("cEditor/commentRuleColor").toUInt()));
485 }
486 if (mpSettings->contains("cEditor/numberRuleColor")) {
487 mpCEditorPage->setColor("Number", QColor(mpSettings->value("cEditor/numberRuleColor").toUInt()));
488 }
489}
490
491/*!
492 * \brief OptionsDialog::readHTMLEditorSettings
493 * Reads the HTMLEditor settings from omedit.ini
494 */
495void OptionsDialog::readHTMLEditorSettings()
496{
497 if (mpSettings->contains("HTMLEditor/textRuleColor")) {
498 mpHTMLEditorPage->setColor("Text", QColor(mpSettings->value("HTMLEditor/textRuleColor").toUInt()));
499 }
500 if (mpSettings->contains("HTMLEditor/commentRuleColor")) {
501 mpHTMLEditorPage->setColor("Comment", QColor(mpSettings->value("HTMLEditor/commentRuleColor").toUInt()));
502 }
503 if (mpSettings->contains("HTMLEditor/tagRuleColor")) {
504 mpHTMLEditorPage->setColor("Tag", QColor(mpSettings->value("HTMLEditor/tagRuleColor").toUInt()));
505 }
506 if (mpSettings->contains("HTMLEditor/quotesRuleColor")) {
507 mpHTMLEditorPage->setColor("Quotes", QColor(mpSettings->value("HTMLEditor/quotesRuleColor").toUInt()));
508 }
509}
510
511//! Reads the GraphicsViews section settings from omedit.ini
512void OptionsDialog::readGraphicalViewsSettings()
513{
514 if (mpSettings->contains("iconView/extentLeft"))
515 mpGraphicalViewsPage->setIconViewExtentLeft(mpSettings->value("iconView/extentLeft").toDouble());
516 if (mpSettings->contains("iconView/extentBottom"))
517 mpGraphicalViewsPage->setIconViewExtentBottom(mpSettings->value("iconView/extentBottom").toDouble());
518 if (mpSettings->contains("iconView/extentRight"))
519 mpGraphicalViewsPage->setIconViewExtentRight(mpSettings->value("iconView/extentRight").toDouble());
520 if (mpSettings->contains("iconView/extentTop"))
521 mpGraphicalViewsPage->setIconViewExtentTop(mpSettings->value("iconView/extentTop").toDouble());
522 if (mpSettings->contains("iconView/gridHorizontal"))
523 mpGraphicalViewsPage->setIconViewGridHorizontal(mpSettings->value("iconView/gridHorizontal").toDouble());
524 if (mpSettings->contains("iconView/gridVertical"))
525 mpGraphicalViewsPage->setIconViewGridVertical(mpSettings->value("iconView/gridVertical").toDouble());
526 if (mpSettings->contains("iconView/scaleFactor"))
527 mpGraphicalViewsPage->setIconViewScaleFactor(mpSettings->value("iconView/scaleFactor").toDouble());
528 if (mpSettings->contains("iconView/preserveAspectRatio"))
529 mpGraphicalViewsPage->setIconViewPreserveAspectRation(mpSettings->value("iconView/preserveAspectRatio").toBool());
530 if (mpSettings->contains("DiagramView/extentLeft"))
531 mpGraphicalViewsPage->setDiagramViewExtentLeft(mpSettings->value("DiagramView/extentLeft").toDouble());
532 if (mpSettings->contains("DiagramView/extentBottom"))
533 mpGraphicalViewsPage->setDiagramViewExtentBottom(mpSettings->value("DiagramView/extentBottom").toDouble());
534 if (mpSettings->contains("DiagramView/extentRight"))
535 mpGraphicalViewsPage->setDiagramViewExtentRight(mpSettings->value("DiagramView/extentRight").toDouble());
536 if (mpSettings->contains("DiagramView/extentTop"))
537 mpGraphicalViewsPage->setDiagramViewExtentTop(mpSettings->value("DiagramView/extentTop").toDouble());
538 if (mpSettings->contains("DiagramView/gridHorizontal"))
539 mpGraphicalViewsPage->setDiagramViewGridHorizontal(mpSettings->value("DiagramView/gridHorizontal").toDouble());
540 if (mpSettings->contains("DiagramView/gridVertical"))
541 mpGraphicalViewsPage->setDiagramViewGridVertical(mpSettings->value("DiagramView/gridVertical").toDouble());
542 if (mpSettings->contains("DiagramView/scaleFactor"))
543 mpGraphicalViewsPage->setDiagramViewScaleFactor(mpSettings->value("DiagramView/scaleFactor").toDouble());
544 if (mpSettings->contains("DiagramView/preserveAspectRatio"))
545 mpGraphicalViewsPage->setDiagramViewPreserveAspectRation(mpSettings->value("DiagramView/preserveAspectRatio").toBool());
546}
547
548//! Reads the Simulation section settings from omedit.ini
549void OptionsDialog::readSimulationSettings()
550{
551 if (mpSettings->contains("simulation/matchingAlgorithm")) {
552 int currentIndex = mpSimulationPage->getTranslationFlagsWidget()->getMatchingAlgorithmComboBox()->findText(mpSettings->value("simulation/matchingAlgorithm").toString(), Qt::MatchExactly);
553 if (currentIndex > -1) {
554 mpSimulationPage->getTranslationFlagsWidget()->getMatchingAlgorithmComboBox()->setCurrentIndex(currentIndex);
555 }
556 }
557 if (mpSettings->contains("simulation/indexReductionMethod")) {
558 int currentIndex = mpSimulationPage->getTranslationFlagsWidget()->getIndexReductionMethodComboBox()->findText(mpSettings->value("simulation/indexReductionMethod").toString(), Qt::MatchExactly);
559 if (currentIndex > -1) {
560 mpSimulationPage->getTranslationFlagsWidget()->getIndexReductionMethodComboBox()->setCurrentIndex(currentIndex);
561 }
562 }
563 // read initialization
564 if (mpSettings->contains("simulation/initialization")) {
565 mpSimulationPage->getTranslationFlagsWidget()->getInitializationCheckBox()->setChecked(mpSettings->value("simulation/initialization").toBool());
566 }
567 // read evaluate all parameters
568 if (mpSettings->contains("simulation/evaluateAllParameters")) {
569 mpSimulationPage->getTranslationFlagsWidget()->getEvaluateAllParametersCheckBox()->setChecked(mpSettings->value("simulation/evaluateAllParameters").toBool());
570 }
571 // read NLS analytic jacobian
572 if (mpSettings->contains("simulation/NLSanalyticJacobian")) {
573 mpSimulationPage->getTranslationFlagsWidget()->getNLSanalyticJacobianCheckBox()->setChecked(mpSettings->value("simulation/NLSanalyticJacobian").toBool());
574 }
575 // save parmodauto
576 if (mpSettings->contains("simulation/parmodauto")) {
577 mpSimulationPage->getTranslationFlagsWidget()->getParmodautoCheckBox()->setChecked(mpSettings->value("simulation/parmodauto").toBool());
578 }
579 // save old instantiation
580 if (mpSettings->contains("simulation/newInst")) {
581 mpSimulationPage->getTranslationFlagsWidget()->getOldInstantiationCheckBox()->setChecked(!mpSettings->value("simulation/newInst").toBool());
582 }
583 if (mpSettings->contains("simulation/dataReconciliation")) {
584 mpSimulationPage->getTranslationFlagsWidget()->getDataReconciliationCheckBox()->setChecked(mpSettings->value("simulation/dataReconciliation").toBool());
585 }
586 if (mpSettings->contains("simulation/OMCFlags")) {
587 mpSimulationPage->getTranslationFlagsWidget()->getAdditionalTranslationFlagsTextBox()->setText(mpSettings->value("simulation/OMCFlags").toString());
588 }
589 if (mpSettings->contains("simulation/targetLanguage")) {
590 int currentIndex = mpSimulationPage->getTargetLanguageComboBox()->findText(mpSettings->value("simulation/targetLanguage").toString(), Qt::MatchExactly);
591 if (currentIndex > -1) {
592 mpSimulationPage->getTargetLanguageComboBox()->setCurrentIndex(currentIndex);
593 }
594 }
595 if (mpSettings->contains("simulation/targetCompiler")) {
596 int currentIndex = mpSimulationPage->getTargetBuildComboBox()->findData(mpSettings->value("simulation/targetCompiler"), Qt::UserRole, Qt::MatchExactly);
597 if (currentIndex > -1) {
598 mpSimulationPage->getTargetBuildComboBox()->setCurrentIndex(currentIndex);
599 }
600 }
601 if (mpSettings->contains("simulation/compiler")) {
602 mpSimulationPage->getCompilerComboBox()->lineEdit()->setText(mpSettings->value("simulation/compiler").toString());
603 }
604 if (mpSettings->contains("simulation/cxxCompiler")) {
605 mpSimulationPage->getCXXCompilerComboBox()->lineEdit()->setText(mpSettings->value("simulation/cxxCompiler").toString());
606 }
607 if (mpSettings->contains("simulation/ignoreCommandLineOptionsAnnotation")) {
608 mpSimulationPage->getIgnoreCommandLineOptionsAnnotationCheckBox()->setChecked(mpSettings->value("simulation/ignoreCommandLineOptionsAnnotation").toBool());
609 }
610 if (mpSettings->contains("simulation/ignoreSimulationFlagsAnnotation")) {
611 mpSimulationPage->getIgnoreSimulationFlagsAnnotationCheckBox()->setChecked(mpSettings->value("simulation/ignoreSimulationFlagsAnnotation").toBool());
612 }
613 if (mpSettings->contains("simulation/saveClassBeforeSimulation")) {
614 mpSimulationPage->getSaveClassBeforeSimulationCheckBox()->setChecked(mpSettings->value("simulation/saveClassBeforeSimulation").toBool());
615 }
616 if (mpSettings->contains("simulation/switchToPlottingPerspectiveAfterSimulation")) {
617 mpSimulationPage->getSwitchToPlottingPerspectiveCheckBox()->setChecked(mpSettings->value("simulation/switchToPlottingPerspectiveAfterSimulation").toBool());
618 }
619 if (mpSettings->contains("simulation/closeSimulationOutputWidgetsBeforeSimulation")) {
620 mpSimulationPage->getCloseSimulationOutputWidgetsBeforeSimulationCheckBox()->setChecked(mpSettings->value("simulation/closeSimulationOutputWidgetsBeforeSimulation").toBool());
621 }
622 if (mpSettings->contains("simulation/deleteIntermediateCompilationFiles")) {
623 mpSimulationPage->getDeleteIntermediateCompilationFilesCheckBox()->setChecked(mpSettings->value("simulation/deleteIntermediateCompilationFiles").toBool());
624 }
625 if (mpSettings->contains("simulation/deleteEntireSimulationDirectory")) {
626 mpSimulationPage->getDeleteEntireSimulationDirectoryCheckBox()->setChecked(mpSettings->value("simulation/deleteEntireSimulationDirectory").toBool());
627 }
628 if (mpSettings->contains("simulation/nfAPI")) {
629 mpSimulationPage->getEnableNewInstantiationAPICheckBox()->setChecked(mpSettings->value("simulation/nfAPI").toBool());
630 }
631 if (mpSettings->contains("simulation/nfAPINoise")) {
632 mpSimulationPage->getDisplayNFAPIErrorsWarningsCheckBox()->setChecked(mpSettings->value("simulation/nfAPINoise").toBool());
633 }
634 if (mpSettings->contains("simulation/outputMode")) {
635 mpSimulationPage->setOutputMode(mpSettings->value("simulation/outputMode").toString());
636 }
637 if (mpSettings->contains("simulation/displayLimit")) {
638 mpSimulationPage->getDisplayLimitSpinBox()->setValue(mpSettings->value("simulation/displayLimit").toInt());
639 }
640}
641//! Reads the Messages section settings from omedit.ini
642void OptionsDialog::readMessagesSettings()
643{
644 // read output size
645 if (mpSettings->contains("messages/outputSize")) {
646 mpMessagesPage->getOutputSizeSpinBox()->setValue(mpSettings->value("messages/outputSize").toInt());
647 }
648 if (mpSettings->contains("messages/resetMessagesNumber")) {
649 mpMessagesPage->getResetMessagesNumberBeforeSimulationCheckBox()->setChecked(mpSettings->value("messages/resetMessagesNumber").toBool());
650 }
651 if (mpSettings->contains("messages/clearMessagesBrowser")) {
652 mpMessagesPage->getClearMessagesBrowserBeforeSimulationCheckBox()->setChecked(mpSettings->value("messages/clearMessagesBrowser").toBool());
653 }
654 // read font family
655 if (mpSettings->contains("messages/fontFamily")) {
656 int currentIndex;
657 // select font family item
658 currentIndex = mpMessagesPage->getFontFamilyComboBox()->findText(mpSettings->value("messages/fontFamily").toString(), Qt::MatchExactly);
659 mpMessagesPage->getFontFamilyComboBox()->setCurrentIndex(currentIndex);
660 }
661 // read font size
662 if (mpSettings->contains("messages/fontSize")) {
663 mpMessagesPage->getFontSizeSpinBox()->setValue(mpSettings->value("messages/fontSize").toDouble());
664 }
665 // read notification color
666 if (mpSettings->contains("messages/notificationColor")) {
667 QColor color = QColor(mpSettings->value("messages/notificationColor").toUInt());
668 if (color.isValid()) {
669 mpMessagesPage->setNotificationColor(color);
670 mpMessagesPage->setNotificationPickColorButtonIcon();
671 }
672 }
673 // read warning color
674 if (mpSettings->contains("messages/warningColor")) {
675 QColor color = QColor(mpSettings->value("messages/warningColor").toUInt());
676 if (color.isValid()) {
677 mpMessagesPage->setWarningColor(color);
678 mpMessagesPage->setWarningPickColorButtonIcon();
679 }
680 }
681 // read error color
682 if (mpSettings->contains("messages/errorColor")) {
683 QColor color = QColor(mpSettings->value("messages/errorColor").toUInt());
684 if (color.isValid()) {
685 mpMessagesPage->setErrorColor(color);
686 mpMessagesPage->setErrorPickColorButtonIcon();
687 }
688 }
689}
690
691//! Reads the Notifications section settings from omedit.ini
692void OptionsDialog::readNotificationsSettings()
693{
694 if (mpSettings->contains("notifications/promptQuitApplication")) {
695 mpNotificationsPage->getQuitApplicationCheckBox()->setChecked(mpSettings->value("notifications/promptQuitApplication").toBool());
696 }
697 if (mpSettings->contains("notifications/itemDroppedOnItself")) {
698 mpNotificationsPage->getItemDroppedOnItselfCheckBox()->setChecked(mpSettings->value("notifications/itemDroppedOnItself").toBool());
699 }
700 if (mpSettings->contains("notifications/replaceableIfPartial")) {
701 mpNotificationsPage->getReplaceableIfPartialCheckBox()->setChecked(mpSettings->value("notifications/replaceableIfPartial").toBool());
702 }
703 if (mpSettings->contains("notifications/innerModelNameChanged")) {
704 mpNotificationsPage->getInnerModelNameChangedCheckBox()->setChecked(mpSettings->value("notifications/innerModelNameChanged").toBool());
705 }
706 if (mpSettings->contains("notifications/saveModelForBitmapInsertion")) {
707 mpNotificationsPage->getSaveModelForBitmapInsertionCheckBox()->setChecked(mpSettings->value("notifications/saveModelForBitmapInsertion").toBool());
708 }
709 if (mpSettings->contains("notifications/alwaysAskForDraggedComponentName")) {
710 mpNotificationsPage->getAlwaysAskForDraggedComponentName()->setChecked(mpSettings->value("notifications/alwaysAskForDraggedComponentName").toBool());
711 }
712 if (mpSettings->contains("notifications/alwaysAskForTextEditorError")) {
713 mpNotificationsPage->getAlwaysAskForTextEditorErrorCheckBox()->setChecked(mpSettings->value("notifications/alwaysAskForTextEditorError").toBool());
714 }
715 if (mpSettings->contains("notifications/promptOldFrontend")) {
716 bool ok;
717 int currentIndex = mpNotificationsPage->getOldFrontendComboBox()->findData(mpSettings->value("notifications/promptOldFrontend").toInt(&ok));
718 if (currentIndex > -1 && ok) {
719 mpNotificationsPage->getOldFrontendComboBox()->setCurrentIndex(currentIndex);
720 }
721 }
722}
723
724//! Reads the LineStyle section settings from omedit.ini
725void OptionsDialog::readLineStyleSettings()
726{
727 if (mpSettings->contains("linestyle/color"))
728 {
729 QColor color = QColor(mpSettings->value("linestyle/color").toUInt());
730 if (color.isValid())
731 {
732 mpLineStylePage->setLineColor(color);
733 mpLineStylePage->setLinePickColorButtonIcon();
734 }
735 }
736 if (mpSettings->contains("linestyle/pattern"))
737 mpLineStylePage->setLinePattern(mpSettings->value("linestyle/pattern").toString());
738 if (mpSettings->contains("linestyle/thickness"))
739 mpLineStylePage->setLineThickness(mpSettings->value("linestyle/thickness").toFloat());
740 if (mpSettings->contains("linestyle/startArrow"))
741 mpLineStylePage->setLineStartArrow(mpSettings->value("linestyle/startArrow").toString());
742 if (mpSettings->contains("linestyle/endArrow"))
743 mpLineStylePage->setLineEndArrow(mpSettings->value("linestyle/endArrow").toString());
744 if (mpSettings->contains("linestyle/arrowSize"))
745 mpLineStylePage->setLineArrowSize(mpSettings->value("linestyle/arrowSize").toFloat());
746 if (mpSettings->contains("linestyle/smooth"))
747 mpLineStylePage->setLineSmooth(mpSettings->value("linestyle/smooth").toBool());
748}
749
750//! Reads the FillStyle section settings from omedit.ini
751void OptionsDialog::readFillStyleSettings()
752{
753 if (mpSettings->contains("fillstyle/color"))
754 {
755 QColor color = QColor(mpSettings->value("fillstyle/color").toUInt());
756 if (color.isValid())
757 {
758 mpFillStylePage->setFillColor(color);
759 mpFillStylePage->setFillPickColorButtonIcon();
760 }
761 }
762 if (mpSettings->contains("fillstyle/pattern"))
763 mpFillStylePage->setFillPattern(mpSettings->value("fillstyle/pattern").toString());
764}
765
766//! Reads the Plotting section settings from omedit.ini
767void OptionsDialog::readPlottingSettings()
768{
769 // read the auto scale
770 if (mpSettings->contains("plotting/autoScale")) {
771 mpPlottingPage->getAutoScaleCheckBox()->setChecked(mpSettings->value("plotting/autoScale").toBool());
772 }
773 // read the plotting view mode
774 if (mpSettings->contains("plotting/viewmode")) {
775 mpPlottingPage->setPlottingViewMode(mpSettings->value("plotting/viewmode").toString());
776 }
777 if (mpSettings->contains("curvestyle/pattern")) {
778 mpPlottingPage->setCurvePattern(mpSettings->value("curvestyle/pattern").toInt());
779 }
780 if (mpSettings->contains("curvestyle/thickness")) {
781 mpPlottingPage->setCurveThickness(mpSettings->value("curvestyle/thickness").toFloat());
782 }
783 if (mpSettings->contains("variableFilter/interval")) {
784 mpPlottingPage->getFilterIntervalSpinBox()->setValue(mpSettings->value("variableFilter/interval").toInt());
785 }
786 if (mpSettings->contains("plotting/titleFontSize")) {
787 mpPlottingPage->getTitleFontSizeSpinBox()->setValue(mpSettings->value("plotting/titleFontSize").toDouble());
788 }
789 if (mpSettings->contains("plotting/verticalAxisTitleFontSize")) {
790 mpPlottingPage->getVerticalAxisTitleFontSizeSpinBox()->setValue(mpSettings->value("plotting/verticalAxisTitleFontSize").toDouble());
791 }
792 if (mpSettings->contains("plotting/verticalAxisNumbersFontSize")) {
793 mpPlottingPage->getVerticalAxisNumbersFontSizeSpinBox()->setValue(mpSettings->value("plotting/verticalAxisNumbersFontSize").toDouble());
794 }
795 if (mpSettings->contains("plotting/horizontalAxisTitleFontSize")) {
796 mpPlottingPage->getHorizontalAxisTitleFontSizeSpinBox()->setValue(mpSettings->value("plotting/horizontalAxisTitleFontSize").toDouble());
797 }
798 if (mpSettings->contains("plotting/horizontalAxisNumbersFontSize")) {
799 mpPlottingPage->getHorizontalAxisNumbersFontSizeSpinBox()->setValue(mpSettings->value("plotting/horizontalAxisNumbersFontSize").toDouble());
800 }
801 if (mpSettings->contains("plotting/footerFontSize")) {
802 mpPlottingPage->getFooterFontSizeSpinBox()->setValue(mpSettings->value("plotting/footerFontSize").toDouble());
803 }
804 if (mpSettings->contains("plotting/legendFontSize")) {
805 mpPlottingPage->getLegendFontSizeSpinBox()->setValue(mpSettings->value("plotting/legendFontSize").toDouble());
806 }
807}
808
809//! Reads the Fiagro section settings from omedit.ini
810void OptionsDialog::readFigaroSettings()
811{
812 if (mpSettings->contains("figaro/databasefile")) {
813 mpFigaroPage->getFigaroDatabaseFileTextBox()->setText(mpSettings->value("figaro/databasefile").toString());
814 }
815 if (mpSettings->contains("figaro/options")) {
816 mpFigaroPage->getFigaroOptionsTextBox()->setText(mpSettings->value("figaro/options").toString());
817 }
818 if (mpSettings->contains("figaro/process") && !mpSettings->value("figaro/process").toString().isEmpty()) {
819 mpFigaroPage->getFigaroProcessTextBox()->setText(mpSettings->value("figaro/process").toString());
820 }
821}
822
823/*!
824 Reads the Debugger section settings from omedit.ini
825 */
826void OptionsDialog::readDebuggerSettings()
827{
828 if (mpSettings->contains("algorithmicDebugger/GDBPath")) {
829 mpDebuggerPage->setGDBPath(mpSettings->value("algorithmicDebugger/GDBPath").toString());
830 }
831 if (mpSettings->contains("algorithmicDebugger/GDBCommandTimeout")) {
832 mpDebuggerPage->getGDBCommandTimeoutSpinBox()->setValue(mpSettings->value("algorithmicDebugger/GDBCommandTimeout").toInt());
833 }
834 if (mpSettings->contains("algorithmicDebugger/GDBOutputLimit")) {
835 mpDebuggerPage->getGDBOutputLimitSpinBox()->setValue(mpSettings->value("algorithmicDebugger/GDBOutputLimit").toInt());
836 }
837 if (mpSettings->contains("algorithmicDebugger/displayCFrames")) {
838 mpDebuggerPage->getDisplayCFramesCheckBox()->setChecked(mpSettings->value("algorithmicDebugger/displayCFrames").toBool());
839 }
840 if (mpSettings->contains("algorithmicDebugger/displayUnknownFrames")) {
841 mpDebuggerPage->getDisplayUnknownFramesCheckBox()->setChecked(mpSettings->value("algorithmicDebugger/displayUnknownFrames").toBool());
842 }
843 if (mpSettings->contains("algorithmicDebugger/clearOutputOnNewRun")) {
844 mpDebuggerPage->getClearOutputOnNewRunCheckBox()->setChecked(mpSettings->value("algorithmicDebugger/clearOutputOnNewRun").toBool());
845 }
846 if (mpSettings->contains("algorithmicDebugger/clearLogOnNewRun")) {
847 mpDebuggerPage->getClearLogOnNewRunCheckBox()->setChecked(mpSettings->value("algorithmicDebugger/clearLogOnNewRun").toBool());
848 }
849 if (mpSettings->contains("transformationalDebugger/alwaysShowTransformationalDebugger")) {
850 mpDebuggerPage->getAlwaysShowTransformationsCheckBox()->setChecked(mpSettings->value("transformationalDebugger/alwaysShowTransformationalDebugger").toBool());
851 }
852 if (mpSettings->contains("transformationalDebugger/generateOperations")) {
853 mpDebuggerPage->getGenerateOperationsCheckBox()->setChecked(mpSettings->value("transformationalDebugger/generateOperations").toBool());
854 }
855}
856
857/*!
858 * \brief OptionsDialog::readFMISettings
859 * Reads the FMI section settings from omedit.ini
860 */
861void OptionsDialog::readFMISettings()
862{
863 if (mpSettings->contains("FMIExport/Version")) {
864 mpFMIPage->setFMIExportVersion(mpSettings->value("FMIExport/Version").toString());
865 }
866 if (mpSettings->contains("FMIExport/Type")) {
867 mpFMIPage->setFMIExportType(mpSettings->value("FMIExport/Type").toString());
868 }
869 if (mpSettings->contains("FMIExport/FMUName")) {
870 mpFMIPage->getFMUNameTextBox()->setText(mpSettings->value("FMIExport/FMUName").toString());
871 }
872 if (mpSettings->contains("FMIExport/MoveFMU")) {
873 mpFMIPage->getMoveFMUTextBox()->setText(mpSettings->value("FMIExport/MoveFMU").toString());
874 }
875 // read platforms
876 QStringList platforms = mpSettings->value("FMIExport/Platforms").toStringList();
877 foreach (QString platform, platforms)for (auto _container_ = QtPrivate::qMakeForeachContainer(platforms
); _container_.control && _container_.i != _container_
.e; ++_container_.i, _container_.control ^= 1) for (QString platform
= *_container_.i; _container_.control; _container_.control =
0)
{
878 int currentIndex = mpFMIPage->getLinkingComboBox()->findData(platform);
879 if (currentIndex > -1) {
880 mpFMIPage->getLinkingComboBox()->setCurrentIndex(currentIndex);
881 } else {
882 int i = 0;
883 while (QLayoutItem* pLayoutItem = mpFMIPage->getPlatformsGroupBox()->layout()->itemAt(i)) {
884 if (dynamic_cast<QCheckBox*>(pLayoutItem->widget())) {
885 QCheckBox *pPlatformCheckBox = dynamic_cast<QCheckBox*>(pLayoutItem->widget());
886 if (pPlatformCheckBox->property(Helper::fmuPlatformNamePropertyId).toString().compare(platform) == 0) {
887 pPlatformCheckBox->setChecked(true);
888 break;
889 }
890 }
891 i++;
892 }
893 }
894 }
895 if (mpSettings->contains("FMIImport/DeleteFMUDirectoyAndModel")) {
896 mpFMIPage->getDeleteFMUDirectoryAndModelCheckBox()->setChecked(mpSettings->value("FMIImport/DeleteFMUDirectoyAndModel").toBool());
897 }
898}
899
900/*!
901 * \brief OptionsDialog::readTLMSettings
902 * Reads the TLM settings from omedit.ini
903 */
904void OptionsDialog::readTLMSettings()
905{
906 // read TLM Path
907 if (mpSettings->contains("TLM/PluginPath")) {
908 mpTLMPage->getTLMPluginPathTextBox()->setText(mpSettings->value("TLM/PluginPath").toString());
909 }
910 // read the TLM Manager Process
911 if (mpSettings->contains("TLM/ManagerProcess")) {
912 mpTLMPage->getTLMManagerProcessTextBox()->setText(mpSettings->value("TLM/ManagerProcess").toString());
913 }
914 // read TLM Monitor Process
915 if (mpSettings->contains("TLM/MonitorProcess")) {
916 mpTLMPage->getTLMMonitorProcessTextBox()->setText(mpSettings->value("TLM/MonitorProcess").toString());
917 }
918}
919
920/*!
921 * \brief OptionsDialog::readOMSimulatorSettings
922 * Reads the OMSimulator settings from omedit.ini
923 */
924void OptionsDialog::readOMSimulatorSettings()
925{
926 // read command line options
927 if (mpSettings->contains("OMSimulator/commandLineOptions")) {
928 QString commandLineOptions = mpSettings->value("OMSimulator/commandLineOptions").toString();
929 mpOMSimulatorPage->getCommandLineOptionsTextBox()->setText(commandLineOptions);
930 OMSProxy::instance()->setCommandLineOption(commandLineOptions);
931 }
932 // read working directory
933 if (mpSettings->contains("OMSimulator/workingDirectory")) {
934 mpOMSimulatorPage->setWorkingDirectory(mpSettings->value("OMSimulator/workingDirectory").toString());
935 OMSProxy::instance()->setWorkingDirectory(mpSettings->value("OMSimulator/workingDirectory").toString());
936 }
937 // read logging level
938 int index;
939 if (mpSettings->contains("OMSimulator/loggingLevel")) {
940 index = mpOMSimulatorPage->getLoggingLevelComboBox()->findData(mpSettings->value("OMSimulator/loggingLevel").toInt());
941 if (index > -1) {
942 mpOMSimulatorPage->getLoggingLevelComboBox()->setCurrentIndex(index);
943 OMSProxy::instance()->setLoggingLevel(mpSettings->value("OMSimulator/loggingLevel").toInt());
944 }
945 }
946}
947
948/*!
949 * \brief OptionsDialog::readTraceabilitySettings
950 * Reads the Traceability settings from omedit.ini
951 */
952void OptionsDialog::readTraceabilitySettings()
953{
954 // read traceability checkbox
955 if (mpSettings->contains("traceability/Traceability")) {
956 mpTraceabilityPage->getTraceabilityGroupBox()->setChecked(mpSettings->value("traceability/Traceability").toBool());
957 }
958 // read user name
959 if (mpSettings->contains("traceability/UserName")) {
960 mpTraceabilityPage->getUserName()->setText(mpSettings->value("traceability/UserName").toString());
961 }
962 // read Email
963 if (mpSettings->contains("traceability/Email")) {
964 mpTraceabilityPage->getEmail()->setText(mpSettings->value("traceability/Email").toString());
965 }
966 // read Git repository
967 if (mpSettings->contains("traceability/GitRepository")) {
968 mpTraceabilityPage->getGitRepository()->setText(mpSettings->value("traceability/GitRepository").toString());
969 }
970 // read the traceability daemon IP-adress
971 if (mpSettings->contains("traceability/IPAdress")) {
972 mpTraceabilityPage->getTraceabilityDaemonIpAdress()->setText(mpSettings->value("traceability/IPAdress").toString());
973 }
974 // read the traceability daemon Port
975 if (mpSettings->contains("traceability/Port")) {
976 mpTraceabilityPage->getTraceabilityDaemonPort()->setText(mpSettings->value("traceability/Port").toString());
977 }
978}
979
980//! Saves the General section settings to omedit.ini
981void OptionsDialog::saveGeneralSettings()
982{
983 // save Language option
984 QString language;
985 if (mpGeneralSettingsPage->getLanguageComboBox()->currentIndex() == 0) {
986 language = QLocale::system().name();
987 } else {
988 language = mpGeneralSettingsPage->getLanguageComboBox()->itemData(mpGeneralSettingsPage->getLanguageComboBox()->currentIndex()).toLocale().name();
989 }
990 mpSettings->setValue("language", language);
991 // save working directory
992 MainWindow::instance()->getOMCProxy()->changeDirectory(mpGeneralSettingsPage->getWorkingDirectory());
993 mpGeneralSettingsPage->setWorkingDirectory(MainWindow::instance()->getOMCProxy()->changeDirectory());
994 mpSettings->setValue("workingDirectory", mpGeneralSettingsPage->getWorkingDirectory());
995 // save toolbar icon size
996 mpSettings->setValue("toolbarIconSize", mpGeneralSettingsPage->getToolbarIconSizeSpinBox()->value());
997 // save user customizations
998 mpSettings->setValue("userCustomizations", mpGeneralSettingsPage->getPreserveUserCustomizations());
999 // save terminal command
1000 mpSettings->setValue("terminalCommand", mpGeneralSettingsPage->getTerminalCommand());
1001 // save terminal command arguments
1002 mpSettings->setValue("terminalCommandArgs", mpGeneralSettingsPage->getTerminalCommandArguments());
1003 // save hide variables browser
1004 mpSettings->setValue("hideVariablesBrowser", mpGeneralSettingsPage->getHideVariablesBrowserCheckBox()->isChecked());
1005 // save activate access annotations
1006 mpSettings->setValue("activateAccessAnnotations", mpGeneralSettingsPage->getActivateAccessAnnotationsComboBox()->itemData(mpGeneralSettingsPage->getActivateAccessAnnotationsComboBox()->currentIndex()).toInt());
1007 // save create backup file
1008 mpSettings->setValue("createBackupFile", mpGeneralSettingsPage->getCreateBackupFileCheckbox()->isChecked());
1009 // save library icon size
1010 mpSettings->setValue("libraryIconSize", mpGeneralSettingsPage->getLibraryIconSizeSpinBox()->value());
1011 // save the max. text length to show on a library icon
1012 mpSettings->setValue("libraryIconMaxTextLength", mpGeneralSettingsPage->getLibraryIconTextLengthSpinBox()->value());
1013 // save show protected classes
1014 mpSettings->setValue("showProtectedClasses", mpGeneralSettingsPage->getShowProtectedClasses());
1015 // save show hidden classes
1016 mpSettings->setValue("showHiddenClasses", mpGeneralSettingsPage->getShowHiddenClasses());
1017 // show/hide the protected classes
1018 MainWindow::instance()->getLibraryWidget()->getLibraryTreeModel()->showHideProtectedClasses();
1019 // save modeling view mode
1020 mpSettings->setValue("modeling/viewmode", mpGeneralSettingsPage->getModelingViewMode());
1021 if (mpGeneralSettingsPage->getModelingViewMode().compare(Helper::subWindow) == 0) {
1022 MainWindow::instance()->getModelWidgetContainer()->setViewMode(QMdiArea::SubWindowView);
1023 ModelWidget *pModelWidget = MainWindow::instance()->getModelWidgetContainer()->getCurrentModelWidget();
1024 if (pModelWidget) {
1025 pModelWidget->show();
1026 pModelWidget->setWindowState(Qt::WindowMaximized);
1027 }
1028 } else {
1029 MainWindow::instance()->getModelWidgetContainer()->setViewMode(QMdiArea::TabbedView);
1030 }
1031 // save default view
1032 mpSettings->setValue("defaultView", mpGeneralSettingsPage->getDefaultView());
1033 // save auto save
1034 mpSettings->setValue("autoSave/enable", mpGeneralSettingsPage->getEnableAutoSaveGroupBox()->isChecked());
1035 mpSettings->setValue("autoSave/interval", mpGeneralSettingsPage->getAutoSaveIntervalSpinBox()->value());
1036 MainWindow::instance()->getAutoSaveTimer()->setInterval(mpGeneralSettingsPage->getAutoSaveIntervalSpinBox()->value() * 1000);
1037 MainWindow::instance()->toggleAutoSave();
1038 // save welcome page
1039 switch (mpGeneralSettingsPage->getWelcomePageView()) {
1040 case 2:
1041 MainWindow::instance()->getWelcomePageWidget()->getSplitter()->setOrientation(Qt::Vertical);
1042 break;
1043 case 1:
1044 default:
1045 MainWindow::instance()->getWelcomePageWidget()->getSplitter()->setOrientation(Qt::Horizontal);
1046 break;
1047 }
1048 mpSettings->setValue("welcomePage/view", mpGeneralSettingsPage->getWelcomePageView());
1049 bool showLatestNews = mpGeneralSettingsPage->getShowLatestNewsCheckBox()->isChecked();
1050 if (MainWindow::instance()->getWelcomePageWidget()->getLatestNewsFrame()->isHidden() && showLatestNews) {
1051 MainWindow::instance()->getWelcomePageWidget()->getLatestNewsFrame()->show();
1052 MainWindow::instance()->getWelcomePageWidget()->addLatestNewsListItems();
1053 } else if (!showLatestNews) {
1054 MainWindow::instance()->getWelcomePageWidget()->getLatestNewsFrame()->hide();
1055 }
1056 mpSettings->setValue("welcomePage/showLatestNews", showLatestNews);
1057}
1058
1059//! Saves the Libraries section settings to omedit.ini
1060void OptionsDialog::saveLibrariesSettings()
1061{
1062 // read the settings and add system libraries
1063 mpSettings->beginGroup("libraries");
1064 foreach (QString lib, mpSettings->childKeys())for (auto _container_ = QtPrivate::qMakeForeachContainer(mpSettings
->childKeys()); _container_.control && _container_
.i != _container_.e; ++_container_.i, _container_.control ^= 1
) for (QString lib = *_container_.i; _container_.control; _container_
.control = 0)
{
1065 mpSettings->remove(lib);
1066 }
1067 QTreeWidgetItemIterator systemLibrariesIterator(mpLibrariesPage->getSystemLibrariesTree());
1068 while (*systemLibrariesIterator) {
1069 QTreeWidgetItem *pItem = dynamic_cast<QTreeWidgetItem*>(*systemLibrariesIterator);
1070 mpSettings->setValue(pItem->text(0), pItem->text(1));
1071 ++systemLibrariesIterator;
1072 }
1073 mpSettings->endGroup();
1074 mpSettings->setValue("forceModelicaLoad", mpLibrariesPage->getForceModelicaLoadCheckBox()->isChecked());
1075 mpSettings->setValue("loadOpenModelicaOnStartup", mpLibrariesPage->getLoadOpenModelicaLibraryCheckBox()->isChecked());
1076 // read the settings and add user libraries
1077 mpSettings->beginGroup("userlibraries");
1078 foreach (QString lib, mpSettings->childKeys())for (auto _container_ = QtPrivate::qMakeForeachContainer(mpSettings
->childKeys()); _container_.control && _container_
.i != _container_.e; ++_container_.i, _container_.control ^= 1
) for (QString lib = *_container_.i; _container_.control; _container_
.control = 0)
{
1079 mpSettings->remove(lib);
1080 }
1081 QTreeWidgetItemIterator userLibrariesIterator(mpLibrariesPage->getUserLibrariesTree());
1082 while (*userLibrariesIterator) {
1083 QTreeWidgetItem *pItem = dynamic_cast<QTreeWidgetItem*>(*userLibrariesIterator);
1084 mpSettings->setValue(QUrl::toPercentEncoding(pItem->text(0)), pItem->text(1));
1085 ++userLibrariesIterator;
1086 }
1087 mpSettings->endGroup();
1088}
1089
1090/*!
1091 * \brief OptionsDialog::saveTextEditorSettings
1092 * Saves the TextEditor settings to omedit.ini
1093 */
1094void OptionsDialog::saveTextEditorSettings()
1095{
1096 mpSettings->setValue("textEditor/lineEnding", mpTextEditorPage->getLineEndingComboBox()->itemData(mpTextEditorPage->getLineEndingComboBox()->currentIndex()).toInt());
1097 mpSettings->setValue("textEditor/bom", mpTextEditorPage->getBOMComboBox()->itemData(mpTextEditorPage->getBOMComboBox()->currentIndex()).toInt());
1098 mpSettings->setValue("textEditor/tabPolicy", mpTextEditorPage->getTabPolicyComboBox()->itemData(mpTextEditorPage->getTabPolicyComboBox()->currentIndex()).toInt());
1099 mpSettings->setValue("textEditor/tabSize", mpTextEditorPage->getTabSizeSpinBox()->value());
1100 mpSettings->setValue("textEditor/indentSize", mpTextEditorPage->getIndentSpinBox()->value());
1101 mpSettings->setValue("textEditor/enableSyntaxHighlighting", mpTextEditorPage->getSyntaxHighlightingGroupBox()->isChecked());
1102 mpSettings->setValue("textEditor/enableCodeFolding", mpTextEditorPage->getCodeFoldingCheckBox()->isChecked());
1103 mpSettings->setValue("textEditor/matchParenthesesCommentsQuotes", mpTextEditorPage->getMatchParenthesesCommentsQuotesCheckBox()->isChecked());
1104 mpSettings->setValue("textEditor/enableLineWrapping", mpTextEditorPage->getLineWrappingCheckbox()->isChecked());
1105 mpSettings->setValue("textEditor/fontFamily", mpTextEditorPage->getFontFamilyComboBox()->currentFont().family());
1106 mpSettings->setValue("textEditor/fontSize", mpTextEditorPage->getFontSizeSpinBox()->value());
1107 mpSettings->setValue("textEditor/enableAutocomplete", mpTextEditorPage->getAutoCompleteCheckBox()->isChecked());
1108}
1109
1110/*!
1111 * \brief OptionsDialog::saveModelicaEditorSettings
1112 * Saves the ModelicaEditor settings to omedit.ini
1113 */
1114void OptionsDialog::saveModelicaEditorSettings()
1115{
1116 mpSettings->setValue("modelicaEditor/preserveTextIndentation", mpModelicaEditorPage->getPreserveTextIndentationCheckBox()->isChecked());
1117 mpSettings->setValue("modelicaEditor/textRuleColor", mpModelicaEditorPage->getColor("Text").rgba());
1118 mpSettings->setValue("modelicaEditor/keywordRuleColor", mpModelicaEditorPage->getColor("Keyword").rgba());
1119 mpSettings->setValue("modelicaEditor/typeRuleColor", mpModelicaEditorPage->getColor("Type").rgba());
1120 mpSettings->setValue("modelicaEditor/functionRuleColor", mpModelicaEditorPage->getColor("Function").rgba());
1121 mpSettings->setValue("modelicaEditor/quotesRuleColor", mpModelicaEditorPage->getColor("Quotes").rgba());
1122 mpSettings->setValue("modelicaEditor/commentRuleColor", mpModelicaEditorPage->getColor("Comment").rgba());
1123 mpSettings->setValue("modelicaEditor/numberRuleColor", mpModelicaEditorPage->getColor("Number").rgba());
1124}
1125
1126/*!
1127 * \brief OptionsDialog::saveMetaModelicaEditorSettings
1128 * Saves the MetaModelicaEditor settings to omedit.ini
1129 */
1130void OptionsDialog::saveMetaModelicaEditorSettings()
1131{
1132 mpSettings->setValue("metaModelicaEditor/textRuleColor", mpMetaModelicaEditorPage->getColor("Text").rgba());
1133 mpSettings->setValue("metaModelicaEditor/keywordRuleColor", mpMetaModelicaEditorPage->getColor("Keyword").rgba());
1134 mpSettings->setValue("metaModelicaEditor/typeRuleColor", mpMetaModelicaEditorPage->getColor("Type").rgba());
1135 mpSettings->setValue("metaModelicaEditor/quotesRuleColor", mpMetaModelicaEditorPage->getColor("Quotes").rgba());
1136 mpSettings->setValue("metaModelicaEditor/commentRuleColor", mpMetaModelicaEditorPage->getColor("Comment").rgba());
1137 mpSettings->setValue("metaModelicaEditor/numberRuleColor", mpMetaModelicaEditorPage->getColor("Number").rgba());
1138}
1139
1140/*!
1141 * \brief OptionsDialog::saveCompositeModelEditorSettings
1142 * Saves the CompositeModelEditor settings to omedit.ini
1143 */
1144void OptionsDialog::saveCompositeModelEditorSettings()
1145{
1146 mpSettings->setValue("compositeModelEditor/textRuleColor", mpCompositeModelEditorPage->getColor("Text").rgba());
1147 mpSettings->setValue("compositeModelEditor/commentRuleColor", mpCompositeModelEditorPage->getColor("Comment").rgba());
1148 mpSettings->setValue("compositeModelEditor/tagRuleColor", mpCompositeModelEditorPage->getColor("Tag").rgba());
1149 mpSettings->setValue("compositeModelEditor/quotesRuleColor", mpCompositeModelEditorPage->getColor("Quotes").rgba());
1150 mpSettings->setValue("compositeModelEditor/elementsRuleColor", mpCompositeModelEditorPage->getColor("Element").rgba());
1151}
1152
1153/*!
1154 * \brief OptionsDialog::saveOMSimulatorEditorSettings
1155 * Saves the OMSimulatorEditor settings to omedit.ini
1156 */
1157void OptionsDialog::saveOMSimulatorEditorSettings()
1158{
1159 mpSettings->setValue("omsimulatorEditor/textRuleColor", mpOMSimulatorEditorPage->getColor("Text").rgba());
1160 mpSettings->setValue("omsimulatorEditor/commentRuleColor", mpOMSimulatorEditorPage->getColor("Comment").rgba());
1161 mpSettings->setValue("omsimulatorEditor/tagRuleColor", mpOMSimulatorEditorPage->getColor("Tag").rgba());
1162 mpSettings->setValue("omsimulatorEditor/quotesRuleColor", mpOMSimulatorEditorPage->getColor("Quotes").rgba());
1163 mpSettings->setValue("omsimulatorEditor/elementsRuleColor", mpOMSimulatorEditorPage->getColor("Element").rgba());
1164}
1165
1166/*!
1167 * \brief OptionsDialog::saveCEditorSettings
1168 * Saves the CEditor settings to omedit.ini
1169 */
1170void OptionsDialog::saveCEditorSettings()
1171{
1172 mpSettings->setValue("cEditor/textRuleColor", mpCEditorPage->getColor("Text").rgba());
1173 mpSettings->setValue("cEditor/keywordRuleColor", mpCEditorPage->getColor("Keyword").rgba());
1174 mpSettings->setValue("cEditor/typeRuleColor", mpCEditorPage->getColor("Type").rgba());
1175 mpSettings->setValue("cEditor/quotesRuleColor", mpCEditorPage->getColor("Quotes").rgba());
1176 mpSettings->setValue("cEditor/commentRuleColor", mpCEditorPage->getColor("Comment").rgba());
1177 mpSettings->setValue("cEditor/numberRuleColor", mpCEditorPage->getColor("Number").rgba());
1178}
1179
1180/*!
1181 * \brief OptionsDialog::saveHTMLEditorSettings
1182 * Saves the HTMLEditor settings to omedit.ini
1183 */
1184void OptionsDialog::saveHTMLEditorSettings()
1185{
1186 mpSettings->setValue("HTMLEditor/textRuleColor", mpHTMLEditorPage->getColor("Text").rgba());
1187 mpSettings->setValue("HTMLEditor/commentRuleColor", mpHTMLEditorPage->getColor("Comment").rgba());
1188 mpSettings->setValue("HTMLEditor/tagRuleColor", mpHTMLEditorPage->getColor("Tag").rgba());
1189 mpSettings->setValue("HTMLEditor/quotesRuleColor", mpHTMLEditorPage->getColor("Quotes").rgba());
1190}
1191
1192//! Saves the GraphicsViews section settings to omedit.ini
1193void OptionsDialog::saveGraphicalViewsSettings()
1194{
1195 mpSettings->setValue("iconView/extentLeft", mpGraphicalViewsPage->getIconViewExtentLeft());
1196 mpSettings->setValue("iconView/extentBottom", mpGraphicalViewsPage->getIconViewExtentBottom());
1197 mpSettings->setValue("iconView/extentRight", mpGraphicalViewsPage->getIconViewExtentRight());
1198 mpSettings->setValue("iconView/extentTop", mpGraphicalViewsPage->getIconViewExtentTop());
1199 mpSettings->setValue("iconView/gridHorizontal", mpGraphicalViewsPage->getIconViewGridHorizontal());
1200 mpSettings->setValue("iconView/gridVertical", mpGraphicalViewsPage->getIconViewGridVertical());
1201 mpSettings->setValue("iconView/scaleFactor", mpGraphicalViewsPage->getIconViewScaleFactor());
1202 mpSettings->setValue("iconView/preserveAspectRatio", mpGraphicalViewsPage->getIconViewPreserveAspectRation());
1203 mpSettings->setValue("DiagramView/extentLeft", mpGraphicalViewsPage->getDiagramViewExtentLeft());
1204 mpSettings->setValue("DiagramView/extentBottom", mpGraphicalViewsPage->getDiagramViewExtentBottom());
1205 mpSettings->setValue("DiagramView/extentRight", mpGraphicalViewsPage->getDiagramViewExtentRight());
1206 mpSettings->setValue("DiagramView/extentTop", mpGraphicalViewsPage->getDiagramViewExtentTop());
1207 mpSettings->setValue("DiagramView/gridHorizontal", mpGraphicalViewsPage->getDiagramViewGridHorizontal());
1208 mpSettings->setValue("DiagramView/gridVertical", mpGraphicalViewsPage->getDiagramViewGridVertical());
1209 mpSettings->setValue("DiagramView/scaleFactor", mpGraphicalViewsPage->getDiagramViewScaleFactor());
1210 mpSettings->setValue("DiagramView/preserveAspectRatio", mpGraphicalViewsPage->getDiagramViewPreserveAspectRation());
1211}
1212
1213//! Saves the Simulation section settings to omedit.ini
1214void OptionsDialog::saveSimulationSettings()
1215{
1216 // clear command line options before saving new ones
1217 MainWindow::instance()->getOMCProxy()->clearCommandLineOptions();
1218 // save matching algorithm
1219 mpSettings->setValue("simulation/matchingAlgorithm", mpSimulationPage->getTranslationFlagsWidget()->getMatchingAlgorithmComboBox()->currentText());
1220 // save index reduction
1221 mpSettings->setValue("simulation/indexReductionMethod", mpSimulationPage->getTranslationFlagsWidget()->getIndexReductionMethodComboBox()->currentText());
1222 // save initialization
1223 mpSettings->setValue("simulation/initialization", mpSimulationPage->getTranslationFlagsWidget()->getInitializationCheckBox()->isChecked());
1224 // save evaluate all parameters
1225 mpSettings->setValue("simulation/evaluateAllParameters", mpSimulationPage->getTranslationFlagsWidget()->getEvaluateAllParametersCheckBox()->isChecked());
1226 // save NLS analytic jacobian
1227 mpSettings->setValue("simulation/NLSanalyticJacobian", mpSimulationPage->getTranslationFlagsWidget()->getNLSanalyticJacobianCheckBox()->isChecked());
1228 // save parmodauto
1229 mpSettings->setValue("simulation/parmodauto", mpSimulationPage->getTranslationFlagsWidget()->getParmodautoCheckBox()->isChecked());
1230 // save old instantiation
1231 mpSettings->setValue("simulation/newInst", !mpSimulationPage->getTranslationFlagsWidget()->getOldInstantiationCheckBox()->isChecked());
1232 // save dataReconciliation
1233 mpSettings->setValue("simulation/dataReconciliation", mpSimulationPage->getTranslationFlagsWidget()->getDataReconciliationCheckBox()->isChecked());
1234 // save command line options
1235 if (mpSimulationPage->getTranslationFlagsWidget()->applyFlags()) {
1236 mpSettings->setValue("simulation/OMCFlags", mpSimulationPage->getTranslationFlagsWidget()->getAdditionalTranslationFlagsTextBox()->text());
1237 } else {
1238 mpSimulationPage->getTranslationFlagsWidget()->getAdditionalTranslationFlagsTextBox()->setText(mpSettings->value("simulation/OMCFlags").toString());
1239 }
1240 // save global simulation settings.
1241 saveGlobalSimulationSettings();
1242 // save class before simulation.
1243 mpSettings->setValue("simulation/saveClassBeforeSimulation", mpSimulationPage->getSaveClassBeforeSimulationCheckBox()->isChecked());
1244 mpSettings->setValue("simulation/switchToPlottingPerspectiveAfterSimulation", mpSimulationPage->getSwitchToPlottingPerspectiveCheckBox()->isChecked());
1245 mpSettings->setValue("simulation/closeSimulationOutputWidgetsBeforeSimulation", mpSimulationPage->getCloseSimulationOutputWidgetsBeforeSimulationCheckBox()->isChecked());
1246 mpSettings->setValue("simulation/deleteIntermediateCompilationFiles", mpSimulationPage->getDeleteIntermediateCompilationFilesCheckBox()->isChecked());
1247 mpSettings->setValue("simulation/deleteEntireSimulationDirectory", mpSimulationPage->getDeleteEntireSimulationDirectoryCheckBox()->isChecked());
1248 mpSettings->setValue("simulation/outputMode", mpSimulationPage->getOutputMode());
1249 mpSettings->setValue("simulation/displayLimit", mpSimulationPage->getDisplayLimitSpinBox()->value());
1250}
1251
1252/*!
1253 * \brief OptionsDialog::saveGlobalSimulationSettings
1254 * This function is just added so that SimulationDialog can set the global
1255 * simulatin settings in the SimulationDialog::translateModel()
1256 */
1257void OptionsDialog::saveGlobalSimulationSettings()
1258{
1259 // save target language
1260 mpSettings->setValue("simulation/targetLanguage", mpSimulationPage->getTargetLanguageComboBox()->currentText());
1261 MainWindow::instance()->getOMCProxy()->setCommandLineOptions(QString("--simCodeTarget=%1").arg(mpSimulationPage->getTargetLanguageComboBox()->currentText()));
1262 // save target build
1263 QString target = mpSimulationPage->getTargetBuildComboBox()->itemData(mpSimulationPage->getTargetBuildComboBox()->currentIndex()).toString();
1264 mpSettings->setValue("simulation/targetCompiler", target);
1265 MainWindow::instance()->getOMCProxy()->setCommandLineOptions(QString("--target=%1").arg(target));
1266 // save compiler
1267 QString compiler = mpSimulationPage->getCompilerComboBox()->lineEdit()->text();
1268 mpSettings->setValue("simulation/compiler", compiler);
1269 if (compiler.isEmpty()) {
1270 compiler = mpSimulationPage->getCompilerComboBox()->lineEdit()->placeholderText();
1271 }
1272 MainWindow::instance()->getOMCProxy()->setCompiler(compiler);
1273 // save cxxcompiler
1274 QString cxxCompiler = mpSimulationPage->getCXXCompilerComboBox()->lineEdit()->text();
1275 mpSettings->setValue("simulation/cxxCompiler", cxxCompiler);
1276 if (cxxCompiler.isEmpty()) {
1277 cxxCompiler = mpSimulationPage->getCXXCompilerComboBox()->lineEdit()->placeholderText();
1278 }
1279 MainWindow::instance()->getOMCProxy()->setCXXCompiler(cxxCompiler);
1280 // save ignore command line options
1281 mpSettings->setValue("simulation/ignoreCommandLineOptionsAnnotation", mpSimulationPage->getIgnoreCommandLineOptionsAnnotationCheckBox()->isChecked());
1282 if (mpSimulationPage->getIgnoreCommandLineOptionsAnnotationCheckBox()->isChecked()) {
1283 MainWindow::instance()->getOMCProxy()->setCommandLineOptions("+ignoreCommandLineOptionsAnnotation=true");
1284 } else {
1285 MainWindow::instance()->getOMCProxy()->setCommandLineOptions("+ignoreCommandLineOptionsAnnotation=false");
1286 }
1287 // save ignore simulation flags
1288 mpSettings->setValue("simulation/ignoreSimulationFlagsAnnotation", mpSimulationPage->getIgnoreSimulationFlagsAnnotationCheckBox()->isChecked());
1289 if (mpSimulationPage->getIgnoreSimulationFlagsAnnotationCheckBox()->isChecked()) {
1290 MainWindow::instance()->getOMCProxy()->setCommandLineOptions("+ignoreSimulationFlagsAnnotation=true");
1291 } else {
1292 MainWindow::instance()->getOMCProxy()->setCommandLineOptions("+ignoreSimulationFlagsAnnotation=false");
1293 }
1294 // save nfAPI
1295 mpSettings->setValue("simulation/nfAPI", mpSimulationPage->getEnableNewInstantiationAPICheckBox()->isChecked());
1296 if (mpSimulationPage->getEnableNewInstantiationAPICheckBox()->isChecked()) {
1297 MainWindow::instance()->getOMCProxy()->setCommandLineOptions("-d=nfAPI");
1298 }
1299 // save nfAPINoise
1300 mpSettings->setValue("simulation/nfAPINoise", mpSimulationPage->getDisplayNFAPIErrorsWarningsCheckBox()->isChecked());
1301 if (mpSimulationPage->getDisplayNFAPIErrorsWarningsCheckBox()->isChecked()) {
1302 MainWindow::instance()->getOMCProxy()->setCommandLineOptions("-d=nfAPINoise");
1303 }
1304}
1305
1306//! Saves the Messages section settings to omedit.ini
1307void OptionsDialog::saveMessagesSettings()
1308{
1309 // save output size
1310 mpSettings->setValue("messages/outputSize", mpMessagesPage->getOutputSizeSpinBox()->value());
1311 // save reset messages number
1312 mpSettings->setValue("messages/resetMessagesNumber", mpMessagesPage->getResetMessagesNumberBeforeSimulationCheckBox()->isChecked());
1313 // save clear messages browser
1314 mpSettings->setValue("messages/clearMessagesBrowser", mpMessagesPage->getClearMessagesBrowserBeforeSimulationCheckBox()->isChecked());
1315 // save font
1316 mpSettings->setValue("messages/fontFamily", mpMessagesPage->getFontFamilyComboBox()->currentFont().family());
1317 mpSettings->setValue("messages/fontSize", mpMessagesPage->getFontSizeSpinBox()->value());
1318 // save notification color
1319 mpSettings->setValue("messages/notificationColor", mpMessagesPage->getNotificationColor().rgba());
1320 // save warning color
1321 mpSettings->setValue("messages/warningColor", mpMessagesPage->getWarningColor().rgba());
1322 // save error color
1323 mpSettings->setValue("messages/errorColor", mpMessagesPage->getErrorColor().rgba());
1324 // apply the above settings to Messages
1325 MessagesWidget::instance()->applyMessagesSettings();
1326}
1327
1328//! Saves the Notifications section settings to omedit.ini
1329void OptionsDialog::saveNotificationsSettings()
1330{
1331 mpSettings->setValue("notifications/promptQuitApplication", mpNotificationsPage->getQuitApplicationCheckBox()->isChecked());
1332 mpSettings->setValue("notifications/itemDroppedOnItself", mpNotificationsPage->getItemDroppedOnItselfCheckBox()->isChecked());
1333 mpSettings->setValue("notifications/replaceableIfPartial", mpNotificationsPage->getReplaceableIfPartialCheckBox()->isChecked());
1334 mpSettings->setValue("notifications/innerModelNameChanged", mpNotificationsPage->getInnerModelNameChangedCheckBox()->isChecked());
1335 mpSettings->setValue("notifications/saveModelForBitmapInsertion", mpNotificationsPage->getSaveModelForBitmapInsertionCheckBox()->isChecked());
1336 mpSettings->setValue("notifications/alwaysAskForDraggedComponentName", mpNotificationsPage->getAlwaysAskForDraggedComponentName()->isChecked());
1337 mpSettings->setValue("notifications/alwaysAskForTextEditorError", mpNotificationsPage->getAlwaysAskForTextEditorErrorCheckBox()->isChecked());
1338 mpSettings->setValue("notifications/promptOldFrontend", mpNotificationsPage->getOldFrontendComboBox()->itemData(mpNotificationsPage->getOldFrontendComboBox()->currentIndex()).toInt());
1339}
1340
1341//! Saves the LineStyle section settings to omedit.ini
1342void OptionsDialog::saveLineStyleSettings()
1343{
1344 mpSettings->setValue("linestyle/color", mpLineStylePage->getLineColor().rgba());
1345 mpSettings->setValue("linestyle/pattern", mpLineStylePage->getLinePattern());
1346 mpSettings->setValue("linestyle/thickness", mpLineStylePage->getLineThickness());
1347 mpSettings->setValue("linestyle/startArrow", mpLineStylePage->getLineStartArrow());
1348 mpSettings->setValue("linestyle/endArrow", mpLineStylePage->getLineEndArrow());
1349 mpSettings->setValue("linestyle/arrowSize", mpLineStylePage->getLineArrowSize());
1350 mpSettings->setValue("linestyle/smooth", mpLineStylePage->getLineSmooth());
1351}
1352
1353//! Saves the FillStyle section settings to omedit.ini
1354void OptionsDialog::saveFillStyleSettings()
1355{
1356 mpSettings->setValue("fillstyle/color", mpFillStylePage->getFillColor().rgba());
1357 mpSettings->setValue("fillstyle/pattern", mpFillStylePage->getFillPattern());
1358}
1359
1360//! Saves the Plotting section settings to omedit.ini
1361void OptionsDialog::savePlottingSettings()
1362{
1363 // save the auto scale
1364 mpSettings->setValue("plotting/autoScale", mpPlottingPage->getAutoScaleCheckBox()->isChecked());
1365 // save plotting view mode
1366 mpSettings->setValue("plotting/viewmode", mpPlottingPage->getPlottingViewMode());
1367 if (mpPlottingPage->getPlottingViewMode().compare(Helper::subWindow) == 0) {
1368 MainWindow::instance()->getPlotWindowContainer()->setViewMode(QMdiArea::SubWindowView);
1369 OMPlot::PlotWindow *pPlotWindow = MainWindow::instance()->getPlotWindowContainer()->getCurrentWindow();
1370 if (pPlotWindow) {
1371 pPlotWindow->show();
1372 pPlotWindow->setWindowState(Qt::WindowMaximized);
1373 }
1374 } else {
1375 MainWindow::instance()->getPlotWindowContainer()->setViewMode(QMdiArea::TabbedView);
1376 }
1377
1378 mpSettings->setValue("curvestyle/pattern", mpPlottingPage->getCurvePattern());
1379 mpSettings->setValue("curvestyle/thickness", mpPlottingPage->getCurveThickness());
1380 // save variable filter interval
1381 mpSettings->setValue("variableFilter/interval", mpPlottingPage->getFilterIntervalSpinBox()->value());
1382 MainWindow::instance()->getVariablesWidget()->getTreeSearchFilters()->getFilterTimer()->setInterval(mpPlottingPage->getFilterIntervalSpinBox()->value() * 1000);
1383 // save plot font sizes
1384 mpSettings->setValue("plotting/titleFontSize", mpPlottingPage->getTitleFontSizeSpinBox()->value());
1385 mpSettings->setValue("plotting/verticalAxisTitleFontSize", mpPlottingPage->getVerticalAxisTitleFontSizeSpinBox()->value());
1386 mpSettings->setValue("plotting/verticalAxisNumbersFontSize", mpPlottingPage->getVerticalAxisNumbersFontSizeSpinBox()->value());
1387 mpSettings->setValue("plotting/horizontalAxisTitleFontSize", mpPlottingPage->getHorizontalAxisTitleFontSizeSpinBox()->value());
1388 mpSettings->setValue("plotting/horizontalAxisNumbersFontSize", mpPlottingPage->getHorizontalAxisNumbersFontSizeSpinBox()->value());
1389 mpSettings->setValue("plotting/footerFontSize", mpPlottingPage->getFooterFontSizeSpinBox()->value());
1390 mpSettings->setValue("plotting/legendFontSize", mpPlottingPage->getLegendFontSizeSpinBox()->value());
1391}
1392
1393//! Saves the Figaro section settings to omedit.ini
1394void OptionsDialog::saveFigaroSettings()
1395{
1396 mpSettings->setValue("figaro/databasefile", mpFigaroPage->getFigaroDatabaseFileTextBox()->text());
1397 mpSettings->setValue("figaro/options", mpFigaroPage->getFigaroOptionsTextBox()->text());
1398 mpSettings->setValue("figaro/process", mpFigaroPage->getFigaroProcessTextBox()->text());
1399}
1400
1401/*!
1402 Saves the Debugger section settings to omedit.ini
1403 */
1404void OptionsDialog::saveDebuggerSettings()
1405{
1406 mpSettings->beginGroup("algorithmicDebugger");
1407 mpSettings->setValue("GDBPath", mpDebuggerPage->getGDBPathForSettings());
1408 mpSettings->setValue("GDBCommandTimeout", mpDebuggerPage->getGDBCommandTimeoutSpinBox()->value());
1409 mpSettings->setValue("GDBOutputLimit", mpDebuggerPage->getGDBOutputLimitSpinBox()->value());
1410 mpSettings->setValue("displayCFrames", mpDebuggerPage->getDisplayCFramesCheckBox()->isChecked());
1411 mpSettings->setValue("displayUnknownFrames", mpDebuggerPage->getDisplayUnknownFramesCheckBox()->isChecked());
1412 MainWindow::instance()->getStackFramesWidget()->getStackFramesTreeWidget()->updateStackFrames();
1413 mpSettings->setValue("clearOutputOnNewRun", mpDebuggerPage->getClearOutputOnNewRunCheckBox()->isChecked());
1414 mpSettings->setValue("clearLogOnNewRun", mpDebuggerPage->getClearLogOnNewRunCheckBox()->isChecked());
1415 mpSettings->endGroup();
1416 mpSettings->beginGroup("transformationalDebugger");
1417 mpSettings->setValue("alwaysShowTransformationalDebugger", mpDebuggerPage->getAlwaysShowTransformationsCheckBox()->isChecked());
1418 mpSettings->setValue("generateOperations", mpDebuggerPage->getGenerateOperationsCheckBox()->isChecked());
1419 if (mpDebuggerPage->getGenerateOperationsCheckBox()->isChecked()) {
1420 MainWindow::instance()->getOMCProxy()->setCommandLineOptions("-d=infoXmlOperations");
1421 }
1422 mpSettings->endGroup();
1423}
1424
1425/*!
1426 * \brief OptionsDialog::saveFMISettings
1427 * Saves the FMI section settings to omedit.ini
1428 */
1429void OptionsDialog::saveFMISettings()
1430{
1431 mpSettings->setValue("FMIExport/Version", mpFMIPage->getFMIExportVersion());
1432 mpSettings->setValue("FMIExport/Type", mpFMIPage->getFMIExportType());
1433 mpSettings->setValue("FMIExport/FMUName", mpFMIPage->getFMUNameTextBox()->text());
1434 mpSettings->setValue("FMIExport/MoveFMU", mpFMIPage->getMoveFMUTextBox()->text());
1435 // save platforms
1436 QStringList platforms;
1437 QString linking = mpFMIPage->getLinkingComboBox()->itemData(mpFMIPage->getLinkingComboBox()->currentIndex()).toString();
1438 platforms.append(linking);
1439 int i = 0;
1440 while (QLayoutItem* pLayoutItem = mpFMIPage->getPlatformsGroupBox()->layout()->itemAt(i)) {
1441 if (dynamic_cast<QCheckBox*>(pLayoutItem->widget())) {
1442 QCheckBox *pPlatformCheckBox = dynamic_cast<QCheckBox*>(pLayoutItem->widget());
1443 if (pPlatformCheckBox->isChecked()) {
1444 platforms.append(pPlatformCheckBox->property(Helper::fmuPlatformNamePropertyId).toString());
1445 }
1446 }
1447 i++;
1448 }
1449 mpSettings->setValue("FMIExport/Platforms", platforms);
1450 mpSettings->setValue("FMIImport/DeleteFMUDirectoyAndModel", mpFMIPage->getDeleteFMUDirectoryAndModelCheckBox()->isChecked());
1451}
1452
1453/*!
1454 * \brief OptionsDialog::saveTLMSettings
1455 * Saves the TLM settings in omedit.ini
1456 */
1457void OptionsDialog::saveTLMSettings()
1458{
1459 // read TLM Path
1460 mpSettings->setValue("TLM/PluginPath", mpTLMPage->getTLMPluginPathTextBox()->text());
1461 // save the TLM Manager Process
1462 mpSettings->setValue("TLM/ManagerProcess", mpTLMPage->getTLMManagerProcessTextBox()->text());
1463 // save the TLM Monitor Process
1464 mpSettings->setValue("TLM/MonitorProcess", mpTLMPage->getTLMMonitorProcessTextBox()->text());
1465}
1466
1467/*!
1468 * \brief OptionsDialog::saveOMSimulatorSettings
1469 * Saves the OMSimulator settings in omedit.ini
1470 */
1471void OptionsDialog::saveOMSimulatorSettings()
1472{
1473 // set command line options
1474 mpSettings->setValue("OMSimulator/commandLineOptions", mpOMSimulatorPage->getCommandLineOptionsTextBox()->text());
1475 // first clear all the command line options and then set the new
1476 OMSProxy::instance()->setCommandLineOption("--clearAllOptions");
1477 OMSProxy::instance()->setCommandLineOption(mpOMSimulatorPage->getCommandLineOptionsTextBox()->text());
1478 // set working directory
1479 mpSettings->setValue("OMSimulator/workingDirectory", mpOMSimulatorPage->getWorkingDirectory());
1480 OMSProxy::instance()->setWorkingDirectory(mpOMSimulatorPage->getWorkingDirectory());
1481 // set logging level
1482 mpSettings->setValue("OMSimulator/loggingLevel", mpOMSimulatorPage->getLoggingLevelComboBox()->itemData(mpOMSimulatorPage->getLoggingLevelComboBox()->currentIndex()).toInt());
1483 OMSProxy::instance()->setLoggingLevel(mpOMSimulatorPage->getLoggingLevelComboBox()->itemData(mpOMSimulatorPage->getLoggingLevelComboBox()->currentIndex()).toInt());
1484}
1485
1486/*!
1487 * \brief OptionsDialog::saveTraceabilitySettings
1488 * Saves the traceability settings in omedit.ini
1489 */
1490void OptionsDialog::saveTraceabilitySettings()
1491{
1492 // save traceability checkBox
1493 mpSettings->setValue("traceability/Traceability", mpTraceabilityPage->getTraceabilityGroupBox()->isChecked());
1494 // save user name
1495 mpSettings->setValue("traceability/UserName", mpTraceabilityPage->getUserName()->text());
1496 // save email
1497 mpSettings->setValue("traceability/Email", mpTraceabilityPage->getEmail()->text());
1498 // save Git repository
1499 mpSettings->setValue("traceability/GitRepository", mpTraceabilityPage->getGitRepository()->text());
1500 // save the traceability daemon IP-Adress
1501 mpSettings->setValue("traceability/IPAdress", mpTraceabilityPage->getTraceabilityDaemonIpAdress()->text());
1502 // save the traceability daemon port
1503 mpSettings->setValue("traceability/Port", mpTraceabilityPage->getTraceabilityDaemonPort()->text());
1504}
1505//! Sets up the Options Widget dialog
1506void OptionsDialog::setUpDialog()
1507{
1508 mpOptionsList = new QListWidget;
1509 mpOptionsList->setItemDelegate(new ItemDelegate(mpOptionsList));
1510 mpOptionsList->setViewMode(QListView::ListMode);
1511 mpOptionsList->setMovement(QListView::Static);
1512 mpOptionsList->setIconSize(QSize(24, 24));
1513 mpOptionsList->setCurrentRow(0, QItemSelectionModel::Select);
1514 connect(mpOptionsList, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*))"2""currentItemChanged(QListWidgetItem*,QListWidgetItem*)", SLOT(changePage(QListWidgetItem*,QListWidgetItem*))"1""changePage(QListWidgetItem*,QListWidgetItem*)");
1515 // add items to options list
1516 addListItems();
1517 // get maximum width for options list
1518 mpOptionsList->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
1519 int width = mpOptionsList->sizeHintForColumn(0) + mpOptionsList->frameWidth() * 2 + 20;
1520 if (mpOptionsList->verticalScrollBar()->isVisible()) {
1521 width += mpOptionsList->verticalScrollBar()->width();
1522 }
1523 mpOptionsList->setMaximumWidth(width);
1524 // create pages
1525 createPages();
1526 mpChangesEffectLabel = new Label(tr("* The changes will take effect after restart."));
1527 mpChangesEffectLabel->setElideMode(Qt::ElideMiddle);
1528 // Create the buttons
1529 mpOkButton = new QPushButton(Helper::ok);
1530 mpOkButton->setAutoDefault(true);
1531 connect(mpOkButton, SIGNAL(clicked())"2""clicked()", SLOT(saveSettings())"1""saveSettings()");
1532 mpCancelButton = new QPushButton(Helper::cancel);
1533 mpCancelButton->setAutoDefault(false);
1534 connect(mpCancelButton, SIGNAL(clicked())"2""clicked()", SLOT(reject())"1""reject()");
1535 mpResetButton = new QPushButton(Helper::reset);
1536 mpResetButton->setAutoDefault(false);
1537 connect(mpResetButton, SIGNAL(clicked())"2""clicked()", SLOT(reset())"1""reset()");
1538 mpButtonBox = new QDialogButtonBox(Qt::Horizontal);
1539 mpButtonBox->addButton(mpOkButton, QDialogButtonBox::ActionRole);
1540 mpButtonBox->addButton(mpResetButton, QDialogButtonBox::ActionRole);
1541 mpButtonBox->addButton(mpCancelButton, QDialogButtonBox::ActionRole);
1542 QHBoxLayout *horizontalLayout = new QHBoxLayout;
1543 horizontalLayout->addWidget(mpOptionsList);
1544 mpPagesWidgetScrollArea = new QScrollArea;
1545 mpPagesWidgetScrollArea->setWidgetResizable(true);
1546 mpPagesWidgetScrollArea->setWidget(mpPagesWidget);
1547 horizontalLayout->addWidget(mpPagesWidgetScrollArea);
1548 // Create a layout
1549 QGridLayout *mainLayout = new QGridLayout;
1550 mainLayout->addLayout(horizontalLayout, 0, 0, 1, 2);
1551 mainLayout->addWidget(mpChangesEffectLabel, 1, 0);
1552 mainLayout->addWidget(mpButtonBox, 1, 1, Qt::AlignRight);
1553 setLayout(mainLayout);
1554}
1555
1556//! Adds items to the list view of Options Widget
1557void OptionsDialog::addListItems()
1558{
1559 // General Settings Item
1560 QListWidgetItem *pGeneralSettingsItem = new QListWidgetItem(mpOptionsList);
1561 pGeneralSettingsItem->setIcon(QIcon(":/Resources/icons/general.svg"));
1562 pGeneralSettingsItem->setText(tr("General"));
1563 mpOptionsList->item(0)->setSelected(true);
1564 // Libraries Item
1565 QListWidgetItem *pLibrariesItem = new QListWidgetItem(mpOptionsList);
1566 pLibrariesItem->setIcon(QIcon(":/Resources/icons/libraries.svg"));
1567 pLibrariesItem->setText(Helper::libraries);
1568 // Text Editor Item
1569 QListWidgetItem *pTextEditorItem = new QListWidgetItem(mpOptionsList);
1570 pTextEditorItem->setIcon(QIcon(":/Resources/icons/modeltext.svg"));
1571 pTextEditorItem->setText(tr("Text Editor"));
1572 // Modelica Editor Item
1573 QListWidgetItem *pModelicaEditorItem = new QListWidgetItem(mpOptionsList);
1574 pModelicaEditorItem->setIcon(QIcon(":/Resources/icons/modeltext.svg"));
1575 pModelicaEditorItem->setText(tr("Modelica Editor"));
1576 // MetaModelica Editor Item
1577 QListWidgetItem *pMetaModelicaEditorItem = new QListWidgetItem(mpOptionsList);
1578 pMetaModelicaEditorItem->setIcon(QIcon(":/Resources/icons/modeltext.svg"));
1579 pMetaModelicaEditorItem->setText(tr("MetaModelica Editor"));
1580 // CompositeModel Editor Item
1581 QListWidgetItem *pCompositeModelEditorItem = new QListWidgetItem(mpOptionsList);
1582 pCompositeModelEditorItem->setIcon(QIcon(":/Resources/icons/modeltext.svg"));
1583 pCompositeModelEditorItem->setText(tr("CompositeModel Editor"));
1584 // OMSimulator Editor Item
1585 QListWidgetItem *pOMSimulatorEditorItem = new QListWidgetItem(mpOptionsList);
1586 pOMSimulatorEditorItem->setIcon(QIcon(":/Resources/icons/modeltext.svg"));
1587 pOMSimulatorEditorItem->setText(tr("OMSimulator Editor"));
1588 // C/C++ Editor Item
1589 QListWidgetItem *pCEditorItem = new QListWidgetItem(mpOptionsList);
1590 pCEditorItem->setIcon(QIcon(":/Resources/icons/modeltext.svg"));
1591 pCEditorItem->setText(tr("C/C++ Editor"));
1592 // HTML Editor Item
1593 QListWidgetItem *pHTMLEditorItem = new QListWidgetItem(mpOptionsList);
1594 pHTMLEditorItem->setIcon(QIcon(":/Resources/icons/modeltext.svg"));
1595 pHTMLEditorItem->setText(tr("HTML Editor"));
1596 // Graphical Views Item
1597 QListWidgetItem *pGraphicalViewsItem = new QListWidgetItem(mpOptionsList);
1598 pGraphicalViewsItem->setIcon(QIcon(":/Resources/icons/modeling.png"));
1599 pGraphicalViewsItem->setText(tr("Graphical Views"));
1600 // Simulation Item
1601 QListWidgetItem *pSimulationItem = new QListWidgetItem(mpOptionsList);
1602 pSimulationItem->setIcon(QIcon(":/Resources/icons/simulate.svg"));
1603 pSimulationItem->setText(Helper::simulation);
1604 // Messages Item
1605 QListWidgetItem *pMessagesItem = new QListWidgetItem(mpOptionsList);
1606 pMessagesItem->setIcon(QIcon(":/Resources/icons/messages.svg"));
1607 pMessagesItem->setText(tr("Messages"));
1608 // Notifications Item
1609 QListWidgetItem *pNotificationsItem = new QListWidgetItem(mpOptionsList);
1610 pNotificationsItem->setIcon(QIcon(":/Resources/icons/notificationicon.svg"));
1611 pNotificationsItem->setText(tr("Notifications"));
1612 // Pen Style Item
1613 QListWidgetItem *pLineStyleItem = new QListWidgetItem(mpOptionsList);
1614 pLineStyleItem->setIcon(QIcon(":/Resources/icons/linestyle.svg"));
1615 pLineStyleItem->setText(Helper::lineStyle);
1616 // Brush Style Item
1617 QListWidgetItem *pFillStyleItem = new QListWidgetItem(mpOptionsList);
1618 pFillStyleItem->setIcon(QIcon(":/Resources/icons/fillstyle.svg"));
1619 pFillStyleItem->setText(Helper::fillStyle);
1620 // Plotting Item
1621 QListWidgetItem *pPlottingItem = new QListWidgetItem(mpOptionsList);
1622 pPlottingItem->setIcon(QIcon(":/Resources/icons/omplot.png"));
1623 pPlottingItem->setText(tr("Plotting"));
1624 // Figaro Item
1625 QListWidgetItem *pFigaroItem = new QListWidgetItem(mpOptionsList);
1626 pFigaroItem->setIcon(QIcon(":/Resources/icons/console.svg"));
1627 pFigaroItem->setText(Helper::figaro);
1628 // Debugger Item
1629 QListWidgetItem *pDebuggerItem = new QListWidgetItem(mpOptionsList);
1630 pDebuggerItem->setIcon(QIcon(":/Resources/icons/debugger.svg"));
1631 pDebuggerItem->setText(tr("Debugger"));
1632 // FMI Item
1633 QListWidgetItem *pFMIItem = new QListWidgetItem(mpOptionsList);
1634 pFMIItem->setIcon(QIcon(":/Resources/icons/fmi.svg"));
1635 pFMIItem->setText(tr("FMI"));
1636 // TLM Item
1637 QListWidgetItem *pTLMItem = new QListWidgetItem(mpOptionsList);
1638 pTLMItem->setIcon(QIcon(":/Resources/icons/tlm-icon.svg"));
1639 pTLMItem->setText(tr("OMTLMSimulator"));
1640 // OMSimulator Item
1641 QListWidgetItem *pOMSimulatorItem = new QListWidgetItem(mpOptionsList);
1642 pOMSimulatorItem->setIcon(QIcon(":/Resources/icons/tlm-icon.svg"));
1643 pOMSimulatorItem->setText(tr("OMSimulator"));
1644 // Traceability Item
1645 QListWidgetItem *pTraceabilityItem = new QListWidgetItem(mpOptionsList);
1646 pTraceabilityItem->setIcon(QIcon(":/Resources/icons/traceability.svg"));
1647 pTraceabilityItem->setText(tr("Traceability"));
1648}
1649
1650//! Creates pages for the Options Widget. The pages are created as stacked widget and are mapped with mpOptionsList.
1651void OptionsDialog::createPages()
1652{
1653 mpPagesWidget = new QStackedWidget;
1654 mpPagesWidget->setContentsMargins(5, 2, 5, 2);
1655 mpPagesWidget->addWidget(mpGeneralSettingsPage);
1656 mpPagesWidget->addWidget(mpLibrariesPage);
1657 mpPagesWidget->addWidget(mpTextEditorPage);
1658 mpPagesWidget->addWidget(mpModelicaEditorPage);
1659 mpPagesWidget->addWidget(mpMetaModelicaEditorPage);
1660 mpPagesWidget->addWidget(mpCompositeModelEditorPage);
1661 mpPagesWidget->addWidget(mpOMSimulatorEditorPage);
1662 mpPagesWidget->addWidget(mpCEditorPage);
1663 mpPagesWidget->addWidget(mpHTMLEditorPage);
1664 mpPagesWidget->addWidget(mpGraphicalViewsPage);
1665 mpPagesWidget->addWidget(mpSimulationPage);
1666 mpPagesWidget->addWidget(mpMessagesPage);
1667 mpPagesWidget->addWidget(mpNotificationsPage);
1668 mpPagesWidget->addWidget(mpLineStylePage);
1669 mpPagesWidget->addWidget(mpFillStylePage);
1670 mpPagesWidget->addWidget(mpPlottingPage);
1671 mpPagesWidget->addWidget(mpFigaroPage);
1672 mpPagesWidget->addWidget(mpDebuggerPage);
1673 mpPagesWidget->addWidget(mpFMIPage);
1674 mpPagesWidget->addWidget(mpTLMPage);
1675 mpPagesWidget->addWidget(mpOMSimulatorPage);
1676 mpPagesWidget->addWidget(mpTraceabilityPage);
1677}
1678
1679/*!
1680 Saves the OptionsDialog geometry to omedit.ini file.
1681 */
1682void OptionsDialog::saveDialogGeometry()
1683{
1684 /* save the window geometry. */
1685 if (mpGeneralSettingsPage->getPreserveUserCustomizations()) {
1686 mpSettings->setValue("OptionsDialog/geometry", saveGeometry());
1687 }
1688}
1689
1690/*!
1691 * \brief OptionsDialog::show
1692 * Reimplementation of QDialog::show method.
1693 */
1694void OptionsDialog::show()
1695{
1696 /* restore the window geometry. */
1697 if (mpGeneralSettingsPage->getPreserveUserCustomizations()) {
1698 restoreGeometry(mpSettings->value("OptionsDialog/geometry").toByteArray());
1699 }
1700 setVisible(true);
1701}
1702
1703/*!
1704 * \brief OptionsDialog::getTabSettings
1705 * Returns a TabSettings
1706 * \return
1707 */
1708TabSettings OptionsDialog::getTabSettings()
1709{
1710 TabSettings tabSettings;
1711 tabSettings.setTabPolicy(mpTextEditorPage->getTabPolicyComboBox()->itemData(mpTextEditorPage->getTabPolicyComboBox()->currentIndex()).toInt());
1712 tabSettings.setTabSize(mpTextEditorPage->getTabSizeSpinBox()->value());
1713 tabSettings.setIndentSize(mpTextEditorPage->getIndentSpinBox()->value());
1714 return tabSettings;
1715}
1716
1717/*!
1718 * \brief OptionsDialog::changePage
1719 * Change the page in Options Widget when the mpOptionsList currentItemChanged Signal is raised.
1720 * \param current
1721 * \param previous
1722 */
1723void OptionsDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
1724{
1725 if (!current) {
1726 current = previous;
1727 }
1728 mpPagesWidget->setCurrentIndex(mpOptionsList->row(current));
1729 /* ticket:4345 reset the scrollbars to top */
1730 mpPagesWidgetScrollArea->verticalScrollBar()->setValue(0);
1731 mpPagesWidgetScrollArea->horizontalScrollBar()->setValue(0);
1732}
1733
1734//! Reimplementation of QWidget's reject function. If user reject the settings then set them back to original.
1735void OptionsDialog::reject()
1736{
1737 // read the old settings from the file
1738 readSettings();
1739 saveDialogGeometry();
1740 QDialog::reject();
1741}
1742
1743void OptionsDialog::reset()
1744{
1745 const QString title = tr("Reset to default");
1746 const QString text0 = tr("Are you sure that you want to reset OMEdit? This operation can not be undone. ");
1747 const QString textWithLink = tr(("Please back up your settings "
1748 + QString("<a href='%1'>file</a>").arg(mpSettings->fileName())
1749 + " before proceeding, restart to have the changes take effect.").toUtf8().constData());
1750 const QString text = text0 + textWithLink;
1751 QMessageBox* pResetMessageBox = new QMessageBox();
1752 pResetMessageBox->setTextFormat(Qt::RichText);
1753 pResetMessageBox->setWindowTitle(title);
1754 pResetMessageBox->setText(text);
1755 const QMessageBox::StandardButton reply = pResetMessageBox->question(this, title, text, QMessageBox::Ok | QMessageBox::Cancel);
1756 if (reply == QMessageBox::Ok) {
1757 mpSettings->clear();
1758 mpSettings->sync();
1759 accept();
1760 destroy();
1761 }
1762 delete pResetMessageBox;
1763}
1764
1765//! Saves the settings to omedit.ini file.
1766void OptionsDialog::saveSettings()
1767{
1768 saveGeneralSettings();
1769 saveLibrariesSettings();
1770 saveTextEditorSettings();
1771 saveModelicaEditorSettings();
1772 emit modelicaEditorSettingsChanged();
1773 saveMetaModelicaEditorSettings();
1774 emit metaModelicaEditorSettingsChanged();
1775 saveCompositeModelEditorSettings();
1776 emit compositeModelEditorSettingsChanged();
1777 saveOMSimulatorEditorSettings();
1778 emit omsimulatorEditorSettingsChanged();
1779 saveCEditorSettings();
1780 emit cEditorSettingsChanged();
1781 saveHTMLEditorSettings();
1782 emit HTMLEditorSettingsChanged();
1783 saveGraphicalViewsSettings();
1784 saveSimulationSettings();
1785 saveMessagesSettings();
1786 saveNotificationsSettings();
1787 saveLineStyleSettings();
1788 saveFillStyleSettings();
1789 savePlottingSettings();
1790 saveFigaroSettings();
1791 saveDebuggerSettings();
1792 saveFMISettings();
1793 saveTLMSettings();
1794 saveOMSimulatorSettings();
1795 saveTraceabilitySettings();
1796 // emit the signal so that all text editors can set settings & line wrapping mode
1797 emit textSettingsChanged();
1798 mpSettings->sync();
1799 saveDialogGeometry();
1800 accept();
1801}
1802
1803//! @class GeneralSettingsPage
1804//! @brief Creates an interface for genaral settings.
1805
1806//! Constructor
1807//! @param pOptionsDialog is the pointer to OptionsDialog
1808GeneralSettingsPage::GeneralSettingsPage(OptionsDialog *pOptionsDialog)
1809 : QWidget(pOptionsDialog)
1810{
1811 mpOptionsDialog = pOptionsDialog;
1812 mpGeneralSettingsGroupBox = new QGroupBox(Helper::general);
1813 // Language Option
1814 mpLanguageLabel = new Label(tr("Language: *"));
1815 mpLanguageComboBox = new QComboBox;
1816 mpLanguageComboBox->addItem(tr("Auto Detected"), "");
1817 /* Slow sorting, but works using regular Qt functions */
1818 QMap<QString, QLocale> map;
1819 map.insert(tr("Chinese").append(" (zh_CN)"), QLocale(QLocale::Chinese));
1820 map.insert(tr("English").append(" (en)"), QLocale(QLocale::English));
1821 map.insert(tr("French").append(" (fr)"), QLocale(QLocale::French));
1822 map.insert(tr("German").append(" (de)"), QLocale(QLocale::German));
1823 map.insert(tr("Italian").append(" (it)"), QLocale(QLocale::Italian));
1824 map.insert(tr("Japanese").append(" (ja)"), QLocale(QLocale::Japanese));
1825 map.insert(tr("Romanian").append(" (ro)"), QLocale(QLocale::Romanian));
1826 map.insert(tr("Russian").append(" (ru)"), QLocale(QLocale::Russian));
1827 map.insert(tr("Spanish").append(" (es)"), QLocale(QLocale::Spanish));
1828 map.insert(tr("Swedish").append(" (sv)"), QLocale(QLocale::Swedish));
1829 QStringList keys(map.keys());
1830 keys.sort();
1831 foreach (const QString &key, keys)for (auto _container_ = QtPrivate::qMakeForeachContainer(keys
); _container_.control && _container_.i != _container_
.e; ++_container_.i, _container_.control ^= 1) for (const QString
&key = *_container_.i; _container_.control; _container_.
control = 0)
{
1832 QLocale locale = map[key];
1833 mpLanguageComboBox->addItem(key, locale);
1834 }
1835 // Working Directory
1836 mpWorkingDirectoryLabel = new Label(Helper::workingDirectory);
1837 mpWorkingDirectoryTextBox = new QLineEdit(MainWindow::instance()->getOMCProxy()->changeDirectory());
1838 mpWorkingDirectoryBrowseButton = new QPushButton(Helper::browse);
1839 mpWorkingDirectoryBrowseButton->setAutoDefault(false);
1840 connect(mpWorkingDirectoryBrowseButton, SIGNAL(clicked())"2""clicked()", SLOT(selectWorkingDirectory())"1""selectWorkingDirectory()");
1841 // toolbar icon size
1842 mpToolbarIconSizeLabel = new Label(tr("Toolbar Icon Size: *"));
1843 mpToolbarIconSizeSpinBox = new QSpinBox;
1844 mpToolbarIconSizeSpinBox->setMinimum(16); // icons smaller than 16.......naaaaahhhh!!!!!
1845 mpToolbarIconSizeSpinBox->setValue(24);
1846 // Store Customizations Option
1847 mpPreserveUserCustomizations = new QCheckBox(tr("Preserve User's GUI Customizations"));
1848 mpPreserveUserCustomizations->setChecked(true);
1849 // terminal command
1850 mpTerminalCommandLabel = new Label(tr("Terminal Command:"));
1851 mpTerminalCommandTextBox = new QLineEdit;
1852#ifdef Q_OS_WIN32
1853 mpTerminalCommandTextBox->setText("cmd.exe");
1854#elif defined(Q_OS_MAC)
1855 mpTerminalCommandTextBox->setText("");
1856#else
1857 mpTerminalCommandTextBox->setText("");
1858#endif
1859 mpTerminalCommandBrowseButton = new QPushButton(Helper::browse);
1860 mpTerminalCommandBrowseButton->setAutoDefault(false);
1861 connect(mpTerminalCommandBrowseButton, SIGNAL(clicked())"2""clicked()", SLOT(selectTerminalCommand())"1""selectTerminalCommand()");
1862 // terminal command args
1863 mpTerminalCommandArgumentsLabel = new Label(tr("Terminal Command Arguments:"));
1864 mpTerminalCommandArgumentsTextBox = new QLineEdit;
1865 // hide variables browser checkbox
1866 mpHideVariablesBrowserCheckBox = new QCheckBox(tr("Hide Variables Browser"));
1867 mpHideVariablesBrowserCheckBox->setToolTip(tr("Hides the variable browser when switching away from plotting perspective."));
1868 mpHideVariablesBrowserCheckBox->setChecked(true);
1869 // activate access annotation
1870 mpActivateAccessAnnotationsLabel = new Label(tr("Activate Access Annotations *"));
1871 mpActivateAccessAnnotationsComboBox = new QComboBox;
1872 mpActivateAccessAnnotationsComboBox->addItem(tr("Always"), GeneralSettingsPage::Always);
1873 mpActivateAccessAnnotationsComboBox->addItem(tr("When loading .mol file(s)"), GeneralSettingsPage::Loading);
1874 mpActivateAccessAnnotationsComboBox->addItem(tr("Never"), GeneralSettingsPage::Never);
1875 mpActivateAccessAnnotationsComboBox->setCurrentIndex(1);
1876 mpActivateAccessAnnotationsComboBox->setToolTip(tr("<html><head/><body>"
1877 "<p>Options for handling of access annotations:</p>"
1878 "<ul><li><i>Always:</i> Activates the access annotations even for the non-encrypted libraries.</li>"
1879 "<li><i>When loading .mol file(s):</i> Activates the access annotations even if the .mol contains a non-encrypted library.</li>"
1880 "<li><i>Never:</i> Deactivates access annotations except for encrypted libraries.</li></ul>"
1881 "</body></html>"));
1882 // create backup file
1883 mpCreateBackupFileCheckbox = new QCheckBox(tr("Create a model.bak-mo backup file when deleting a model."));
1884 mpCreateBackupFileCheckbox->setChecked(true);
1885 // set the layout of general settings group
1886 QGridLayout *generalSettingsLayout = new QGridLayout;
1887 generalSettingsLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
1888 generalSettingsLayout->addWidget(mpLanguageLabel, 0, 0);
1889 generalSettingsLayout->addWidget(mpLanguageComboBox, 0, 1, 1, 2);
1890 generalSettingsLayout->addWidget(mpWorkingDirectoryLabel, 1, 0);
1891 generalSettingsLayout->addWidget(mpWorkingDirectoryTextBox, 1, 1);
1892 generalSettingsLayout->addWidget(mpWorkingDirectoryBrowseButton, 1, 2);
1893 generalSettingsLayout->addWidget(mpToolbarIconSizeLabel, 2, 0);
1894 generalSettingsLayout->addWidget(mpToolbarIconSizeSpinBox, 2, 1, 1, 2);
1895 generalSettingsLayout->addWidget(mpPreserveUserCustomizations, 3, 0, 1, 3);
1896 generalSettingsLayout->addWidget(mpTerminalCommandLabel, 4, 0);
1897 generalSettingsLayout->addWidget(mpTerminalCommandTextBox, 4, 1);
1898 generalSettingsLayout->addWidget(mpTerminalCommandBrowseButton, 4, 2);
1899 generalSettingsLayout->addWidget(mpTerminalCommandArgumentsLabel, 5, 0);
1900 generalSettingsLayout->addWidget(mpTerminalCommandArgumentsTextBox, 5, 1, 1, 2);
1901 generalSettingsLayout->addWidget(mpHideVariablesBrowserCheckBox, 6, 0, 1, 3);
1902 generalSettingsLayout->addWidget(mpActivateAccessAnnotationsLabel, 7, 0);
1903 generalSettingsLayout->addWidget(mpActivateAccessAnnotationsComboBox, 7, 1, 1, 2);
1904 generalSettingsLayout->addWidget(mpCreateBackupFileCheckbox, 8, 0, 1, 3);
1905 mpGeneralSettingsGroupBox->setLayout(generalSettingsLayout);
1906 // Libraries Browser group box
1907 mpLibrariesBrowserGroupBox = new QGroupBox(tr("Libraries Browser"));
1908 // library icon size
1909 mpLibraryIconSizeLabel = new Label(tr("Library Icon Size: *"));
1910 mpLibraryIconSizeSpinBox = new QSpinBox;
1911 mpLibraryIconSizeSpinBox->setMinimum(16);
1912 mpLibraryIconSizeSpinBox->setValue(24);
1913 // library icon max. text length, value is set later
1914 mpLibraryIconTextLengthLabel = new Label(tr("Max. Library Icon Text Length to Show: *"));
1915 mpLibraryIconTextLengthSpinBox = new QSpinBox;
1916 mpLibraryIconTextLengthSpinBox->setMinimum(0);
1917 // show protected classes
1918 mpShowProtectedClasses = new QCheckBox(tr("Show Protected Classes"));
1919 // show hidden classes
1920 mpShowHiddenClasses = new QCheckBox(tr("Show Hidden Classes (Ignores the annotation(Protection(access = Access.hide)))"));
1921 // Libraries Browser group box layout
1922 QGridLayout *pLibrariesBrowserLayout = new QGridLayout;
1923 pLibrariesBrowserLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
1924 pLibrariesBrowserLayout->setColumnStretch(1, 1);
1925 pLibrariesBrowserLayout->addWidget(mpLibraryIconSizeLabel, 0, 0);
1926 pLibrariesBrowserLayout->addWidget(mpLibraryIconSizeSpinBox, 0, 1);
1927 pLibrariesBrowserLayout->addWidget(mpLibraryIconTextLengthLabel, 1, 0);
1928 pLibrariesBrowserLayout->addWidget(mpLibraryIconTextLengthSpinBox, 1, 1);
1929 pLibrariesBrowserLayout->addWidget(mpShowProtectedClasses, 2, 0, 1, 2);
1930 pLibrariesBrowserLayout->addWidget(mpShowHiddenClasses, 3, 0, 1, 2);
1931 mpLibrariesBrowserGroupBox->setLayout(pLibrariesBrowserLayout);
1932 // Modeling View Mode
1933 mpModelingViewModeGroupBox = new QGroupBox(tr("Default Modeling View Mode"));
1934 mpModelingTabbedViewRadioButton = new QRadioButton(tr("Tabbed View"));
1935 mpModelingTabbedViewRadioButton->setChecked(true);
1936 mpModelingSubWindowViewRadioButton = new QRadioButton(tr("SubWindow View"));
1937 QButtonGroup *pModelingViewModeButtonGroup = new QButtonGroup;
1938 pModelingViewModeButtonGroup->addButton(mpModelingTabbedViewRadioButton);
1939 pModelingViewModeButtonGroup->addButton(mpModelingSubWindowViewRadioButton);
1940 // modeling view radio buttons layout
1941 QHBoxLayout *pModelingRadioButtonsLayout = new QHBoxLayout;
1942 pModelingRadioButtonsLayout->addWidget(mpModelingTabbedViewRadioButton);
1943 pModelingRadioButtonsLayout->addWidget(mpModelingSubWindowViewRadioButton);
1944 // set the layout of modeling view mode group
1945 QGridLayout *modelingViewModeLayout = new QGridLayout;
1946 modelingViewModeLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
1947 modelingViewModeLayout->addLayout(pModelingRadioButtonsLayout, 0, 0);
1948 mpModelingViewModeGroupBox->setLayout(modelingViewModeLayout);
1949 // Default View
1950 mpDefaultViewGroupBox = new QGroupBox(tr("Default View"));
1951 mpDefaultViewGroupBox->setToolTip(tr("This settings will be used when no preferredView annotation is defined."));
1952 mpIconViewRadioButton = new QRadioButton(Helper::iconView);
1953 mpDiagramViewRadioButton = new QRadioButton(Helper::diagramView);
1954 mpDiagramViewRadioButton->setChecked(true);
1955 mpTextViewRadioButton = new QRadioButton(Helper::textView);
1956 mpDocumentationViewRadioButton = new QRadioButton(Helper::documentationView);
1957 QButtonGroup *pDefaultViewButtonGroup = new QButtonGroup;
1958 pDefaultViewButtonGroup->addButton(mpIconViewRadioButton);
1959 pDefaultViewButtonGroup->addButton(mpDiagramViewRadioButton);
1960 pDefaultViewButtonGroup->addButton(mpTextViewRadioButton);
1961 pDefaultViewButtonGroup->addButton(mpDocumentationViewRadioButton);
1962 // default view radio buttons layout
1963 QGridLayout *pDefaultViewRadioButtonsGridLayout = new QGridLayout;
1964 pDefaultViewRadioButtonsGridLayout->addWidget(mpIconViewRadioButton, 0, 0);
1965 pDefaultViewRadioButtonsGridLayout->addWidget(mpDiagramViewRadioButton, 0, 1);
1966 pDefaultViewRadioButtonsGridLayout->addWidget(mpTextViewRadioButton, 1, 0);
1967 pDefaultViewRadioButtonsGridLayout->addWidget(mpDocumentationViewRadioButton, 1, 1);
1968 // set the layout of default view group
1969 QGridLayout *pDefaultViewLayout = new QGridLayout;
1970 pDefaultViewLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
1971 pDefaultViewLayout->addLayout(pDefaultViewRadioButtonsGridLayout, 0, 0);
1972 mpDefaultViewGroupBox->setLayout(pDefaultViewLayout);
1973 // Auto Save
1974 mpEnableAutoSaveGroupBox = new QGroupBox(tr("Enable Auto Save"));
1975 mpEnableAutoSaveGroupBox->setToolTip("Auto save feature is experimental. If you encounter unexpected crashes then disable it.");
1976 mpEnableAutoSaveGroupBox->setCheckable(true);
1977 mpEnableAutoSaveGroupBox->setChecked(true);
1978 mpAutoSaveIntervalLabel = new Label(tr("Auto Save Interval:"));
1979 mpAutoSaveIntervalSpinBox = new QSpinBox;
1980 mpAutoSaveIntervalSpinBox->setSuffix(tr(" seconds"));
1981 mpAutoSaveIntervalSpinBox->setRange(60, std::numeric_limits<int>::max());
1982 mpAutoSaveIntervalSpinBox->setSingleStep(30);
1983 mpAutoSaveIntervalSpinBox->setValue(300);
1984 mpAutoSaveSecondsLabel = new Label;
1985 connect(mpAutoSaveIntervalSpinBox, SIGNAL(valueChanged(int))"2""valueChanged(int)", SLOT(autoSaveIntervalValueChanged(int))"1""autoSaveIntervalValueChanged(int)");
1986 // calculate the auto save interval seconds.
1987 autoSaveIntervalValueChanged(mpAutoSaveIntervalSpinBox->value());
1988 // Auto Save layout
1989 QGridLayout *pAutoSaveGridLayout = new QGridLayout;
1990 pAutoSaveGridLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
1991 pAutoSaveGridLayout->addWidget(mpAutoSaveIntervalLabel, 0, 0);
1992 pAutoSaveGridLayout->addWidget(mpAutoSaveIntervalSpinBox, 0, 1);
1993 pAutoSaveGridLayout->addWidget(mpAutoSaveSecondsLabel, 0, 2);
1994 mpEnableAutoSaveGroupBox->setLayout(pAutoSaveGridLayout);
1995 // Welcome Page
1996 mpWelcomePageGroupBox = new QGroupBox(tr("Welcome Page"));
1997 mpHorizontalViewRadioButton = new QRadioButton(tr("Horizontal View"));
1998 mpHorizontalViewRadioButton->setChecked(true);
1999 mpVerticalViewRadioButton = new QRadioButton(tr("Vertical View"));
2000 QButtonGroup *pWelcomePageViewButtons = new QButtonGroup;
2001 pWelcomePageViewButtons->addButton(mpHorizontalViewRadioButton);
2002 pWelcomePageViewButtons->addButton(mpVerticalViewRadioButton);
2003 // plotting view radio buttons layout
2004 QHBoxLayout *pWelcomePageViewButtonsLayout = new QHBoxLayout;
2005 pWelcomePageViewButtonsLayout->addWidget(mpHorizontalViewRadioButton);
2006 pWelcomePageViewButtonsLayout->addWidget(mpVerticalViewRadioButton);
2007 // Show/hide latest news checkbox
2008 mpShowLatestNewsCheckBox = new QCheckBox(tr("Show Latest News"));
2009 mpShowLatestNewsCheckBox->setChecked(true);
2010 // Welcome Page layout
2011 QGridLayout *pWelcomePageGridLayout = new QGridLayout;
2012 pWelcomePageGridLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
2013 pWelcomePageGridLayout->addLayout(pWelcomePageViewButtonsLayout, 0, 0);
2014 pWelcomePageGridLayout->addWidget(mpShowLatestNewsCheckBox, 1, 0);
2015 mpWelcomePageGroupBox->setLayout(pWelcomePageGridLayout);
2016 // set the layout
2017 QVBoxLayout *pMainLayout = new QVBoxLayout;
2018 pMainLayout->setContentsMargins(0, 0, 0, 0);
2019 pMainLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
2020 pMainLayout->addWidget(mpGeneralSettingsGroupBox);
2021 pMainLayout->addWidget(mpLibrariesBrowserGroupBox);
2022 pMainLayout->addWidget(mpModelingViewModeGroupBox);
2023 pMainLayout->addWidget(mpDefaultViewGroupBox);
2024 pMainLayout->addWidget(mpEnableAutoSaveGroupBox);
2025 pMainLayout->addWidget(mpWelcomePageGroupBox);
2026 setLayout(pMainLayout);
2027}
2028
2029/*!
2030 * \brief GeneralSettingsPage::setModelingViewMode
2031 * Sets the Modeling view mode.
2032 * \param value
2033 */
2034void GeneralSettingsPage::setModelingViewMode(QString value)
2035{
2036 if (value.compare(Helper::subWindow) == 0) {
2037 mpModelingSubWindowViewRadioButton->setChecked(true);
2038 } else {
2039 mpModelingTabbedViewRadioButton->setChecked(true);
2040 }
2041}
2042
2043/*!
2044 * \brief GeneralSettingsPage::getModelingViewMode
2045 * Gets the Modeling view mode.
2046 * \return
2047 */
2048QString GeneralSettingsPage::getModelingViewMode()
2049{
2050 if (mpModelingSubWindowViewRadioButton->isChecked()) {
2051 return Helper::subWindow;
2052 } else {
2053 return Helper::tabbed;
2054 }
2055}
2056
2057/*!
2058 * \brief GeneralSettingsPage::setDefaultView
2059 * Sets the default view.
2060 * \param value
2061 */
2062void GeneralSettingsPage::setDefaultView(QString value)
2063{
2064 if (value.compare(Helper::iconView) == 0) {
2065 mpIconViewRadioButton->setChecked(true);
2066 } else if (value.compare(Helper::textView) == 0) {
2067 mpTextViewRadioButton->setChecked(true);
2068 } else if (value.compare(Helper::documentationView) == 0) {
2069 mpDocumentationViewRadioButton->setChecked(true);
2070 } else {
2071 mpDiagramViewRadioButton->setChecked(true);
2072 }
2073}
2074
2075/*!
2076 * \brief GeneralSettingsPage::getDefaultView
2077 * Returns the default view as QString.
2078 * \return
2079 */
2080QString GeneralSettingsPage::getDefaultView()
2081{
2082 if (mpIconViewRadioButton->isChecked()) {
2083 return Helper::iconView;
2084 } else if (mpTextViewRadioButton->isChecked()) {
2085 return Helper::textView;
2086 } else if (mpDocumentationViewRadioButton->isChecked()) {
2087 return Helper::documentationView;
2088 } else {
2089 return Helper::diagramView;
2090 }
2091}
2092
2093/*!
2094 * \brief GeneralSettingsPage::getWelcomePageView
2095 * Returns the WelcomePageWidget orientation.
2096 * \return
2097 */
2098int GeneralSettingsPage::getWelcomePageView()
2099{
2100 if (mpHorizontalViewRadioButton->isChecked()) {
2101 return 1;
2102 } else if (mpVerticalViewRadioButton->isChecked()) {
2103 return 2;
2104 } else {
2105 return 0;
2106 }
2107}
2108
2109/*!
2110 * \brief GeneralSettingsPage::setWelcomePageView
2111 * Sets the WelcomePageWidget orientation.
2112 * \param view
2113 */
2114void GeneralSettingsPage::setWelcomePageView(int view)
2115{
2116 switch (view) {
2117 case 2:
2118 mpVerticalViewRadioButton->setChecked(true);
2119 break;
2120 case 1:
2121 default:
2122 mpHorizontalViewRadioButton->setChecked(true);
2123 break;
2124 }
2125}
2126
2127/*!
2128 * \brief GeneralSettingsPage::selectWorkingDirectory
2129 * Slot activated when mpWorkingDirectoryBrowseButton clicked signal is raised.
2130 * Allows user to choose a new working directory.
2131 */
2132void GeneralSettingsPage::selectWorkingDirectory()
2133{
2134 mpWorkingDirectoryTextBox->setText(StringHandler::getExistingDirectory(this, QString("%1 - %2").arg(Helper::applicationName)
2135 .arg(Helper::chooseDirectory), NULL__null));
2136}
2137
2138/*!
2139 * \brief GeneralSettingsPage::selectTerminalCommand
2140 * Slot activated when mpTerminalCommandBrowseButton clicked signal is raised.
2141 * Allows user to select a new terminal command.
2142 */
2143void GeneralSettingsPage::selectTerminalCommand()
2144{
2145 mpTerminalCommandTextBox->setText(StringHandler::getOpenFileName(this, QString("%1 - %2").arg(Helper::applicationName)
2146 .arg(Helper::chooseFile), NULL__null, NULL__null, NULL__null));
2147}
2148
2149/*!
2150 * \brief GeneralSettingsPage::autoSaveIntervalValueChanged
2151 * Slot activated when mpAutoSaveIntervalSpinBox valueChanged signal is raised.
2152 * \param value
2153 */
2154void GeneralSettingsPage::autoSaveIntervalValueChanged(int value)
2155{
2156 mpAutoSaveSecondsLabel->setText(tr("(%1 minute(s))").arg((double)value/60));
2157}
2158
2159//! @class LibrariesPage
2160//! @brief Creates an interface for Libraries settings.
2161
2162//! Constructor
2163//! @param pOptionsDialog is the pointer to OptionsDialog
2164LibrariesPage::LibrariesPage(OptionsDialog *pOptionsDialog)
2165 : QWidget(pOptionsDialog)
2166{
2167 mpOptionsDialog = pOptionsDialog;
2168 // system libraries groupbox
2169 mpSystemLibrariesGroupBox = new QGroupBox(tr("System Libraries *"));
2170 // system libraries note
2171 mpSystemLibrariesNoteLabel = new Label(tr("The system libraries are read from the MODELICAPATH and are always read-only."));
2172 mpSystemLibrariesNoteLabel->setElideMode(Qt::ElideMiddle);
2173 // MODELICAPATH
2174 mpModelicaPathLabel = new Label(QString("MODELICAPATH = ").append(Helper::OpenModelicaLibrary));
2175 mpModelicaPathLabel->setElideMode(Qt::ElideMiddle);
2176 // system libraries tree
2177 mpSystemLibrariesTree = new QTreeWidget;
2178 mpSystemLibrariesTree->setItemDelegate(new ItemDelegate(mpSystemLibrariesTree));
2179 mpSystemLibrariesTree->setIndentation(0);
2180 mpSystemLibrariesTree->setColumnCount(2);
2181 mpSystemLibrariesTree->setTextElideMode(Qt::ElideMiddle);
2182 QStringList systemLabels;
2183 systemLabels << tr("Name") << Helper::version;
2184 mpSystemLibrariesTree->setHeaderLabels(systemLabels);
2185 connect(mpSystemLibrariesTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int))"2""itemDoubleClicked(QTreeWidgetItem*,int)", SLOT(openEditSystemLibrary())"1""openEditSystemLibrary()");
2186 // system libraries buttons
2187 mpAddSystemLibraryButton = new QPushButton(Helper::add);
2188 mpAddSystemLibraryButton->setAutoDefault(false);
2189 connect(mpAddSystemLibraryButton, SIGNAL(clicked())"2""clicked()", SLOT(openAddSystemLibrary())"1""openAddSystemLibrary()");
2190 mpEditSystemLibraryButton = new QPushButton(Helper::edit);
2191 mpEditSystemLibraryButton->setAutoDefault(false);
2192 connect(mpEditSystemLibraryButton, SIGNAL(clicked())"2""clicked()", SLOT(openEditSystemLibrary())"1""openEditSystemLibrary()");
2193 mpRemoveSystemLibraryButton = new QPushButton(Helper::remove);
2194 mpRemoveSystemLibraryButton->setAutoDefault(false);
2195 connect(mpRemoveSystemLibraryButton, SIGNAL(clicked())"2""clicked()", SLOT(removeSystemLibrary())"1""removeSystemLibrary()");
2196 // system libraries button box
2197 mpSystemLibrariesButtonBox = new QDialogButtonBox(Qt::Vertical);
2198 mpSystemLibrariesButtonBox->addButton(mpAddSystemLibraryButton, QDialogButtonBox::ActionRole);
2199 mpSystemLibrariesButtonBox->addButton(mpEditSystemLibraryButton, QDialogButtonBox::ActionRole);
2200 mpSystemLibrariesButtonBox->addButton(mpRemoveSystemLibraryButton, QDialogButtonBox::ActionRole);
2201 // system libraries groupbox layout
2202 QGridLayout *pSystemLibrariesLayout = new QGridLayout;
2203 pSystemLibrariesLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
2204 pSystemLibrariesLayout->addWidget(mpSystemLibrariesNoteLabel, 0, 0, 1, 2);
2205 pSystemLibrariesLayout->addWidget(mpModelicaPathLabel, 1, 0);
2206 pSystemLibrariesLayout->addWidget(mpSystemLibrariesTree, 2, 0);
2207 pSystemLibrariesLayout->addWidget(mpSystemLibrariesButtonBox, 2, 1);
2208 mpSystemLibrariesGroupBox->setLayout(pSystemLibrariesLayout);
2209 // force Modelica load checkbox
2210 mpForceModelicaLoadCheckBox = new QCheckBox(tr("Force loading of Modelica Standard Library"));
2211 mpForceModelicaLoadCheckBox->setToolTip(tr("This will make sure that Modelica and ModelicaReference will always load even if user has removed them from the list of system libraries."));
2212 mpForceModelicaLoadCheckBox->setChecked(true);
2213 // force Modelica load checkbox
2214 mpLoadOpenModelicaOnStartupCheckBox = new QCheckBox(tr("Load OpenModelica library on startup"));
2215 mpLoadOpenModelicaOnStartupCheckBox->setChecked(true);
2216 // user libraries groupbox
2217 mpUserLibrariesGroupBox = new QGroupBox(tr("User Libraries *"));
2218 // user libraries tree
2219 mpUserLibrariesTree = new QTreeWidget;
2220 mpUserLibrariesTree->setItemDelegate(new ItemDelegate(mpUserLibrariesTree));
2221 mpUserLibrariesTree->setIndentation(0);
2222 mpUserLibrariesTree->setColumnCount(2);
2223 mpUserLibrariesTree->setTextElideMode(Qt::ElideMiddle);
2224 QStringList userLabels;
2225 userLabels << tr("Path") << tr("Encoding");
2226 mpUserLibrariesTree->setHeaderLabels(userLabels);
2227 connect(mpUserLibrariesTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int))"2""itemDoubleClicked(QTreeWidgetItem*,int)", SLOT(openEditUserLibrary())"1""openEditUserLibrary()");
2228 // user libraries buttons
2229 mpAddUserLibraryButton = new QPushButton(Helper::add);
2230 mpAddUserLibraryButton->setAutoDefault(false);
2231 connect(mpAddUserLibraryButton, SIGNAL(clicked())"2""clicked()", SLOT(openAddUserLibrary())"1""openAddUserLibrary()");
2232 mpEditUserLibraryButton = new QPushButton(Helper::edit);
2233 mpEditUserLibraryButton->setAutoDefault(false);
2234 connect(mpEditUserLibraryButton, SIGNAL(clicked())"2""clicked()", SLOT(openEditUserLibrary())"1""openEditUserLibrary()");
2235 mpRemoveUserLibraryButton = new QPushButton(Helper::remove);
2236 mpRemoveUserLibraryButton->setAutoDefault(false);
2237 connect(mpRemoveUserLibraryButton, SIGNAL(clicked())"2""clicked()", SLOT(removeUserLibrary())"1""removeUserLibrary()");
2238 // user libraries button box
2239 mpUserLibrariesButtonBox = new QDialogButtonBox(Qt::Vertical);
2240 mpUserLibrariesButtonBox->addButton(mpAddUserLibraryButton, QDialogButtonBox::ActionRole);
2241 mpUserLibrariesButtonBox->addButton(mpEditUserLibraryButton, QDialogButtonBox::ActionRole);
2242 mpUserLibrariesButtonBox->addButton(mpRemoveUserLibraryButton, QDialogButtonBox::ActionRole);
2243 // user libraries groupbox layout
2244 QGridLayout *pUserLibrariesLayout = new QGridLayout;
2245 pUserLibrariesLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
2246 pUserLibrariesLayout->addWidget(mpUserLibrariesTree, 0, 0);
2247 pUserLibrariesLayout->addWidget(mpUserLibrariesButtonBox, 0, 1);
2248 mpUserLibrariesGroupBox->setLayout(pUserLibrariesLayout);
2249 // main layout
2250 QVBoxLayout *layout = new QVBoxLayout;
2251 layout->setContentsMargins(0, 0, 0, 0);
2252 layout->addWidget(mpSystemLibrariesGroupBox);
2253 layout->addWidget(mpForceModelicaLoadCheckBox);
2254 layout->addWidget(mpLoadOpenModelicaOnStartupCheckBox);
2255 layout->addWidget(mpUserLibrariesGroupBox);
2256 setLayout(layout);
2257}
2258
2259//! Slot activated when mpAddSystemLibraryButton clicked signal is raised.
2260//! Creates an instance of AddLibraryWidget and show it.
2261void LibrariesPage::openAddSystemLibrary()
2262{
2263 AddSystemLibraryDialog *pAddSystemLibraryWidget = new AddSystemLibraryDialog(this);
2264 pAddSystemLibraryWidget->show();
2265}
2266
2267//! Slot activated when mpRemoveSystemLibraryButton clicked signal is raised.
2268//! Removes the selected tree item
2269void LibrariesPage::removeSystemLibrary()
2270{
2271 if (mpSystemLibrariesTree->selectedItems().size() > 0)
2272 {
2273 mpSystemLibrariesTree->removeItemWidget(mpSystemLibrariesTree->selectedItems().at(0), 0);
2274 delete mpSystemLibrariesTree->selectedItems().at(0);
2275 }
2276}
2277
2278//! Slot activated when mpEditSystemLibraryButton clicked signal is raised.
2279//! Opens the AddLibraryWidget in edit mode and pass it the selected tree item.
2280void LibrariesPage::openEditSystemLibrary()
2281{
2282 if (mpSystemLibrariesTree->selectedItems().size() > 0)
2283 {
2284 AddSystemLibraryDialog *pAddSystemLibraryWidget = new AddSystemLibraryDialog(this);
2285 pAddSystemLibraryWidget->setWindowTitle(QString(Helper::applicationName).append(" - ").append(tr("Edit System Library")));
2286 pAddSystemLibraryWidget->mEditFlag = true;
2287 int currentIndex = pAddSystemLibraryWidget->mpNameComboBox->findText(mpSystemLibrariesTree->selectedItems().at(0)->text(0), Qt::MatchExactly);
2288 pAddSystemLibraryWidget->mpNameComboBox->setCurrentIndex(currentIndex);
2289 pAddSystemLibraryWidget->mpVersionTextBox->setText(mpSystemLibrariesTree->selectedItems().at(0)->text(1));
2290 pAddSystemLibraryWidget->show();
2291 }
2292}
2293
2294//! Slot activated when mpAddUserLibraryButton clicked signal is raised.
2295//! Creates an instance of AddLibraryWidget and show it.
2296void LibrariesPage::openAddUserLibrary()
2297{
2298 AddUserLibraryDialog *pAddUserLibraryWidget = new AddUserLibraryDialog(this);
2299 pAddUserLibraryWidget->show();
2300}
2301
2302//! Slot activated when mpRemoveUserLibraryButton clicked signal is raised.
2303//! Removes the selected tree item
2304void LibrariesPage::removeUserLibrary()
2305{
2306 if (mpUserLibrariesTree->selectedItems().size() > 0)
2307 {
2308 mpUserLibrariesTree->removeItemWidget(mpUserLibrariesTree->selectedItems().at(0), 0);
2309 delete mpUserLibrariesTree->selectedItems().at(0);
2310 }
2311}
2312
2313//! Slot activated when mpEditUserLibraryButton clicked signal is raised.
2314//! Opens the AddLibraryWidget in edit mode and pass it the selected tree item.
2315void LibrariesPage::openEditUserLibrary()
2316{
2317 if (mpUserLibrariesTree->selectedItems().size() > 0)
2318 {
2319 AddUserLibraryDialog *pAddUserLibraryWidget = new AddUserLibraryDialog(this);
2320 pAddUserLibraryWidget->setWindowTitle(QString(Helper::applicationName).append(" - ").append(tr("Edit User Library")));
2321 pAddUserLibraryWidget->mEditFlag = true;
2322 pAddUserLibraryWidget->mpPathTextBox->setText(mpUserLibrariesTree->selectedItems().at(0)->text(0));
2323 int currentIndex = pAddUserLibraryWidget->mpEncodingComboBox->findData(mpUserLibrariesTree->selectedItems().at(0)->text(1));
2324 if (currentIndex > -1)
2325 pAddUserLibraryWidget->mpEncodingComboBox->setCurrentIndex(currentIndex);
2326 pAddUserLibraryWidget->show();
2327 }
2328}
2329
2330//! @class AddSystemLibraryDialog
2331//! @brief Creates an interface for Adding new System Libraries.
2332
2333//! Constructor
2334//! @param pLibrariesPage is the pointer to LibrariesPage
2335AddSystemLibraryDialog::AddSystemLibraryDialog(LibrariesPage *pLibrariesPage)
2336 : QDialog(pLibrariesPage), mEditFlag(false)
2337{
2338 setWindowTitle(QString(Helper::applicationName).append(" - ").append(tr("Add System Library")));
2339 setAttribute(Qt::WA_DeleteOnClose);
2340 setModal(true);
2341 mpLibrariesPage = pLibrariesPage;
2342 mpNameLabel = new Label(Helper::name);
2343 mpNameComboBox = new QComboBox;
2344 foreach (const QString &key, MainWindow::instance()->getOMCProxy()->getAvailableLibraries())for (auto _container_ = QtPrivate::qMakeForeachContainer(MainWindow
::instance()->getOMCProxy()->getAvailableLibraries()); _container_
.control && _container_.i != _container_.e; ++_container_
.i, _container_.control ^= 1) for (const QString &key = *
_container_.i; _container_.control; _container_.control = 0)
{
2345 mpNameComboBox->addItem(key,key);
2346 }
2347
2348 mpValueLabel = new Label(Helper::version + ":");
2349 mpVersionTextBox = new QLineEdit("default");
2350 mpOkButton = new QPushButton(Helper::ok);
2351 connect(mpOkButton, SIGNAL(clicked())"2""clicked()", SLOT(addSystemLibrary())"1""addSystemLibrary()");
2352 QGridLayout *mainLayout = new QGridLayout;
2353 mainLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
2354 mainLayout->addWidget(mpNameLabel, 0, 0);
2355 mainLayout->addWidget(mpNameComboBox, 0, 1);
2356 mainLayout->addWidget(mpValueLabel, 1, 0);
2357 mainLayout->addWidget(mpVersionTextBox, 1, 1);
2358 mainLayout->addWidget(mpOkButton, 2, 0, 1, 2, Qt::AlignRight);
2359 setLayout(mainLayout);
2360}
2361
2362//! Returns tree if the name exists in the tree's first column.
2363bool AddSystemLibraryDialog::nameExists(QTreeWidgetItem *pItem)
2364{
2365 QTreeWidgetItemIterator it(mpLibrariesPage->getSystemLibrariesTree());
2366 while (*it)
2367 {
2368 QTreeWidgetItem *pChildItem = dynamic_cast<QTreeWidgetItem*>(*it);
2369 // edit case
2370 if (pItem)
2371 {
2372 if (pChildItem != pItem)
2373 {
2374 if (pChildItem->text(0).compare(mpNameComboBox->currentText()) == 0)
2375 {
2376 return true;
2377 }
2378 }
2379 }
2380 // add case
2381 else
2382 {
2383 if (pChildItem->text(0).compare(mpNameComboBox->currentText()) == 0)
2384 {
2385 return true;
2386 }
2387 }
2388 ++it;
2389 }
2390 return false;
2391}
2392
2393//! Slot activated when mpOkButton clicked signal is raised.
2394//! Add/Edit the system library in the tree.
2395void AddSystemLibraryDialog::addSystemLibrary()
2396{
2397 // if name text box is empty show error and return
2398 if (mpNameComboBox->currentText().isEmpty())
2399 {
2400 QMessageBox::critical(this, QString(Helper::applicationName).append(" - ").append(Helper::error),
2401 GUIMessages::getMessage(GUIMessages::ENTER_NAME).arg("a"), Helper::ok);
2402 return;
2403 }
2404 // if value text box is empty show error and return
2405 if (mpVersionTextBox->text().isEmpty())
2406 {
2407 QMessageBox::critical(this, QString(Helper::applicationName).append(" - ").append(Helper::error),
2408 GUIMessages::getMessage(GUIMessages::ENTER_NAME).arg("the value for a"), Helper::ok);
2409 return;
2410 }
2411 // if user is adding a new library
2412 if (!mEditFlag)
2413 {
2414 if (nameExists())
2415 {
2416 QMessageBox::critical(this, QString(Helper::applicationName).append(" - ").append(Helper::error),
2417 GUIMessages::getMessage(GUIMessages::ITEM_ALREADY_EXISTS), Helper::ok);
2418 return;
2419 }
2420 QStringList values;
2421 values << mpNameComboBox->currentText() << mpVersionTextBox->text();
2422 mpLibrariesPage->getSystemLibrariesTree()->addTopLevelItem(new QTreeWidgetItem(values));
2423 }
2424 // if user is editing old library
2425 else if (mEditFlag)
2426 {
2427 QTreeWidgetItem *pItem = mpLibrariesPage->getSystemLibrariesTree()->selectedItems().at(0);
2428 if (nameExists(pItem))
2429 {
2430 QMessageBox::critical(this, QString(Helper::applicationName).append(" - ").append(Helper::error),
2431 GUIMessages::getMessage(GUIMessages::ITEM_ALREADY_EXISTS), Helper::ok);
2432 return;
2433 }
2434 // pItem->setText(0, mpNameTextBox->text());
2435 pItem->setText(1, mpVersionTextBox->text());
2436 }
2437 accept();
2438}
2439
2440//! @class AddUserLibraryDialog
2441//! @brief Creates an interface for Adding new User Libraries.
2442
2443//! Constructor
2444//! @param pLibrariesPage is the pointer to LibrariesPage
2445AddUserLibraryDialog::AddUserLibraryDialog(LibrariesPage *pLibrariesPage)
2446 : QDialog(pLibrariesPage), mEditFlag(false)
2447{
2448 setWindowTitle(QString(Helper::applicationName).append(" - ").append(tr("Add User Library")));
2449 setAttribute(Qt::WA_DeleteOnClose);
2450 setModal(true);
2451 mpLibrariesPage = pLibrariesPage;
2452 mpPathLabel = new Label(Helper::path);
2453 mpPathTextBox = new QLineEdit;
2454 mpPathBrowseButton = new QPushButton(Helper::browse);
2455 mpPathBrowseButton->setAutoDefault(false);
2456 connect(mpPathBrowseButton, SIGNAL(clicked())"2""clicked()", SLOT(browseUserLibraryPath())"1""browseUserLibraryPath()");
2457 mpEncodingLabel = new Label(Helper::encoding);
2458 mpEncodingComboBox = new QComboBox;
2459 StringHandler::fillEncodingComboBox(mpEncodingComboBox);
2460 mpOkButton = new QPushButton(Helper::ok);
2461 connect(mpOkButton, SIGNAL(clicked())"2""clicked()", SLOT(addUserLibrary())"1""addUserLibrary()");
2462 QGridLayout *mainLayout = new QGridLayout;
2463 mainLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
2464 mainLayout->addWidget(mpPathLabel, 0, 0);
2465 mainLayout->addWidget(mpPathTextBox, 0, 1);
2466 mainLayout->addWidget(mpPathBrowseButton, 0, 2);
2467 mainLayout->addWidget(mpEncodingLabel, 1, 0);
2468 mainLayout->addWidget(mpEncodingComboBox, 1, 1, 1, 2);
2469 mainLayout->addWidget(mpOkButton, 2, 0, 1, 3, Qt::AlignRight);
2470 setLayout(mainLayout);
2471}
2472
2473//! Returns tree if the name exists in the tree's first column.
2474bool AddUserLibraryDialog::pathExists(QTreeWidgetItem *pItem)
2475{
2476 QTreeWidgetItemIterator it(mpLibrariesPage->getUserLibrariesTree());
2477 while (*it)
2478 {
2479 QTreeWidgetItem *pChildItem = dynamic_cast<QTreeWidgetItem*>(*it);
2480 // edit case
2481 if (pItem)
2482 {
2483 if (pChildItem != pItem)
2484 {
2485 if (pChildItem->text(0).compare(mpPathTextBox->text()) == 0)
2486 {
2487 return true;
2488 }
2489 }
2490 }
2491 // add case
2492 else
2493 {
2494 if (pChildItem->text(0).compare(mpPathTextBox->text()) == 0)
2495 {
2496 return true;
2497 }
2498 }
2499 ++it;
2500 }
2501 return false;
2502}
2503
2504//! Slot activated when mpPathBrowseButton clicked signal is raised.
2505//! Add/Edit the user library in the tree.
2506void AddUserLibraryDialog::browseUserLibraryPath()
2507{
2508 mpPathTextBox->setText(StringHandler::getOpenFileName(this, QString(Helper::applicationName).append(" - ").append(Helper::chooseFile),
2509 NULL__null, Helper::omFileTypes, NULL__null));
2510}
2511
2512//! Slot activated when mpOkButton clicked signal is raised.
2513//! Add/Edit the user library in the tree.
2514void AddUserLibraryDialog::addUserLibrary()
2515{
2516 // if path text box is empty show error and return
2517 if (mpPathTextBox->text().isEmpty())
2518 {
2519 QMessageBox::critical(this, QString(Helper::applicationName).append(" - ").append(Helper::error),
2520 tr("Please enter the file path."), Helper::ok);
2521 return;
2522 }
2523 // if user is adding a new library
2524 if (!mEditFlag)
2525 {
2526 if (pathExists())
2527 {
2528 QMessageBox::critical(this, QString(Helper::applicationName).append(" - ").append(Helper::error),
2529 GUIMessages::getMessage(GUIMessages::ITEM_ALREADY_EXISTS), Helper::ok);
2530 return;
2531 }
2532 QStringList values;
2533 values << mpPathTextBox->text() << mpEncodingComboBox->itemData(mpEncodingComboBox->currentIndex()).toString();
2534 mpLibrariesPage->getUserLibrariesTree()->addTopLevelItem(new QTreeWidgetItem(values));
2535 }
2536 // if user is editing old library
2537 else if (mEditFlag)
2538 {
2539 QTreeWidgetItem *pItem = mpLibrariesPage->getUserLibrariesTree()->selectedItems().at(0);
2540 if (pathExists(pItem))
2541 {
2542 QMessageBox::critical(this, QString(Helper::applicationName).append(" - ").append(Helper::error),
2543 GUIMessages::getMessage(GUIMessages::ITEM_ALREADY_EXISTS), Helper::ok);
2544 return;
2545 }
2546 pItem->setText(0, mpPathTextBox->text());
2547 pItem->setText(1, mpEncodingComboBox->itemData(mpEncodingComboBox->currentIndex()).toString());
2548 }
2549 accept();
2550}
2551
2552/*!
2553 * \class TextEditorPage
2554 * \brief Creates an interface for Text Editor settings.
2555 */
2556/*!
2557 * \brief TextEditorPage::TextEditorPage
2558 * \param pOptionsDialog is the pointer to OptionsDialog
2559 */
2560TextEditorPage::TextEditorPage(OptionsDialog *pOptionsDialog)
2561 : QWidget(pOptionsDialog)
2562{
2563 mpOptionsDialog = pOptionsDialog;
2564 // format groupbox
2565 mpFormatGroupBox = new QGroupBox(tr("Format"));
2566 // line ending
2567 mpLineEndingLabel = new Label(tr("Line Ending:"));
2568 mpLineEndingComboBox = new QComboBox;
2569 mpLineEndingComboBox->addItem(tr("Windows (CRLF)"), Utilities::CRLFLineEnding);
2570 mpLineEndingComboBox->addItem(tr("Unix (LF)"), Utilities::LFLineEnding);
2571#ifndef WIN32
2572 mpLineEndingComboBox->setCurrentIndex(1);
2573#endif
2574 // Byte Order Mark BOM
2575 mpBOMLabel = new Label(tr("Byte Order Mark (BOM):"));
2576 mpBOMComboBox = new QComboBox;
2577 mpBOMComboBox->setToolTip(tr("<html><head/><body>"
2578 "<p>Note that BOMs are uncommon and treated incorrectly by some editors, so it usually makes little sense to add any.</p>"
2579 "<ul><li><i>Always Add:</i> always add a BOM when saving a file.</li>"
2580 "<li><i>Keep If Already Present:</i> save the file with a BOM if it already had one when it was loaded.</li>"
2581 "<li><i>Always Delete:</i> never write a BOM, possibly deleting a pre-existing one.</li></ul>"
2582 "</body></html>"));
2583 mpBOMComboBox->addItem(tr("Always Add"), Utilities::AlwaysAddBom);
2584 mpBOMComboBox->addItem(tr("Keep If Already Present"), Utilities::KeepBom);
2585 mpBOMComboBox->addItem(tr("Always Delete"), Utilities::AlwaysDeleteBom);
2586 mpBOMComboBox->setCurrentIndex(1);
2587 // set format groupbox layout
2588 QGridLayout *pFormatGroupBoxLayout = new QGridLayout;
2589 pFormatGroupBoxLayout->addWidget(mpLineEndingLabel, 0, 0);
2590 pFormatGroupBoxLayout->setColumnStretch(1, 1);
2591 pFormatGroupBoxLayout->addWidget(mpLineEndingComboBox, 0, 1);
2592 pFormatGroupBoxLayout->addWidget(mpBOMLabel, 1, 0);
2593 pFormatGroupBoxLayout->addWidget(mpBOMComboBox, 1, 1);
2594 mpFormatGroupBox->setLayout(pFormatGroupBoxLayout);
2595 // tabs and indentation groupbox
2596 mpTabsAndIndentation = new QGroupBox(tr("Tabs and Indentation"));
2597 // tab policy
2598 mpTabPolicyLabel = new Label(tr("Tab Policy:"));
2599 mpTabPolicyComboBox = new QComboBox;
2600 mpTabPolicyComboBox->addItem(tr("Spaces Only"), 0);
2601 mpTabPolicyComboBox->addItem(tr("Tabs Only"), 1);
2602 // tab size
2603 mpTabSizeLabel = new Label(tr("Tab Size:"));
2604 mpTabSizeSpinBox = new QSpinBox;
2605 mpTabSizeSpinBox->setRange(1, 20);
2606 mpTabSizeSpinBox->setValue(4);
2607 // indent size
2608 mpIndentSizeLabel = new Label(tr("Indent Size:"));
2609 mpIndentSpinBox = new QSpinBox;
2610 mpIndentSpinBox->setRange(1, 20);
2611 mpIndentSpinBox->setValue(2);
2612 // set tabs & indentation groupbox layout
2613 QGridLayout *pTabsAndIndentationGroupBoxLayout = new QGridLayout;
2614 pTabsAndIndentationGroupBoxLayout->addWidget(mpTabPolicyLabel, 0, 0);
2615 pTabsAndIndentationGroupBoxLayout->setColumnStretch(1, 1);
2616 pTabsAndIndentationGroupBoxLayout->addWidget(mpTabPolicyComboBox, 0, 1);
2617 pTabsAndIndentationGroupBoxLayout->addWidget(mpTabSizeLabel, 1, 0);
2618 pTabsAndIndentationGroupBoxLayout->addWidget(mpTabSizeSpinBox, 1, 1);
2619 pTabsAndIndentationGroupBoxLayout->addWidget(mpIndentSizeLabel, 2, 0);
2620 pTabsAndIndentationGroupBoxLayout->addWidget(mpIndentSpinBox, 2, 1);
2621 mpTabsAndIndentation->setLayout(pTabsAndIndentationGroupBoxLayout);
2622 // syntax highlight and text wrapping groupbox
2623 mpSyntaxHighlightAndTextWrappingGroupBox = new QGroupBox(tr("Syntax Highlight and Text Wrapping"));
2624 // syntax highlighting groupbox
2625 mpSyntaxHighlightingGroupBox = new QGroupBox(tr("Enable Syntax Highlighting"));
2626 mpSyntaxHighlightingGroupBox->setCheckable(true);
2627 mpSyntaxHighlightingGroupBox->setChecked(true);
2628 // code folding checkbox
2629 mpCodeFoldingCheckBox = new QCheckBox(tr("Enable Code Folding"));
2630 mpCodeFoldingCheckBox->setChecked(true);
2631 // match parenthesis within comments and quotes
2632 mpMatchParenthesesCommentsQuotesCheckBox = new QCheckBox(tr("Match Parentheses within Comments and Quotes"));
2633 // set Syntax Highlighting groupbox layout
2634 QGridLayout *pSyntaxHighlightingGroupBoxLayout = new QGridLayout;
2635 pSyntaxHighlightingGroupBoxLayout->addWidget(mpCodeFoldingCheckBox, 0, 0);
2636 pSyntaxHighlightingGroupBoxLayout->addWidget(mpMatchParenthesesCommentsQuotesCheckBox, 1, 0);
2637 mpSyntaxHighlightingGroupBox->setLayout(pSyntaxHighlightingGroupBoxLayout);
2638 // line wrap checkbox
2639 mpLineWrappingCheckbox = new QCheckBox(tr("Enable Line Wrapping"));
2640 mpLineWrappingCheckbox->setChecked(true);
2641 // set Syntax Highlight & Text Wrapping groupbox layout
2642 QGridLayout *pSyntaxHighlightAndTextWrappingGroupBoxLayout = new QGridLayout;
2643 pSyntaxHighlightAndTextWrappingGroupBoxLayout->addWidget(mpSyntaxHighlightingGroupBox, 0, 0);
2644 pSyntaxHighlightAndTextWrappingGroupBoxLayout->addWidget(mpLineWrappingCheckbox, 1, 0);
2645 mpSyntaxHighlightAndTextWrappingGroupBox->setLayout(pSyntaxHighlightAndTextWrappingGroupBoxLayout);
2646 // AutoCompleter group box
2647 mpAutoCompleteGroupBox = new QGroupBox(tr("Autocomplete"));
2648 // autocompleter checkbox
2649 mpAutoCompleteCheckBox = new QCheckBox(tr("Enable Autocomplete"));
2650 mpAutoCompleteCheckBox->setChecked(true);
2651 QGridLayout *pAutoCompleteGroupBoxLayout = new QGridLayout;
2652 pAutoCompleteGroupBoxLayout->addWidget(mpAutoCompleteCheckBox,0,0);
2653 mpAutoCompleteGroupBox->setLayout(pAutoCompleteGroupBoxLayout);
2654 // font groupbox
2655 mpFontGroupBox = new QGroupBox(tr("Font"));
2656 // font family combobox
2657 mpFontFamilyLabel = new Label(Helper::fontFamily);
2658 mpFontFamilyComboBox = new QFontComboBox;
2659 int currentIndex;
2660 currentIndex = mpFontFamilyComboBox->findText(Helper::monospacedFontInfo.family(), Qt::MatchExactly);
2661 mpFontFamilyComboBox->setCurrentIndex(currentIndex);
2662 // font size combobox
2663 mpFontSizeLabel = new Label(Helper::fontSize);
2664 mpFontSizeSpinBox = new DoubleSpinBox;
2665 mpFontSizeSpinBox->setRange(6, std::numeric_limits<double>::max());
2666 mpFontSizeSpinBox->setValue(Helper::monospacedFontInfo.pointSizeF());
2667 mpFontSizeSpinBox->setSingleStep(1);
2668 // set font groupbox layout
2669 QGridLayout *pFontGroupBoxLayout = new QGridLayout;
2670 pFontGroupBoxLayout->addWidget(mpFontFamilyLabel, 0, 0);
2671 pFontGroupBoxLayout->addWidget(mpFontSizeLabel, 0, 1);
2672 pFontGroupBoxLayout->addWidget(mpFontFamilyComboBox, 1, 0);
2673 pFontGroupBoxLayout->addWidget(mpFontSizeSpinBox, 1, 1);
2674 mpFontGroupBox->setLayout(pFontGroupBoxLayout);
2675 // set the layout
2676 QVBoxLayout *pMainLayout = new QVBoxLayout;
2677 pMainLayout->setContentsMargins(0, 0, 0, 0);
2678 pMainLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
2679 pMainLayout->addWidget(mpFormatGroupBox);
2680 pMainLayout->addWidget(mpTabsAndIndentation);
2681 pMainLayout->addWidget(mpSyntaxHighlightAndTextWrappingGroupBox);
2682 pMainLayout->addWidget(mpAutoCompleteGroupBox);
2683 pMainLayout->addWidget(mpFontGroupBox);
2684 setLayout(pMainLayout);
2685}
2686
2687/*!
2688 * \class ModelicaEditorPage
2689 * \brief Creates an interface for Modelica Text settings.
2690 */
2691/*!
2692 * \brief ModelicaEditorPage::ModelicaEditorPage
2693 * \param pOptionsDialog is the pointer to OptionsDialog
2694 */
2695ModelicaEditorPage::ModelicaEditorPage(OptionsDialog *pOptionsDialog)
2696 : QWidget(pOptionsDialog)
2697{
2698 mpOptionsDialog = pOptionsDialog;
2699 // preserve text indentation
2700 mpPreserveTextIndentationCheckBox = new QCheckBox(tr("Preserve Text Indentation"));
2701 mpPreserveTextIndentationCheckBox->setChecked(true);
2702 // code colors widget
2703 mpCodeColorsWidget = new CodeColorsWidget(this);
2704 connect(mpCodeColorsWidget, SIGNAL(colorUpdated())"2""colorUpdated()", SIGNAL(updatePreview())"2""updatePreview()");
2705 // Add items to list
2706 // number (purple)
2707 new ListWidgetItem("Number", QColor(139, 0, 139), mpCodeColorsWidget->getItemsListWidget());
2708 // keyword (dark red)
2709 new ListWidgetItem("Keyword", QColor(139, 0, 0), mpCodeColorsWidget->getItemsListWidget());
2710 // type (red)
2711 new ListWidgetItem("Type", QColor(255, 10, 10), mpCodeColorsWidget->getItemsListWidget());
2712 // function (blue)
2713 new ListWidgetItem("Function", QColor(0, 0, 255), mpCodeColorsWidget->getItemsListWidget());
2714 // Quotes (dark green)
2715 new ListWidgetItem("Quotes", QColor(0, 139, 0), mpCodeColorsWidget->getItemsListWidget());
2716 // comment (dark green)
2717 new ListWidgetItem("Comment", QColor(0, 150, 0), mpCodeColorsWidget->getItemsListWidget());
2718 // preview text
2719 QString previewText;
2720 previewText.append("class HelloWorld /* block\n"
2721 "comment */\n"
2722 "\tReal x(start = 1); // Line comment\n"
2723 "\tparameter Real a = 1.573;\n"
2724 "\tString str = \"a\\\"bc\n"
2725 "123\";\n"
2726 "equation\n"
2727 "\tder(x) = - a * x;\n"
2728 "end HelloWorld;\n");
2729 mpCodeColorsWidget->getPreviewPlainTextEdit()->setPlainText(previewText);
2730 // highlight preview textbox
2731 ModelicaHighlighter *pModelicaTextHighlighter = new ModelicaHighlighter(this, mpCodeColorsWidget->getPreviewPlainTextEdit());
2732 connect(this, SIGNAL(updatePreview())"2""updatePreview()", pModelicaTextHighlighter, SLOT(settingsChanged())"1""settingsChanged()");
2733 connect(mpOptionsDialog->getTextEditorPage()->getSyntaxHighlightingGroupBox(), SIGNAL(toggled(bool))"2""toggled(bool)",
2734 pModelicaTextHighlighter, SLOT(settingsChanged())"1""settingsChanged()");
2735 connect(mpOptionsDialog->getTextEditorPage()->getMatchParenthesesCommentsQuotesCheckBox(), SIGNAL(toggled(bool))"2""toggled(bool)",
2736 pModelicaTextHighlighter, SLOT(settingsChanged())"1""settingsChanged()");
2737 connect(mpOptionsDialog->getTextEditorPage()->getLineWrappingCheckbox(), SIGNAL(toggled(bool))"2""toggled(bool)", this, SLOT(setLineWrapping(bool))"1""setLineWrapping(bool)");
2738 // set the layout
2739 QVBoxLayout *pMainLayout = new QVBoxLayout;
2740 pMainLayout->setContentsMargins(0, 0, 0, 0);
2741 pMainLayout->addWidget(mpPreserveTextIndentationCheckBox);
2742 pMainLayout->addWidget(mpCodeColorsWidget);
2743 setLayout(pMainLayout);
2744}
2745
2746/*!
2747 * \brief ModelicaEditorPage::setColor
2748 * Sets the color of an item.
2749 * \param item
2750 * \param color
2751 */
2752void ModelicaEditorPage::setColor(QString item, QColor color)
2753{
2754 QList<QListWidgetItem*> items = mpCodeColorsWidget->getItemsListWidget()->findItems(item, Qt::MatchExactly);
2755 if (items.size() > 0) {
2756 ListWidgetItem *pListWidgetItem = dynamic_cast<ListWidgetItem*>(items.at(0));
2757 if (pListWidgetItem) {
2758 pListWidgetItem->setColor(color);
2759 pListWidgetItem->setForeground(color);
2760 }
2761 }
2762}
2763
2764/*!
2765 * \brief ModelicaEditorPage::getColor
2766 * Returns the color of an item.
2767 * \param item
2768 * \return
2769 */
2770QColor ModelicaEditorPage::getColor(QString item)
2771{
2772 QList<QListWidgetItem*> items = mpCodeColorsWidget->getItemsListWidget()->findItems(item, Qt::MatchExactly);
2773 if (items.size() > 0) {
2774 ListWidgetItem *pListWidgetItem = dynamic_cast<ListWidgetItem*>(items.at(0));
2775 if (pListWidgetItem) {
2776 return pListWidgetItem->getColor();
2777 }
2778 }
2779 return QColor(0, 0, 0);
2780}
2781
2782/*!
2783 * \brief ModelicaEditorPage::setLineWrapping
2784 * Slot activated when mpLineWrappingCheckbox toggled SIGNAL is raised.
2785 * Sets the mpPreviewPlainTextBox line wrapping mode.
2786 */
2787void ModelicaEditorPage::setLineWrapping(bool enabled)
2788{
2789 if (enabled) {
2790 mpCodeColorsWidget->getPreviewPlainTextEdit()->setLineWrapMode(QPlainTextEdit::WidgetWidth);
2791 } else {
2792 mpCodeColorsWidget->getPreviewPlainTextEdit()->setLineWrapMode(QPlainTextEdit::NoWrap);
2793 }
2794}
2795
2796/*!
2797 * \class MetaModelicaEditorPage
2798 * \brief Creates an interface for MetaModelica Text settings.
2799 */
2800/*!
2801 * \brief MetaModelicaEditorPage::MetaModelicaEditorPage
2802 * \param pOptionsDialog is the pointer to OptionsDialog
2803 */
2804MetaModelicaEditorPage::MetaModelicaEditorPage(OptionsDialog *pOptionsDialog)
2805 : QWidget(pOptionsDialog)
2806{
2807 mpOptionsDialog = pOptionsDialog;
2808 // code colors widget
2809 mpCodeColorsWidget = new CodeColorsWidget(this);
2810 connect(mpCodeColorsWidget, SIGNAL(colorUpdated())"2""colorUpdated()", SIGNAL(updatePreview())"2""updatePreview()");
2811 // Add items to list
2812 // number (purple)
2813 new ListWidgetItem("Number", QColor(139, 0, 139), mpCodeColorsWidget->getItemsListWidget());
2814 // keyword (dark red)
2815 new ListWidgetItem("Keyword", QColor(139, 0, 0), mpCodeColorsWidget->getItemsListWidget());
2816 // type (red)
2817 new ListWidgetItem("Type", QColor(255, 10, 10), mpCodeColorsWidget->getItemsListWidget());
2818 // Quotes (dark green)
2819 new ListWidgetItem("Quotes", QColor(0, 139, 0), mpCodeColorsWidget->getItemsListWidget());
2820 // comment (dark green)
2821 new ListWidgetItem("Comment", QColor(0, 150, 0), mpCodeColorsWidget->getItemsListWidget());
2822 // preview text
2823 QString previewText;
2824 previewText.append("function HelloWorld /* block\n"
2825 "comment */\n"
2826 "\tinput Integer request; // Line comment\n"
2827 "\toutput String str;\n"
2828 "algorithm\n"
2829 "\tstr := match (request)\n"
2830 "\t\tcase (1) then \"Hi\";\n"
2831 "\t\tcase (2) then \"Hey\";\n"
2832 "\t\tcase (3) then \"Hello\";\n"
2833 "\tend match;\n"
2834 "end HelloWorld;\n");
2835 mpCodeColorsWidget->getPreviewPlainTextEdit()->setPlainText(previewText);
2836 // highlight preview textbox
2837 MetaModelicaHighlighter *pMetaModelicaHighlighter = new MetaModelicaHighlighter(this, mpCodeColorsWidget->getPreviewPlainTextEdit());
2838 connect(this, SIGNAL(updatePreview())"2""updatePreview()", pMetaModelicaHighlighter, SLOT(settingsChanged())"1""settingsChanged()");
2839 connect(mpOptionsDialog->getTextEditorPage()->getSyntaxHighlightingGroupBox(), SIGNAL(toggled(bool))"2""toggled(bool)",
2840 pMetaModelicaHighlighter, SLOT(settingsChanged())"1""settingsChanged()");
2841 connect(mpOptionsDialog->getTextEditorPage()->getMatchParenthesesCommentsQuotesCheckBox(), SIGNAL(toggled(bool))"2""toggled(bool)",
2842 pMetaModelicaHighlighter, SLOT(settingsChanged())"1""settingsChanged()");
2843 connect(mpOptionsDialog->getTextEditorPage()->getLineWrappingCheckbox(), SIGNAL(toggled(bool))"2""toggled(bool)", this, SLOT(setLineWrapping(bool))"1""setLineWrapping(bool)");
2844 // set the layout
2845 QVBoxLayout *pMainLayout = new QVBoxLayout;
2846 pMainLayout->setContentsMargins(0, 0, 0, 0);
2847 pMainLayout->addWidget(mpCodeColorsWidget);
2848 setLayout(pMainLayout);
2849}
2850
2851/*!
2852 * \brief MetaModelicaEditorPage::setColor
2853 * Sets the color of an item.
2854 * \param item
2855 * \param color
2856 */
2857void MetaModelicaEditorPage::setColor(QString item, QColor color)
2858{
2859 QList<QListWidgetItem*> items = mpCodeColorsWidget->getItemsListWidget()->findItems(item, Qt::MatchExactly);
2860 if (items.size() > 0) {
2861 ListWidgetItem *pListWidgetItem = dynamic_cast<ListWidgetItem*>(items.at(0));
2862 if (pListWidgetItem) {
2863 pListWidgetItem->setColor(color);
2864 pListWidgetItem->setForeground(color);
2865 }
2866 }
2867}
2868
2869/*!
2870 * \brief MetaModelicaEditorPage::getColor
2871 * Returns the color of an item.
2872 * \param item
2873 * \return
2874 */
2875QColor MetaModelicaEditorPage::getColor(QString item)
2876{
2877 QList<QListWidgetItem*> items = mpCodeColorsWidget->getItemsListWidget()->findItems(item, Qt::MatchExactly);
2878 if (items.size() > 0) {
2879 ListWidgetItem *pListWidgetItem = dynamic_cast<ListWidgetItem*>(items.at(0));
2880 if (pListWidgetItem) {
2881 return pListWidgetItem->getColor();
2882 }
2883 }
2884 return QColor(0, 0, 0);
2885}
2886
2887/*!
2888 * \brief MetaModelicaEditorPage::setLineWrapping
2889 * Slot activated when mpLineWrappingCheckbox toggled SIGNAL is raised.
2890 * Sets the mpPreviewPlainTextBox line wrapping mode.
2891 */
2892void MetaModelicaEditorPage::setLineWrapping(bool enabled)
2893{
2894 if (enabled) {
2895 mpCodeColorsWidget->getPreviewPlainTextEdit()->setLineWrapMode(QPlainTextEdit::WidgetWidth);
2896 } else {
2897 mpCodeColorsWidget->getPreviewPlainTextEdit()->setLineWrapMode(QPlainTextEdit::NoWrap);
2898 }
2899}
2900
2901/*!
2902 * \class CompositeModelEditorPage
2903 * \brief Creates an interface for CompositeModel Text settings.
2904 */
2905/*!
2906 * \brief CompositeModelEditorPage::CompositeModelEditorPage
2907 * \param pOptionsDialog is the pointer to OptionsDialog
2908 */
2909CompositeModelEditorPage::CompositeModelEditorPage(OptionsDialog *pOptionsDialog)
2910 : QWidget(pOptionsDialog)
2911{
2912 mpOptionsDialog = pOptionsDialog;
2913 // code colors widget
2914 mpCodeColorsWidget = new CodeColorsWidget(this);
2915 connect(mpCodeColorsWidget, SIGNAL(colorUpdated())"2""colorUpdated()", SIGNAL(updatePreview())"2""updatePreview()");
2916 // Add items to list
2917 // tag (blue)
2918 new ListWidgetItem("Tag", QColor(0, 0, 255), mpCodeColorsWidget->getItemsListWidget());
2919 // element (blue)
2920 new ListWidgetItem("Element", QColor(0, 0, 255), mpCodeColorsWidget->getItemsListWidget());
2921 // quotes (dark red)
2922 new ListWidgetItem("Quotes", QColor(139, 0, 0), mpCodeColorsWidget->getItemsListWidget());
2923 // comment (dark green)
2924 new ListWidgetItem("Comment", QColor(0, 150, 0), mpCodeColorsWidget->getItemsListWidget());
2925 // preview textbox
2926 QString previewText;
2927 previewText.append("<!-- This is a comment. -->\n"
2928 "<Model Name=\"model\">\n"
2929 "\t<SubModels>\n"
2930 "\t\t<SubModel Name=\"submodel\">\n"
2931 "\t\t</SubModel>\n"
2932 "\t</SubModels>\n"
2933 "\t<Connections>\n"
2934 "\t\t<Connection From=\"from\" To=\"to\">\n"
2935 "\t</Connections>\n"
2936 "</Model>\n");
2937 mpCodeColorsWidget->getPreviewPlainTextEdit()->setPlainText(previewText);
2938 // highlight preview textbox
2939 CompositeModelHighlighter *pCompositeModelHighlighter = new CompositeModelHighlighter(this, mpCodeColorsWidget->getPreviewPlainTextEdit());
1
Memory is allocated
2940 connect(this, SIGNAL(updatePreview())"2""updatePreview()", pCompositeModelHighlighter, SLOT(settingsChanged())"1""settingsChanged()");
2941 connect(mpOptionsDialog->getTextEditorPage()->getSyntaxHighlightingGroupBox(), SIGNAL(toggled(bool))"2""toggled(bool)",
2942 pCompositeModelHighlighter, SLOT(settingsChanged())"1""settingsChanged()");
2943 connect(mpOptionsDialog->getTextEditorPage()->getMatchParenthesesCommentsQuotesCheckBox(), SIGNAL(toggled(bool))"2""toggled(bool)",
2944 pCompositeModelHighlighter, SLOT(settingsChanged())"1""settingsChanged()");
2945 connect(mpOptionsDialog->getTextEditorPage()->getLineWrappingCheckbox(), SIGNAL(toggled(bool))"2""toggled(bool)", this, SLOT(setLineWrapping(bool))"1""setLineWrapping(bool)");
2
Potential leak of memory pointed to by 'pCompositeModelHighlighter'
2946 // set the layout
2947 QVBoxLayout *pMainLayout = new QVBoxLayout;
2948 pMainLayout->setContentsMargins(0, 0, 0, 0);
2949 pMainLayout->addWidget(mpCodeColorsWidget);
2950 setLayout(pMainLayout);
2951}
2952
2953/*!
2954 * \brief CompositeModelEditorPage::setColor
2955 * Sets the color of an item.
2956 * \param item
2957 * \param color
2958 */
2959void CompositeModelEditorPage::setColor(QString item, QColor color)
2960{
2961 QList<QListWidgetItem*> items = mpCodeColorsWidget->getItemsListWidget()->findItems(item, Qt::MatchExactly);
2962 if (items.size() > 0) {
2963 ListWidgetItem *pListWidgetItem = dynamic_cast<ListWidgetItem*>(items.at(0));
2964 if (pListWidgetItem) {
2965 pListWidgetItem->setColor(color);
2966 pListWidgetItem->setForeground(color);
2967 }
2968 }
2969}
2970
2971/*!
2972 * \brief CompositeModelEditorPage::getColor
2973 * Returns the color of an item.
2974 * \param item
2975 * \return
2976 */
2977QColor CompositeModelEditorPage::getColor(QString item)
2978{
2979 QList<QListWidgetItem*> items = mpCodeColorsWidget->getItemsListWidget()->findItems(item, Qt::MatchExactly);
2980 if (items.size() > 0) {
2981 ListWidgetItem *pListWidgetItem = dynamic_cast<ListWidgetItem*>(items.at(0));
2982 if (pListWidgetItem) {
2983 return pListWidgetItem->getColor();
2984 }
2985 }
2986 return QColor(0, 0, 0);
2987}
2988
2989/*!
2990 * \brief CompositeModelEditorPage::setLineWrapping
2991 * Slot activated when mpLineWrappingCheckbox toggled SIGNAL is raised.
2992 * Sets the mpPreviewPlainTextBox line wrapping mode.
2993 */
2994void CompositeModelEditorPage::setLineWrapping(bool enabled)
2995{
2996 if (enabled) {
2997 mpCodeColorsWidget->getPreviewPlainTextEdit()->setLineWrapMode(QPlainTextEdit::WidgetWidth);
2998 } else {
2999 mpCodeColorsWidget->getPreviewPlainTextEdit()->setLineWrapMode(QPlainTextEdit::NoWrap);
3000 }
3001}
3002
3003/*!
3004 * \class OMSimulatorEditorPage
3005 * \brief Creates an interface for OMS CompositeModel Text settings.
3006 */
3007/*!
3008 * \brief OMSimulatorEditorPage::OMSimulatorEditorPage
3009 * \param pOptionsDialog is the pointer to OptionsDialog
3010 */
3011OMSimulatorEditorPage::OMSimulatorEditorPage(OptionsDialog *pOptionsDialog)
3012 : QWidget(pOptionsDialog)
3013{
3014 mpOptionsDialog = pOptionsDialog;
3015 // code colors widget
3016 mpCodeColorsWidget = new CodeColorsWidget(this);
3017 connect(mpCodeColorsWidget, SIGNAL(colorUpdated())"2""colorUpdated()", SIGNAL(updatePreview())"2""updatePreview()");
3018 // Add items to list
3019 // tag (blue)
3020 new ListWidgetItem("Tag", QColor(0, 0, 255), mpCodeColorsWidget->getItemsListWidget());
3021 // element (blue)
3022 new ListWidgetItem("Element", QColor(0, 0, 255), mpCodeColorsWidget->getItemsListWidget());
3023 // quotes (dark red)
3024 new ListWidgetItem("Quotes", QColor(139, 0, 0), mpCodeColorsWidget->getItemsListWidget());
3025 // comment (dark green)
3026 new ListWidgetItem("Comment", QColor(0, 150, 0), mpCodeColorsWidget->getItemsListWidget());
3027 // preview textbox
3028 QString previewText;
3029 previewText.append("<!-- This is a comment. -->\n"
3030 "<ssd:SystemStructureDescription name=\"model\">"
3031 "\t<ssd:System name=\"model\">\n"
3032 "\t\t<ssd:Component name=\"adder1\" type=\"application/x-fmu-sharedlibrary\" source=\"FMUs/adder.fmu\">\n"
3033 "\t\t\t<ssd:ElementGeometry x1=\"40\" y1=\"20\" x2=\"60\" y2=\"40\" rotation=\"0\" iconRotation=\"0\" iconFlip=\"false\" iconFixedAspectRatio=\"false\" />\n"
3034 "\t\t\t<ssd:Connectors />\n"
3035 "\t\t</ssd:Component>\n"
3036 "\t\t<ssd:Connections />\n"
3037 "\t</ssd:System>\n"
3038 "\t<ssd:DefaultExperiment startTime=\"0\" stopTime=\"5\" />\n"
3039 "</ssd:SystemStructureDescription>");
3040 mpCodeColorsWidget->getPreviewPlainTextEdit()->setPlainText(previewText);
3041 // highlight preview textbox
3042 OMSimulatorHighlighter *pOMSimulatorHighlighter = new OMSimulatorHighlighter(this, mpCodeColorsWidget->getPreviewPlainTextEdit());
3043 connect(this, SIGNAL(updatePreview())"2""updatePreview()", pOMSimulatorHighlighter, SLOT(settingsChanged())"1""settingsChanged()");
3044 connect(mpOptionsDialog->getTextEditorPage()->getSyntaxHighlightingGroupBox(), SIGNAL(toggled(bool))"2""toggled(bool)",
3045 pOMSimulatorHighlighter, SLOT(settingsChanged())"1""settingsChanged()");
3046 connect(mpOptionsDialog->getTextEditorPage()->getMatchParenthesesCommentsQuotesCheckBox(), SIGNAL(toggled(bool))"2""toggled(bool)",
3047 pOMSimulatorHighlighter, SLOT(settingsChanged())"1""settingsChanged()");
3048 connect(mpOptionsDialog->getTextEditorPage()->getLineWrappingCheckbox(), SIGNAL(toggled(bool))"2""toggled(bool)", this, SLOT(setLineWrapping(bool))"1""setLineWrapping(bool)");
3049 // set the layout
3050 QVBoxLayout *pMainLayout = new QVBoxLayout;
3051 pMainLayout->setContentsMargins(0, 0, 0, 0);
3052 pMainLayout->addWidget(mpCodeColorsWidget);
3053 setLayout(pMainLayout);
3054}
3055
3056/*!
3057 * \brief OMSimulatorEditorPage::setColor
3058 * Sets the color of an item.
3059 * \param item
3060 * \param color
3061 */
3062void OMSimulatorEditorPage::setColor(QString item, QColor color)
3063{
3064 QList<QListWidgetItem*> items = mpCodeColorsWidget->getItemsListWidget()->findItems(item, Qt::MatchExactly);
3065 if (items.size() > 0) {
3066 ListWidgetItem *pListWidgetItem = dynamic_cast<ListWidgetItem*>(items.at(0));
3067 if (pListWidgetItem) {
3068 pListWidgetItem->setColor(color);
3069 pListWidgetItem->setForeground(color);
3070 }
3071 }
3072}
3073
3074/*!
3075 * \brief OMSimulatorEditorPage::getColor
3076 * Returns the color of an item.
3077 * \param item
3078 * \return
3079 */
3080QColor OMSimulatorEditorPage::getColor(QString item)
3081{
3082 QList<QListWidgetItem*> items = mpCodeColorsWidget->getItemsListWidget()->findItems(item, Qt::MatchExactly);
3083 if (items.size() > 0) {
3084 ListWidgetItem *pListWidgetItem = dynamic_cast<ListWidgetItem*>(items.at(0));
3085 if (pListWidgetItem) {
3086 return pListWidgetItem->getColor();
3087 }
3088 }
3089 return QColor(0, 0, 0);
3090}
3091
3092/*!
3093 * \brief OMSimulatorEditorPage::setLineWrapping
3094 * Slot activated when mpLineWrappingCheckbox toggled SIGNAL is raised.
3095 * Sets the mpPreviewPlainTextBox line wrapping mode.
3096 */
3097void OMSimulatorEditorPage::setLineWrapping(bool enabled)
3098{
3099 if (enabled) {
3100 mpCodeColorsWidget->getPreviewPlainTextEdit()->setLineWrapMode(QPlainTextEdit::WidgetWidth);
3101 } else {
3102 mpCodeColorsWidget->getPreviewPlainTextEdit()->setLineWrapMode(QPlainTextEdit::NoWrap);
3103 }
3104}
3105
3106/*!
3107 * \class CEditorPage
3108 * \brief Creates an interface for C Text settings.
3109 */
3110/*!
3111 * \brief CEditorPage::CEditorPage
3112 * \param pOptionsDialog is the pointer to OptionsDialog
3113 */
3114CEditorPage::CEditorPage(OptionsDialog *pOptionsDialog)
3115 : QWidget(pOptionsDialog)
3116{
3117 mpOptionsDialog = pOptionsDialog;
3118 // code colors widget
3119 mpCodeColorsWidget = new CodeColorsWidget(this);
3120 connect(mpCodeColorsWidget, SIGNAL(colorUpdated())"2""colorUpdated()", SIGNAL(updatePreview())"2""updatePreview()");
3121 // Add items to list
3122 // number (purple)
3123 new ListWidgetItem("Number", QColor(139, 0, 139), mpCodeColorsWidget->getItemsListWidget());
3124 // keyword (dark red)
3125 new ListWidgetItem("Keyword", QColor(139, 0, 0), mpCodeColorsWidget->getItemsListWidget());
3126 // type (red)
3127 new ListWidgetItem("Type", QColor(255, 10, 10), mpCodeColorsWidget->getItemsListWidget());
3128 // Quotes (dark green)
3129 new ListWidgetItem("Quotes", QColor(0, 139, 0), mpCodeColorsWidget->getItemsListWidget());
3130 // comment (dark green)
3131 new ListWidgetItem("Comment", QColor(0, 150, 0), mpCodeColorsWidget->getItemsListWidget());
3132 // preview text
3133 QString previewText;
3134 previewText.append("#include <stdio.h>\n"
3135 "int main() { /* block\n"
3136 "comment */\n"
3137 "\tprintf(\"Hello World\"); // Line comment\n"
3138 "return 0;\n"
3139 "}\n");
3140 mpCodeColorsWidget->getPreviewPlainTextEdit()->setPlainText(previewText);
3141 // highlight preview textbox
3142 CHighlighter *pCHighlighter = new CHighlighter(this, mpCodeColorsWidget->getPreviewPlainTextEdit());
3143 connect(this, SIGNAL(updatePreview())"2""updatePreview()", pCHighlighter, SLOT(settingsChanged())"1""settingsChanged()");
3144 connect(mpOptionsDialog->getTextEditorPage()->getSyntaxHighlightingGroupBox(), SIGNAL(toggled(bool))"2""toggled(bool)",
3145 pCHighlighter, SLOT(settingsChanged())"1""settingsChanged()");
3146 connect(mpOptionsDialog->getTextEditorPage()->getMatchParenthesesCommentsQuotesCheckBox(), SIGNAL(toggled(bool))"2""toggled(bool)",
3147 pCHighlighter, SLOT(settingsChanged())"1""settingsChanged()");
3148 connect(mpOptionsDialog->getTextEditorPage()->getLineWrappingCheckbox(), SIGNAL(toggled(bool))"2""toggled(bool)", this, SLOT(setLineWrapping(bool))"1""setLineWrapping(bool)");
3149 // set the layout
3150 QVBoxLayout *pMainLayout = new QVBoxLayout;
3151 pMainLayout->setContentsMargins(0, 0, 0, 0);
3152 pMainLayout->addWidget(mpCodeColorsWidget);
3153 setLayout(pMainLayout);
3154}
3155
3156/*!
3157 * \brief CEditorPage::setColor
3158 * Sets the color of an item.
3159 * \param item
3160 * \param color
3161 */
3162void CEditorPage::setColor(QString item, QColor color)
3163{
3164 QList<QListWidgetItem*> items = mpCodeColorsWidget->getItemsListWidget()->findItems(item, Qt::MatchExactly);
3165 if (items.size() > 0) {
3166 ListWidgetItem *pListWidgetItem = dynamic_cast<ListWidgetItem*>(items.at(0));
3167 if (pListWidgetItem) {
3168 pListWidgetItem->setColor(color);
3169 pListWidgetItem->setForeground(color);
3170 }
3171 }
3172}
3173
3174/*!
3175 * \brief CEditorPage::getColor
3176 * Returns the color of an item.
3177 * \param item
3178 * \return
3179 */
3180QColor CEditorPage::getColor(QString item)
3181{
3182 QList<QListWidgetItem*> items = mpCodeColorsWidget->getItemsListWidget()->findItems(item, Qt::MatchExactly);
3183 if (items.size() > 0) {
3184 ListWidgetItem *pListWidgetItem = dynamic_cast<ListWidgetItem*>(items.at(0));
3185 if (pListWidgetItem) {
3186 return pListWidgetItem->getColor();
3187 }
3188 }
3189 return QColor(0, 0, 0);
3190}
3191
3192/*!
3193 * \brief CEditorPage::setLineWrapping
3194 * Slot activated when mpLineWrappingCheckbox toggled SIGNAL is raised.
3195 * Sets the mpPreviewPlainTextBox line wrapping mode.
3196 */
3197void CEditorPage::setLineWrapping(bool enabled)
3198{
3199 if (enabled) {
3200 mpCodeColorsWidget->getPreviewPlainTextEdit()->setLineWrapMode(QPlainTextEdit::WidgetWidth);
3201 } else {
3202 mpCodeColorsWidget->getPreviewPlainTextEdit()->setLineWrapMode(QPlainTextEdit::NoWrap);
3203 }
3204}
3205
3206/*!
3207 * \class HTMLEditorPage
3208 * \brief Creates an interface for HTML Text settings.
3209 */
3210/*!
3211 * \brief HTMLEditorPage::HTMLEditorPage
3212 * \param pOptionsDialog is the pointer to OptionsDialog
3213 */
3214HTMLEditorPage::HTMLEditorPage(OptionsDialog *pOptionsDialog)
3215 : QWidget(pOptionsDialog)
3216{
3217 mpOptionsDialog = pOptionsDialog;
3218 // code colors widget
3219 mpCodeColorsWidget = new CodeColorsWidget(this);
3220 connect(mpCodeColorsWidget, SIGNAL(colorUpdated())"2""colorUpdated()", SIGNAL(updatePreview())"2""updatePreview()");
3221 // Add items to list
3222 // tag (blue)
3223 new ListWidgetItem("Tag", QColor(0, 0, 255), mpCodeColorsWidget->getItemsListWidget());
3224 // quotes (dark red)
3225 new ListWidgetItem("Quotes", QColor(139, 0, 0), mpCodeColorsWidget->getItemsListWidget());
3226 // comment (dark green)
3227 new ListWidgetItem("Comment", QColor(0, 150, 0), mpCodeColorsWidget->getItemsListWidget());
3228 // preview textbox
3229 QString previewText;
3230 previewText.append("<!-- This is a comment. -->\n"
3231 "<html>\n"
3232 "\t<body>\n"
3233 "\t\t<h1>OPENMODELICA</h1>\n"
3234 "\t\t<p>OpenModelica is an open-source Modelica-based modeling and simulation environment"
3235 " intended for industrial and academic usage. Its long-term development is supported by a"
3236 " non-profit organization – the <a href=\"http://www.openmodelica.org\">Open Source Modelica Consortium (OSMC)</a></p>\n"
3237 "\t</body>\n"
3238 "</html>\n");
3239 mpCodeColorsWidget->getPreviewPlainTextEdit()->setPlainText(previewText);
3240 // highlight preview textbox
3241 HTMLHighlighter *pHTMLHighlighter = new HTMLHighlighter(this, mpCodeColorsWidget->getPreviewPlainTextEdit());
3242 connect(this, SIGNAL(updatePreview())"2""updatePreview()", pHTMLHighlighter, SLOT(settingsChanged())"1""settingsChanged()");
3243 connect(mpOptionsDialog->getTextEditorPage()->getSyntaxHighlightingGroupBox(), SIGNAL(toggled(bool))"2""toggled(bool)",
3244 pHTMLHighlighter, SLOT(settingsChanged())"1""settingsChanged()");
3245 connect(mpOptionsDialog->getTextEditorPage()->getMatchParenthesesCommentsQuotesCheckBox(), SIGNAL(toggled(bool))"2""toggled(bool)",
3246 pHTMLHighlighter, SLOT(settingsChanged())"1""settingsChanged()");
3247 connect(mpOptionsDialog->getTextEditorPage()->getLineWrappingCheckbox(), SIGNAL(toggled(bool))"2""toggled(bool)", this, SLOT(setLineWrapping(bool))"1""setLineWrapping(bool)");
3248 // set the layout
3249 QVBoxLayout *pMainLayout = new QVBoxLayout;
3250 pMainLayout->setContentsMargins(0, 0, 0, 0);
3251 pMainLayout->addWidget(mpCodeColorsWidget);
3252 setLayout(pMainLayout);
3253}
3254
3255/*!
3256 * \brief HTMLEditorPage::setColor
3257 * Sets the color of an item.
3258 * \param item
3259 * \param color
3260 */
3261void HTMLEditorPage::setColor(QString item, QColor color)
3262{
3263 QList<QListWidgetItem*> items = mpCodeColorsWidget->getItemsListWidget()->findItems(item, Qt::MatchExactly);
3264 if (items.size() > 0) {
3265 ListWidgetItem *pListWidgetItem = dynamic_cast<ListWidgetItem*>(items.at(0));
3266 if (pListWidgetItem) {
3267 pListWidgetItem->setColor(color);
3268 pListWidgetItem->setForeground(color);
3269 }
3270 }
3271}
3272
3273/*!
3274 * \brief HTMLEditorPage::getColor
3275 * Returns the color of an item.
3276 * \param item
3277 * \return
3278 */
3279QColor HTMLEditorPage::getColor(QString item)
3280{
3281 QList<QListWidgetItem*> items = mpCodeColorsWidget->getItemsListWidget()->findItems(item, Qt::MatchExactly);
3282 if (items.size() > 0) {
3283 ListWidgetItem *pListWidgetItem = dynamic_cast<ListWidgetItem*>(items.at(0));
3284 if (pListWidgetItem) {
3285 return pListWidgetItem->getColor();
3286 }
3287 }
3288 return QColor(0, 0, 0);
3289}
3290
3291/*!
3292 * \brief HTMLEditorPage::setLineWrapping
3293 * Slot activated when mpLineWrappingCheckbox toggled SIGNAL is raised.
3294 * Sets the mpPreviewPlainTextBox line wrapping mode.
3295 */
3296void HTMLEditorPage::setLineWrapping(bool enabled)
3297{
3298 if (enabled) {
3299 mpCodeColorsWidget->getPreviewPlainTextEdit()->setLineWrapMode(QPlainTextEdit::WidgetWidth);
3300 } else {
3301 mpCodeColorsWidget->getPreviewPlainTextEdit()->setLineWrapMode(QPlainTextEdit::NoWrap);
3302 }
3303}
3304
3305GraphicalViewsPage::GraphicalViewsPage(OptionsDialog *pOptionsDialog)
3306 : QWidget(pOptionsDialog)
3307{
3308 mpOptionsDialog = pOptionsDialog;
3309 // graphical view tab widget
3310 mpGraphicalViewsTabWidget = new QTabWidget;
3311 // Icon View Widget
3312 mpIconViewWidget = new QWidget;
3313 // create Icon View extent points group box
3314 mpIconViewExtentGroupBox = new QGroupBox(Helper::extent);
3315 mpIconViewLeftLabel = new Label(QString(Helper::left).append(":"));
3316 mpIconViewLeftSpinBox = new DoubleSpinBox;
3317 mpIconViewLeftSpinBox->setRange(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max());
3318 mpIconViewLeftSpinBox->setValue(-100);
3319 mpIconViewLeftSpinBox->setSingleStep(10);
3320 mpIconViewBottomLabel = new Label(Helper::bottom);
3321 mpIconViewBottomSpinBox = new DoubleSpinBox;
3322 mpIconViewBottomSpinBox->setRange(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max());
3323 mpIconViewBottomSpinBox->setValue(-100);
3324 mpIconViewBottomSpinBox->setSingleStep(10);
3325 mpIconViewRightLabel = new Label(QString(Helper::right).append(":"));
3326 mpIconViewRightSpinBox = new DoubleSpinBox;
3327 mpIconViewRightSpinBox->setRange(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max());
3328 mpIconViewRightSpinBox->setValue(100);
3329 mpIconViewRightSpinBox->setSingleStep(10);
3330 mpIconViewTopLabel = new Label(Helper::top);
3331 mpIconViewTopSpinBox = new DoubleSpinBox;
3332 mpIconViewTopSpinBox->setRange(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max());
3333 mpIconViewTopSpinBox->setValue(100);
3334 mpIconViewTopSpinBox->setSingleStep(10);
3335 // set the Icon View extent group box layout
3336 QGridLayout *pIconViewExtentLayout = new QGridLayout;
3337 pIconViewExtentLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
3338 pIconViewExtentLayout->setColumnStretch(1, 1);
3339 pIconViewExtentLayout->setColumnStretch(3, 1);
3340 pIconViewExtentLayout->addWidget(mpIconViewLeftLabel, 0, 0);
3341 pIconViewExtentLayout->addWidget(mpIconViewLeftSpinBox, 0, 1);
3342 pIconViewExtentLayout->addWidget(mpIconViewBottomLabel, 0, 2);
3343 pIconViewExtentLayout->addWidget(mpIconViewBottomSpinBox, 0, 3);
3344 pIconViewExtentLayout->addWidget(mpIconViewRightLabel, 1, 0);
3345 pIconViewExtentLayout->addWidget(mpIconViewRightSpinBox, 1, 1);
3346 pIconViewExtentLayout->addWidget(mpIconViewTopLabel, 1, 2);
3347 pIconViewExtentLayout->addWidget(mpIconViewTopSpinBox, 1, 3);
3348 mpIconViewExtentGroupBox->setLayout(pIconViewExtentLayout);
3349 // create the Icon View grid group box
3350 mpIconViewGridGroupBox = new QGroupBox(Helper::grid);
3351 mpIconViewGridHorizontalLabel = new Label(QString(Helper::horizontal).append(":"));
3352 mpIconViewGridHorizontalSpinBox = new DoubleSpinBox;
3353 mpIconViewGridHorizontalSpinBox->setRange(0, std::numeric_limits<double>::max());
3354 mpIconViewGridHorizontalSpinBox->setValue(2);
3355 mpIconViewGridHorizontalSpinBox->setSingleStep(1);
3356 mpIconViewGridVerticalLabel = new Label(QString(Helper::vertical).append(":"));
3357 mpIconViewGridVerticalSpinBox = new DoubleSpinBox;
3358 mpIconViewGridVerticalSpinBox->setRange(0, std::numeric_limits<double>::max());
3359 mpIconViewGridVerticalSpinBox->setValue(2);
3360 mpIconViewGridVerticalSpinBox->setSingleStep(1);
3361 // set the Icon View grid group box layout
3362 QGridLayout *pIconViewGridLayout = new QGridLayout;
3363 pIconViewGridLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
3364 pIconViewGridLayout->setColumnStretch(1, 1);
3365 pIconViewGridLayout->addWidget(mpIconViewGridHorizontalLabel, 0, 0);
3366 pIconViewGridLayout->addWidget(mpIconViewGridHorizontalSpinBox, 0, 1);
3367 pIconViewGridLayout->addWidget(mpIconViewGridVerticalLabel, 1, 0);
3368 pIconViewGridLayout->addWidget(mpIconViewGridVerticalSpinBox, 1, 1);
3369 mpIconViewGridGroupBox->setLayout(pIconViewGridLayout);
3370 // create the Icon View Component group box
3371 mpIconViewComponentGroupBox = new QGroupBox(Helper::component);
3372 mpIconViewScaleFactorLabel = new Label(Helper::scaleFactor);
3373 mpIconViewScaleFactorSpinBox = new DoubleSpinBox;
3374 mpIconViewScaleFactorSpinBox->setRange(0, std::numeric_limits<double>::max());
3375 mpIconViewScaleFactorSpinBox->setValue(0.1);
3376 mpIconViewScaleFactorSpinBox->setSingleStep(0.1);
3377 mpIconViewPreserveAspectRatioCheckBox = new QCheckBox(Helper::preserveAspectRatio);
3378 mpIconViewPreserveAspectRatioCheckBox->setChecked(true);
3379 // set the Icon View component group box layout
3380 QGridLayout *pIconViewComponentLayout = new QGridLayout;
3381 pIconViewComponentLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
3382 pIconViewComponentLayout->setColumnStretch(1, 1);
3383 pIconViewComponentLayout->addWidget(mpIconViewScaleFactorLabel, 0, 0);
3384 pIconViewComponentLayout->addWidget(mpIconViewScaleFactorSpinBox, 0, 1);
3385 pIconViewComponentLayout->addWidget(mpIconViewPreserveAspectRatioCheckBox, 1, 0, 1, 2);
3386 mpIconViewComponentGroupBox->setLayout(pIconViewComponentLayout);
3387 // Icon View Widget Layout
3388 QVBoxLayout *pIconViewMainLayout = new QVBoxLayout;
3389 pIconViewMainLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
3390 pIconViewMainLayout->addWidget(mpIconViewExtentGroupBox);
3391 pIconViewMainLayout->addWidget(mpIconViewGridGroupBox);
3392 pIconViewMainLayout->addWidget(mpIconViewComponentGroupBox);
3393 mpIconViewWidget->setLayout(pIconViewMainLayout);
3394 // add Icon View Widget as a tab
3395 mpGraphicalViewsTabWidget->addTab(mpIconViewWidget, tr("Icon View"));
3396 // Digram View Widget
3397 mpDiagramViewWidget = new QWidget;
3398 // create Diagram View extent points group box
3399 mpDiagramViewExtentGroupBox = new QGroupBox(Helper::extent);
3400 mpDiagramViewLeftLabel = new Label(QString(Helper::left).append(":"));
3401 mpDiagramViewLeftSpinBox = new DoubleSpinBox;
3402 mpDiagramViewLeftSpinBox->setRange(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max());
3403 mpDiagramViewLeftSpinBox->setValue(-100);
3404 mpDiagramViewLeftSpinBox->setSingleStep(10);
3405 mpDiagramViewBottomLabel = new Label(Helper::bottom);
3406 mpDiagramViewBottomSpinBox = new DoubleSpinBox;
3407 mpDiagramViewBottomSpinBox->setRange(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max());
3408 mpDiagramViewBottomSpinBox->setValue(-100);
3409 mpDiagramViewBottomSpinBox->setSingleStep(10);
3410 mpDiagramViewRightLabel = new Label(QString(Helper::right).append(":"));
3411 mpDiagramViewRightSpinBox = new DoubleSpinBox;
3412 mpDiagramViewRightSpinBox->setRange(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max());
3413 mpDiagramViewRightSpinBox->setValue(100);
3414 mpDiagramViewRightSpinBox->setSingleStep(10);
3415 mpDiagramViewTopLabel = new Label(Helper::top);
3416 mpDiagramViewTopSpinBox = new DoubleSpinBox;
3417 mpDiagramViewTopSpinBox->setRange(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max());
3418 mpDiagramViewTopSpinBox->setValue(100);
3419 mpDiagramViewTopSpinBox->setSingleStep(10);
3420 // set the Diagram View extent group box layout
3421 QGridLayout *pDiagramViewExtentLayout = new QGridLayout;
3422 pDiagramViewExtentLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
3423 pDiagramViewExtentLayout->setColumnStretch(1, 1);
3424 pDiagramViewExtentLayout->setColumnStretch(3, 1);
3425 pDiagramViewExtentLayout->addWidget(mpDiagramViewLeftLabel, 0, 0);
3426 pDiagramViewExtentLayout->addWidget(mpDiagramViewLeftSpinBox, 0, 1);
3427 pDiagramViewExtentLayout->addWidget(mpDiagramViewBottomLabel, 0, 2);
3428 pDiagramViewExtentLayout->addWidget(mpDiagramViewBottomSpinBox, 0, 3);
3429 pDiagramViewExtentLayout->addWidget(mpDiagramViewRightLabel, 1, 0);
3430 pDiagramViewExtentLayout->addWidget(mpDiagramViewRightSpinBox, 1, 1);
3431 pDiagramViewExtentLayout->addWidget(mpDiagramViewTopLabel, 1, 2);
3432 pDiagramViewExtentLayout->addWidget(mpDiagramViewTopSpinBox, 1, 3);
3433 mpDiagramViewExtentGroupBox->setLayout(pDiagramViewExtentLayout);
3434 // create the Diagram View grid group box
3435 mpDiagramViewGridGroupBox = new QGroupBox(Helper::grid);
3436 mpDiagramViewGridHorizontalLabel = new Label(QString(Helper::horizontal).append(":"));
3437 mpDiagramViewGridHorizontalSpinBox = new DoubleSpinBox;
3438 mpDiagramViewGridHorizontalSpinBox->setRange(0, std::numeric_limits<double>::max());
3439 mpDiagramViewGridHorizontalSpinBox->setValue(2);
3440 mpDiagramViewGridHorizontalSpinBox->setSingleStep(1);
3441 mpDiagramViewGridVerticalLabel = new Label(QString(Helper::vertical).append(":"));
3442 mpDiagramViewGridVerticalSpinBox = new DoubleSpinBox;
3443 mpDiagramViewGridVerticalSpinBox->setRange(0, std::numeric_limits<double>::max());
3444 mpDiagramViewGridVerticalSpinBox->setValue(2);
3445 mpDiagramViewGridVerticalSpinBox->setSingleStep(1);
3446 // set the Diagram View grid group box layout
3447 QGridLayout *pDiagramViewGridLayout = new QGridLayout;
3448 pDiagramViewGridLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
3449 pDiagramViewGridLayout->setColumnStretch(1, 1);
3450 pDiagramViewGridLayout->addWidget(mpDiagramViewGridHorizontalLabel, 0, 0);
3451 pDiagramViewGridLayout->addWidget(mpDiagramViewGridHorizontalSpinBox, 0, 1);
3452 pDiagramViewGridLayout->addWidget(mpDiagramViewGridVerticalLabel, 1, 0);
3453 pDiagramViewGridLayout->addWidget(mpDiagramViewGridVerticalSpinBox, 1, 1);
3454 mpDiagramViewGridGroupBox->setLayout(pDiagramViewGridLayout);
3455 // create the Diagram View Component group box
3456 mpDiagramViewComponentGroupBox = new QGroupBox(Helper::component);
3457 mpDiagramViewScaleFactorLabel = new Label(Helper::scaleFactor);
3458 mpDiagramViewScaleFactorSpinBox = new DoubleSpinBox;
3459 mpDiagramViewScaleFactorSpinBox->setRange(0, std::numeric_limits<double>::max());
3460 mpDiagramViewScaleFactorSpinBox->setValue(0.1);
3461 mpDiagramViewScaleFactorSpinBox->setSingleStep(0.1);
3462 mpDiagramViewPreserveAspectRatioCheckBox = new QCheckBox(Helper::preserveAspectRatio);
3463 mpDiagramViewPreserveAspectRatioCheckBox->setChecked(true);
3464 // set the Diagram View component group box layout
3465 QGridLayout *pDiagramViewComponentLayout = new QGridLayout;
3466 pDiagramViewComponentLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
3467 pDiagramViewComponentLayout->setColumnStretch(1, 1);
3468 pDiagramViewComponentLayout->addWidget(mpDiagramViewScaleFactorLabel, 0, 0);
3469 pDiagramViewComponentLayout->addWidget(mpDiagramViewScaleFactorSpinBox, 0, 1);
3470 pDiagramViewComponentLayout->addWidget(mpDiagramViewPreserveAspectRatioCheckBox, 1, 0, 1, 2);
3471 mpDiagramViewComponentGroupBox->setLayout(pDiagramViewComponentLayout);
3472 // Diagram View Widget Layout
3473 QVBoxLayout *pDiagramViewMainLayout = new QVBoxLayout;
3474 pDiagramViewMainLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
3475 pDiagramViewMainLayout->addWidget(mpDiagramViewExtentGroupBox);
3476 pDiagramViewMainLayout->addWidget(mpDiagramViewGridGroupBox);
3477 pDiagramViewMainLayout->addWidget(mpDiagramViewComponentGroupBox);
3478 mpDiagramViewWidget->setLayout(pDiagramViewMainLayout);
3479 // add Diagram View Widget as a tab
3480 mpGraphicalViewsTabWidget->addTab(mpDiagramViewWidget, tr("Diagram View"));
3481 // set Main Layout
3482 QHBoxLayout *pHBoxLayout = new QHBoxLayout;
3483 pHBoxLayout->setContentsMargins(0, 0, 0, 0);
3484 pHBoxLayout->addWidget(mpGraphicalViewsTabWidget);
3485 setLayout(pHBoxLayout);
3486}
3487
3488void GraphicalViewsPage::setIconViewExtentLeft(double extentLeft)
3489{
3490 mpIconViewLeftSpinBox->setValue(extentLeft);
3491}
3492
3493double GraphicalViewsPage::getIconViewExtentLeft()
3494{
3495 return mpIconViewLeftSpinBox->value();
3496}
3497
3498void GraphicalViewsPage::setIconViewExtentBottom(double extentBottom)
3499{
3500 mpIconViewBottomSpinBox->setValue(extentBottom);
3501}
3502
3503double GraphicalViewsPage::getIconViewExtentBottom()
3504{
3505 return mpIconViewBottomSpinBox->value();
3506}
3507
3508void GraphicalViewsPage::setIconViewExtentRight(double extentRight)
3509{
3510 mpIconViewRightSpinBox->setValue(extentRight);
3511}
3512
3513double GraphicalViewsPage::getIconViewExtentRight()
3514{
3515 return mpIconViewRightSpinBox->value();
3516}
3517
3518void GraphicalViewsPage::setIconViewExtentTop(double extentTop)
3519{
3520 mpIconViewTopSpinBox->setValue(extentTop);
3521}
3522
3523double GraphicalViewsPage::getIconViewExtentTop()
3524{
3525 return mpIconViewTopSpinBox->value();
3526}
3527
3528void GraphicalViewsPage::setIconViewGridHorizontal(double gridHorizontal)
3529{
3530 mpIconViewGridHorizontalSpinBox->setValue(gridHorizontal);
3531}
3532
3533double GraphicalViewsPage::getIconViewGridHorizontal()
3534{
3535 return mpIconViewGridHorizontalSpinBox->value();
3536}
3537
3538void GraphicalViewsPage::setIconViewGridVertical(double gridVertical)
3539{
3540 mpIconViewGridVerticalSpinBox->setValue(gridVertical);
3541}
3542
3543double GraphicalViewsPage::getIconViewGridVertical()
3544{
3545 return mpIconViewGridVerticalSpinBox->value();
3546}
3547
3548void GraphicalViewsPage::setIconViewScaleFactor(double scaleFactor)
3549{
3550 mpIconViewScaleFactorSpinBox->setValue(scaleFactor);
3551}
3552
3553double GraphicalViewsPage::getIconViewScaleFactor()
3554{
3555 return mpIconViewScaleFactorSpinBox->value();
3556}
3557
3558void GraphicalViewsPage::setIconViewPreserveAspectRation(bool preserveAspectRation)
3559{
3560 mpIconViewPreserveAspectRatioCheckBox->setChecked(preserveAspectRation);
3561}
3562
3563bool GraphicalViewsPage::getIconViewPreserveAspectRation()
3564{
3565 return mpIconViewPreserveAspectRatioCheckBox->isChecked();
3566}
3567
3568void GraphicalViewsPage::setDiagramViewExtentLeft(double extentLeft)
3569{
3570 mpDiagramViewLeftSpinBox->setValue(extentLeft);
3571}
3572
3573double GraphicalViewsPage::getDiagramViewExtentLeft()
3574{
3575 return mpDiagramViewLeftSpinBox->value();
3576}
3577
3578void GraphicalViewsPage::setDiagramViewExtentBottom(double extentBottom)
3579{
3580 mpDiagramViewBottomSpinBox->setValue(extentBottom);
3581}
3582
3583double GraphicalViewsPage::getDiagramViewExtentBottom()
3584{
3585 return mpDiagramViewBottomSpinBox->value();
3586}
3587
3588void GraphicalViewsPage::setDiagramViewExtentRight(double extentRight)
3589{
3590 mpDiagramViewRightSpinBox->setValue(extentRight);
3591}
3592
3593double GraphicalViewsPage::getDiagramViewExtentRight()
3594{
3595 return mpDiagramViewRightSpinBox->value();
3596}
3597
3598void GraphicalViewsPage::setDiagramViewExtentTop(double extentTop)
3599{
3600 mpDiagramViewTopSpinBox->setValue(extentTop);
3601}
3602
3603double GraphicalViewsPage::getDiagramViewExtentTop()
3604{
3605 return mpDiagramViewTopSpinBox->value();
3606}
3607
3608void GraphicalViewsPage::setDiagramViewGridHorizontal(double gridHorizontal)
3609{
3610 mpDiagramViewGridHorizontalSpinBox->setValue(gridHorizontal);
3611}
3612
3613double GraphicalViewsPage::getDiagramViewGridHorizontal()
3614{
3615 return mpDiagramViewGridHorizontalSpinBox->value();
3616}
3617
3618void GraphicalViewsPage::setDiagramViewGridVertical(double gridVertical)
3619{
3620 mpDiagramViewGridVerticalSpinBox->setValue(gridVertical);
3621}
3622
3623double GraphicalViewsPage::getDiagramViewGridVertical()
3624{
3625 return mpDiagramViewGridVerticalSpinBox->value();
3626}
3627
3628void GraphicalViewsPage::setDiagramViewScaleFactor(double scaleFactor)
3629{
3630 mpDiagramViewScaleFactorSpinBox->setValue(scaleFactor);
3631}
3632
3633double GraphicalViewsPage::getDiagramViewScaleFactor()
3634{
3635 return mpDiagramViewScaleFactorSpinBox->value();
3636}
3637
3638void GraphicalViewsPage::setDiagramViewPreserveAspectRation(bool preserveAspectRation)
3639{
3640 mpDiagramViewPreserveAspectRatioCheckBox->setChecked(preserveAspectRation);
3641}
3642
3643bool GraphicalViewsPage::getDiagramViewPreserveAspectRation()
3644{
3645 return mpDiagramViewPreserveAspectRatioCheckBox->isChecked();
3646}
3647
3648//! @class SimulationPage
3649//! @brief Creates an interface for simulation settings.
3650
3651//! Constructor
3652//! @param pOptionsDialog is the pointer to OptionsDialog
3653SimulationPage::SimulationPage(OptionsDialog *pOptionsDialog)
3654 : QWidget(pOptionsDialog)
3655{
3656 mpOptionsDialog = pOptionsDialog;
3657 mpSimulationGroupBox = new QGroupBox(Helper::simulation);
3658 // Translation Flags
3659 mpTranslationFlagsGroupBox = new QGroupBox(Helper::translationFlags);
3660 mpTranslationFlagsWidget = new TranslationFlagsWidget(this);
3661 SimulationOptions simulationOptions;
3662 mpTranslationFlagsWidget->applySimulationOptions(simulationOptions);
3663 // Translation Flags layout
3664 QGridLayout *pTranslationFlagsGridLayout = new QGridLayout;
3665 pTranslationFlagsGridLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
3666 pTranslationFlagsGridLayout->addWidget(new Label("Global flags applied to the Simulation Setup dialog upon the first simulation of a model.\n"
3667 "For subsequent simulations, you can change them locally using the Simulation Setup dialog."), 0, 0);
3668 pTranslationFlagsGridLayout->addWidget(mpTranslationFlagsWidget, 1, 0);
3669 mpTranslationFlagsGroupBox->setLayout(pTranslationFlagsGridLayout);
3670 // Target Language
3671 mpTargetLanguageLabel = new Label(tr("Target Language:"));
3672 OMCInterface::getConfigFlagValidOptions_res simCodeTarget = MainWindow::instance()->getOMCProxy()->getConfigFlagValidOptions("simCodeTarget");
3673 mpTargetLanguageComboBox = new QComboBox;
3674 mpTargetLanguageComboBox->addItems(simCodeTarget.validOptions);
3675 mpTargetLanguageComboBox->setToolTip(simCodeTarget.mainDescription);
3676 int i = 0;
3677 foreach (QString description, simCodeTarget.descriptions)for (auto _container_ = QtPrivate::qMakeForeachContainer(simCodeTarget
.descriptions); _container_.control && _container_.i !=
_container_.e; ++_container_.i, _container_.control ^= 1) for
(QString description = *_container_.i; _container_.control; _container_
.control = 0)
{
3678 mpTargetLanguageComboBox->setItemData(i, description, Qt::ToolTipRole);
3679 i++;
3680 }
3681 mpTargetLanguageComboBox->setCurrentIndex(mpTargetLanguageComboBox->findText("C"));
3682 // Target Build
3683 mpTargetBuildLabel = new Label(tr("Target Build:"));
3684 mpTargetBuildComboBox = new QComboBox;
3685#ifdef Q_OS_WIN
3686 mpTargetBuildComboBox->addItem("MinGW", "gcc");
3687 mpTargetBuildComboBox->addItem("Visual Studio (msvc)", "msvc");
3688 mpTargetBuildComboBox->addItem("Visual Studio 2010 (msvc10)", "msvc10");
3689 mpTargetBuildComboBox->addItem("Visual Studio 2012 (msvc12)", "msvc12");
3690 mpTargetBuildComboBox->addItem("Visual Studio 2013 (msvc13)", "msvc13");
3691 mpTargetBuildComboBox->addItem("Visual Studio 2015 (msvc15)", "msvc15");
3692#else
3693 mpTargetBuildComboBox->addItem("GNU Make", "gcc");
3694#endif
3695 mpTargetBuildComboBox->addItem("vxworks69", "vxworks69");
3696 mpTargetBuildComboBox->addItem("debugrt", "debugrt");
3697 connect(mpTargetBuildComboBox, SIGNAL(currentIndexChanged(int))"2""currentIndexChanged(int)", SLOT(targetBuildChanged(int))"1""targetBuildChanged(int)");
3698 // C Compiler
3699 mpCompilerLabel = new Label(tr("C Compiler:"));
3700 mpCompilerComboBox = new QComboBox;
3701 mpCompilerComboBox->setEditable(true);
3702 mpCompilerComboBox->addItem("");
3703 mpCompilerComboBox->addItem("gcc");
3704#ifdef Q_OS_UNIX
3705 mpCompilerComboBox->addItem("clang");
3706#endif
3707 mpCompilerComboBox->lineEdit()->setPlaceholderText(MainWindow::instance()->getOMCProxy()->getCompiler());
3708 // CXX Compiler
3709 mpCXXCompilerLabel = new Label(tr("CXX Compiler:"));
3710 mpCXXCompilerComboBox = new QComboBox;
3711 mpCXXCompilerComboBox->setEditable(true);
3712 mpCXXCompilerComboBox->addItem("");
3713 mpCXXCompilerComboBox->addItem("g++");
3714#ifdef Q_OS_UNIX
3715 mpCXXCompilerComboBox->addItem("clang++");
3716#endif
3717 mpCXXCompilerComboBox->lineEdit()->setPlaceholderText(MainWindow::instance()->getOMCProxy()->getCXXCompiler());
3718 // ignore command line options annotation checkbox
3719 mpIgnoreCommandLineOptionsAnnotationCheckBox = new QCheckBox(tr("Ignore __OpenModelica_commandLineOptions annotation"));
3720 // ignore simulation flags annotation checkbox
3721 mpIgnoreSimulationFlagsAnnotationCheckBox = new QCheckBox(tr("Ignore __OpenModelica_simulationFlags annotation"));
3722 //! @todo Remove this once we enable this bydefault in OMC.
3723 /* Enable new instantiation use in OMC API */
3724 mpEnableNewInstantiationAPICheckBox = new QCheckBox(tr("Enable new frontend use in the OMC API (faster GUI response)"));
3725 mpEnableNewInstantiationAPICheckBox->setChecked(true);
3726 /* Display errors/warnings when new instantiation fails in evaluating graphical annotations */
3727 mpDisplayNFAPIErrorsWarningsCheckBox = new QCheckBox(tr("Display errors/warnings when instantiating the graphical annotations"));
3728 /* save class before simulation checkbox */
3729 mpSaveClassBeforeSimulationCheckBox = new QCheckBox(tr("Save class before simulation"));
3730 mpSaveClassBeforeSimulationCheckBox->setToolTip(tr("Disabling this will effect the debugger functionality."));
3731 mpSaveClassBeforeSimulationCheckBox->setChecked(true);
3732 /* switch to plotting perspective after simulation checkbox */
3733 mpSwitchToPlottingPerspectiveCheckBox = new QCheckBox(tr("Switch to plotting perspective after simulation"));
3734 mpSwitchToPlottingPerspectiveCheckBox->setChecked(true);
3735 /* Close completed SimulationOutputWidgets before simulation checkbox */
3736 mpCloseSimulationOutputWidgetsBeforeSimulationCheckBox = new QCheckBox(tr("Close completed simulation output windows before simulation"));
3737 mpCloseSimulationOutputWidgetsBeforeSimulationCheckBox->setChecked(true);
3738 /* Delete intermediate compilation files checkbox */
3739 mpDeleteIntermediateCompilationFilesCheckBox = new QCheckBox(tr("Delete intermediate compilation files"));
3740 mpDeleteIntermediateCompilationFilesCheckBox->setChecked(true);
3741 /* Delete entire simulation directory checkbox */
3742 mpDeleteEntireSimulationDirectoryCheckBox = new QCheckBox(tr("Delete entire simulation directory of the model when OMEdit is closed"));
3743 // simulation output format
3744 mpOutputGroupBox = new QGroupBox(Helper::output);
3745 mpStructuredRadioButton = new QRadioButton(tr("Structured"));
3746 mpStructuredRadioButton->setToolTip(tr("Shows the simulation output in the form of tree structure."));
3747 mpStructuredRadioButton->setChecked(true);
3748 mpFormattedTextRadioButton = new QRadioButton(tr("Formatted Text"));
3749 mpFormattedTextRadioButton->setToolTip(tr("Shows the simulation output in the form of formatted text."));
3750 QButtonGroup *pOutputButtonGroup = new QButtonGroup;
3751 pOutputButtonGroup->addButton(mpStructuredRadioButton);
3752 pOutputButtonGroup->addButton(mpFormattedTextRadioButton);
3753 // output view buttons layout
3754 QHBoxLayout *pOutputRadioButtonsLayout = new QHBoxLayout;
3755 pOutputRadioButtonsLayout->addWidget(mpStructuredRadioButton);
3756 pOutputRadioButtonsLayout->addWidget(mpFormattedTextRadioButton);
3757 // display limit
3758 mpDisplayLimitLabel = new Label(tr("Display Limit:"));
3759 mpDisplayLimitSpinBox = new QSpinBox;
3760 mpDisplayLimitSpinBox->setSuffix(" KB");
3761 mpDisplayLimitSpinBox->setRange(1, std::numeric_limits<int>::max());
3762 mpDisplayLimitSpinBox->setSingleStep(100);
3763 mpDisplayLimitSpinBox->setValue(500);
3764 mpDisplayLimitMBLabel = new Label;
3765 connect(mpDisplayLimitSpinBox, SIGNAL(valueChanged(int))"2""valueChanged(int)", SLOT(displayLimitValueChanged(int))"1""displayLimitValueChanged(int)");
3766 // calculate the display limit in MBs.
3767 displayLimitValueChanged(mpDisplayLimitSpinBox->value());
3768 // set the layout of output view mode group
3769 QGridLayout *pOutputGroupGridLayout = new QGridLayout;
3770 pOutputGroupGridLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
3771 pOutputGroupGridLayout->addLayout(pOutputRadioButtonsLayout, 0, 0, 1, 3, Qt::AlignLeft);
3772 pOutputGroupGridLayout->addWidget(mpDisplayLimitLabel, 1, 0);
3773 pOutputGroupGridLayout->addWidget(mpDisplayLimitSpinBox, 1, 1);
3774 pOutputGroupGridLayout->addWidget(mpDisplayLimitMBLabel, 1, 2);
3775 mpOutputGroupBox->setLayout(pOutputGroupGridLayout);
3776 // set the layout of simulation group
3777 QGridLayout *pSimulationLayout = new QGridLayout;
3778 pSimulationLayout->setAlignment(Qt::AlignTop);
3779 int row = 0;
3780 pSimulationLayout->addWidget(mpTranslationFlagsGroupBox, row++, 0, 1, 2);
3781 pSimulationLayout->addWidget(mpTargetLanguageLabel, row, 0);
3782 pSimulationLayout->addWidget(mpTargetLanguageComboBox, row++, 1);
3783 pSimulationLayout->addWidget(mpTargetBuildLabel, row, 0);
3784 pSimulationLayout->addWidget(mpTargetBuildComboBox, row++, 1);
3785 pSimulationLayout->addWidget(mpCompilerLabel, row, 0);
3786 pSimulationLayout->addWidget(mpCompilerComboBox, row++, 1);
3787 pSimulationLayout->addWidget(mpCXXCompilerLabel, row, 0);
3788 pSimulationLayout->addWidget(mpCXXCompilerComboBox, row++, 1);
3789 pSimulationLayout->addWidget(mpIgnoreCommandLineOptionsAnnotationCheckBox, row++, 0, 1, 2);
3790 pSimulationLayout->addWidget(mpIgnoreSimulationFlagsAnnotationCheckBox, row++, 0, 1, 2);
3791 pSimulationLayout->addWidget(mpEnableNewInstantiationAPICheckBox, row++, 0, 1, 2);
3792 pSimulationLayout->addWidget(mpDisplayNFAPIErrorsWarningsCheckBox, row++, 0, 1, 2);
3793 pSimulationLayout->addWidget(mpSaveClassBeforeSimulationCheckBox, row++, 0, 1, 2);
3794 pSimulationLayout->addWidget(mpSwitchToPlottingPerspectiveCheckBox, row++, 0, 1, 2);
3795 pSimulationLayout->addWidget(mpCloseSimulationOutputWidgetsBeforeSimulationCheckBox, row++, 0, 1, 2);
3796 pSimulationLayout->addWidget(mpDeleteIntermediateCompilationFilesCheckBox, row++, 0, 1, 2);
3797 pSimulationLayout->addWidget(mpDeleteEntireSimulationDirectoryCheckBox, row++, 0, 1, 2);
3798 pSimulationLayout->addWidget(mpOutputGroupBox, row++, 0, 1, 2);
3799 mpSimulationGroupBox->setLayout(pSimulationLayout);
3800 // set the layout
3801 QVBoxLayout *pLayout = new QVBoxLayout;
3802 pLayout->setAlignment(Qt::AlignTop);
3803 pLayout->setContentsMargins(0, 0, 0, 0);
3804 pLayout->addWidget(mpSimulationGroupBox);
3805 setLayout(pLayout);
3806}
3807
3808void SimulationPage::setOutputMode(QString value)
3809{
3810 if (value.compare(Helper::structuredOutput) == 0) {
3811 mpStructuredRadioButton->setChecked(true);
3812 } else {
3813 mpFormattedTextRadioButton->setChecked(true);
3814 }
3815}
3816
3817QString SimulationPage::getOutputMode()
3818{
3819 if (mpStructuredRadioButton->isChecked()) {
3820 return Helper::structuredOutput;
3821 } else {
3822 return Helper::textOutput;
3823 }
3824}
3825
3826/*!
3827 * \brief SimulationPage::targetBuildChanged
3828 * Enable/Disable the Compiler and CXX Compiler fields.
3829 * \param index
3830 */
3831void SimulationPage::targetBuildChanged(int index)
3832{
3833 if (mpTargetBuildComboBox->itemData(index).toString() == "gcc") {
3834 mpCompilerComboBox->setEnabled(true);
3835 mpCXXCompilerComboBox->setEnabled(true);
3836 } else {
3837 mpCompilerComboBox->setEnabled(false);
3838 mpCXXCompilerComboBox->setEnabled(false);
3839 }
3840}
3841
3842/*!
3843 * \brief SimulationPage::displayLimitValueChanged
3844 * Slot activated when mpDisplayLimitSpinBox valueChanged SIGNAL is raised.
3845 * Shows the display limit is MBs.
3846 * 1 KB is 0,001 MB.
3847 * \param value
3848 */
3849void SimulationPage::displayLimitValueChanged(int value)
3850{
3851 mpDisplayLimitMBLabel->setText(QString("(%1 MB)").arg(value*0.001));
3852}
3853
3854//! @class MessagesPage
3855//! @brief Creates an interface for MessagesWidget settings.
3856
3857//! Constructor
3858//! @param pOptionsDialog is the pointer to OptionsDialog
3859MessagesPage::MessagesPage(OptionsDialog *pOptionsDialog)
3860 : QWidget(pOptionsDialog)
3861{
3862 mpOptionsDialog = pOptionsDialog;
3863 // general groupbox
3864 mpGeneralGroupBox = new QGroupBox(Helper::general);
3865 // output size
3866 mpOutputSizeLabel = new Label(tr("Output size:"));
3867 mpOutputSizeLabel->setToolTip(tr("Specifies the maximum number of rows the Messages Browser may have. "
3868 "If there are more rows then the rows are removed from the beginning."));
3869 mpOutputSizeSpinBox = new QSpinBox;
3870 mpOutputSizeSpinBox->setRange(0, std::numeric_limits<int>::max());
3871 mpOutputSizeSpinBox->setSingleStep(1000);
3872 mpOutputSizeSpinBox->setSuffix(" rows");
3873 mpOutputSizeSpinBox->setSpecialValueText(Helper::unlimited);
3874 // reset messages number before simulation
3875 mpResetMessagesNumberBeforeSimulationCheckBox = new QCheckBox(tr("Reset messages number before checking, instantiation && simulation"));
3876 mpResetMessagesNumberBeforeSimulationCheckBox->setChecked(true);
3877 // clear messages browser before simulation
3878 mpClearMessagesBrowserBeforeSimulationCheckBox = new QCheckBox(tr("Clear messages browser before checking, instantiation && simulation"));
3879 // set general groupbox layout
3880 QGridLayout *pGeneralGroupBoxLayout = new QGridLayout;
3881 pGeneralGroupBoxLayout->setColumnStretch(1, 1);
3882 pGeneralGroupBoxLayout->addWidget(mpOutputSizeLabel, 0, 0);
3883 pGeneralGroupBoxLayout->addWidget(mpOutputSizeSpinBox, 0, 1);
3884 pGeneralGroupBoxLayout->addWidget(mpResetMessagesNumberBeforeSimulationCheckBox, 1, 0, 1, 2);
3885 pGeneralGroupBoxLayout->addWidget(mpClearMessagesBrowserBeforeSimulationCheckBox, 2, 0, 1, 2);
3886 mpGeneralGroupBox->setLayout(pGeneralGroupBoxLayout);
3887 // Font and Colors
3888 mpFontColorsGroupBox = new QGroupBox(Helper::Colors);
3889 // font family combobox
3890 mpFontFamilyLabel = new Label(Helper::fontFamily);
3891 mpFontFamilyComboBox = new QFontComboBox;
3892 QTextBrowser textBrowser;
3893 int currentIndex;
3894 currentIndex = mpFontFamilyComboBox->findText(textBrowser.font().family(), Qt::MatchExactly);
3895 mpFontFamilyComboBox->setCurrentIndex(currentIndex);
3896 // font size combobox
3897 mpFontSizeLabel = new Label(Helper::fontSize);
3898 mpFontSizeSpinBox = new DoubleSpinBox;
3899 mpFontSizeSpinBox->setRange(6, std::numeric_limits<double>::max());
3900 mpFontSizeSpinBox->setValue(textBrowser.font().pointSizeF());
3901 mpFontSizeSpinBox->setSingleStep(1);
3902 // Notification Color
3903 mpNotificationColorLabel = new Label(tr("Notification Color:"));
3904 mpNotificationColorButton = new QPushButton(Helper::pickColor);
3905 mpNotificationColorButton->setAutoDefault(false);
3906 connect(mpNotificationColorButton, SIGNAL(clicked())"2""clicked()", SLOT(pickNotificationColor())"1""pickNotificationColor()");
3907 setNotificationColor(Qt::black);
3908 setNotificationPickColorButtonIcon();
3909 // Warning Color
3910 mpWarningColorLabel = new Label(tr("Warning Color:"));
3911 mpWarningColorButton = new QPushButton(Helper::pickColor);
3912 mpWarningColorButton->setAutoDefault(false);
3913 connect(mpWarningColorButton, SIGNAL(clicked())"2""clicked()", SLOT(pickWarningColor())"1""pickWarningColor()");
3914 setWarningColor(QColor(255, 170, 0));
3915 setWarningPickColorButtonIcon();
3916 // Error Color
3917 mpErrorColorLabel = new Label(tr("Error Color:"));
3918 mpErrorColorButton = new QPushButton(Helper::pickColor);
3919 mpErrorColorButton->setAutoDefault(false);
3920 connect(mpErrorColorButton, SIGNAL(clicked())"2""clicked()", SLOT(pickErrorColor())"1""pickErrorColor()");
3921 setErrorColor(Qt::red);
3922 setErrorPickColorButtonIcon();
3923 // set the layout of FontColors group
3924 QGridLayout *pFontColorsLayout = new QGridLayout;
3925 pFontColorsLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
3926 pFontColorsLayout->setColumnStretch(1, 1);
3927 pFontColorsLayout->addWidget(mpFontFamilyLabel, 0, 0);
3928 pFontColorsLayout->addWidget(mpFontFamilyComboBox, 0, 1);
3929 pFontColorsLayout->addWidget(mpFontSizeLabel, 1, 0);
3930 pFontColorsLayout->addWidget(mpFontSizeSpinBox, 1, 1);
3931 pFontColorsLayout->addWidget(mpNotificationColorLabel, 2, 0);
3932 pFontColorsLayout->addWidget(mpNotificationColorButton, 2, 1);
3933 pFontColorsLayout->addWidget(mpWarningColorLabel, 3, 0);
3934 pFontColorsLayout->addWidget(mpWarningColorButton, 3, 1);
3935 pFontColorsLayout->addWidget(mpErrorColorLabel, 4, 0);
3936 pFontColorsLayout->addWidget(mpErrorColorButton, 4, 1);
3937 mpFontColorsGroupBox->setLayout(pFontColorsLayout);
3938 // set the layout
3939 QVBoxLayout *pMainLayout = new QVBoxLayout;
3940 pMainLayout->setAlignment(Qt::AlignTop);
3941 pMainLayout->setContentsMargins(0, 0, 0, 0);
3942 pMainLayout->addWidget(mpGeneralGroupBox);
3943 pMainLayout->addWidget(mpFontColorsGroupBox);
3944 setLayout(pMainLayout);
3945}
3946
3947void MessagesPage::setNotificationPickColorButtonIcon()
3948{
3949 QPixmap pixmap(Helper::iconSize);
3950 pixmap.fill(getNotificationColor());
3951 mpNotificationColorButton->setIcon(pixmap);
3952}
3953
3954void MessagesPage::setWarningPickColorButtonIcon()
3955{
3956 QPixmap pixmap(Helper::iconSize);
3957 pixmap.fill(getWarningColor());
3958 mpWarningColorButton->setIcon(pixmap);
3959}
3960
3961void MessagesPage::setErrorPickColorButtonIcon()
3962{
3963 QPixmap pixmap(Helper::iconSize);
3964 pixmap.fill(getErrorColor());
3965 mpErrorColorButton->setIcon(pixmap);
3966}
3967
3968void MessagesPage::pickNotificationColor()
3969{
3970 QColor color = QColorDialog::getColor(getNotificationColor());
3971 // if user press ESC
3972 if (!color.isValid()) {
3973 return;
3974 }
3975 setNotificationColor(color);
3976 setNotificationPickColorButtonIcon();
3977}
3978
3979void MessagesPage::pickWarningColor()
3980{
3981 QColor color = QColorDialog::getColor(getWarningColor());
3982 // if user press ESC
3983 if (!color.isValid()) {
3984 return;
3985 }
3986 setWarningColor(color);
3987 setWarningPickColorButtonIcon();
3988}
3989
3990void MessagesPage::pickErrorColor()
3991{
3992 QColor color = QColorDialog::getColor(getErrorColor());
3993 // if user press ESC
3994 if (!color.isValid()) {
3995 return;
3996 }
3997 setErrorColor(color);
3998 setErrorPickColorButtonIcon();
3999}
4000
4001/*!
4002 * \class NotificationsPage
4003 * \brief Creates an interface for Notifications settings.
4004 */
4005/*!
4006 * \brief NotificationsPage::NotificationsPage
4007 * \param pOptionsDialog is the pointer to OptionsDialog
4008 */
4009NotificationsPage::NotificationsPage(OptionsDialog *pOptionsDialog)
4010 : QWidget(pOptionsDialog)
4011{
4012 mpOptionsDialog = pOptionsDialog;
4013 // create the notifications groupbox
4014 mpNotificationsGroupBox = new QGroupBox(tr("Notifications"));
4015 // create the exit application checkbox
4016 mpQuitApplicationCheckBox = new QCheckBox(tr("Always quit without prompt"));
4017 // create the item drop on itself checkbox
4018 mpItemDroppedOnItselfCheckBox = new QCheckBox(tr("Show item dropped on itself message"));
4019 mpItemDroppedOnItselfCheckBox->setChecked(true);
4020 // create the replaceable if partial checkbox
4021 mpReplaceableIfPartialCheckBox = new QCheckBox(tr("Show model is partial and component is added as replaceable message"));
4022 mpReplaceableIfPartialCheckBox->setChecked(true);
4023 // create the inner model name changed checkbox
4024 mpInnerModelNameChangedCheckBox = new QCheckBox(tr("Show component is declared as inner message"));
4025 mpInnerModelNameChangedCheckBox->setChecked(true);
4026 // create the save model for bitmap insertion checkbox
4027 mpSaveModelForBitmapInsertionCheckBox = new QCheckBox(tr("Show save model for bitmap insertion message"));
4028 mpSaveModelForBitmapInsertionCheckBox->setChecked(true);
4029 // create the save model for bitmap insertion checkbox
4030 mpAlwaysAskForDraggedComponentName = new QCheckBox(tr("Always ask for the dragged component name"));
4031 mpAlwaysAskForDraggedComponentName->setChecked(true);
4032 // create the always ask for text editor error
4033 mpAlwaysAskForTextEditorErrorCheckBox = new QCheckBox(tr("Always ask for what to do with the text editor error"));
4034 mpAlwaysAskForTextEditorErrorCheckBox->setChecked(true);
4035 // prompt for old frontend
4036 mpOldFrontendLabel = new Label(tr("If new frontend for code generation fails?"));
4037 mpOldFrontendComboBox = new QComboBox;
4038 mpOldFrontendComboBox->addItem(tr("Always ask for old frontend"), NotificationsPage::AlwaysAskForOF);
4039 mpOldFrontendComboBox->addItem(tr("Try with old frontend once"), NotificationsPage::TryOnceWithOF);
4040 mpOldFrontendComboBox->addItem(tr("Switch to old frontend permanently"), NotificationsPage::SwitchPermanentlyToOF);
4041 mpOldFrontendComboBox->addItem(tr("Keep using new frontend"), NotificationsPage::KeepUsingNF);
4042 // set the layout of notifications group
4043 QGridLayout *pNotificationsLayout = new QGridLayout;
4044 pNotificationsLayout->setAlignment(Qt::AlignTop);
4045 pNotificationsLayout->addWidget(mpQuitApplicationCheckBox, 0, 0, 1, 2);
4046 pNotificationsLayout->addWidget(mpItemDroppedOnItselfCheckBox, 1, 0, 1, 2);
4047 pNotificationsLayout->addWidget(mpReplaceableIfPartialCheckBox, 2, 0, 1, 2);
4048 pNotificationsLayout->addWidget(mpInnerModelNameChangedCheckBox, 3, 0, 1, 2);
4049 pNotificationsLayout->addWidget(mpSaveModelForBitmapInsertionCheckBox, 4, 0, 1, 2);
4050 pNotificationsLayout->addWidget(mpAlwaysAskForDraggedComponentName, 5, 0, 1, 2);
4051 pNotificationsLayout->addWidget(mpAlwaysAskForTextEditorErrorCheckBox, 6, 0, 1, 2);
4052 pNotificationsLayout->addWidget(mpOldFrontendLabel, 7, 0);
4053 pNotificationsLayout->addWidget(mpOldFrontendComboBox, 7, 1);
4054 mpNotificationsGroupBox->setLayout(pNotificationsLayout);
4055 // set the layout
4056 QVBoxLayout *pLayout = new QVBoxLayout;
4057 pLayout->setAlignment(Qt::AlignTop);
4058 pLayout->setContentsMargins(0, 0, 0, 0);
4059 pLayout->addWidget(mpNotificationsGroupBox);
4060 setLayout(pLayout);
4061}
4062
4063//! @class LineStylePage
4064//! @brief Creates an interface for line style settings.
4065
4066//! Constructor
4067//! @param pOptionsDialog is the pointer to OptionsDialog
4068LineStylePage::LineStylePage(OptionsDialog *pOptionsDialog)
4069 : QWidget(pOptionsDialog)
4070{
4071 mpOptionsDialog = pOptionsDialog;
4072 mpLineStyleGroupBox = new QGroupBox(Helper::lineStyle);
4073 // Line Color
4074 mpLineColorLabel = new Label(Helper::color);
4075 mpLinePickColorButton = new QPushButton(Helper::pickColor);
4076 mpLinePickColorButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
4077 mpLinePickColorButton->setAutoDefault(false);
4078 connect(mpLinePickColorButton, SIGNAL(clicked())"2""clicked()", SLOT(linePickColor())"1""linePickColor()");
4079 setLineColor(Qt::black);
4080 setLinePickColorButtonIcon();
4081 // Line Pattern
4082 mpLinePatternLabel = new Label(Helper::pattern);
4083 mpLinePatternComboBox = StringHandler::getLinePatternComboBox();
4084 setLinePattern(StringHandler::getLinePatternString(StringHandler::LineSolid));
4085 // Line Thickness
4086 mpLineThicknessLabel = new Label(Helper::thickness);
4087 mpLineThicknessSpinBox = new DoubleSpinBox;
4088 mpLineThicknessSpinBox->setRange(0, std::numeric_limits<double>::max());
4089 mpLineThicknessSpinBox->setValue(0.25);
4090 mpLineThicknessSpinBox->setSingleStep(0.25);
4091 // Line Arrow
4092 mpLineStartArrowLabel = new Label(Helper::startArrow);
4093 mpLineStartArrowComboBox = StringHandler::getStartArrowComboBox();
4094 mpLineEndArrowLabel = new Label(Helper::endArrow);
4095 mpLineEndArrowComboBox = StringHandler::getEndArrowComboBox();
4096 mpLineArrowSizeLabel = new Label(Helper::arrowSize);
4097 mpLineArrowSizeSpinBox = new DoubleSpinBox;
4098 mpLineArrowSizeSpinBox->setRange(0, std::numeric_limits<double>::max());
4099 mpLineArrowSizeSpinBox->setValue(3);
4100 mpLineArrowSizeSpinBox->setSingleStep(1);
4101 // Line smooth
4102 mpLineSmoothLabel = new Label(Helper::smooth);
4103 mpLineSmoothCheckBox = new QCheckBox(Helper::bezier);
4104 // set the layout
4105 QGridLayout *pLineStyleLayout = new QGridLayout;
4106 pLineStyleLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
4107 pLineStyleLayout->addWidget(mpLineColorLabel, 0, 0);
4108 pLineStyleLayout->addWidget(mpLinePickColorButton, 0, 1);
4109 pLineStyleLayout->addWidget(mpLinePatternLabel, 2, 0);
4110 pLineStyleLayout->addWidget(mpLinePatternComboBox, 2, 1);
4111 pLineStyleLayout->addWidget(mpLineThicknessLabel, 3, 0);
4112 pLineStyleLayout->addWidget(mpLineThicknessSpinBox, 3, 1);
4113 pLineStyleLayout->addWidget(mpLineStartArrowLabel, 4, 0);
4114 pLineStyleLayout->addWidget(mpLineStartArrowComboBox, 4, 1);
4115 pLineStyleLayout->addWidget(mpLineEndArrowLabel, 5, 0);
4116 pLineStyleLayout->addWidget(mpLineEndArrowComboBox, 5, 1);
4117 pLineStyleLayout->addWidget(mpLineArrowSizeLabel, 6, 0);
4118 pLineStyleLayout->addWidget(mpLineArrowSizeSpinBox, 6, 1);
4119 pLineStyleLayout->addWidget(mpLineSmoothLabel, 7, 0);
4120 pLineStyleLayout->addWidget(mpLineSmoothCheckBox, 7, 1);
4121 mpLineStyleGroupBox->setLayout(pLineStyleLayout);
4122 QVBoxLayout *pMainLayout = new QVBoxLayout;
4123 pMainLayout->setAlignment(Qt::AlignTop);
4124 pMainLayout->setContentsMargins(0, 0, 0, 0);
4125 pMainLayout->addWidget(mpLineStyleGroupBox);
4126 setLayout(pMainLayout);
4127}
4128
4129//! Sets the pen color
4130//! @param color to set.
4131void LineStylePage::setLineColor(QColor color)
4132{
4133 mLineColor = color;
4134}
4135
4136//! Returns the pen color
4137QColor LineStylePage::getLineColor()
4138{
4139 return mLineColor;
4140}
4141
4142void LineStylePage::setLinePickColorButtonIcon()
4143{
4144 QPixmap pixmap(Helper::iconSize);
4145 pixmap.fill(getLineColor());
4146 mpLinePickColorButton->setIcon(pixmap);
4147}
4148
4149//! Sets the pen pattern
4150//! @param pattern to set.
4151void LineStylePage::setLinePattern(QString pattern)
4152{
4153 int index = mpLinePatternComboBox->findText(pattern, Qt::MatchExactly);
4154 if (index != -1)
4155 mpLinePatternComboBox->setCurrentIndex(index);
4156}
4157
4158QString LineStylePage::getLinePattern()
4159{
4160 return mpLinePatternComboBox->currentText();
4161}
4162
4163//! Sets the pen thickness
4164//! @param thickness to set.
4165void LineStylePage::setLineThickness(qreal thickness)
4166{
4167 if (thickness <= 0)
4168 thickness = 0.25;
4169 mpLineThicknessSpinBox->setValue(thickness);
4170}
4171
4172//! Returns the pen thickness
4173qreal LineStylePage::getLineThickness()
4174{
4175 return mpLineThicknessSpinBox->value();
4176}
4177
4178void LineStylePage::setLineStartArrow(QString startArrow)
4179{
4180 int index = mpLineStartArrowComboBox->findText(startArrow, Qt::MatchExactly);
4181 if (index != -1)
4182 mpLineStartArrowComboBox->setCurrentIndex(index);
4183}
4184
4185QString LineStylePage::getLineStartArrow()
4186{
4187 return mpLineStartArrowComboBox->currentText();
4188}
4189
4190void LineStylePage::setLineEndArrow(QString endArrow)
4191{
4192 int index = mpLineEndArrowComboBox->findText(endArrow, Qt::MatchExactly);
4193 if (index != -1)
4194 mpLineEndArrowComboBox->setCurrentIndex(index);
4195}
4196
4197QString LineStylePage::getLineEndArrow()
4198{
4199 return mpLineEndArrowComboBox->currentText();
4200}
4201
4202void LineStylePage::setLineArrowSize(qreal size)
4203{
4204 if (size <= 0)
4205 size = 3;
4206 mpLineArrowSizeSpinBox->setValue(size);
4207}
4208
4209qreal LineStylePage::getLineArrowSize()
4210{
4211 return mpLineArrowSizeSpinBox->value();
4212}
4213
4214//! Sets whether the pen used will be smooth (for splines) or not.
4215//! @param smooth
4216void LineStylePage::setLineSmooth(bool smooth)
4217{
4218 mpLineSmoothCheckBox->setChecked(smooth);
4219}
4220
4221//! Returns the pen smooth
4222bool LineStylePage::getLineSmooth()
4223{
4224 return mpLineSmoothCheckBox->isChecked();
4225}
4226
4227//! Opens the color picker dialog. The user selects the color and the color saved as a pen color.
4228void LineStylePage::linePickColor()
4229{
4230 QColor color = QColorDialog::getColor(getLineColor());
4231 // if user press ESC
4232 if (!color.isValid())
4233 return;
4234 setLineColor(color);
4235 setLinePickColorButtonIcon();
4236}
4237
4238//! @class FillStylePage
4239//! @brief Creates an interface for fill style settings.
4240
4241//! Constructor
4242//! @param pOptionsDialog is the pointer to OptionsDialog
4243FillStylePage::FillStylePage(OptionsDialog *pOptionsDialog)
4244 : QWidget(pOptionsDialog)
4245{
4246 mpFillStyleGroupBox = new QGroupBox(Helper::fillStyle);
4247 // Fill Color
4248 mpFillColorLabel = new Label(Helper::color);
4249 mpFillPickColorButton = new QPushButton(Helper::pickColor);
4250 mpFillPickColorButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
4251 mpFillPickColorButton->setAutoDefault(false);
4252 connect(mpFillPickColorButton, SIGNAL(clicked())"2""clicked()", SLOT(fillPickColor())"1""fillPickColor()");
4253 setFillColor(Qt::black);
4254 setFillPickColorButtonIcon();
4255 // Fill Pattern
4256 mpFillPatternLabel = new Label(Helper::pattern);
4257 mpFillPatternComboBox = StringHandler::getFillPatternComboBox();
4258 setFillPattern(StringHandler::getFillPatternString(StringHandler::FillNone));
4259 // set the layout
4260 QGridLayout *pFillStyleLayout = new QGridLayout;
4261 pFillStyleLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
4262 pFillStyleLayout->addWidget(mpFillColorLabel, 0, 0);
4263 pFillStyleLayout->addWidget(mpFillPickColorButton, 0, 1);
4264 pFillStyleLayout->addWidget(mpFillPatternLabel, 1, 0);
4265 pFillStyleLayout->addWidget(mpFillPatternComboBox, 1, 1);
4266 mpFillStyleGroupBox->setLayout(pFillStyleLayout);
4267 QVBoxLayout *pMainLayout = new QVBoxLayout;
4268 pMainLayout->setAlignment(Qt::AlignTop);
4269 pMainLayout->setContentsMargins(0, 0, 0, 0);
4270 pMainLayout->addWidget(mpFillStyleGroupBox);
4271 setLayout(pMainLayout);
4272}
4273
4274void FillStylePage::setFillColor(QColor color)
4275{
4276 mFillColor = color;
4277}
4278
4279QColor FillStylePage::getFillColor()
4280{
4281 return mFillColor;
4282}
4283
4284void FillStylePage::setFillPickColorButtonIcon()
4285{
4286 QPixmap pixmap(Helper::iconSize);
4287 pixmap.fill(getFillColor());
4288 mpFillPickColorButton->setIcon(pixmap);
4289}
4290
4291void FillStylePage::setFillPattern(QString pattern)
4292{
4293 int index = mpFillPatternComboBox->findText(pattern, Qt::MatchExactly);
4294 if (index != -1)
4295 mpFillPatternComboBox->setCurrentIndex(index);
4296}
4297
4298QString FillStylePage::getFillPattern()
4299{
4300 return mpFillPatternComboBox->currentText();
4301}
4302
4303void FillStylePage::fillPickColor()
4304{
4305 QColor color = QColorDialog::getColor(getFillColor());
4306 // if user press ESC
4307 if (!color.isValid())
4308 return;
4309 setFillColor(color);
4310 setFillPickColorButtonIcon();
4311}
4312
4313//! @class PlottingPage
4314//! @brief Creates an interface for curve style settings.
4315
4316//! Constructor
4317//! @param pOptionsDialog is the pointer to OptionsDialog
4318PlottingPage::PlottingPage(OptionsDialog *pOptionsDialog)
4319 : QWidget(pOptionsDialog)
4320{
4321 mpOptionsDialog = pOptionsDialog;
4322 // general groupbox
4323 mpGeneralGroupBox = new QGroupBox(Helper::general);
4324 // auto scale
4325 mpAutoScaleCheckBox = new QCheckBox(tr("Auto Scale"));
4326 mpAutoScaleCheckBox->setToolTip(tr("Auto scale the plot to fit in view when variable is plotted."));
4327 // set general groupbox layout
4328 QGridLayout *pGeneralGroupBoxLayout = new QGridLayout;
4329 pGeneralGroupBoxLayout->addWidget(mpAutoScaleCheckBox, 0, 0);
4330 mpGeneralGroupBox->setLayout(pGeneralGroupBoxLayout);
4331 // Plotting View Mode
4332 mpPlottingViewModeGroupBox = new QGroupBox(tr("Default Plotting View Mode"));
4333 mpPlottingTabbedViewRadioButton = new QRadioButton(tr("Tabbed View"));
4334 mpPlottingTabbedViewRadioButton->setChecked(true);
4335 mpPlottingSubWindowViewRadioButton = new QRadioButton(tr("SubWindow View"));
4336 QButtonGroup *pPlottingViewModeButtonGroup = new QButtonGroup;
4337 pPlottingViewModeButtonGroup->addButton(mpPlottingTabbedViewRadioButton);
4338 pPlottingViewModeButtonGroup->addButton(mpPlottingSubWindowViewRadioButton);
4339 // plotting view radio buttons layout
4340 QHBoxLayout *pPlottingRadioButtonsLayout = new QHBoxLayout;
4341 pPlottingRadioButtonsLayout->addWidget(mpPlottingTabbedViewRadioButton);
4342 pPlottingRadioButtonsLayout->addWidget(mpPlottingSubWindowViewRadioButton);
4343 // set the layout of plotting view mode group
4344 QGridLayout *pPlottingViewModeLayout = new QGridLayout;
4345 pPlottingViewModeLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
4346 pPlottingViewModeLayout->addLayout(pPlottingRadioButtonsLayout, 0, 0);
4347 mpPlottingViewModeGroupBox->setLayout(pPlottingViewModeLayout);
4348 mpCurveStyleGroupBox = new QGroupBox(Helper::curveStyle);
4349 // Curve Pattern
4350 mpCurvePatternLabel = new Label(Helper::pattern);
4351 mpCurvePatternComboBox = new QComboBox;
4352 mpCurvePatternComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
4353 mpCurvePatternComboBox->addItem("SolidLine", 1);
4354 mpCurvePatternComboBox->addItem("DashLine", 2);
4355 mpCurvePatternComboBox->addItem("DotLine", 3);
4356 mpCurvePatternComboBox->addItem("DashDotLine", 4);
4357 mpCurvePatternComboBox->addItem("DashDotDotLine", 5);
4358 mpCurvePatternComboBox->addItem("Sticks", 6);
4359 mpCurvePatternComboBox->addItem("Steps", 7);
4360 // Curve Thickness
4361 mpCurveThicknessLabel = new Label(Helper::thickness);
4362 mpCurveThicknessSpinBox = new DoubleSpinBox;
4363 mpCurveThicknessSpinBox->setRange(0, std::numeric_limits<double>::max());
4364 mpCurveThicknessSpinBox->setValue(1);
4365 mpCurveThicknessSpinBox->setSingleStep(1);
4366 // set the layout
4367 QGridLayout *pCurveStyleLayout = new QGridLayout;
4368 pCurveStyleLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
4369 pCurveStyleLayout->addWidget(new Label(tr("Curve styles are used for new curves. Use plot setup window to update the existing curves.")), 0, 0, 1, 2);
4370 pCurveStyleLayout->addWidget(mpCurvePatternLabel, 1, 0);
4371 pCurveStyleLayout->addWidget(mpCurvePatternComboBox, 1, 1);
4372 pCurveStyleLayout->addWidget(mpCurveThicknessLabel, 2, 0);
4373 pCurveStyleLayout->addWidget(mpCurveThicknessSpinBox, 2, 1);
4374 mpCurveStyleGroupBox->setLayout(pCurveStyleLayout);
4375 // variable filter interval
4376 mpVariableFilterGroupBox = new QGroupBox(tr("Variable Filter"));
4377 mpFilterIntervalHelpLabel = new Label(tr("Adds a delay, specified as Filter Interval, in filtering the variables.\n"
4378 "Set the value to 0 if you don't want any delay."));
4379 mpFilterIntervalLabel = new Label(tr("Filter Interval:"));
4380 mpFilterIntervalSpinBox = new QSpinBox;
4381 mpFilterIntervalSpinBox->setSuffix(tr(" seconds"));
4382 mpFilterIntervalSpinBox->setRange(0, std::numeric_limits<int>::max());
4383 mpFilterIntervalSpinBox->setValue(2);
4384 mpFilterIntervalSpinBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
4385 // variable filter layout
4386 QGridLayout *pVariableFilterGridLayout = new QGridLayout;
4387 pVariableFilterGridLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
4388 pVariableFilterGridLayout->addWidget(mpFilterIntervalHelpLabel, 0, 0, 1, 2);
4389 pVariableFilterGridLayout->addWidget(mpFilterIntervalLabel, 1, 0);
4390 pVariableFilterGridLayout->addWidget(mpFilterIntervalSpinBox, 1, 1);
4391 mpVariableFilterGroupBox->setLayout(pVariableFilterGridLayout);
4392 // font size
4393 mpFontSizeGroupBox = new QGroupBox(tr("Font Size"));
4394 mpTitleFontSizeLabel = new Label("Title:");
4395 mpTitleFontSizeSpinBox = new DoubleSpinBox;
4396 mpTitleFontSizeSpinBox->setRange(6, std::numeric_limits<double>::max());
4397 mpTitleFontSizeSpinBox->setValue(14);
4398 mpTitleFontSizeSpinBox->setSingleStep(1);
4399 mpTitleFontSizeSpinBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
4400 mpVerticalAxisTitleFontSizeLabel = new Label("Vertical Axis Title:");
4401 mpVerticalAxisTitleFontSizeSpinBox = new DoubleSpinBox;
4402 mpVerticalAxisTitleFontSizeSpinBox->setRange(6, std::numeric_limits<double>::max());
4403 mpVerticalAxisTitleFontSizeSpinBox->setValue(11);
4404 mpVerticalAxisTitleFontSizeSpinBox->setSingleStep(1);
4405 mpVerticalAxisNumbersFontSizeLabel = new Label("Vertical Axis Numbers:");
4406 mpVerticalAxisNumbersFontSizeSpinBox = new DoubleSpinBox;
4407 mpVerticalAxisNumbersFontSizeSpinBox->setRange(6, std::numeric_limits<double>::max());
4408 mpVerticalAxisNumbersFontSizeSpinBox->setValue(10);
4409 mpVerticalAxisNumbersFontSizeSpinBox->setSingleStep(1);
4410 mpHorizontalAxisTitleFontSizeLabel = new Label("Horizontal Axis Title:");
4411 mpHorizontalAxisTitleFontSizeSpinBox = new DoubleSpinBox;
4412 mpHorizontalAxisTitleFontSizeSpinBox->setRange(6, std::numeric_limits<double>::max());
4413 mpHorizontalAxisTitleFontSizeSpinBox->setValue(11);
4414 mpHorizontalAxisTitleFontSizeSpinBox->setSingleStep(1);
4415 mpHorizontalAxisNumbersFontSizeLabel = new Label("Horizontal Axis Numbers:");
4416 mpHorizontalAxisNumbersFontSizeSpinBox = new DoubleSpinBox;
4417 mpHorizontalAxisNumbersFontSizeSpinBox->setRange(6, std::numeric_limits<double>::max());
4418 mpHorizontalAxisNumbersFontSizeSpinBox->setValue(10);
4419 mpHorizontalAxisNumbersFontSizeSpinBox->setSingleStep(1);
4420 mpFooterFontSizeLabel = new Label("Footer:");
4421 mpFooterFontSizeSpinBox = new DoubleSpinBox;
4422 mpFooterFontSizeSpinBox->setRange(6, std::numeric_limits<double>::max());
4423 mpFooterFontSizeSpinBox->setValue(QApplication::font().pointSizeF());
4424 mpFooterFontSizeSpinBox->setSingleStep(1);
4425 mpLegendFontSizeLabel = new Label("Legend:");
4426 mpLegendFontSizeSpinBox = new DoubleSpinBox;
4427 mpLegendFontSizeSpinBox->setRange(6, std::numeric_limits<double>::max());
4428 mpLegendFontSizeSpinBox->setValue(QApplication::font().pointSizeF());
4429 mpLegendFontSizeSpinBox->setSingleStep(1);
4430 // font size layout
4431 QGridLayout *pFontSizeGridLayout = new QGridLayout;
4432 pFontSizeGridLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
4433 pFontSizeGridLayout->addWidget(new Label(tr("Font sizes are used for new plot windows. Use plot setup window to update the existing plots.")), 0, 0, 1, 2);
4434 pFontSizeGridLayout->addWidget(mpTitleFontSizeLabel, 1, 0);
4435 pFontSizeGridLayout->addWidget(mpTitleFontSizeSpinBox, 1, 1);
4436 pFontSizeGridLayout->addWidget(mpVerticalAxisTitleFontSizeLabel, 2, 0);
4437 pFontSizeGridLayout->addWidget(mpVerticalAxisTitleFontSizeSpinBox, 2, 1);
4438 pFontSizeGridLayout->addWidget(mpVerticalAxisNumbersFontSizeLabel, 3, 0);
4439 pFontSizeGridLayout->addWidget(mpVerticalAxisNumbersFontSizeSpinBox, 3, 1);
4440 pFontSizeGridLayout->addWidget(mpHorizontalAxisTitleFontSizeLabel, 4, 0);
4441 pFontSizeGridLayout->addWidget(mpHorizontalAxisTitleFontSizeSpinBox, 4, 1);
4442 pFontSizeGridLayout->addWidget(mpHorizontalAxisNumbersFontSizeLabel, 5, 0);
4443 pFontSizeGridLayout->addWidget(mpHorizontalAxisNumbersFontSizeSpinBox, 5, 1);
4444 int index = 6;
4445#if QWT_VERSION0x060200 > 0x060000
4446 pFontSizeGridLayout->addWidget(mpFooterFontSizeLabel, index, 0);
4447 pFontSizeGridLayout->addWidget(mpFooterFontSizeSpinBox, index++, 1);
4448#endif
4449 pFontSizeGridLayout->addWidget(mpLegendFontSizeLabel, index, 0);
4450 pFontSizeGridLayout->addWidget(mpLegendFontSizeSpinBox, index, 1);
4451 mpFontSizeGroupBox->setLayout(pFontSizeGridLayout);
4452 // main layout
4453 QVBoxLayout *pMainLayout = new QVBoxLayout;
4454 pMainLayout->setAlignment(Qt::AlignTop);
4455 pMainLayout->setContentsMargins(0, 0, 0, 0);
4456 pMainLayout->addWidget(mpGeneralGroupBox);
4457 pMainLayout->addWidget(mpPlottingViewModeGroupBox);
4458 pMainLayout->addWidget(mpCurveStyleGroupBox);
4459 pMainLayout->addWidget(mpVariableFilterGroupBox);
4460 pMainLayout->addWidget(mpFontSizeGroupBox);
4461 setLayout(pMainLayout);
4462}
4463
4464
4465/*!
4466 * \brief PlottingPage::setPlottingViewMode
4467 * Sets the plotting view mode.
4468 * \param value
4469 */
4470void PlottingPage::setPlottingViewMode(QString value)
4471{
4472 if (value.compare(Helper::subWindow) == 0) {
4473 mpPlottingSubWindowViewRadioButton->setChecked(true);
4474 } else {
4475 mpPlottingTabbedViewRadioButton->setChecked(true);
4476 }
4477}
4478
4479/*!
4480 * \brief PlottingPage::getPlottingViewMode
4481 * Gets the plotting view mode.
4482 * \return
4483 */
4484QString PlottingPage::getPlottingViewMode()
4485{
4486 if (mpPlottingSubWindowViewRadioButton->isChecked()) {
4487 return Helper::subWindow;
4488 } else {
4489 return Helper::tabbed;
4490 }
4491}
4492
4493//! Sets the pen pattern
4494//! @param pattern to set.
4495void PlottingPage::setCurvePattern(int pattern)
4496{
4497 int index = mpCurvePatternComboBox->findData(pattern);
4498 if (index != -1)
4499 mpCurvePatternComboBox->setCurrentIndex(index);
4500}
4501
4502int PlottingPage::getCurvePattern()
4503{
4504 return mpCurvePatternComboBox->itemData(mpCurvePatternComboBox->currentIndex()).toInt();
4505}
4506
4507//! Sets the pen thickness
4508//! @param thickness to set.
4509void PlottingPage::setCurveThickness(qreal thickness)
4510{
4511 if (thickness <= 0)
4512 thickness = 1.0;
4513 mpCurveThicknessSpinBox->setValue(thickness);
4514}
4515
4516//! Returns the pen thickness
4517qreal PlottingPage::getCurveThickness()
4518{
4519 return mpCurveThicknessSpinBox->value();
4520}
4521
4522//! @class FigaroPage
4523//! @brief Creates an interface for Figaro settings.
4524
4525//! Constructor
4526//! @param pOptionsDialog is the pointer to OptionsDialog
4527FigaroPage::FigaroPage(OptionsDialog *pOptionsDialog)
4528 : QWidget(pOptionsDialog)
4529{
4530 mpOptionsDialog = pOptionsDialog;
4531 mpFigaroGroupBox = new QGroupBox(Helper::figaro);
4532 // Figaro database file
4533 mpFigaroDatabaseFileLabel = new Label(tr("Figaro Library:"));
4534 mpFigaroDatabaseFileTextBox = new QLineEdit;
4535 mpBrowseFigaroDatabaseFileButton = new QPushButton(Helper::browse);
4536 mpBrowseFigaroDatabaseFileButton->setAutoDefault(false);
4537 connect(mpBrowseFigaroDatabaseFileButton, SIGNAL(clicked())"2""clicked()", SLOT(browseFigaroLibraryFile())"1""browseFigaroLibraryFile()");
4538 // Figaro options file
4539 mpFigaroOptionsFileLabel = new Label(tr("Tree generation options:"));
4540 mpFigaroOptionsFileTextBox = new QLineEdit;
4541 mpBrowseFigaroOptionsFileButton = new QPushButton(Helper::browse);
4542 mpBrowseFigaroOptionsFileButton->setAutoDefault(false);
4543 connect(mpBrowseFigaroOptionsFileButton, SIGNAL(clicked())"2""clicked()", SLOT(browseFigaroOptionsFile())"1""browseFigaroOptionsFile()");
4544 // figaro process
4545 mpFigaroProcessLabel = new Label(tr("Figaro Processor:"));
4546 mFigaroProcessPath = QString(Helper::OpenModelicaHome).append("/share/jEdit4.5_VisualFigaro/VisualFigaro/figp.exe");
4547 mpFigaroProcessTextBox = new QLineEdit(mFigaroProcessPath);
4548 mpBrowseFigaroProcessButton = new QPushButton(Helper::browse);
4549 mpBrowseFigaroProcessButton->setAutoDefault(false);
4550 connect(mpBrowseFigaroProcessButton, SIGNAL(clicked())"2""clicked()", SLOT(browseFigaroProcessFile())"1""browseFigaroProcessFile()");
4551 mpResetFigaroProcessButton = new QPushButton(Helper::reset);
4552 mpResetFigaroProcessButton->setToolTip(tr("Resets to default Figaro Processor path"));
4553 mpResetFigaroProcessButton->setAutoDefault(false);
4554 connect(mpResetFigaroProcessButton, SIGNAL(clicked())"2""clicked()", SLOT(resetFigaroProcessPath())"1""resetFigaroProcessPath()");
4555 // set the layout
4556 QGridLayout *pFigaroLayout = new QGridLayout;
4557 pFigaroLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
4558 pFigaroLayout->addWidget(mpFigaroDatabaseFileLabel, 0, 0);
4559 pFigaroLayout->addWidget(mpFigaroDatabaseFileTextBox, 0, 1, 1, 2);
4560 pFigaroLayout->addWidget(mpBrowseFigaroDatabaseFileButton, 0, 3);
4561 pFigaroLayout->addWidget(mpFigaroOptionsFileLabel, 1, 0);
4562 pFigaroLayout->addWidget(mpFigaroOptionsFileTextBox, 1, 1, 1, 2);
4563 pFigaroLayout->addWidget(mpBrowseFigaroOptionsFileButton, 1, 3);
4564 pFigaroLayout->addWidget(mpFigaroProcessLabel, 2, 0);
4565 pFigaroLayout->addWidget(mpFigaroProcessTextBox, 2, 1);
4566 pFigaroLayout->addWidget(mpBrowseFigaroProcessButton, 2, 2);
4567 pFigaroLayout->addWidget(mpResetFigaroProcessButton, 2, 3);
4568 mpFigaroGroupBox->setLayout(pFigaroLayout);
4569 QVBoxLayout *pMainLayout = new QVBoxLayout;
4570 pMainLayout->setAlignment(Qt::AlignTop);
4571 pMainLayout->setContentsMargins(0, 0, 0, 0);
4572 pMainLayout->addWidget(mpFigaroGroupBox);
4573 setLayout(pMainLayout);
4574}
4575
4576void FigaroPage::browseFigaroLibraryFile()
4577{
4578 mpFigaroDatabaseFileTextBox->setText(StringHandler::getOpenFileName(this, QString(Helper::applicationName).append(" - ").append(Helper::chooseFile),
4579 NULL__null, Helper::figaroFileTypes, NULL__null));
4580}
4581
4582void FigaroPage::browseFigaroOptionsFile()
4583{
4584 mpFigaroOptionsFileTextBox->setText(StringHandler::getOpenFileName(this, QString(Helper::applicationName).append(" - ").append(Helper::chooseFile),
4585 NULL__null, Helper::xmlFileTypes, NULL__null));
4586}
4587
4588void FigaroPage::browseFigaroProcessFile()
4589{
4590 mpFigaroProcessTextBox->setText(StringHandler::getOpenFileName(this, QString(Helper::applicationName).append(" - ").append(Helper::chooseFile),
4591 NULL__null, Helper::exeFileTypes, NULL__null));
4592}
4593
4594/*!
4595 * \brief FigaroPage::resetFigaroProcessPath
4596 * Resets the figaro process path to default.
4597 */
4598void FigaroPage::resetFigaroProcessPath()
4599{
4600 mpFigaroProcessTextBox->setText(mFigaroProcessPath);
4601}
4602
4603/*!
4604 \class DebuggerPage
4605 \brief Creates an interface for debugger settings.
4606 */
4607/*!
4608 \param pParent - pointer to OptionsDialog
4609 */
4610DebuggerPage::DebuggerPage(OptionsDialog *pOptionsDialog)
4611 : QWidget(pOptionsDialog)
4612{
4613 mpOptionsDialog = pOptionsDialog;
4614 mpAlgorithmicDebuggerGroupBox = new QGroupBox(Helper::algorithmicDebugger);
4615 // GDB Path
4616 mpGDBPathLabel = new Label(tr("GDB Path:"));
4617 mpGDBPathTextBox = new QLineEdit;
4618#ifdef WIN32
4619 mpGDBPathTextBox->setPlaceholderText(Utilities::getGDBPath());
4620#else
4621 mpGDBPathTextBox->setPlaceholderText("gdb");
4622#endif
4623 mpGDBPathBrowseButton = new QPushButton(Helper::browse);
4624 mpGDBPathBrowseButton->setAutoDefault(false);
4625 connect(mpGDBPathBrowseButton, SIGNAL(clicked())"2""clicked()", SLOT(browseGDBPath())"1""browseGDBPath()");
4626 /* GDB Command Timeout */
4627 mpGDBCommandTimeoutLabel = new Label(tr("GDB Command Timeout:"));
4628 mpGDBCommandTimeoutSpinBox = new QSpinBox;
4629 mpGDBCommandTimeoutSpinBox->setSuffix(tr(" seconds"));
4630 mpGDBCommandTimeoutSpinBox->setRange(30, std::numeric_limits<int>::max());
4631 mpGDBCommandTimeoutSpinBox->setSingleStep(10);
4632 mpGDBCommandTimeoutSpinBox->setValue(40);
4633 /* GDB Output limit */
4634 mpGDBOutputLimitLabel = new Label(tr("GDB Output Limit:"));
4635 mpGDBOutputLimitSpinBox = new QSpinBox;
4636 mpGDBOutputLimitSpinBox->setSuffix(tr(" characters"));
4637 mpGDBOutputLimitSpinBox->setSpecialValueText(Helper::unlimited);
4638 mpGDBOutputLimitSpinBox->setRange(0, std::numeric_limits<int>::max());
4639 mpGDBOutputLimitSpinBox->setSingleStep(10);
4640 // Display C Frames
4641 mpDisplayCFramesCheckBox = new QCheckBox(tr("Display C frames"));
4642 mpDisplayCFramesCheckBox->setChecked(true);
4643 // Display Unknown Frames
4644 mpDisplayUnknownFramesCheckBox = new QCheckBox(tr("Display unknown frames"));
4645 mpDisplayUnknownFramesCheckBox->setChecked(true);
4646 // clear output on new run
4647 mpClearOutputOnNewRunCheckBox = new QCheckBox(tr("Clear old output on a new run"));
4648 mpClearOutputOnNewRunCheckBox->setChecked(true);
4649 // clear log on new run
4650 mpClearLogOnNewRunCheckBox = new QCheckBox(tr("Clear old log on a new run"));
4651 mpClearLogOnNewRunCheckBox->setChecked(true);
4652 /* set the debugger group box layout */
4653 QGridLayout *pDebuggerLayout = new QGridLayout;
4654 pDebuggerLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
4655 pDebuggerLayout->addWidget(mpGDBPathLabel, 0, 0);
4656 pDebuggerLayout->addWidget(mpGDBPathTextBox, 0, 1);
4657 pDebuggerLayout->addWidget(mpGDBPathBrowseButton, 0, 2);
4658 pDebuggerLayout->addItem(new QSpacerItem(1, 1), 1, 0);
4659 pDebuggerLayout->addWidget(new Label(tr("Default GDB path is used if above field is empty.")), 1, 1, 1, 2);
4660 pDebuggerLayout->addWidget(mpGDBCommandTimeoutLabel, 2, 0);
4661 pDebuggerLayout->addWidget(mpGDBCommandTimeoutSpinBox, 2, 1, 1, 2);
4662 pDebuggerLayout->addWidget(mpGDBOutputLimitLabel, 3, 0);
4663 pDebuggerLayout->addWidget(mpGDBOutputLimitSpinBox, 3, 1, 1, 2);
4664 pDebuggerLayout->addWidget(mpDisplayCFramesCheckBox, 4, 0, 1, 2);
4665 pDebuggerLayout->addWidget(mpDisplayUnknownFramesCheckBox, 5, 0, 1, 2);
4666 pDebuggerLayout->addWidget(mpClearOutputOnNewRunCheckBox, 6, 0, 1, 2);
4667 pDebuggerLayout->addWidget(mpClearLogOnNewRunCheckBox, 7, 0, 1, 2);
4668 mpAlgorithmicDebuggerGroupBox->setLayout(pDebuggerLayout);
4669 /* Transformational Debugger */
4670 mpTransformationalDebuggerGroupBox = new QGroupBox(Helper::transformationalDebugger);
4671 mpAlwaysShowTransformationsCheckBox = new QCheckBox(tr("Always show %1 after compilation").arg(Helper::transformationalDebugger));
4672 mpGenerateOperationsCheckBox = new QCheckBox(tr("Generate Operations"));
4673 // set the layout of Transformational Debugger group
4674 QGridLayout *pTransformationalDebuggerLayout = new QGridLayout;
4675 pTransformationalDebuggerLayout->setAlignment(Qt::AlignTop);
4676 pTransformationalDebuggerLayout->addWidget(mpAlwaysShowTransformationsCheckBox, 0, 0);
4677 pTransformationalDebuggerLayout->addWidget(mpGenerateOperationsCheckBox, 1, 0);
4678 mpTransformationalDebuggerGroupBox->setLayout(pTransformationalDebuggerLayout);
4679 // set the layout
4680 QVBoxLayout *pMainLayout = new QVBoxLayout;
4681 pMainLayout->setAlignment(Qt::AlignTop);
4682 pMainLayout->setContentsMargins(0, 0, 0, 0);
4683 pMainLayout->addWidget(mpAlgorithmicDebuggerGroupBox);
4684 pMainLayout->addWidget(mpTransformationalDebuggerGroupBox);
4685 setLayout(pMainLayout);
4686}
4687
4688/*!
4689 * \brief DebuggerPage::setGDBPath
4690 * Sets the GDB path. Only set the path if its not empty.
4691 * \param path
4692 */
4693void DebuggerPage::setGDBPath(QString path)
4694{
4695 if (!path.isEmpty()) {
4696 mpGDBPathTextBox->setText(path);
4697 }
4698}
4699
4700/*!
4701 * \brief DebuggerPage::getGDBPath
4702 * Returns the GDB path. If path is empty then return the default path which is stored in placeholderText.
4703 * \return
4704 */
4705QString DebuggerPage::getGDBPath()
4706{
4707 if (mpGDBPathTextBox->text().isEmpty()) {
4708 return mpGDBPathTextBox->placeholderText();
4709 } else {
4710 return mpGDBPathTextBox->text();
4711 }
4712}
4713
4714/*!
4715 * \brief DebuggerPage::browseGDBPath
4716 * Browse a path for GDB.
4717 */
4718void DebuggerPage::browseGDBPath()
4719{
4720 QString GDBPath = StringHandler::getOpenFileName(this, QString(Helper::applicationName).append(" - ").append(Helper::chooseFile),
4721 NULL__null, "", NULL__null);
4722 if (GDBPath.isEmpty()) {
4723 return;
4724 }
4725 mpGDBPathTextBox->setText(GDBPath);
4726}
4727
4728/*!
4729 * \class DebuggerPage
4730 * \brief Creates an interface for debugger settings.
4731 */
4732/*!
4733 * \brief FMIPage::FMIPage
4734 * \param pParent - pointer to OptionsDialog
4735 */
4736FMIPage::FMIPage(OptionsDialog *pOptionsDialog)
4737 : QWidget(pOptionsDialog)
4738{
4739 mpOptionsDialog = pOptionsDialog;
4740 mpExportGroupBox = new QGroupBox(Helper::exportt);
4741 // FMI export version
4742 mpVersionGroupBox = new QGroupBox(Helper::version);
4743 mpVersion1RadioButton = new QRadioButton("1.0");
4744 mpVersion2RadioButton = new QRadioButton("2.0");
4745 mpVersion2RadioButton->setChecked(true);
4746 // set the version groupbox layout
4747 QVBoxLayout *pVersionLayout = new QVBoxLayout;
4748 pVersionLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
4749 pVersionLayout->addWidget(mpVersion1RadioButton);
4750 pVersionLayout->addWidget(mpVersion2RadioButton);
4751 mpVersionGroupBox->setLayout(pVersionLayout);
4752 // FMI export type
4753 mpTypeGroupBox = new QGroupBox(Helper::type);
4754 mpModelExchangeRadioButton = new QRadioButton(tr("Model Exchange"));
4755 mpCoSimulationRadioButton = new QRadioButton(tr("Co-Simulation"));
4756 mpModelExchangeCoSimulationRadioButton = new QRadioButton(tr("Model Exchange and Co-Simulation"));
4757 mpModelExchangeCoSimulationRadioButton->setChecked(true);
4758 // set the type groupbox layout
4759 QVBoxLayout *pTypeLayout = new QVBoxLayout;
4760 pTypeLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
4761 pTypeLayout->addWidget(mpModelExchangeRadioButton);
4762 pTypeLayout->addWidget(mpCoSimulationRadioButton);
4763 pTypeLayout->addWidget(mpModelExchangeCoSimulationRadioButton);
4764 mpTypeGroupBox->setLayout(pTypeLayout);
4765 // FMU name prefix
4766 mpFMUNameLabel = new Label(tr("FMU Name:"));
4767 mpFMUNameTextBox = new QLineEdit;
4768 mpFMUNameTextBox->setPlaceholderText("<default>");
4769 // Move FMU after build
4770 mpMoveFMULabel = new Label(tr("Move FMU:"));
4771 mpMoveFMUTextBox = new QLineEdit;
4772 mpMoveFMUTextBox->setPlaceholderText(tr("<directory name or full file name with placeholders>"));
4773 mpBrowseFMUDirectoryButton = new QPushButton(Helper::browse);
4774 mpBrowseFMUDirectoryButton->setAutoDefault(false);
4775 connect(mpBrowseFMUDirectoryButton, SIGNAL(clicked())"2""clicked()", SLOT(selectFMUDirectory())"1""selectFMUDirectory()");
4776 // placeholder count may change, don't invalidate translation
4777 mpMoveFMUTextBox->setToolTip(tr("Placeholders:\n") +
4778 FMIPage::FMU_FULL_CLASS_NAME_DOTS_PLACEHOLDER + tr(" i.e.,") + " Modelica.Electrical.Analog.Examples.ChuaCircuit\n" +
4779 FMIPage::FMU_FULL_CLASS_NAME_UNDERSCORES_PLACEHOLDER + tr(" i.e.,") + " Modelica_Electrical_Analog_Examples_ChuaCircuit\n" +
4780 FMIPage::FMU_SHORT_CLASS_NAME_PLACEHOLDER + tr(" i.e.,") + " ChuaCircuit");
4781#ifdef WIN32
4782 QStringList paths = QString(getenv("PATH")).split(";");
4783#else
4784 QStringList paths = QString(getenv("PATH")).split(":");
4785#endif
4786 QStringList nameFilters;
4787 nameFilters << "*-*-*-*cc";
4788 QStringList compilers;
4789 foreach (QString path, paths)for (auto _container_ = QtPrivate::qMakeForeachContainer(paths
); _container_.control && _container_.i != _container_
.e; ++_container_.i, _container_.control ^= 1) for (QString path
= *_container_.i; _container_.control; _container_.control =
0)
{
4790 QDir dir(path);
4791 compilers << dir.entryList(nameFilters, QDir::Files | QDir::NoDotAndDotDot, QDir::Name);
4792 }
4793 mpPlatformsGroupBox = new QGroupBox(tr("Platforms"));
4794 Label *pPlatformNoteLabel = new Label(tr("Note: The list of platforms is created by searching for programs in the PATH\n"
4795 "matching pattern \"*-*-*-*cc\"."));
4796 mpLinkingComboBox = new QComboBox;
4797 mpLinkingComboBox->addItem(tr("None"), "none");
4798 mpLinkingComboBox->addItem(tr("Dynamic"), "dynamic");
4799 mpLinkingComboBox->addItem(tr("Static"), "static");
4800 mpLinkingComboBox->setCurrentIndex(2);
4801 // set the type groupbox layout
4802 QVBoxLayout *pPlatformsLayout = new QVBoxLayout;
4803 pPlatformsLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
4804 pPlatformsLayout->addWidget(pPlatformNoteLabel);
4805 pPlatformsLayout->addWidget(mpLinkingComboBox);
4806 foreach (QString compiler, compilers)for (auto _container_ = QtPrivate::qMakeForeachContainer(compilers
); _container_.control && _container_.i != _container_
.e; ++_container_.i, _container_.control ^= 1) for (QString compiler
= *_container_.i; _container_.control; _container_.control =
0)
{
4807 QString platformName = compiler.left(compiler.lastIndexOf('-'));
4808 QCheckBox *pCheckBox = new QCheckBox(platformName);
4809 pCheckBox->setProperty(Helper::fmuPlatformNamePropertyId, platformName);
4810 pPlatformsLayout->addWidget(pCheckBox);
4811 }
4812 mpPlatformsGroupBox->setLayout(pPlatformsLayout);
4813 // set the export group box layout
4814 QGridLayout *pExportLayout = new QGridLayout;
4815 pExportLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
4816 pExportLayout->addWidget(mpVersionGroupBox, 0, 0, 1, 3);
4817 pExportLayout->addWidget(mpTypeGroupBox, 1, 0, 1, 3);
4818 pExportLayout->addWidget(mpFMUNameLabel, 2, 0);
4819 pExportLayout->addWidget(mpFMUNameTextBox, 2, 1, 1, 2);
4820 pExportLayout->addWidget(mpMoveFMULabel, 3, 0);
4821 pExportLayout->addWidget(mpMoveFMUTextBox, 3, 1);
4822 pExportLayout->addWidget(mpBrowseFMUDirectoryButton, 3, 2);
4823 pExportLayout->addWidget(mpPlatformsGroupBox, 4, 0, 1, 3);
4824 mpExportGroupBox->setLayout(pExportLayout);
4825 // import groupbox
4826 mpImportGroupBox = new QGroupBox(tr("Import"));
4827 mpDeleteFMUDirectoryAndModelCheckBox = new QCheckBox(tr("Delete FMU directory and generated model when OMEdit is closed"));
4828 // set the import group box layout
4829 QGridLayout *pImportLayout = new QGridLayout;
4830 pImportLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
4831 pImportLayout->addWidget(mpDeleteFMUDirectoryAndModelCheckBox, 0, 0);
4832 mpImportGroupBox->setLayout(pImportLayout);
4833 // set the layout
4834 QVBoxLayout *pMainLayout = new QVBoxLayout;
4835 pMainLayout->setAlignment(Qt::AlignTop);
4836 pMainLayout->setContentsMargins(0, 0, 0, 0);
4837 pMainLayout->addWidget(mpExportGroupBox);
4838 pMainLayout->addWidget(mpImportGroupBox);
4839 setLayout(pMainLayout);
4840}
4841
4842const QString FMIPage::FMU_FULL_CLASS_NAME_DOTS_PLACEHOLDER = "{Full.Name}";
4843const QString FMIPage::FMU_FULL_CLASS_NAME_UNDERSCORES_PLACEHOLDER = "{Full_Name}";
4844const QString FMIPage::FMU_SHORT_CLASS_NAME_PLACEHOLDER = "{shortName}";
4845
4846/*!
4847 * \brief FMIPage::setFMIExportVersion
4848 * Sets the FMI export version
4849 * \param version
4850 */
4851void FMIPage::setFMIExportVersion(QString version)
4852{
4853 if (version == "1.0" || version == "1") {
4854 mpVersion1RadioButton->setChecked(true);
4855 } else {
4856 mpVersion2RadioButton->setChecked(true);
4857 }
4858}
4859
4860/*!
4861 * \brief FMIPage::getFMIExportVersion
4862 * Gets the FMI export version
4863 * \return
4864 */
4865QString FMIPage::getFMIExportVersion()
4866{
4867 if (mpVersion1RadioButton->isChecked()) {
4868 return "1.0";
4869 } else {
4870 return "2.0";
4871 }
4872}
4873
4874/*!
4875 * \brief FMIPage::setFMIExportType
4876 * Sets the FMI export type
4877 * \param type
4878 */
4879void FMIPage::setFMIExportType(QString type)
4880{
4881 if (type.compare("me") == 0) {
4882 mpModelExchangeRadioButton->setChecked(true);
4883 } else if (type.compare("cs") == 0) {
4884 mpCoSimulationRadioButton->setChecked(true);
4885 } else {
4886 mpModelExchangeCoSimulationRadioButton->setChecked(true);
4887 }
4888}
4889
4890/*!
4891 * \brief FMIPage::getFMIExportType
4892 * Gets the FMI export type
4893 * \return
4894 */
4895QString FMIPage::getFMIExportType()
4896{
4897 if (mpModelExchangeRadioButton->isChecked()) {
4898 return "me";
4899 } else if (mpCoSimulationRadioButton->isChecked()) {
4900 return "cs";
4901 } else {
4902 return "me_cs";
4903 }
4904}
4905
4906void FMIPage::selectFMUDirectory()
4907{
4908 mpMoveFMUTextBox->setText(StringHandler::getExistingDirectory(this, QString("%1 - %2").arg(Helper::applicationName)
4909 .arg(Helper::chooseDirectory), NULL__null));
4910}
4911
4912/*!
4913 * \class TLMPage
4914 * Creates an interface for TLM settings.
4915 */
4916TLMPage::TLMPage(OptionsDialog *pOptionsDialog)
4917 : QWidget(pOptionsDialog)
4918{
4919 mpOptionsDialog = pOptionsDialog;
4920 mpGeneralGroupBox = new QGroupBox(Helper::general);
4921 // TLM Plugin Path
4922 mpTLMPluginPathLabel = new Label(tr("Path:"));
4923 mpTLMPluginPathTextBox = new QLineEdit;
4924 mpTLMPluginPathTextBox->setPlaceholderText(QString("%1/OMTLMSimulator/bin").arg(Helper::OpenModelicaHome));
4925 mpBrowseTLMPluginPathButton = new QPushButton(Helper::browse);
4926 mpBrowseTLMPluginPathButton->setAutoDefault(false);
4927 connect(mpBrowseTLMPluginPathButton, SIGNAL(clicked())"2""clicked()", SLOT(browseTLMPluginPath())"1""browseTLMPluginPath()");
4928 // TLM Manager Process
4929 mpTLMManagerProcessLabel = new Label(tr("Manager Process:"));
4930 mpTLMManagerProcessTextBox = new QLineEdit;
4931 mpTLMManagerProcessTextBox->setPlaceholderText(QString("%1/OMTLMSimulator/bin/tlmmanager").arg(Helper::OpenModelicaHome));
4932 mpBrowseTLMManagerProcessButton = new QPushButton(Helper::browse);
4933 mpBrowseTLMManagerProcessButton->setAutoDefault(false);
4934 connect(mpBrowseTLMManagerProcessButton, SIGNAL(clicked())"2""clicked()", SLOT(browseTLMManagerProcess())"1""browseTLMManagerProcess()");
4935 // TLM Monitor Process
4936 mpTLMMonitorProcessLabel = new Label(tr("Monitor Process:"));
4937 mpTLMMonitorProcessTextBox = new QLineEdit;
4938 mpTLMMonitorProcessTextBox->setPlaceholderText(QString("%1/OMTLMSimulator/bin/tlmmonitor").arg(Helper::OpenModelicaHome));
4939 mpBrowseTLMMonitorProcessButton = new QPushButton(Helper::browse);
4940 mpBrowseTLMMonitorProcessButton->setAutoDefault(false);
4941 connect(mpBrowseTLMMonitorProcessButton, SIGNAL(clicked())"2""clicked()", SLOT(browseTLMMonitorProcess())"1""browseTLMMonitorProcess()");
4942 // set the layout
4943 QGridLayout *pGeneralGroupBoxLayout = new QGridLayout;
4944 pGeneralGroupBoxLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
4945 pGeneralGroupBoxLayout->addWidget(mpTLMPluginPathLabel, 0, 0);
4946 pGeneralGroupBoxLayout->addWidget(mpTLMPluginPathTextBox, 0, 1);
4947 pGeneralGroupBoxLayout->addWidget(mpBrowseTLMPluginPathButton, 0, 2);
4948 pGeneralGroupBoxLayout->addWidget(mpTLMManagerProcessLabel, 1, 0);
4949 pGeneralGroupBoxLayout->addWidget(mpTLMManagerProcessTextBox, 1, 1);
4950 pGeneralGroupBoxLayout->addWidget(mpBrowseTLMManagerProcessButton, 1, 2);
4951 pGeneralGroupBoxLayout->addWidget(mpTLMMonitorProcessLabel, 3, 0);
4952 pGeneralGroupBoxLayout->addWidget(mpTLMMonitorProcessTextBox, 3, 1);
4953 pGeneralGroupBoxLayout->addWidget(mpBrowseTLMMonitorProcessButton, 3, 2);
4954 pGeneralGroupBoxLayout->addWidget(new Label(tr("* Default OMTLMSimulator paths are used if above field are empty.")), 4, 0, 1, 3);
4955 mpGeneralGroupBox->setLayout(pGeneralGroupBoxLayout);
4956 QVBoxLayout *pMainLayout = new QVBoxLayout;
4957 pMainLayout->setAlignment(Qt::AlignTop);
4958 pMainLayout->setContentsMargins(0, 0, 0, 0);
4959 pMainLayout->addWidget(mpGeneralGroupBox);
4960 setLayout(pMainLayout);
4961}
4962
4963/*!
4964 * \brief TLMPage::getOMTLMSimulatorPath
4965 * Returns the OMTLMSimulator path.
4966 * \return
4967 */
4968QString TLMPage::getOMTLMSimulatorPath()
4969{
4970 if (mpTLMPluginPathTextBox->text().isEmpty()) {
4971 return mpTLMPluginPathTextBox->placeholderText();
4972 } else {
4973 return mpTLMPluginPathTextBox->text();
4974 }
4975}
4976
4977/*!
4978 * \brief TLMPage::getOMTLMSimulatorManagerPath
4979 * Returns the OMTLMSimulator manager path.
4980 * \return
4981 */
4982QString TLMPage::getOMTLMSimulatorManagerPath()
4983{
4984 if (mpTLMManagerProcessTextBox->text().isEmpty()) {
4985 return mpTLMManagerProcessTextBox->placeholderText();
4986 } else {
4987 return mpTLMManagerProcessTextBox->text();
4988 }
4989}
4990
4991/*!
4992 * \brief TLMPage::getOMTLMSimulatorMonitorPath
4993 * Returns the OMTLMSimulator monitor path.
4994 * \return
4995 */
4996QString TLMPage::getOMTLMSimulatorMonitorPath()
4997{
4998 if (mpTLMMonitorProcessTextBox->text().isEmpty()) {
4999 return mpTLMMonitorProcessTextBox->placeholderText();
5000 } else {
5001 return mpTLMMonitorProcessTextBox->text();
5002 }
5003}
5004
5005/*!
5006 * \brief TLMPage::browseTLMPath
5007 * Browse TLM path.
5008 */
5009void TLMPage::browseTLMPluginPath()
5010{
5011 QString path = StringHandler::getExistingDirectory(this, QString(Helper::applicationName).append(" - ").append(Helper::chooseDirectory), NULL__null);
5012 path = path.replace('\\', '/');
5013 mpTLMPluginPathTextBox->setText(path);
5014 if (mpTLMManagerProcessTextBox->text().isEmpty()) {
5015#ifdef WIN32
5016 mpTLMManagerProcessTextBox->setText(mpTLMPluginPathTextBox->text() + "/tlmmanager.exe");
5017#else
5018 mpTLMManagerProcessTextBox->setText(mpTLMPluginPathTextBox->text() + "/tlmmanager");
5019#endif
5020 }
5021 if (mpTLMMonitorProcessTextBox->text().isEmpty()) {
5022#ifdef WIN32
5023 mpTLMMonitorProcessTextBox->setText(mpTLMPluginPathTextBox->text() + "/tlmmonitor.exe");
5024#else
5025 mpTLMMonitorProcessTextBox->setText(mpTLMPluginPathTextBox->text() + "/tlmmonitor");
5026#endif
5027 }
5028}
5029
5030/*!
5031 * \brief TLMPage::browseTLMManagerProcess
5032 * Browse TLM Manager Process.
5033 */
5034void TLMPage::browseTLMManagerProcess()
5035{
5036 mpTLMManagerProcessTextBox->setText(StringHandler::getOpenFileName(this, QString(Helper::applicationName).append(" - ").append(Helper::chooseFile),
5037 NULL__null, Helper::exeFileTypes, NULL__null));
5038}
5039
5040/*!
5041 * \brief TLMPage::browseTLMMonitorProcess
5042 * Browse TLM Monitor Process.
5043 */
5044void TLMPage::browseTLMMonitorProcess()
5045{
5046 mpTLMMonitorProcessTextBox->setText(StringHandler::getOpenFileName(this, QString(Helper::applicationName).append(" - ").append(Helper::chooseFile),
5047 NULL__null, Helper::exeFileTypes, NULL__null));
5048}
5049
5050/*!
5051 * \class OMSimulatorPage
5052 * Creates an interface for OMSimulator settings.
5053 */
5054/*!
5055 * \brief OMSimulatorPage::OMSimulatorPage
5056 * \param pOptionsDialog
5057 */
5058OMSimulatorPage::OMSimulatorPage(OptionsDialog *pOptionsDialog)
5059 : QWidget(pOptionsDialog)
5060{
5061 mpOptionsDialog = pOptionsDialog;
5062 mpGeneralGroupBox = new QGroupBox(Helper::general);
5063 // command line options
5064 mpCommandLineOptionsLabel = new Label(tr("Command Line Options:"));
5065 mpCommandLineOptionsTextBox = new QLineEdit("--suppressPath=true");
5066 mpCommandLineOptionsTextBox->setToolTip(tr("Space separated list of command line options e.g., --suppressPath=true --ignoreInitialUnknowns=true"));
5067 // working directory
5068 mpWorkingDirectoryLabel = new Label(Helper::workingDirectory);
5069 mpWorkingDirectoryTextBox = new QLineEdit(Utilities::tempDirectory());
5070 mpBrowseWorkingDirectoryButton = new QPushButton(Helper::browse);
5071 mpBrowseWorkingDirectoryButton->setAutoDefault(false);
5072 connect(mpBrowseWorkingDirectoryButton, SIGNAL(clicked())"2""clicked()", SLOT(browseWorkingDirectory())"1""browseWorkingDirectory()");
5073 // logging level
5074 mpLoggingLevelLabel = new Label(tr("Logging Level:"));
5075 mpLoggingLevelComboBox = new QComboBox;
5076 mpLoggingLevelComboBox->addItem("default", QVariant(0));
5077 mpLoggingLevelComboBox->addItem("default+debug", QVariant(1));
5078 mpLoggingLevelComboBox->addItem("default+debug+trace", QVariant(2));
5079 // set the layout
5080 QGridLayout *pGeneralGroupBoxLayout = new QGridLayout;
5081 pGeneralGroupBoxLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
5082 pGeneralGroupBoxLayout->addWidget(mpCommandLineOptionsLabel, 0, 0);
5083 pGeneralGroupBoxLayout->addWidget(mpCommandLineOptionsTextBox, 0, 1, 1, 2);
5084 pGeneralGroupBoxLayout->addWidget(mpWorkingDirectoryLabel, 1, 0);
5085 pGeneralGroupBoxLayout->addWidget(mpWorkingDirectoryTextBox, 1, 1);
5086 pGeneralGroupBoxLayout->addWidget(mpBrowseWorkingDirectoryButton, 1, 2);
5087 pGeneralGroupBoxLayout->addWidget(mpLoggingLevelLabel, 2, 0);
5088 pGeneralGroupBoxLayout->addWidget(mpLoggingLevelComboBox, 2, 1, 1, 2);
5089 mpGeneralGroupBox->setLayout(pGeneralGroupBoxLayout);
5090 QVBoxLayout *pMainLayout = new QVBoxLayout;
5091 pMainLayout->setAlignment(Qt::AlignTop);
5092 pMainLayout->setContentsMargins(0, 0, 0, 0);
5093 pMainLayout->addWidget(mpGeneralGroupBox);
5094 setLayout(pMainLayout);
5095}
5096
5097/*!
5098 * \brief OMSimulatorPage::browseWorkingDirectory
5099 * Slot activated when mpBrowseWorkingDirectoryButton clicked signal is raised.
5100 * Allows user to choose a new working directory.
5101 */
5102void OMSimulatorPage::browseWorkingDirectory()
5103{
5104 mpWorkingDirectoryTextBox->setText(StringHandler::getExistingDirectory(this, QString("%1 - %2").arg(Helper::applicationName)
5105 .arg(Helper::chooseDirectory), NULL__null));
5106}
5107
5108/*!
5109 * \class TraceabilityPage
5110 * Creates an interface for Traceability settings.
5111 */
5112TraceabilityPage::TraceabilityPage(OptionsDialog *pOptionsDialog)
5113 : QWidget(pOptionsDialog)
5114{
5115 mpOptionsDialog = pOptionsDialog;
5116 mpTraceabilityGroupBox = new QGroupBox(tr("Traceability"));
5117 mpTraceabilityGroupBox->setCheckable(true);
5118 mpTraceabilityGroupBox->setChecked(false);
5119 // User name
5120 mpUserNameLabel = new Label(tr("User Name:"));
5121 mpUserNameTextBox = new QLineEdit;
5122 // Email
5123 mpEmailLabel = new Label(tr("Email:"));
5124 mpEmailTextBox = new QLineEdit;
5125 // Git repository
5126 mpGitRepositoryLabel = new Label(tr("Git Repository:"));
5127 mpGitRepositoryTextBox = new QLineEdit;
5128 mpBrowseGitRepositoryButton = new QPushButton(Helper::browse);
5129 mpBrowseGitRepositoryButton->setAutoDefault(false);
5130 connect(mpBrowseGitRepositoryButton, SIGNAL(clicked())"2""clicked()", SLOT(browseGitRepository())"1""browseGitRepository()");
5131 // Traceability Daemon Ip Adress
5132 mpTraceabilityDaemonIpAdressLabel = new Label(tr("Traceability Daemon IP Adress:"));
5133 mpTraceabilityDaemonIpAdressTextBox = new QLineEdit;
5134 // Traceability Daemon Port
5135 mpTraceabilityDaemonPortLabel = new Label(tr("Traceability Daemon Port:"));
5136 mpTraceabilityDaemonPortTextBox = new QLineEdit;
5137 // set the layout
5138 QGridLayout *pTraceabilityGroupBoxLayout = new QGridLayout;
5139 pTraceabilityGroupBoxLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
5140 pTraceabilityGroupBoxLayout->addWidget(mpUserNameLabel, 0, 0);
5141 pTraceabilityGroupBoxLayout->addWidget(mpUserNameTextBox, 0, 1);
5142 pTraceabilityGroupBoxLayout->addWidget(mpEmailLabel, 1, 0);
5143 pTraceabilityGroupBoxLayout->addWidget(mpEmailTextBox, 1, 1);
5144 pTraceabilityGroupBoxLayout->addWidget(mpGitRepositoryLabel, 2, 0);
5145 pTraceabilityGroupBoxLayout->addWidget(mpGitRepositoryTextBox, 2, 1);
5146 pTraceabilityGroupBoxLayout->addWidget(mpBrowseGitRepositoryButton, 2, 2);
5147 pTraceabilityGroupBoxLayout->addWidget(mpTraceabilityDaemonIpAdressLabel, 3, 0);
5148 pTraceabilityGroupBoxLayout->addWidget(mpTraceabilityDaemonIpAdressTextBox, 3, 1);
5149 pTraceabilityGroupBoxLayout->addWidget(mpTraceabilityDaemonPortLabel, 4, 0);
5150 pTraceabilityGroupBoxLayout->addWidget(mpTraceabilityDaemonPortTextBox, 4, 1);
5151 mpTraceabilityGroupBox->setLayout(pTraceabilityGroupBoxLayout);
5152 QVBoxLayout *pMainLayout = new QVBoxLayout;
5153 pMainLayout->setAlignment(Qt::AlignTop);
5154 pMainLayout->setContentsMargins(0, 0, 0, 0);
5155 pMainLayout->addWidget(mpTraceabilityGroupBox);
5156 setLayout(pMainLayout);
5157}
5158
5159/*!
5160 * \brief TraceabilityPage::browseFMUOutputDirectory
5161 * Browse FMU Output Directory.
5162 */
5163//void TraceabilityPage::browseFMUOutputDirectory()
5164//{
5165// mpFMUOutputDirectoryTextBox->setText(StringHandler::getExistingDirectory(this, QString("%1 - %2").arg(Helper::applicationName)
5166// .arg(Helper::chooseDirectory), NULL));
5167//}
5168
5169/*!
5170 * \brief TraceabilityPage::browseFMUOutputDirectory
5171 * Browse FMU Output Directory.
5172 */
5173void TraceabilityPage::browseGitRepository()
5174{
5175 mpGitRepositoryTextBox->setText(StringHandler::getExistingDirectory(this, QString("%1 - %2").arg(Helper::applicationName)
5176 .arg(Helper::chooseDirectory), NULL__null));
5177}