@ -9,86 +9,65 @@
# include <QAction>
# include <QMessageBox>
# include <QPushButton>
# include <QDebug>
Dp4LoginWidget : : Dp4LoginWidget ( QWidget * parent )
: QWidget ( parent )
, m_environment ( nullptr )
, m_username ( nullptr )
, m_password ( nullptr )
{
initUi ( ) ;
}
Dp4LoginWidget : : ~ Dp4LoginWidget ( )
{
}
void Dp4LoginWidget : : Logon ( )
{
QMessageBox ( QMessageBox : : Information , " Logon " , " Environment: " + environment - > currentText ( ) + " \n Username: " + username - > text ( ) + " \n Password: " + password - > text ( ) ) . exec ( ) ;
QMessageBox ( QMessageBox : : Information , tr ( " Logon " ) , tr ( " Environment: " ) + m_ environment- > currentText ( ) + " \n " + tr ( " Username: " ) + m_ username- > text ( ) + " \n Password: " + m_ password- > text ( ) ) . exec ( ) ;
}
void Dp4LoginWidget : : ResetPassword ( )
{
QMessageBox ( QMessageBox : : Information , " Forget Password " , " Forget Password " ) . exec ( ) ;
// QMessageBox(QMessageBox::Information,QIcon::themeName(),QIcon::themeSearchPaths().join("\n")).exec();
QMessageBox ( QMessageBox : : Information , tr ( " Forget Password " ) , tr ( " Forget Password " ) ) . exec ( ) ;
// QMessageBox(QMessageBox::Information,QIcon::themeName(),QIcon::themeSearchPaths().join("\n")).exec();
}
Dp4LoginWidget : : Dp4LoginWidget ( QWidget * parent ) : QWidget ( parent )
void Dp4LoginWidget : : initUi ( )
{
QWidget * top = new QWidget ( this ) ;
QVBoxLayout * layout = new QVBoxLayout ( this ) ;
QVBoxLayout * layout = new QVBoxLayout ( this ) ;
layout - > setContentsMargins ( 100 , 0 , 100 , 50 ) ; //left,top,right,bottom
QLabel * pic = new QLabel ( top ) ;
pic - > setPixmap ( QPixmap ( " /home/admin/Desktop/user-192.png " ) ) ;
layout - > addWidget ( pic , 0 , Qt : : AlignCenter ) ;
layout - > addWidget ( new QLabel ( " Other User " ) , 0 , Qt : : AlignCenter ) ;
username = new QLineEdit ( top ) ;
username - > setPlaceholderText ( " Username 使用者名稱 " ) ;
username - > setStyleSheet ( " background-color:royalblue; " ) ;
layout - > addWidget ( username ) ;
password = new QLineEdit ( top ) ;
password - > setPlaceholderText ( " Password 密碼 " ) ;
password - > setEchoMode ( QLineEdit : : PasswordEchoOnEdit ) ;
password - > setStyleSheet ( " background-color:royalblue; " ) ;
connect ( password - > addAction ( QIcon : : fromTheme ( " media-playback-start " ) , QLineEdit : : TrailingPosition ) , & QAction : : triggered , this , [ = ] ( ) { this - > Logon ( ) ; } ) ;
layout - > addWidget ( password ) ;
environment = new QComboBox ( top ) ;
environment - > addItem ( " Production " ) ;
environment - > addItem ( " Development " ) ;
environment - > setStyleSheet ( " background-color:royalblue; " ) ;
layout - > addWidget ( environment ) ;
QPushButton * pb = new QPushButton ( " Forget Password 忘記密碼 " , top ) ;
pic - > setPixmap ( QPixmap ( USER_ICON ) ) ;
layout - > addWidget ( pic , 0 , Qt : : AlignCenter ) ;
layout - > addWidget ( new QLabel ( tr ( " Other User " ) ) , 0 , Qt : : AlignCenter ) ;
m_ username = new QLineEdit ( top ) ;
m_ username- > setPlaceholderText ( tr ( " Username " ) ) ;
m_ username- > setStyleSheet ( " background-color:royalblue; " ) ;
layout - > addWidget ( m_ username) ;
m_ password = new QLineEdit ( top ) ;
m_ password- > setPlaceholderText ( tr ( " Password " ) ) ;
m_ password- > setEchoMode ( QLineEdit : : PasswordEchoOnEdit ) ;
m_ password- > setStyleSheet ( " background-color:royalblue; " ) ;
connect ( m_ password- > addAction ( QIcon : : fromTheme ( " media-playback-start " ) , QLineEdit : : TrailingPosition ) , & QAction : : triggered , this , [ = ] ( ) { this - > Logon ( ) ; } ) ;
layout - > addWidget ( m_ password) ;
m_ environment = new QComboBox ( top ) ;
m_ environment- > addItem ( tr ( " Production " ) ) ;
m_ environment- > addItem ( tr ( " Development " ) ) ;
m_ environment- > setStyleSheet ( " background-color:royalblue; " ) ;
layout - > addWidget ( m_ environment) ;
QPushButton * pb = new QPushButton ( tr ( " Forget Password " ) , top ) ;
pb - > setFlat ( true ) ;
connect ( pb , & QPushButton : : released , this , [ = ] ( ) { this - > ResetPassword ( ) ; } ) ;
connect ( pb , & QPushButton : : released , this , [ = ] ( ) { this - > ResetPassword ( ) ; } ) ;
layout - > addWidget ( pb ) ;
const char * const text [ ] = {
" 當你點擊『➔』或按『Enter』,代表你明白及接受以下使用守則。 " ,
" When you click the '➔' button or press 'Enter', indicates you understand and accept the following usage policy. " ,
" 『依據香港法例,未經授權許可擅自使用此電腦終端機,即屬觸犯刑事罪行。』 " ,
" 'Unauthorized use of this Computer Terminal is a Criminal Offence under the Laws of Hong Kong.' "
} ;
for ( unsigned int i = 0 ; i < 4 ; i + + )
{
QLabel * label = new QLabel ( text [ i ] , top ) ;
label - > setWordWrap ( true ) ;
layout - > addWidget ( label ) ;
}
/*
QWidget * topWidget = new QWidget ( this ) ;
QLineEdit * topLineEdit = new QLineEdit ( topWidget ) ;
QPushButton * btn = new QPushButton ( topWidget ) ;
QHBoxLayout * topLayout = new QHBoxLayout ( topWidget ) ;
topLayout - > addWidget ( topLineEdit ) ;
topLayout - > addWidget ( btn ) ;
topLayout - > addStretch ( ) ;
topLayout - > setSpacing ( 0 ) ;
topLayout - > setContentsMargins ( 0 , 0 , 0 , 0 ) ;
QWidget * bottomWidget = new QWidget ( this ) ;
QLineEdit * bottomEdit = new QLineEdit ( bottomWidget ) ;
QPushButton * btnBottom = new QPushButton ( bottomWidget ) ;
QPushButton * btnBottom2 = new QPushButton ( bottomWidget ) ;
QHBoxLayout * bottomLayout = new QHBoxLayout ( bottomWidget ) ;
bottomLayout - > addWidget ( bottomEdit ) ;
bottomLayout - > addWidget ( btnBottom ) ;
bottomLayout - > addWidget ( btnBottom2 ) ;
bottomLayout - > addStretch ( ) ;
bottomLayout - > setContentsMargins ( 50 , 0 , 0 , 0 ) ;
QVBoxLayout * layout = new QVBoxLayout ( this ) ;
layout - > addWidget ( topWidget ) ;
layout - > addWidget ( bottomWidget ) ;
// layout->setContentsMargins(0,0,0,0);
*/
QString warningText = QString ( tr ( " When you click the '➔' button or press 'Enter', indicates you understand and accept the following usage policy. " ) ) + " \n \n "
+ QString ( tr ( " 'Unauthorized use of this Computer Terminal is a Criminal Offence under the Laws of Hong Kong.' " ) ) ;
QLabel * labelText = new QLabel ( top ) ;
labelText - > setWordWrap ( true ) ;
labelText - > setText ( warningText ) ;
layout - > addWidget ( labelText ) ;
}