diff --git a/agreementwindow.cpp b/agreementwindow.cpp new file mode 100644 index 0000000..8a63c6e --- /dev/null +++ b/agreementwindow.cpp @@ -0,0 +1,140 @@ +#include "agreementwindow.h" +#include +#include +#include +#include +#include + +#define CONFIG_FILE "/usr/share/ukui-greeter/ukui-greeter.conf" + +AgreementWindow::AgreementWindow(QWidget *parent) : + QWidget(parent) +{ + init(); +} + +bool AgreementWindow::getShowLoginPrompt() +{ + return showLoginPrompt; +} + +void AgreementWindow::initUI() +{ + centerWidget = new QWidget(this); + centerWidget->setObjectName("centerWidget"); + // centerWidget->setFixedSize(960,744); + centerWidget->setStyleSheet("#centerWidget{background-color: rgba(0,0,0,15%);border-radius: 12px;}"); + + QVBoxLayout *layout = new QVBoxLayout(centerWidget); + + + ensureBtn = new QPushButton(this); + ensureBtn->setText(tr("I know")); + ensureBtn->setObjectName("ensureBtn"); + ensureBtn->setFixedSize(240,48); + ensureBtn->setDefault(true); + ensureBtn->setFocusPolicy(Qt::StrongFocus); + ensureBtn->setStyleSheet("#ensureBtn{background-color:rgba(55, 144, 250, 1);border-radius: 6px;}"); + ensureBtn->setStyleSheet("QPushButton{text-align:center;background-color:#3790FA;border-radius: 6px;color:white} \ + QPushButton::hover{background-color:#3489EE;} \ + QPushButton::pressed {background-color:#2C73C8;}"); + connect(ensureBtn, &QPushButton::clicked, this, &AgreementWindow::switchPage); + + titleLbl = new QLabel(centerWidget); + titleLbl->setText(promptTitle); + titleLbl->setObjectName("titleLbl"); + titleLbl->setStyleSheet("#titleLbl{color: white;font-size: 24px;}"); + + browser = new QTextBrowser(centerWidget); + browser->setObjectName("browser"); + browser->setAttribute(Qt::WA_TranslucentBackground); + browser->setStyleSheet("#browser{background-color:transparent;border-radius: none;color: white;font-size: 16px;}"); + browser->verticalScrollBar()->setProperty("drawScrollBarGroove", false); + browser->setContextMenuPolicy(Qt::NoContextMenu); + browser->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); + + setFocusProxy(ensureBtn); + + bool res = loadText(); + if(!res || (promptTitle.isEmpty() && !hideTitle)){ + emit switchToGreeter(); + } + + layout->addSpacing(24); + layout->addWidget(titleLbl); + layout->addWidget(browser); + layout->setAlignment(ensureBtn,Qt::AlignCenter); + layout->setAlignment(titleLbl,Qt::AlignCenter); + + if(hideTitle) + titleLbl->hide(); +} + +void AgreementWindow::switchPage() +{ + emit switchToGreeter(); +} + +void AgreementWindow::resizeEvent(QResizeEvent *event) +{ + // qDebug()<<"" + int m_width = 960,m_height = 722 - 88; + if(this->width() < (960+80)) + m_width = (width() - 80)/2; + if(this->height() < (722+80)) + m_height = (height() - 80)/2; + + centerWidget->setGeometry((width()-m_width)/2,(height()-m_height)/2,m_width,m_height); + + ensureBtn->move((width()-ensureBtn->width())/2,centerWidget->geometry().bottom() + 40); + +} + +bool AgreementWindow::loadText() +{ + if(!promptText.isEmpty()){ + browser->setText(promptText); + return true; + } + + if(promptTextFilePath.isEmpty()) + return false; + QFile file(promptTextFilePath); + if(!file.exists()) + return false; + file.open(QFile::ReadOnly); + QString str(file.readAll()); + if(str == "") + return false; + browser->setText(str); + file.close(); + return true; + +} + +void AgreementWindow::init() +{ + QSettings *settings = new QSettings(CONFIG_FILE,QSettings::IniFormat); + settings->setIniCodec(QTextCodec::codecForName("utf-8")); + + if(settings->contains("Greeter/showLoginPrompt")){ + showLoginPrompt = settings->value("Greeter/showLoginPrompt").toBool(); + } + + if(settings->contains("Greeter/hideTitle")){ + hideTitle = settings->value("Greeter/hideTitle").toBool(); + } + + if(settings->contains("Greeter/promptTitle")){ + promptTitle = settings->value("Greeter/promptTitle").toString(); + } + + if(settings->contains("Greeter/promptText")){ + promptText = settings->value("Greeter/promptText").toString(); + } + + if(settings->contains("Greeter/promptTextFilePath")){ + promptTextFilePath = settings->value("Greeter/promptTextFilePath").toString(); + } + +} diff --git a/agreementwindow.h b/agreementwindow.h new file mode 100644 index 0000000..4dca358 --- /dev/null +++ b/agreementwindow.h @@ -0,0 +1,48 @@ +#ifndef AGREEMENTWINDOW_H +#define AGREEMENTWINDOW_H + +#include +#include +#include +#include +#include + +class AgreementWindow : public QWidget +{ + Q_OBJECT +public: + explicit AgreementWindow(QWidget *parent = nullptr); + bool getShowLoginPrompt(); + void initUI(); + +signals: + void switchToGreeter(); + +protected: + void resizeEvent(QResizeEvent *event); + +protected Q_SLOTS: + void switchPage(); + +private: + void init(); + bool loadText(); + + QTextBrowser *browser = nullptr; + QLabel *titleLbl = nullptr; + QPushButton *ensureBtn = nullptr; + + QFile *file = nullptr; + + bool showLoginPrompt = false; + bool hideTitle = true; + + QString promptTitle = ""; + QString promptText = ""; + QString promptTextFilePath = ""; + + QWidget *centerWidget = nullptr; + +}; + +#endif // AGREEMENTWINDOW_H diff --git a/i18n_ts/bo.ts b/i18n_ts/bo.ts index a474659..16a474d 100644 --- a/i18n_ts/bo.ts +++ b/i18n_ts/bo.ts @@ -1,10 +1,19 @@ + + AgreementWindow + + + + I know + + + AuthDialog - + Authentication failure, Please try again @@ -43,80 +52,80 @@ - + Verify face recognition or enter password to unlock - + Press fingerprint or enter password to unlock - + Verify voiceprint or enter password to unlock - + Verify finger vein or enter password to unlock - + Verify iris or enter password to unlock - + Use the bound wechat scanning code or enter the password to unlock + - Password cannot be empty - + Password: - + Input Password - + Login - + Retry - + Failed to verify %1, please enter password to unlock - - + + Unable to verify %1, please enter password to unlock - - + + Failed to verify %1, you still have %2 verification opportunities - + Abnormal network @@ -1815,37 +1824,37 @@ - + PowerInfo - + Power - + VirtualKeyboard - + SwitchUser - + Multiple users are logged in at the same time.Are you sure you want to reboot this system? - + LAN - + WLAN @@ -2142,17 +2151,17 @@ Screensaver - + Picture does not exist - + View - + You have new notification diff --git a/i18n_ts/bo_CN.ts b/i18n_ts/bo_CN.ts index 0a7d185..65a7c75 100644 --- a/i18n_ts/bo_CN.ts +++ b/i18n_ts/bo_CN.ts @@ -1,6 +1,13 @@ + + AgreementWindow + + I know + + + AuthDialog diff --git a/i18n_ts/es.ts b/i18n_ts/es.ts index c7e3324..c6eb0fb 100644 --- a/i18n_ts/es.ts +++ b/i18n_ts/es.ts @@ -1,6 +1,13 @@ + + AgreementWindow + + I know + + + AuthDialog diff --git a/i18n_ts/fr.ts b/i18n_ts/fr.ts index 875defa..7479a1f 100644 --- a/i18n_ts/fr.ts +++ b/i18n_ts/fr.ts @@ -1,6 +1,13 @@ + + AgreementWindow + + I know + + + AuthDialog diff --git a/i18n_ts/mn.ts b/i18n_ts/mn.ts index cbe399e..c79878b 100644 --- a/i18n_ts/mn.ts +++ b/i18n_ts/mn.ts @@ -4,8 +4,10 @@ AgreementWindow + + I know - ᠪᠢ ᠮᠡᠳᠡᠵᠡᠢ ᠃ + ᠪᠢ ᠮᠡᠳᠡᠵᠡᠢ ᠃ @@ -23,7 +25,7 @@ 使用密码认证 - + Retry ᠳᠠᠬᠢᠵᠤ ᠳᠤᠷᠱᠢᠬᠤ @@ -44,7 +46,7 @@ 已登录 - + Password: 密码: @@ -77,48 +79,48 @@ ᠳᠠᠩᠰᠠ ᠨᠢᠭᠡᠨᠳᠡ ᠦᠨᠢᠳᠡ ᠤᠨᠢᠰᠤᠯᠠᠭᠳᠠᠪᠠ᠃ - + Verify face recognition or enter password to unlock ᠨᠢᠭᠤᠷ ᠱᠢᠷᠪᠢᠵᠤ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠬᠤ ᠪᠤᠶᠤ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ - + Press fingerprint or enter password to unlock ᠬᠤᠷᠤᠭᠤᠨ᠎ᠤ ᠤᠷᠤᠮ ᠳᠠᠷᠤᠬᠤ ᠪᠤᠶᠤ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ - + Verify voiceprint or enter password to unlock ᠳᠠᠭᠤ᠎ᠪᠠᠷ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠬᠤ ᠪᠤᠶᠤ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ - + Verify finger vein or enter password to unlock ᠬᠤᠷᠤᠭᠤᠨ᠎ᠤ ᠨᠠᠮᠵᠢᠭᠤᠨ ᠰᠤᠳᠠᠯ᠎ᠢᠶᠠᠷ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠬᠤ ᠪᠤᠶᠤ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ - + Verify iris or enter password to unlock ᠰᠤᠯᠤᠩᠭ᠎ᠠ ᠪᠦᠷᠬᠦᠪᠴᠢ᠎ᠶᠢ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠬᠤ ᠪᠤᠶᠤ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ - + Input Password ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠬᠤ - + Failed to verify %1, please enter password to unlock %1᠎ᠤ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠤᠯᠳᠠ ᠢᠯᠠᠭᠳᠠᠪᠠ ᠂ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ - - + + Unable to verify %1, please enter password to unlock %1᠎ᠶᠢ/᠎ᠢ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠬᠤ ᠠᠷᠭ᠎ᠠ ᠦᠬᠡᠢ ᠂ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ - + Abnormal network ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠬᠡᠪ᠎ᠦᠨ ᠪᠤᠰᠤ @@ -127,8 +129,8 @@ 使用绑定的微信扫码或输入密码登录 + - Password cannot be empty ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠬᠤᠭᠤᠰᠤᠨ ᠪᠠᠢᠵᠤ ᠪᠤᠯᠬᠤ ᠦᠬᠡᠢ @@ -141,8 +143,8 @@ 无法验证%1,请输入密码. - - + + Failed to verify %1, you still have %2 verification opportunities %1᠎ᠶᠢᠨ/᠎ᠦᠨ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠤᠯᠳᠠ ᠢᠯᠠᠭᠳᠠᠪᠠ ᠂ ᠲᠠ ᠪᠠᠰᠠ%2 ᠤᠳᠠᠭᠠᠨ᠎ᠤ ᠳᠤᠷᠱᠢᠬᠤ ᠵᠠᠪᠱᠢᠶᠠᠨ ᠲᠠᠢ @@ -171,12 +173,12 @@ 请输入密码或者录入指纹 - + Authentication failure, Please try again ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠤᠯᠳᠠ ᠢᠯᠠᠭᠳᠠᠪᠠ ᠂ ᠳᠠᠬᠢᠵᠤ ᠳᠤᠷᠱᠢᠭᠠᠷᠠᠢ - + Use the bound wechat scanning code or enter the password to unlock ᠤᠶᠠᠭᠰᠠᠨ ᠸᠢᠴᠠᠲ᠎ᠢᠶᠠᠷ ᠺᠤᠳ᠋ ᠱᠢᠷᠪᠢᠬᠦ᠌ ᠪᠤᠶᠤ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ @@ -195,7 +197,7 @@ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ - + Login ᠳᠠᠩᠰᠠᠯᠠᠨ ᠤᠷᠤᠬᠤ @@ -2130,37 +2132,37 @@ 游客 - + PowerInfo - + Power ᠴᠠᠬᠢᠯᠭᠠᠨ ᠡᠭᠦᠰᠭᠡᠭᠴᠢ᠃ - + VirtualKeyboard ᠬᠡᠶᠢᠰᠬᠡᠷ ᠲᠠᠷᠤᠭᠤᠯ ᠤᠨ ᠫᠠᠨᠰᠠ᠃ - + SwitchUser ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠶᠢ ᠰᠣᠯᠢᠨ᠎ᠠ᠃ - + Multiple users are logged in at the same time.Are you sure you want to reboot this system? ᠬᠡᠳᠦ ᠬᠡᠳᠦᠨ ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠠᠳᠠᠯᠢ ᠴᠠᠭ᠎ᠲᠤ ᠨᠡᠪᠳᠡᠷᠡᠵᠤ ᠪᠠᠢᠬᠤ ᠪᠠᠢᠳᠠᠯ ᠲᠠᠢ ᠂ ᠲᠠ ᠱᠢᠰᠲ᠋ᠧᠮ᠎ᠡᠴᠡ ᠪᠤᠴᠠᠵᠤ ᠭᠠᠷᠬᠤ ᠤᠤ? - + LAN ᠤᠳᠠᠰᠤᠳᠤ ᠰᠦᠯᠵᠢᠶ᠎ᠡ - + WLAN ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠬᠡᠰᠡᠭ ᠬᠡᠪᠴᠢᠶᠡᠨ᠎ᠦ ᠰᠦᠯᠵᠢᠶ᠎ᠡ @@ -2510,72 +2512,6 @@ - this is only shown for laptops with multiple batteries - - - - - - this is only shown for laptops with multiple batteries - - - - - - laptop primary battery - - - - - - battery-backed AC power source - - - - - - a monitor is a device to measure voltage and current - - - - - - wireless mice with internal batteries - - - - - - wireless keyboard with internal battery - - - - - - portable device - - - - - - cell phone (mobile...) - - - - - - media player, mp3 etc - - - - - - tablet device - - - - - tablet device @@ -2591,7 +2527,7 @@ 退出 - + Picture does not exist ᠵᠢᠷᠤᠭ ᠪᠠᠢᠬᠤ ᠦᠬᠡᠢ @@ -2608,12 +2544,12 @@ 您有%1条未读消息 - + You have new notification ᠲᠠ ᠱᠢᠨ᠎ᠡ ᠮᠡᠳᠡᠭᠳᠡᠯ ᠤᠯᠤᠭᠰᠠᠨ - + View ᠬᠡᠪ ᠦᠵᠡᠬᠦ᠌ diff --git a/i18n_ts/pt.ts b/i18n_ts/pt.ts index 5b9bc1f..5659448 100644 --- a/i18n_ts/pt.ts +++ b/i18n_ts/pt.ts @@ -1,6 +1,13 @@ + + AgreementWindow + + I know + + + AuthDialog diff --git a/i18n_ts/ru.ts b/i18n_ts/ru.ts index b4ee418..cabb146 100644 --- a/i18n_ts/ru.ts +++ b/i18n_ts/ru.ts @@ -1,6 +1,13 @@ + + AgreementWindow + + I know + + + AuthDialog diff --git a/i18n_ts/tr.ts b/i18n_ts/tr.ts index 3d72bb4..138992b 100644 --- a/i18n_ts/tr.ts +++ b/i18n_ts/tr.ts @@ -1,6 +1,15 @@ + + AgreementWindow + + + + I know + + + AuthDialog @@ -16,7 +25,7 @@ Parola - + Retry Yeniden Dene @@ -25,7 +34,7 @@ Kilidi Aç - + Password: Parola @@ -42,7 +51,7 @@ Kimlik doğrulama hatası, hala %1 kalan denemen var - + Authentication failure, Please try again @@ -81,70 +90,70 @@ - + Verify face recognition or enter password to unlock - + Press fingerprint or enter password to unlock - + Verify voiceprint or enter password to unlock - + Verify finger vein or enter password to unlock - + Verify iris or enter password to unlock - + Use the bound wechat scanning code or enter the password to unlock + - Password cannot be empty - + Input Password - + Login - + Failed to verify %1, please enter password to unlock - - + + Unable to verify %1, please enter password to unlock - - + + Failed to verify %1, you still have %2 verification opportunities - + Abnormal network @@ -1897,37 +1906,37 @@ Misafir - + PowerInfo - + Power - + VirtualKeyboard - + SwitchUser Kullanıcı Değiştir - + Multiple users are logged in at the same time.Are you sure you want to reboot this system? - + LAN - + WLAN @@ -2256,17 +2265,17 @@ çıkış - + Picture does not exist - + View - + You have new notification diff --git a/i18n_ts/zh_CN.ts b/i18n_ts/zh_CN.ts index d3559ce..351d419 100644 --- a/i18n_ts/zh_CN.ts +++ b/i18n_ts/zh_CN.ts @@ -1,6 +1,15 @@ + + AgreementWindow + + + + I know + 我已知晓 + + AuthDialog @@ -16,7 +25,7 @@ 使用密码认证 - + Retry 重试 @@ -37,7 +46,7 @@ 已登录 - + Password: 密码: @@ -70,48 +79,48 @@ 账号已被永久锁定 - + Verify face recognition or enter password to unlock 验证人脸识别或输入密码解锁 - + Press fingerprint or enter password to unlock 按压指纹或输入密码解锁 - + Verify voiceprint or enter password to unlock 验证声纹或输入密码解锁 - + Verify finger vein or enter password to unlock 验证指静脉或输入密码解锁 - + Verify iris or enter password to unlock 验证虹膜或输入密码解锁 - + Input Password 输入密码 - + Failed to verify %1, please enter password to unlock 验证%1失败,请输入密码解锁 - - + + Unable to verify %1, please enter password to unlock 无法验证%1,请输入密码解锁 - + Abnormal network 网络异常 @@ -120,8 +129,8 @@ 使用绑定的微信扫码或输入密码登录 + - Password cannot be empty 密码不能为空 @@ -134,8 +143,8 @@ 无法验证%1,请输入密码. - - + + Failed to verify %1, you still have %2 verification opportunities 验证%1失败,您还有%2次尝试机会 @@ -164,12 +173,12 @@ 请输入密码或者录入指纹 - + Authentication failure, Please try again 认证失败,请重试 - + Use the bound wechat scanning code or enter the password to unlock 使用绑定的微信扫码或输入密码解锁 @@ -188,7 +197,7 @@ 密码 - + Login 登录 @@ -2109,16 +2118,6 @@ 123 - - - Ctrl - - - - - Alt - - LockWidget @@ -2142,37 +2141,37 @@ 游客 - + PowerInfo 电源信息 - + Power 电源 - + VirtualKeyboard 虚拟键盘 - + SwitchUser 切换用户 - + Multiple users are logged in at the same time.Are you sure you want to reboot this system? 同时有多个用户登录系统,您确定要退出系统吗? - + LAN 有线网络 - + WLAN 无线局域网 @@ -2545,7 +2544,7 @@ 退出 - + Picture does not exist 图片不存在 @@ -2562,12 +2561,12 @@ 您有%1条未读消息 - + You have new notification 您有新的消息 - + View 预览 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 66b0154..2a9e00f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -73,6 +73,7 @@ qt5_add_resources(dialog_SRC # 头文件中包含了Xlib.h,需要单独拿出来处理,不知道原因 qt5_wrap_cpp(dialog_SRC + agreementwindow.h pam-tally.h fullbackgroundwidget.h lockwidget.h @@ -133,7 +134,8 @@ qt5_wrap_cpp(dialog_SRC set(dialog_SRC ${dialog_SRC} - pam-tally.c + agreementwindow.cpp + pam-tally.c ukui-screensaver-dialog.cpp fullbackgroundwidget.cpp lockwidget.cpp diff --git a/src/agreementwindow.cpp b/src/agreementwindow.cpp new file mode 100644 index 0000000..8a63c6e --- /dev/null +++ b/src/agreementwindow.cpp @@ -0,0 +1,140 @@ +#include "agreementwindow.h" +#include +#include +#include +#include +#include + +#define CONFIG_FILE "/usr/share/ukui-greeter/ukui-greeter.conf" + +AgreementWindow::AgreementWindow(QWidget *parent) : + QWidget(parent) +{ + init(); +} + +bool AgreementWindow::getShowLoginPrompt() +{ + return showLoginPrompt; +} + +void AgreementWindow::initUI() +{ + centerWidget = new QWidget(this); + centerWidget->setObjectName("centerWidget"); + // centerWidget->setFixedSize(960,744); + centerWidget->setStyleSheet("#centerWidget{background-color: rgba(0,0,0,15%);border-radius: 12px;}"); + + QVBoxLayout *layout = new QVBoxLayout(centerWidget); + + + ensureBtn = new QPushButton(this); + ensureBtn->setText(tr("I know")); + ensureBtn->setObjectName("ensureBtn"); + ensureBtn->setFixedSize(240,48); + ensureBtn->setDefault(true); + ensureBtn->setFocusPolicy(Qt::StrongFocus); + ensureBtn->setStyleSheet("#ensureBtn{background-color:rgba(55, 144, 250, 1);border-radius: 6px;}"); + ensureBtn->setStyleSheet("QPushButton{text-align:center;background-color:#3790FA;border-radius: 6px;color:white} \ + QPushButton::hover{background-color:#3489EE;} \ + QPushButton::pressed {background-color:#2C73C8;}"); + connect(ensureBtn, &QPushButton::clicked, this, &AgreementWindow::switchPage); + + titleLbl = new QLabel(centerWidget); + titleLbl->setText(promptTitle); + titleLbl->setObjectName("titleLbl"); + titleLbl->setStyleSheet("#titleLbl{color: white;font-size: 24px;}"); + + browser = new QTextBrowser(centerWidget); + browser->setObjectName("browser"); + browser->setAttribute(Qt::WA_TranslucentBackground); + browser->setStyleSheet("#browser{background-color:transparent;border-radius: none;color: white;font-size: 16px;}"); + browser->verticalScrollBar()->setProperty("drawScrollBarGroove", false); + browser->setContextMenuPolicy(Qt::NoContextMenu); + browser->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); + + setFocusProxy(ensureBtn); + + bool res = loadText(); + if(!res || (promptTitle.isEmpty() && !hideTitle)){ + emit switchToGreeter(); + } + + layout->addSpacing(24); + layout->addWidget(titleLbl); + layout->addWidget(browser); + layout->setAlignment(ensureBtn,Qt::AlignCenter); + layout->setAlignment(titleLbl,Qt::AlignCenter); + + if(hideTitle) + titleLbl->hide(); +} + +void AgreementWindow::switchPage() +{ + emit switchToGreeter(); +} + +void AgreementWindow::resizeEvent(QResizeEvent *event) +{ + // qDebug()<<"" + int m_width = 960,m_height = 722 - 88; + if(this->width() < (960+80)) + m_width = (width() - 80)/2; + if(this->height() < (722+80)) + m_height = (height() - 80)/2; + + centerWidget->setGeometry((width()-m_width)/2,(height()-m_height)/2,m_width,m_height); + + ensureBtn->move((width()-ensureBtn->width())/2,centerWidget->geometry().bottom() + 40); + +} + +bool AgreementWindow::loadText() +{ + if(!promptText.isEmpty()){ + browser->setText(promptText); + return true; + } + + if(promptTextFilePath.isEmpty()) + return false; + QFile file(promptTextFilePath); + if(!file.exists()) + return false; + file.open(QFile::ReadOnly); + QString str(file.readAll()); + if(str == "") + return false; + browser->setText(str); + file.close(); + return true; + +} + +void AgreementWindow::init() +{ + QSettings *settings = new QSettings(CONFIG_FILE,QSettings::IniFormat); + settings->setIniCodec(QTextCodec::codecForName("utf-8")); + + if(settings->contains("Greeter/showLoginPrompt")){ + showLoginPrompt = settings->value("Greeter/showLoginPrompt").toBool(); + } + + if(settings->contains("Greeter/hideTitle")){ + hideTitle = settings->value("Greeter/hideTitle").toBool(); + } + + if(settings->contains("Greeter/promptTitle")){ + promptTitle = settings->value("Greeter/promptTitle").toString(); + } + + if(settings->contains("Greeter/promptText")){ + promptText = settings->value("Greeter/promptText").toString(); + } + + if(settings->contains("Greeter/promptTextFilePath")){ + promptTextFilePath = settings->value("Greeter/promptTextFilePath").toString(); + } + +} diff --git a/src/agreementwindow.h b/src/agreementwindow.h new file mode 100644 index 0000000..4dca358 --- /dev/null +++ b/src/agreementwindow.h @@ -0,0 +1,48 @@ +#ifndef AGREEMENTWINDOW_H +#define AGREEMENTWINDOW_H + +#include +#include +#include +#include +#include + +class AgreementWindow : public QWidget +{ + Q_OBJECT +public: + explicit AgreementWindow(QWidget *parent = nullptr); + bool getShowLoginPrompt(); + void initUI(); + +signals: + void switchToGreeter(); + +protected: + void resizeEvent(QResizeEvent *event); + +protected Q_SLOTS: + void switchPage(); + +private: + void init(); + bool loadText(); + + QTextBrowser *browser = nullptr; + QLabel *titleLbl = nullptr; + QPushButton *ensureBtn = nullptr; + + QFile *file = nullptr; + + bool showLoginPrompt = false; + bool hideTitle = true; + + QString promptTitle = ""; + QString promptText = ""; + QString promptTextFilePath = ""; + + QWidget *centerWidget = nullptr; + +}; + +#endif // AGREEMENTWINDOW_H diff --git a/src/lockwidget.cpp b/src/lockwidget.cpp index fc79fce..cb6723d 100644 --- a/src/lockwidget.cpp +++ b/src/lockwidget.cpp @@ -210,6 +210,79 @@ void LockWidget::setStartupMode(bool mode) m_futureLoadDeskBg = QtConcurrent::run([=](){ setRootWindow(); }); + + m_agreementWindow = new AgreementWindow(this); + + connect(m_agreementWindow, &AgreementWindow::switchToGreeter, this, + [this]() { + switchWnd(0); + update(); + }); + + if(m_agreementWindow->getShowLoginPrompt()){ + switchWnd(1); + m_agreementWindow->initUI(); + }else{ + m_agreementWindow->hide(); + } + } +} + +void LockWidget::switchWnd(int index) +{ + if(authDialog) + authDialog->hide(); + if(m_agreementWindow) + m_agreementWindow->hide(); + ui->widgetTime->show(); + + repaint(); + + switch (index) { + case 0: + if(m_agreementWindow){ + m_agreementWindow->clearFocus(); + } + if(authDialog){ + authDialog->show(); + authDialog->setFocus(); + } + setBottomBtnVisible(true); + break; + case 1: + if(m_agreementWindow) + m_agreementWindow->show(); + ui->widgetTime->hide(); + + setBottomBtnVisible(false); + authDialog->clearFocus(); + m_agreementWindow->setFocusPolicy(Qt::StrongFocus); + setFocusProxy(m_agreementWindow); + m_agreementWindow->setFocus(); + default: + break; + } +} + +void LockWidget::setBottomBtnVisible(bool visible) +{ + if(visible){ + ui->btnSwitchUser->setVisible(btnVisMap.value(ui->btnSwitchUser)); + ui->btnPowerManager->setVisible(btnVisMap.value(ui->btnPowerManager)); + ui->btnKeyboard->setVisible(btnVisMap.value(ui->btnKeyboard)); + btnNetworkManager->setVisible(btnVisMap.value(btnNetworkManager)); + ui->btnBatteryStatus->setVisible(btnVisMap.value(btnNetworkManager)); + }else{ + btnVisMap.insert(ui->btnSwitchUser,!ui->btnSwitchUser->isHidden()); + ui->btnSwitchUser->setVisible(visible); + btnVisMap.insert(ui->btnPowerManager,!ui->btnPowerManager->isHidden()); + ui->btnPowerManager->setVisible(visible); + btnVisMap.insert(ui->btnKeyboard,!ui->btnKeyboard->isHidden()); + ui->btnKeyboard->setVisible(visible); + btnVisMap.insert(btnNetworkManager,!btnNetworkManager->isHidden()); + btnNetworkManager->setVisible(visible); + btnVisMap.insert(ui->btnBatteryStatus,!ui->btnBatteryStatus->isHidden()); + ui->btnBatteryStatus->setVisible(visible); } } @@ -1697,6 +1770,10 @@ void LockWidget::resizeEvent(QResizeEvent *event) authDialog->setGeometry((width()-authDialog->geometry().width())/2,height()/(4-0.65*scale), \ authDialog->width(), (height()*3/4)); + if(m_agreementWindow){ + m_agreementWindow->setGeometry(this->geometry()); + } + if(scale > 1) scale = 1; @@ -1705,7 +1782,7 @@ void LockWidget::resizeEvent(QResizeEvent *event) x = x + ui->btnPowerManager->width(); ui->btnPowerManager->move(width() - x,height() - y); - if(!ui->btnKeyboard->isHidden()){ + if(ui->btnKeyboard){ x = x+ui->btnKeyboard->width()+16; ui->btnKeyboard->move(width() - x, height() - y); } @@ -1713,7 +1790,7 @@ void LockWidget::resizeEvent(QResizeEvent *event) x = x + widgetNetworkManager->width()+16; widgetNetworkManager->move(width() - x, height() - y); - if(!ui->btnSwitchUser->isHidden()) { + if(ui->btnSwitchUser && (!ui->btnSwitchUser->isHidden()||m_isShowUserSwitch) ) { x = x + ui->btnSwitchUser->width()+16; ui->btnSwitchUser->move(width() - x, height() - y); } diff --git a/src/lockwidget.h b/src/lockwidget.h index 6d08f8f..91613c4 100644 --- a/src/lockwidget.h +++ b/src/lockwidget.h @@ -35,6 +35,7 @@ #include "xeventmonitor.h" #include "batterywidget.h" #include "libinputswitchevent.h" +#include "agreementwindow.h" #include namespace Ui { @@ -109,6 +110,7 @@ Q_SIGNALS: // void capsLockChanged(); private: + void switchWnd(int); void initUI(); void initUserMenu(); void setVirkeyboardPos(); @@ -123,6 +125,7 @@ private: void setBottomBtnSheet(); void setCheckedSheet(int type, bool show); void netResetLocation(); + void setBottomBtnVisible(bool visible); QString getLongFormatDate(int type); /** @@ -220,7 +223,7 @@ private: QDBusInterface *batInterface = nullptr; QDBusInterface *iface = nullptr; QDBusInterface *dface = nullptr; - + AgreementWindow *m_agreementWindow = nullptr; // 监听键盘插拔 LibinputSwitchEvent *libswitch = nullptr; @@ -231,6 +234,7 @@ private: QFuture m_futureLoadDeskBg; QTimer *m_timerChkActive = nullptr; + QMap btnVisMap; bool m_isCustomDefault = false; /** 是否默认使用第三方认证 */ bool m_isShowNetwork = true; /** 是否显示网络插件 */ bool m_isShowUserSwitch = true; /** 是否显示用户切换 */