#include "dp4loginwidget.h" #include #include #include #include #include #include #include #include #include #include void Dp4LoginWidget::Logon() { QMessageBox(QMessageBox::Information,"Logon","Environment:"+environment->currentText()+"\nUsername:"+username->text()+"\nPassword:"+password->text()).exec(); } void Dp4LoginWidget::ResetPassword() { QMessageBox(QMessageBox::Information,"Forget Password","Forget Password").exec(); // QMessageBox(QMessageBox::Information,QIcon::themeName(),QIcon::themeSearchPaths().join("\n")).exec(); } Dp4LoginWidget::Dp4LoginWidget(QWidget *parent) : QWidget(parent) { QWidget *top = new QWidget(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); pb->setFlat(true); 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); */ }