格式优化

master
donghualin 2 years ago
parent ab896c674f
commit aa3b4f6b2d
  1. 1
      debian/login-dp4-plugin.install
  2. 5
      dp4-login-plugin/CMakeLists.txt
  3. 6
      dp4-login-plugin/dp4_login_module.cpp
  4. 111
      dp4-login-plugin/dp4loginwidget.cpp
  5. 16
      dp4-login-plugin/dp4loginwidget.h
  6. BIN
      dp4-login-plugin/files/user-192.png
  7. 2
      example/CMakeLists.txt

@ -1,2 +1,3 @@
usr/lib/dde-session-shell/modules/libdp4-login-plugin.so
usr/share/dp4-login-plugin/translations
usr/share/wallpapers/deepin/dp4-login/*.png

@ -14,8 +14,11 @@ file(GLOB_RECURSE SRCS "*.h" "*.cpp")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
ADD_DEFINITIONS(-DQM_FILES_DIR="${CMAKE_BINARY_DIR}/${LIB_NAME}")
ADD_DEFINITIONS(-DUSER_ICON="${CMAKE_BINARY_DIR}/user-192.png")
EXECUTE_PROCESS(COMMAND cp -f ${CMAKE_CURRENT_SOURCE_DIR}/files/user-192.png ${CMAKE_BINARY_DIR}/user-192.png)
else()
ADD_DEFINITIONS(-DQM_FILES_DIR="/usr/share/${LIB_NAME}/translations")
ADD_DEFINITIONS(-DUSER_ICON="/usr/share/wallpapers/deepin/dp4-login/user-192.png")
endif()
find_package(Qt5 COMPONENTS Core Widgets DBus Network LinguistTools REQUIRED)
@ -42,3 +45,5 @@ target_link_libraries(${LIB_NAME} PRIVATE
install(TARGETS ${LIB_NAME} LIBRARY DESTINATION lib/dde-session-shell/modules)# .qm
install(FILES ${QM_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/${LIB_NAME}/translations/)
file(GLOB BGIMAGE files/*.png)
install(FILES ${BGIMAGE} DESTINATION share/wallpapers/deepin/dp4-login)

@ -17,13 +17,11 @@ Dp4LoginModule::Dp4LoginModule(QObject *parent)
, m_callbackFun(nullptr)
, m_callbackData(new AuthCallbackData)
, m_messageCallbackFunc(nullptr)
, m_dp4Widget(new Dp4LoginWidget)
, m_dp4Widget(nullptr)
{
setObjectName(QStringLiteral("Dp4LoginModule"));
installTranslator();
QString testText = tr("test");
QString test1 = tr("my name is");
m_dp4Widget = new Dp4LoginWidget;
// 以下部分爲測試代碼,具體如何寫請根據實際的業務來處理即可
/*m_callbackData->account = "uos";
m_callbackData->token = "1";

@ -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()+"\nUsername:"+username->text()+"\nPassword:"+password->text()).exec();
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,"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);
}

@ -6,12 +6,20 @@
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);
~Dp4LoginWidget();
private:
void Logon();
void ResetPassword();
void initUi();
private:
class QComboBox *m_environment;
class QLineEdit *m_username;
class QLineEdit *m_password;
};
#endif // TESTWIDGET_H

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

@ -19,10 +19,12 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
ADD_DEFINITIONS(-DQM_FILES_DIR="${CMAKE_BINARY_DIR}/dp4-login-plugin")
ADD_DEFINITIONS(-DSERVICE_CONFIG_DIR="${CMAKE_BINARY_DIR}/share/")
ADD_DEFINITIONS(-DSERVICE_LIB_DIR="${CMAKE_BINARY_DIR}/dp4-dbus-service/")
ADD_DEFINITIONS(-DUSER_ICON="${CMAKE_BINARY_DIR}/user-192.png")
else()
ADD_DEFINITIONS(-DSERVICE_CONFIG_DIR="${CMAKE_INSTALL_PREFIX}/share/deepin-service-manager/")
ADD_DEFINITIONS(-DSERVICE_LIB_DIR="${CMAKE_INSTALL_FULL_LIBDIR}/deepin-service-manager/")
ADD_DEFINITIONS(-DQM_FILES_DIR="/usr/lib/dp4-login-plugin/translations")
ADD_DEFINITIONS(-DUSER_ICON="/usr/share/wallpapers/deepin/dp4-login/user-192.png")
endif()
file(GLOB_RECURSE COMPILEFILES *.h *.cpp ../dp4-login-plugin/*.h ../dp4-login-plugin/*.cpp)

Loading…
Cancel
Save