-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
47 lines (37 loc) · 1.2 KB
/
Copy pathmain.cpp
File metadata and controls
47 lines (37 loc) · 1.2 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
40
41
42
43
44
45
46
47
#include <QApplication>
#include <QInputDialog>
#include <QMessageBox>
#include "CameraPermission.h"
#include "CameraWorker.h"
#include "CameraSettingsDialog.h"
#include "CameraWidget.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
if (!requestCameraPermission()) {
QMessageBox::critical(nullptr, "Camera Viewer",
"Camera access denied. Please enable camera access in\n"
"System Settings > Privacy & Security > Camera.");
return 1;
}
QStringList devices = CameraWorker::listDevices();
if (devices.isEmpty()) {
QMessageBox::critical(nullptr, "Camera Viewer", "No cameras found.");
return 1;
}
bool ok = false;
QString selected = QInputDialog::getItem(
nullptr, "Camera Selection", "Select a camera:",
devices, 0, false, &ok
);
if (!ok)
return 0;
int deviceIndex = devices.indexOf(selected);
CameraSettingsDialog settingsDialog(deviceIndex, selected);
if (settingsDialog.exec() != QDialog::Accepted)
return 0;
CameraSettings settings = settingsDialog.settings();
CameraWidget widget(deviceIndex, settings);
widget.show();
return app.exec();
}