xref: /OK3568_Linux_fs/app/forlinx/flapp/src/plugins/allwinner/camera/CameraUI/src/setfirst.cpp (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 #include "setfirst.h"
2 #include "ui_setfirst.h"
3 #include <QDesktopWidget>
4 #include "midwindow.h"
5 #include "main_desktop.h"
6 #include "frmmessagebox.h"
7 extern main_desktop *g_pStaticMaindesktop;
8 #if defined(Q_OS_LINUX)
9 #include <ls_ctrl.h>
10 //#include <asoundlib.h>
11 #endif
12 extern int g_iRecordTime;
13 static int old_recordTime=g_iRecordTime;
14 extern MidWindow *g_MidWindow;
15 extern int open_recordVideo_front,open_recordVideo_rear;
16 extern int open_recordAudio_front,open_recordAudio_rear;
17 extern int open_reverseLine_front,open_reverseLine_rear;
18 extern int open_adas_front,open_adas_rear;
19 extern int g_iCameraHeight,g_iCameraWidth;
20 extern int g_iNowVoiceValue;
21 extern SetFirst *g_pStaticSetfirst;
22 #if defined(Q_OS_LINUX)
23 extern dvr_factory* pdvr;
24 extern dvr_factory* pdvr1;
25 #endif
26 
SetFirst(QWidget * parent)27 SetFirst::SetFirst(QWidget *parent) :
28     QDialog(parent),
29     ui(new Ui::SetFirst)
30 {
31     ui->setupUi(this);
32     qDebug()<<"-----------here0";
33 
34     ui->comboBox->setView(new QListView());
35     voiceButtonState=false;
36     setWindowStyleSheet();
37 
38 #if defined(Q_OS_LINUX)
39     lcd_blk_ctrl_init();
40 #endif
41 
42     ui->voiceSlider->setRange(0,100);
43     ui->voiceSlider->setSingleStep(0.5);
44     ui->lightSlider->setRange(0,100);
45     ui->lightSlider->setSingleStep(5);
46     ui->ColorEffectSlider->setRange(0,100);
47     ui->whiteBalanceSlider->setRange(0,100);
48     ui->ExposureCompensationSlider->setRange(0,100);
49     connect(ui->voiceSlider,SIGNAL(valueChanged(int)),this,SLOT(on_slider_valuechanged(int)));
50     connect(ui->lightSlider,SIGNAL(valueChanged(int)),this,SLOT(on_slider_valuechanged(int)));
51     connect(ui->ColorEffectSlider,SIGNAL(valueChanged(int)),this,SLOT(on_slider_valuechanged(int)));
52     connect(ui->ExposureCompensationSlider,SIGNAL(valueChanged(int)),this,SLOT(on_slider_valuechanged(int)));
53     connect(ui->whiteBalanceSlider,SIGNAL(valueChanged(int)),this,SLOT(on_slider_valuechanged(int)));
54     ui->voiceSlider->setValue(g_iNowVoiceValue);
55     ui->lightSlider->setValue(50);
56     ui->ColorEffectSlider->setValue(50);
57     ui->whiteBalanceSlider->setValue(50);
58     ui->ExposureCompensationSlider->setValue(50);
59     ui->voiceLabel->setText(tr("50"));
60     ui->lightLabel->setText(tr("50"));
61     ui->ColorEffectLabel->setText("50");
62     ui->whiteBalanceLabel->setText("50");
63     ui->ExposureCompensationLabel->setText("50");
64 
65 
66     ui->movieTimeSetting->setRange(1,5);
67     ui->movieTimeSetting->setSingleStep(2);
68     ui->movieTimeSetting->setValue(1);
69     ui->movieTimeSetting->setSuffix(tr("min"));
70 
71 
72     ui->audioButton->setCheckable(true);
73     ui->ADASButton->setCheckable(true);
74     ui->reverseButton->setCheckable(true);
75     ui->movieButton->setCheckable(true);
76     ui->voiceButton->setCheckable(true);
77 
78     qDebug()<<"the value of the config ini:"<<open_adas_front<<open_recordVideo_front<<open_recordAudio_front<<open_reverseLine_front;
79     if(open_adas_front){
80         ui->ADASButton->setChecked(true);
81         ui->ADASButton->setStyleSheet("background-color:#54ff4b;");
82     }else{
83         ui->ADASButton->setChecked(false);
84         ui->ADASButton->setStyleSheet("background-color:#38a4d6;");
85     }
86     if(open_recordVideo_front){
87         ui->movieButton->setChecked(true);
88         ui->movieButton->setStyleSheet("background-color:#54ff4b;");
89     }else{
90         ui->movieButton->setChecked(false);
91         ui->movieButton->setStyleSheet("background-color:#38a4d6;");
92     }
93     if(open_recordAudio_front){
94         ui->audioButton->setChecked(true);
95         ui->audioButton->setStyleSheet("background-color:#54ff4b;");
96     }else{
97         ui->audioButton->setChecked(false);
98         ui->audioButton->setStyleSheet("background-color:#38a4d6;");
99     }
100     if(open_reverseLine_front){
101         ui->reverseButton->setChecked(true);
102         ui->reverseButton->setStyleSheet("background-color:#54ff4b;");
103     }else{
104         ui->reverseButton->setChecked(false);
105         ui->reverseButton->setStyleSheet("background-color:#38a4d6;");
106     }
107     //need update when camera is mount or unmount
108 
109     if(720==g_iCameraHeight)
110     {
111         qDebug()<<"this is a 720p camera";
112         ui->comboBox->setCurrentIndex(1);
113     }else if(1080==g_iCameraHeight)
114     {
115         qDebug()<<"this is a 1080p camera";
116         ui->comboBox->setCurrentIndex(0);
117     }else{
118         qDebug()<<"can't find correct resolution";
119     }
120 
121     //update voice value
122 
123     setSecond_Desk=new Settings(this);
124     setSecond_Desk->FormInCenter();
125     g_pStaticSetfirst=this;
126 }
~SetFirst()127 SetFirst::~SetFirst()
128 {
129     delete ui;
130     delete setSecond_Desk;
131 }
paintEvent(QPaintEvent * event)132 void SetFirst::paintEvent(QPaintEvent *event)
133 {
134     QPainter painter(this);
135     painter.fillRect(this->rect(), QColor(104, 98, 98, 0));
136 }
on_want_window_close()137 void SetFirst::on_want_window_close()
138 {
139     qDebug()<<"here is on_want";
140     qDebug()<<"the window will close";
141     this->close();
142 }
FormInCenter()143 void SetFirst::FormInCenter()
144 {
145     QDesktopWidget w;
146     int deskWidth = w.width();
147     int deskHeight = w.height();
148     this->resize(deskWidth*4/5,deskHeight*4/5);
149     QPoint movePoint(deskWidth / 2 - this->width() / 2, deskHeight / 2 - this->height() / 2);
150     this->move(movePoint);
151 }
152 
UpdateCurCameraState(int iCameraId)153 void SetFirst::UpdateCurCameraState(int iCameraId)
154 {
155     QString CruCamInfo = "当前设置:Video"+ QString::number(iCameraId,10);
156     ui->DisInfoLabel->setText(tr(CruCamInfo.toStdString().data()));
157     ui->DisInfoLabel->setAlignment(Qt::AlignCenter);
158     ui->DisInfoLabel->setStyleSheet("font-size:30px;color:white");
159 	int iCurPreCamState = config_get_startup(iCameraId);
160     if(iCurPreCamState == 1){
161         ui->movieButton->setStyleSheet("background-color:#54ff4b;");
162     }
163     else
164     {
165         ui->movieButton->setStyleSheet("background-color:#38a4d6;");
166     }
167 
168 	int iCurPreAudioState = config_get_sound(iCameraId);
169 	if(iCurPreAudioState == 1){
170 		ui->audioButton->setStyleSheet("background-color:#54ff4b;");
171 	}
172 	else
173 	{
174 		ui->audioButton->setStyleSheet("background-color:#38a4d6;");
175 	}
176 	//printf("SetFirst::UpdateCurCameraState,iCameraId:%d iCurPreCamState:%d iCurPreAudioState:%d\n", iCameraId,iCurPreCamState,iCurPreAudioState);
177 }
178 
179 
update_voice(int value)180 void SetFirst::update_voice(int value)
181 {
182     qDebug()<<"SetFirst change voice";
183     ui->voiceSlider->setValue(value);
184 }
on_slider_valuechanged(int n_value)185 void SetFirst::on_slider_valuechanged(int n_value)
186 {
187     QObject* sender = QObject::sender();
188     if(sender==ui->voiceSlider){
189         qDebug()<<"change the voice"<<n_value;
190         g_iNowVoiceValue=n_value;
191     #if defined(Q_OS_LINUX)
192         qDebug()<<"ready to change the voice";
193         //QString cmd="tinymix 2 "+ QString::number(n_value*2,10);
194         //system((char*)cmd.toStdString().c_str());
195 
196     #endif
197         ui->voiceLabel->setText(QString("%1").arg(n_value));
198     }
199     else if(sender==ui->lightSlider){
200         qDebug()<<"change the light:"<<n_value;
201     #if defined(Q_OS_LINUX)
202         qDebug()<<"ready to change the light";
203         lcd_blk_ctrl((unsigned long)n_value/5);
204     #endif
205         ui->lightLabel->setText(QString("%1").arg(n_value));
206     }else if(sender==ui->ColorEffectSlider){
207         qDebug()<<"change the ColorEffect:"<<n_value;
208     #if defined(Q_OS_LINUX)
209         qDebug()<<"ready to change the contrast";
210 //        if(pdvr!=NULL);
211 //            pdvr->setColorEffectData(n_value);
212     #endif
213         ui->ColorEffectLabel->setText(QString("%1").arg(n_value));
214     }else if(sender==ui->whiteBalanceSlider){
215         qDebug()<<"change the whiteBalance:"<<n_value;
216     #if defined(Q_OS_LINUX)
217         qDebug()<<"ready to change the whiteBalance";
218 //        if(pdvr!=NULL);
219 //            pdvr->setWhiteBlanceData(n_value);
220     #endif
221         ui->whiteBalanceLabel->setText(QString("%1").arg(n_value));
222     }else if(sender==ui->ExposureCompensationSlider){
223         qDebug()<<"change the saturation:"<<n_value;
224     #if defined(Q_OS_LINUX)
225         qDebug()<<"ready to change the saturation";
226 //        if(pdvr!=NULL);
227 //            pdvr->setExposureCompensationData(n_value);
228     #endif
229         ui->ExposureCompensationLabel->setText(QString("%1").arg(n_value));
230     }
231     else{
232         qDebug()<<"no signals";
233     }
234 
235 }
on_audioButton_clicked()236 void SetFirst::on_audioButton_clicked()
237 {
238     if(ui->audioButton->isChecked()){
239         qDebug()<<"Set Current audio "<<g_pStaticMaindesktop->m_iCurCamera<<" enable to record when reboot";
240         config_set_sound(g_pStaticMaindesktop->m_iCurCamera,1);
241         ui->audioButton->setStyleSheet("background-color:#54ff4b;");
242     }
243     else{
244         qDebug()<<"Set Current audio "<<g_pStaticMaindesktop->m_iCurCamera<<" disable to record when reboot";
245         config_set_sound(g_pStaticMaindesktop->m_iCurCamera,0);
246         ui->audioButton->setStyleSheet("background-color:#38a4d6;");
247     }
248 }
on_ADASButton_clicked()249 void SetFirst::on_ADASButton_clicked()
250 {
251     if(ui->ADASButton->isChecked()){
252         qDebug()<<"ADAS 1";
253     #if defined(Q_OS_LINUX)
254         config_set_adas(0,1);
255         open_adas_front=1;
256         ui->ADASButton->setStyleSheet("background-color:#54ff4b;");
257     #endif
258     }
259     else{
260         qDebug()<<"ADAS 0";
261     #if defined(Q_OS_LINUX)
262         config_set_adas(0,0);
263         open_adas_front=0;
264         ui->ADASButton->setStyleSheet("background-color:#38a4d6;");
265     #endif
266     }
267 }
on_movieButton_clicked()268 void SetFirst::on_movieButton_clicked()
269 {
270     if(ui->movieButton->isChecked()){
271         qDebug()<<"Set Current Preview Camera"<<g_pStaticMaindesktop->m_iCurCamera<<" enable to record when reboot";
272         config_set_startup(g_pStaticMaindesktop->m_iCurCamera,1);
273         ui->movieButton->setStyleSheet("background-color:#54ff4b;");
274     }
275     else
276     {
277         qDebug()<<"Set Current Preview Camera"<<g_pStaticMaindesktop->m_iCurCamera<<" disbale to record when reboot";
278         config_set_startup(g_pStaticMaindesktop->m_iCurCamera,0);
279         ui->movieButton->setStyleSheet("background-color:#38a4d6;");
280     }
281 }
on_reverseButton_clicked()282 void SetFirst::on_reverseButton_clicked()
283 {
284     if(ui->reverseButton->isChecked()){
285         qDebug()<<"REVERSE 1";
286     #if defined(Q_OS_LINUX)
287         #if 0
288         config_set_reverseLine(0,1);
289         #endif
290         open_reverseLine_front=1;
291         ui->reverseButton->setStyleSheet("background-color:#54ff4b;");
292     #endif
293     }
294     else{
295         qDebug()<<"REVERSE 0";
296     #if defined(Q_OS_LINUX)
297         #if 0
298         config_set_reverseLine(0,0);
299         #endif
300         open_reverseLine_front=0;
301         ui->reverseButton->setStyleSheet("background-color:#38a4d6;");
302     #endif
303     }
304 }
305 
on_voiceButton_clicked()306 void SetFirst::on_voiceButton_clicked()
307 {
308     if(!voiceButtonState){
309 
310         ui->voiceButton->setStyleSheet("QPushButton{border-image:url(:/icon/no_sound.png)};");
311         ui->voiceSlider->setValue(0);
312         ui->voiceSlider->setEnabled(false);
313         voiceButtonState=true;
314     }
315     else{
316 
317         ui->voiceButton->setStyleSheet("QPushButton{border-image:url(:/icon/sound.png)};");
318         ui->voiceSlider->setValue(g_iNowVoiceValue);
319         ui->voiceSlider->setEnabled(true);
320         voiceButtonState=false;
321     }
322 
323 }
324 
on_movieTimeSetting_valueChanged(int value)325 void SetFirst::on_movieTimeSetting_valueChanged(int value)
326 {
327     qDebug() << "Value : "  << value;
328     qDebug() << "Text : "  << ui->movieTimeSetting->text();
329     g_iRecordTime=value;
330 #if defined(os_test)
331     config_set_cyctime(0,g_iRecordTime);
332 #endif
333 }
on_comboBox_currentIndexChanged(int index)334 void SetFirst::on_comboBox_currentIndexChanged(int index)
335 {
336     qDebug()<<"save the resolutiong change";
337     if(ui->comboBox->currentIndex()==0){
338     #if defined(os_test)
339         config_set_weith(0,1920);
340         config_set_heigth(0,1080);
341     #endif
342 
343     }else if(ui->comboBox->currentIndex()==1){
344     #if defined(os_test)
345         config_set_weith(0,1280);
346         config_set_heigth(0,720);
347     #endif
348     }
349 }
setWindowStyleSheet()350 void SetFirst::setWindowStyleSheet()
351 {
352 
353     QPalette p=QPalette();
354     p.setColor(QPalette::WindowText,Qt::white);
355 
356     ui->label->setPalette(p);
357     ui->label_2->setPalette(p);
358     ui->voiceLabel->setPalette(p);
359     ui->lightLabel->setPalette(p);
360     ui->ColorEffectLabel->setPalette(p);
361     ui->ExposureCompensationLabel->setPalette(p);
362     ui->whiteBalanceLabel->setPalette(p);
363 
364 }
365 
on_settingsButton_clicked()366 void SetFirst::on_settingsButton_clicked()
367 {
368     this->hide();
369     setSecond_Desk->showNormal();
370 }
371 
on_returnButton_clicked()372 void SetFirst::on_returnButton_clicked()
373 {
374     this->close();
375     g_pStaticMaindesktop->setHidden(false);
376 }
377 
378 
379 
380 
381