xref: /OK3568_Linux_fs/app/forlinx/flapp/src/plugins/allwinner/camera/CameraUI/src/recordseldlg.cpp (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 #include <QDebug>
2 #include <QString>
3 
4 #include "recordseldlg.h"
5 #include "ui_recordseldlg.h"
6 #include "main_desktop.h"
7 
8 
9 extern main_desktop *g_pStaticMaindesktop;
10 
RecordSelDlg(QWidget * parent)11 RecordSelDlg::RecordSelDlg(QWidget *parent) :
12     QDialog(parent),
13     ui(new Ui::RecordSelDlg)
14 {
15     ui->setupUi(this);
16     ui->buttonGroup->setExclusive(false);
17 	InitCheckBoxStyle();
18 	m_pRedCamState = g_pStaticMaindesktop->m_iRedCameraState;
19 	SelCheckBox();
20 	UpdateCurCamera(g_pStaticMaindesktop->m_iCurCamera);
21 	m_pNewRedCameraId = new int[MAX_TEST_CAMERA];
22 	for(int iCnt = 0; iCnt < MAX_TEST_CAMERA; iCnt++)
23 	{
24 		m_pNewRedCameraId[iCnt] = 0xff;
25 	}
26     connect(ui->buttonGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(onButtonClicked(QAbstractButton*)));
27 }
28 
~RecordSelDlg()29 RecordSelDlg::~RecordSelDlg()
30 {
31     delete ui;
32 	delete []m_pNewRedCameraId;
33 }
34 
SelCheckBox()35 void RecordSelDlg::SelCheckBox()
36 {
37 	for(int iCnt = 0; iCnt < MAX_TEST_CAMERA; iCnt++)
38 	{
39 		int iCamerdState = m_pRedCamState[iCnt];
40 		//printf("===RecordSelDlg::SelCheckBox:iCamerdState:%d m_pRedCamState[%d]:%d\n",iCamerdState,iCnt,m_pRedCamState[iCnt]);
41 		if(iCamerdState == 1)
42 		{
43 			switch(iCnt)
44 			{
45 				case 0:
46 					ui->checkBoxVideo0->setChecked(true);
47 					break;
48 				case 1:
49 					ui->checkBoxVideo1->setChecked(true);
50 					break;
51 				case 2:
52 					ui->checkBoxVideo2->setChecked(true);
53 					break;
54 				case 3:
55 					ui->checkBoxVideo3->setChecked(true);
56 					break;
57 				case 4:
58 					ui->checkBoxVideo4->setChecked(true);
59 					break;
60 				case 5:
61 					ui->checkBoxVideo5->setChecked(true);
62 					break;
63 				case 6:
64 					ui->checkBoxVideo6->setChecked(true);
65 					break;
66 				case 7:
67 					ui->checkBoxVideo7->setChecked(true);
68 					break;
69 				default:
70 					break;
71 			}
72 		}
73 		else if(iCamerdState == 0)
74 		{
75 			switch(iCnt)
76 			{
77 				case 0:
78 					ui->checkBoxVideo0->setChecked(false);
79 					break;
80 				case 1:
81 					ui->checkBoxVideo1->setChecked(false);
82 					break;
83 				case 2:
84 					ui->checkBoxVideo2->setChecked(false);
85 					break;
86 				case 3:
87 					ui->checkBoxVideo3->setChecked(false);
88 					break;
89 				case 4:
90 					ui->checkBoxVideo4->setChecked(false);
91 					break;
92 				case 5:
93 					ui->checkBoxVideo5->setChecked(false);
94 					break;
95 				case 6:
96 					ui->checkBoxVideo6->setChecked(false);
97 					break;
98 				case 7:
99 					ui->checkBoxVideo7->setChecked(false);
100 					break;
101 				default:
102 					break;
103 			}
104 		}
105 		else
106 		{
107 			//printf("===The record of camera%d has not been started\n",iCnt);
108 			switch(iCnt)
109 			{
110 				case 0:
111 					ui->checkBoxVideo0->setChecked(false);
112                     ui->checkBoxVideo0->setEnabled(false);
113 					break;
114 				case 1:
115 					ui->checkBoxVideo1->setChecked(false);
116                     ui->checkBoxVideo1->setEnabled(false);
117 					break;
118 				case 2:
119 					ui->checkBoxVideo2->setChecked(false);
120                     ui->checkBoxVideo2->setEnabled(false);
121 					break;
122 				case 3:
123 					ui->checkBoxVideo3->setChecked(false);
124                     ui->checkBoxVideo3->setEnabled(false);
125 					break;
126 				case 4:
127 					ui->checkBoxVideo4->setChecked(false);
128                     ui->checkBoxVideo4->setEnabled(false);
129 					break;
130 				case 5:
131 					ui->checkBoxVideo5->setChecked(false);
132                     ui->checkBoxVideo5->setEnabled(false);
133 					break;
134 				case 6:
135 					ui->checkBoxVideo6->setChecked(false);
136                     ui->checkBoxVideo6->setEnabled(false);
137 					break;
138 				case 7:
139 					ui->checkBoxVideo7->setChecked(false);
140                     ui->checkBoxVideo7->setEnabled(false);
141 					break;
142 				default:
143 					break;
144 			}
145 
146 		}
147 	}
148 }
149 
CheckBoxIsEnabled(int iCameraId)150 bool RecordSelDlg::CheckBoxIsEnabled(int iCameraId)
151 {
152 	switch(iCameraId)
153 	{
154 		case 0:
155 			return ui->checkBoxVideo0->isEnabled();
156 			break;
157 		case 1:
158 			return ui->checkBoxVideo1->isEnabled();
159 			break;
160 		case 2:
161 			return ui->checkBoxVideo2->isEnabled();
162 			break;
163 		case 3:
164 			return ui->checkBoxVideo3->isEnabled();
165 			break;
166 		case 4:
167 			return ui->checkBoxVideo4->isEnabled();
168 			break;
169 		case 5:
170 			return ui->checkBoxVideo5->isEnabled();
171 			break;
172 		case 6:
173 			return ui->checkBoxVideo6->isEnabled();
174 			break;
175 		case 7:
176 			return ui->checkBoxVideo7->isEnabled();
177 			break;
178 		default:
179 			break;
180 	}
181 	return false;
182 }
183 
onButtonClicked(QAbstractButton * button)184 void RecordSelDlg::onButtonClicked(QAbstractButton *button)
185 {
186     qDebug() << QString("Clicked Button : %1").arg(button->text());
187 
188     QList<QAbstractButton*> list = ui->buttonGroup->buttons();
189     foreach (QAbstractButton *pCheckBox, list)
190     {
191         //QString strStatus = pCheckBox->isChecked() ? "Checked" : "Unchecked";
192         //qDebug() << QString("Button : %1 is %2").arg(pCheckBox->text()).arg(strStatus);
193         if(pCheckBox->isChecked())
194         {
195 			int iRedCameraId = GetRedCameraId(pCheckBox->text());
196 			if(iRedCameraId != 0xff)
197 			{
198 				m_pNewRedCameraId[iRedCameraId] = 1;
199 				qDebug() << "===Select" << pCheckBox->text() << "iCameraId" << iRedCameraId << endl;
200 			}
201         }
202 		else
203 		{
204 			int iRedCameraId = GetRedCameraId(pCheckBox->text());
205             if((iRedCameraId != 0xff) && CheckBoxIsEnabled(iRedCameraId))
206 			{
207 				m_pNewRedCameraId[iRedCameraId] = 0;
208 				qDebug() << "===Cancel" << pCheckBox->text() << "iCameraId" << iRedCameraId << endl;
209 			}
210 		}
211 
212     }
213 
214 }
215 
on_pushButtonEnter_clicked()216 void RecordSelDlg::on_pushButtonEnter_clicked()
217 {
218     this->close();
219     g_pStaticMaindesktop->setHidden(false);
220 	g_pStaticMaindesktop->RecordCamSel(m_pNewRedCameraId);
221 }
222 
223 
GetRedCameraId(QString QStr)224 int RecordSelDlg::GetRedCameraId(QString QStr)
225 {
226 	char *pRedCameraVideo[MAX_TEST_CAMERA]={"RedVideo0","RedVideo1","RedVideo2","RedVideo3","RedVideo4","RedVideo5","RedVideo6","RedVideo7"};
227 	for(int iCnt = 0; iCnt < MAX_TEST_CAMERA; iCnt++)
228 	{
229 		QString Str(pRedCameraVideo[iCnt]);
230 		//qDebug()<<"Ori:"<<Str<<"Cmp:"<<QStr<<endl;
231 		if(Str.compare(QStr) == 0)
232 		{
233 			return iCnt;
234 		}
235 	}
236 	return 0xff;
237 }
238 
UpdateCurCamera(int iCameraId)239 void RecordSelDlg::UpdateCurCamera(int iCameraId)
240 {
241     QString CruCamInfo = "当前预览:Video"+ QString::number(iCameraId,10);
242     ui->VideoLabel->setText(tr(CruCamInfo.toStdString().data()));
243     ui->VideoLabel->setAlignment(Qt::AlignCenter);
244     ui->VideoLabel->setStyleSheet("font-size:20px;background-color:rgb(0, 0, 0,0);color:white;");
245 }
246 
InitCheckBoxStyle()247 void RecordSelDlg::InitCheckBoxStyle()
248 {
249     QString QStrStyle("QCheckBox{color:white;background-color:rgb(0, 0, 0,0);}\
250                       QCheckBox::indicator{width: 35px; height:50px; }\
251 						 QCheckBox::indicator:unchecked{image:url(:/icon/unchecked.png);}\
252 						 QCheckBox::indicator:checked{image:url(:/icon/checked.png);}");
253 
254 	ui->checkBoxVideo0->setStyleSheet(QStrStyle);
255 	ui->checkBoxVideo1->setStyleSheet(QStrStyle);
256 	ui->checkBoxVideo2->setStyleSheet(QStrStyle);
257 	ui->checkBoxVideo3->setStyleSheet(QStrStyle);
258 	ui->checkBoxVideo4->setStyleSheet(QStrStyle);
259 	ui->checkBoxVideo5->setStyleSheet(QStrStyle);
260 	ui->checkBoxVideo6->setStyleSheet(QStrStyle);
261 	ui->checkBoxVideo7->setStyleSheet(QStrStyle);
262 
263     ui->pushButtonEnter->setStyleSheet(
264                 //正常状态样式
265                 "QPushButton{"
266                 "background-color:rgba(100,225,100,30);"//背景色(也可以设置图片)
267                 "border-style:outset;"                  //边框样式(inset/outset
268                 "border-width:4px;"                     //边框宽度像素
269                 "border-radius:10px;"                   //边框圆角半径像素
270                 "border-color:rgba(255,255,255,30);"    //边框颜色
271                 "color:white;"                //字体颜色
272                 "}"
273                 //鼠标按下样式
274                 "QPushButton:pressed{"
275                 "background-color:rgba(100,255,100,200);"
276                 "border-color:rgba(255,255,255,200);"
277                 "border-style:inset;"
278                 "color:white;"
279                 "}");
280 }
281 
282 
283 
284