From 6181b3fa1aaff13a410ce469b7f96d012cf1cdf5 Mon Sep 17 00:00:00 2001 From: liudun Date: Thu, 16 May 2024 12:34:11 +0800 Subject: [PATCH] fix(Session power management is merged into the lock screen): Session power management is merged into the lock screen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description: Session power management is merged into the lock screen Log: session电源管理合入锁屏 Task: task#195456 子 【2024】基础组件组周例会待办&平时任务&OEM临时任务 / 【刘顿】电源选项点击锁屏的场景方案预研、讨论 --- i18n_ts/bo_CN.ts | 303 +++++++++++++------- i18n_ts/mn.ts | 301 +++++++++++++------- i18n_ts/zh_CN.ts | 289 ++++++++++++------- i18n_ts/zh_HK.ts | 301 +++++++++++++------- src/CMakeLists.txt | 1 + src/assets.qrc | 2 + src/assets/lockscreen.svg | 1 + src/assets/logout.svg | 1 + src/common/definetypes.h | 24 ++ src/dbusifs/login1helper.cpp | 20 ++ src/dbusifs/login1helper.h | 4 + src/dbusifs/sessionhelper.cpp | 159 +++++++++++ src/dbusifs/sessionhelper.h | 13 + src/dbusifs/systemupgradehelper.cpp | 100 +++++++ src/dbusifs/systemupgradehelper.h | 53 ++++ src/lock-backend/dbusupperinterface.cpp | 222 ++++++++++++++- src/lock-backend/dbusupperinterface.h | 18 +- src/lock-backend/gsettingshelper.cpp | 14 + src/lock-backend/gsettingshelper.h | 2 + src/lock-backend/lightdmhelper.cpp | 12 + src/lock-backend/lightdmhelper.h | 2 + src/lock-backend/org.ukui.ScreenSaver.xml | 23 ++ src/lock-command/main.cpp | 30 +- src/lock-dialog/backenddbushelper.cpp | 148 ++++++++++ src/lock-dialog/backenddbushelper.h | 5 + src/lock-dialog/lockdialogmodel.cpp | 95 ++++++- src/lock-dialog/lockdialogmodel.h | 48 ++++ src/lock-dialog/lockdialogperformer.cpp | 8 + src/lock-dialog/main.cpp | 12 + src/widgets/blockwidget.cpp | 31 ++- src/widgets/fullbackgroundwidget.cpp | 90 +++++- src/widgets/fullbackgroundwidget.h | 6 +- src/widgets/lockwidget.cpp | 322 ++++++++++++++++++---- src/widgets/lockwidget.h | 32 ++- src/widgets/poweritemwidget.cpp | 1 + src/widgets/powerlistwidget.cpp | 147 ++++++++-- src/widgets/powerlistwidget.h | 101 ++++++- src/widgets/statusbutton.cpp | 152 ++++++---- src/widgets/statusbutton.h | 3 +- 39 files changed, 2517 insertions(+), 579 deletions(-) create mode 100755 src/assets/lockscreen.svg create mode 100755 src/assets/logout.svg create mode 100755 src/dbusifs/systemupgradehelper.cpp create mode 100755 src/dbusifs/systemupgradehelper.h diff --git a/i18n_ts/bo_CN.ts b/i18n_ts/bo_CN.ts index 2ee5c53..08c46a1 100644 --- a/i18n_ts/bo_CN.ts +++ b/i18n_ts/bo_CN.ts @@ -24,7 +24,7 @@ 使用密码认证 - + Retry བསྐྱར་དུ་ཞིབ་བཤེར་བྱ་དགོས། @@ -53,157 +53,157 @@ 账户锁定%1分钟由于%2次错误尝试 - + Please try again in %1 minutes. ཁྱོད་ཀྱིས་ཡང་བསྐྱར་ཐེངས་གཅིག་ལ་ཚོད་ལྟ་ཞིག་བྱེད་རོགས། - + Please try again in %1 seconds. ཁྱོད་ཀྱིས་དུས་ཚོད་སྐར་ཆ་གཅིག་གི་ནང་དུ་ཡང་བསྐྱར་ཚོད་ལྟ་ཞིག་བྱེད་རོགས། - + Account locked permanently. དུས་གཏན་དུ་ཟྭ་བརྒྱབ་པའི་རྩིས་ཐོ། - - + + Verify face recognition or enter password to unlock ངོ་གདོང་ངོས་འཛིན་ལ་ཞིབ་བཤེར་བྱེད་པའམ་ཡང་ན་གསང་གྲངས་ནང་ - + Guest 游客 - + 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 iris ཞིབ་བཤེར་བྱེད་པའམ་ཡང་ན་གསང་གྲངས་ནང་འཇུག་བྱས་ནས་ཟྭ་ - + Input Password ནང་འཇུག་གི་གསང་གྲངས། - + Username སྤྱོད་མཁན་གྱི་མིང་། - + User name input error! - + login - - - - + + + + Failed to verify %1, please enter password to unlock %1ལ་ཞིབ་བཤེར་བྱེད་མ་ཐུབ་ན། གསང་གྲངས་ནང་འཇུག་བྱས་ནས་ཟྭ་རྒྱག་རོགས། - - - - - + + + + + Unable to verify %1, please enter password to unlock %1ལ་ཞིབ་བཤེར་བྱེད་ཐབས་བྲལ་བ་དང་། གསང་གྲངས་ནང་འཇུག་བྱས་ནས་ཟྭ་རྒྱག་རོགས། - + Abnormal network རྒྱུན་ལྡན་མིན་པའི་དྲ་ - + Face recognition waiting time out, please click refresh or enter the password to unlock. མིའི་གདོང་ལ་དབྱེ་འབྱེད་བྱེད་པར་རེ་སྒུག་བྱེད་དུས་གསང་གྲངས་ཀྱི་སྒོ་ལྕགས་རྒྱག་རོགས། - + FingerPrint མཛུབ་རིས། - + FingerVein FingerVein - + Iris Iris - + Face མིའི་གདོང་། - + VoicePrint སྒྲ་རིས། - - + + Ukey བདེ་འཇགས་གསང་ལྡེ་ - - + + QRCode དོན་ཚན་གཉིས་པ། - + fingerprint མཛུབ་རིས། - + fingervein སྡོད་རྩ་ཞེས་པ་ནི་སྡོད་རྩར - + iris འཇའ་སྐྱི། - + face ངོ་གདོང་། - + voiceprint སྒྲ་གདངས་ཀྱི་རི་མོ། @@ -212,8 +212,8 @@ 使用绑定的微信扫码或输入密码登录 - - + + Password cannot be empty གསང་གྲངས་སྟོང་པ་ཡིན་མི་སྲིད། @@ -226,8 +226,8 @@ 无法验证%1,请输入密码. - - + + Failed to verify %1, you still have %2 verification opportunities %1ལ་ཞིབ་བཤེར་བྱེད་མ་ཐུབ་ན། ཁྱེད་ཚོར་ད་དུང་%2ལ་ཞིབ་བཤེར་བྱེད་པའི་གོ་སྐབས་ཡོད། @@ -256,13 +256,13 @@ 请输入密码或者录入指纹 - - + + Authentication failure, Please try again བདེན་དཔང་ར་སྤྲོད་བྱེད་མ་ཐུབ་ན། ཡང་བསྐྱར་ཚོད་ལྟ་ཞིག - + Use the bound wechat scanning code or enter the password to unlock འབྲེལ་མཐུད་ཀྱི་འཕྲིན་ཕྲན་ཞིབ་བཤེར་ཨང་གྲངས་སམ་ཡང་ན་གསང་གྲངས་ནང་འཇུག་བྱས་ནས་ཟྭ་རྒྱག་པ། @@ -275,13 +275,13 @@ བདེ་འཇགས་ཀྱི་གསང་བའི་ལྡེ་མིག་དེ་USBཡི་སྣེ་འདྲེན་དུ་འཇུག་རོགས། - + Password གསང་གྲངས། - - + + Login ཐོ་འགོད་བྱེད་པ། @@ -406,36 +406,41 @@ - + Cancel ཕྱིར་འཐེན། - + Confrim དངོས་སུ་ཁས་ལེན་པ། - The following program is running to prevent the system from reboot! - གཤམ་གྱི་གོ་རིམ་ནི་མ་ལག་བསྐྱར་དུ་འབྱུང་བར་སྔོན་འགོག་བྱེད་ཆེད་ཡིན། + The following programs prevent restarting, you can click "Cancel" and then close these programs. + གཤམ་གྱི་གོ་རིམ་གྱིས་བསྐྱར་དུ་སྒོ་འབྱེད་པར་བཀག་འགོག་བྱས་ན། ཁྱེད་ཀྱིས་"མེད་པར་བཟོ་"བའི་"རྗེས་སུ་གོ་རིམ་འདི་དག་སྒོ་རྒྱག་ཆོག - The following program is running to prevent the system from shutting down! - གཤམ་གྱི་གོ་རིམ་ནི་མ་ལག་གི་སྒོ་རྒྱག་པར་བཀག་འགོག་བྱེད་པའི་ཆེད་དུ་ཡིན། + The following programs prevent the shutdown, you can click "Cancel" and then close these programs. + གཤམ་གྱི་གོ་རིམ་གྱིས་འགག་སྒོ་བཀག་འགོག་བྱས་ན་ཁྱེད་ཀྱིས་"མེད་པར་བཟོ་"བའི་རྗེས་སུ་གོ་རིམ་འདི་དག་སྒོ་རྒྱག་ཆོག - The following program is running to prevent the system from suspend! - གཤམ་གྱི་གོ་རིམ་ནི་མ་ལག་གནས་སྐབས་མཚམས་འཇོག་པར་བཀག་འགོག་བྱེད་པའི་ཆེད་དུ་ཡིན། + The following programs prevent suspend, you can click "Cancel" and then close these programs. + གཤམ་གྱི་གོ་རིམ་གྱིས་གཉིད་མི་ཁུག་པར་བཀག་འགོག་བྱས་ན་ཁྱེད་ཀྱིས་"མེད་པར་བཟོ་"བ་དང་དེ་ནས་གོ་རིམ་འདི་དག་སྒོ་རྒྱག་ཆོག - The following program is running to prevent the system from hibernate! - གཤམ་གྱི་གོ་རིམ་ནི་མ་ལག་ལ་བཀག་འགོག་བྱེད་པའི་ཆེད་དུ་ཡིན། + The following programs prevent hibernation, you can click "Cancel" and then close these programs. + གཤམ་གྱི་གོ་རིམ་གྱིས་ངལ་གསོ་བར་བཀག་འགོག་བྱས་ན་ཁྱེད་ཀྱིས་"མེད་པར་བཟོ་"བའི་རྗེས་སུ་གོ་རིམ་འདི་དག་སྒོ་རྒྱག་ཆོག + + + + The following programs prevent you from logging out, you can click "Cancel" and then close them. + གཤམ་གྱི་གོ་རིམ་གྱིས་ཐོ་ཁོངས་ནས་སུབ་པར་བཀག་འགོག་བྱས་ན། ཁྱེད་ཀྱིས་"མེད་པར་བཟོ་"བའི་"རྗེས་སུ་གོ་རིམ་འདི་དག་སྒོ་རྒྱག་ཆོག @@ -1948,17 +1953,17 @@ LightDMHelper - + failed to start session. - + Login ཐོ་འགོད་བྱེད་པ། - + Guest 游客 @@ -2002,61 +2007,87 @@ སྐུད་མེད་ཅུས་ཁོངས་ཀྱི་དྲ་བ། - + + system-monitor + མ་ལག་གི་ལྟ་ཞིབ་ཡོ་བྱད། + + + + Restart + ཡང་བསྐྱར་འགོ་འཛུགས་ + + + + Multiple users are logged in at the same time.Are you sure you want to %1 this system? སྤྱོད་མཁན་མང་པོ་ཞིག་དུས་གཅིག་ཏུ་ཐོ་འགོད་བྱས། ཁྱེད་རང་གིས་%1མ་ལག་འདི་གཏན་འཁེལ་བྱེད་དགོས་སམ། + + + Reboot + བསྐྱར་དུ་སྒོ་འབྱེད་དགོས། + + + + PowerOff + གནམ་གྲུའི་སྒོ་རྒྱག་དགོས། + + + + Shut Down + ལས་མཚམས་འཇོག + LoginOptionsWidget - - + + Login Options ཐོ་འགོད་ཀྱི་བསལ་འདེམས་ཀྱི་དབང་ཆ། - + Password གསང་གྲངས། - + Other གཞན་དག - + FingerPrint མཛུབ་རིས། - + FingerVein སྡོད་རྩ་ཞེས་པ་ནི་སྡོད་རྩར - + Iris འཇའ་སྐྱི། - + Face ངོ་གདོང་། - + VoicePrint སྒྲ་གདངས་ཀྱི་རི་མོ། - + Ukey བདེ་འཇགས་གསང་ལྡེ་ - + QRCode དོན་ཚན་གཉིས་པ། @@ -2065,7 +2096,7 @@ 微信 - + Identify device removed! དབྱེ་འབྱེད་སྒྲིག་ཆས་མེད་པར་བཟོ་དགོས། @@ -2260,61 +2291,102 @@ PowerListWidget - - + + Hibernate ཧིན་རྡུ་ཉི་ཞི་ཡ། - - + + Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left གློག་ཀླད་ཀྱི་སྒོ་བརྒྱབ་ནས་བཀོལ་སྤྱོད་བྱེད་སྐབས་ཐོག་མཐའ་བར་གསུམ་དུ་རྣམ་པ་རྒྱུན་འཁྱོངས་བྱེད་ཐུབ། གློག་ཀླད་ཀྱི་ཁ་ཕྱེ་དུས་ཁྱོད་དང་ཁ་བྲལ་བའི་རྣམ་པ་སླར་གསོ་བྱེད་ཐུབ། - - + + Suspend གནས་སྐབས་མཚམས་འཇོག་ - - + + The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off གློག་ཀླད་ཀྱི་ཁ་ཕྱེ་བའི་རྣམ་པ་རྒྱུན་འཁྱོངས་བྱས་མོད། འོན་ཀྱང་གློག་ཟད་ཚད་ཅུང་ཉུང་། ཉེར་སྤྱོད་ཚོགས་འདུའི་ཐོག་ཁ་ཕྱེ་ནས་མགྱོགས་མྱུར་ངང་གློག་ཀླད་དཀྲོགས་ཏེ་ཁྱོད་དང་ཁ་བྲལ་བའི་རྣམ་པ་སླར་གསོ་བྱེད་ཐུབ། - - + + Restart ཡང་བསྐྱར་འགོ་འཛུགས་ - + Close all apps, and then restart your computer བཀོལ་སྤྱོད་ཡོད་ཚད་སྒོ་བརྒྱབ་རྗེས་གློག་ཀླད་བསྐྱར་དུ་སྒོ་ཕྱེ་བ་རེད། - - + + Shut Down - ལས་མཚམས་འཇོག + ལས་མཚམས་འཇོག + + + + + The current user logs out of the system, terminates the session, and returns to the login page + མིག་སྔར་སྤྱོད་མཁན་གྱི་ཐོ་ཁོངས་ནས་སུབ་པ་དང་། ཚོགས་འདུ་གྲོལ་མཚམས་བཞག་ནས་ཤོག་ངོས་སུ་འགོད་དགོས། + + + + Logout + ཐོ་ཁོངས་ནས་སུབ་དགོས། Power Off གློག་ཆད་པ། - - + + Close all apps, and then shut down your computer བཀོལ་སྤྱོད་ཡོད་ཚད་སྒོ་བརྒྱབ་ནས་གློག་ཀླད་སྒོ་རྒྱག་དགོས། - + + + SwitchUser + སྤྱོད་མཁན་བརྗེ་དགོས། + + + + + LockScreen + ཟྭ་བརྒྱབ་པ། + + + + + Log Out + ཕྱིར་འཐེན་བྱ་དགོས། + + + + + UpgradeThenRestart + གསར་བཅོས་བྱས་རྗེས་བསྐྱར་དུ་སྒོ་འབྱེད་དགོས། + + + Close all apps, turn off your computer, and then turn your computer back on སྤྱོད་སྒོ་ཡོད་ཚད་སྒོ་བརྒྱབ་ནས་གློག་ཀླད་སྒོ་རྒྱག་པ་དང་། དེ་ནས་ཡང་བསྐྱར་གློག་ཀླད་ཀྱི་ཁ་ཕྱེ་བ་རེད། + + + + UpgradeThenShutdown + རྒྱབ་སྒོ་གསར་སྒྱུར་བྱེད་དགོས། + PowerManager @@ -2394,39 +2466,39 @@ QObject - + The screensaver is active. བརྙན་ཤེལ་འདི་འགུལ་སྐྱོད་བྱེད་བཞིན་ཡོད། - + The screensaver is inactive. བརྙན་ཤེལ་འདི་ལ་ནུས་པ་མེད། FingerPrint - + མཛུབ་རིས། FingerVein - + སྡོད་རྩ་ཞེས་པ་ནི་སྡོད་རྩར Iris - + འཇའ་སྐྱི། Face - + ངོ་གདོང་། VoicePrint - + སྒྲ་གདངས་ཀྱི་རི་མོ། @@ -2436,7 +2508,7 @@ QRCode - དོན་ཚན་གཉིས་པ། + དོན་ཚན་གཉིས་པ། @@ -2599,7 +2671,7 @@ Login - ཐོ་འགོད་བྱེད་པ། + ཐོ་འགོད་བྱེད་པ། @@ -2677,6 +2749,15 @@ + + action + + + + which block type + + + delay @@ -2727,6 +2808,24 @@ show blank and delay to lock,param:idle/lid/lowpower + + + + show the session tools + + + + + + show the app block window + + + + + + show the multiUsers block window + + Dialog for the ukui ScreenSaver. diff --git a/i18n_ts/mn.ts b/i18n_ts/mn.ts index 3684b19..a5a733d 100644 --- a/i18n_ts/mn.ts +++ b/i18n_ts/mn.ts @@ -24,7 +24,7 @@ 使用密码认证 - + Retry ᠳᠠᠬᠢᠵᠤ ᠳᠤᠷᠱᠢᠬᠤ @@ -53,157 +53,157 @@ 账户锁定%1分钟由于%2次错误尝试 - + Please try again in %1 minutes. %1 ᠮᠢᠨᠦ᠋ᠲ᠎ᠦᠨ ᠳᠠᠷᠠᠭ᠎ᠠ ᠳᠠᠬᠢᠵᠤ ᠳᠤᠷᠠᠱᠢᠭᠠᠷᠠᠢ - + Please try again in %1 seconds. %1 ᠮᠢᠨᠦ᠋ᠲ᠎ᠦᠨ ᠳᠠᠷᠠᠭ᠎ᠠ ᠳᠠᠬᠢᠵᠤ ᠳᠤᠷᠠᠱᠢᠭᠠᠷᠠᠢ - + Account locked permanently. ᠳᠠᠩᠰᠠ ᠨᠢᠭᠡᠨᠳᠡ ᠦᠨᠢᠳᠡ ᠤᠨᠢᠰᠤᠯᠠᠭᠳᠠᠪᠠ᠃ - - + + Verify face recognition or enter password to unlock ᠨᠢᠭᠤᠷ ᠱᠢᠷᠪᠢᠵᠤ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠬᠤ ᠪᠤᠶᠤ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ - + Guest 游客 - + 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 ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠬᠤ - + Username - + User name input error! - + login - - - - + + + + Failed to verify %1, please enter password to unlock %1᠎ᠤ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠤᠯᠳᠠ ᠢᠯᠠᠭᠳᠠᠪᠠ ᠂ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ - - - - - + + + + + Unable to verify %1, please enter password to unlock %1᠎ᠶᠢ/᠎ᠢ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠬᠤ ᠠᠷᠭ᠎ᠠ ᠦᠬᠡᠢ ᠂ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ - + Abnormal network ᠰᠦᠯᠵᠢᠶ᠎ᠡ ᠬᠡᠪ᠎ᠦᠨ ᠪᠤᠰᠤ - + Face recognition waiting time out, please click refresh or enter the password to unlock. ᠬᠦᠮᠦᠨ ᠤ ᠨᠢᠭᠤᠷ ᠢ ᠢᠯᠭᠠᠬᠤ ᠦᠶᠡᠰ᠂ ᠰᠢᠨᠡᠳᠭᠡᠬᠦ ᠪᠤᠶᠤ ᠨᠢᠭᠤᠴᠠ ᠨᠤᠮᠸᠷ ᠤᠨ ᠣᠨᠢᠰᠤ ᠶᠢ ᠲᠠᠷᠤᠭᠠᠷᠠᠢ᠃ - + FingerPrint ᠬᠤᠷᠤᠭᠤᠨ ᠣᠷᠣᠮ ᠃ - + FingerVein ᠨᠠᠮ ᠵᠢᠮ ᠰᠤᠳᠠᠯ ᠢ ᠵᠢᠭᠠᠨ᠎ᠠ ᠃ - + Iris ᠬᠠᠯᠢᠰᠤ᠃ - + Face ᠬᠥᠮᠥᠨ ᠦ ᠨᠢᠭᠤᠷ ᠃ - + VoicePrint ᠳᠠᠭᠤᠨ ᠤ ᠣᠷᠣᠮ ᠃ - - + + Ukey ᠠᠮᠤᠷ ᠲᠦᠪᠰᠢᠨ ᠪᠢᠲᠡᠭᠦᠮᠵᠢᠯᠡᠭᠦᠷ ᠃ - - + + QRCode ᠬᠤᠶᠠᠷ ᠬᠡᠮᠵᠢᠯᠳᠡᠳᠦ ᠺᠤᠳ᠋ - + fingerprint ᠬᠤᠷᠤᠭᠤᠨ ᠣᠷᠣᠮ ᠃ - + fingervein ᠨᠠᠮ ᠵᠢᠮ ᠰᠤᠳᠠᠯ ᠢ ᠵᠢᠭᠠᠨ᠎ᠠ ᠃ - + iris ᠬᠠᠯᠢᠰᠤ᠃ - + face ᠬᠥᠮᠥᠨ ᠦ ᠨᠢᠭᠤᠷ ᠃ - + voiceprint ᠳᠠᠭᠤᠨ ᠤ ᠣᠷᠣᠮ ᠃ @@ -212,8 +212,8 @@ 使用绑定的微信扫码或输入密码登录 - - + + Password cannot be empty ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠬᠤᠭᠤᠰᠤᠨ ᠪᠠᠢᠵᠤ ᠪᠤᠯᠬᠤ ᠦᠬᠡᠢ @@ -226,8 +226,8 @@ 无法验证%1,请输入密码. - - + + Failed to verify %1, you still have %2 verification opportunities %1᠎ᠶᠢᠨ/᠎ᠦᠨ ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠤᠯᠳᠠ ᠢᠯᠠᠭᠳᠠᠪᠠ ᠂ ᠲᠠ ᠪᠠᠰᠠ%2 ᠤᠳᠠᠭᠠᠨ᠎ᠤ ᠳᠤᠷᠱᠢᠬᠤ ᠵᠠᠪᠱᠢᠶᠠᠨ ᠲᠠᠢ @@ -256,13 +256,13 @@ 请输入密码或者录入指纹 - - + + Authentication failure, Please try again ᠪᠠᠳᠤᠯᠭᠠᠵᠢᠭᠤᠯᠤᠯᠳᠠ ᠢᠯᠠᠭᠳᠠᠪᠠ ᠂ ᠳᠠᠬᠢᠵᠤ ᠳᠤᠷᠱᠢᠭᠠᠷᠠᠢ - + Use the bound wechat scanning code or enter the password to unlock ᠤᠶᠠᠭᠰᠠᠨ ᠸᠢᠴᠠᠲ᠎ᠢᠶᠠᠷ ᠺᠤᠳ᠋ ᠱᠢᠷᠪᠢᠬᠦ᠌ ᠪᠤᠶᠤ ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ ᠤᠷᠤᠭᠤᠯᠵᠤ ᠤᠨᠢᠰᠤ᠎ᠶᠢ ᠳᠠᠢᠯᠤᠭᠠᠷᠠᠢ @@ -275,13 +275,13 @@ ᠠᠮᠤᠷ ᠲᠦᠪᠰᠢᠨ ᠦ ᠨᠢᠭᠤᠴᠠ ᠶᠢ USB ᠦᠵᠦᠭᠦᠷ ᠲᠦ ᠬᠠᠳᠬᠤᠵᠤ ᠣᠷᠣᠭᠠᠷᠠᠢ ᠃ - + Password ᠨᠢᠭᠤᠴᠠ ᠺᠤᠳ᠋ - - + + Login ᠳᠠᠩᠰᠠᠯᠠᠨ ᠤᠷᠤᠬᠤ @@ -406,36 +406,41 @@ - + Cancel ᠬᠦᠴᠦᠨ ᠦᠭᠡᠶ ᠪᠣᠯᠭᠠᠨ᠎ᠠ᠃ - + Confrim ᠨᠤᠲᠠᠯᠠᠨ ᠲᠣᠭᠲᠠᠭᠠᠬᠤ ᠃ - The following program is running to prevent the system from reboot! - ᠳᠠᠷᠠᠭᠠᠬᠢ ᠫᠠᠷᠦᠭᠷᠡᠮ ᠶᠠᠭ ᠠᠵᠢᠯᠯᠠᠵᠤ ᠪᠠᠢᠨ᠎ᠠ ᠂ ᠱᠢᠰᠲ᠋ᠧᠮ᠎ᠦᠨ ᠳᠠᠬᠢᠵᠤ ᠡᠬᠢᠯᠡᠬᠦ᠌᠎ᠶᠢ ᠬᠤᠷᠢᠭᠯᠠᠨ᠎ᠠ! + The following programs prevent restarting, you can click "Cancel" and then close these programs. + ᠳᠣᠣᠷᠠᠬᠢ ᠳᠡᠰ ᠳᠠᠷᠠᠭᠠᠯᠠᠯ ᠳᠠᠬᠢᠨ ᠡᠬᠢᠯᠡᠬᠦ ᠶᠢ ᠬᠣᠷᠢᠭᠯᠠᠬᠤ ᠳᠤ ᠲᠠ 《 ᠬᠦᠴᠦᠨ ᠦᠭᠡᠢ ᠪᠣᠯᠭᠠᠬᠤ 》 ᠶᠢ ᠳᠠᠷᠤᠭᠰᠠᠨ ᠤ ᠳᠠᠷᠠᠭ᠎ᠠ ᠡᠳᠡᠭᠡᠷ ᠫᠷᠦᠭ᠍ᠷᠠᠮ ᠢ ᠬᠠᠭᠠᠵᠤ ᠪᠣᠯᠣᠨ᠎ᠠ ᠃ - The following program is running to prevent the system from shutting down! - ᠳᠠᠷᠠᠭᠠᠬᠢ ᠫᠠᠷᠦᠭᠷᠡᠮ ᠶᠠᠭ ᠠᠵᠢᠯᠯᠠᠵᠤ ᠪᠠᠢᠨ᠎ᠠ ᠂ ᠱᠢᠰᠲ᠋ᠧᠮ᠎ᠦᠨ ᠬᠠᠭᠠᠬᠤ᠎ᠶᠢ ᠬᠤᠷᠢᠭᠯᠠᠨ᠎ᠠ! + The following programs prevent the shutdown, you can click "Cancel" and then close these programs. + ᠳᠣᠣᠷᠠᠬᠢ ᠳᠡᠰ ᠳᠠᠷᠠᠭᠠᠯᠠᠯ ᠨᠢ ᠬᠠᠭᠠᠯᠭ᠎ᠠ ᠶᠢ ᠬᠣᠷᠢᠭᠯᠠᠬᠤ ᠳᠤ ᠲᠠ 《 ᠬᠦᠴᠦᠨ ᠦᠭᠡᠢ ᠪᠣᠯᠭᠠᠬᠤ 》 ᠶᠢ ᠳᠠᠷᠤᠭᠰᠠᠨ ᠤ ᠳᠠᠷᠠᠭ᠎ᠠ ᠡᠳᠡᠭᠡᠷ ᠳᠡᠰ ᠳᠠᠷᠠᠭᠠᠯᠠᠯ ᠢ ᠬᠠᠭᠠᠵᠤ ᠪᠣᠯᠣᠨ᠎ᠠ ᠃ - The following program is running to prevent the system from suspend! - ᠳᠠᠷᠠᠭᠠᠬᠢ ᠫᠠᠷᠦᠭᠷᠡᠮ ᠶᠠᠭ ᠠᠵᠢᠯᠯᠠᠵᠤ ᠪᠠᠢᠨ᠎ᠠ ᠂ ᠱᠢᠰᠲ᠋ᠧᠮ᠎ᠦᠨ ᠤᠨᠳᠠᠬᠤ᠎ᠶᠢ ᠬᠤᠷᠢᠭᠯᠠᠨ᠎ᠠ! + The following programs prevent suspend, you can click "Cancel" and then close these programs. + ᠳᠣᠣᠷᠠᠬᠢ ᠳᠡᠰ ᠳᠠᠷᠠᠭᠠᠯᠠᠯ ᠤᠨ ᠨᠣᠶᠢᠷ ᠢ ᠬᠣᠷᠢᠭᠯᠠᠬᠤ ᠳᠤ ᠲᠠ 《 ᠬᠦᠴᠦᠨ ᠦᠭᠡᠢ ᠪᠣᠯᠭᠠᠬᠤ 》 ᠶᠢ ᠳᠠᠷᠤᠭᠰᠠᠨ ᠤ ᠳᠠᠷᠠᠭ᠎ᠠ ᠡᠳᠡᠭᠡᠷ ᠫᠷᠦᠭ᠍ᠷᠠᠮ ᠢ ᠬᠠᠭᠠᠵᠤ ᠪᠣᠯᠣᠨ᠎ᠠ ᠃ - The following program is running to prevent the system from hibernate! - ᠳᠠᠷᠠᠭᠠᠬᠢ ᠫᠠᠷᠦᠭᠷᠡᠮ ᠶᠠᠭ ᠠᠵᠢᠯᠯᠠᠵᠤ ᠪᠠᠢᠨ᠎ᠠ ᠂ ᠱᠢᠰᠲ᠋ᠧᠮ᠎ᠦᠨ ᠢᠴᠡᠬᠡᠯᠡᠬᠦ᠌᠎ᠶᠢ ᠬᠤᠷᠢᠭᠯᠠᠨ᠎ᠠ! + The following programs prevent hibernation, you can click "Cancel" and then close these programs. + ᠳᠣᠣᠷᠠᠬᠢ ᠳᠡᠰ ᠳᠠᠷᠠᠭᠠᠯᠠᠯ ᠢᠶᠠᠷ ᠤᠨᠲᠠᠬᠤ ᠶᠢ ᠬᠣᠷᠢᠭᠯᠠᠬᠤ ᠳᠤ ᠲᠠ 《 ᠬᠦᠴᠦᠨ ᠦᠭᠡᠢ ᠪᠣᠯᠭᠠᠬᠤ 》 ᠶᠢ ᠳᠠᠷᠤᠭᠠᠳ ᠡᠳᠡᠭᠡᠷ ᠫᠷᠦᠭ᠍ᠷᠠᠮ ᠢ ᠬᠠᠭᠠᠵᠤ ᠪᠣᠯᠣᠨ᠎ᠠ ᠃ + + + + The following programs prevent you from logging out, you can click "Cancel" and then close them. + ᠳᠣᠣᠷᠠᠬᠢ ᠳᠡᠰ ᠳᠠᠷᠠᠭᠠᠯᠠᠯ ᠨᠢ ᠬᠦᠴᠦᠨ ᠦᠭᠡᠢ ᠪᠣᠯᠭᠠᠬᠤ ᠶᠢ ᠬᠣᠷᠢᠭᠯᠠᠬᠤ ᠳᠤ ᠲᠠ 《 ᠬᠦᠴᠦᠨ ᠦᠭᠡᠢ ᠪᠣᠯᠭᠠᠬᠤ 》 ᠶᠢ ᠳᠠᠷᠤᠭᠰᠠᠨ ᠤ ᠳᠠᠷᠠᠭ᠎ᠠ ᠡᠳᠡᠭᠡᠷ ᠳᠡᠰ ᠳᠠᠷᠠᠭᠠᠯᠠᠯ ᠢ ᠬᠠᠭᠠᠵᠤ ᠪᠣᠯᠣᠨ᠎ᠠ ᠃ @@ -1951,17 +1956,17 @@ LightDMHelper - + failed to start session. - + Login ᠳᠠᠩᠰᠠᠯᠠᠨ ᠤᠷᠤᠬᠤ - + Guest 游客 @@ -2005,61 +2010,87 @@ ᠤᠳᠠᠰᠤ ᠦᠬᠡᠢ ᠬᠡᠰᠡᠭ ᠬᠡᠪᠴᠢᠶᠡᠨ᠎ᠦ ᠰᠦᠯᠵᠢᠶ᠎ᠡ - + + system-monitor + ᠰᠢᠰᠲ᠋ᠧᠮᠲᠦ ᠬᠢᠨᠠᠨ ᠠᠵᠢᠭᠯᠠᠬᠤ ᠮᠠᠰᠢᠨ ᠃ + + + + Restart + ᠳᠠᠬᠢᠵᠤ ᠡᠬᠢᠯᠡᠬᠦᠯᠬᠦ᠌ + + + + Multiple users are logged in at the same time.Are you sure you want to %1 this system? ᠣᠯᠠᠨ ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠬᠠᠮᠲᠤ ᠳᠤᠨᠢ ᠲᠡᠮᠳᠡᠭ᠍ᠯᠡᠵᠡᠢ ᠃ ᠲᠠ %1 ᠡᠨᠡ ᠰᠢᠰᠲ᠋ᠧᠮ ᠢ ᠲᠣᠭᠲᠠᠭᠠᠨ᠎ᠠ ᠤᠤ ? + + + Reboot + ᠳᠠᠬᠢᠨ ᠰᠡᠩᠭᠡᠷᠡᠭᠦᠯᠬᠦ + + + + PowerOff + ᠬᠠᠭᠠᠬᠤ + + + + Shut Down + ᠬᠠᠭᠠᠬᠤ + LoginOptionsWidget - - + + Login Options ᠨᠡᠪᠳᠡᠷᠡᠬᠦ᠌ ᠰᠤᠩᠭᠤᠯᠳᠠ - + Password ᠨᠢᠭᠤᠴᠠ ᠺᠣᠳ᠋᠎ᠢ᠋ ᠵᠠᠰᠠᠬᠤ - + Other ᠪᠤᠰᠤᠳ ᠃ - + FingerPrint ᠬᠤᠷᠤᠭᠤᠨ ᠣᠷᠣᠮ ᠃ - + FingerVein ᠨᠠᠮ ᠵᠢᠮ ᠰᠤᠳᠠᠯ ᠃ - + Iris ᠬᠠᠯᠢᠰᠤ᠃ - + Face ᠬᠥᠮᠥᠨ ᠦ ᠨᠢᠭᠤᠷ ᠃ - + VoicePrint ᠳᠠᠭᠤᠨ ᠤ ᠣᠷᠣᠮ ᠃ - + Ukey ᠠᠮᠤᠷ ᠲᠦᠪᠰᠢᠨ ᠨᠢᠭᠤᠴᠠ ᠪᠠᠷ ᠬᠥᠯᠬᠢᠳᠡᠬᠦ ᠃ - + QRCode ᠬᠤᠶᠠᠷ ᠬᠡᠮᠵᠢᠯᠳᠡᠳᠦ ᠺᠤᠳ᠋ @@ -2068,7 +2099,7 @@ 微信 - + Identify device removed! ᠬᠠᠷᠭᠤᠭᠤᠯᠵᠤ ᠱᠢᠯᠭᠠᠬᠤ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ᠎ᠶᠢ ᠨᠢᠭᠡᠨᠳᠡ ᠱᠢᠯᠵᠢᠬᠦᠯᠦᠨ ᠬᠠᠰᠤᠪᠠ! @@ -2263,61 +2294,102 @@ PowerListWidget - - + + Hibernate ᠢᠴᠡᠬᠡᠯᠡᠬᠦ᠌ - - + + Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠢ ᠬᠠᠭᠠᠬᠤ ᠪᠣᠯᠪᠠᠴᠤ ᠬᠡᠷᠡᠭᠯᠡᠭᠡᠨ ᠦ ᠬᠤᠷᠠᠯ ᠨᠡᠭᠡᠭᠡᠬᠦ ᠪᠠᠶᠢᠳᠠᠯ ᠢᠶᠠᠨ ᠪᠠᠷᠢᠮᠲᠠᠯᠠᠳᠠᠭ ᠃ ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠢ ᠨᠡᠭᠡᠭᠡᠬᠦ ᠦᠶ᠎ᠡ ᠳᠦ ᠂ ᠴᠢᠨᠦ ᠰᠠᠯᠤᠭᠰᠠᠨ ᠪᠠᠶᠢᠳᠠᠯ ᠢᠶᠠᠨ ᠰᠡᠷᠭᠦᠭᠡᠵᠦ ᠪᠣᠯᠣᠨ᠎ᠠ ᠃ - - + + Suspend ᠤᠨᠳᠠᠬᠤ - - + + The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠮᠠᠰᠢᠨ ᠢᠶᠠᠨ ᠨᠡᠭᠡᠭᠡᠬᠦ ᠪᠠᠶᠢᠳᠠᠯ ᠢᠶᠠᠨ ᠪᠠᠷᠢᠮᠲᠠᠯᠠᠳᠠᠭ ᠂ ᠭᠡᠪᠡᠴᠦ ᠴᠠᠬᠢᠯᠭᠠᠨ ᠬᠣᠷᠣᠭᠳᠠᠭᠤᠯᠭ᠎ᠠ ᠨᠡᠯᠢᠶᠡᠳ ᠪᠠᠭ᠎ᠠ ᠃ ᠬᠡᠷᠡᠭᠯᠡᠭᠡᠨ ᠦ ᠬᠤᠷᠠᠯ ᠨᠡᠭᠡᠭᠡᠬᠦ ᠪᠠᠶᠢᠳᠠᠯ ᠢᠶᠠᠨ ᠦᠷᠭᠦᠯᠵᠢᠯᠡᠭᠦᠯᠦᠭᠰᠡᠭᠡᠷ ᠂ ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠢ ᠲᠦᠷᠭᠡᠨ ᠰᠡᠷᠢᠭᠡᠬᠦ ᠶᠢᠨ ᠬᠠᠮᠲᠤ ᠴᠢᠨᠦ ᠰᠠᠯᠤᠭᠰᠠᠨ ᠪᠠᠶᠢᠳᠠᠯ ᠢᠶᠠᠨ ᠰᠡᠷᠭᠦᠭᠡᠵᠦ ᠪᠣᠯᠣᠨ᠎ᠠ ᠃ - - + + Restart ᠳᠠᠬᠢᠵᠤ ᠡᠬᠢᠯᠡᠬᠦᠯᠬᠦ᠌ - + Close all apps, and then restart your computer ᠪᠤᠢ ᠪᠥᠬᠥᠢ ᠬᠡᠷᠡᠭ᠍ᠯᠡᠭᠡ ᠶᠢ ᠬᠠᠭᠠᠵᠤ ᠂ ᠳᠠᠷᠠᠭ᠎ᠠ ᠨᠢ ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠢ ᠳᠠᠬᠢᠨ ᠰᠡᠩᠭᠡᠷᠡᠭᠦᠯᠦᠨ᠎ᠡ ᠃ - - + + Shut Down - ᠬᠠᠭᠠᠬᠤ + ᠬᠠᠭᠠᠬᠤ + + + + + The current user logs out of the system, terminates the session, and returns to the login page + ᠣᠳᠣᠬᠠᠨ ᠳᠤ ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠰᠢᠰᠲ᠋ᠧᠮ ᠡᠴᠡ ᠬᠦᠴᠦᠨ ᠦᠭᠡᠶ ᠪᠣᠯᠭᠠᠵᠤ ᠂ ᠲᠡᠭᠦᠨ ᠦ ᠬᠤᠷᠠᠯ ᠤᠨ ᠦᠭᠡ ᠪᠡᠨ ᠳᠠᠭᠤᠰᠬᠠᠬᠤ ᠶᠢᠨ ᠬᠠᠮᠲᠤ ᠲᠡᠮᠳᠡᠭᠯᠡᠭᠰᠡᠨ ᠨᠢᠭᠤᠷ ᠲᠤ ᠪᠤᠴᠠᠵᠠᠶ ᠃ + + + + Logout + ᠬᠦᠴᠦᠨ ᠦᠭᠡᠶ ᠪᠣᠯᠭᠠᠬᠤ᠃ Power Off ᠬᠠᠭᠠᠬᠤ - - + + Close all apps, and then shut down your computer བཀོལ་སྤྱོད་ཡོད་ཚད་སྒོ་བརྒྱབ་ནས་རྩིས་འཁོར་སྒོ་རྒྱག་དགོས། - + + + SwitchUser + ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠶᠢ ᠰᠣᠯᠢᠨ᠎ᠠ᠃ + + + + + LockScreen + ᠳᠡᠯᠪᠡᠴᠢᠬᠦ ᠃ + + + + + Log Out + ᠬᠦᠴᠦᠨ ᠦᠬᠡᠢ ᠪᠤᠯᠭᠠᠬᠤ + + + + + UpgradeThenRestart + ᠰᠢᠨᠡᠳᠬᠡᠭᠰᠡᠨ ᠦ ᠳᠠᠷᠠᠭ᠎ᠠ ᠳᠠᠬᠢᠨ ᠰᠡᠩᠬᠡᠷᠡᠭᠦᠯᠪᠡ ᠃ + + + Close all apps, turn off your computer, and then turn your computer back on ᠪᠤᠢ ᠪᠥᠬᠥᠢ ᠬᠡᠷᠡᠭ᠍ᠯᠡᠭᠡ ᠶᠢ ᠬᠠᠭᠠᠵᠤ ᠂ ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠢ ᠬᠠᠭᠠᠵᠤ ᠂ ᠳᠠᠷᠠᠭ᠎ᠠ ᠨᠢ ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ ᠢ ᠳᠠᠬᠢᠨ ᠨᠡᠭᠡᠭᠡᠨ᠎ᠡ ᠃ + + + + UpgradeThenShutdown + ᠰᠢᠨᠡᠳᠬᠡᠭᠰᠡᠨ ᠦ ᠳᠠᠷᠠᠭ᠎ᠠ ᠪᠠᠶᠢᠭᠤᠯᠤᠯᠭ᠎ᠠ ᠶᠢ ᠰᠢᠨᠡᠳᠬᠡᠨ᠎ᠡ + PowerManager @@ -2397,39 +2469,39 @@ QObject - + The screensaver is active. ᠳᠡᠯᠭᠡᠴᠡ ᠬᠠᠮᠠᠭᠠᠯᠠᠬᠤ ᠫᠠᠷᠦᠭᠷᠡᠮ᠎ᠢ ᠨᠢᠭᠡᠨᠳᠡ ᠢᠳᠡᠪᠬᠢᠵᠢᠬᠦᠯᠪᠡ - + The screensaver is inactive. ᠳᠡᠯᠭᠡᠴᠡ ᠬᠠᠮᠠᠭᠠᠯᠠᠬᠤ ᠫᠠᠷᠦᠭᠷᠡᠮ᠎ᠢ ᠢᠳᠡᠪᠬᠢᠵᠢᠬᠦᠯᠦᠬᠡ ᠦᠬᠡᠢ ᠃ FingerPrint - + ᠬᠤᠷᠤᠭᠤᠨ ᠣᠷᠣᠮ ᠃ FingerVein - + ᠨᠠᠮ ᠵᠢᠮ ᠰᠤᠳᠠᠯ ᠢ ᠵᠢᠭᠠᠨ᠎ᠠ ᠃ Iris - + ᠬᠠᠯᠢᠰᠤ᠃ Face - + ᠬᠥᠮᠥᠨ ᠦ ᠨᠢᠭᠤᠷ ᠃ VoicePrint - + ᠳᠠᠭᠤᠨ ᠤ ᠣᠷᠣᠮ ᠃ @@ -2439,7 +2511,7 @@ QRCode - ᠬᠤᠶᠠᠷ ᠬᠡᠮᠵᠢᠯᠳᠡᠳᠦ ᠺᠤᠳ᠋ + ᠬᠤᠶᠠᠷ ᠬᠡᠮᠵᠢᠯᠳᠡᠳᠦ ᠺᠤᠳ᠋ @@ -2680,6 +2752,15 @@ + + action + + + + which block type + + + delay @@ -2730,6 +2811,24 @@ show blank and delay to lock,param:idle/lid/lowpower ᠬᠣᠭᠣᠰᠣᠨ ᠪᠠᠢᠬᠤ ᠪᠥᠭᠡᠳ ᠣᠨᠢᠰᠤᠯᠠᠬᠤ᠎ᠶ᠋ᠢ ᠬᠣᠢᠰᠢᠯᠠᠭᠤᠯᠬᠤ ᠫᠷᠠᠮᠧᠲ᠋ᠷ᠎ᠢ᠋ ᠢᠯᠡᠷᠡᠭᠦᠯᠬᠦ ᠄ ᠰᠤᠯᠠ / ᠳᠡᠭᠡᠷ᠎ᠡ ᠬᠠᠪᠬᠠᠭᠠᠰᠤ / ᠪᠠᠭ᠎ᠠ ᠴᠢᠳᠠᠮᠵᠢ + + + + show the session tools + + + + + + show the app block window + + + + + + show the multiUsers block window + + Dialog for the ukui ScreenSaver. diff --git a/i18n_ts/zh_CN.ts b/i18n_ts/zh_CN.ts index ec8c885..5338d41 100644 --- a/i18n_ts/zh_CN.ts +++ b/i18n_ts/zh_CN.ts @@ -24,7 +24,7 @@ 使用密码认证 - + Retry 重试 @@ -53,157 +53,157 @@ 账户锁定%1分钟由于%2次错误尝试 - + Please try again in %1 minutes. 请%1分钟后再试 - + Please try again in %1 seconds. 请%1秒后再试 - + Account locked permanently. 账号已被永久锁定 - - + + Verify face recognition or enter password to unlock 验证人脸识别或输入密码解锁 - + Guest 游客 - + 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 输入密码 - + Username 用户名: - + User name input error! 用户名输入错误 - + login 登录 - - - - + + + + Failed to verify %1, please enter password to unlock 验证%1失败,请输入密码解锁 - - - - - + + + + + Unable to verify %1, please enter password to unlock 无法验证%1,请输入密码解锁 - + Abnormal network 网络异常 - + Face recognition waiting time out, please click refresh or enter the password to unlock. 人脸识别等待超时,请点击刷新或输入密码解锁 - + FingerPrint 指纹 - + FingerVein 指静脉 - + Iris 虹膜 - + Face 人脸识别 - + VoicePrint 声纹 - - + + Ukey 安全密钥 - - + + QRCode 二维码 - + fingerprint 指纹 - + fingervein 指静脉 - + iris 虹膜 - + face 人脸 - + voiceprint 声纹 @@ -212,8 +212,8 @@ 使用绑定的微信扫码或输入密码登录 - - + + Password cannot be empty 密码不能为空 @@ -226,8 +226,8 @@ 无法验证%1,请输入密码. - - + + Failed to verify %1, you still have %2 verification opportunities 验证%1失败,您还有%2次尝试机会 @@ -256,13 +256,13 @@ 请输入密码或者录入指纹 - - + + Authentication failure, Please try again 认证失败,请重试 - + Use the bound wechat scanning code or enter the password to unlock 使用绑定的微信扫码或输入密码解锁 @@ -275,13 +275,13 @@ 请将安全密钥插入USB端口 - + Password 密码 - - + + Login 登录 @@ -406,36 +406,41 @@ - + Cancel 取消 - + Confrim 确认 - The following program is running to prevent the system from reboot! - 以下程序正在运行,阻止系统重启! + The following programs prevent restarting, you can click "Cancel" and then close these programs. + 以下程序阻止重启,您可以点击“取消”然后关闭这些程序。 - The following program is running to prevent the system from shutting down! - 以下程序正在运行,阻止系统关机! + The following programs prevent the shutdown, you can click "Cancel" and then close these programs. + 以下程序阻止关机,您可以点击“取消”然后关闭这些程序。 - The following program is running to prevent the system from suspend! - 以下程序正在运行,阻止系统进入睡眠! + The following programs prevent suspend, you can click "Cancel" and then close these programs. + 以下程序阻止睡眠,您可以点击“取消”然后关闭这些程序。 - The following program is running to prevent the system from hibernate! - 以下程序正在运行,阻止系统进入休眠! + The following programs prevent hibernation, you can click "Cancel" and then close these programs. + 以下程序阻止休眠,您可以点击“取消”然后关闭这些程序。 + + + + The following programs prevent you from logging out, you can click "Cancel" and then close them. + 以下程序阻止注销,您可以点击“取消”然后关闭这些程序。 @@ -1928,17 +1933,17 @@ LightDMHelper - + failed to start session. 启动会话失败。 - + Login 登录 - + Guest 游客 @@ -1982,61 +1987,87 @@ 无线局域网 - + + system-monitor + 系统监视器 + + + + Restart + 重启 + + + + Multiple users are logged in at the same time.Are you sure you want to %1 this system? 同时有多个用户处于登录状态,你确定要%1吗? + + + Reboot + 重启 + + + + PowerOff + 关机 + + + + Shut Down + 关机 + LoginOptionsWidget - - + + Login Options 登录选项 - + Password 密码 - + Other 其他 - + FingerPrint 指纹 - + FingerVein 指静脉 - + Iris 虹膜 - + Face 人脸识别 - + VoicePrint 声纹 - + Ukey 安全密钥 - + QRCode 二维码 @@ -2045,7 +2076,7 @@ 微信 - + Identify device removed! 校验设备已移除! @@ -2236,61 +2267,102 @@ PowerListWidget - - + + Hibernate 休眠 - - + + Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left 关闭电脑,但是应用会一直保持打开状态。当打开电脑时,可以恢复到你离开的状态。 - - + + Suspend 睡眠 - - + + The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off 电脑保持开机状态,但耗电较少。应用会一直保持打开状态,可快速唤醒电脑并恢复到你离开的状态。 - - + + Restart 重启 - + Close all apps, and then restart your computer 关闭所有应用,然后重启电脑。 - - + + Shut Down - 关机 + 关机 + + + + + The current user logs out of the system, terminates the session, and returns to the login page + 当前用户从系统中注销,结束其会话并返回登录界面。 + + + + Logout + 注销 Power Off 关机 - - + + Close all apps, and then shut down your computer 关闭所有应用,然后关闭电脑。 - + + + SwitchUser + 切换用户 + + + + + LockScreen + 锁屏 + + + + + Log Out + 注销 + + + + + UpgradeThenRestart + 更新后重启 + + + Close all apps, turn off your computer, and then turn your computer back on 关闭所有应用,关闭电脑,然后重新打开电脑。 + + + + UpgradeThenShutdown + 更新后关机 + PowerManager @@ -2370,12 +2442,12 @@ QObject - + The screensaver is active. 屏幕保护程序已激活 - + The screensaver is inactive. 屏幕保护程序未激活 @@ -2649,6 +2721,15 @@ + + action + + + + which block type + + + delay @@ -2699,6 +2780,24 @@ show blank and delay to lock,param:idle/lid/lowpower + + + + show the session tools + + + + + + show the app block window + + + + + + show the multiUsers block window + + Backend for the ukui ScreenSaver. diff --git a/i18n_ts/zh_HK.ts b/i18n_ts/zh_HK.ts index 631f8da..46de307 100644 --- a/i18n_ts/zh_HK.ts +++ b/i18n_ts/zh_HK.ts @@ -24,7 +24,7 @@ 使用密码认证 - + Retry 重試 @@ -53,157 +53,157 @@ 账户锁定%1分钟由于%2次错误尝试 - + Please try again in %1 minutes. 請在 %1 分鐘後重試。 - + Please try again in %1 seconds. 請在 %1 秒後重試。 - + Account locked permanently. 帳戶永久鎖定。 - - + + Verify face recognition or enter password to unlock 驗證人臉識別或輸入密碼解鎖 - + Guest 游客 - + 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 輸入密碼 - + Username 使用者名 - + User name input error! - + login - - - - + + + + Failed to verify %1, please enter password to unlock 驗證 %1 失敗,請輸入密碼進行解鎖 - - - - - + + + + + Unable to verify %1, please enter password to unlock 無法驗證 %1,請輸入密碼進行解鎖 - + Abnormal network 網路異常 - + Face recognition waiting time out, please click refresh or enter the password to unlock. 人臉識別等待超時,請點擊刷新或輸入密碼解鎖 - + FingerPrint 指紋 - + FingerVein 指靜脈 - + Iris 虹膜 - + Face 人臉 - + VoicePrint 聲紋 - - + + Ukey 安全金鑰 - - + + QRCode 微信掃碼 - + fingerprint 指紋 - + fingervein 指靜脈 - + iris 虹膜 - + face 人臉 - + voiceprint 聲紋 @@ -212,8 +212,8 @@ 使用绑定的微信扫码或输入密码登录 - - + + Password cannot be empty 密碼不能為空 @@ -226,8 +226,8 @@ 无法验证%1,请输入密码. - - + + Failed to verify %1, you still have %2 verification opportunities 驗證 %1 失敗,您仍有 %2 次驗證機會 @@ -256,13 +256,13 @@ 请输入密码或者录入指纹 - - + + Authentication failure, Please try again 身份驗證失敗,請重試 - + Use the bound wechat scanning code or enter the password to unlock 使用綁定的微信掃碼或輸入密碼解鎖 @@ -275,13 +275,13 @@ 將 Ukey 插入 USB 埠 - + Password 密碼 - - + + Login 登錄 @@ -406,36 +406,41 @@ - + Cancel 取消 - + Confrim 確認 - The following program is running to prevent the system from reboot! - 以下程式正在運行以防止系統重新啟動! + The following programs prevent restarting, you can click "Cancel" and then close these programs. + 以下程式阻止重啟,您可以點擊“取消”然後關閉這些程式。 - The following program is running to prevent the system from shutting down! - 以下程式正在運行以防止系統關閉! + The following programs prevent the shutdown, you can click "Cancel" and then close these programs. + 以下程式阻止關閉,您可以點擊“取消”然後關閉這些程式。 - The following program is running to prevent the system from suspend! - 以下程式正在運行以防止系統掛起! + The following programs prevent suspend,you can click "Cancel" and then close these programs. + 以下程式阻止睡眠,您可以點擊“取消”然後關閉這些程式。 - The following program is running to prevent the system from hibernate! - 以下程式正在運行以防止系統休眠! + The following programs prevent hibernation, you can click "Cancel" and then close these programs. + 以下程式阻止休眠,您可以點擊“取消”然後關閉這些程式。 + + + + The following programs prevent you from logging out, you can click "Cancel" and then close them. + 以下程式阻止註銷,您可以點擊“取消”然後關閉這些程式。 @@ -1944,17 +1949,17 @@ LightDMHelper - + failed to start session. - + Login 登錄 - + Guest 游客 @@ -1998,61 +2003,87 @@ 無線局域網 - + + system-monitor + 系統監視器 + + + + Restart + + + + + Multiple users are logged in at the same time.Are you sure you want to %1 this system? 多個用戶同時登錄,您確定要 %1 此系統嗎? + + + Reboot + 重啟 + + + + PowerOff + 關機 + + + + Shut Down + 關機 + LoginOptionsWidget - - + + Login Options 登錄選項 - + Password 密碼 - + Other 其他 - + FingerPrint 指紋 - + FingerVein 指靜脈 - + Iris 虹膜 - + Face 人臉 - + VoicePrint 聲紋 - + Ukey 安全金鑰 - + QRCode 微信掃碼 @@ -2061,7 +2092,7 @@ 微信 - + Identify device removed! 識別已刪除的設備! @@ -2256,61 +2287,102 @@ PowerListWidget - - + + Hibernate 休眠 - - + + Turn off your computer, but the app stays open. When the computer is turned on, it can be restored to the state you left 關閉電腦,但應用會保持打開狀態。當計算機打開時,它可以恢復到您離開時的狀態 - - + + Suspend 睡眠 - - + + The computer stays on, but consumes less power. The app stays open and can quickly wake up and revert to where you left off 計算機保持打開狀態,但消耗的電量更少。該應用程式保持打開狀態,可以快速喚醒並恢復到上次中斷的位置 - - + + Restart 重啟 - + Close all apps, and then restart your computer 關閉所有應用,然後重啟電腦。 - - + + Shut Down - 關閉 + 關機 + + + + + The current user logs out of the system, terminates the session, and returns to the login page + 當前使用者從系統中註銷,結束其會話並返回登錄介面。 + + + + Logout + 註銷 Power Off 關機 - - + + Close all apps, and then shut down your computer 關閉所有應用,然後關閉電腦 - + + + SwitchUser + 切換使用者 + + + + + LockScreen + 鎖屏 + + + + + Log Out + 註銷 + + + + + UpgradeThenRestart + 更新後重啟 + + + Close all apps, turn off your computer, and then turn your computer back on 關閉所有應用,關閉計算機,然後重新打開計算機 + + + + UpgradeThenShutdown + 更新後關機 + PowerManager @@ -2390,39 +2462,39 @@ QObject - + The screensaver is active. 屏幕保護程式處於活動狀態。 - + The screensaver is inactive. 屏幕保護程式處於非活動狀態。 FingerPrint - + 指紋 FingerVein - + 指靜脈 Iris - 虹膜 + 虹膜 Face - + 人臉 VoicePrint - + 聲紋 @@ -2432,7 +2504,7 @@ QRCode - 微信掃碼 + 微信掃碼 @@ -2673,6 +2745,15 @@ + + action + + + + which block type + + + delay @@ -2723,6 +2804,24 @@ show blank and delay to lock,param:idle/lid/lowpower 顯示空白和延遲鎖定,參數:空閒/蓋子/低功耗 + + + + show the session tools + + + + + + show the app block window + + + + + + show the multiUsers block window + + Dialog for the ukui ScreenSaver. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f0d38c8..00a754b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -168,6 +168,7 @@ set(backend_SRC dbusifs/kglobalaccelhelper.cpp dbusifs/machinemodel.cpp dbusifs/libinputswitchevent.cpp + dbusifs/systemupgradehelper.cpp userinfo.cpp agreementinfo.cpp common/global_utils.cpp diff --git a/src/assets.qrc b/src/assets.qrc index 4f20edd..d225770 100644 --- a/src/assets.qrc +++ b/src/assets.qrc @@ -125,6 +125,8 @@ assets/reboot.svg assets/hibernate.svg assets/switchuser.svg + assets/logout.svg + assets/lockscreen.svg assets/data/conf.ini diff --git a/src/assets/lockscreen.svg b/src/assets/lockscreen.svg new file mode 100755 index 0000000..1f910ee --- /dev/null +++ b/src/assets/lockscreen.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/logout.svg b/src/assets/logout.svg new file mode 100755 index 0000000..9659657 --- /dev/null +++ b/src/assets/logout.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/common/definetypes.h b/src/common/definetypes.h index 06e85f5..d6266f9 100644 --- a/src/common/definetypes.h +++ b/src/common/definetypes.h @@ -40,10 +40,14 @@ typedef enum _LOCK_CMD_ID_e LOCK_CMD_ID_LOGIN1_IS_SESSION_ACTIVE, LOCK_CMD_ID_LOGIN1_LIDSTATE_CHANGED, LOCK_CMD_ID_LOGIN1_SET_POWER_MANAGER, + LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANSWITCHUSER, LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANHIBERNATE, LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANPOWEROFF, LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANREBOOT, LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANSUSPEND, + LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANLOGOUT, + LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANLOCKSCREEN, + LOCK_CMD_ID_SYSTEM_UPGRADE_CHECK, LOCK_CMD_ID_GSETTINGS_GET_LOCKSCREEN_CONF = 200, LOCK_CMD_ID_GSETTINGS_SET_LOCKSCREEN_CONF, LOCK_CMD_ID_GSETTINGS_LOCKSCREEN_CONF_CHANGED, @@ -71,6 +75,9 @@ typedef enum _LOCK_CMD_ID_e LOCK_CMD_ID_GSETTINGS_GET_USD_MEDIAKEYS_CONF, LOCK_CMD_ID_GSETTINGS_SET_USD_MEDIAKEYS_CONF, LOCK_CMD_ID_GSETTINGS_USD_MEDIAKEYS_CONF_CHANGED, + LOCK_CMD_ID_GSETTINGS_GET_USD_MEDIA_STATE_KEYS_CONF, + LOCK_CMD_ID_GSETTINGS_SET_USD_MEDIA_STATE_KEYS_CONF, + LOCK_CMD_ID_GSETTINGS_USD_MEDIA_STATE_KEYS_CONF_CHANGED, LOCK_CMD_ID_GET_AGREEMENT = 300, LOCK_CMD_ID_LOCK_STATE_CHANGED, LOCK_CMD_ID_GET_PUBLIC_KEY, @@ -171,6 +178,8 @@ typedef enum _LOCK_CMD_ID_e #define GSETTINGS_SCHEMA_SESSION "org.ukui.session" #define KEY_SESSION_IDLE "idleDelay" +#define KEY_SESSION_LOGOUT_MUSIC "logoutMusic" +#define KEY_SESSION_POWEROFF_MUSIC "poweroffMusic" #define GSETTINGS_SCHEMA_PERIPHERALS_KEYBOARD "org.ukui.peripherals-keyboard" #define KEY_CAPSLOCK_STATUS "capslockState" @@ -182,6 +191,9 @@ typedef enum _LOCK_CMD_ID_e #define KEY_SCREEN_SHOT2 "screenshot2" #define KEY_WINDOW_SCREENSHOT "windowScreenshot" +#define GSETTINGS_SCHEMA_MEDIAKEY_STATE_SCHEMA "org.ukui.SettingsDaemon.plugins.media-keys-state" +#define KEY_RFKILL_STATE "rfkillState" + #define WORKING_DIRECTORY "/usr/share/ukui-screensaver" #define SUBWND_COUNT_MAX 1024 @@ -323,4 +335,16 @@ typedef enum { #define ACCOUNTS_USER_DBUS_INTERFACE "org.freedesktop.Accounts.User" #define ACCOUNTS_USER_LDM_SERVICE_INTERFACE "org.freedesktop.DisplayManager.AccountsService" +enum Action { + PowerSwitchUser, + PowerHibernate, + PowerSuspend, + PowerMonitorOff, + PowerLogout, + PowerUpgradeThenRboot, + PowerReboot, + PowerUpgradeThenShutdown, + PowerShutdown, +}; + #endif // DEFINETYPES_H diff --git a/src/dbusifs/login1helper.cpp b/src/dbusifs/login1helper.cpp index d32d99a..a45b5ac 100644 --- a/src/dbusifs/login1helper.cpp +++ b/src/dbusifs/login1helper.cpp @@ -178,3 +178,23 @@ bool Login1Helper::isCanPowerOff() { return m_isCanPowerOff; } + +bool Login1Helper::canAction(Action action) +{ + switch (action) { + case PowerHibernate: + return m_isCanHibernate; + case PowerSuspend: + return m_isCanSuspend; + case PowerMonitorOff: + return m_isCanLockScreen; + case PowerLogout: + return m_isCanLogout; + case PowerReboot: + return m_isCanReboot; + case PowerShutdown: + return m_isCanPowerOff; + default: + return false; + } +} diff --git a/src/dbusifs/login1helper.h b/src/dbusifs/login1helper.h index a466484..1267353 100644 --- a/src/dbusifs/login1helper.h +++ b/src/dbusifs/login1helper.h @@ -21,6 +21,7 @@ #include #include #include +#include "definetypes.h" /** * @brief login1访问工具类 @@ -56,6 +57,7 @@ public: bool isCanSuspend(); bool isCanReboot(); bool isCanPowerOff(); + bool canAction(Action action); public Q_SLOTS: /** @@ -116,6 +118,8 @@ private: bool m_isCanSuspend = true; bool m_isCanReboot = true; bool m_isCanPowerOff = true; + bool m_isCanLockScreen = true; + bool m_isCanLogout = true; }; #endif // LOGIN1HELPER_H diff --git a/src/dbusifs/sessionhelper.cpp b/src/dbusifs/sessionhelper.cpp index 9d48a44..0bb27a7 100644 --- a/src/dbusifs/sessionhelper.cpp +++ b/src/dbusifs/sessionhelper.cpp @@ -23,6 +23,10 @@ #include #include #include +#include + +#include "login1helper.h" +#include "lock-backend/gsettingshelper.h" const static QString sessionService = QStringLiteral("org.gnome.SessionManager"); const static QString sessionPath = QStringLiteral("/org/gnome/SessionManager"); @@ -58,6 +62,110 @@ SessionHelper::~SessionHelper() } +bool SessionHelper::canAction(Action action) +{ + //以下为代码结构调整 + QString command; + switch (action) { + case PowerSwitchUser: + command = QLatin1String("canSwitch"); + break; + case PowerHibernate: + command = QLatin1String("canHibernate"); + break; + case PowerSuspend: + command = QLatin1String("canSuspend"); + break; + case PowerMonitorOff: + command = QLatin1String("canLockscreen"); + break; + case PowerLogout: + command = QLatin1String("canLogout"); + break; + case PowerReboot: + command = QLatin1String("canReboot"); + break; + case PowerShutdown: + command = QLatin1String("canPowerOff"); + break; + default: + break; + } + + if (!m_sessionInterface->isValid()) { + qWarning() << "dbusCall: Session QDBusInterface is invalid"; + return false; + } + + QDBusReply testReply = m_sessionInterface->call(QLatin1String("canLockscreen")); + if (!testReply.isValid()) { + //解决老版本升级到新版本接口不兼容的问题,在session接口不存在的情况下,调用systemd的接口 + QDBusError error = testReply.error(); + Login1Helper* m_login1Helper = new Login1Helper(this); + if (error.type() == QDBusError::UnknownMethod) { + qInfo() << "updating ! old ukui-session dose not have canAction method"; + if (action == PowerLogout || action == PowerMonitorOff) { + return true; + } + return m_login1Helper->canAction(action); + } + qInfo() << "dbus error"; + return false; + } + + QDBusReply reply = m_sessionInterface->call(command); + + qInfo() << "command = " << command << "reply = " << m_sessionInterface->call(command); + + return reply.value(); +} + +bool SessionHelper::doAction(const QString &powerManagerfunc) +{ + if (!m_sessionInterface->isValid()) { + qWarning() << "dbusCall: Session QDBusInterface is invalid"; + return false; + } + + up_to_time = new QTimer(); + up_to_time->setSingleShot(true); + + qDebug() << "playShutdownMusic(powerManagerfunc) = " << playShutdownMusic(powerManagerfunc); + + if (!playShutdownMusic(powerManagerfunc)) { + doPowerManager(powerManagerfunc); + } + return true; +} + + +void SessionHelper::doPowerManager(const QString &powerManagerfunc) +{ + QString command; + if (powerManagerfunc == "Hibernate") { + command = QLatin1String("hibernate"); + } else if (powerManagerfunc == "Suspend") { + command = QLatin1String("suspend"); + } else if (powerManagerfunc == "Reboot") { + command = QLatin1String("reboot"); + } else if (powerManagerfunc == "PowerOff") { + command = QLatin1String("powerOff"); + } else if (powerManagerfunc == "Logout") { + command = QLatin1String("logout"); + } else if (powerManagerfunc == "SwitchUser") { + command = QLatin1String("switchUser"); + } else { + return ; + } + QDBusMessage mes = m_sessionInterface->call(command); + + if (!(mes.errorName().isEmpty())) { + Login1Helper* m_login1Helper = new Login1Helper(this); + //本来应该判断错误类别,考虑到运行效率,不做该判断 + m_login1Helper->setPowerManager(powerManagerfunc); + } +} + QStringList SessionHelper::getLockCheckStatus(QString type) { qDBusRegisterMetaType(); @@ -89,3 +197,54 @@ QStringList SessionHelper::getLockCheckStatus(QString type) return lockCheckList; } + +bool SessionHelper::playShutdownMusic(const QString &powerManagerfunc) +{ + // up_to_time and soundplayer can not be define out of this if(). + // otherwise run ukui-session-tools --suspend with segmente error. + // because they will be delate at the end of the playShutdownMusic(). + bool play_music = false; + GSettingsHelper *gsettingsHelper = new GSettingsHelper(this); + if (powerManagerfunc == "Reboot" || powerManagerfunc == "PowerOff") { + play_music = gsettingsHelper->GetSessionConf(KEY_SESSION_POWEROFF_MUSIC).toBool(); + } else if (powerManagerfunc == "Logout") { + play_music = gsettingsHelper->GetSessionConf(KEY_SESSION_LOGOUT_MUSIC).toBool(); + } else { + return false; + } + + QDBusMessage msg; + if (powerManagerfunc == "SwitchUser") { + msg = m_sessionInterface->call("emitPrepareForSwitchuser"); + if (!msg.errorName().isEmpty()) { + qWarning() << "Dbus error: " << msg; + } + } + + if (play_music) { + QObject::connect(up_to_time, &QTimer::timeout, [=]() { + doPowerManager(powerManagerfunc); + return true; + }); + QString xdg_session_type = qgetenv("XDG_SESSION_TYPE"); + if (powerManagerfunc == "Reboot" || powerManagerfunc == "PowerOff") { + if (xdg_session_type == "wayland") { + QProcess::startDetached("paplay /usr/share/ukui/ukui-session-manager/shutdown.wav"); + } else { + QProcess::startDetached("aplay /usr/share/ukui/ukui-session-manager/shutdown.wav"); + } + up_to_time->start(5000); + } else if (powerManagerfunc == "Logout") { + if (xdg_session_type == "wayland") { + QProcess::startDetached("paplay /usr/share/ukui/ukui-session-manager/logout.wav"); + } else { + QProcess::startDetached("aplay /usr/share/ukui/ukui-session-manager/logout.wav"); + } + up_to_time->start(2000); + } else { + qDebug() << "error num"; + return false; + } + } + return play_music; +} diff --git a/src/dbusifs/sessionhelper.h b/src/dbusifs/sessionhelper.h index 30d3bf2..1bbe5c7 100644 --- a/src/dbusifs/sessionhelper.h +++ b/src/dbusifs/sessionhelper.h @@ -20,7 +20,9 @@ #define SESSIONHELPER_H #include +#include #include +#include "definetypes.h" namespace InhibitInfo { struct InhibitorInfo { @@ -36,6 +38,7 @@ namespace InhibitInfo { Q_DECLARE_METATYPE(InhibitInfo::InhibitorInfo) class QDBusInterface; +class Login1Helper; class SessionHelper : public QObject { @@ -47,8 +50,18 @@ public: QStringList getLockCheckStatus(QString type); + bool canAction(Action action); + + bool doAction(const QString &powerManagerfunc); + private: QDBusInterface *m_sessionInterface = nullptr; + + QTimer *up_to_time = nullptr; + + void doPowerManager(const QString &powerManagerfunc); + + bool playShutdownMusic(const QString &powerManagerfunc); }; #endif // SESSIONHELPER_H diff --git a/src/dbusifs/systemupgradehelper.cpp b/src/dbusifs/systemupgradehelper.cpp new file mode 100755 index 0000000..4feb0f6 --- /dev/null +++ b/src/dbusifs/systemupgradehelper.cpp @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2023 KylinSoftCo., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#include "systemupgradehelper.h" +#include +#include + +const static QString sysUpgradeService = QStringLiteral("com.kylin.systemupgrade"); +const static QString sysUpgradePath = QStringLiteral("/com/kylin/systemupgrade"); +const static QString sysUpgradeInterface = QStringLiteral("com.kylin.systemupgrade.interface"); + +SystemUpgradeHelper::SystemUpgradeHelper(QObject *parent) : QObject(parent) +{ + m_sysUpgradeInterface = new QDBusInterface(sysUpgradeService, sysUpgradePath, sysUpgradeInterface, QDBusConnection::systemBus()); + + if (!m_sysUpgradeInterface->isValid()) { + qDebug() << "systemUpgrade interface not valid"; + isDbusActive = false; + isSystemUpgrade =false; + } else { + isDbusActive = true; + } +} + +SystemUpgradeHelper::~SystemUpgradeHelper() +{ + +} + +bool SystemUpgradeHelper::checkSystemUpgrade(){ + if (!isDbusActive) return false; + + QDBusMessage response = m_sysUpgradeInterface->call("CheckInstallRequired"); + if (response.type() == QDBusMessage::ReplyMessage) { + int res = response.arguments()[0].toInt(); + qDebug() << "CheckInstallRequired return " << res; + if (res == 0) + isSystemUpgrade = false; + else + isSystemUpgrade = true; + } else { + qDebug () << "call CheckInstallRequired failed;"; + isSystemUpgrade = false; + } + return isSystemUpgrade; +} + +bool SystemUpgradeHelper::doUpgradeThenRboot(){ + if (!isDbusActive) return false; + + bool mask = false; + QDBusMessage response = m_sysUpgradeInterface->call("TriggerInstallOnShutdown","reboot"); + if (response.type() == QDBusMessage::ReplyMessage) { + int res = response.arguments()[0].toInt(); + qDebug() << "TriggerInstallOnShutdown reboot return " << res; + if (res == 0) + mask = true; + else + mask = false; + } else { + qDebug () << "call TriggerInstallOnShutdown reboot failed;"; + mask = false; + } + + return mask; +} + +bool SystemUpgradeHelper::doUpgradeThenShutdown(){ + if (!isDbusActive) return false; + + bool mask = false; + QDBusMessage response = m_sysUpgradeInterface->call("TriggerInstallOnShutdown","shutdown"); + if (response.type() == QDBusMessage::ReplyMessage) { + int res = response.arguments()[0].toInt(); + qDebug() << "TriggerInstallOnShutdown shutdown return " << res; + if (res == 0) + mask = true; + else + mask = false; + } else { + qDebug () << "call TriggerInstallOnShutdown shutdown failed;"; + mask = false; + } + + return mask; +} diff --git a/src/dbusifs/systemupgradehelper.h b/src/dbusifs/systemupgradehelper.h new file mode 100755 index 0000000..c059562 --- /dev/null +++ b/src/dbusifs/systemupgradehelper.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2023 KylinSoftCo., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +**/ +#ifndef SYSTEMUPGRADEHELPER_H +#define SYSTEMUPGRADEHELPER_H + +#include +#include +#include +#include + +class SystemUpgradeHelper : public QObject +{ + Q_OBJECT +public: + /** + * @brief 构造 + * + * @param parent 父指针 + */ + explicit SystemUpgradeHelper(QObject *parent = nullptr); + /** + * @brief 析构 + * + */ + virtual ~SystemUpgradeHelper(); + + bool checkSystemUpgrade(); + bool doUpgradeThenRboot(); + bool doUpgradeThenShutdown(); +private: + +private: + QDBusInterface *m_sysUpgradeInterface = nullptr; + bool isDbusActive = false; + bool isSystemUpgrade = false; +}; + +#endif // SYSTEMUPGRADEHELPER_H diff --git a/src/lock-backend/dbusupperinterface.cpp b/src/lock-backend/dbusupperinterface.cpp index 0faa36f..e22fc96 100644 --- a/src/lock-backend/dbusupperinterface.cpp +++ b/src/lock-backend/dbusupperinterface.cpp @@ -35,6 +35,7 @@ #include "upowerhelper.h" #include "accountshelper.h" #include "sessionhelper.h" +#include "systemupgradehelper.h" #include "sessionwatcher.h" #include "freedesktophelper.h" #include "bioauthenticate.h" @@ -67,6 +68,7 @@ void DbusUpperInterface::initData() m_usdHelper= new UsdHelper(this); m_upowerHelper = new UpowerHelper(this); m_sessionHelper = new SessionHelper(this); + m_systemsUpgradeHelper = new SystemUpgradeHelper(this); m_sessionWatcher = new SessionWatcher(m_gsettingsHelper, this); m_kglobalHelper = new KglobalAccelHelper(this); m_libinputSwitchEvent = new LibinputSwitchEvent(this); @@ -215,6 +217,182 @@ void DbusUpperInterface::Lock() emitLockState(true); } +bool DbusUpperInterface::CheckAppVersion() +{ + return true; +} + +void DbusUpperInterface::SessionTools() +{ + if(GetLockState()) + return; + + if(m_procLockDialog.state() != QProcess::NotRunning) { + QDBusMessage message; + message = QDBusMessage::createSignal(SS_DBUS_PATH, + SS_DBUS_INTERFACE, + "SecondRunParam"); + message<<"CmdSessionTools"; + QDBusConnection::sessionBus().send(message); + emitLockState(true); + return ; + } + m_bLockState = false; + QString cmd = QString("/usr/bin/ukui-screensaver-dialog --session-tools"); + qDebug() << cmd; + + m_procLockDialog.start(cmd); + emitLockState(true); +} + +void DbusUpperInterface::AppBlockWindow(QString actionType) +{ + QStringList lockcheck; + if (actionType == "Shutdown" || actionType == "Restart" || actionType == "Logout") { + lockcheck = m_sessionHelper->getLockCheckStatus("shutdown"); + } else if (actionType == "Suspend" || actionType == "Hibernate") { + lockcheck = m_sessionHelper->getLockCheckStatus("sleep"); + } + qDebug() << "lockCheck = " << lockcheck; + if (lockcheck.isEmpty()) { + return ; + } + if(m_procLockDialog.state() != QProcess::NotRunning) { + QDBusMessage message; + message = QDBusMessage::createSignal(SS_DBUS_PATH, + SS_DBUS_INTERFACE, + "SecondRunParam"); + if (actionType == "Restart") + message<<"CmdRestartAppBlock"; + else if (actionType == "Shutdown") + message<<"CmdPowerOffAppBlock"; + else if (actionType == "Suspend") + message<<"CmdSuspendAppBlock"; + else if (actionType == "Hibernate") + message<<"CmdHibernateAppBlock"; + else if (actionType == "Logout") + message<<"CmdLogoutAppBlock"; + else + return; + QDBusConnection::sessionBus().send(message); + emitLockState(false); + return ; + } + if (actionType != "Restart" && actionType != "Shutdown" && actionType != "Suspend" && actionType != "Hibernate" && actionType != "Logout") + return ; + m_bLockState = false; + QString cmd; + cmd = QString("/usr/bin/ukui-screensaver-dialog --app-block %1").arg(actionType); + qDebug() << cmd; + + m_procLockDialog.start(cmd); + emitLockState(false); +} + +void DbusUpperInterface::MultiUserBlockWindow(QString actionType) +{ + if(m_procLockDialog.state() != QProcess::NotRunning) { + QDBusMessage message; + message = QDBusMessage::createSignal(SS_DBUS_PATH, + SS_DBUS_INTERFACE, + "SecondRunParam"); + if (actionType == "Restart") + message<<"CmdRestartMulTiUserBlock"; + else if (actionType == "Shutdown") + message<<"CmdPowerOffMulTiUserBlock"; + else + return; + QDBusConnection::sessionBus().send(message); + emitLockState(false); + return ; + } + if (actionType != "Restart" && actionType != "Shutdown") + return ; + m_bLockState = false; + QString cmd; + cmd = QString("/usr/bin/ukui-screensaver-dialog --multiusers-block %1").arg(actionType); + qDebug() << cmd; + + m_procLockDialog.start(cmd); + emitLockState(false); +} + +void DbusUpperInterface::Suspend() +{ + if (m_sessionHelper) { + QStringList lockCheckList = m_sessionHelper->getLockCheckStatus("sleep"); + if (lockCheckList.count() == 0) + m_sessionHelper->doAction("Suspend"); + else { + AppBlockWindow("Suspend"); + } + } +} + +void DbusUpperInterface::Hibernate() +{ + if (m_sessionHelper) { + QStringList lockCheckList = m_sessionHelper->getLockCheckStatus("sleep"); + if (lockCheckList.count() == 0) + m_sessionHelper->doAction("Hibernate"); + else { + AppBlockWindow("Hibernate"); + } + } +} + +void DbusUpperInterface::Reboot() +{ + if (m_sessionHelper) { + QStringList lockCheckList = m_sessionHelper->getLockCheckStatus("shutdown"); + if (lockCheckList.count() == 0) { + if (m_lightDmHelper && m_lightDmHelper->getLoginUserCount() > 1) { + MultiUserBlockWindow("Restart"); + } else { + m_sessionHelper->doAction("Reboot"); + + } + } else { + AppBlockWindow("Restart"); + } + } +} + +void DbusUpperInterface::PowerOff() +{ + if (m_sessionHelper) { + QStringList lockCheckList = m_sessionHelper->getLockCheckStatus("shutdown"); + if (lockCheckList.count() == 0) { + if (m_lightDmHelper && m_lightDmHelper->getLoginUserCount() > 1) { + MultiUserBlockWindow("Shutdown"); + } else { + m_sessionHelper->doAction("PowerOff"); + } + } else { + AppBlockWindow("Shutdown"); + } + } +} + +void DbusUpperInterface::Logout() +{ + if (m_sessionHelper) { + QStringList lockCheckList = m_sessionHelper->getLockCheckStatus("shutdown"); + if (lockCheckList.count() == 0) + m_sessionHelper->doAction("Logout"); + else { + AppBlockWindow("Logout"); + } + } +} + +void DbusUpperInterface::SwitchUser() +{ + if (m_sessionHelper) { + m_sessionHelper->doAction("SwitchUser"); + } +} + void DbusUpperInterface::UnLock() { if(m_procLockDialog.state() != QProcess::NotRunning) @@ -497,23 +675,42 @@ QString DbusUpperInterface::GetInformation(QString strJson) PamAuthenticationUser(rootObj, retObj); case LOCK_CMD_ID_GSETTINGS_GET_USD_MEDIAKEYS_CONF: retObj["CmdId"] = cmdId; - getUsdMediaKeys(rootObj, retObj); + GetUsdMediaKeys(rootObj, retObj); break; case LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANHIBERNATE: retObj["CmdId"] = cmdId; - retObj["Content"] = m_login1Helper->isCanHibernate(); + if (m_login1Helper) + retObj["Content"] = m_login1Helper->isCanHibernate(); break; case LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANPOWEROFF: retObj["CmdId"] = cmdId; - retObj["Content"] = m_login1Helper->isCanPowerOff(); + if (m_login1Helper) + retObj["Content"] = m_login1Helper->isCanPowerOff(); break; case LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANREBOOT: retObj["CmdId"] = cmdId; - retObj["Content"] = m_login1Helper->isCanReboot(); + if (m_login1Helper) + retObj["Content"] = m_login1Helper->isCanReboot(); break; case LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANSUSPEND: retObj["CmdId"] = cmdId; - retObj["Content"] = m_login1Helper->isCanSuspend(); + if (m_login1Helper) + retObj["Content"] = m_login1Helper->isCanSuspend(); + break; + case LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANLOGOUT: + retObj["CmdId"] = cmdId; + if (m_sessionHelper) + retObj["Content"] = m_sessionHelper->canAction(PowerLogout); + break; + case LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANLOCKSCREEN: + retObj["CmdId"] = cmdId; + if (m_sessionHelper) + retObj["Content"] = m_sessionHelper->canAction(PowerMonitorOff); + break; + case LOCK_CMD_ID_SYSTEM_UPGRADE_CHECK: + retObj["CmdId"] = cmdId; + if (m_systemsUpgradeHelper) + retObj["Content"] = m_systemsUpgradeHelper->checkSystemUpgrade(); break; case LOCK_CMD_ID_UPOWER_BATTERY_STATUS: retObj["CmdId"] = cmdId; @@ -2220,7 +2417,7 @@ int DbusUpperInterface::BioStopAuth(const QJsonObject &objInfo) return nRet; } -void DbusUpperInterface::getUsdMediaKeys(QJsonObject &reqObj, QJsonObject &retObj) +void DbusUpperInterface::GetUsdMediaKeys(QJsonObject &reqObj, QJsonObject &retObj) { QString strKey = reqObj.value("Key").toString(); if (!strKey.isEmpty()) { @@ -2286,8 +2483,17 @@ int DbusUpperInterface::SetPowerManager(const QJsonObject &objInfo) QString strFuncName = objInfo.value("Content").toString(); if (!strFuncName.isEmpty()) { qWarning() << __LINE__ << __FUNCTION__ << strFuncName; - if (m_login1Helper) - m_login1Helper->setPowerManager(strFuncName); + if (strFuncName != "UpgradeThenRestart" && strFuncName != "UpgradeThenShutdown" && m_sessionHelper) + if (!isGreeterMode()) { + m_sessionHelper->doAction(strFuncName); + } else if (m_login1Helper) { + m_login1Helper->setPowerManager(strFuncName); + } + else if (strFuncName == "UpgradeThenRestart" && m_systemsUpgradeHelper) { + m_systemsUpgradeHelper->doUpgradeThenRboot(); + } else if (strFuncName == "UpgradeThenShutdown" && m_systemsUpgradeHelper) { + m_systemsUpgradeHelper->doUpgradeThenShutdown(); + } nRet = 0; } diff --git a/src/lock-backend/dbusupperinterface.h b/src/lock-backend/dbusupperinterface.h index 650749f..8fa7761 100644 --- a/src/lock-backend/dbusupperinterface.h +++ b/src/lock-backend/dbusupperinterface.h @@ -39,6 +39,7 @@ class UsdHelper; class UpowerHelper; class AccountsHelper; class SessionHelper; +class SystemUpgradeHelper; class SessionWatcher; class BioAuthenticate; class KglobalAccelHelper; @@ -112,6 +113,20 @@ public: * */ void LockScreensaver(); + /** + * @brief session tools + * + */ + bool CheckAppVersion(); + void SessionTools(); + void AppBlockWindow(QString actionType); + void MultiUserBlockWindow(QString actionType); + void Suspend(); + void Logout(); + void SwitchUser(); + void Reboot(); + void PowerOff(); + void Hibernate(); /** * @brief 获取信息 * @@ -302,7 +317,7 @@ private: int PamRespond(const QJsonObject &objInfo); - void getUsdMediaKeys(QJsonObject &reqObj, QJsonObject &retObj); + void GetUsdMediaKeys(QJsonObject &reqObj, QJsonObject &retObj); bool usdExternalDoAction(const QJsonObject &objInfo); @@ -393,6 +408,7 @@ private: AccountsHelper *m_accountsHelper = nullptr; bool lockState = false; SessionHelper *m_sessionHelper = nullptr; + SystemUpgradeHelper *m_systemsUpgradeHelper = nullptr; SessionWatcher *m_sessionWatcher = nullptr; BioAuthenticate *m_bioAuth = nullptr; RSAC rsac; diff --git a/src/lock-backend/gsettingshelper.cpp b/src/lock-backend/gsettingshelper.cpp index a769856..4fe50cd 100644 --- a/src/lock-backend/gsettingshelper.cpp +++ b/src/lock-backend/gsettingshelper.cpp @@ -242,6 +242,12 @@ bool GSettingsHelper::initSession() if (keys.contains(KEY_SESSION_IDLE)) { m_nSessionIdle = m_gsSession->get(KEY_SESSION_IDLE).toInt(); } + if (keys.contains(KEY_SESSION_LOGOUT_MUSIC)) { + m_nSessionLogout = m_gsSession->get(KEY_SESSION_LOGOUT_MUSIC).toBool(); + } + if (keys.contains(KEY_SESSION_POWEROFF_MUSIC)) { + m_nSessionPoweroff = m_gsSession->get(KEY_SESSION_POWEROFF_MUSIC).toBool(); + } } } return (bool)(m_gsSession); @@ -423,6 +429,10 @@ void GSettingsHelper::onSessionConfigChanged(QString strKey) QVariant varValue; if (strKey == KEY_SESSION_IDLE) { varValue = m_nSessionIdle = m_gsSession->get(KEY_SESSION_IDLE).toInt(); + } else if (strKey == KEY_SESSION_LOGOUT_MUSIC) { + m_nSessionLogout = m_gsSession->get(KEY_SESSION_LOGOUT_MUSIC).toBool(); + } else if (strKey == KEY_SESSION_POWEROFF_MUSIC) { + m_nSessionPoweroff = m_gsSession->get(KEY_SESSION_POWEROFF_MUSIC).toBool(); } Q_EMIT sessionConfigChanged(strKey, varValue); } @@ -661,6 +671,10 @@ QVariant GSettingsHelper::GetSessionConf(QString strKey) if (initSession()) { if (strKey == KEY_SESSION_IDLE) { varValue = m_nSessionIdle; + } else if (strKey == KEY_SESSION_LOGOUT_MUSIC) { + varValue = m_nSessionLogout; + } else if (strKey == KEY_SESSION_POWEROFF_MUSIC) { + varValue = m_nSessionPoweroff; } } return varValue; diff --git a/src/lock-backend/gsettingshelper.h b/src/lock-backend/gsettingshelper.h index d005236..b325f23 100644 --- a/src/lock-backend/gsettingshelper.h +++ b/src/lock-backend/gsettingshelper.h @@ -137,6 +137,8 @@ private: QString m_font; int m_nSessionIdle = -1; + bool m_nSessionLogout = false; + bool m_nSessionPoweroff = false; bool m_capsState = false; diff --git a/src/lock-backend/lightdmhelper.cpp b/src/lock-backend/lightdmhelper.cpp index fe0ab07..cbe9eab 100644 --- a/src/lock-backend/lightdmhelper.cpp +++ b/src/lock-backend/lightdmhelper.cpp @@ -95,6 +95,18 @@ QList LightDMHelper::getSessionsInfo() return m_listSessions; } +int LightDMHelper::getLoginUserCount() +{ + QList userInfos = m_mapUsers->values(); + int loginUserCount = 0; + for (auto user : userInfos) { + if (isUserLoggined(user->name())) { + loginUserCount += 1; + } + } + return loginUserCount; +} + void LightDMHelper::startSession() { if(isAuthenticated()) { diff --git a/src/lock-backend/lightdmhelper.h b/src/lock-backend/lightdmhelper.h index 0468fec..34a9f39 100644 --- a/src/lock-backend/lightdmhelper.h +++ b/src/lock-backend/lightdmhelper.h @@ -95,6 +95,8 @@ public: QList getSessionsInfo(); + int getLoginUserCount(); + public Q_SLOTS: /** * @brief 启动会话 diff --git a/src/lock-backend/org.ukui.ScreenSaver.xml b/src/lock-backend/org.ukui.ScreenSaver.xml index ae260a2..5ce8c18 100644 --- a/src/lock-backend/org.ukui.ScreenSaver.xml +++ b/src/lock-backend/org.ukui.ScreenSaver.xml @@ -41,5 +41,28 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/lock-command/main.cpp b/src/lock-command/main.cpp index 2bec02d..3ec82f9 100644 --- a/src/lock-command/main.cpp +++ b/src/lock-command/main.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include "utils.h" #include #include @@ -56,16 +57,28 @@ int main(int argc, char **argv) QCoreApplication::translate("main", "show the screensaver")); QCommandLineOption blankOption({"b", QStringLiteral("blank")}, QCoreApplication::translate("main", "show blank and delay to lock,param:idle/lid/lowpower"), "lid"); + QCommandLineOption sessiontoolsOption({"t", QStringLiteral("session-tools")}, + QCoreApplication::translate("main", "show the session tools")); + QCommandLineOption appBlockOption({"a", QStringLiteral("app-block")}, + QCoreApplication::translate("main", "show the app block window"), + QGuiApplication::translate("action", "which block type,param:Suspend/Hibernate/Restart/Shutdown/Logout"), "type"); + QCommandLineOption multiUsersOption({"m", QStringLiteral("multiusers-block")}, + QCoreApplication::translate("main", "show the multiUsers block window"), + QGuiApplication::translate("action", "which block type,param:Shutdown/Restart"), "type"); parser.addOption(lockOption); parser.addOption(queryOption); parser.addOption(unlockOption); parser.addOption(screensaverOption); parser.addOption(blankOption); + parser.addOption(sessiontoolsOption); + parser.addOption(appBlockOption); + parser.addOption(multiUsersOption); parser.process(a); if(!parser.isSet(lockOption) && !parser.isSet(queryOption) && !parser.isSet(unlockOption) - && !parser.isSet(screensaverOption) && !parser.isSet(blankOption)) + && !parser.isSet(screensaverOption) && !parser.isSet(blankOption) + && !parser.isSet(sessiontoolsOption) && !parser.isSet(appBlockOption) && !parser.isSet(multiUsersOption)) return -1; QString displayNum = QString(qgetenv("DISPLAY")).replace(":", "").replace(".", "_"); @@ -132,6 +145,21 @@ int main(int argc, char **argv) } else { qDebug()<<"LockByBlank:"<call("SessionTools"); + if(msg.type() == QDBusMessage::ErrorMessage) + qDebug() << msg.errorMessage(); + } else if (parser.isSet(appBlockOption) && !stateReply) { + QString opValue = parser.value(appBlockOption); + QDBusMessage msg = interface->call("AppBlockWindow", opValue); + if(msg.type() == QDBusMessage::ErrorMessage) + qDebug() << msg.errorMessage(); + } else if (parser.isSet(multiUsersOption) && !stateReply) { + QString opValue = parser.value(multiUsersOption); + qDebug() << opValue; + QDBusMessage msg = interface->call("MultiUserBlockWindow", opValue); + if(msg.type() == QDBusMessage::ErrorMessage) + qDebug() << msg.errorMessage(); } return 0; } diff --git a/src/lock-dialog/backenddbushelper.cpp b/src/lock-dialog/backenddbushelper.cpp index 203f1f9..95db190 100644 --- a/src/lock-dialog/backenddbushelper.cpp +++ b/src/lock-dialog/backenddbushelper.cpp @@ -2388,6 +2388,43 @@ bool BackendDbusHelper::getPowerManagerCanPowerOff() return canFlag; } +bool BackendDbusHelper::getPowerManagerCanSwitchUser() +{ + bool canFlag = true; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANSWITCHUSER; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getPowerManagerCanSwitchUser error: " << reply.error().message(); + } else { + QString strResponse = reply.value(); + QJsonParseError jsonParseError; + const QJsonDocument jsonDoc = QJsonDocument::fromJson(strResponse.toUtf8(), &jsonParseError); + if (jsonParseError.error != QJsonParseError::NoError) { + qInfo()<<"getPowerManagerCanSwitchUser Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getPowerManagerCanSwitchUser Json is null!!"; + } else { + if (objRes.contains("CmdId") && objRes.contains("Ret")) { + int nCmdId = objRes.value("CmdId").toInt(-1); + int nRet = objRes.value("Ret").toInt(-1); + if (nCmdId != LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANSWITCHUSER || nRet != 0) { + qInfo()<<"getPowerManagerCanSwitchUser Failed!!"; + } else { + canFlag = objRes.value("Content").toBool(); + } + } else { + qInfo()<<"getPowerManagerCanSwitchUser Json is invalid!!"; + } + } + } + } + return canFlag; +} + bool BackendDbusHelper::getPowerManagerCanHibernate() { bool canFlag = true; @@ -2425,6 +2462,117 @@ bool BackendDbusHelper::getPowerManagerCanHibernate() return canFlag; } +bool BackendDbusHelper::getPowerManagerCanLogout() +{ + bool canFlag = true; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANLOGOUT; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getPowerManagerCanLogout error: " << reply.error().message(); + } else { + QString strResponse = reply.value(); + QJsonParseError jsonParseError; + const QJsonDocument jsonDoc = QJsonDocument::fromJson(strResponse.toUtf8(), &jsonParseError); + if (jsonParseError.error != QJsonParseError::NoError) { + qInfo()<<"getPowerManagerCanLogout Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getPowerManagerCanLogout Json is null!!"; + } else { + if (objRes.contains("CmdId") && objRes.contains("Ret")) { + int nCmdId = objRes.value("CmdId").toInt(-1); + int nRet = objRes.value("Ret").toInt(-1); + if (nCmdId != LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANLOGOUT || nRet != 0) { + qInfo()<<"getPowerManagerCanLogout Failed!!"; + } else { + canFlag = objRes.value("Content").toBool(); + } + } else { + qInfo()<<"getPowerManagerCanLogout Json is invalid!!"; + } + } + } + } + return canFlag; +} + +bool BackendDbusHelper::getPowerManagerCanLockScreen() +{ + bool canFlag = true; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANLOCKSCREEN; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "getPowerManagerCanLockScreen error: " << reply.error().message(); + } else { + QString strResponse = reply.value(); + QJsonParseError jsonParseError; + const QJsonDocument jsonDoc = QJsonDocument::fromJson(strResponse.toUtf8(), &jsonParseError); + if (jsonParseError.error != QJsonParseError::NoError) { + qInfo()<<"getPowerManagerCanLockScreen Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"getPowerManagerCanLockScreen Json is null!!"; + } else { + if (objRes.contains("CmdId") && objRes.contains("Ret")) { + int nCmdId = objRes.value("CmdId").toInt(-1); + int nRet = objRes.value("Ret").toInt(-1); + if (nCmdId != LOCK_CMD_ID_LOGIN1_GET_POWER_MANAGER_CANLOCKSCREEN || nRet != 0) { + qInfo()<<"getPowerManagerCanLockScreen Failed!!"; + } else { + canFlag = objRes.value("Content").toBool(); + } + } else { + qInfo()<<"getPowerManagerCanLockScreen Json is invalid!!"; + } + } + } + } + return canFlag; +} + +bool BackendDbusHelper::checkSystemUpgrade() +{ + bool canFlag = true; + QJsonObject jsonCmd; + jsonCmd["CmdId"] = LOCK_CMD_ID_SYSTEM_UPGRADE_CHECK; + QDBusPendingReply reply = GetInformation(QString(QJsonDocument(jsonCmd).toJson())); + reply.waitForFinished(); + if (reply.isError()) { + qWarning() << "checkSystemUpgrade error: " << reply.error().message(); + } else { + QString strResponse = reply.value(); + QJsonParseError jsonParseError; + const QJsonDocument jsonDoc = QJsonDocument::fromJson(strResponse.toUtf8(), &jsonParseError); + if (jsonParseError.error != QJsonParseError::NoError) { + qInfo()<<"checkSystemUpgrade Parse json failed!!"; + } else { + QJsonObject objRes = jsonDoc.object(); + if (objRes.isEmpty()) { + qInfo()<<"checkSystemUpgrade Json is null!!"; + } else { + if (objRes.contains("CmdId") && objRes.contains("Ret")) { + int nCmdId = objRes.value("CmdId").toInt(-1); + int nRet = objRes.value("Ret").toInt(-1); + if (nCmdId != LOCK_CMD_ID_SYSTEM_UPGRADE_CHECK || nRet != 0) { + qInfo()<<"checkSystemUpgrade Failed!!"; + } else { + canFlag = objRes.value("Content").toBool(); + } + } else { + qInfo()<<"checkSystemUpgrade Json is invalid!!"; + } + } + } + } + return canFlag; +} + QString BackendDbusHelper::getPublicEncrypt() { QString publicEncrypt = ""; diff --git a/src/lock-dialog/backenddbushelper.h b/src/lock-dialog/backenddbushelper.h index 71c908c..5c3d555 100644 --- a/src/lock-dialog/backenddbushelper.h +++ b/src/lock-dialog/backenddbushelper.h @@ -110,10 +110,15 @@ public: * @return 是否调用成功 */ bool usdExternalDoAction(int actionType); + + bool getPowerManagerCanSwitchUser(); bool getPowerManagerCanHibernate(); bool getPowerManagerCanPowerOff(); bool getPowerManagerCanReboot(); bool getPowerManagerCanSuspend(); + bool getPowerManagerCanLockScreen(); + bool getPowerManagerCanLogout(); + bool checkSystemUpgrade(); QStringList getBatteryArgs(); diff --git a/src/lock-dialog/lockdialogmodel.cpp b/src/lock-dialog/lockdialogmodel.cpp index dbfc914..712bd04 100644 --- a/src/lock-dialog/lockdialogmodel.cpp +++ b/src/lock-dialog/lockdialogmodel.cpp @@ -60,7 +60,16 @@ bool LockDialogModel::parseCmdArguments(QStringList args, CommandLineArgs &cmdAr QCommandLineOption hasLockOption(QStringLiteral("has-lock"), QGuiApplication::translate("main", "show blank screensaver immediately and if lock"), QGuiApplication::translate("has-lock", "if show lock"), "1"); - parser.addOptions({lockOption, lstOption,sessionIdleOption , screensaverOption,blankOption,lscreensaverOption,delayOption,hasLockOption}); + QCommandLineOption sessiontoolsOption({"t", QStringLiteral("session-tools")}, + QCoreApplication::translate("main", "show the session tools")); + QCommandLineOption appBlockOption({"a", QStringLiteral("app-block")}, + QCoreApplication::translate("main", "show the app block window"), + QGuiApplication::translate("action", "which block type"), "type"); + QCommandLineOption multiUsersOption({"m", QStringLiteral("multiusers-block")}, + QCoreApplication::translate("main", "show the multiUsers block window"), + QGuiApplication::translate("action", "which block type"), "type"); + parser.addOptions({lockOption, lstOption,sessionIdleOption , screensaverOption,blankOption,lscreensaverOption,delayOption, + hasLockOption,sessiontoolsOption,appBlockOption,multiUsersOption}); parser.process(args); QString strHostCloundPlatform = getHostCloudPlatform(); @@ -75,7 +84,10 @@ bool LockDialogModel::parseCmdArguments(QStringList args, CommandLineArgs &cmdAr && !parser.isSet(lstOption) && !parser.isSet(screensaverOption) && !parser.isSet(lscreensaverOption) - && !parser.isSet(blankOption)) + && !parser.isSet(blankOption) + && !parser.isSet(sessiontoolsOption) + && !parser.isSet(appBlockOption) + && !parser.isSet(multiUsersOption)) { return false; } @@ -86,6 +98,7 @@ bool LockDialogModel::parseCmdArguments(QStringList args, CommandLineArgs &cmdAr cmdArgs.isScreenSaver = parser.isSet(screensaverOption); cmdArgs.isLockScreensaver = parser.isSet(lscreensaverOption); cmdArgs.isBlank = parser.isSet(blankOption); + cmdArgs.isSessionTools = parser.isSet(sessiontoolsOption); if (parser.isSet(hasLockOption)) { int nHasLockValue = parser.value(hasLockOption).toInt(); if (nHasLockValue == 0) { @@ -97,6 +110,28 @@ bool LockDialogModel::parseCmdArguments(QStringList args, CommandLineArgs &cmdAr if (parser.isSet(delayOption)) { cmdArgs.nBlankDelay = parser.value(delayOption).toInt(); } + if (parser.isSet(appBlockOption)) { + QString opValue = parser.value(appBlockOption); + if (opValue == "Restart") { + cmdArgs.isAppBlock = 0; + } else if (opValue == "Shutdown") { + cmdArgs.isAppBlock = 1; + } else if (opValue == "Suspend") { + cmdArgs.isAppBlock = 2; + } else if (opValue == "Hibernate") { + cmdArgs.isAppBlock = 3; + } else if (opValue == "Logout") { + cmdArgs.isAppBlock = 4; + } + } + if (parser.isSet(multiUsersOption)) { + QString opValue = parser.value(multiUsersOption); + if (opValue == "Restart") { + cmdArgs.isMultiUserBlock = 0; + } else if (opValue == "Shutdown") { + cmdArgs.isMultiUserBlock = 1; + } + } return true; } @@ -147,6 +182,18 @@ void LockDialogModel::onRunningMessage(const QString &strMsg) Q_EMIT showScreensaver(); } + if (cmdArgs.isSessionTools) { + Q_EMIT showSessionTools(); + } + + if (cmdArgs.isAppBlock != -1) { + Q_EMIT showAppBlockWindow(cmdArgs.isAppBlock); + } + + if (cmdArgs.isMultiUserBlock != -1) { + Q_EMIT showMultiUsersBlockWindow(cmdArgs.isMultiUserBlock); + } + KillFocusOfKydroid(); } @@ -383,6 +430,8 @@ void LockDialogModel::onLockScreenConfChanged(const QString &key, QVariant value m_lockTimeout = value.toInt(); } else if (key ==KEY_LOCK_ENABLED){ m_lockEnabled = value.toBool(); + } else if (key == KEY_SLEEP_ACTIVATION_ENABLED) { + m_sleepActivationEnabled = value.toBool(); } } @@ -412,6 +461,15 @@ void LockDialogModel::onTabletModeChanged(bool tabletMode) Q_EMIT tabletModeChanged(tabletMode); } +void LockDialogModel::onSessionConfChanged(const QString &key, QVariant value) +{ + if (key == KEY_SESSION_LOGOUT_MUSIC) { + m_logoutMusic = value.toBool(); + } else if (key == KEY_SESSION_POWEROFF_MUSIC) { + m_poweroffMusic = value.toBool(); + } +} + void LockDialogModel::updateCapslockState(bool capslockState) { m_capslockState = capslockState; @@ -443,6 +501,11 @@ void LockDialogModel::updateLockEnabled(bool value) m_lockEnabled = value; } +void LockDialogModel::updateSleepActivationEnabled(bool value) +{ + m_sleepActivationEnabled = value; +} + void LockDialogModel::updateLockTimeout(int value) { m_lockTimeout = value; @@ -495,6 +558,34 @@ void LockDialogModel::updateCanSuspend(bool canflag) } +void LockDialogModel::updateCanLockScreen(bool canflag) +{ + qWarning()<<__LINE__ << __FUNCTION__ << canflag; + m_CanLockScreen = canflag; + +} + +void LockDialogModel::updateCanSwitchUser(bool canflag) +{ + qWarning()<<__LINE__ << __FUNCTION__ << canflag; + m_CanSwitchUser = canflag; + +} + +void LockDialogModel::updateCanLogout(bool canflag) +{ + qWarning()<<__LINE__ << __FUNCTION__ << canflag; + m_CanLogout = canflag; + +} + +void LockDialogModel::updataCheckSystemUpgrade(bool canflag) +{ + qWarning()<<__LINE__ << __FUNCTION__ << canflag; + m_sysUpgradeStatus = canflag; + +} + void LockDialogModel::updateBatteryArgs(QStringList batteryArgs) { m_batteryArgs = batteryArgs; diff --git a/src/lock-dialog/lockdialogmodel.h b/src/lock-dialog/lockdialogmodel.h index 4d7bf04..518df49 100644 --- a/src/lock-dialog/lockdialogmodel.h +++ b/src/lock-dialog/lockdialogmodel.h @@ -45,6 +45,9 @@ public: bool isBlank = false; /**< 是否黑色屏保锁定 */ bool isBlankHasLock = true; /**< 是否黑色屏保需要锁定 */ int nBlankDelay = 0; /**< 黑色屏保延迟锁定时间 */ + bool isSessionTools = false; /**< 显示session电源管理界面*/ + int isAppBlock = -1; /**< 显示应用阻塞关机/重启界面*/ + int isMultiUserBlock = -1; /**< 显示多用户登录阻塞关机/重启界面*/ }; /** * @brief 构造 @@ -125,6 +128,8 @@ public: void updateLockEnabled(bool value); + void updateSleepActivationEnabled(bool value); + inline QStringList sessionsInfo() { return m_listSessions; } inline void updateCurSession(const QString &strSession) { m_strCurSession = strSession; } @@ -147,6 +152,10 @@ public: void updateSystemFontSize(double fontSize) { m_curFontSize = fontSize; } + void updateSessionLogoutMusic(bool logoutMusic) {m_logoutMusic = logoutMusic;} + + void updateSessionPoweroffMusic(bool poweroffMusic) {m_poweroffMusic = poweroffMusic;} + inline AgreementInfoPtr agreementInfo() { return m_agreementInfo;} inline bool getAgreementWindowShowLoginPrompt() { return m_agreementInfo->showLoginPrompt(); } @@ -170,11 +179,19 @@ public: inline bool getCanSuspend() { return m_CanSuspend; } inline bool getCanReboot() { return m_CanReboot; } inline bool getCanPowerOff() { return m_CanPowerOff; } + inline bool getCanLockScreen() { return m_CanLockScreen; } + inline bool getCanSwitchUser() { return m_CanSwitchUser; } + inline bool getCanLogout() { return m_CanLogout; } + inline bool checkSystemUpgrade() { return m_sysUpgradeStatus; } void updateCanHibernate(bool); void updateCanReboot(bool); void updateCanPowerOff(bool); void updateCanSuspend(bool); + void updateCanLockScreen(bool); + void updateCanSwitchUser(bool); + void updateCanLogout(bool); + void updataCheckSystemUpgrade(bool); inline QStringList getBatteryArgs() { return m_batteryArgs; } @@ -198,6 +215,12 @@ public: inline bool getTabletMode() { return m_tabletMode; } + inline bool getSessionLogoutMusic() { return m_logoutMusic; } + + inline bool getSessionPoweroffMusic() { return m_poweroffMusic; } + + inline bool getSleepActivationEnabled() {return m_sleepActivationEnabled; } + public Q_SLOTS: /** * @brief 会话激活状态改变 @@ -240,6 +263,8 @@ public Q_SLOTS: void onTabletModeChanged(bool tabletMode); + void onSessionConfChanged(const QString &key, QVariant value); + Q_SIGNALS: /** * @brief 请求解锁会话 @@ -302,6 +327,21 @@ Q_SIGNALS: * */ void showPowerManager(); + /** + * @brief 显示session电源管理 + * + */ + void showSessionTools(); + /** + * @brief 显示应用阻塞关机界面 + * + */ + void showAppBlockWindow(int actionType); + /** + * @brief 显示多用户登录阻塞关机界面 + * + */ + void showMultiUsersBlockWindow(int actionType); void currentUserChanged(const QString &strUserName); @@ -398,6 +438,10 @@ private: bool m_CanReboot; bool m_CanPowerOff; bool m_CanSuspend; + bool m_CanLockScreen; + bool m_CanSwitchUser; + bool m_CanLogout; + bool m_sysUpgradeStatus; QStringList m_batteryArgs; QString m_batteryIconName; @@ -409,8 +453,12 @@ private: int m_lockTimeout = 10; bool m_lockEnabled = true; double m_curFontSize; + bool m_sleepActivationEnabled = false; bool m_tabletMode = false; + + bool m_logoutMusic = false; + bool m_poweroffMusic = false; }; #endif // LOCKDIALOGMODEL_H diff --git a/src/lock-dialog/lockdialogperformer.cpp b/src/lock-dialog/lockdialogperformer.cpp index 0a6fc6c..fa27173 100644 --- a/src/lock-dialog/lockdialogperformer.cpp +++ b/src/lock-dialog/lockdialogperformer.cpp @@ -58,6 +58,7 @@ void LockDialogPerformer::initConnections() connect(m_bdHelper, &BackendDbusHelper::SecondRunParam, m_modelLockDialog, &LockDialogModel::onSecondRunParam); connect(m_bdHelper, &BackendDbusHelper::lockScreenConfChanged, m_modelLockDialog, &LockDialogModel::onLockScreenConfChanged); connect(m_bdHelper, &BackendDbusHelper::themeStyleConfChanged, m_modelLockDialog, &LockDialogModel::onThemeStyleConfChanged); + connect(m_bdHelper, &BackendDbusHelper::sessionConfChanged, m_modelLockDialog, &LockDialogModel::onSessionConfChanged); // pam signals connect(m_bdHelper, SIGNAL(pamShowMessage(QString, int)), m_modelLockDialog, SIGNAL(pamShowMessage(QString, int))); @@ -136,10 +137,14 @@ void LockDialogPerformer::initData() m_modelLockDialog->updateScreensaverTheme(m_bdHelper->getSaverThemes()); m_modelLockDialog->updateScreensaverImageTSEffect(m_bdHelper->getLockScreenConf(KEY_IMAGE_TRANSITION_EFFECT).toInt()); m_modelLockDialog->updateScreensaverImageSwitchInterval(m_bdHelper->getLockScreenConf(KEY_IMAGE_SWITCH_INTERVAL).toInt()); + m_modelLockDialog->updateCanSwitchUser(m_bdHelper->getPowerManagerCanSwitchUser()); m_modelLockDialog->updateCanHibernate(m_bdHelper->getPowerManagerCanHibernate()); m_modelLockDialog->updateCanReboot(m_bdHelper->getPowerManagerCanReboot()); m_modelLockDialog->updateCanPowerOff(m_bdHelper->getPowerManagerCanPowerOff()); m_modelLockDialog->updateCanSuspend(m_bdHelper->getPowerManagerCanSuspend()); + m_modelLockDialog->updateCanLockScreen(m_bdHelper->getPowerManagerCanLockScreen()); + m_modelLockDialog->updateCanLogout(m_bdHelper->getPowerManagerCanLogout()); + m_modelLockDialog->updataCheckSystemUpgrade(m_bdHelper->checkSystemUpgrade()); m_modelLockDialog->updateBatteryArgs(m_bdHelper->getBatteryArgs()); m_modelLockDialog->updateBatteryIconName(m_bdHelper->getBatteryIconName()); m_modelLockDialog->updateIsBattery(m_bdHelper->getIsBattery()); @@ -148,7 +153,10 @@ void LockDialogPerformer::initData() m_modelLockDialog->updateLoggedInUsersCount(); m_modelLockDialog->updateLockTimeout(m_bdHelper->getLockScreenConf(KEY_LOCK_TIMEOUT).toInt()); m_modelLockDialog->updateLockEnabled(m_bdHelper->getLockScreenConf(KEY_LOCK_ENABLED).toBool()); + m_modelLockDialog->updateSleepActivationEnabled(m_bdHelper->getLockScreenConf(KEY_SLEEP_ACTIVATION_ENABLED).toBool()); m_modelLockDialog->updateSystemFontSize(m_bdHelper->getThemeStyleConf(KEY_SYSTEM_FONT_SIZE).toDouble()); m_modelLockDialog->updateTabletMode(m_bdHelper->getCurTabletMode()); + m_modelLockDialog->updateSessionLogoutMusic(m_bdHelper->getSessionConf(KEY_SESSION_LOGOUT_MUSIC).toBool()); + m_modelLockDialog->updateSessionPoweroffMusic(m_bdHelper->getSessionConf(KEY_SESSION_POWEROFF_MUSIC).toBool()); } diff --git a/src/lock-dialog/main.cpp b/src/lock-dialog/main.cpp index d93297e..6a7dfac 100644 --- a/src/lock-dialog/main.cpp +++ b/src/lock-dialog/main.cpp @@ -183,6 +183,18 @@ int main(int argc, char *argv[]) Q_EMIT lockDialogModel->showScreensaver(); } + if(cmdArgs.isSessionTools) { + Q_EMIT lockDialogModel->showSessionTools(); + } + + if (cmdArgs.isAppBlock != -1) { + Q_EMIT lockDialogModel->showAppBlockWindow(cmdArgs.isAppBlock); + } + + if (cmdArgs.isMultiUserBlock != -1) { + Q_EMIT lockDialogModel->showMultiUsersBlockWindow(cmdArgs.isMultiUserBlock); + } + KillFocusOfKydroid(); return app.exec(); diff --git a/src/widgets/blockwidget.cpp b/src/widgets/blockwidget.cpp index 1a79724..44d8eda 100644 --- a/src/widgets/blockwidget.cpp +++ b/src/widgets/blockwidget.cpp @@ -49,6 +49,7 @@ void BlockWidget::initUi() QHBoxLayout *listLayout = new QHBoxLayout(); listLayout->setAlignment(Qt::AlignCenter); m_listView = new QListView(this); + m_listView->setObjectName(QString::fromUtf8("applist")); listLayout->addWidget(m_listView); @@ -73,7 +74,7 @@ void BlockWidget::initUi() m_curFontSize = m_modelLockDialog->getCurFontSize(); m_ptToPx = m_modelLockDialog->getPtToPx(); connect(m_modelLockDialog, &LockDialogModel::fontSizeChanged, this, &BlockWidget::onFontSizeChanged); - m_tipLabel->setFontSize((14 + m_curFontSize)*m_ptToPx); + m_tipLabel->setFontSize((18 + m_curFontSize)*m_ptToPx); connect(m_cancelButton, &QPushButton::clicked, this, [&]() { emit cancelButtonclicked(); }); connect(m_confirmButton, &QPushButton::clicked, this, [&]() { emit confirmButtonclicked(); }); @@ -82,7 +83,7 @@ void BlockWidget::initUi() void BlockWidget::onFontSizeChanged(double fontSize) { m_curFontSize = fontSize; - m_tipLabel->setFontSize((14 + m_curFontSize)*m_ptToPx); + m_tipLabel->setFontSize((18 + m_curFontSize)*m_ptToPx); sysFont.setPointSize((16 + m_curFontSize) *m_ptToPx); m_confirmButton->setFont(sysFont); @@ -114,7 +115,7 @@ void BlockWidget::setTips(const QString tips) m_confirmButton->setStyleSheet("QPushButton{background: rgba(255, 255, 255, 0.2);border-radius: 8px;color: white;}" "QPushButton:hover{background: rgba(255, 255, 255, 0.4);border-radius: 8px;}" "QPushButton:pressed {background: rgba(255, 255, 255, 0.3);border-radius: 8px;}"); - sysFont.setPointSize((16 + m_curFontSize) *m_ptToPx); + sysFont.setPointSize((20 + m_curFontSize) *m_ptToPx); m_confirmButton->setFont(sysFont); m_cancelButton->setFont(sysFont); m_confirmButton->show(); @@ -130,16 +131,19 @@ void BlockWidget::setWarning(QStringList list, int type) m_tipLabel->setFixedWidth(this->width()); switch (type) { case 0: - m_tipLabel->setText(tr("The following program is running to prevent the system from reboot!")); + m_tipLabel->setText(tr("The following programs prevent restarting, you can click \"Cancel\" and then close these programs.")); break; case 1: - m_tipLabel->setText(tr("The following program is running to prevent the system from shutting down!")); + m_tipLabel->setText(tr("The following programs prevent the shutdown, you can click \"Cancel\" and then close these programs.")); break; case 2: - m_tipLabel->setText(tr("The following program is running to prevent the system from suspend!")); + m_tipLabel->setText(tr("The following programs prevent suspend, you can click \"Cancel\" and then close these programs.")); break; case 3: - m_tipLabel->setText(tr("The following program is running to prevent the system from hibernate!")); + m_tipLabel->setText(tr("The following programs prevent hibernation, you can click \"Cancel\" and then close these programs.")); + break; + case 4: + m_tipLabel->setText(tr("The following programs prevent you from logging out, you can click \"Cancel\" and then close them.")); break; default: break; @@ -159,7 +163,12 @@ void BlockWidget::setWarning(QStringList list, int type) model->appendRow(new QStandardItem(icon, appName)); m_listView->verticalScrollMode(); - m_listView->setStyleSheet("color:white; background-color: rgba(255,255,255,30%); border-radius: 12px;"); + m_listView->setStyleSheet("QListView#applist{font:10pt;color:white;background-color: rgb(255,255,255,80);border-style: outset;border-width: 0px;border-radius: 6px;}\ + QListView#applist::item{height:48px;margin-top:2px;border-radius: 6px;}\ + QListView#applist::item::selected {background-color: rgb(255,255,255,80);border: 1px solid #296CD9;\ + height:48px;margin-top:2px;border-radius: 6px;}\ + QListView#applist::item::hover {background-color: rgb(255,255,255,80);height:48px;margin-top:2px;border-radius: 6px;}"); + sysFont.setPointSize((10 + m_curFontSize) *m_ptToPx); m_listView->setFont(sysFont); m_listView->setEditTriggers(QAbstractItemView::NoEditTriggers); @@ -169,9 +178,9 @@ void BlockWidget::setWarning(QStringList list, int type) m_cancelButton->setFixedSize(120, 48); m_confirmButton->hide(); - m_cancelButton->setStyleSheet("QPushButton{background: rgba(255, 255, 255, 0.2);border-radius: 8px;color: white;}" - "QPushButton:hover{background: rgba(255, 255, 255, 0.4);border-radius: 8px;}" - "QPushButton:pressed {background: rgba(255, 255, 255, 0.3);border-radius: 8px;}"); + m_cancelButton->setStyleSheet("QPushButton{background: rgba(255, 255, 255, 0.2);border-radius: 24px;color: white;}" + "QPushButton:hover{background: rgba(255, 255, 255, 0.4);border-radius:24px;}" + "QPushButton:pressed {background: rgba(255, 255, 255, 0.3);border-radius: 24px;}"); sysFont.setPointSize((16 + m_curFontSize) *m_ptToPx); m_cancelButton->setFont(sysFont); m_cancelButton->setText(tr("Cancel")); diff --git a/src/widgets/fullbackgroundwidget.cpp b/src/widgets/fullbackgroundwidget.cpp index 9ec7f0d..b97953b 100644 --- a/src/widgets/fullbackgroundwidget.cpp +++ b/src/widgets/fullbackgroundwidget.cpp @@ -95,6 +95,8 @@ void FullBackgroundWidget::initUI() if (!m_lockWidget) { m_lockWidget = new LockWidget(m_modelLockDialog, this); connect(m_lockWidget, &LockWidget::authSucceed, this, &FullBackgroundWidget::onAuthSucceed); + connect(m_lockWidget, &LockWidget::sessionToolsExit, this, &FullBackgroundWidget::onCloseScreensaver); + connect(m_lockWidget, &LockWidget::showBlankScreensaver, this, &FullBackgroundWidget::onShowBlankScreensaver); moveToPrimaryScreen(); } @@ -187,6 +189,9 @@ void FullBackgroundWidget::initConnections() connect(m_modelLockDialog, &LockDialogModel::showScreensaver, this, &FullBackgroundWidget::onShowScreensaver); connect(m_modelLockDialog, &LockDialogModel::showSessionIdle, this, &FullBackgroundWidget::onShowSessionIdle); connect(m_modelLockDialog, &LockDialogModel::SecondRunParam, this, &FullBackgroundWidget::onSecondRunParam); + connect(m_modelLockDialog, &LockDialogModel::showSessionTools, this, &FullBackgroundWidget::onShowSessionTools); + connect(m_modelLockDialog, &LockDialogModel::showAppBlockWindow, this, &FullBackgroundWidget::onShowAppBlockWindow); + connect(m_modelLockDialog, &LockDialogModel::showMultiUsersBlockWindow, this, &FullBackgroundWidget::onShowMultiUsersBlockWindows); } void FullBackgroundWidget::setLockState() @@ -225,6 +230,22 @@ void FullBackgroundWidget::onSecondRunParam(const QString &str) onShowSessionIdle(); } else if (str == "Screensaver") { onShowScreensaver(); + } else if (str == "CmdSessionTools") { + onShowSessionTools(); + } else if (str == "CmdRestartAppBlock") { + onShowAppBlockWindow(0); + } else if (str == "CmdPowerOffAppBlock") { + onShowAppBlockWindow(1); + } else if (str == "CmdSuspendAppBlock") { + onShowAppBlockWindow(2); + } else if (str == "CmdHibernateAppBlock") { + onShowAppBlockWindow(3); + } else if (str == "CmdLogoutAppBlock") { + onShowAppBlockWindow(4); + } else if (str == "CmdRestartMulTiUserBlock") { + onShowMultiUsersBlockWindows(0); + } else if (str == "CmdPowerOffMulTiUserBlock") { + onShowMultiUsersBlockWindows(1); } } @@ -271,6 +292,12 @@ void FullBackgroundWidget::onShowBlankScreensaver(int nDelay, bool isHasLock) void FullBackgroundWidget::onShowLock(bool isStartup) { + if (m_isSessionTools) { + m_isSessionTools = false; + if (m_lockWidget && !m_lockWidget->isHidden()) + m_lockWidget->exitSubWidget(); + } + screenStatus = (ScreenStatus)(screenStatus | SCREEN_LOCK); m_isStartupMode = isStartup; show(); @@ -280,6 +307,50 @@ void FullBackgroundWidget::onShowLock(bool isStartup) m_lockWidget->show(); } +void FullBackgroundWidget::onShowSessionTools() +{ + screenStatus = (ScreenStatus)(screenStatus | SCREEN_LOCK); + m_isSessionTools = true; + show(); + Q_EMIT m_modelLockDialog->setCurrentUser(m_modelLockDialog->defaultUserName()); + Q_EMIT m_modelLockDialog->lockStateChanged(true); + if (m_lockWidget && !m_lockWidget->isHidden()) + m_lockWidget->onShowPowerListWidget(true); +} + +void FullBackgroundWidget::onShowAppBlockWindow(int actionType) +{ + QStringList lockcheck; + if (actionType == 0 || actionType == 1 || actionType == 4) { + lockcheck = m_modelLockDialog->getShutdownLockcheck(); + } else if (actionType == 2 || actionType == 3) { + lockcheck = m_modelLockDialog->getSleepLockcheck(); + } + if (!lockcheck.isEmpty()) { + show(); + if (m_lockWidget && !m_lockWidget->isHidden()) + screenStatus = (ScreenStatus)(screenStatus | SCREEN_LOCK); + Q_EMIT m_modelLockDialog->setCurrentUser(m_modelLockDialog->defaultUserName()); + Q_EMIT m_modelLockDialog->lockStateChanged(true); + m_isSessionTools = true; + if (m_lockWidget && !m_lockWidget->isHidden()) + m_lockWidget->onShowInhibitWarning(lockcheck, actionType, true); + } + +} + +void FullBackgroundWidget::onShowMultiUsersBlockWindows(int actionType) +{ + screenStatus = (ScreenStatus)(screenStatus | SCREEN_LOCK); + m_isSessionTools = true; + show(); + if (m_lockWidget && !m_lockWidget->isHidden()) + Q_EMIT m_modelLockDialog->setCurrentUser(m_modelLockDialog->defaultUserName()); + Q_EMIT m_modelLockDialog->lockStateChanged(true); + if (m_lockWidget && !m_lockWidget->isHidden()) + m_lockWidget->onMulUsersLogined(actionType, true); +} + void FullBackgroundWidget::onShowSessionIdle() { onShowScreensaver(); @@ -295,6 +366,12 @@ void FullBackgroundWidget::onShowLockScreensaver() void FullBackgroundWidget::onShowScreensaver() { + if (m_isSessionTools) { + m_isSessionTools = false; + if (m_lockWidget && !m_lockWidget->isHidden()) + m_lockWidget->exitSubWidget(true); + } + screenStatus = (ScreenStatus)(screenStatus | SCREEN_SAVER); for (auto screen : QGuiApplication::screens()) { @@ -379,12 +456,6 @@ void FullBackgroundWidget::onCloseScreensaver() screenStatus = UNDEFINED; } -void FullBackgroundWidget::onShowPowerManager() -{ - show(); - Q_EMIT m_modelLockDialog->lockStateChanged(true); -} - void FullBackgroundWidget::onDesktopResized() { qDebug() << "[FullBackgroundWidget] [onDesktopResized]"; @@ -416,8 +487,13 @@ void FullBackgroundWidget::onPrepareForSleep(bool sleep) onClearScreensaver(); } else { repaint(); - if (m_lockWidget) + if (m_lockWidget) { + if (m_lockWidget->isHidden()) { + m_lockWidget->show(); + m_lockWidget->activateWindow(); + } m_lockWidget->startAuth(); + } // inhibit(); } } diff --git a/src/widgets/fullbackgroundwidget.h b/src/widgets/fullbackgroundwidget.h index 2ec9609..e10cc84 100644 --- a/src/widgets/fullbackgroundwidget.h +++ b/src/widgets/fullbackgroundwidget.h @@ -72,13 +72,15 @@ public Q_SLOTS: void onShowSessionIdle(); void onShowLockScreensaver(); void onShowScreensaver(); - void onShowPowerManager(); void onCloseScreensaver(); void onDesktopResized(); void onPrepareForSleep(bool sleep); void laterActivate(); void setLockState(); void onClearScreensaver(); + void onShowSessionTools(); + void onShowAppBlockWindow(int actionType); + void onShowMultiUsersBlockWindows(int actionType); void onCurUserChanged(const QString &strUserName); void onUpdateUserBackground(const QString &strUserName); @@ -157,6 +159,8 @@ private: int m_RREventBase; int m_RRErrorBase; QList m_listMonitors; + + bool m_isSessionTools = false; }; #endif // FULLBACKGROUNDWIDGET_H diff --git a/src/widgets/lockwidget.cpp b/src/widgets/lockwidget.cpp index da9abf4..264b091 100644 --- a/src/widgets/lockwidget.cpp +++ b/src/widgets/lockwidget.cpp @@ -99,8 +99,25 @@ bool LockWidget::eventFilter(QObject *obj, QEvent *event) return false; } -bool LockWidget::exitSubWidget() +bool LockWidget::exitSubWidget(bool isForScreensaver) { + if (m_isSessionTools) { + authDialog->setFocus(); + authDialog->show(); + buttonListWidget->show(); + m_timeWidget->show(); + m_powerListWidget->hide(); + if (m_systemMonitorBtn && m_systemMonitorBtn->isVisible()) { + m_systemMonitorBtn->hide(); + } + m_blockWidget->hide(); + m_powerManagerButton->setClickedStatus(NORMAL); + if (!isForScreensaver) { + Q_EMIT sessionToolsExit(); + } + m_isSessionTools = false; + return false; + } bool allExited = true; if (m_userListWidget && m_userListWidget->isVisible()) { m_userListWidget->hide(); @@ -110,8 +127,11 @@ bool LockWidget::exitSubWidget() if (m_powerListWidget && m_powerListWidget->isVisible()) { authDialog->setFocus(); authDialog->show(); - authDialog->lower(); m_powerListWidget->hide(); + buttonListWidget->show(); + if (m_systemMonitorBtn && m_systemMonitorBtn->isVisible()) { + m_systemMonitorBtn->hide(); + } m_powerManagerButton->setClickedStatus(NORMAL); allExited = false; } @@ -136,6 +156,13 @@ bool LockWidget::exitSubWidget() m_sessionButton->setClickedStatus(NORMAL); allExited = false; } + if (m_blockWidget && m_blockWidget->isVisible()) { + m_blockWidget->hide(); + m_timeWidget->show(); + m_powerListWidget->show(); + buttonListWidget->show(); + allExited = false; + } authDialog->setFocus(); return allExited; @@ -177,9 +204,16 @@ void LockWidget::resizeEvent(QResizeEvent *event) m_userListWidget->updateWidgetSize(); qDebug() << "m_userListWidget:" << m_userListWidget->geometry(); } + m_powerListWidget->setMaxHeight(height() - (80 + m_timeWidget->height() + m_systemMonitorBtn->height())); + m_powerListWidget->updateWidgetSize(); - m_powerListWidget->move((width() - m_powerListWidget->width()) / 2, - (height() - m_powerListWidget->height()) / 2 - BOTTOM_MARGIN * scale); + if (m_powerListWidget->getScrollShowStatus()) { //如果显示Scroll,直接从时间窗口底部开始显示 + m_powerListWidget->move((width() - m_powerListWidget->width())/2, + m_timeWidget->height() + 30); + } else { //居中显示 + m_powerListWidget->move((width() - m_powerListWidget->width())/2, + (height() - m_powerListWidget->height())/2); + } updateBottomButton(); if (m_curUserInfo->isLoggedIn() && m_sessionButton) { @@ -219,6 +253,10 @@ void LockWidget::resizeEvent(QResizeEvent *event) height() - BOTTOM_MARGIN * scale - buttonListWidget->height() - buttonListWidget->spacing() * scale - m_userListWidget->height()); } + + if (m_systemMonitorBtn) { + m_systemMonitorBtn->move((width() - m_systemMonitorBtn->width()) / 2, height() - m_systemMonitorBtn->height() - 40); + } onSetVirkeyboardPos(); } @@ -293,6 +331,7 @@ void LockWidget::initUI() initPowerWidget(); initButtonWidget(); initBlockWidget(); + initSystemMonitorBtn(); // authDialog->setFocus(); // Q_EMIT m_modelLockDialog->setCurrentUser(m_modelLockDialog->defaultUserName()); } @@ -366,14 +405,16 @@ void LockWidget::initSessionWidget() void LockWidget::initPowerWidget() { m_powerListWidget = new PowerListWidget(m_modelLockDialog, this); - m_powerListWidget->setMaximumHeight(height() / 2); m_powerListWidget->move((width() - m_powerListWidget->width()) / 2, (height() - m_powerListWidget->height()) / 2 - 80); m_powerListWidget->hide(); connect(m_powerListWidget, &MyListWidget::currentItemChanged, this, &LockWidget::onPowerItemChanged); connect(m_powerListWidget, &PowerListWidget::showInhibitWarning, this, &LockWidget::onShowInhibitWarning); connect(m_powerListWidget, &PowerListWidget::mulUsersLogined, this, &LockWidget::onMulUsersLogined); - connect(m_powerListWidget, &PowerListWidget::itemClicked, this, &LockWidget::onShowPowerListWidget); + connect(m_powerListWidget, &PowerListWidget::lockScreenClicked, this, &LockWidget::onLockScreenClicked); + connect(m_powerListWidget, &PowerListWidget::suspendClicked, this, &LockWidget::onSuspendClicked); + connect(m_powerListWidget, &PowerListWidget::itemClicked, this, &LockWidget::onPowerItemClicked); + connect(m_powerListWidget, &PowerListWidget::switchuserClicked, this, &LockWidget::onSwitchuserClicked); m_powerListWidget->clearFocus(); } @@ -484,16 +525,18 @@ void LockWidget::initButtonWidget() connect(m_virKbButton, &StatusButton::clicked, this, [this]() { onShowVirtualKeyboard(); }); onShowVirtualKeyboard(m_modelLockDialog->getTabletMode()); - if (m_powerListWidget->count() > 1) { +// if (m_powerListWidget->count() > 1 ) { m_powerManagerButton = new StatusButton(this, BOTBUTTON); - QListWidgetItem *buttonItem = new QListWidgetItem(); - buttonItem->setSizeHint(QSize(48, 48)); - buttonListWidget->insertItem(buttonListWidget->count(), buttonItem); - buttonListWidget->setItemWidget(buttonItem, m_powerManagerButton); + QListWidgetItem *powerButtonItem = new QListWidgetItem(); + powerButtonItem->setSizeHint(QSize(48, 48)); + buttonListWidget->insertItem(buttonListWidget->count(), powerButtonItem); + buttonListWidget->setItemWidget(powerButtonItem, m_powerManagerButton); m_powerManagerButton->setIcon(QIcon(":/image/assets/shutdown.svg")); - buttonListWidget->addItem(buttonItem); - connect(m_powerManagerButton, &StatusButton::clicked, this, [this]() { onShowPowerListWidget(); }); - } + buttonListWidget->addItem(powerButtonItem); + connect(m_powerManagerButton, &StatusButton::clicked, this, [this]() { + onShowPowerListWidget(); + }); +// } if (m_curUserInfo->isLoggedIn() && m_sessionButton) { buttonListWidget->setFixedSize(QSize(48 * (buttonListWidget->count() - 1) @@ -519,6 +562,21 @@ void LockWidget::initBlockWidget() connect(m_blockWidget, SIGNAL(confirmButtonclicked()), this, SLOT(onConfirmBtnClicked())); } +void LockWidget::initSystemMonitorBtn() +{ + m_systemMonitorBtn = new StatusButton(this, NORMALBTN); + QFont sysBtnFont; + sysBtnFont.setFamily(m_curFont); + sysBtnFont.setPointSize((16 + m_curFontSize) * m_ptToPx); + m_systemMonitorBtn->setFont(sysBtnFont); + m_systemMonitorBtn->hide(); + m_systemMonitorBtn->setFixedHeight(48); + m_systemMonitorBtn->setText(tr("system-monitor")); + m_systemMonitorBtn->setContentsMargins(5, 0, 5, 0); + m_systemMonitorBtn->adjustSize(); + connect(m_systemMonitorBtn, &StatusButton::clicked, this, &LockWidget::doSystemMonitor); +} + void LockWidget::initUsdMediaKeys() { m_areaScreenShot = m_modelLockDialog->getUsdAreaScreenShotKey(); @@ -543,10 +601,10 @@ void LockWidget::updateBottomButton() { QList statusButton = this->findChildren(); for (auto button : statusButton) { - if (button->getButtonTyoe() == POWERBUTTON) { + if (button->getButtonType() == POWERBUTTON) { button->setFixedSize(130, 130); button->setIconSize(QSize(130, 130)); - } else { + } else if (button->getButtonType() != NORMALBTN) { button->setFixedSize(48, 48); button->setIconSize(QSize(24, 24)); } @@ -628,6 +686,13 @@ void LockWidget::onPowerItemClicked(QListWidgetItem *item) currentItem->setSelected(CLICKED); currentItem->clicked(); } + if (m_isSessionTools && m_blockWidget->isHidden()) { + exitSubWidget(); + Q_EMIT sessionToolsExit(); + m_isSessionTools = false; + }/* else if (m_blockWidget->isHidden()) { + exitSubWidget(); + }*/ } void LockWidget::onUsersInfoChanged() @@ -757,12 +822,18 @@ void LockWidget::onShowSessionListWidget() m_sessionListWidget->show(); m_sessionListWidget->setFocus(); m_sessionButton->setClickedStatus(CLICKED); - if (m_networkWidget && m_networkWidget->isVisible()) + if (m_networkWidget && m_networkWidget->isVisible()) { m_networkWidget->hide(); - if (batteryWidget && batteryWidget->isVisible()) + m_networkButton->setClickedStatus(NORMAL); + } + if (batteryWidget && batteryWidget->isVisible()) { batteryWidget->hide(); - if (m_userListWidget && m_userListWidget->isVisible()) + m_batteryonButton->setClickedStatus(NORMAL); + } + if (m_userListWidget && m_userListWidget->isVisible()) { m_userListWidget->hide(); + m_userButton->setClickedStatus(NORMAL); + } } else { m_sessionListWidget->hide(); m_sessionButton->setClickedStatus(NORMAL); @@ -784,12 +855,18 @@ void LockWidget::onShowBatteryWidget() if (batteryWidget && batteryWidget->isHidden()) { batteryWidget->show(); m_batteryonButton->setClickedStatus(CLICKED); - if (m_networkWidget && m_networkWidget->isVisible()) + if (m_networkWidget && m_networkWidget->isVisible()) { m_networkWidget->hide(); - if (m_userListWidget && m_userListWidget->isVisible()) + m_networkButton->setClickedStatus(NORMAL); + } + if (m_userListWidget && m_userListWidget->isVisible()) { m_userListWidget->hide(); - if (m_sessionListWidget && m_sessionListWidget->isVisible()) + m_userButton->setClickedStatus(NORMAL); + } + if (m_sessionListWidget && m_sessionListWidget->isVisible()) { m_sessionListWidget->hide(); + m_sessionButton->setClickedStatus(NORMAL); + } } else { batteryWidget->hide(); m_batteryonButton->setClickedStatus(NORMAL); @@ -801,14 +878,20 @@ void LockWidget::onShowUserListWidget() initUserWidget(); if (m_userListWidget && m_userListWidget->isHidden()) { m_userListWidget->show(); - m_userListWidget->setFocus(); +// m_userListWidget->setFocus(); m_userButton->setClickedStatus(CLICKED); - if (m_networkWidget && m_networkWidget->isVisible()) + if (m_networkWidget && m_networkWidget->isVisible()) { m_networkWidget->hide(); - if (batteryWidget && batteryWidget->isVisible()) + m_networkButton->setClickedStatus(NORMAL); + } + if (batteryWidget && batteryWidget->isVisible()) { batteryWidget->hide(); - if (m_sessionListWidget && m_sessionListWidget->isVisible()) + m_batteryonButton->setClickedStatus(NORMAL); + } + if (m_sessionListWidget && m_sessionListWidget->isVisible()) { m_sessionListWidget->hide(); + m_sessionButton->setClickedStatus(NORMAL); + } } else { m_userListWidget->hide(); m_userButton->setClickedStatus(NORMAL); @@ -836,12 +919,18 @@ void LockWidget::onShowNetworkWidget() } else { m_networkWidget->show(); m_networkButton->setClickedStatus(CLICKED); - if (m_userListWidget && m_userListWidget->isVisible()) + if (m_userListWidget && m_userListWidget->isVisible()) { m_userListWidget->hide(); - if (batteryWidget && batteryWidget->isVisible()) + m_userButton->setClickedStatus(NORMAL); + } + if (batteryWidget && batteryWidget->isVisible()) { batteryWidget->hide(); - if (m_sessionListWidget && m_sessionListWidget->isVisible()) + m_batteryonButton->setClickedStatus(NORMAL); + } + if (m_sessionListWidget && m_sessionListWidget->isVisible()) { m_sessionListWidget->hide(); + m_sessionButton->setClickedStatus(NORMAL); + } } } @@ -857,12 +946,18 @@ void LockWidget::onLineEditClicked() m_virtualKeyboardWidget, &VirtualKeyboardWidget::aboutToFloat, this, &LockWidget::onNetWorkResetLocation); } if (m_isTabletMode) { - if (batteryWidget && batteryWidget->isVisible()) + if (batteryWidget && batteryWidget->isVisible()) { batteryWidget->hide(); - if (m_sessionListWidget && m_sessionListWidget->isVisible()) + m_batteryonButton->setClickedStatus(NORMAL); + } + if (m_sessionListWidget && m_sessionListWidget->isVisible()) { m_sessionListWidget->hide(); - if (m_userListWidget && m_userListWidget->isVisible()) + m_sessionButton->setClickedStatus(NORMAL); + } + if (m_userListWidget && m_userListWidget->isVisible()) { m_userListWidget->hide(); + m_userButton->setClickedStatus(NORMAL); + } m_virtualKeyboardWidget->show(); authDialog->setFocus(); } @@ -880,12 +975,18 @@ void LockWidget::onShowVirtualKeyboard() m_virtualKeyboardWidget, &VirtualKeyboardWidget::aboutToFloat, this, &LockWidget::onNetWorkResetLocation); } if (m_virtualKeyboardWidget->isHidden()) { - if (batteryWidget && batteryWidget->isVisible()) + if (batteryWidget && batteryWidget->isVisible()) { batteryWidget->hide(); - if (m_sessionListWidget && m_sessionListWidget->isVisible()) + m_batteryonButton->setClickedStatus(NORMAL); + } + if (m_sessionListWidget && m_sessionListWidget->isVisible()) { m_sessionListWidget->hide(); - if (m_userListWidget && m_userListWidget->isVisible()) + m_sessionButton->setClickedStatus(NORMAL); + } + if (m_userListWidget && m_userListWidget->isVisible()) { m_userListWidget->hide(); + m_userButton->setClickedStatus(NORMAL); + } m_virtualKeyboardWidget->show(); authDialog->setFocus(); } else { @@ -917,12 +1018,18 @@ void LockWidget::onShowVirtualKeyboard(bool tabletMode) m_virtualKeyboardWidget, &VirtualKeyboardWidget::aboutToFloat, this, &LockWidget::onNetWorkResetLocation); } if (tabletMode) { - if (batteryWidget && batteryWidget->isVisible()) + if (batteryWidget && batteryWidget->isVisible()) { batteryWidget->hide(); - if (m_sessionListWidget && m_sessionListWidget->isVisible()) + m_batteryonButton->setClickedStatus(NORMAL); + } + if (m_sessionListWidget && m_sessionListWidget->isVisible()) { m_sessionListWidget->hide(); - if (m_userListWidget && m_userListWidget->isVisible()) + m_sessionButton->setClickedStatus(NORMAL); + } + if (m_userListWidget && m_userListWidget->isVisible()) { m_userListWidget->hide(); + m_userButton->setClickedStatus(NORMAL); + } m_virtualKeyboardWidget->show(); authDialog->setFocus(); } else { @@ -941,39 +1048,74 @@ void LockWidget::onShowVirtualKeyboard(bool tabletMode) m_virKbButton->setClickedStatus(NORMAL); } -void LockWidget::onShowPowerListWidget() +void LockWidget::onShowPowerListWidget(bool issessionTools) { + if (issessionTools) { + m_powerListWidget->setPowerType(SESSION); + m_isSessionTools = issessionTools; + } else { + m_powerListWidget->setPowerType(SAVER); + } if (m_powerListWidget->isHidden()) { m_powerListWidget->show(); authDialog->hide(); m_powerListWidget->clearFocus(); buttonListWidget->clearFocus(); + if (m_powerListWidget->getScrollShowStatus()) { //如果显示Scroll,直接从时间窗口底部开始显示 + m_powerListWidget->move((width() - m_powerListWidget->width())/2, + m_timeWidget->height() + 30); + } else { //居中显示 + m_powerListWidget->move((width() - m_powerListWidget->width())/2, + (height() - m_powerListWidget->height())/2); + } + if (m_isSessionTools) { + m_systemMonitorBtn->show(); + buttonListWidget->hide(); + } } else { m_powerListWidget->hide(); authDialog->show(); authDialog->setFocus(); + m_systemMonitorBtn->hide(); + buttonListWidget->show(); } - if (m_isInhibitStatus) { - authDialog->hide(); - m_powerListWidget->hide(); - buttonListWidget->hide(); - m_timeWidget->hide(); - } +// if (m_isInhibitStatus) { +// authDialog->hide(); +// m_powerListWidget->hide(); +// buttonListWidget->hide(); +// m_timeWidget->hide(); +// } - if (m_userListWidget && m_userListWidget->isVisible()) + if (m_userListWidget && m_userListWidget->isVisible()) { m_userListWidget->hide(); - if (m_virtualKeyboardWidget && m_virtualKeyboardWidget->isVisible()) + m_userButton->setClickedStatus(NORMAL); + } + if (m_virtualKeyboardWidget && m_virtualKeyboardWidget->isVisible()) { m_virtualKeyboardWidget->hide(); - if (batteryWidget && batteryWidget->isVisible()) + m_virKbButton->setClickedStatus(NORMAL); + } + if (batteryWidget && batteryWidget->isVisible()) { batteryWidget->hide(); - if (m_networkWidget && m_networkWidget->isVisible()) + m_batteryonButton->setClickedStatus(NORMAL); + } + if (m_networkWidget && m_networkWidget->isVisible()) { m_networkWidget->hide(); - if (m_sessionListWidget && m_sessionListWidget->isVisible()) + m_networkButton->setClickedStatus(NORMAL); + } + if (m_sessionListWidget && m_sessionListWidget->isVisible()) { m_sessionListWidget->hide(); + m_sessionButton->setClickedStatus(NORMAL); + } m_powerManagerButton->setClickedStatus(NORMAL); } +void LockWidget::doSystemMonitor() +{ + qDebug() << "doSystemMonitor...."; + QProcess::startDetached("ukui-system-monitor", QStringList()); +} + void LockWidget::onSetVirkeyboardPos() { if (m_virtualKeyboardWidget) { @@ -1011,22 +1153,50 @@ void LockWidget::onHideVirkeyboard() } } -void LockWidget::onShowInhibitWarning(QStringList list, int type) +void LockWidget::onShowInhibitWarning(QStringList list, int type, bool iscommand) { + authDialog->hide(); + buttonListWidget->hide(); + m_timeWidget->hide(); + if (m_userListWidget && m_userListWidget->isVisible()) { + m_userListWidget->hide(); + m_userButton->setClickedStatus(NORMAL); + } + m_powerListWidget->hide(); m_blockWidget->setGeometry(this->geometry()); m_blockWidget->setWarning(list, type); m_blockWidget->show(); m_isInhibitStatus = true; + if (!m_isSessionTools) + m_isSessionTools = iscommand; + if (m_isSessionTools) + m_systemMonitorBtn->show(); } -void LockWidget::onMulUsersLogined(QString inhibitType) +void LockWidget::onMulUsersLogined(int inhibitType, bool iscommand) { - m_inhibitType = inhibitType; + authDialog->hide(); + buttonListWidget->hide(); + m_timeWidget->hide(); + m_powerListWidget->hide(); + if (m_userListWidget && m_userListWidget->isVisible()) { + m_userListWidget->hide(); + m_userButton->setClickedStatus(NORMAL); + } m_blockWidget->setGeometry(this->geometry()); - m_blockWidget->setTips( - tr("Multiple users are logged in at the same time.Are you sure you want to %1 this system?").arg(inhibitType)); + if (inhibitType == 0) { + m_inhibitType = "Reboot"; + m_blockWidget->setTips(tr("Multiple users are logged in at the same time.Are you sure you want to %1 this system?").arg(tr("Reboot"))); + } else if (inhibitType == 1) { + m_inhibitType = "PowerOff"; + m_blockWidget->setTips(tr("Multiple users are logged in at the same time.Are you sure you want to %1 this system?").arg(tr("Shut Down"))); + } m_blockWidget->show(); m_isInhibitStatus = true; + if (!m_isSessionTools) + m_isSessionTools = iscommand; + if (m_isSessionTools) + m_systemMonitorBtn->show(); } void LockWidget::onConfirmBtnClicked() @@ -1034,9 +1204,15 @@ void LockWidget::onConfirmBtnClicked() m_blockWidget->hide(); m_powerListWidget->hide(); authDialog->show(); + m_timeWidget->show(); buttonListWidget->show(); m_isInhibitStatus = false; Q_EMIT m_modelLockDialog->setPowerManager(m_inhibitType); + if (m_isSessionTools) { +// m_isSessionTools = false; + exitSubWidget(); + Q_EMIT sessionToolsExit(); + } } void LockWidget::onCancelBtnClicked() @@ -1046,6 +1222,34 @@ void LockWidget::onCancelBtnClicked() m_powerListWidget->show(); buttonListWidget->show(); m_timeWidget->show(); + if (m_isSessionTools) { +// m_isSessionTools = false; + exitSubWidget(); + Q_EMIT sessionToolsExit(); + } +} + +void LockWidget::onLockScreenClicked() +{ + m_isSessionTools = false; + exitSubWidget(); +} + +void LockWidget::onSuspendClicked() +{ + if (m_modelLockDialog->getSleepActivationEnabled()) { + m_isSessionTools = false; + Q_EMIT showBlankScreensaver(0, true); + } else { + exitSubWidget(); + } +} + +void LockWidget::onSwitchuserClicked() +{ + onLockScreenClicked(); + qDebug() << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ; + onShowUserListWidget(); } void LockWidget::onCustomRequestAccount(QString account) @@ -1261,6 +1465,14 @@ void LockWidget::updateFont() if (m_blockWidget) { m_blockWidget->updateFontFamily(m_curFont); } + if (m_systemMonitorBtn) { + QFont sysBtnFont; + sysBtnFont.setFamily(m_curFont); + sysBtnFont.setPointSize((16 + m_curFontSize) * m_ptToPx); + m_systemMonitorBtn->setFont(sysBtnFont); + m_systemMonitorBtn->setText(tr("system-monitor")); + m_systemMonitorBtn->adjustSize(); + } } void LockWidget::updateFontSize() diff --git a/src/widgets/lockwidget.h b/src/widgets/lockwidget.h index 500e156..e41e3bd 100644 --- a/src/widgets/lockwidget.h +++ b/src/widgets/lockwidget.h @@ -49,13 +49,24 @@ class LockWidget : public QWidget Q_OBJECT public: explicit LockWidget(LockDialogModel *model, QWidget *parent = nullptr); - bool exitSubWidget(); + bool exitSubWidget(bool isForScreensaver = false); void stopAuth(); void startAuth(); void reloadRootBackground(); void drawRootBackground(); void updateFont(); void updateFontSize(); + void onShowPowerListWidget(bool issessionTools = false); + + void onShowInhibitWarning(QStringList list, int type, bool iscommand = false); + + void onMulUsersLogined(int inhibitType, bool iscommand = false); + + void onLockScreenClicked(); + + void onSuspendClicked(); + + void onSwitchuserClicked(); protected: void paintEvent(QPaintEvent *event); @@ -74,6 +85,7 @@ private: void initButtonWidget(); void initTimeWidget(); void initBlockWidget(); + void initSystemMonitorBtn(); void sendNetPluginVisible(bool visible); /** @@ -120,19 +132,15 @@ private Q_SLOTS: void onShowBatteryWidget(); void onShowUserListWidget(); void onShowNetworkWidget(); - void onShowPowerListWidget(); void onShowVirtualKeyboard(); void onShowVirtualKeyboard(bool tabletMode); void onLineEditClicked(); + void doSystemMonitor(); void onNetWorkResetLocation(); void onSetVirkeyboardPos(); void onHideVirkeyboard(); - void onShowInhibitWarning(QStringList list, int type); - - void onMulUsersLogined(QString inhibitType); - void onConfirmBtnClicked(); void onCancelBtnClicked(); /** @@ -159,6 +167,10 @@ private Q_SLOTS: Q_SIGNALS: void authSucceed(QString strUserName); + void sessionToolsExit(); + + void showBlankScreensaver(int nDelay, bool isHasLock); + private: void setrootWindowBackground(int type,unsigned int color,QString filename); @@ -215,6 +227,9 @@ private: StatusButton *m_virKbButton = nullptr; StatusButton *m_powerManagerButton = nullptr; + // 底部系统监视器按钮 + StatusButton *m_systemMonitorBtn = nullptr; + bool m_isCustomDefault = false; /** 是否默认使用第三方认证 */ bool m_isShowNetwork = true; /** 是否显示网络插件 */ bool m_isShowUserSwitch = true; /** 是否显示用户切换 */ @@ -231,6 +246,11 @@ private: QString m_curFont; double m_curFontSize; double m_ptToPx = 1.0; + + int m_powerBtnNum = 0; + + bool m_isSessionTools = false; + bool m_iscommand = false; }; #endif // LOCKWIDGET_H diff --git a/src/widgets/poweritemwidget.cpp b/src/widgets/poweritemwidget.cpp index 075f0c2..0abe0d2 100644 --- a/src/widgets/poweritemwidget.cpp +++ b/src/widgets/poweritemwidget.cpp @@ -28,6 +28,7 @@ PowerItemWidget::PowerItemWidget(QWidget *parent) : QFrame(parent) textLabel = new KLabel(this); textLabel->setAlignment(Qt::AlignCenter); textLabel->setStyleSheet("color: white"); + textLabel->setMaximumWidth(130); QVBoxLayout *itemlayout = new QVBoxLayout(this); itemlayout->addWidget(itemFace); itemlayout->addWidget(textLabel); diff --git a/src/widgets/powerlistwidget.cpp b/src/widgets/powerlistwidget.cpp index ccec649..fe93d40 100644 --- a/src/widgets/powerlistwidget.cpp +++ b/src/widgets/powerlistwidget.cpp @@ -16,12 +16,14 @@ * **/ #include +#include +#include #include "powerlistwidget.h" PowerListWidget::PowerListWidget(LockDialogModel *model, QWidget *parent) : m_modelLockDialog(model), MyListWidget(parent) { - initBtnShowFlag(); +// updateBtnShowFlag(); initUI(); initConnections(); } @@ -48,40 +50,100 @@ bool PowerListWidget::eventFilter(QObject *obj, QEvent *event) return MyListWidget::eventFilter(obj, event); } +void PowerListWidget::setPowerType(int type) +{ + m_powerType = type; + qDebug() << "m_powerType = " << m_powerType; + updateBtnShowFlag(); + onUpdateListInfo(); + updateWidgetSize(); +} + void PowerListWidget::initUI() { setFlow(QListWidget::LeftToRight); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setProperty("isWrapping", QVariant(true)); + setResizeMode(QListView::Adjust); QString powerListStyle = "QListWidget{background:rgba(255, 255, 255, 0%); border: 0px;}" "QListWidget::item{background:rgba(255, 255, 255, 0%);}"; setStyleSheet(powerListStyle); - setFixedSize(QSize(BTN_ITEM_SIZE_WIDTH * sizeof(powerBtnList) / sizeof(powerBtnList[0]) + 1, BTN_ITEM_SIZE_HEIGHT)); + this->verticalScrollBar()->setStyleSheet("QScrollBar{ background: transparent; margin-top:3px;margin-bottom:3px ; }"\ + "QScrollBar:vertical{width: 6px;background: transparent;border-radius:3px;}"\ + "QScrollBar::handle:vertical{width: 6px; background: rgba(255,255,255, 40); border-radius:3px;}"\ + "QScrollBar::handle:vertical:hover{width: 6px; background: rgba(255,255,255, 60); border-radius:3px;}"\ + "QScrollBar::add-line:vertical{width:0px;height:0px}"\ + "QScrollBar::sub-line:vertical{width:0px;height:0px}"); // powerBtnList[0].func = &PowerListWidget::setSystemSuspend1(); m_curFontSize = m_modelLockDialog->getCurFontSize(); m_ptToPx = m_modelLockDialog->getPtToPx(); - onUpdateListInfo(); } void PowerListWidget::initConnections() { connect(this, &PowerListWidget::itemClicked, this, &PowerListWidget::onListItemClicked); } -void PowerListWidget::initBtnShowFlag() +void PowerListWidget::updateBtnShowFlag() { + m_powerBtnNum = 0; for (int i = 0; i < sizeof(powerBtnList) / sizeof(powerBtnList[0]); i++) { - if (powerBtnList[i].canFuncName == QString("CanPowerOff")) + if (powerBtnList[i].canFuncName == QString("CanSwitchUser")) { + powerBtnList[i].m_show_flag = (m_powerType == SESSION && m_modelLockDialog->usersInfo().count() > 1); + if (powerBtnList[i].m_show_flag) + m_powerBtnNum += 1; + } + + if (powerBtnList[i].canFuncName == QString("CanLockScreen")) { + powerBtnList[i].m_show_flag = (m_powerType == SESSION && m_modelLockDialog->getCanLockScreen()); + if (powerBtnList[i].m_show_flag) + m_powerBtnNum += 1; + } + + if (powerBtnList[i].canFuncName == QString("CanLogout")) { + powerBtnList[i].m_show_flag = (m_powerType == SESSION && m_modelLockDialog->getCanLogout()); + if (powerBtnList[i].m_show_flag) + m_powerBtnNum += 1; + } + + if (powerBtnList[i].canFuncName == QString("CanPowerOff")) { powerBtnList[i].m_show_flag = m_modelLockDialog->getCanPowerOff(); + if (powerBtnList[i].m_show_flag) + m_powerBtnNum += 1; + } - if (powerBtnList[i].canFuncName == QString("CanSuspend")) + if (powerBtnList[i].canFuncName == QString("CanSuspend")) { powerBtnList[i].m_show_flag = m_modelLockDialog->getCanSuspend(); + if (powerBtnList[i].m_show_flag) + m_powerBtnNum += 1; + } - if (powerBtnList[i].canFuncName == QString("CanReboot")) + if (powerBtnList[i].canFuncName == QString("CheckSystemUpgradeReboot")) { + powerBtnList[i].m_show_flag = (m_powerType == SESSION && m_modelLockDialog->checkSystemUpgrade()); + if (powerBtnList[i].m_show_flag) + m_powerBtnNum += 1; + } + + if (powerBtnList[i].canFuncName == QString("CheckSystemUpgradeShutdown")) { + powerBtnList[i].m_show_flag = (m_powerType == SESSION && m_modelLockDialog->checkSystemUpgrade()); + if (powerBtnList[i].m_show_flag) + m_powerBtnNum += 1; + } + + if (powerBtnList[i].canFuncName == QString("CanReboot")) { powerBtnList[i].m_show_flag = m_modelLockDialog->getCanReboot(); + if (powerBtnList[i].m_show_flag) + m_powerBtnNum += 1; + } - if (powerBtnList[i].canFuncName == QString("CanHibernate")) + if (powerBtnList[i].canFuncName == QString("CanHibernate")) { powerBtnList[i].m_show_flag = m_modelLockDialog->getCanHibernate(); + if (powerBtnList[i].m_show_flag) + m_powerBtnNum += 1; + } } + qInfo() << "m_powerBtnNum = " << m_powerBtnNum; } void PowerListWidget::onUpdateListInfo() @@ -118,22 +180,33 @@ void PowerListWidget::onListItemClicked(QListWidgetItem *item) if (powerBtnList[i].setFuncName == "Hibernate" || powerBtnList[i].setFuncName == "Suspend") { QStringList sleepLockcheck = m_modelLockDialog->getSleepLockcheck(); if (!sleepLockcheck.isEmpty()) { - Q_EMIT showInhibitWarning(sleepLockcheck, powerBtnList[i].m_inhibitType); + Q_EMIT showInhibitWarning(sleepLockcheck, powerBtnList[i].m_inhibitType, false); break; } } - if (powerBtnList[i].setFuncName == "Reboot" || powerBtnList[i].setFuncName == "PowerOff") { + if (powerBtnList[i].setFuncName == "Reboot" || powerBtnList[i].setFuncName == "PowerOff" || powerBtnList[i].setFuncName == "Logout") { QStringList shutdownLockcheck = m_modelLockDialog->getShutdownLockcheck(); if (shutdownLockcheck.count() > 0) { - Q_EMIT showInhibitWarning(shutdownLockcheck, powerBtnList[i].m_inhibitType); + Q_EMIT showInhibitWarning(shutdownLockcheck, powerBtnList[i].m_inhibitType, false); break; } else if (m_modelLockDialog->getLoggedInUsersCount() > 1) { - Q_EMIT mulUsersLogined(powerBtnList[i].setFuncName); + Q_EMIT mulUsersLogined(powerBtnList[i].m_inhibitType, false); break; } } qWarning() << __LINE__ << "=================" << powerBtnList[i].setFuncName << __FUNCTION__; - Q_EMIT m_modelLockDialog->setPowerManager(powerBtnList[i].setFuncName); + if (powerBtnList[i].setFuncName == "LockScreen") { + Q_EMIT lockScreenClicked(); + } else if (powerBtnList[i].setFuncName == "Suspend") { + Q_EMIT m_modelLockDialog->setPowerManager(powerBtnList[i].setFuncName); + Q_EMIT suspendClicked(); + } else if (powerBtnList[i].setFuncName == "SwitchUser") { +// Q_EMIT lockScreenClicked(); +// Q_EMIT m_modelLockDialog->setPowerManager(powerBtnList[i].setFuncName); + Q_EMIT switchuserClicked(); + } else { + Q_EMIT m_modelLockDialog->setPowerManager(powerBtnList[i].setFuncName); + } break; } } @@ -141,12 +214,35 @@ void PowerListWidget::onListItemClicked(QListWidgetItem *item) void PowerListWidget::updateWidgetSize() { - if (count() * 40 + 10 > maximumHeight()) { - setFixedHeight(maximumHeight()); - } else { - setFixedHeight(count() * 40 + 10); + QScreen *screen = QApplication::primaryScreen(); + QRect rect = screen->geometry(); + if (BTN_ITEM_SIZE_WIDTH * m_powerBtnNum < rect.width()) { + if (BTN_ITEM_SIZE_HEIGHT < this->maxHeight()) { + setFixedSize(QSize((BTN_ITEM_SIZE_WIDTH + 3) * m_powerBtnNum, BTN_ITEM_SIZE_HEIGHT)); + m_scrollIsShow = false; + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + } else { + setFixedSize(QSize((BTN_ITEM_SIZE_WIDTH + 3) * m_powerBtnNum, this->maxHeight())); + m_scrollIsShow = true; + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + } + } else { //宽度超过屏幕宽度,需要换行显示,取item宽度的倍数设为总宽度,防止显示不居中 + int pHeight = BTN_ITEM_SIZE_HEIGHT * (BTN_ITEM_SIZE_WIDTH * m_powerBtnNum / rect.width() + 1); + if (pHeight < this->maxHeight()) { + setFixedSize(QSize(rect.width() / BTN_ITEM_SIZE_WIDTH * (BTN_ITEM_SIZE_WIDTH + 3), + BTN_ITEM_SIZE_HEIGHT * (BTN_ITEM_SIZE_WIDTH * m_powerBtnNum / rect.width() + 1))); + m_scrollIsShow = false; + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + } else if ((rect.width() / BTN_ITEM_SIZE_WIDTH * BTN_ITEM_SIZE_WIDTH + 10) > rect.width()) { //需要显示滚动条 + setFixedSize(QSize((rect.width() / BTN_ITEM_SIZE_WIDTH - 1) * BTN_ITEM_SIZE_WIDTH + 10, this->maxHeight())); + m_scrollIsShow = true; + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + } else { + setFixedSize(QSize(rect.width() / BTN_ITEM_SIZE_WIDTH * BTN_ITEM_SIZE_WIDTH + 10, this->maxHeight())); + m_scrollIsShow = true; + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + } } - adjustSize(); } void PowerListWidget::setSystemPowerStatus(QString statusName) @@ -178,6 +274,19 @@ void PowerListWidget::refreshTranslate() } else if (powerBtnList[i].setFuncName == "PowerOff") { powerBtnList[i].m_strName = tr("Shut Down"); powerBtnList[i].m_strToolTip = tr("Close all apps, and then shut down your computer"); + } else if (powerBtnList[i].setFuncName == "Log Out") { + powerBtnList[i].m_strName = tr("Log Out"); + powerBtnList[i].m_strToolTip = tr("The current user logs out of the system, terminates the session, and returns to the login page"); + } else if (powerBtnList[i].setFuncName == "SwitchUser") { + powerBtnList[i].m_strName = tr("SwitchUser"); + } else if (powerBtnList[i].setFuncName == "LockScreen") { + powerBtnList[i].m_strName = tr("LockScreen"); + } else if (powerBtnList[i].setFuncName == "UpgradeThenRestart") { + powerBtnList[i].m_strName = tr("UpgradeThenRestart"); + } else if (powerBtnList[i].setFuncName == "UpgradeThenShutdown") { + powerBtnList[i].m_strName = tr("UpgradeThenShutdown"); + } else if (powerBtnList[i].setFuncName == "PowerOff") { + powerBtnList[i].m_strName = tr("Logout"); } } onUpdateListInfo(); diff --git a/src/widgets/powerlistwidget.h b/src/widgets/powerlistwidget.h index e4ed43e..df2ea8f 100644 --- a/src/widgets/powerlistwidget.h +++ b/src/widgets/powerlistwidget.h @@ -41,12 +41,23 @@ class LockDialogModel; #define BTN_ICON_SIZE_WIDTH 48 #define BTN_ICON_SIZE_HEIGHT 48 +enum powerType +{ + SAVER, + SESSION +}; + enum stateType { REBOOT, SHUTDOWN, SLEEP, HIBERNATE, + LOGOUT, + SWITCHUSER, + LOCKSCREEN, + UPGRADETHENREBOOT, + UPGRADETHENSHUTDOWN, NOTHING }; @@ -60,6 +71,8 @@ public: void updateWidgetSize(); void setSystemSuspend1(); + void setPowerType(int type); + inline bool getScrollShowStatus() { return m_scrollIsShow; } struct Btn_Data_Struct { @@ -76,8 +89,20 @@ public: QString setFuncName; int m_inhibitType; // void (*func)(); - } powerBtnList[4] - = { // 1.Hibernate + } powerBtnList[9] + = { // 1.switchuser + { .m_strName = tr("SwitchUser"), + .m_strToolTip = tr(""), + .m_strIcon = ":/image/assets/switchuser.svg", + .m_show_flag = true, + .m_item_width = BTN_ITEM_SIZE_WIDTH, + .m_item_height = BTN_ITEM_SIZE_HEIGHT, + .m_icon_width = BTN_ICON_SIZE_WIDTH, + .m_icon_height = BTN_ICON_SIZE_HEIGHT, + .canFuncName = "CanSwitchUser", + .setFuncName = "SwitchUser", + .m_inhibitType = SWITCHUSER }, + // 2.Hibernate { .m_strName = tr("Hibernate"), .m_strToolTip = tr("Turn off your computer, but the app stays open. When the computer is turned on, it " "can be restored to the state you left"), @@ -90,7 +115,7 @@ public: .canFuncName = "CanHibernate", .setFuncName = "Hibernate", .m_inhibitType = HIBERNATE }, - // 2.Suspend + // 3.Suspend { .m_strName = tr("Suspend"), .m_strToolTip = tr("The computer stays on, but consumes less power. The app stays open and can quickly " "wake up and revert to where you left off"), @@ -103,7 +128,43 @@ public: .canFuncName = "CanSuspend", .setFuncName = "Suspend", .m_inhibitType = SLEEP }, - // 3.reboot + // 4.LockScreen + { .m_strName = tr("LockScreen"), + .m_strToolTip = tr(""), + .m_strIcon = ":/image/assets/lockscreen.svg", + .m_show_flag = true, + .m_item_width = BTN_ITEM_SIZE_WIDTH, + .m_item_height = BTN_ITEM_SIZE_HEIGHT, + .m_icon_width = BTN_ICON_SIZE_WIDTH, + .m_icon_height = BTN_ICON_SIZE_HEIGHT, + .canFuncName = "CanLockScreen", + .setFuncName = "LockScreen", + .m_inhibitType = LOCKSCREEN }, + // 5.Logout + { .m_strName = tr("Log Out"), + .m_strToolTip = tr("The current user logs out of the system, terminates the session, and returns to the login page"), + .m_strIcon = ":/image/assets/logout.svg", + .m_show_flag = true, + .m_item_width = BTN_ITEM_SIZE_WIDTH, + .m_item_height = BTN_ITEM_SIZE_HEIGHT, + .m_icon_width = BTN_ICON_SIZE_WIDTH, + .m_icon_height = BTN_ICON_SIZE_HEIGHT, + .canFuncName = "CanLogout", + .setFuncName = "Logout", + .m_inhibitType = LOGOUT }, + // 6.upgradethenreboot + { .m_strName = tr("UpgradeThenRestart"), + .m_strToolTip = tr(""), + .m_strIcon = ":/image/assets/reboot.svg", + .m_show_flag = true, + .m_item_width = BTN_ITEM_SIZE_WIDTH, + .m_item_height = BTN_ITEM_SIZE_HEIGHT, + .m_icon_width = BTN_ICON_SIZE_WIDTH, + .m_icon_height = BTN_ICON_SIZE_HEIGHT, + .canFuncName = "CheckSystemUpgradeReboot", + .setFuncName = "UpgradeThenRestart", + .m_inhibitType = UPGRADETHENREBOOT }, + // 7.reboot { .m_strName = tr("Restart"), .m_strToolTip = tr("Close all apps, turn off your computer, and then turn your computer back on"), .m_strIcon = ":/image/assets/reboot.svg", @@ -115,7 +176,19 @@ public: .canFuncName = "CanReboot", .setFuncName = "Reboot", .m_inhibitType = REBOOT }, - // 4.Shut Down + // 8.upgradethenshutdown + { .m_strName = tr("UpgradeThenShutdown"), + .m_strToolTip = tr(""), + .m_strIcon = ":/image/assets/shutdown.svg", + .m_show_flag = true, + .m_item_width = BTN_ITEM_SIZE_WIDTH, + .m_item_height = BTN_ITEM_SIZE_HEIGHT, + .m_icon_width = BTN_ICON_SIZE_WIDTH, + .m_icon_height = BTN_ICON_SIZE_HEIGHT, + .canFuncName = "CheckSystemUpgradeShutdown", + .setFuncName = "UpgradeThenShutdown", + .m_inhibitType = UPGRADETHENREBOOT }, + // 9.Shut Down { .m_strName = tr("Shut Down"), .m_strToolTip = tr("Close all apps, and then shut down your computer"), .m_strIcon = ":/image/assets/shutdown.svg", @@ -136,8 +209,11 @@ protected: void changeEvent(QEvent *event); Q_SIGNALS: - void mulUsersLogined(QString inhibitType); - void showInhibitWarning(QStringList list, int type); + void mulUsersLogined(int inhibitType, bool iscommand); + void showInhibitWarning(QStringList list, int type, bool iscommand); + void lockScreenClicked(); + void suspendClicked(); + void switchuserClicked(); public Q_SLOTS: void onUpdateListInfo(); @@ -152,11 +228,20 @@ private: bool m_canReboot; bool m_canShutDown; + bool m_canLockScreen = true; + bool m_canSwitchUser = true; + bool m_canLogout = true; + double m_curFontSize; double m_ptToPx = 1.0; + int m_powerType = SAVER; + int m_powerBtnNum = 0; + + bool m_scrollIsShow = false; + void initUI(); - void initBtnShowFlag(); + void updateBtnShowFlag(); void initConnections(); void refreshTranslate(); // void initDBusInterface(); diff --git a/src/widgets/statusbutton.cpp b/src/widgets/statusbutton.cpp index 3573f38..3a8934d 100644 --- a/src/widgets/statusbutton.cpp +++ b/src/widgets/statusbutton.cpp @@ -18,7 +18,7 @@ #include "statusbutton.h" #include #include -#include +#include StatusButton::StatusButton(QWidget *parent, int type) : QPushButton(parent) { @@ -29,8 +29,12 @@ StatusButton::StatusButton(QWidget *parent, int type) : QPushButton(parent) } else if (buttonType == POWERBUTTON) { setFixedSize(130, 130); setIconSize(QSize(48, 48)); + } else if (buttonType == NORMALBTN) { + setFixedHeight(48); + setFocusPolicy(Qt::TabFocus); } - this->setFocusPolicy(Qt::NoFocus); + if (buttonType != NORMALBTN) + this->setFocusPolicy(Qt::NoFocus); } void StatusButton::setClickedStatus(int status) @@ -57,22 +61,26 @@ void StatusButton::paintEvent(QPaintEvent *e) painter.setPen(Qt::NoPen); painter.setBrush(Qt::white); switch (buttonType) { - case BOTBUTTON: - painter.setOpacity(0); - painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); - break; - case BIOBUTTON: - painter.setOpacity(0.1); - painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); - break; - case POWERBUTTON: - painter.setOpacity(0.1); - painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65); - break; - default: - painter.setOpacity(0); - painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); - break; + case BOTBUTTON: + painter.setOpacity(0); + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + break; + case BIOBUTTON: + painter.setOpacity(0.1); + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + break; + case POWERBUTTON: + painter.setOpacity(0.1); + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65); + break; + case NORMALBTN: + painter.setOpacity(0); + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 24, 24); + break; + default: + painter.setOpacity(0); + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + break; } painter.restore(); } @@ -81,18 +89,22 @@ void StatusButton::paintEvent(QPaintEvent *e) painter.save(); painter.setPen(Qt::NoPen); painter.setBrush(Qt::white); - painter.setOpacity(0.25); + painter.setOpacity(0.15); switch (buttonType) { - case BOTBUTTON: - case BIOBUTTON: - painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); - break; - case POWERBUTTON: - painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65); - break; - default: - painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); - break; + case BOTBUTTON: + case BIOBUTTON: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + break; + case POWERBUTTON: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65); + break; + case NORMALBTN: + painter.setOpacity(0.15); + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 24, 24); + break; + default: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + break; } painter.restore(); } @@ -101,18 +113,21 @@ void StatusButton::paintEvent(QPaintEvent *e) painter.save(); painter.setPen(Qt::NoPen); painter.setBrush(Qt::white); - painter.setOpacity(0.35); + painter.setOpacity(0.21); switch (buttonType) { - case BOTBUTTON: - case BIOBUTTON: - painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); - break; - case POWERBUTTON: - painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65); - break; - default: - painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); - break; + case BOTBUTTON: + case BIOBUTTON: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + break; + case POWERBUTTON: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65); + break; + case NORMALBTN: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 24, 24); + break; + default: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + break; } painter.restore(); } @@ -123,16 +138,19 @@ void StatusButton::paintEvent(QPaintEvent *e) painter.setBrush(Qt::white); painter.setOpacity(0.25); switch (buttonType) { - case BOTBUTTON: - case BIOBUTTON: - painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); - break; - case POWERBUTTON: - painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65); - break; - default: - painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); - break; + case BOTBUTTON: + case BIOBUTTON: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + break; + case POWERBUTTON: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65); + break; + case NORMALBTN: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 24, 24); + break; + default: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + break; } painter.restore(); painter.save(); @@ -141,20 +159,30 @@ void StatusButton::paintEvent(QPaintEvent *e) painter.setPen(QPen(color, 2)); painter.setBrush(Qt::NoBrush); switch (buttonType) { - case BOTBUTTON: - case BIOBUTTON: - painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); - break; - case POWERBUTTON: - painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65); - break; - default: - painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); - break; + case BOTBUTTON: + case BIOBUTTON: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + break; + case POWERBUTTON: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 65, 65); + break; + case NORMALBTN: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 24, 24); + break; + default: + painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), 6, 6); + break; } painter.restore(); } + // 绘制文字 + if (buttonType == NORMALBTN && !text().isEmpty() && text() != "") { + painter.setPen(QColor(255,255,255,255)); + painter.setFont(font()); + painter.drawText(this->rect(), Qt::AlignHCenter | Qt::AlignVCenter, this->text()); + } + // 绘制图片 int buttonWidget = this->width(); int buttonHeight = this->height(); @@ -185,10 +213,14 @@ void StatusButton::paintEvent(QPaintEvent *e) void StatusButton::mouseReleaseEvent(QMouseEvent *e) { + if (buttonType == NORMALBTN) + Q_EMIT clicked(); e->ignore(); } void StatusButton::mousePressEvent(QMouseEvent *e) { + if (buttonType == NORMALBTN) + Q_EMIT clicked(); e->ignore(); } diff --git a/src/widgets/statusbutton.h b/src/widgets/statusbutton.h index e867032..42ea1fc 100644 --- a/src/widgets/statusbutton.h +++ b/src/widgets/statusbutton.h @@ -36,6 +36,7 @@ enum BUTTONTYPE { BOTBUTTON, BIOBUTTON, POWERBUTTON, + NORMALBTN, }; class StatusButton : public QPushButton @@ -53,7 +54,7 @@ public: void setDrivedId(int drivedId); inline int getDrivedId() { return m_drivedId; } - inline int getButtonTyoe() { return buttonType; } + inline int getButtonType() { return buttonType; } protected: void paintEvent(QPaintEvent *e) override; void mouseReleaseEvent(QMouseEvent *e);