add login ui

master
TY 2 years ago
parent 141a77ac0f
commit ab896c674f
  1. 1
      dp4-login-plugin/dp4_login_module.cpp
  2. 61
      dp4-login-plugin/dp4loginwidget.cpp
  3. 5
      dp4-login-plugin/dp4loginwidget.h
  4. 4
      dp4-login-plugin/translations/dp4-login-plugin.ts
  5. 3
      example/main.cpp

@ -23,6 +23,7 @@ Dp4LoginModule::Dp4LoginModule(QObject *parent)
installTranslator();
QString testText = tr("test");
QString test1 = tr("my name is");
// 以下部分爲測試代碼,具體如何寫請根據實際的業務來處理即可
/*m_callbackData->account = "uos";
m_callbackData->token = "1";

@ -1,12 +1,68 @@
#include "dp4loginwidget.h"
#include <QComboBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QLineEdit>
#include <QLabel>
#include <QPushButton>
#include <QPixmap>
#include <QAction>
#include <QMessageBox>
#include <QPushButton>
void Dp4LoginWidget::Logon()
{
QMessageBox(QMessageBox::Information,"Logon","Environment:"+environment->currentText()+"\nUsername:"+username->text()+"\nPassword:"+password->text()).exec();
}
Dp4LoginWidget::Dp4LoginWidget(QWidget *parent)
: QWidget(parent)
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);
@ -34,4 +90,5 @@ Dp4LoginWidget::Dp4LoginWidget(QWidget *parent)
layout->addWidget(topWidget);
layout->addWidget(bottomWidget);
// layout->setContentsMargins(0,0,0,0);
*/
}

@ -6,9 +6,12 @@
class Dp4LoginWidget : public QWidget
{
Q_OBJECT
void Logon();
void ResetPassword();
class QComboBox*environment=NULL;
class QLineEdit*username=NULL,*password=NULL;
public:
explicit Dp4LoginWidget(QWidget *parent = nullptr);
};
#endif // TESTWIDGET_H

@ -7,5 +7,9 @@
<source>test</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>my name is</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

@ -32,7 +32,8 @@ int main(int argc, char *argv[])
// 登錄插件的demo
LoginWidget widget;
widget.show();
widget.resize(500, 500);
widget.resize(500, 700);
widget.setStyleSheet("background-color:rgb(10,42,136);color:white;");
return app.exec();
}

Loading…
Cancel
Save