📄 shutdown.cpp~
字号:
/****************************************************************************** Form implementation generated from reading ui file 'shutdown.ui'**** Created: Tue May 30 18:03:29 2006** by: The User Interface Compiler (uic)**** WARNING! All changes made in this file will be lost!****************************************************************************/#include "shutdown.h"#include <qlabel.h>#include <qpushbutton.h>#include <qlayout.h>#include <qvariant.h>#include <qtooltip.h>#include <qwhatsthis.h>#include <qimage.h>#include <qpixmap.h>#include <qmessagebox.h>#include <stdio.h>#include <unistd.h>#include <sys/wait.h>#include <signal.h>#include "libdriver.h"int execute(char *arglist[]){ int pid,exitstatus; BARCODE_poweron(); pid =fork(); switch (pid) { case -1: perror("fork failed"); return 1; case 0: execvp(arglist[0],arglist); perror("execvp failed"); return 1; default: while( wait(&exitstatus)!=pid); } return 0; } /* * Constructs a shutdown_form which is a child of 'parent', with the * name 'name' and widget flags set to 'f' * * The dialog will by default be modeless, unless you set 'modal' to * TRUE to construct a modal dialog. */shutdown_form::shutdown_form( QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ){ if ( !name ) setName( "shutdown_form" ); resize( 300, 190 ); setCaption( tr( "Shutdown" ) ); PixmapLabel2 = new QLabel( this, "PixmapLabel2" ); PixmapLabel2->setGeometry( QRect( 30, 50, 50, 50 ) ); PixmapLabel2->setPixmap( QPixmap("/mnt/a/myapp/icon/shutdown.png")); PixmapLabel2->setScaledContents( TRUE ); PButshutdown = new QPushButton( this, "PButshutdown" ); PButshutdown->setGeometry( QRect( 181, 11, 120, 31 ) ); PButshutdown->setText( tr( "Shutdown" ) ); PButReboot = new QPushButton( this, "PButReboot" ); PButReboot->setGeometry( QRect( 181, 48, 120, 31 ) ); PButReboot->setText( tr( "Reboot" ) ); PButDebug = new QPushButton( this, "PButDebug" ); PButDebug->setGeometry( QRect( 181, 85, 120, 31 ) ); PButDebug->setText( tr( "Debug Mode" ) ); PButCom = new QPushButton( this, "PButCom" ); PButCom->setGeometry( QRect( 181, 122, 120, 31 ) ); PButCom->setText( tr( "Open Com" ) ); PButCancel = new QPushButton( this, "PButCancel" ); PButCancel->setGeometry( QRect( 180, 170, 120, 31 ) ); PButCancel->setText( tr( "Cancel" ) ); // signals and slots connections connect( PButshutdown, SIGNAL( clicked() ), this, SLOT( shutdown_slot() ) ); connect( PButCom, SIGNAL( clicked() ), this, SLOT( com_slot() ) ); connect( PButCancel, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( PButDebug, SIGNAL( clicked() ), this, SLOT( debug_slot() ) ); connect( PButReboot, SIGNAL( clicked() ), this, SLOT( reboot_slot() ) );}/* * Destroys the object and frees any allocated resources */shutdown_form::~shutdown_form(){ }void shutdown_form::com_slot(){}void shutdown_form::debug_slot(){ char *arglist[4]; arglist[0]="killall"; arglist[1]="launcher"; arglist[2]=0; if(execute(arglist)) QMessageBox::information(this,"Debug mode","Debug mode error!");}void shutdown_form::reboot_slot(){ if (kill(1,SIGTERM)) QMessageBox::information(this,"Reboot","Reboot error!");}void shutdown_form::shutdown_slot(){ if (kill(1,SIGTERM)) //if (kill(1,SIGUSR2)) QMessageBox::information(this,"Shutdown","shutdown error!");}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -