a2176e65 |
1 | // Copyright (c) 2020 OPEN CASCADE SAS |
2 | // |
3 | // This file is part of the examples of the Open CASCADE Technology software library. |
4 | // |
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy |
6 | // of this software and associated documentation files (the "Software"), to deal |
7 | // in the Software without restriction, including without limitation the rights |
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
9 | // copies of the Software, and to permit persons to whom the Software is |
10 | // furnished to do so, subject to the following conditions: |
11 | // |
12 | // The above copyright notice and this permission notice shall be included in all |
13 | // copies or substantial portions of the Software. |
14 | // |
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE |
21 | |
22 | #include "ApplicationCommon.h" |
23 | |
24 | #include <OSD_Environment.hxx> |
25 | |
26 | #include <Standard_WarningsDisable.hxx> |
27 | #include <QApplication> |
a2176e65 |
28 | #include <QLocale> |
29 | #include <QSettings> |
30 | #include <QStringList> |
31 | #include <QTranslator> |
32 | #include <Standard_WarningsRestore.hxx> |
33 | |
34 | int main ( int argc, char* argv[] ) |
35 | { |
a2176e65 |
36 | QApplication aQApp( argc, argv ); |
37 | |
8833fd4d |
38 | #include <Standard_WarningsDisable.hxx> |
39 | Q_INIT_RESOURCE(OCCTOverview); |
40 | #include <Standard_WarningsRestore.hxx> |
41 | |
a2176e65 |
42 | QSettings settings("OCCTOverview.conf", QSettings::IniFormat); |
43 | settings.beginGroup("ApplicationSetting"); |
44 | ApplicationType aCategory = static_cast<ApplicationType>(settings.value("ApplicationType", "").toInt()); |
45 | settings.endGroup(); |
46 | |
47 | ApplicationCommonWindow* aWindow = new ApplicationCommonWindow(aCategory); |
48 | QString aResName(":/icons/lamp.png"); |
49 | aWindow->setWindowIcon(QPixmap(aResName)); |
50 | |
51 | settings.beginGroup("WindowPosition"); |
52 | int x = settings.value("x", -1).toInt(); |
53 | int y = settings.value("y", -1).toInt(); |
54 | int width = settings.value("width", -1).toInt(); |
55 | int height = settings.value("height", -1).toInt(); |
56 | settings.endGroup(); |
57 | |
58 | if (x > 0 && y > 0 && width > 0 && height > 0) |
59 | { |
60 | aWindow->setGeometry(x, y, width, height); |
61 | } |
62 | aWindow->SetApplicationType(aCategory); |
63 | |
64 | aWindow->show(); |
65 | int aResult = aQApp.exec(); |
66 | |
67 | settings.beginGroup("WindowPosition"); |
68 | settings.setValue("x", aWindow->x()); |
69 | settings.setValue("y", aWindow->y()); |
70 | settings.setValue("width", aWindow->width()); |
71 | settings.setValue("height", aWindow->height()); |
72 | settings.endGroup(); |
73 | |
74 | settings.beginGroup("ApplicationSetting"); |
75 | settings.setValue("ApplicationType", aWindow->GetApplicationType()); |
76 | settings.endGroup(); |
77 | |
78 | return aResult; |
79 | } |