-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathmainwindow.h
More file actions
146 lines (112 loc) · 3.84 KB
/
mainwindow.h
File metadata and controls
146 lines (112 loc) · 3.84 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
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
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QPushButton>
#include <QGridLayout>
#include <QtGui>
#include <QAction>
#include <QLabel>
#include <mutex>
#include <atomic>
#include <ic4/ic4.h>
#include <ic4-interop/interop-Qt.h>
#include "PropertyDialog.h"
#include "settings.h"
#include "fpscounter.h"
#include <filesystem>
class MainWindow : public QMainWindow, ic4::QueueSinkListener
{
Q_OBJECT
public:
struct init_options {
std::filesystem::path appDataDirectory;
// If empty, then appDataDirectory / "device.json" is used, if deviceSetupFile.value().empty() no device is opened
std::optional<std::filesystem::path> deviceSetupFile;
// Show the settings menu
bool show_settings_menu = false;
bool start_full_screen = false;
};
explicit MainWindow(const init_options& params, QWidget* parent = nullptr);
~MainWindow();
void showVideoFullScreen();
private:
void onSelectDevice();
void onDeviceProperties();
void onDeviceDriverProperties();
void onToggleTriggerMode();
void startstopstream();
void onShootPhoto();
void onStartCaptureVideo();
void onPauseCaptureVideo();
void onStopCaptureVideo();
void onCodecProperties();
void onDeviceLost();
void onExportDeviceSettings();
void onImportDeviceSettings();
void onCloseDevice();
void onAbout();
void onDisplayContextMenu(const QPoint& pos);
void onToggleFullScreen();
void onFullScreenShowMenuBarToggled(bool checked);
void onFullScreenShowToolBarToggled(bool checked);
void onFullScreenShowStatusBarToggled(bool checked);
void onExitFullScreen();
void onDeviceOpened();
void updateControls();
void updateTriggerControl();
void updateCameraLabel();
void updateStatistics();
void onUpdateStatisticsTimer();
void createUI();
protected:
void closeEvent(QCloseEvent* ev) override;
void changeEvent(QEvent* ev) override;
bool eventFilter(QObject* obj, QEvent* event) override;
private:
void customEvent(QEvent* event);
void savePhoto(const ic4::ImageBuffer& imagebuffer);
void prepareNewDeviceOpen();
Settings _settings = {};
std::filesystem::path _devicefile; // File name of device state xml
std::filesystem::path _codecconfigfile; // File name of device state xml
std::mutex _snapphotomutex;
bool _shootPhoto = false;
std::atomic<bool> _capturetovideo = false;
std::atomic<bool> _videocapturepause = false;
QGridLayout* mainLayout = nullptr;
ic4interop::Qt::DisplayWidget* _VideoWidget = nullptr;
QToolBar* _toolBar = nullptr;
QAction* _DeviceSelectAct = nullptr;
QAction* _DevicePropertiesAct = nullptr;
QAction* _DeviceDriverPropertiesAct = nullptr;
QAction* _TriggerModeAct = nullptr;
QAction* _StartLiveAct = nullptr;
QAction* _ShootPhotoAct = nullptr;
QAction* _recordstartact = nullptr;
QAction* _recordpauseact = nullptr;
QAction* _recordstopact = nullptr;
QAction* _codecpropertyact = nullptr;
QAction* _exportDeviceSettingsAct = nullptr;
QAction* _importDeviceSettingsAct = nullptr;
QAction* _toggleFullscreenAct = nullptr;
QAction* _toggle_visibility_full_screen_menu_bar = nullptr;
QAction* _toggle_visibility_full_screen_tool_bar = nullptr;
QAction* _toggle_visibility_full_screen_status_bar = nullptr;
QAction* _closeDeviceAct = nullptr;
QLabel* _sbStatisticsLabel = nullptr;
QLabel* _sbFpsLabel = nullptr;
QLabel* _sbCameraLabel = nullptr;
QTimer* _updateStatisticsTimer = nullptr;
ic4::PropertyMap _devicePropertyMap;
ic4::Grabber _grabber;
std::shared_ptr<ic4::Display> _display;
std::shared_ptr<ic4::QueueSink> _queuesink;
ic4::VideoWriter _videowriter;
PropertyDialog* _propertyDialog = nullptr;
bool sinkConnected( ic4::QueueSink& sink, const ic4::ImageType& imageType, size_t min_buffers_required ) final;
void framesQueued( ic4::QueueSink& sink ) final;
bool _showSettingsMenu = false;
bool _preFullscreenMaximized = false;
ic4demoapp::FpsCounter _fpsCounter;
};
#endif // MAINWINDOW_H