|
|
|
|
@ -1,4 +1,6 @@ |
|
|
|
|
#include "dp4loginwidget.h" |
|
|
|
|
#include "login_module_interface.h" |
|
|
|
|
|
|
|
|
|
#include <QComboBox> |
|
|
|
|
#include <QHBoxLayout> |
|
|
|
|
#include <QVBoxLayout> |
|
|
|
|
@ -14,9 +16,17 @@ |
|
|
|
|
|
|
|
|
|
Dp4LoginWidget::Dp4LoginWidget(QWidget *parent) |
|
|
|
|
: QWidget(parent) |
|
|
|
|
, m_topWidget(nullptr) |
|
|
|
|
, m_labelImage(nullptr) |
|
|
|
|
, m_labelOtherUser(nullptr) |
|
|
|
|
, m_labelText(nullptr) |
|
|
|
|
, m_layout(nullptr) |
|
|
|
|
, m_environment(nullptr) |
|
|
|
|
, m_username(nullptr) |
|
|
|
|
, m_password(nullptr) |
|
|
|
|
, m_pbForgetPassword(nullptr) |
|
|
|
|
, m_callback(nullptr) |
|
|
|
|
, m_callbackData(new dss::module::AuthCallbackData) |
|
|
|
|
{ |
|
|
|
|
initUi(); |
|
|
|
|
} |
|
|
|
|
@ -25,9 +35,56 @@ Dp4LoginWidget::~Dp4LoginWidget() |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Dp4LoginWidget::setCallback(dss::module::LoginCallBack *callback) |
|
|
|
|
{ |
|
|
|
|
m_callback = callback; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Dp4LoginWidget::updateAuthenResult(int type, int state) |
|
|
|
|
{ |
|
|
|
|
Q_UNUSED(type); |
|
|
|
|
dss::module::AuthState AuthState = static_cast<dss::module::AuthState>(state); |
|
|
|
|
switch (AuthState) { |
|
|
|
|
case dss::module::AuthState::AS_Success: { |
|
|
|
|
// TODO: 登陆成功,此处从界面上修改登陆成功的状态(这里的提示框三为了验证结果,后续实际开发建议不要用这种方式)
|
|
|
|
|
QMessageBox(QMessageBox::Information, tr("Logon"), tr("success")).exec(); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case dss::module::AuthState::AS_Failure: { |
|
|
|
|
// TODO: 登陆失败,从界面上体现登录失败的状态,(这里的提示框三为了验证结果,后续实际开发建议不要用这种方式)
|
|
|
|
|
QMessageBox(QMessageBox::Warning, tr("Logon"), tr("failure")).exec(); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
default: { |
|
|
|
|
// TODO: 其他状态,根据需要决定是否列举出来,例如正在登陆等状态,看看界面是否需要处理,
|
|
|
|
|
// 根据实际情况看看是否需要加上case分支,这里暂时统一按照default(由开发人员自行添加case分支)
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Dp4LoginWidget::setMessage(const QString &type, const QString &message) |
|
|
|
|
{ |
|
|
|
|
// 接收界面发送的消息
|
|
|
|
|
if (type == QString("account_error")) { |
|
|
|
|
// TODO 如果是账户错误,就在界面上体现出来,此处暂时使用消息框代替,具体怎么做由开发人员自己定义
|
|
|
|
|
QMessageBox(QMessageBox::Critical, tr("Logon"), message).exec(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Dp4LoginWidget::Logon() |
|
|
|
|
{ |
|
|
|
|
QMessageBox(QMessageBox::Information, tr("Logon"), tr("Environment:") + m_environment->currentText() + "\n" + tr("Username:") + m_username->text() + "\nPassword:" + m_password->text()).exec(); |
|
|
|
|
// TODO: 这里由开发人员自行添加dp的验证流程,如果在dde-session-shell验证之前,请在这里写验证流程,
|
|
|
|
|
// 如果在dde-session-shell,请在后面写(由开发人员根据实际情况来决定)
|
|
|
|
|
|
|
|
|
|
// 这里将用户名和密码传给dde-session-shell,由dde-session-shell来处理DA的验证,
|
|
|
|
|
if (m_callback) |
|
|
|
|
{ |
|
|
|
|
m_callbackData->account = m_username->text().trimmed().toStdString(); |
|
|
|
|
m_callbackData->token = m_password->text().trimmed().toStdString(); |
|
|
|
|
m_callback->authCallbackFun(m_callbackData, m_callback->app_data); |
|
|
|
|
} |
|
|
|
|
//QMessageBox(QMessageBox::Information, tr("Logon"), tr("Environment:") + m_environment->currentText() + "\n" + tr("Username:") + m_username->text() + "\nPassword:" + m_password->text()).exec();
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Dp4LoginWidget::ResetPassword() |
|
|
|
|
@ -56,7 +113,7 @@ void Dp4LoginWidget::initUi() |
|
|
|
|
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();}); |
|
|
|
|
connect(m_password->addAction(QIcon::fromTheme("media-playback-start"), QLineEdit::TrailingPosition), &QAction::triggered, this, [this] { this->Logon(); }); |
|
|
|
|
m_layout->addWidget(m_password); |
|
|
|
|
m_environment = new QComboBox(m_topWidget); |
|
|
|
|
m_environment->addItem(tr("Production")); |
|
|
|
|
|