-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.cpp
43 lines (40 loc) · 1.4 KB
/
main.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
#include "Mainwindow.h"
#include <QApplication>
#include <QSettings>
#include <QScreen>
#include "Global/GlobalDir.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
#ifndef MOBILE
//Load windows position
QSettings conf(CGlobalDir::Instance()->GetApplicationConfigureFile(),
QSettings::IniFormat);
QScreen *pScreen = QGuiApplication::primaryScreen();
int top = conf.value("UI/MainWindow/top",
pScreen->availableGeometry().height() > w.height()
? (pScreen->availableGeometry().height() - w.height()) >> 1
: 60
).toInt();
int left = conf.value("UI/MainWindow/left",
pScreen->availableGeometry().width() > w.width()
? (pScreen->availableGeometry().width() - w.width()) >> 1
: 60
).toInt();
int Width = conf.value("UI/MainWindow/width",
pScreen->availableGeometry().width() > w.width()
? w.geometry().width()
: pScreen->availableGeometry().width() - 120
).toInt();
int Height = conf.value("UI/MainWindow/height",
pScreen->availableGeometry().height() > w.height()
? w.geometry().height()
: pScreen->availableGeometry().height() - 120
).toInt();
w.resize(Width, Height);
w.move(left, top);
#endif
w.show();
return a.exec();
}