forked from m-garanin/zgui-qt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayerconstructdlg.cpp
97 lines (68 loc) · 2.14 KB
/
layerconstructdlg.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
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
#include "layerconstructdlg.h"
#include "scenepanel.h"
#include "utils.h"
#include <QMenuBar>
#include <QLayout>
#include <QDebug>
#include <QSettings>
#include <QDir>
#include <QFileDialog>
CLayerConstructDlg::CLayerConstructDlg(qint32 compkey, QWidget *parent) :
QDialog(parent, Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint),
pathToSettings("settings.ini")
{
resize(800, 400);
setWindowTitle(tr("Sub Scene # %1").arg(compkey));
connect(this, SIGNAL(accepted()), SLOT(onAccepted()));
connect(this, SIGNAL(rejected()), SLOT(onRejected()));
QMenuBar *menuBar = new QMenuBar(this);
menuBar->setDefaultUp(false);
menuBar->setNativeMenuBar(false);
QMenu *camMenu = menuBar->addMenu(tr("Add Cam"));
QAction* action;
QStringList list(getVideoCaptureDevices());
for (int i = 0; i < list.size(); i++){
action = camMenu->addAction(list[i]);
connect(action, SIGNAL(triggered()), SLOT(onVSTriggered()));
}
action = menuBar->addAction(tr("Add Image"));
connect(action, SIGNAL(triggered()), SLOT(onImageTriggered()));
_scenePanel = new CScenePanel(compkey, this);
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setMenuBar(menuBar);
layout->addWidget(_scenePanel);
}
CLayerConstructDlg::~CLayerConstructDlg()
{
}
void CLayerConstructDlg::onVSTriggered()
{
if(QAction *action = qobject_cast<QAction*>(sender()))
{
_scenePanel->addCamLayer(action->text());
}
}
void CLayerConstructDlg::onImageTriggered()
{
QSettings settings(pathToSettings, QSettings::IniFormat);
QString file = QFileDialog::getOpenFileName(this, "Add Image", settings.value("default_dir").toString(), "Image Files (*.png *.jpg *.bmp)");
if (!file.isEmpty())
{
QDir curDir(file);
settings.setValue("default_dir", curDir.absolutePath());
_scenePanel->addImageLayer(file);
}
}
void CLayerConstructDlg::onAccepted()
{
_scenePanel->stop();
}
void CLayerConstructDlg::onRejected()
{
_scenePanel->stop();
}
void CLayerConstructDlg::showEvent(QShowEvent *event)
{
_scenePanel->start();
QDialog::showEvent(event);
}