Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
DlgCapture.cpp
1#include <QWindowCapture>
2#include <QFileDialog>
3#include <QLoggingCategory>
4
5#include "DlgCapture.h"
6#include "ui_DlgCapture.h"
7#include "ParameterRecordUI.h"
8
9static Q_LOGGING_CATEGORY(log, "Screen.Capture.Dialog")
10CDlgCapture::CDlgCapture(CParameterScreenCapture *pPara, QWidget *parent)
11 : QDialog(parent)
12 , ui(new Ui::CDlgCapture)
13 , m_pParameters(pPara)
14{
15 ui->setupUi(this);
16
17 setWindowTitle(tr("Screen capture"));
18 setWindowIcon(QIcon::fromTheme("camera-photo"));
19
20 auto screens = QGuiApplication::screens();
21 ui->sbScreen->setMinimum(0);
22 ui->sbScreen->setMaximum(screens.size() - 1);
23 ui->sbScreen->setValue(m_pParameters->GetScreen());
24
25 m_Windows = QWindowCapture::capturableWindows();
26 foreach(auto w, m_Windows)
27 ui->cmbWindows->addItem(w.description());
28
29 //TODO: Complete below
30 ui->rbCustomize->setVisible(false);
31 ui->rbCustomRectangle->setVisible(false);
32
33 switch(m_pParameters->GetTarget())
34 {
35 case CParameterScreenCapture::TARGET::Screen:
36 ui->rbScreen->setChecked(true);
37 break;
38 case CParameterScreenCapture::TARGET::Window:
39 ui->rbWindow->setChecked(true);
40 break;
41 case CParameterScreenCapture::TARGET::CustomRectangle:
42 ui->rbCustomRectangle->setChecked(true);
43 break;
44 case CParameterScreenCapture::TARGET::Curstomize:
45 ui->rbCustomize->setChecked(true);
46 break;
47 }
48
49 switch(m_pParameters->GetOperate())
50 {
51 case CParameterScreenCapture::OPERATE::Shot:
52 ui->rbShot->setChecked(true);
53 break;
54 case CParameterScreenCapture::OPERATE::Record:
55 ui->rbRecord->setChecked(true);
56 break;
57 }
58
59 m_pRecordUI = new CParameterRecordUI(ui->objTab);
60 m_pRecordUI->SetParameter(&m_pParameters->m_Record);
61 ui->objTab->addTab(m_pRecordUI, m_pRecordUI->windowIcon(), m_pRecordUI->windowTitle());
62}
63
64CDlgCapture::~CDlgCapture()
65{
66 delete ui;
67}
68
69void CDlgCapture::accept()
70{
71 int nRet = 0;
72
73 if(!m_pRecordUI->CheckValidity(true)) {
74 ui->objTab->setCurrentWidget(m_pRecordUI);
75 return;
76 }
77
78 if(ui->rbScreen->isChecked())
79 m_pParameters->SetTarget(CParameterScreenCapture::TARGET::Screen);
80 else if(ui->rbWindow->isChecked())
81 m_pParameters->SetTarget(CParameterScreenCapture::TARGET::Window);
82 else if(ui->rbCustomRectangle->isChecked())
83 m_pParameters->SetTarget(CParameterScreenCapture::TARGET::CustomRectangle);
84 else if(ui->rbCustomize->isChecked())
85 m_pParameters->SetTarget(CParameterScreenCapture::TARGET::Curstomize);
86
87 if(ui->rbShot->isChecked())
88 m_pParameters->SetOperate(CParameterScreenCapture::OPERATE::Shot);
89 else if(ui->rbRecord->isChecked())
90 m_pParameters->SetOperate(CParameterScreenCapture::OPERATE::Record);
91
92 m_pParameters->SetScreen(ui->sbScreen->value());
93 int nIndex = ui->cmbWindows->currentIndex();
94 if(-1 < nIndex && nIndex < m_Windows.size())
95 m_pParameters->SetWindow(m_Windows.at(nIndex));
96
97 nRet = m_pRecordUI->Accept();
98 if(nRet)
99 return;
100
101 QDialog::accept();
102}
103
virtual bool CheckValidity(bool validity=false)
Check parameters validity.