-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
39 lines (32 loc) · 1.17 KB
/
main.cpp
File metadata and controls
39 lines (32 loc) · 1.17 KB
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
#include <iostream>
#include <QApplication>
#include <QScreen>
#include "integratedwindow.hpp"
#include "selectiondialog.hpp"
#include "separatedwindow.hpp"
int main(int argc, char* argv[]) {
QApplication app(argc, argv);
SelectionDialog dialog;
if (dialog.exec() != QDialog::Accepted) {
return 0; // 正确退出,不再启动事件循环
}
QMainWindow* window_ptr;
const auto type = dialog.getSelectedType();
std::cout << "Selected type: " << (type == SelectionDialog::Integrated ? "一体式" : "分离式") << std::endl;
if (type == SelectionDialog::Integrated) {
// 一体式
window_ptr = new IntegratedWindow();
} else {
// 分离式
window_ptr = new SeparatedWindow();
}
window_ptr->setWindowTitle(QString("LinuxGB28181"));
const QRect screenRect = QApplication::primaryScreen()->availableGeometry();
const int screenWidth = screenRect.width();
const int screenHeight = screenRect.height();
const int x = (screenWidth - window_ptr->width()) / 2;
const int y = (screenHeight - window_ptr->height()) / 2;
window_ptr->move(x, y);
window_ptr->show();
return app.exec();
}