⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 carborn_form.ui.h

📁 嵌入式LINUX的智能家居系统源码
💻 H
字号:
/****************************************************************************** ui.h extension file, included from the uic-generated form implementation.**** If you wish to add, delete or rename functions or slots use** Qt Designer which will update this file, preserving your code. Create an** init() function in place of a constructor, and a destroy() function in** place of a destructor.*****************************************************************************/#include <qpalette.h>#include <stdlib.h>#include <math.h>#include <qdatetime.h>#include "cmd_config.h"static QString password="123456";QString inputword;QString showcode;int wrongtimes=0;void carborn_Form::switcher(int cmd){    QTimer *passtimer = new QTimer(this);    QPalette palette;    int re_cmd;    cmd &= Nui;    int order=cmd&(0xff);    switch (order)    {    case open_door:		passtext->setText( tr( "<h1><p align=\"center\">Welcome to Home !!</p></h1>" ) );	palette.setColor(QPalette::Active, QColorGroup::Text, QColor(0,255,0));	passtext->setPalette(palette);    	passtext->setGeometry(QRect(100,40,440,400));	connect(passtimer, SIGNAL(timeout()), this, SLOT(resetPasstext()));	passtimer->start(2000,true);	wrongtimes=0;	randButton();	//send return	re_cmd=door_opened;	re_cmd |= FROM(DOOR_CMD);	re_cmd |= TO(HOME_CMD);	emit sig_cmd(re_cmd);	break;    case close_door:	passtext->setText( tr( "<h1><p align=\"center\">The door is closing !!</p></h1>" ) );	palette.setColor(QPalette::Active, QColorGroup::Text, QColor(0,255,0));	passtext->setPalette(palette);    	passtext->setGeometry(QRect(100,40,440,400));	connect(passtimer, SIGNAL(timeout()), this, SLOT(resetPasstext()));	passtimer->start(2000,true);	//send return	re_cmd=door_closed;	re_cmd |= FROM(DOOR_CMD);	re_cmd |= TO(HOME_CMD);	emit sig_cmd(re_cmd);	break;    case door_alarm:	passtext->setText( tr( "<h1><p align=\"center\">You haved tried the Wrong Password over   3 times !!!!!</p></h1>" ) );	palette.setColor(QPalette::Active, QColorGroup::Text, QColor(255,0,0));	passtext->setPalette(palette);	passtext->setGeometry(QRect(100,40,440,400));	submitButton->setEnabled(false);	resetButton->setEnabled(false);	connect(passtimer, SIGNAL(timeout()), this, SLOT(resetPasstext()));	connect(passtimer, SIGNAL(timeout()), submitButton, SLOT(setEnabled(false)));	connect(passtimer, SIGNAL(timeout()), resetButton, SLOT(setEnabled(false)));	passtimer->start(600000,true);    //stop 10 minites	randButton();	//send return	re_cmd=door_alarm;	re_cmd |= FROM(DOOR_CMD);	re_cmd |= TO(HOME_CMD);	emit sig_cmd(re_cmd);	break;    }}void carborn_Form::submit(){    if (inputword=="")	return ;    else if (inputword==password)	openDoor();       else if (wrongtimes<2)	codeWrong();        else	alarm();    }void carborn_Form::openDoor(){    QTimer *passtimer = new QTimer(this);    QPalette palette;    passtext->setText( tr( "<h1><p align=\"center\">Welcome to Home !!</p></h1>" ) );    palette.setColor(QPalette::Active, QColorGroup::Text, QColor(0,255,0));    passtext->setPalette(palette);        passtext->setGeometry(QRect(100,40,440,400));    connect(passtimer, SIGNAL(timeout()), this, SLOT(resetPasstext()));    passtimer->start(2000,true);    wrongtimes=0;    randButton();        int cmd=open_door;    cmd |= FROM(DOOR_CMD);    cmd |= TO(DOOR_CMD);    emit sig_cmd(cmd);    }void carborn_Form::codeWrong(){    QTimer *passtimer = new QTimer(this);    passtext->setText( tr( "<h1><p align=\"center\">Password is wrong !!!!!</p></h1>" ) );    QPalette palette;    palette.setColor(QPalette::Active, QColorGroup::Text, QColor(255,0,0));    passtext->setPalette(palette);	        passtext->setGeometry(QRect(100,40,440,400));    connect(passtimer, SIGNAL(timeout()), this, SLOT(resetPasstext()));    passtimer->start(2000,true);    wrongtimes++;    randButton();        int cmd=door_password_wrong;    cmd |= FROM(DOOR_CMD);    cmd |= TO(HOME_CMD);    emit sig_cmd(cmd);}void carborn_Form::alarm(){    int cmd=door_alarm;    cmd |= FROM(DOOR_CMD);    cmd |= TO(DOOR_CMD);    emit sig_cmd(cmd);}void carborn_Form::closeDoor(){    int cmd=close_door;    cmd |= FROM(DOOR_CMD);    cmd |= TO(DOOR_CMD);    emit sig_cmd(cmd);}void carborn_Form::callHost(){    int cmd=talk_back;    cmd |= FROM(DOOR_CMD);    cmd |= TO(HOME_CMD);    emit sig_cmd(cmd);    if (isAudioOn==false)    {	emit sig_start_audio();	visitButton->setText( tr( "Stop Audio" ) );       isAudioOn=true;        }    else    {       emit sig_stop_audio();    	visitButton->setText( tr( "Call the host" ) );       isAudioOn=false;    }}///////////////////////////////////////////////////////////////////////////////////QTime gettime;void carborn_Form::showTime(){    gettime = QTime::currentTime();    QString time_text = gettime.toString();    if((gettime.second() % 2) == 0)        time_text[2] = ' ';    time_text=time_text.left(5);    time_lCDNumber->display(time_text);}int isButtonSet[10];bool isInputing=false;void carborn_Form::randButton(){    isInputing=false;    inputword="";    showcode="";    numlCDNumber->display(showcode);    int randnum,i;    for (i=0;i<10;i++)    {	isButtonSet[i]=0;    }    for (i=0;i<9;i++)    {	randnum=randNumber();	while (isButtonSet[randnum])	{	    randnum=(randnum+3)%10;	}	switch (randnum)	{	case 0:	    numButton0->setGeometry( QRect( 10+(i*100)%300, 40+(i/3)*100, 100, 100 ) );break;	case 1:	    numButton1->setGeometry( QRect( 10+(i*100)%300, 40+(i/3)*100, 100, 100 ) );break;	case 2:	    numButton2->setGeometry( QRect( 10+(i*100)%300, 40+(i/3)*100, 100, 100 ) );break;	case 3:	    numButton3->setGeometry( QRect( 10+(i*100)%300, 40+(i/3)*100, 100, 100 ) );break;	case 4:	    numButton4->setGeometry( QRect( 10+(i*100)%300, 40+(i/3)*100, 100, 100 ) );break;	case 5:	    numButton5->setGeometry( QRect( 10+(i*100)%300, 40+(i/3)*100, 100, 100 ) );break;	case 6:	    numButton6->setGeometry( QRect( 10+(i*100)%300, 40+(i/3)*100, 100, 100 ) );break;	case 7:	    numButton7->setGeometry( QRect( 10+(i*100)%300, 40+(i/3)*100, 100, 100 ) );break;	case 8:	    numButton8->setGeometry( QRect( 10+(i*100)%300, 40+(i/3)*100, 100, 100 ) );break;	case 9:	    numButton9->setGeometry( QRect( 10+(i*100)%300, 40+(i/3)*100, 100, 100 ) );break;	}		isButtonSet[randnum]=1;    }    i=0;    while (isButtonSet[i])	i++;    switch (i)    {    case 0:	numButton0->setGeometry( QRect( 110, 340, 100, 100 ) );break;    case 1:	numButton1->setGeometry( QRect( 110, 340, 100, 100 ) );break;    case 2:	numButton2->setGeometry( QRect( 110, 340, 100, 100 ) );break;    case 3:	numButton3->setGeometry( QRect( 110, 340, 100, 100 ) );break;    case 4:	numButton4->setGeometry( QRect( 110, 340, 100, 100 ) );break;    case 5:	numButton5->setGeometry( QRect( 110, 340, 100, 100 ) );break;    case 6:	numButton6->setGeometry( QRect( 110, 340, 100, 100 ) );break;    case 7:	numButton7->setGeometry( QRect( 110, 340, 100, 100 ) );break;    case 8:	numButton8->setGeometry( QRect( 110, 340, 100, 100 ) );break;    case 9:	numButton9->setGeometry( QRect( 110, 340, 100, 100 ) );break;    }	    isButtonSet[i]=1;}int carborn_Form::randNumber(){    float i;    int randnum;    gettime=QTime::currentTime();    srand(gettime.second());    i=rand();    randnum=((int)i)%10;    return (int)randnum;}void carborn_Form::push0(){    if (inputword.length()<15)    {	isInputing=true;	inputword+="0";	showcode+="-";    }    numlCDNumber->display(showcode);}void carborn_Form::push1(){    if (inputword.length()<15)    {	isInputing=true;	inputword+="1";	showcode+="-";    }    numlCDNumber->display(showcode);}void carborn_Form::push2(){    if (inputword.length()<15)    {	isInputing=true;	inputword+="2";	showcode+="-";    }    numlCDNumber->display(showcode);}void carborn_Form::push3(){    if (inputword.length()<15)    {	isInputing=true;	inputword+="3";	showcode+="-";    }    numlCDNumber->display(showcode);}void carborn_Form::push4(){    if (inputword.length()<15)    {	isInputing=true;	inputword+="4";	showcode+="-";    }    numlCDNumber->display(showcode);}void carborn_Form::push5(){    if (inputword.length()<15)    {	isInputing=true;	inputword+="5";	showcode+="-";    }    numlCDNumber->display(showcode);}void carborn_Form::push6(){    if (inputword.length()<15)    {	isInputing=true;	inputword+="6";	showcode+="-";    }    numlCDNumber->display(showcode);}void carborn_Form::push7(){    if (inputword.length()<15)    {	isInputing=true;	inputword+="7";	showcode+="-";    }    numlCDNumber->display(showcode);}void carborn_Form::push8(){    if (inputword.length()<15)    {	isInputing=true;	inputword+="8";	showcode+="-";    }    numlCDNumber->display(showcode);}void carborn_Form::push9(){    if (inputword.length()<15)    {	isInputing=true;	inputword+="9";	showcode+="-";    }    numlCDNumber->display(showcode);}void carborn_Form::push11(){    if (inputword.length()<15)    {	isInputing=true;	inputword+="*";	showcode+="-";    }    numlCDNumber->display(showcode);}void carborn_Form::push12(){    if (inputword.length()<15)    {	isInputing=true;	inputword+="#";	showcode+="-";    }    numlCDNumber->display(showcode);}void carborn_Form::resetPasstext(){    passtext->setGeometry(QRect(100,490,440,400));}void carborn_Form::autoReset(){    if (!isInputing)	randButton();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -