-
Notifications
You must be signed in to change notification settings - Fork 298
/
OptionsDialog.cpp
3915 lines (3701 loc) · 166 KB
/
OptionsDialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-2014, Open Source Modelica Consortium (OSMC),
* c/o Linköpings universitet, Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR
* THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
* RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3,
* ACCORDING TO RECIPIENTS CHOICE.
*
* The OpenModelica software and the Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from OSMC, either from the above address,
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
* http://www.openmodelica.org, and in the OpenModelica distribution.
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
*/
/*
*
* @author Adeel Asghar <adeel.asghar@liu.se>
*
* RCS: $Id$
*
*/
#include "OptionsDialog.h"
#include <limits>
//! @class OptionsDialog
//! @brief Creates an interface with options like Modelica Text, Pen Styles, Libraries etc.
//! Constructor
//! @param pMainWindow is the pointer to MainWindow
OptionsDialog::OptionsDialog(MainWindow *pMainWindow)
: QDialog(pMainWindow, Qt::WindowTitleHint), mpSettings(OpenModelica::getApplicationSettings())
{
setWindowTitle(QString(Helper::applicationName).append(" - ").append(Helper::options));
setModal(true);
mpMainWindow = pMainWindow;
mpGeneralSettingsPage = new GeneralSettingsPage(this);
mpLibrariesPage = new LibrariesPage(this);
mpModelicaTextEditorPage = new ModelicaTextEditorPage(this);
mpGraphicalViewsPage = new GraphicalViewsPage(this);
mpSimulationPage = new SimulationPage(this);
mpMessagesPage = new MessagesPage(this);
mpNotificationsPage = new NotificationsPage(this);
mpLineStylePage = new LineStylePage(this);
mpFillStylePage = new FillStylePage(this);
mpPlottingPage = new PlottingPage(this);
mpFigaroPage = new FigaroPage(this);
mpDebuggerPage = new DebuggerPage(this);
mpFMIPage = new FMIPage(this);
mpTLMPage = new TLMPage(this);
mpTLMEditorPage = new TLMEditorPage(this);
// get the settings
readSettings();
// set up the Options Dialog
setUpDialog();
}
//! Reads the settings from omedit.ini file.
void OptionsDialog::readSettings()
{
mpSettings->sync();
readGeneralSettings();
readLibrariesSettings();
readModelicaTextSettings();
emit modelicaTextSettingsChanged();
readGraphicalViewsSettings();
readSimulationSettings();
readMessagesSettings();
readNotificationsSettings();
readLineStyleSettings();
readFillStyleSettings();
readPlottingSettings();
readFigaroSettings();
readDebuggerSettings();
readFMISettings();
readTLMSettings();
readTLMEditorSettings();
emit TLMEditorSettingsChanged();
}
//! Reads the General section settings from omedit.ini
void OptionsDialog::readGeneralSettings()
{
// read the language option
if (mpSettings->contains("language")) {
/* Handle locale stored both as variant and as QString */
QLocale locale = QLocale(mpSettings->value("language").toString());
int currentIndex = mpGeneralSettingsPage->getLanguageComboBox()->findData(locale.name() == "C" ? mpSettings->value("language") : QVariant(locale), Qt::UserRole, Qt::MatchExactly);
if (currentIndex > -1) {
mpGeneralSettingsPage->getLanguageComboBox()->setCurrentIndex(currentIndex);
}
}
// read the working directory
if (mpSettings->contains("workingDirectory")) {
mpMainWindow->getOMCProxy()->changeDirectory(mpSettings->value("workingDirectory").toString());
}
mpGeneralSettingsPage->setWorkingDirectory(mpMainWindow->getOMCProxy()->changeDirectory());
// read toolbar icon size
if (mpSettings->contains("toolbarIconSize")) {
mpGeneralSettingsPage->getToolbarIconSizeSpinBox()->setValue(mpSettings->value("toolbarIconSize").toInt());
}
// read the user customizations
if (mpSettings->contains("userCustomizations")) {
mpGeneralSettingsPage->setPreserveUserCustomizations(mpSettings->value("userCustomizations").toBool());
}
// read the terminal command
if (mpSettings->contains("terminalCommand")) {
mpGeneralSettingsPage->setTerminalCommand(mpSettings->value("terminalCommand").toString());
}
// read the terminal command arguments
if (mpSettings->contains("terminalCommandArgs")) {
mpGeneralSettingsPage->setTerminalCommandArguments(mpSettings->value("terminalCommandArgs").toString());
}
// read library icon size
if (mpSettings->contains("libraryIconSize")) {
mpGeneralSettingsPage->getLibraryIconSizeSpinBox()->setValue(mpSettings->value("libraryIconSize").toInt());
}
// read show protected classes
if (mpSettings->contains("showProtectedClasses")) {
mpGeneralSettingsPage->setShowProtectedClasses(mpSettings->value("showProtectedClasses").toBool());
}
// read the modeling view mode
if (mpSettings->contains("modeling/viewmode")) {
mpGeneralSettingsPage->setModelingViewMode(mpSettings->value("modeling/viewmode").toString());
}
// read the default view
if (mpSettings->contains("defaultView")) {
mpGeneralSettingsPage->setDefaultView(mpSettings->value("defaultView").toString());
}
// read auto save
if (mpSettings->contains("autoSave/enable")) {
mpGeneralSettingsPage->getEnableAutoSaveGroupBox()->setChecked(mpSettings->value("autoSave/enable").toBool());
}
if (mpSettings->contains("autoSave/interval")) {
mpGeneralSettingsPage->getAutoSaveIntervalSpinBox()->setValue(mpSettings->value("autoSave/interval").toInt());
}
if (mpSettings->contains("autoSave/enableSingleClasses")) {
mpGeneralSettingsPage->getEnableAutoSaveForSingleClassesCheckBox()->setChecked(mpSettings->value("autoSave/enableSingleClasses").toBool());
}
if (mpSettings->contains("autoSave/enableOneFilePackages")) {
mpGeneralSettingsPage->getEnableAutoSaveForOneFilePackagesCheckBox()->setChecked(mpSettings->value("autoSave/enableOneFilePackages").toBool());
}
// read welcome page
if (mpSettings->contains("welcomePage/view")) {
mpGeneralSettingsPage->setWelcomePageView(mpSettings->value("welcomePage/view").toInt());
}
if (mpSettings->contains("welcomePage/showLatestNews")) {
mpGeneralSettingsPage->getShowLatestNewsCheckBox()->setChecked(mpSettings->value("welcomePage/showLatestNews").toBool());
}
}
//! Reads the Libraries section settings from omedit.ini
void OptionsDialog::readLibrariesSettings()
{
// read the system libraries
int i = 0;
while(i < mpLibrariesPage->getSystemLibrariesTree()->topLevelItemCount())
{
qDeleteAll(mpLibrariesPage->getSystemLibrariesTree()->topLevelItem(i)->takeChildren());
delete mpLibrariesPage->getSystemLibrariesTree()->topLevelItem(i);
i = 0; //Restart iteration
}
// read the settings and add libraries
mpSettings->beginGroup("libraries");
QStringList systemLibraries = mpSettings->childKeys();
foreach (QString systemLibrary, systemLibraries)
{
QStringList values;
values << systemLibrary << mpSettings->value(systemLibrary).toString();
mpLibrariesPage->getSystemLibrariesTree()->addTopLevelItem(new QTreeWidgetItem(values));
}
mpSettings->endGroup();
// read the forceModelicaLoad
if (mpSettings->contains("forceModelicaLoad"))
mpLibrariesPage->getForceModelicaLoadCheckBox()->setChecked(mpSettings->value("forceModelicaLoad").toBool());
// read user libraries
i = 0;
while(i < mpLibrariesPage->getUserLibrariesTree()->topLevelItemCount())
{
qDeleteAll(mpLibrariesPage->getUserLibrariesTree()->topLevelItem(i)->takeChildren());
delete mpLibrariesPage->getUserLibrariesTree()->topLevelItem(i);
i = 0; //Restart iteration
}
// read the settings and add libraries
mpSettings->beginGroup("userlibraries");
QStringList userLibraries = mpSettings->childKeys();
foreach (QString userLibrary, userLibraries)
{
QStringList values;
values << QUrl::fromPercentEncoding(QByteArray(userLibrary.toStdString().c_str())) << mpSettings->value(userLibrary).toString();
mpLibrariesPage->getUserLibrariesTree()->addTopLevelItem(new QTreeWidgetItem(values));
}
mpSettings->endGroup();
}
//! Reads the ModelicaText settings from omedit.ini
void OptionsDialog::readModelicaTextSettings()
{
int currentIndex;
if (mpSettings->contains("textEditor/tabPolicy")) {
currentIndex = mpModelicaTextEditorPage->getTabPolicyComboBox()->findData(mpSettings->value("textEditor/tabPolicy").toInt());
mpModelicaTextEditorPage->getTabPolicyComboBox()->setCurrentIndex(currentIndex);
}
if (mpSettings->contains("textEditor/tabSize")) {
mpModelicaTextEditorPage->getTabSizeSpinBox()->setValue(mpSettings->value("textEditor/tabSize").toInt());
}
if (mpSettings->contains("textEditor/indentSize")) {
mpModelicaTextEditorPage->getIndentSpinBox()->setValue(mpSettings->value("textEditor/indentSize").toInt());
}
if (mpSettings->contains("textEditor/preserveTextIndentation")) {
mpModelicaTextEditorPage->getPreserveTextIndentationCheckBox()->setChecked(mpSettings->value("textEditor/preserveTextIndentation").toBool());
}
if (mpSettings->contains("textEditor/enableSyntaxHighlighting")) {
mpModelicaTextEditorPage->getSyntaxHighlightingCheckbox()->setChecked(mpSettings->value("textEditor/enableSyntaxHighlighting").toBool());
}
if (mpSettings->contains("textEditor/matchParenthesesCommentsQuotes")) {
mpModelicaTextEditorPage->getMatchParenthesesCommentsQuotesCheckBox()->setChecked(mpSettings->value("textEditor/matchParenthesesCommentsQuotes").toBool());
}
if (mpSettings->contains("textEditor/enableLineWrapping")) {
mpModelicaTextEditorPage->getLineWrappingCheckbox()->setChecked(mpSettings->value("textEditor/enableLineWrapping").toBool());
}
if (mpSettings->contains("textEditor/fontFamily")) {
// select font family item
currentIndex = mpModelicaTextEditorPage->getFontFamilyComboBox()->findText(mpSettings->value("textEditor/fontFamily").toString(), Qt::MatchExactly);
mpModelicaTextEditorPage->getFontFamilyComboBox()->setCurrentIndex(currentIndex);
}
if (mpSettings->contains("textEditor/fontSize")) {
// select font size item
mpModelicaTextEditorPage->getFontSizeSpinBox()->setValue(mpSettings->value("textEditor/fontSize").toDouble());
}
if (mpSettings->contains("textEditor/textRuleColor")) {
mpModelicaTextEditorPage->setTextRuleColor(QColor(mpSettings->value("textEditor/textRuleColor").toUInt()));
}
if (mpSettings->contains("textEditor/keywordRuleColor")) {
mpModelicaTextEditorPage->setKeywordRuleColor(QColor(mpSettings->value("textEditor/keywordRuleColor").toUInt()));
}
if (mpSettings->contains("textEditor/typeRuleColor")) {
mpModelicaTextEditorPage->setTypeRuleColor(QColor(mpSettings->value("textEditor/typeRuleColor").toUInt()));
}
if (mpSettings->contains("textEditor/functionRuleColor")) {
mpModelicaTextEditorPage->setFunctionRuleColor(QColor(mpSettings->value("textEditor/functionRuleColor").toUInt()));
}
if (mpSettings->contains("textEditor/quotesRuleColor")) {
mpModelicaTextEditorPage->setQuotesRuleColor(QColor(mpSettings->value("textEditor/quotesRuleColor").toUInt()));
}
if (mpSettings->contains("textEditor/commentRuleColor")) {
mpModelicaTextEditorPage->setCommentRuleColor(QColor(mpSettings->value("textEditor/commentRuleColor").toUInt()));
}
if (mpSettings->contains("textEditor/numberRuleColor")) {
mpModelicaTextEditorPage->setNumberRuleColor(QColor(mpSettings->value("textEditor/numberRuleColor").toUInt()));
}
}
//! Reads the GraphicsViews section settings from omedit.ini
void OptionsDialog::readGraphicalViewsSettings()
{
if (mpSettings->contains("iconView/extentLeft"))
mpGraphicalViewsPage->setIconViewExtentLeft(mpSettings->value("iconView/extentLeft").toDouble());
if (mpSettings->contains("iconView/extentBottom"))
mpGraphicalViewsPage->setIconViewExtentBottom(mpSettings->value("iconView/extentBottom").toDouble());
if (mpSettings->contains("iconView/extentRight"))
mpGraphicalViewsPage->setIconViewExtentRight(mpSettings->value("iconView/extentRight").toDouble());
if (mpSettings->contains("iconView/extentTop"))
mpGraphicalViewsPage->setIconViewExtentTop(mpSettings->value("iconView/extentTop").toDouble());
if (mpSettings->contains("iconView/gridHorizontal"))
mpGraphicalViewsPage->setIconViewGridHorizontal(mpSettings->value("iconView/gridHorizontal").toDouble());
if (mpSettings->contains("iconView/gridVertical"))
mpGraphicalViewsPage->setIconViewGridVertical(mpSettings->value("iconView/gridVertical").toDouble());
if (mpSettings->contains("iconView/scaleFactor"))
mpGraphicalViewsPage->setIconViewScaleFactor(mpSettings->value("iconView/scaleFactor").toDouble());
if (mpSettings->contains("iconView/preserveAspectRatio"))
mpGraphicalViewsPage->setIconViewPreserveAspectRation(mpSettings->value("iconView/preserveAspectRatio").toBool());
if (mpSettings->contains("DiagramView/extentLeft"))
mpGraphicalViewsPage->setDiagramViewExtentLeft(mpSettings->value("DiagramView/extentLeft").toDouble());
if (mpSettings->contains("DiagramView/extentBottom"))
mpGraphicalViewsPage->setDiagramViewExtentBottom(mpSettings->value("DiagramView/extentBottom").toDouble());
if (mpSettings->contains("DiagramView/extentRight"))
mpGraphicalViewsPage->setDiagramViewExtentRight(mpSettings->value("DiagramView/extentRight").toDouble());
if (mpSettings->contains("DiagramView/extentTop"))
mpGraphicalViewsPage->setDiagramViewExtentTop(mpSettings->value("DiagramView/extentTop").toDouble());
if (mpSettings->contains("DiagramView/gridHorizontal"))
mpGraphicalViewsPage->setDiagramViewGridHorizontal(mpSettings->value("DiagramView/gridHorizontal").toDouble());
if (mpSettings->contains("DiagramView/gridVertical"))
mpGraphicalViewsPage->setDiagramViewGridVertical(mpSettings->value("DiagramView/gridVertical").toDouble());
if (mpSettings->contains("DiagramView/scaleFactor"))
mpGraphicalViewsPage->setDiagramViewScaleFactor(mpSettings->value("DiagramView/scaleFactor").toDouble());
if (mpSettings->contains("DiagramView/preserveAspectRatio"))
mpGraphicalViewsPage->setDiagramViewPreserveAspectRation(mpSettings->value("DiagramView/preserveAspectRatio").toBool());
}
//! Reads the Simulation section settings from omedit.ini
void OptionsDialog::readSimulationSettings()
{
if (mpSettings->contains("simulation/matchingAlgorithm")) {
int currentIndex = mpSimulationPage->getMatchingAlgorithmComboBox()->findText(mpSettings->value("simulation/matchingAlgorithm").toString(), Qt::MatchExactly);
if (currentIndex > -1) {
mpSimulationPage->getMatchingAlgorithmComboBox()->setCurrentIndex(currentIndex);
}
}
if (mpSettings->contains("simulation/indexReductionMethod")) {
int currentIndex = mpSimulationPage->getIndexReductionMethodComboBox()->findText(mpSettings->value("simulation/indexReductionMethod").toString(), Qt::MatchExactly);
if (currentIndex > -1) {
mpSimulationPage->getIndexReductionMethodComboBox()->setCurrentIndex(currentIndex);
}
}
if (mpSettings->contains("simulation/targetLanguage")) {
int currentIndex = mpSimulationPage->getTargetLanguageComboBox()->findText(mpSettings->value("simulation/targetLanguage").toString(), Qt::MatchExactly);
if (currentIndex > -1) {
mpSimulationPage->getTargetLanguageComboBox()->setCurrentIndex(currentIndex);
}
}
if (mpSettings->contains("simulation/targetCompiler")) {
int currentIndex = mpSimulationPage->getTargetCompilerComboBox()->findText(mpSettings->value("simulation/targetCompiler").toString(), Qt::MatchExactly);
if (currentIndex > -1) {
mpSimulationPage->getTargetCompilerComboBox()->setCurrentIndex(currentIndex);
}
}
if (mpSettings->contains("simulation/OMCFlags")) {
mpSimulationPage->getOMCFlagsTextBox()->setText(mpSettings->value("simulation/OMCFlags").toString());
}
if (mpSettings->contains("simulation/saveClassBeforeSimulation")) {
mpSimulationPage->getSaveClassBeforeSimulationCheckBox()->setChecked(mpSettings->value("simulation/saveClassBeforeSimulation").toBool());
}
if (mpSettings->contains("simulation/outputMode")) {
mpSimulationPage->setOutputMode(mpSettings->value("simulation/outputMode").toString());
}
}
//! Reads the Messages section settings from omedit.ini
void OptionsDialog::readMessagesSettings()
{
// read output size
if (mpSettings->contains("messages/outputSize")) {
mpMessagesPage->getOutputSizeSpinBox()->setValue(mpSettings->value("messages/outputSize").toInt());
}
if (mpSettings->contains("messages/resetMessagesNumber")) {
mpMessagesPage->getResetMessagesNumberBeforeSimulationCheckBox()->setChecked(mpSettings->value("messages/resetMessagesNumber").toBool());
}
// read font family
if (mpSettings->contains("messages/fontFamily")) {
int currentIndex;
// select font family item
currentIndex = mpMessagesPage->getFontFamilyComboBox()->findText(mpSettings->value("messages/fontFamily").toString(), Qt::MatchExactly);
mpMessagesPage->getFontFamilyComboBox()->setCurrentIndex(currentIndex);
}
// read font size
if (mpSettings->contains("messages/fontSize")) {
mpMessagesPage->getFontSizeSpinBox()->setValue(mpSettings->value("messages/fontSize").toDouble());
}
// read notification color
if (mpSettings->contains("messages/notificationColor")) {
QColor color = QColor(mpSettings->value("messages/notificationColor").toUInt());
if (color.isValid()) {
mpMessagesPage->setNotificationColor(color);
mpMessagesPage->setNotificationPickColorButtonIcon();
}
}
// read warning color
if (mpSettings->contains("messages/warningColor")) {
QColor color = QColor(mpSettings->value("messages/warningColor").toUInt());
if (color.isValid()) {
mpMessagesPage->setWarningColor(color);
mpMessagesPage->setWarningPickColorButtonIcon();
}
}
// read error color
if (mpSettings->contains("messages/errorColor")) {
QColor color = QColor(mpSettings->value("messages/errorColor").toUInt());
if (color.isValid()) {
mpMessagesPage->setErrorColor(color);
mpMessagesPage->setErrorPickColorButtonIcon();
}
}
}
//! Reads the Notifications section settings from omedit.ini
void OptionsDialog::readNotificationsSettings()
{
if (mpSettings->contains("notifications/promptQuitApplication"))
{
mpNotificationsPage->getQuitApplicationCheckBox()->setChecked(mpSettings->value("notifications/promptQuitApplication").toBool());
}
if (mpSettings->contains("notifications/itemDroppedOnItself"))
{
mpNotificationsPage->getItemDroppedOnItselfCheckBox()->setChecked(mpSettings->value("notifications/itemDroppedOnItself").toBool());
}
if (mpSettings->contains("notifications/replaceableIfPartial"))
{
mpNotificationsPage->getReplaceableIfPartialCheckBox()->setChecked(mpSettings->value("notifications/replaceableIfPartial").toBool());
}
if (mpSettings->contains("notifications/innerModelNameChanged"))
{
mpNotificationsPage->getInnerModelNameChangedCheckBox()->setChecked(mpSettings->value("notifications/innerModelNameChanged").toBool());
}
if (mpSettings->contains("notifications/saveModelForBitmapInsertion"))
{
mpNotificationsPage->getSaveModelForBitmapInsertionCheckBox()->setChecked(mpSettings->value("notifications/saveModelForBitmapInsertion").toBool());
}
}
//! Reads the LineStyle section settings from omedit.ini
void OptionsDialog::readLineStyleSettings()
{
if (mpSettings->contains("linestyle/color"))
{
QColor color = QColor(mpSettings->value("linestyle/color").toUInt());
if (color.isValid())
{
mpLineStylePage->setLineColor(color);
mpLineStylePage->setLinePickColorButtonIcon();
}
}
if (mpSettings->contains("linestyle/pattern"))
mpLineStylePage->setLinePattern(mpSettings->value("linestyle/pattern").toString());
if (mpSettings->contains("linestyle/thickness"))
mpLineStylePage->setLineThickness(mpSettings->value("linestyle/thickness").toFloat());
if (mpSettings->contains("linestyle/startArrow"))
mpLineStylePage->setLineStartArrow(mpSettings->value("linestyle/startArrow").toString());
if (mpSettings->contains("linestyle/endArrow"))
mpLineStylePage->setLineEndArrow(mpSettings->value("linestyle/endArrow").toString());
if (mpSettings->contains("linestyle/arrowSize"))
mpLineStylePage->setLineArrowSize(mpSettings->value("linestyle/arrowSize").toFloat());
if (mpSettings->contains("linestyle/smooth"))
mpLineStylePage->setLineSmooth(mpSettings->value("linestyle/smooth").toBool());
}
//! Reads the FillStyle section settings from omedit.ini
void OptionsDialog::readFillStyleSettings()
{
if (mpSettings->contains("fillstyle/color"))
{
QColor color = QColor(mpSettings->value("fillstyle/color").toUInt());
if (color.isValid())
{
mpFillStylePage->setFillColor(color);
mpFillStylePage->setFillPickColorButtonIcon();
}
}
if (mpSettings->contains("fillstyle/pattern"))
mpFillStylePage->setFillPattern(mpSettings->value("fillstyle/pattern").toString());
}
//! Reads the Plotting section settings from omedit.ini
void OptionsDialog::readPlottingSettings()
{
// read the auto scale
if (mpSettings->contains("plotting/autoScale")) {
mpPlottingPage->getAutoScaleCheckBox()->setChecked(mpSettings->value("plotting/autoScale").toBool());
}
// read the plotting view mode
if (mpSettings->contains("plotting/viewmode")) {
mpPlottingPage->setPlottingViewMode(mpSettings->value("plotting/viewmode").toString());
}
if (mpSettings->contains("curvestyle/pattern")) {
mpPlottingPage->setCurvePattern(mpSettings->value("curvestyle/pattern").toInt());
}
if (mpSettings->contains("curvestyle/thickness")) {
mpPlottingPage->setCurveThickness(mpSettings->value("curvestyle/thickness").toFloat());
}
}
//! Reads the Fiagro section settings from omedit.ini
void OptionsDialog::readFigaroSettings()
{
if (mpSettings->contains("figaro/databasefile")) {
mpFigaroPage->getFigaroDatabaseFileTextBox()->setText(mpSettings->value("figaro/databasefile").toString());
}
if (mpSettings->contains("figaro/options")) {
mpFigaroPage->getFigaroOptionsTextBox()->setText(mpSettings->value("figaro/options").toString());
}
if (mpSettings->contains("figaro/process") && !mpSettings->value("figaro/process").toString().isEmpty()) {
mpFigaroPage->getFigaroProcessTextBox()->setText(mpSettings->value("figaro/process").toString());
}
}
/*!
Reads the Debugger section settings from omedit.ini
*/
void OptionsDialog::readDebuggerSettings()
{
if (mpSettings->contains("algorithmicDebugger/GDBPath")) {
mpDebuggerPage->setGDBPath(mpSettings->value("algorithmicDebugger/GDBPath").toString());
}
if (mpSettings->contains("algorithmicDebugger/GDBCommandTimeout")) {
mpDebuggerPage->getGDBCommandTimeoutSpinBox()->setValue(mpSettings->value("algorithmicDebugger/GDBCommandTimeout").toInt());
}
if (mpSettings->contains("algorithmicDebugger/GDBOutputLimit")) {
mpDebuggerPage->getGDBOutputLimitSpinBox()->setValue(mpSettings->value("algorithmicDebugger/GDBOutputLimit").toInt());
}
if (mpSettings->contains("algorithmicDebugger/displayCFrames")) {
mpDebuggerPage->getDisplayCFramesCheckBox()->setChecked(mpSettings->value("algorithmicDebugger/displayCFrames").toBool());
}
if (mpSettings->contains("algorithmicDebugger/displayUnknownFrames")) {
mpDebuggerPage->getDisplayUnknownFramesCheckBox()->setChecked(mpSettings->value("algorithmicDebugger/displayUnknownFrames").toBool());
}
if (mpSettings->contains("algorithmicDebugger/clearOutputOnNewRun")) {
mpDebuggerPage->getClearOutputOnNewRunCheckBox()->setChecked(mpSettings->value("algorithmicDebugger/clearOutputOnNewRun").toBool());
}
if (mpSettings->contains("algorithmicDebugger/clearLogOnNewRun")) {
mpDebuggerPage->getClearLogOnNewRunCheckBox()->setChecked(mpSettings->value("algorithmicDebugger/clearLogOnNewRun").toBool());
}
if (mpSettings->contains("transformationalDebugger/alwaysShowTransformationalDebugger")) {
mpDebuggerPage->getAlwaysShowTransformationsCheckBox()->setChecked(mpSettings->value("transformationalDebugger/alwaysShowTransformationalDebugger").toBool());
}
if (mpSettings->contains("transformationalDebugger/generateOperations")) {
mpDebuggerPage->getGenerateOperationsCheckBox()->setChecked(mpSettings->value("transformationalDebugger/generateOperations").toBool());
}
}
/*!
Reads the FMI section settings from omedit.ini
*/
void OptionsDialog::readFMISettings()
{
if (mpSettings->contains("FMIExport/Version")) {
mpFMIPage->setFMIExportVersion(mpSettings->value("FMIExport/Version").toDouble());
}
if (mpSettings->contains("FMIExport/Type")) {
mpFMIPage->setFMIExportType(mpSettings->value("FMIExport/Type").toString());
}
if (mpSettings->contains("FMI/FMUName")) {
mpFMIPage->getFMUNameTextBox()->setText(mpSettings->value("FMI/FMUName").toString());
}
}
/*!
* \brief OptionsDialog::readTLMSettings
* Reads the TLM settings from omedit.ini
*/
void OptionsDialog::readTLMSettings()
{
// read TLM Path
if (mpSettings->contains("TLM/PluginPath")) {
mpTLMPage->getTLMPluginPathTextBox()->setText(mpSettings->value("TLM/PluginPath").toString());
}
// read the TLM Manager Process
if (mpSettings->contains("TLM/ManagerProcess")) {
mpTLMPage->getTLMManagerProcessTextBox()->setText(mpSettings->value("TLM/ManagerProcess").toString());
}
// read TLM Monitor Process
if (mpSettings->contains("TLM/MonitorProcess")) {
mpTLMPage->getTLMMonitorProcessTextBox()->setText(mpSettings->value("TLM/MonitorProcess").toString());
}
}
//! Reads the TLM Text settings from omedit.ini
void OptionsDialog::readTLMEditorSettings()
{
int currentIndex;
if (mpSettings->contains("TLMEditor/tabPolicy")) {
currentIndex = mpTLMEditorPage->getTabPolicyComboBox()->findData(mpSettings->value("TLMEditor/tabPolicy").toInt());
mpTLMEditorPage->getTabPolicyComboBox()->setCurrentIndex(currentIndex);
}
if (mpSettings->contains("TLMEditor/tabSize")) {
mpTLMEditorPage->getTabSizeSpinBox()->setValue(mpSettings->value("TLMEditor/tabSize").toInt());
}
if (mpSettings->contains("TLMEditor/indentSize")) {
mpTLMEditorPage->getIndentSpinBox()->setValue(mpSettings->value("TLMEditor/indentSize").toInt());
}
if (mpSettings->contains("TLMEditor/enableSyntaxHighlighting")) {
mpTLMEditorPage->getSyntaxHighlightingCheckbox()->setChecked(mpSettings->value("TLMEditor/enableSyntaxHighlighting").toBool());
}
if (mpSettings->contains("TLMEditor/enableLineWrapping")) {
mpTLMEditorPage->getLineWrappingCheckbox()->setChecked(mpSettings->value("TLMEditor/enableLineWrapping").toBool());
}
if (mpSettings->contains("TLMEditor/fontFamily")){
// select font family item
currentIndex = mpTLMEditorPage->getFontFamilyComboBox()->findText(mpSettings->value("TLMEditor/fontFamily").toString(), Qt::MatchExactly);
mpTLMEditorPage->getFontFamilyComboBox()->setCurrentIndex(currentIndex);
}
if (mpSettings->contains("TLMEditor/fontSize"))
mpTLMEditorPage->getFontSizeSpinBox()->setValue(mpSettings->value("TLMEditor/fontSize").toDouble());
if (mpSettings->contains("TLMEditor/textRuleColor"))
mpTLMEditorPage->setTextRuleColor(QColor(mpSettings->value("TLMEditor/textRuleColor").toUInt()));
if (mpSettings->contains("TLMEditor/commentRuleColor"))
mpTLMEditorPage->setCommentRuleColor(QColor(mpSettings->value("TLMEditor/commentRuleColor").toUInt()));
if (mpSettings->contains("TLMEditor/tagRuleColor"))
mpTLMEditorPage->setTagRuleColor(QColor(mpSettings->value("TLMEditor/tagRuleColor").toUInt()));
if (mpSettings->contains("TLMEditor/quotesRuleColor"))
mpTLMEditorPage->setQuotesRuleColor(QColor(mpSettings->value("TLMEditor/quotesRuleColor").toUInt()));
if (mpSettings->contains("TLMEditor/elementsRuleColor"))
mpTLMEditorPage->setElementRuleColor(QColor(mpSettings->value("TLMEditor/elementsRuleColor").toUInt()));
}
//! Saves the General section settings to omedit.ini
void OptionsDialog::saveGeneralSettings()
{
// save Language option
QString language;
if (mpGeneralSettingsPage->getLanguageComboBox()->currentIndex() == 0) {
language = QLocale::system().name();
} else {
language = mpGeneralSettingsPage->getLanguageComboBox()->itemData(mpGeneralSettingsPage->getLanguageComboBox()->currentIndex()).toLocale().name();
}
mpSettings->setValue("language", language);
// save working directory
mpMainWindow->getOMCProxy()->changeDirectory(mpGeneralSettingsPage->getWorkingDirectory());
mpSettings->setValue("workingDirectory", mpMainWindow->getOMCProxy()->changeDirectory());
// save toolbar icon size
mpSettings->setValue("toolbarIconSize", mpGeneralSettingsPage->getToolbarIconSizeSpinBox()->value());
// save user customizations
mpSettings->setValue("userCustomizations", mpGeneralSettingsPage->getPreserveUserCustomizations());
// save terminal command
mpSettings->setValue("terminalCommand", mpGeneralSettingsPage->getTerminalCommand());
// save terminal command arguments
mpSettings->setValue("terminalCommandArgs", mpGeneralSettingsPage->getTerminalCommandArguments());
// save library icon size
mpSettings->setValue("libraryIconSize", mpGeneralSettingsPage->getLibraryIconSizeSpinBox()->value());
// save show protected classes
mpSettings->setValue("showProtectedClasses", mpGeneralSettingsPage->getShowProtectedClasses());
// show/hide the protected classes
getMainWindow()->getLibraryWidget()->getLibraryTreeModel()->showHideProtectedClasses();
// save modeling view mode
mpSettings->setValue("modeling/viewmode", mpGeneralSettingsPage->getModelingViewMode());
if (mpGeneralSettingsPage->getModelingViewMode().compare(Helper::subWindow) == 0) {
mpMainWindow->getModelWidgetContainer()->setViewMode(QMdiArea::SubWindowView);
ModelWidget *pModelWidget = mpMainWindow->getModelWidgetContainer()->getCurrentModelWidget();
if (pModelWidget) {
pModelWidget->show();
pModelWidget->setWindowState(Qt::WindowMaximized);
}
} else {
mpMainWindow->getModelWidgetContainer()->setViewMode(QMdiArea::TabbedView);
}
// save default view
mpSettings->setValue("defaultView", mpGeneralSettingsPage->getDefaultView());
// save auto save
mpSettings->setValue("autoSave/enable", mpGeneralSettingsPage->getEnableAutoSaveGroupBox()->isChecked());
mpSettings->setValue("autoSave/interval", mpGeneralSettingsPage->getAutoSaveIntervalSpinBox()->value());
mpSettings->setValue("autoSave/enableSingleClasses", mpGeneralSettingsPage->getEnableAutoSaveForSingleClassesCheckBox()->isChecked());
mpSettings->setValue("autoSave/enableOneFilePackages", mpGeneralSettingsPage->getEnableAutoSaveForOneFilePackagesCheckBox()->isChecked());
mpMainWindow->toggleAutoSave();
// save welcome page
switch (mpGeneralSettingsPage->getWelcomePageView()) {
case 2:
mpMainWindow->getWelcomePageWidget()->getSplitter()->setOrientation(Qt::Vertical);
break;
case 1:
default:
mpMainWindow->getWelcomePageWidget()->getSplitter()->setOrientation(Qt::Horizontal);
break;
}
mpSettings->setValue("welcomePage/view", mpGeneralSettingsPage->getWelcomePageView());
bool showLatestNews = mpGeneralSettingsPage->getShowLatestNewsCheckBox()->isChecked();
if (mpMainWindow->getWelcomePageWidget()->getLatestNewsFrame()->isHidden() && showLatestNews) {
mpMainWindow->getWelcomePageWidget()->getLatestNewsFrame()->show();
mpMainWindow->getWelcomePageWidget()->addLatestNewsListItems();
} else if (!showLatestNews) {
mpMainWindow->getWelcomePageWidget()->getLatestNewsFrame()->hide();
}
mpSettings->setValue("welcomePage/showLatestNews", showLatestNews);
}
//! Saves the Libraries section settings to omedit.ini
void OptionsDialog::saveLibrariesSettings()
{
// read the settings and add system libraries
mpSettings->beginGroup("libraries");
foreach (QString lib, mpSettings->childKeys())
{
mpSettings->remove(lib);
}
QTreeWidgetItemIterator systemLibrariesIterator(mpLibrariesPage->getSystemLibrariesTree());
while (*systemLibrariesIterator)
{
QTreeWidgetItem *pItem = dynamic_cast<QTreeWidgetItem*>(*systemLibrariesIterator);
mpSettings->setValue(pItem->text(0), pItem->text(1));
++systemLibrariesIterator;
}
mpSettings->endGroup();
mpSettings->setValue("forceModelicaLoad", mpLibrariesPage->getForceModelicaLoadCheckBox()->isChecked());
// read the settings and add user libraries
mpSettings->beginGroup("userlibraries");
foreach (QString lib, mpSettings->childKeys())
{
mpSettings->remove(lib);
}
QTreeWidgetItemIterator userLibrariesIterator(mpLibrariesPage->getUserLibrariesTree());
while (*userLibrariesIterator)
{
QTreeWidgetItem *pItem = dynamic_cast<QTreeWidgetItem*>(*userLibrariesIterator);
mpSettings->setValue(QUrl::toPercentEncoding(pItem->text(0)), pItem->text(1));
++userLibrariesIterator;
}
mpSettings->endGroup();
}
//! Saves the ModelicaText settings to omedit.ini
void OptionsDialog::saveModelicaTextSettings()
{
mpSettings->setValue("textEditor/tabPolicy", mpModelicaTextEditorPage->getTabPolicyComboBox()->itemData(mpModelicaTextEditorPage->getTabPolicyComboBox()->currentIndex()).toInt());
mpSettings->setValue("textEditor/tabSize", mpModelicaTextEditorPage->getTabSizeSpinBox()->value());
mpSettings->setValue("textEditor/indentSize", mpModelicaTextEditorPage->getIndentSpinBox()->value());
mpSettings->setValue("textEditor/preserveTextIndentation", mpModelicaTextEditorPage->getPreserveTextIndentationCheckBox()->isChecked());
mpSettings->setValue("textEditor/enableSyntaxHighlighting", mpModelicaTextEditorPage->getSyntaxHighlightingCheckbox()->isChecked());
mpSettings->setValue("textEditor/matchParenthesesCommentsQuotes", mpModelicaTextEditorPage->getMatchParenthesesCommentsQuotesCheckBox()->isChecked());
mpSettings->setValue("textEditor/enableLineWrapping", mpModelicaTextEditorPage->getLineWrappingCheckbox()->isChecked());
mpSettings->setValue("textEditor/fontFamily", mpModelicaTextEditorPage->getFontFamilyComboBox()->currentFont().family());
mpSettings->setValue("textEditor/fontSize", mpModelicaTextEditorPage->getFontSizeSpinBox()->value());
mpSettings->setValue("textEditor/textRuleColor", mpModelicaTextEditorPage->getTextRuleColor().rgba());
mpSettings->setValue("textEditor/keywordRuleColor", mpModelicaTextEditorPage->getKeywordRuleColor().rgba());
mpSettings->setValue("textEditor/typeRuleColor", mpModelicaTextEditorPage->getTypeRuleColor().rgba());
mpSettings->setValue("textEditor/functionRuleColor", mpModelicaTextEditorPage->getFunctionRuleColor().rgba());
mpSettings->setValue("textEditor/quotesRuleColor", mpModelicaTextEditorPage->getQuotesRuleColor().rgba());
mpSettings->setValue("textEditor/commentRuleColor", mpModelicaTextEditorPage->getCommentRuleColor().rgba());
mpSettings->setValue("textEditor/numberRuleColor", mpModelicaTextEditorPage->getNumberRuleColor().rgba());
}
//! Saves the GraphicsViews section settings to omedit.ini
void OptionsDialog::saveGraphicalViewsSettings()
{
mpSettings->setValue("iconView/extentLeft", mpGraphicalViewsPage->getIconViewExtentLeft());
mpSettings->setValue("iconView/extentBottom", mpGraphicalViewsPage->getIconViewExtentBottom());
mpSettings->setValue("iconView/extentRight", mpGraphicalViewsPage->getIconViewExtentRight());
mpSettings->setValue("iconView/extentTop", mpGraphicalViewsPage->getIconViewExtentTop());
mpSettings->setValue("iconView/gridHorizontal", mpGraphicalViewsPage->getIconViewGridHorizontal());
mpSettings->setValue("iconView/gridVertical", mpGraphicalViewsPage->getIconViewGridVertical());
mpSettings->setValue("iconView/scaleFactor", mpGraphicalViewsPage->getIconViewScaleFactor());
mpSettings->setValue("iconView/preserveAspectRatio", mpGraphicalViewsPage->getIconViewPreserveAspectRation());
mpSettings->setValue("DiagramView/extentLeft", mpGraphicalViewsPage->getDiagramViewExtentLeft());
mpSettings->setValue("DiagramView/extentBottom", mpGraphicalViewsPage->getDiagramViewExtentBottom());
mpSettings->setValue("DiagramView/extentRight", mpGraphicalViewsPage->getDiagramViewExtentRight());
mpSettings->setValue("DiagramView/extentTop", mpGraphicalViewsPage->getDiagramViewExtentTop());
mpSettings->setValue("DiagramView/gridHorizontal", mpGraphicalViewsPage->getDiagramViewGridHorizontal());
mpSettings->setValue("DiagramView/gridVertical", mpGraphicalViewsPage->getDiagramViewGridVertical());
mpSettings->setValue("DiagramView/scaleFactor", mpGraphicalViewsPage->getDiagramViewScaleFactor());
mpSettings->setValue("DiagramView/preserveAspectRatio", mpGraphicalViewsPage->getDiagramViewPreserveAspectRation());
}
//! Saves the Simulation section settings to omedit.ini
void OptionsDialog::saveSimulationSettings()
{
// save matching algorithm
mpSettings->setValue("simulation/matchingAlgorithm", mpSimulationPage->getMatchingAlgorithmComboBox()->currentText());
mpMainWindow->getOMCProxy()->setMatchingAlgorithm(mpSimulationPage->getMatchingAlgorithmComboBox()->currentText());
// save index reduction
mpSettings->setValue("simulation/indexReductionMethod", mpSimulationPage->getIndexReductionMethodComboBox()->currentText());
mpMainWindow->getOMCProxy()->setIndexReductionMethod(mpSimulationPage->getIndexReductionMethodComboBox()->currentText());
// clear command line options before saving new ones
mpMainWindow->getOMCProxy()->clearCommandLineOptions();
// save +simCodeTarget
mpSettings->setValue("simulation/targetLanguage", mpSimulationPage->getTargetLanguageComboBox()->currentText());
mpMainWindow->getOMCProxy()->setCommandLineOptions(QString("+simCodeTarget=%1").arg(mpSimulationPage->getTargetLanguageComboBox()->currentText()));
// save +target
mpSettings->setValue("simulation/targetCompiler", mpSimulationPage->getTargetCompilerComboBox()->currentText());
mpMainWindow->getOMCProxy()->setCommandLineOptions(QString("+target=%1").arg(mpSimulationPage->getTargetCompilerComboBox()->currentText()));
// save command line options ste manually by user. This will override above options.
if (mpMainWindow->getOMCProxy()->setCommandLineOptions(mpSimulationPage->getOMCFlagsTextBox()->text())) {
mpSettings->setValue("simulation/OMCFlags", mpSimulationPage->getOMCFlagsTextBox()->text());
} else {
mpSimulationPage->getOMCFlagsTextBox()->setText(mpSettings->value("simulation/OMCFlags").toString());
}
// save class before simulation.
mpSettings->setValue("simulation/saveClassBeforeSimulation", mpSimulationPage->getSaveClassBeforeSimulationCheckBox()->isChecked());
mpSettings->setValue("simulation/outputMode", mpSimulationPage->getOutputMode());
}
//! Saves the Messages section settings to omedit.ini
void OptionsDialog::saveMessagesSettings()
{
// save output size
mpSettings->setValue("messages/outputSize", mpMessagesPage->getOutputSizeSpinBox()->value());
// save reset messages number
mpSettings->setValue("messages/resetMessagesNumber", mpMessagesPage->getResetMessagesNumberBeforeSimulationCheckBox()->isChecked());
// save font
mpSettings->setValue("messages/fontFamily", mpMessagesPage->getFontFamilyComboBox()->currentFont().family());
mpSettings->setValue("messages/fontSize", mpMessagesPage->getFontSizeSpinBox()->value());
// save notification color
mpSettings->setValue("messages/notificationColor", mpMessagesPage->getNotificationColor().rgba());
// save warning color
mpSettings->setValue("messages/warningColor", mpMessagesPage->getWarningColor().rgba());
// save error color
mpSettings->setValue("messages/errorColor", mpMessagesPage->getErrorColor().rgba());
// apply the above settings to Messages
mpMainWindow->getMessagesWidget()->applyMessagesSettings();
}
//! Saves the Notifications section settings to omedit.ini
void OptionsDialog::saveNotificationsSettings()
{
mpSettings->setValue("notifications/promptQuitApplication", mpNotificationsPage->getQuitApplicationCheckBox()->isChecked());
mpSettings->setValue("notifications/itemDroppedOnItself", mpNotificationsPage->getItemDroppedOnItselfCheckBox()->isChecked());
mpSettings->setValue("notifications/replaceableIfPartial", mpNotificationsPage->getReplaceableIfPartialCheckBox()->isChecked());
mpSettings->setValue("notifications/innerModelNameChanged", mpNotificationsPage->getInnerModelNameChangedCheckBox()->isChecked());
mpSettings->setValue("notifications/saveModelForBitmapInsertion", mpNotificationsPage->getSaveModelForBitmapInsertionCheckBox()->isChecked());
}
//! Saves the LineStyle section settings to omedit.ini
void OptionsDialog::saveLineStyleSettings()
{
mpSettings->setValue("linestyle/color", mpLineStylePage->getLineColor().rgba());
mpSettings->setValue("linestyle/pattern", mpLineStylePage->getLinePattern());
mpSettings->setValue("linestyle/thickness", mpLineStylePage->getLineThickness());
mpSettings->setValue("linestyle/startArrow", mpLineStylePage->getLineStartArrow());
mpSettings->setValue("linestyle/endArrow", mpLineStylePage->getLineEndArrow());
mpSettings->setValue("linestyle/arrowSize", mpLineStylePage->getLineArrowSize());
mpSettings->setValue("linestyle/smooth", mpLineStylePage->getLineSmooth());
}
//! Saves the FillStyle section settings to omedit.ini
void OptionsDialog::saveFillStyleSettings()
{
mpSettings->setValue("fillstyle/color", mpFillStylePage->getFillColor().rgba());
mpSettings->setValue("fillstyle/pattern", mpFillStylePage->getFillPattern());
}
//! Saves the Plotting section settings to omedit.ini
void OptionsDialog::savePlottingSettings()
{
// save the auto scale
mpSettings->setValue("plotting/autoScale", mpPlottingPage->getAutoScaleCheckBox()->isChecked());
// save plotting view mode
mpSettings->setValue("plotting/viewmode", mpPlottingPage->getPlottingViewMode());
if (mpPlottingPage->getPlottingViewMode().compare(Helper::subWindow) == 0) {
mpMainWindow->getPlotWindowContainer()->setViewMode(QMdiArea::SubWindowView);
OMPlot::PlotWindow *pPlotWindow = mpMainWindow->getPlotWindowContainer()->getCurrentWindow();
if (pPlotWindow) {
pPlotWindow->show();
pPlotWindow->setWindowState(Qt::WindowMaximized);
}
} else {
mpMainWindow->getPlotWindowContainer()->setViewMode(QMdiArea::TabbedView);
}
mpSettings->setValue("curvestyle/pattern", mpPlottingPage->getCurvePattern());
mpSettings->setValue("curvestyle/thickness", mpPlottingPage->getCurveThickness());
}
//! Saves the Figaro section settings to omedit.ini
void OptionsDialog::saveFigaroSettings()
{
mpSettings->setValue("figaro/databasefile", mpFigaroPage->getFigaroDatabaseFileTextBox()->text());
mpSettings->setValue("figaro/options", mpFigaroPage->getFigaroOptionsTextBox()->text());
mpSettings->setValue("figaro/process", mpFigaroPage->getFigaroProcessTextBox()->text());
}
/*!
Saves the Debugger section settings to omedit.ini
*/
void OptionsDialog::saveDebuggerSettings()
{
mpSettings->beginGroup("algorithmicDebugger");
mpSettings->setValue("GDBPath", mpDebuggerPage->getGDBPath());
mpSettings->setValue("GDBCommandTimeout", mpDebuggerPage->getGDBCommandTimeoutSpinBox()->value());
mpSettings->setValue("GDBOutputLimit", mpDebuggerPage->getGDBOutputLimitSpinBox()->value());
mpSettings->setValue("displayCFrames", mpDebuggerPage->getDisplayCFramesCheckBox()->isChecked());
mpSettings->setValue("displayUnknownFrames", mpDebuggerPage->getDisplayUnknownFramesCheckBox()->isChecked());
mpMainWindow->getDebuggerMainWindow()->getStackFramesWidget()->getStackFramesTreeWidget()->updateStackFrames();
mpSettings->setValue("clearOutputOnNewRun", mpDebuggerPage->getClearOutputOnNewRunCheckBox()->isChecked());
mpSettings->setValue("clearLogOnNewRun", mpDebuggerPage->getClearLogOnNewRunCheckBox()->isChecked());
mpSettings->endGroup();
mpSettings->beginGroup("transformationalDebugger");
mpSettings->setValue("alwaysShowTransformationalDebugger", mpDebuggerPage->getAlwaysShowTransformationsCheckBox()->isChecked());
mpSettings->setValue("generateOperations", mpDebuggerPage->getGenerateOperationsCheckBox()->isChecked());
if (mpDebuggerPage->getGenerateOperationsCheckBox()->isChecked()) {
mpMainWindow->getOMCProxy()->setCommandLineOptions("+d=infoXmlOperations");
}
mpSettings->endGroup();
}
/*!
Saves the FMI section settings to omedit.ini
*/
void OptionsDialog::saveFMISettings()
{
mpSettings->setValue("FMIExport/Version", mpFMIPage->getFMIExportVersion());
mpSettings->setValue("FMIExport/Type", mpFMIPage->getFMIExportType());
mpSettings->setValue("FMI/FMUName", mpFMIPage->getFMUNameTextBox()->text());
}
/*!
* \brief OptionsDialog::saveTLMSettings
* Saves the TLM settings in omedit.ini
*/
void OptionsDialog::saveTLMSettings()
{
// read TLM Path
mpSettings->setValue("TLM/PluginPath", mpTLMPage->getTLMPluginPathTextBox()->text());
// save the TLM Manager Process
mpSettings->setValue("TLM/ManagerProcess", mpTLMPage->getTLMManagerProcessTextBox()->text());
// save the TLM Monitor Process
mpSettings->setValue("TLM/MonitorProcess", mpTLMPage->getTLMMonitorProcessTextBox()->text());
}
//! Saves the TLM settings to omedit.ini
void OptionsDialog::saveTLMEditorSettings()
{
mpSettings->setValue("TLMEditor/tabPolicy", mpTLMEditorPage->getTabPolicyComboBox()->itemData(mpModelicaTextEditorPage->getTabPolicyComboBox()->currentIndex()).toInt());
mpSettings->setValue("TLMEditor/tabSize", mpTLMEditorPage->getTabSizeSpinBox()->value());
mpSettings->setValue("TLMEditor/indentSize", mpTLMEditorPage->getIndentSpinBox()->value());
mpSettings->setValue("TLMEditor/enableSyntaxHighlighting", mpTLMEditorPage->getSyntaxHighlightingCheckbox()->isChecked());
mpSettings->setValue("TLMEditor/enableLineWrapping", mpTLMEditorPage->getLineWrappingCheckbox()->isChecked());
mpSettings->setValue("TLMEditor/fontFamily", mpTLMEditorPage->getFontFamilyComboBox()->currentFont().family());
mpSettings->setValue("TLMEditor/fontSize", mpTLMEditorPage->getFontSizeSpinBox()->value());
mpSettings->setValue("TLMEditor/textRuleColor", mpTLMEditorPage->getTextRuleColor().rgba());
mpSettings->setValue("TLMEditor/commentRuleColor", mpTLMEditorPage->getCommentRuleColor().rgba());
mpSettings->setValue("TLMEditor/tagRuleColor", mpTLMEditorPage->getTagRuleColor().rgba());
mpSettings->setValue("TLMEditor/quotesRuleColor", mpTLMEditorPage->getQuotesRuleColor().rgba());
mpSettings->setValue("TLMEditor/elementsRuleColor", mpTLMEditorPage->getElementRuleColor().rgba());
}
//! Sets up the Options Widget dialog
void OptionsDialog::setUpDialog()
{
mpOptionsList = new QListWidget;
mpOptionsList->setItemDelegate(new ItemDelegate(mpOptionsList));
mpOptionsList->setViewMode(QListView::ListMode);
mpOptionsList->setMovement(QListView::Static);
mpOptionsList->setIconSize(QSize(24, 24));
mpOptionsList->setCurrentRow(0, QItemSelectionModel::Select);
connect(mpOptionsList, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), SLOT(changePage(QListWidgetItem*,QListWidgetItem*)));
// add items to options list
addListItems();
// get maximum width for options list
mpOptionsList->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
int width = mpOptionsList->sizeHintForColumn(0) + mpOptionsList->frameWidth() * 2 + 20;
if (mpOptionsList->verticalScrollBar()->isVisible()) {
width += mpOptionsList->verticalScrollBar()->width();
}
mpOptionsList->setMaximumWidth(width);
// create pages
createPages();
mpChangesEffectLabel = new Label(tr("* The changes will take effect after restart."));
mpChangesEffectLabel->setElideMode(Qt::ElideMiddle);
// Create the buttons
mpOkButton = new QPushButton(Helper::ok);
mpOkButton->setAutoDefault(true);
connect(mpOkButton, SIGNAL(clicked()), SLOT(saveSettings()));
mpCancelButton = new QPushButton(Helper::cancel);
mpCancelButton->setAutoDefault(false);
connect(mpCancelButton, SIGNAL(clicked()), SLOT(reject()));
mpButtonBox = new QDialogButtonBox(Qt::Horizontal);
mpButtonBox->addButton(mpOkButton, QDialogButtonBox::ActionRole);
mpButtonBox->addButton(mpCancelButton, QDialogButtonBox::ActionRole);
QHBoxLayout *horizontalLayout = new QHBoxLayout;
horizontalLayout->addWidget(mpOptionsList);
QScrollArea *pPagesWidgetScrollArea = new QScrollArea;
pPagesWidgetScrollArea->setWidgetResizable(true);
pPagesWidgetScrollArea->setWidget(mpPagesWidget);
horizontalLayout->addWidget(pPagesWidgetScrollArea);
// Create a layout
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addLayout(horizontalLayout, 0, 0, 1, 2);
mainLayout->addWidget(mpChangesEffectLabel, 1, 0);
mainLayout->addWidget(mpButtonBox, 1, 1);
setLayout(mainLayout);
}
//! Adds items to the list view of Options Widget
void OptionsDialog::addListItems()
{
// General Settings Item
QListWidgetItem *pGeneralSettingsItem = new QListWidgetItem(mpOptionsList);
pGeneralSettingsItem->setIcon(QIcon(":/Resources/icons/general.svg"));
pGeneralSettingsItem->setText(tr("General"));
mpOptionsList->item(0)->setSelected(true);
// Libraries Item
QListWidgetItem *pLibrariesItem = new QListWidgetItem(mpOptionsList);
pLibrariesItem->setIcon(QIcon(":/Resources/icons/libraries.svg"));
pLibrariesItem->setText(Helper::libraries);
// Modelica Text Item
QListWidgetItem *pModelicaTextEditorItem = new QListWidgetItem(mpOptionsList);
pModelicaTextEditorItem->setIcon(QIcon(":/Resources/icons/modeltext.svg"));
pModelicaTextEditorItem->setText(tr("Modelica Text Editor"));
// Graphical Views Item
QListWidgetItem *pGraphicalViewsItem = new QListWidgetItem(mpOptionsList);
pGraphicalViewsItem->setIcon(QIcon(":/Resources/icons/modeling.png"));
pGraphicalViewsItem->setText(tr("Graphical Views"));
// Simulation Item
QListWidgetItem *pSimulationItem = new QListWidgetItem(mpOptionsList);
pSimulationItem->setIcon(QIcon(":/Resources/icons/simulate.svg"));
pSimulationItem->setText(Helper::simulation);
// Messages Item
QListWidgetItem *pMessagesItem = new QListWidgetItem(mpOptionsList);
pMessagesItem->setIcon(QIcon(":/Resources/icons/messages.svg"));
pMessagesItem->setText(tr("Messages"));
// Notifications Item
QListWidgetItem *pNotificationsItem = new QListWidgetItem(mpOptionsList);
pNotificationsItem->setIcon(QIcon(":/Resources/icons/notificationicon.svg"));
pNotificationsItem->setText(tr("Notifications"));
// Pen Style Item
QListWidgetItem *pLineStyleItem = new QListWidgetItem(mpOptionsList);
pLineStyleItem->setIcon(QIcon(":/Resources/icons/linestyle.svg"));
pLineStyleItem->setText(Helper::lineStyle);
// Brush Style Item
QListWidgetItem *pFillStyleItem = new QListWidgetItem(mpOptionsList);