xref: /OK3568_Linux_fs/app/forlinx/flapp/src/plugins/allwinner/camera/CameraUI/src/cameraseldlg.cpp (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 #include <QDebug>
2 #include <QString>
3 
4 #include "main_desktop.h"
5 #include "cameraseldlg.h"
6 #include "ui_cameraseldlg.h"
7 
8 extern main_desktop *g_pStaticMaindesktop;
9 
CameraSelDlg(QWidget * parent)10 CameraSelDlg::CameraSelDlg(QWidget *parent) :
11     QDialog(parent),
12     ui(new Ui::CameraSelDlg)
13 {
14     ui->setupUi(this);
15 	InitCheckBoxStyle();
16 	m_iNewCameraId = -1;
17     SelCheckBox(g_pStaticMaindesktop->m_iCurCamera);
18     connect(ui->buttonGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(onButtonClicked(QAbstractButton*)));
19 
20 #if 0
21     QPalette p=QPalette();
22     p.setColor(QPalette::WindowText,Qt::white);
23     ui->checkBoxVideo0->setPalette(p);
24     ui->checkBoxVideo1->setPalette(p);
25     ui->checkBoxVideo2->setPalette(p);
26     ui->checkBoxVideo3->setPalette(p);
27     ui->checkBoxVideo4->setPalette(p);
28     ui->checkBoxVideo5->setPalette(p);
29     ui->checkBoxVideo6->setPalette(p);
30     ui->checkBoxVideo7->setPalette(p);
31     QPalette pl = QPalette();//this->palette();
32     pl.setColor(QPalette::Window, QColor(0, 0, 0, 200));    //   设置背景颜色为黑色,如果不设置默认为白色
33     this->setPalette(pl);
34     this->setAutoFillBackground(true);
35     this->setWindowOpacity(0.6);     //   背景和元素都设置透明效果
36 #endif
37 }
38 
~CameraSelDlg()39 CameraSelDlg::~CameraSelDlg()
40 {
41     delete ui;
42 }
43 
onButtonClicked(QAbstractButton * button)44 void CameraSelDlg::onButtonClicked(QAbstractButton *button)
45 {
46     qDebug() << QString("Clicked Button : %1").arg(button->text());
47 
48     QList<QAbstractButton*> list = ui->buttonGroup->buttons();
49     foreach (QAbstractButton *pCheckBox, list)
50     {
51         //QString strStatus = pCheckBox->isChecked() ? "Checked" : "Unchecked";
52         //qDebug() << QString("Button : %1 is %2").arg(pCheckBox->text()).arg(strStatus);
53 		if(pCheckBox->isChecked())
54 		{
55             m_iNewCameraId = GetCameraId(pCheckBox->text());
56 			qDebug() << "===Select" << pCheckBox->text() << "iCameraId" << m_iNewCameraId << endl;
57 			break;
58 		}
59     }
60 }
61 
on_pushButtonEnter_clicked()62 void CameraSelDlg::on_pushButtonEnter_clicked()
63 {
64     this->close();
65     g_pStaticMaindesktop->setHidden(false);
66 	g_pStaticMaindesktop->CameraSwitch(m_iNewCameraId);
67 }
68 
GetCameraId(QString QStr)69 int CameraSelDlg::GetCameraId(QString QStr)
70 {
71 	char *pCameraVideo[MAX_TEST_CAMERA]={"Video0","Video1","Video2","Video3","Video4","Video5","Video6","Video7"};
72 	for(int iCnt = 0; iCnt < MAX_TEST_CAMERA; iCnt++)
73 	{
74 		QString Str(pCameraVideo[iCnt]);
75 		//qDebug()<<"Ori:"<<Str<<"Cmp:"<<QStr<<endl;
76 		if(Str.compare(QStr) == 0)
77 		{
78 			return iCnt;
79 		}
80 	}
81 	return -1;
82 }
83 
SelCheckBox(int iCheBoxId)84 void CameraSelDlg::SelCheckBox(int iCheBoxId)
85 {
86     switch(iCheBoxId)
87     {
88         case 0:
89             ui->checkBoxVideo0->setChecked(true);
90             break;
91         case 1:
92             ui->checkBoxVideo1->setChecked(true);
93             break;
94         case 2:
95             ui->checkBoxVideo2->setChecked(true);
96             break;
97         case 3:
98             ui->checkBoxVideo3->setChecked(true);
99             break;
100         case 4:
101             ui->checkBoxVideo4->setChecked(true);
102             break;
103         case 5:
104             ui->checkBoxVideo5->setChecked(true);
105             break;
106         case 6:
107             ui->checkBoxVideo6->setChecked(true);
108             break;
109         case 7:
110             ui->checkBoxVideo7->setChecked(true);
111             break;
112         default:
113             break;
114     }
115 }
116 
InitCheckBoxStyle()117 void CameraSelDlg::InitCheckBoxStyle()
118 {
119     QString QStrStyle("QCheckBox{color:white;background-color:rgb(0, 0, 0,0);}\
120                         QCheckBox::indicator{width: 35px; height:50px; }\
121 						 QCheckBox::indicator:unchecked{image:url(:/icon/unchecked.png);}\
122                          QCheckBox::indicator:checked{image:url(:/icon/checked.png);}");
123 
124 	ui->checkBoxVideo0->setStyleSheet(QStrStyle);
125 	ui->checkBoxVideo1->setStyleSheet(QStrStyle);
126 	ui->checkBoxVideo2->setStyleSheet(QStrStyle);
127 	ui->checkBoxVideo3->setStyleSheet(QStrStyle);
128 	ui->checkBoxVideo4->setStyleSheet(QStrStyle);
129 	ui->checkBoxVideo5->setStyleSheet(QStrStyle);
130 	ui->checkBoxVideo6->setStyleSheet(QStrStyle);
131 	ui->checkBoxVideo7->setStyleSheet(QStrStyle);
132     ui->pushButtonEnter->setStyleSheet(
133                 //正常状态样式
134                 "QPushButton{"
135                 "background-color:rgba(100,225,100,30);"//背景色(也可以设置图片)
136                 "border-style:outset;"                  //边框样式(inset/outset
137                 "border-width:4px;"                     //边框宽度像素
138                 "border-radius:10px;"                   //边框圆角半径像素
139                 "border-color:rgba(255,255,255,30);"    //边框颜色
140                 "color:white;"                //字体颜色
141                 "}"
142                 //鼠标按下样式
143                 "QPushButton:pressed{"
144                 "background-color:rgba(100,255,100,200);"
145                 "border-color:rgba(255,255,255,200);"
146                 "border-style:inset;"
147                 "color:white;"
148                 "}");
149 }
150 
151 
152 
153