You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
dp4-uos/dp4-login-plugin/dp4loginwidget.cpp

73 lines
2.7 KiB

#include "dp4loginwidget.h"
#include <QComboBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QLineEdit>
#include <QLabel>
#include <QPushButton>
#include <QPixmap>
#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, tr("Logon"), tr("Environment:") + m_environment->currentText() + "\n" + tr("Username:") + m_username->text() + "\nPassword:" + m_password->text()).exec();
}
void Dp4LoginWidget::ResetPassword()
{
QMessageBox(QMessageBox::Information,tr("Forget Password"),tr("Forget Password")).exec();
// QMessageBox(QMessageBox::Information,QIcon::themeName(),QIcon::themeSearchPaths().join("\n")).exec();
}
void Dp4LoginWidget::initUi()
{
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(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(); });
layout->addWidget(pb);
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);
}