diff --git a/CMakeLists.txt b/CMakeLists.txt index 6494ed7f..ea215b1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ -cmake_minimum_required(VERSION 3.13.4) +cmake_minimum_required(VERSION 3.16) project(dde-session-shell C CXX) -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) @@ -38,6 +38,9 @@ if (NOT (${CMAKE_BUILD_TYPE} MATCHES "Debug")) WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) endif () +set(QT_VERSION_MAJOR 6) +set(DTK_VERSION_MAJOR 6) + if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX /usr) endif () @@ -46,131 +49,62 @@ include(GNUInstallDirs) # Find the library find_package(PAM REQUIRED) find_package(PkgConfig REQUIRED) -find_package(DtkWidget REQUIRED) -find_package(DtkCMake REQUIRED) -find_package(DtkCore REQUIRED) -find_package(Qt5 COMPONENTS - Core - Widgets - Concurrent - X11Extras - DBus - Xml - Svg - Network -REQUIRED) -find_package(DtkTools REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Widgets Concurrent DBus Xml Svg Network) +find_package(Dtk${DTK_VERSION_MAJOR} REQUIRED COMPONENTS Widget Core Tools) pkg_check_modules(XCB_EWMH REQUIRED xcb-ewmh x11 xi xcursor xfixes xrandr xext xtst) -pkg_check_modules(QGSettings REQUIRED gsettings-qt) -pkg_check_modules(Greeter REQUIRED liblightdm-qt5-3) +pkg_check_modules(Greeter REQUIRED liblightdm-qt6-3) set(Qt_LIBS - Qt5::Core - Qt5::Gui - Qt5::DBus - Qt5::Widgets - Qt5::X11Extras - Qt5::Xml - Qt5::Svg + Qt${QT_VERSION_MAJOR}::Core + Qt${QT_VERSION_MAJOR}::Gui + Qt${QT_VERSION_MAJOR}::DBus + Qt${QT_VERSION_MAJOR}::Widgets + Qt${QT_VERSION_MAJOR}::Concurrent + Qt${QT_VERSION_MAJOR}::Xml + Qt${QT_VERSION_MAJOR}::Svg ) set(XML2CPP_DIR ${PROJECT_SOURCE_DIR}/src/global_util/dbus) -function(generation_dbus_interface xml class_name class_file) - execute_process(COMMAND ${DTK_XML2CPP} -c ${class_name} -p ${class_file} ${xml} - WORKING_DIRECTORY ${XML2CPP_DIR}) -endfunction(generation_dbus_interface) - -generation_dbus_interface( - ${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.Authenticate1.xml - Authenticate - ${XML2CPP_DIR}/authenticate_interface -) - -generation_dbus_interface( - ${CMAKE_SOURCE_DIR}/xml/com.huawei.switchos.xml - HuaWeiSwitchOS - ${XML2CPP_DIR}/huaweiswitchos_interface -) - -generation_dbus_interface( - ${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.Accounts1.xml - Accounts - ${XML2CPP_DIR}/accounts_interface -) - -generation_dbus_interface( - ${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.Accounts1.User.xml - AccountsUser - ${XML2CPP_DIR}/accountsuser_interface -) - -generation_dbus_interface( - ${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.ImageEffect1.xml - ImageEffect - ${XML2CPP_DIR}/imageeffect_interface -) - -generation_dbus_interface( - ${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.Logined.xml - Logined - ${XML2CPP_DIR}/logined_interface -) - -generation_dbus_interface( - ${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.PowerManager1.xml - PowerManager - ${XML2CPP_DIR}/powermanager_interface -) - -generation_dbus_interface( - ${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.SystemPower1.xml - SystemPower - ${XML2CPP_DIR}/systempower_interface -) - -generation_dbus_interface( - ${CMAKE_SOURCE_DIR}/xml/com.deepin.wm.xml - wm - ${XML2CPP_DIR}/wm_interface -) - -generation_dbus_interface( - ${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.Authenticate1.Session2.xml - AuthenticateSession2 - ${XML2CPP_DIR}/authenticatesession2_interface -) - -generation_dbus_interface( - ${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.SessionManager1.xml - SessionManager - ${XML2CPP_DIR}/sessionmanager_interface +function(generation_dbus_interface xml class_file) + set(file_name ${XML2CPP_DIR}/${class_file}) + execute_process( + COMMAND ${DTK_XML2CPP} -p ${file_name} ${xml} + WORKING_DIRECTORY ${XML2CPP_DIR} + ) +endfunction() + +set(DBUS_INTERFACES + "${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.Authenticate1.xml authenticate1interface" + "${CMAKE_SOURCE_DIR}/xml/com.huawei.switchos.xml switchosinterface" + "${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.Accounts1.xml accounts1interface" + "${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.Accounts1.User.xml userinterface" + "${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.ImageEffect1.xml imageeffect1interface" + "${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.Logined.xml loginedinterface" + "${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.PowerManager1.xml powermanager1interface" + "${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.SystemPower1.xml systempower1interface" + "${CMAKE_SOURCE_DIR}/xml/com.deepin.wm.xml wminterface" + "${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.Authenticate1.Session2.xml session2interface" + "${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.SessionManager1.xml sessionmanager1interface" + "${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.SystemDisplay1.xml systemdisplay1interface" + "${CMAKE_SOURCE_DIR}/xml/org.freedesktop.DBus.xml dbusinterface" + "${CMAKE_SOURCE_DIR}/xml/org.freedesktop.login1.session.self.xml selfinterface" ) -generation_dbus_interface( - ${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.SoundThemePlayer1.xml - SoundThemePlayer - ${XML2CPP_DIR}/soundthemeplayer_interface -) +foreach(interface IN LISTS DBUS_INTERFACES) + string(REPLACE " " ";" interface_list "${interface}") -generation_dbus_interface( - ${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.SystemDisplay1.xml - SystemDisplay - ${XML2CPP_DIR}/systemdisplay_interface -) + list(GET interface_list 0 XML_FILE) + list(GET interface_list 1 CLASS_FILE) -generation_dbus_interface( - ${CMAKE_SOURCE_DIR}/xml/org.freedesktop.DBus.xml - FreedesktopDBus - ${XML2CPP_DIR}/freedesktopdbus_interface -) + list(LENGTH interface_list list_len) + if(list_len LESS 2) + message(FATAL_ERROR "Invalid DBus interface definition: ${interface}") + endif() -generation_dbus_interface( - ${CMAKE_SOURCE_DIR}/xml/org.freedesktop.login1.session.self.xml - Login1SessionSelf - ${XML2CPP_DIR}/login1sessionself_interface -) + generation_dbus_interface(${XML_FILE} ${CLASS_FILE}) +endforeach() include_directories(${PROJECT_SOURCE_DIR}/src/global_util) include_directories(${PROJECT_SOURCE_DIR}/src/global_util/dbus) @@ -198,7 +132,6 @@ set(QRCS ) set(LOCK_SRCS - ${transaction_DBUS_SCRS} ${GLOBAL_UTILS} ${GLOBAL_UTILS_DBUS} ${GLOBAL_UTILS_KEYBOARDMONITOR} @@ -222,29 +155,19 @@ add_executable(dde-lock ) target_include_directories(dde-lock PUBLIC ${PAM_INCLUDE_DIR} - ${DTKWIDGET_INCLUDE_DIR} - ${DTKCORE_INCLUDE_DIR} ${XCB_EWMH_INCLUDE_DIRS} - ${Qt5Gui_PRIVATE_INCLUDE_DIRS} ${PROJECT_BINARY_DIR} - ${QGSettings_INCLUDE_DIRS} - ${Qt5X11Extras_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/src/dde-lock ${PROJECT_SOURCE_DIR}/src/dde-lock/dbus ${Greeter_INCLUDE_DIRS} ) + target_link_libraries(dde-lock PRIVATE ${Qt_LIBS} ${PAM_LIBRARIES} ${XCB_EWMH_LIBRARIES} - ${DtkWidget_LIBRARIES} - ${DtkCore_LIBRARIES} - ${Qt5Widgets_LIBRARIES} - ${Qt5Concurrent_LIBRARIES} - ${Qt5X11Extras_LIBRARIES} - ${Qt5DBus_LIBRARIES} - ${Qt5Network_LIBRARIES} - ${QGSettings_LIBRARIES} + Dtk${DTK_VERSION_MAJOR}::Widget + Dtk${DTK_VERSION_MAJOR}::Core ${Greeter_LIBRARIES} ${DEEPIN_PW_CHECK} ) @@ -252,7 +175,6 @@ target_link_libraries(dde-lock PRIVATE set(DEEPIN_PW_CHECK libdeepin_pw_check.so) set(GREETER_SRCS - ${transaction_DBUS_SCRS} ${GLOBAL_UTILS} ${GLOBAL_UTILS_DBUS} ${GLOBAL_UTILS_KEYBOARDMONITOR} @@ -277,13 +199,8 @@ add_executable(lightdm-deepin-greeter target_include_directories(lightdm-deepin-greeter PUBLIC ${PAM_INCLUDE_DIR} - ${DTKWIDGET_INCLUDE_DIR} - ${DTKCORE_INCLUDE_DIR} ${XCB_EWMH_INCLUDE_DIRS} - ${Qt5Gui_PRIVATE_INCLUDE_DIRS} ${PROJECT_BINARY_DIR} - ${QGSettings_INCLUDE_DIRS} - ${Qt5X11Extras_INCLUDE_DIRS} ${Greeter_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/src/lightdm-deepin-greeter ) @@ -301,14 +218,8 @@ target_link_libraries(lightdm-deepin-greeter PRIVATE ${Qt_LIBS} ${PAM_LIBRARIES} ${XCB_EWMH_LIBRARIES} - ${DtkWidget_LIBRARIES} - ${DtkCore_LIBRARIES} - ${Qt5Widgets_LIBRARIES} - ${Qt5Concurrent_LIBRARIES} - ${Qt5X11Extras_LIBRARIES} - ${Qt5DBus_LIBRARIES} - ${Qt5Network_LIBRARIES} - ${QGSettings_LIBRARIES} + Dtk${DTK_VERSION_MAJOR}::Widget + Dtk${DTK_VERSION_MAJOR}::Core ${Greeter_LIBRARIES} ${DEEPIN_PW_CHECK} ) @@ -351,9 +262,6 @@ install(FILES files/lightdm-deepin-greeter.conf DESTINATION ${CMAKE_INSTALL_DATA file(GLOB SERVICES files/*.service) install(FILES ${SERVICES} DESTINATION ${CMAKE_INSTALL_DATADIR}/dbus-1/services) -#schemas -install(FILES xml/com.deepin.dde.session-shell.gschema.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/glib-2.0/schemas) - # dev file(GLOB INTERFACE interface/*.h) install(FILES ${INTERFACE} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dde-session-shell) @@ -374,5 +282,6 @@ file(GLOB PAM_CONFIG files/pam.d/*) install(FILES ${PAM_CONFIG} DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/pam.d/) # config -dconfig_meta_files(APPID org.deepin.dde.lock FILES configs/org.deepin.dde.lock.json) -dconfig_meta_files(APPID org.deepin.dde.lightdm-deepin-greeter FILES configs/org.deepin.dde.lightdm-deepin-greeter.json) +dtk_add_config_meta_files(APPID org.deepin.dde.lock FILES configs/org.deepin.dde.lock.json) +dtk_add_config_meta_files(APPID org.deepin.dde.lightdm-deepin-greeter FILES configs/org.deepin.dde.lightdm-deepin-greeter.json) +dtk_add_config_meta_files(APPID org.deepin.dde.session-shell FILES configs/org.deepin.dde.session-shell.json) diff --git a/configs/org.deepin.dde.session-shell.json b/configs/org.deepin.dde.session-shell.json new file mode 100644 index 00000000..fcd3ed6d --- /dev/null +++ b/configs/org.deepin.dde.session-shell.json @@ -0,0 +1,116 @@ +{ + "magic": "dsg.config.meta", + "version": "1.0", + "contents": { + "authResetTime": { + "value": 15000, + "serial": 0, + "flags": [], + "name": "max auth timeout", + "name[zh_CN]": "最大认证超时时间", + "description[zh_CN]": "最大认证超时时间, 默认为15秒认证超时。", + "description": "max auth timeout", + "permissions": "readwrite", + "visibility": "private" + }, + "delayTime": { + "value": 500, + "serial": 0, + "flags": [], + "name": "delayTime", + "name[zh_CN]": "待机休眠休眠延时时间", + "description[zh_CN]": "待机休眠休眠延时时间, 默认为500毫秒。", + "description": "delay time", + "permissions": "readwrite", + "visibility": "private" + }, + "useDeepinAuth": { + "value": true, + "serial": 0, + "flags": [], + "name": "use Deepin Auth", + "name[zh_CN]": "使用Deepin认证", + "description[zh_CN]": "是否使用Deepin认证。", + "description": "use Deepin Auth", + "permissions": "readwrite", + "visibility": "private" + }, + "sleep": { + "value": true, + "serial": 0, + "flags": [], + "name": "AutoExit", + "name[zh_CN]": "sleep", + "description": "sleep, If enabled, suspend operation display, If disabled, suspend operation does not show.", + "description[zh_CN]": "sleep,如果启用,那么待机操作显示,如果禁用,那么待机操作不显示。", + "permissions": "readwrite", + "visibility": "private" + }, + "hibernate": { + "value": true, + "serial": 0, + "flags": [], + "name": "hibernate", + "name[zh_CN]": "休眠", + "description": "If enabled, hibernate operation display, If disabled, hibernate operation does not show.", + "description[zh_CN]": "如果启用,那么休眠操作显示,如果禁用,那么休眠操作不显示。", + "permissions": "readwrite", + "visibility": "private" + }, + "switchUser": { + "value": 1, + "serial": 0, + "flags": [], + "name": "switch user", + "name[zh_CN]": "切换用户", + "description": "0:always show switch user button。1:ondemand show switch user button。2:disabled show switch user button", + "description[zh_CN]": "0:总是显示切换用户按钮。1:按需显示切换用户按钮。2:禁用显示切换用户按钮", + "permissions": "readwrite", + "visibility": "private" + }, + "systemSuspend": { + "value": 0, + "serial": 0, + "flags": [], + "name": "system suspend", + "name[zh_CN]": "系统待机", + "description": "0:Enabled。1:Disabled。2:Hidden", + "description[zh_CN]": "0:启用。1:禁用。2:隐藏", + "permissions": "readwrite", + "visibility": "private" + }, + "systemHibernate": { + "value": 0, + "serial": 0, + "flags": [], + "name": "system hibernate", + "name[zh_CN]": "系统待机", + "description": "0:Enabled。1:Disabled。2:Hidden", + "description[zh_CN]": "0:启用。1:禁用。2:隐藏", + "permissions": "readwrite", + "visibility": "private" + }, + "systemShutdown": { + "value": 0, + "serial": 0, + "flags": [], + "name": "system shutdown", + "name[zh_CN]": "系统关机", + "description": "0:Enabled。1:Disabled。2:Hidden", + "description[zh_CN]": "0:启用。1:禁用。2:隐藏", + "permissions": "readwrite", + "visibility": "private" + }, + "systemLock": { + "value": 0, + "serial": 0, + "flags": [], + "name": "system lock", + "name[zh_CN]": "系统锁屏", + "description": "0:Enabled。1:Disabled。2:Hidden", + "description[zh_CN]": "0:启用。1:禁用。2:隐藏", + "permissions": "readwrite", + "visibility": "private" + } + } +} diff --git a/debian/changelog b/debian/changelog index a3588da5..7d09d4e7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +dde-session-shell (6.0.27) unstable; urgency=medium + + * chore: adapt to Qt6. + + -- Deepin Packages Builder Thu, 23 Jan 2025 16:38:47 +0800 + dde-session-shell (6.0.26) unstable; urgency=medium * UNRELEASED diff --git a/debian/control b/debian/control index 9706520f..c15fd9d3 100644 --- a/debian/control +++ b/debian/control @@ -4,28 +4,24 @@ Priority: optional Maintainer: Deepin Sysdev Build-Depends: debhelper-compat (=12), pkg-config, cmake, - qtbase5-dev, - liblightdm-qt5-3-dev | liblightdm-qt-dev, + qt6-base-dev, + qt6-svg-dev, + qt6-l10n-tools, + liblightdm-qt6-3-dev | liblightdm-qt-dev, libxcb-ewmh-dev, - libqt5x11extras5-dev, - libgsettings-qt-dev, - libqt5svg5-dev, libglib2.0-dev, - libdtkwidget-dev, - libdtkcore5-bin, - qtdeclarative5-dev, - qttools5-dev-tools, + libdtk6widget-dev, + libdtk6core-bin, + libdtk6core-dev, libpam0g-dev, libsystemd-dev, deepin-gettext-tools, libxtst-dev, libxcursor-dev, libxrandr-dev, - libdtkcore5-bin, libgtest-dev, libx11-xcb-dev, libssl-dev, - libdtkcore-dev, libdeepin-pw-check-dev, libxcb-util0-dev|libxcb-util1-dev Standards-Version: 3.9.4 diff --git a/modules/login/CMakeLists.txt b/modules/login/CMakeLists.txt index 4792fe9f..0e6c17fb 100644 --- a/modules/login/CMakeLists.txt +++ b/modules/login/CMakeLists.txt @@ -1,4 +1,4 @@ -find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets WebEngineWidgets REQUIRED) +#find_package(QT NAMES Qt6 COMPONENTS Widgets WebEngineWidgets REQUIRED) # install qtwebengine5-dev / qt6-webengine-dev manually find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets WebEngineWidgets REQUIRED) diff --git a/src/dde-lock/dbus/dbuslockfrontservice.h b/src/dde-lock/dbus/dbuslockfrontservice.h index bd80dee3..f7caab2a 100644 --- a/src/dde-lock/dbus/dbuslockfrontservice.h +++ b/src/dde-lock/dbus/dbuslockfrontservice.h @@ -15,7 +15,6 @@ class QByteArray; template class QList; template class QMap; class QString; -class QStringList; class QVariant; QT_END_NAMESPACE diff --git a/src/dde-lock/dbus/dbusshutdownfrontservice.h b/src/dde-lock/dbus/dbusshutdownfrontservice.h index c50eb9d7..bbbbd9d9 100644 --- a/src/dde-lock/dbus/dbusshutdownfrontservice.h +++ b/src/dde-lock/dbus/dbusshutdownfrontservice.h @@ -15,7 +15,6 @@ class QByteArray; template class QList; template class QMap; class QString; -class QStringList; class QVariant; QT_END_NAMESPACE diff --git a/src/dde-lock/lockframe.cpp b/src/dde-lock/lockframe.cpp index 24060fa7..5abf4544 100644 --- a/src/dde-lock/lockframe.cpp +++ b/src/dde-lock/lockframe.cpp @@ -10,14 +10,11 @@ #include "warningcontent.h" #include "public_func.h" -#include +#include +#include #include #include -#include -#include -#include -#include #define LOCK_START_EFFECT 16 // 锁屏动效比较特殊,窗管根据这个动效值进行处理 @@ -46,7 +43,7 @@ LockFrame::LockFrame(SessionBaseModel *const model, QWidget *parent) , m_enablePowerOffKey(false) , m_autoExitTimer(nullptr) { - xcb_connection_t *connection = QX11Info::connection(); + xcb_connection_t *connection = qGuiApp->nativeInterface()->connection(); if (connection) { xcb_atom_t cook = internAtom(connection, "_DEEPIN_LOCK_SCREEN", false); xcb_change_property(connection, XCB_PROP_MODE_REPLACE, static_cast(winId()), @@ -101,19 +98,16 @@ LockFrame::LockFrame(SessionBaseModel *const model, QWidget *parent) if (!isSleep) { //待机唤醒后检查是否需要密码,若不需要密码直接隐藏锁定界面 - if (QGSettings::isSchemaInstalled("com.deepin.dde.power")) { - QGSettings powerSettings("com.deepin.dde.power", QByteArray(), this); - if (!powerSettings.get("sleep-lock").toBool()) { - qDebug() << "sleep-lock is off, prepare unlock"; - // 待机唤醒的一瞬间,会延迟收到DBusLogin1Manager::PrepareForSleep(true), 进而最终传入到dde-session的locked状态也是延迟的 - // dde-session 延迟收到locked后会重新发送锁定信号,导致这里unlock后又被重新lock - // 设置一个100ms的延时,等待dde-session的locked状态和dde-lock的locked状态完全同步后再进行隐藏锁屏的动作 - model->setIsBlackMode(true); - QTimer::singleShot(100, this, [this, model](){ - model->setIsBlackMode(false); - hide(); - }); - } + if (!isSleepLock()) { + qDebug() << "sleep-lock is off, prepare unlock"; + // 待机唤醒的一瞬间,会延迟收到DBusLogin1Manager::PrepareForSleep(true), 进而最终传入到dde-session的locked状态也是延迟的 + // dde-session 延迟收到locked后会重新发送锁定信号,导致这里unlock后又被重新lock + // 设置一个100ms的延时,等待dde-session的locked状态和dde-lock的locked状态完全同步后再进行隐藏锁屏的动作 + model->setIsBlackMode(true); + QTimer::singleShot(100, this, [this, model](){ + model->setIsBlackMode(false); + hide(); + }); } } } ); diff --git a/src/dde-lock/lockworker.cpp b/src/dde-lock/lockworker.cpp index dac4bcd3..936d717b 100644 --- a/src/dde-lock/lockworker.cpp +++ b/src/dde-lock/lockworker.cpp @@ -10,14 +10,11 @@ #include -#include #include #include -#include #include #include -#include #include #define DOMAIN_BASE_UID 10000 @@ -49,19 +46,14 @@ LockWorker::LockWorker(SessionBaseModel *const model, QObject *parent) m_resetSessionTimer->setInterval(15000); - if (QGSettings::isSchemaInstalled("com.deepin.dde.session-shell")) { - m_gsettings = new QGSettings("com.deepin.dde.session-shell", "/com/deepin/dde/session-shell/", this); - if(m_gsettings->keys().contains("authResetTime")){ - int resetTime = m_gsettings->get("auth-reset-time").toInt(); - if(resetTime > 0) - m_resetSessionTimer->setInterval(resetTime); + if (!m_dConfig) { + m_dConfig = DConfig::create("org.deepin.dde.session-shell", "org.deepin.dde.session-shell", QString(), this); + int resetTime = m_dConfig->value("authResetTime", 15000).toInt(); + if (resetTime > 0) { + m_resetSessionTimer->setInterval(resetTime); } } - if (QGSettings::isSchemaInstalled("com.deepin.dde.power")) { - m_powerGsettings = new QGSettings("com.deepin.dde.power", "/com/deepin/dde/power/", this); - } - m_resetSessionTimer->setSingleShot(true); connect(m_resetSessionTimer, &QTimer::timeout, this, [ = ] { endAuthentication(m_account, AT_All); @@ -251,8 +243,8 @@ void LockWorker::initData() void LockWorker::initConfiguration() { - m_model->setAlwaysShowUserSwitchButton(getGSettings("", "switchuser").toInt() == AuthInterface::Always); - m_model->setAllowShowUserSwitchButton(getGSettings("", "switchuser").toInt() == AuthInterface::Ondemand); + m_model->setAlwaysShowUserSwitchButton(getDconfigValue("switchUser", Ondemand).toInt() == AuthInterface::Always); + m_model->setAllowShowUserSwitchButton(getDconfigValue("switchUser", Ondemand).toInt() == AuthInterface::Ondemand); checkPowerInfo(); } @@ -384,12 +376,7 @@ void LockWorker::doPowerAction(const SessionBaseModel::PowerAction action) switch (action) { case SessionBaseModel::PowerAction::RequireSuspend: { - bool sleepLock = true; - if (m_powerGsettings && m_powerGsettings->keys().contains("sleep-lock")){ - sleepLock = m_powerGsettings->get("sleep-lock").toBool(); - } - - if (sleepLock) { + if (isSleepLock()) { m_model->setIsBlackMode(true); m_model->setCurrentModeState(SessionBaseModel::ModeStatus::PasswordMode); } else { @@ -398,10 +385,11 @@ void LockWorker::doPowerAction(const SessionBaseModel::PowerAction action) } int delayTime = 500; - if(m_gsettings && m_gsettings->keys().contains("delaytime")){ - delayTime = m_gsettings->get("delaytime").toInt(); + if (m_dConfig) { + delayTime = m_dConfig->value("delayTime", 500).toInt(); qInfo() << "delayTime : " << delayTime; } + if (delayTime < 0) { delayTime = 500; } @@ -415,9 +403,9 @@ void LockWorker::doPowerAction(const SessionBaseModel::PowerAction action) m_model->setIsBlackMode(true); m_model->setCurrentModeState(SessionBaseModel::ModeStatus::PasswordMode); int delayTime = 500; - if(m_gsettings && m_gsettings->keys().contains("delaytime")){ - delayTime = m_gsettings->get("delaytime").toInt(); - qInfo() << " delayTime : " << delayTime; + if (m_dConfig) { + delayTime = m_dConfig->value("delayTime", 500).toInt(); + qInfo() << "delayTime : " << delayTime; } if (delayTime < 0) { delayTime = 500; diff --git a/src/dde-lock/lockworker.h b/src/dde-lock/lockworker.h index 25a350b5..cca88391 100644 --- a/src/dde-lock/lockworker.h +++ b/src/dde-lock/lockworker.h @@ -8,19 +8,17 @@ #include "authinterface.h" #include "dbushotzone.h" #include "dbuslockservice.h" -#include "dbuslogin1manager.h" #include "deepinauthframework.h" #include "sessionbasemodel.h" -#include "huaweiswitchos_interface.h" +#include "switchosinterface.h" #include "userinfo.h" -#include "accounts_interface.h" -#include "logined_interface.h" -#include "accountsuser_interface.h" -#include "sessionmanager_interface.h" +#include "accounts1interface.h" +#include "loginedinterface.h" +#include "userinterface.h" +#include "sessionmanager1interface.h" #include -#include using AccountsInter = org::deepin::dde::Accounts1; using UserInter = org::deepin::dde::accounts1::User; diff --git a/src/global_util/dconfigwatcher.cpp b/src/global_util/dconfigwatcher.cpp new file mode 100644 index 00000000..51d50e0c --- /dev/null +++ b/src/global_util/dconfigwatcher.cpp @@ -0,0 +1,78 @@ +// SPDX-FileCopyrightText: 2020 - 2025 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "dconfigwatcher.h" + +#include +#include + +DConfigWatcher::DConfigWatcher(QObject *parent) + : QObject(parent) + , m_dConfig(Dtk::Core::DConfig::create("org.deepin.dde.session-shell", "org.deepin.dde.session-shell", QString(), this)) +{ + connect(m_dConfig, &Dtk::Core::DConfig::valueChanged, this, &DConfigWatcher::onStatusModeChanged); +} + +DConfigWatcher *DConfigWatcher::instance() +{ + static DConfigWatcher w; + return &w; +} + +void DConfigWatcher::bind(const QString &key, QWidget *binder) +{ + m_map.insert(key, binder); + + setStatus(key, binder); +} + +void DConfigWatcher::erase(const QString &key) +{ + if (m_map.isEmpty() || !m_map.contains(key)) + return; + + m_map.remove(key); +} + +void DConfigWatcher::erase(const QString &key, QWidget *binder) +{ + if (m_map.isEmpty() || !m_map.contains(key)) + return; + + m_map.remove(key, binder); +} + +void DConfigWatcher::setStatus(const QString &key, QWidget *binder) +{ + if (!binder) + return; + + const int setting = m_dConfig->value(key).toInt(); + if (setting == Status_Enabled) { + binder->setEnabled(true); + } else if (setting == Status_Disabled) { + binder->setEnabled(false); + } + + binder->setVisible(setting != Status_Hidden); +} + +const int DConfigWatcher::getStatus(const QString &key) +{ + return m_dConfig->value(key).toInt(); +} + +void DConfigWatcher::onStatusModeChanged(const QString &key) +{ + if (m_map.isEmpty() || !m_map.contains(key)) + return; + + // 重新设置控件对应的显示类型 + for (auto mapUnit = m_map.begin(); mapUnit != m_map.end(); ++mapUnit) { + if (key == mapUnit.key()) { + setStatus(key, mapUnit.value()); + emit enableChanged(key, mapUnit.value()->isEnabled()); + } + } +} diff --git a/src/global_util/dconfigwatcher.h b/src/global_util/dconfigwatcher.h new file mode 100644 index 00000000..50f5bc20 --- /dev/null +++ b/src/global_util/dconfigwatcher.h @@ -0,0 +1,39 @@ +// SPDX-FileCopyrightText: 2020 - 2025 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef DCONFIGWATCHER_H +#define DCONFIGWATCHER_H + +#include + +const static int Status_Enabled = 0; +const static int Status_Disabled = 1; +const static int Status_Hidden = 2; + +class DConfigWatcher : public QObject +{ + Q_OBJECT +public: + static DConfigWatcher *instance(); + + void bind(const QString &key, QWidget *binder); + void erase(const QString &key); + void erase(const QString &key, QWidget *binder); + const int getStatus(const QString &key); + +signals: + void enableChanged(const QString &key, bool enable); + +private: + DConfigWatcher(QObject *parent = nullptr); + + void setStatus(const QString &key, QWidget *binder); + void onStatusModeChanged(const QString &key); + +private: + QMultiHash m_map; + Dtk::Core::DConfig *m_dConfig = nullptr; +}; + +#endif // DCONFIGWATCHER_H diff --git a/src/global_util/gsettingwatcher.cpp b/src/global_util/gsettingwatcher.cpp deleted file mode 100644 index a38393da..00000000 --- a/src/global_util/gsettingwatcher.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// SPDX-FileCopyrightText: 2020 - 2023 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -#include "gsettingwatcher.h" - -#include -#include -#include - -/* convert 'some-key' to 'someKey' or 'SomeKey'. - * the second form is needed for appending to 'set' for 'setSomeKey' - */ -inline QString qtify_name(const char *name) -{ - bool next_cap = false; - QString result; - - while (*name) { - if (*name == '-') { - next_cap = true; - } else if (next_cap) { - result.append(QChar(*name).toUpper().toLatin1()); - next_cap = false; - } else { - result.append(*name); - } - - name++; - } - - return result; -} - -GSettingWatcher::GSettingWatcher(QObject *parent) - : QObject(parent) - , m_gsettings(new QGSettings("com.deepin.dde.session-shell", QByteArray(), this)) -{ - connect(m_gsettings, &QGSettings::changed, this, &GSettingWatcher::onStatusModeChanged); -} - -GSettingWatcher *GSettingWatcher::instance() -{ - static GSettingWatcher w; - return &w; -} - -void GSettingWatcher::bind(const QString &gsettingsName, QWidget *binder) -{ - m_map.insert(gsettingsName, binder); - - setStatus(gsettingsName, binder); -} - -void GSettingWatcher::erase(const QString &gsettingsName) -{ - if (m_map.isEmpty() || !m_map.contains(gsettingsName)) - return; - - m_map.remove(gsettingsName); -} - -void GSettingWatcher::erase(const QString &gsettingsName, QWidget *binder) -{ - if (m_map.isEmpty() || !m_map.contains(gsettingsName)) - return; - - m_map.remove(gsettingsName, binder); -} - -void GSettingWatcher::setStatus(const QString &gsettingsName, QWidget *binder) -{ - if (!binder || !m_gsettings->keys().contains(qtify_name(gsettingsName.toUtf8().data()))) - return; - - const QString setting = m_gsettings->get(gsettingsName).toString(); - - if ("Enabled" == setting) - binder->setEnabled(true); - else if ("Disabled" == setting) - binder->setEnabled(false); - - binder->setVisible("Hiden" != setting); -} - -const QString GSettingWatcher::getStatus(const QString &gsettingsName) -{ - if (!m_gsettings->keys().contains(qtify_name(gsettingsName.toUtf8().data()))) - return QString(); - - return m_gsettings->get(gsettingsName).toString(); -} - -void GSettingWatcher::onStatusModeChanged(const QString &key) -{ - if (m_map.isEmpty() || !m_map.contains(key)) - return; - - // 重新设置控件对应的显示类型 - for (auto mapUnit = m_map.begin(); mapUnit != m_map.end(); ++mapUnit) { - if (key == mapUnit.key()) { - setStatus(key, mapUnit.value()); - emit enableChanged(key, mapUnit.value()->isEnabled()); - } - } -} diff --git a/src/global_util/gsettingwatcher.h b/src/global_util/gsettingwatcher.h deleted file mode 100644 index 2ea12280..00000000 --- a/src/global_util/gsettingwatcher.h +++ /dev/null @@ -1,37 +0,0 @@ -// SPDX-FileCopyrightText: 2020 - 2023 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -#ifndef GSETTINGWATCHER_H -#define GSETTINGWATCHER_H - -#include -#include - -class QGSettings; -class GSettingWatcher : public QObject -{ - Q_OBJECT -public: - static GSettingWatcher *instance(); - - void bind(const QString &gsettingsName, QWidget *binder); - void erase(const QString &gsettingsName); - void erase(const QString &gsettingsName, QWidget *binder); - const QString getStatus(const QString &gsettingsName); - -signals: - void enableChanged(const QString &gsettingsName, bool enable); - -private: - GSettingWatcher(QObject *parent = nullptr); - - void setStatus(const QString &gsettingsName, QWidget *binder); - void onStatusModeChanged(const QString &key); - -private: - QMultiHash m_map; - QGSettings *m_gsettings; -}; - -#endif // GSETTINGWATCHER_H diff --git a/src/global_util/keyboardmonitor/keyboardplantform_x11.cpp b/src/global_util/keyboardmonitor/keyboardplantform_x11.cpp index 76c2d262..42832a5b 100644 --- a/src/global_util/keyboardmonitor/keyboardplantform_x11.cpp +++ b/src/global_util/keyboardmonitor/keyboardplantform_x11.cpp @@ -4,11 +4,9 @@ #include "keyboardplantform_x11.h" -#include -#include +#include #include -#include #include #include #include @@ -17,7 +15,6 @@ #include #include -#include static int xi2_opcode; @@ -137,30 +134,30 @@ int KeyboardPlantformX11::listen(Display *display) KeyboardPlantformX11::KeyboardPlantformX11(QObject *parent) : KeyBoardPlatform(parent) { - + if (auto x11Application = qGuiApp->nativeInterface()) + m_display = x11Application->display(); } bool KeyboardPlantformX11::isCapslockOn() { bool result = false; unsigned int n = 0; - static Display *d = QX11Info::display(); - if (d != nullptr) { - XkbGetIndicatorState(d, XkbUseCoreKbd, &n); + if (m_display) { + XkbGetIndicatorState(m_display, XkbUseCoreKbd, &n); result = (n & 0x01) != 0; } + return result; } bool KeyboardPlantformX11::isNumlockOn() { - bool result; + bool result = false; unsigned int n = 0; - static Display* d = QX11Info::display(); - if (!d) + if (!m_display) return false; - XkbGetIndicatorState(d, XkbUseCoreKbd, &n); + XkbGetIndicatorState(m_display, XkbUseCoreKbd, &n); result = (n & 0x02) != 0; return result; @@ -168,12 +165,11 @@ bool KeyboardPlantformX11::isNumlockOn() bool KeyboardPlantformX11::setNumlockStatus(const bool &on) { - Display* d = QX11Info::display(); - if (!d) + if (!m_display) return false; XKeyboardState x; - XGetKeyboardControl(d, &x); + XGetKeyboardControl(m_display, &x); const bool numLockEnabled = x.led_mask & 2; if (numLockEnabled == on) { @@ -181,15 +177,15 @@ bool KeyboardPlantformX11::setNumlockStatus(const bool &on) } // Get the keycode for XK_Caps_Lock keysymbol - unsigned int keycode = XKeysymToKeycode(d, XK_Num_Lock); + unsigned int keycode = XKeysymToKeycode(m_display, XK_Num_Lock); // Simulate Press - int pressExit = XTestFakeKeyEvent(d, keycode, True, CurrentTime); - XFlush(d); + int pressExit = XTestFakeKeyEvent(m_display, keycode, True, CurrentTime); + XFlush(m_display); // Simulate Release - int releseExit = XTestFakeKeyEvent(d, keycode, False, CurrentTime); - XFlush(d); + int releseExit = XTestFakeKeyEvent(m_display, keycode, False, CurrentTime); + XFlush(m_display); return pressExit == 0 && releseExit == 0; } diff --git a/src/global_util/keyboardmonitor/keyboardplantform_x11.h b/src/global_util/keyboardmonitor/keyboardplantform_x11.h index c7eae5e3..eadb31b3 100644 --- a/src/global_util/keyboardmonitor/keyboardplantform_x11.h +++ b/src/global_util/keyboardmonitor/keyboardplantform_x11.h @@ -24,6 +24,9 @@ class KeyboardPlantformX11 : public KeyBoardPlatform int listen(Display *display); static int xinput_version(Display *display); static void select_events(Display* display); + +private: + Display *m_display = nullptr; }; #endif // KEYBOARDPLANTFORM_X11_H diff --git a/src/global_util/multiscreenmanager.cpp b/src/global_util/multiscreenmanager.cpp index 029d4337..427875a4 100644 --- a/src/global_util/multiscreenmanager.cpp +++ b/src/global_util/multiscreenmanager.cpp @@ -6,9 +6,7 @@ #include "fullscreenbackground.h" #include -#include #include -#include #include #include diff --git a/src/global_util/multiscreenmanager.h b/src/global_util/multiscreenmanager.h index 4be03db0..f977e58b 100644 --- a/src/global_util/multiscreenmanager.h +++ b/src/global_util/multiscreenmanager.h @@ -5,14 +5,12 @@ #ifndef MULTISCREENMANAGER_H #define MULTISCREENMANAGER_H -#include #include #include #include #include -#include -#include "systemdisplay_interface.h" +#include "systemdisplay1interface.h" using SystemDisplayInter = org::deepin::dde::Display1; diff --git a/src/global_util/public_func.cpp b/src/global_util/public_func.cpp index a4e06edc..da5a0040 100644 --- a/src/global_util/public_func.cpp +++ b/src/global_util/public_func.cpp @@ -8,23 +8,15 @@ #include -#include -#include +#include #include -#include +#include #include #include #include -#include -#include -#include #include #include -#include -#include -#include -#include using namespace std; @@ -57,11 +49,12 @@ QPixmap loadPixmap(const QString &file, const QSize& size) /** * @brief 是否使用域管认证。 * - * @return true 使用域管认证 - * @return false 使用系统认证 + * @return false 使用域管认证 + * @return true 使用系统认证 */ bool isDeepinAuth() { +#if 0 // TODO this gsetting config provided by 域管 const char* controlId = "com.deepin.dde.auth.control"; if (QGSettings::isSchemaInstalled(controlId)) { const char *controlPath = "/com/deepin/dde/auth/control/"; @@ -73,15 +66,9 @@ bool isDeepinAuth() #endif return useDeepinAuth; } - return true; -} +#endif -uint timeFromString(QString time) -{ - if (time.isEmpty()) { - return QDateTime::currentDateTime().toTime_t(); - } - return QDateTime::fromString(time, Qt::ISODateWithMs).toLocalTime().toTime_t(); + return true; } /** @@ -156,3 +143,22 @@ void loadTranslation(const QString &locale) translator.load("/usr/share/dde-session-shell/translations/dde-session-shell_" + locale.split(".").first()); qApp->installTranslator(&translator); } + +bool isSleepLock() +{ + QDBusInterface powerInterface("org.deepin.dde.Power1", + "/org/deepin/dde/Power1", "org.deepin.dde.Power1", QDBusConnection::sessionBus()); + + if (!powerInterface.isValid()) { + qCritical() << powerInterface.lastError().message(); + return true; // default + } + + QVariant value = powerInterface.property("SleepLock"); + if (!value.isValid()) { + qCritical() << "read SleepLock property failed"; + return true; // default + } + + return value.toBool(); +} diff --git a/src/global_util/public_func.h b/src/global_util/public_func.h index 0f474646..b3b39e37 100644 --- a/src/global_util/public_func.h +++ b/src/global_util/public_func.h @@ -7,10 +7,8 @@ #include "constants.h" -#include #include #include -#include #include #include @@ -51,11 +49,6 @@ T findValueByQSettings(const QStringList &configFiles, */ bool isDeepinAuth(); -/** - * @brief 把字符串解析成时间,然后转换为Unix时间戳 - */ -uint timeFromString(QString time); - QVariant getDConfigValue(const QString &configFileName, const QString &key, const QVariant &defaultValue); void setDConfigValue(const QString &configFileName, const QString &key, const QVariant &value); @@ -72,4 +65,6 @@ QString getDefaultConfigFileName(); void loadTranslation(const QString &locale); +bool isSleepLock(); + #endif // PUBLIC_FUNC_H diff --git a/src/libdde-auth/deepinauthframework.h b/src/libdde-auth/deepinauthframework.h index fadc53db..abe65972 100644 --- a/src/libdde-auth/deepinauthframework.h +++ b/src/libdde-auth/deepinauthframework.h @@ -5,14 +5,10 @@ #ifndef DEEPINAUTHFRAMEWORK_H #define DEEPINAUTHFRAMEWORK_H -#include -#include - -#include #include -#include "authenticate_interface.h" -#include "authenticatesession2_interface.h" +#include "authenticate1interface.h" +#include "session2interface.h" #define AUTHRNTICATESERVICE "org.deepin.dde.Authenticate1" #define AUTHRNTICATEINTERFACE "org.deepin.dde.Authenticate1.Session" diff --git a/src/lightdm-deepin-greeter/changepasswordwidget.cpp b/src/lightdm-deepin-greeter/changepasswordwidget.cpp index d85044cb..34783eaf 100644 --- a/src/lightdm-deepin-greeter/changepasswordwidget.cpp +++ b/src/lightdm-deepin-greeter/changepasswordwidget.cpp @@ -99,7 +99,7 @@ void ChangePasswordWidget::initUI() m_mainLayout->addWidget(m_tipsLabel, 0, Qt::AlignCenter); auto lineEditWidget = new QWidget; auto lineEditLayout = new QVBoxLayout(lineEditWidget); - lineEditLayout->setMargin(0); + lineEditLayout->setContentsMargins(0, 0, 0, 0); lineEditLayout->setSpacing(0); lineEditLayout->addWidget(m_oldPasswdEdit, 0, Qt::AlignCenter); m_levelWidget->setMinimumHeight(LINEEDIT_SPACING); @@ -298,7 +298,7 @@ void ChangePasswordWidget::parseProcessResult(int exitCode, const QString &outpu // 提示修改成功 DFloatingMessage *message = new DFloatingMessage(DFloatingMessage::MessageType::TransientType); QPalette pa; - pa.setColor(QPalette::Background, QColor(247, 247, 247, 51)); + pa.setColor(QPalette::Window, QColor(247, 247, 247, 51)); message->setPalette(pa); message->setIcon(QIcon::fromTheme("dialog-ok")); message->setMessage(tr("Password changed")); diff --git a/src/lightdm-deepin-greeter/greeterworker.cpp b/src/lightdm-deepin-greeter/greeterworker.cpp index 022d218a..66748f68 100644 --- a/src/lightdm-deepin-greeter/greeterworker.cpp +++ b/src/lightdm-deepin-greeter/greeterworker.cpp @@ -8,12 +8,10 @@ #include "keyboardmonitor.h" #include "userinfo.h" -#include "systempower_interface.h" +#include "systempower1interface.h" #include -#include - #include #define LOCKSERVICE_PATH "/org/deepin/dde/LockService1" @@ -35,7 +33,6 @@ GreeterWorker::GreeterWorker(SessionBaseModel *const model, QObject *parent) , m_greeter(new QLightDM::Greeter(this)) , m_authFramework(new DeepinAuthFramework(this)) , m_lockInter(new DBusLockService(LOCKSERVICE_NAME, LOCKSERVICE_PATH, QDBusConnection::systemBus(), this)) - , m_soundPlayerInter(new SoundThemePlayerInter("org.deepin.dde.SoundThemePlayer1", "/org/deepin/dde/SoundThemePlayer1", QDBusConnection::systemBus(), this)) , m_resetSessionTimer(new QTimer(this)) , m_limitsUpdateTimer(new QTimer(this)) , m_retryAuth(false) @@ -58,12 +55,11 @@ GreeterWorker::GreeterWorker(SessionBaseModel *const model, QObject *parent) //认证超时重启 m_resetSessionTimer->setInterval(15000); - if (QGSettings::isSchemaInstalled("com.deepin.dde.session-shell")) { - QGSettings gsetting("com.deepin.dde.session-shell", "/com/deepin/dde/session-shell/", this); - if (gsetting.keys().contains("authResetTime")) { - int resetTime = gsetting.get("auth-reset-time").toInt(); - if (resetTime > 0) - m_resetSessionTimer->setInterval(resetTime); + if (!m_dConfig) { + m_dConfig = DConfig::create("org.deepin.dde.session-shell", "org.deepin.dde.session-shell", QString(), this); + int resetTime = m_dConfig->value("authResetTime", 15000).toInt(); + if (resetTime > 0) { + m_resetSessionTimer->setInterval(resetTime); } } @@ -100,7 +96,7 @@ void GreeterWorker::initConnections() } else { m_model->setAuthType(AT_None); } - m_soundPlayerInter->PrepareShutdownSound(static_cast(m_model->currentUser()->uid())); + prepareShutdownSound(); } }); connect(m_loginedInter, &LoginedInter::LastLogoutUserChanged, m_model, static_cast(&SessionBaseModel::updateLastLogoutUser)); @@ -161,7 +157,7 @@ void GreeterWorker::initConnections() m_model->setAuthType(AT_None); } } - m_soundPlayerInter->PrepareShutdownSound(static_cast(m_model->currentUser()->uid())); + prepareShutdownSound(); }); /* org.deepin.dde.LockService1 */ connect(m_lockInter, &DBusLockService::UserChanged, this, [ = ](const QString &json) { @@ -253,7 +249,7 @@ void GreeterWorker::initData() /* org.deepin.dde.LockService1 */ m_model->updateCurrentUser(m_lockInter->CurrentUser()); } - m_soundPlayerInter->PrepareShutdownSound(static_cast(m_model->currentUser()->uid())); + prepareShutdownSound(); /* org.deepin.dde.Authenticate1 */ if (m_authFramework->isDeepinAuthValid()) { @@ -266,8 +262,8 @@ void GreeterWorker::initData() void GreeterWorker::initConfiguration() { - m_model->setAlwaysShowUserSwitchButton(getGSettings("", "switchuser").toInt() == AuthInterface::Always); - m_model->setAllowShowUserSwitchButton(getGSettings("", "switchuser").toInt() == AuthInterface::Ondemand); + m_model->setAlwaysShowUserSwitchButton(getDconfigValue("switchUser", Ondemand).toInt() == AuthInterface::Always); + m_model->setAllowShowUserSwitchButton(getDconfigValue("switchUser", Ondemand).toInt() == AuthInterface::Ondemand); checkPowerInfo(); @@ -355,7 +351,7 @@ void GreeterWorker::switchToUser(std::shared_ptr user) } else { m_model->setAuthType(AT_None); } - m_soundPlayerInter->PrepareShutdownSound(static_cast(m_model->currentUser()->uid())); + prepareShutdownSound(); } bool GreeterWorker::isSecurityEnhanceOpen() @@ -527,7 +523,7 @@ void GreeterWorker::checkAccount(const QString &account) passwd *pw = getpwnam(str.c_str()); if (pw) { QString userName = pw->pw_name; - QString userFullName = userName.leftRef(userName.indexOf(QString("@"))).toString(); + QString userFullName = userName.left(userName.indexOf(QString("@"))); user_ptr = std::make_shared(INT_MAX - 1); dynamic_cast(user_ptr.get())->setName(userName); @@ -856,3 +852,10 @@ void GreeterWorker::changePasswd() m_model->updateMFAFlag(false); m_model->setAuthType(AT_PAM); } + +void GreeterWorker::prepareShutdownSound() +{ + QDBusInterface soundPlayerInter("org.deepin.dde.SoundThemePlayer1", "/org/deepin/dde/SoundThemePlayer1", + "org.deepin.dde.SoundThemePlayer1", QDBusConnection::systemBus()); + soundPlayerInter.call("PrepareShutdownSound", static_cast(m_model->currentUser()->uid())); +} diff --git a/src/lightdm-deepin-greeter/greeterworker.h b/src/lightdm-deepin-greeter/greeterworker.h index e52a3249..116c0ba4 100644 --- a/src/lightdm-deepin-greeter/greeterworker.h +++ b/src/lightdm-deepin-greeter/greeterworker.h @@ -7,19 +7,14 @@ #include "authinterface.h" #include "dbuslockservice.h" -#include "dbuslogin1manager.h" #include "deepinauthframework.h" #include "sessionbasemodel.h" -#include "soundthemeplayer_interface.h" #include -#include #include -using SoundThemePlayerInter = org::deepin::dde::SoundThemePlayer1; - class GreeterWorker : public Auth::AuthInterface { Q_OBJECT @@ -76,12 +71,12 @@ private slots: void recoveryUserKBState(std::shared_ptr user); void startGreeterAuth(const QString &account = QString()); void changePasswd(); + void prepareShutdownSound(); private: QLightDM::Greeter *m_greeter; DeepinAuthFramework *m_authFramework; DBusLockService *m_lockInter; - SoundThemePlayerInter *m_soundPlayerInter; QTimer *m_resetSessionTimer; QTimer *m_limitsUpdateTimer; QString m_account; diff --git a/src/lightdm-deepin-greeter/passwordlevelwidget.cpp b/src/lightdm-deepin-greeter/passwordlevelwidget.cpp index 4aae125c..81a4cc87 100644 --- a/src/lightdm-deepin-greeter/passwordlevelwidget.cpp +++ b/src/lightdm-deepin-greeter/passwordlevelwidget.cpp @@ -91,7 +91,7 @@ void PasswordLevelWidget::initUI() m_layout->addWidget(m_lowIcon); m_layout->addWidget(m_mediumIcon); m_layout->addWidget(m_highIcon); - m_layout->setMargin(0); + m_layout->setContentsMargins(0, 0, 0, 0); setLayout(m_layout); } diff --git a/src/session-widgets/auth_module.cpp b/src/session-widgets/auth_module.cpp index 8537110e..2396d499 100644 --- a/src/session-widgets/auth_module.cpp +++ b/src/session-widgets/auth_module.cpp @@ -157,8 +157,8 @@ void AuthModule::updateUnlockTime() void AuthModule::updateIntegerMinutes() { if (QDateTime::fromString(m_limitsInfo->unlockTime, Qt::ISODateWithMs) > QDateTime::currentDateTime()) { - qreal intervalSeconds = QDateTime::fromString(m_limitsInfo->unlockTime, Qt::ISODateWithMs).toLocalTime().toTime_t() - - QDateTime::currentDateTimeUtc().toTime_t(); + qreal intervalSeconds = QDateTime::fromString(m_limitsInfo->unlockTime, Qt::ISODateWithMs).toLocalTime().toSecsSinceEpoch() + - QDateTime::currentDateTimeUtc().toSecsSinceEpoch(); m_integerMinutes = static_cast(qCeil(intervalSeconds / 60)); } else { m_integerMinutes = 0; diff --git a/src/session-widgets/auth_password.cpp b/src/session-widgets/auth_password.cpp index 130a39f4..f6c1b02e 100644 --- a/src/session-widgets/auth_password.cpp +++ b/src/session-widgets/auth_password.cpp @@ -7,7 +7,7 @@ #include "authcommon.h" #include "dlineeditex.h" -#include "accountsuser_interface.h" +#include "userinterface.h" #include #include @@ -17,12 +17,8 @@ #include #include #include -#include -#include #include #include -#include -#include #include @@ -64,7 +60,7 @@ void AuthPassword::initUI() m_passwordEdit->setContextMenuPolicy(Qt::NoContextMenu); m_passwordEdit->setFocusPolicy(Qt::StrongFocus); m_passwordEdit->lineEdit()->setAlignment(Qt::AlignCenter); - m_passwordEdit->lineEdit()->setValidator(new QRegExpValidator(QRegExp("^[ -~]+$"))); + m_passwordEdit->lineEdit()->setValidator(new QRegularExpressionValidator(QRegularExpression("^[ -~]+$"))); setLineEditInfo(tr("Password"), PlaceHolderText); @@ -468,7 +464,7 @@ void AuthPassword::showResetPasswordMessage() } QPalette pa; - pa.setColor(QPalette::Background, QColor(247, 247, 247, 51)); + pa.setColor(QPalette::Window, QColor(247, 247, 247, 51)); m_resetPasswordFloatingMessage = new DFloatingMessage(DFloatingMessage::MessageType::ResidentType); m_resetPasswordFloatingMessage->setPalette(pa); m_resetPasswordFloatingMessage->setIcon(QIcon::fromTheme("dialog-warning")); diff --git a/src/session-widgets/auth_single.cpp b/src/session-widgets/auth_single.cpp index 20ddcea5..a970caa1 100644 --- a/src/session-widgets/auth_single.cpp +++ b/src/session-widgets/auth_single.cpp @@ -7,7 +7,7 @@ #include "authcommon.h" #include "dlineeditex.h" -#include "accountsuser_interface.h" +#include "userinterface.h" #include @@ -15,12 +15,8 @@ #include #include #include -#include -#include #include #include -#include -#include #include @@ -61,7 +57,7 @@ void AuthSingle::initUI() m_lineEdit->setContextMenuPolicy(Qt::NoContextMenu); m_lineEdit->setFocusPolicy(Qt::StrongFocus); m_lineEdit->lineEdit()->setAlignment(Qt::AlignCenter); - m_lineEdit->lineEdit()->setValidator(new QRegExpValidator(QRegExp("^[ -~]+$"))); + m_lineEdit->lineEdit()->setValidator(new QRegularExpressionValidator(QRegularExpression("^[ -~]+$"))); QHBoxLayout *passwordLayout = new QHBoxLayout(m_lineEdit->lineEdit()); passwordLayout->setContentsMargins(0, 0, 10, 0); @@ -459,7 +455,7 @@ void AuthSingle::showResetPasswordMessage() } QPalette pa; - pa.setColor(QPalette::Background, QColor(247, 247, 247, 51)); + pa.setColor(QPalette::Window, QColor(247, 247, 247, 51)); m_resetPasswordFloatingMessage = new DFloatingMessage(DFloatingMessage::MessageType::ResidentType); m_resetPasswordFloatingMessage->setPalette(pa); m_resetPasswordFloatingMessage->setIcon(QIcon::fromTheme("dialog-warning")); diff --git a/src/session-widgets/authinterface.cpp b/src/session-widgets/authinterface.cpp index 24717466..8ff34896 100644 --- a/src/session-widgets/authinterface.cpp +++ b/src/session-widgets/authinterface.cpp @@ -200,13 +200,13 @@ bool AuthInterface::checkHaveDisplay(const QJsonArray &array) return false; } -QVariant AuthInterface::getGSettings(const QString& node, const QString& key) +QVariant AuthInterface::getDconfigValue(const QString &key, const QVariant &fallbackValue) { - QVariant value = valueByQSettings(node, key, true); - if (m_gsettings != nullptr && m_gsettings->keys().contains(key)) { - value = m_gsettings->get(key); + if (m_dConfig) { + return m_dConfig->value(key, fallbackValue); } - return value; + + return fallbackValue; } bool AuthInterface::isLogined(uint uid) @@ -220,14 +220,14 @@ bool AuthInterface::isDeepin() #ifdef QT_DEBUG return true; #else - return getGSettings("","useDeepinAuth").toBool(); + return getDconfigValue("useDeepinAuth", true).toBool(); #endif } void AuthInterface::checkConfig() { - m_model->setAlwaysShowUserSwitchButton(getGSettings("","switchuser").toInt() == AuthInterface::Always); - m_model->setAllowShowUserSwitchButton(getGSettings("","switchuser").toInt() == AuthInterface::Ondemand); + m_model->setAlwaysShowUserSwitchButton(getDconfigValue("switchUser", Ondemand).toInt() == AuthInterface::Always); + m_model->setAllowShowUserSwitchButton(getDconfigValue("switchUser", Ondemand).toInt() == AuthInterface::Ondemand); } void AuthInterface::checkPowerInfo() @@ -235,11 +235,11 @@ void AuthInterface::checkPowerInfo() // 替换接口org.freedesktop.login1 org.deepin.dde.SessionManager1,原接口的是否支持待机和休眠的信息不准确 QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); bool can_sleep = env.contains(POWER_CAN_SLEEP) ? QVariant(env.value(POWER_CAN_SLEEP)).toBool() - : getGSettings("Power","sleep").toBool() && m_powerManagerInter->CanSuspend(); + : getDconfigValue("sleep", true).toBool() && m_powerManagerInter->CanSuspend(); m_model->setCanSleep(can_sleep); bool can_hibernate = env.contains(POWER_CAN_HIBERNATE) ? QVariant(env.value(POWER_CAN_HIBERNATE)).toBool() - : getGSettings("Power","hibernate").toBool() && m_powerManagerInter->CanHibernate(); + : getDconfigValue("hibernate", true).toBool() && m_powerManagerInter->CanHibernate(); m_model->setHasSwap(can_hibernate); } diff --git a/src/session-widgets/authinterface.h b/src/session-widgets/authinterface.h index 23e72b03..1109ca6c 100644 --- a/src/session-widgets/authinterface.h +++ b/src/session-widgets/authinterface.h @@ -9,18 +9,18 @@ #include "constants.h" #include "dbuslogin1manager.h" -#include "authenticate_interface.h" -#include "accounts_interface.h" -#include "logined_interface.h" -#include "powermanager_interface.h" -#include "freedesktopdbus_interface.h" -#include "login1sessionself_interface.h" - -#include +#include "authenticate1interface.h" +#include "accounts1interface.h" +#include "loginedinterface.h" +#include "powermanager1interface.h" +#include "dbusinterface.h" +#include "selfinterface.h" + #include -#include #include +#include + using AccountsInter = org::deepin::dde::Accounts1; using LoginedInter = org::deepin::dde::Logined; using Login1SessionSelf = org::freedesktop::login1::Session; @@ -62,7 +62,7 @@ class AuthInterface : public QObject { void checkConfig(); void checkPowerInfo(); bool isDeepin(); - QVariant getGSettings(const QString& node, const QString& key); + QVariant getDconfigValue(const QString &key, const QVariant &fallbackValue); template T valueByQSettings(const QString & group, @@ -83,8 +83,7 @@ class AuthInterface : public QObject { PowerManagerInter* m_powerManagerInter; Authenticate* m_authenticateInter; DBusObjectInter* m_dbusInter; - QGSettings* m_gsettings = nullptr; - QGSettings* m_powerGsettings = nullptr; + Dtk::Core::DConfig* m_dConfig = nullptr; uint m_lastLogoutUid; uint m_currentUserUid; std::list m_loginUserList; diff --git a/src/session-widgets/lockcontent.cpp b/src/session-widgets/lockcontent.cpp index 9e47e95d..e75421a6 100644 --- a/src/session-widgets/lockcontent.cpp +++ b/src/session-widgets/lockcontent.cpp @@ -132,7 +132,7 @@ void LockContent::initConnections() setCenterContent(m_authWidget, Qt::AlignTop, m_authWidget->getTopSpacing()); }); - connect(m_wmInter, &__wm::WorkspaceSwitched, this, &LockContent::currentWorkspaceChanged); + connect(m_wmInter, &com::deepin::wm::WorkspaceSwitched, this, &LockContent::currentWorkspaceChanged); connect(m_localServer, &QLocalServer::newConnection, this, &LockContent::onNewConnection); } @@ -298,7 +298,7 @@ void LockContent::onCurrentUserChanged(std::shared_ptr user) m_user = user; m_localeName = regionValue(localeName_key); - QLocale locale = m_localeName.isEmpty()? user->locale() : QLocale(m_localeName); + QLocale locale = m_localeName.isEmpty() ? QLocale(user->locale()) : QLocale(m_localeName); m_shortTimeFormat = regionValue(shortTimeFormat_key); m_longDateFormat = regionValue(longDateFormat_key); buildConnect(); diff --git a/src/session-widgets/lockcontent.h b/src/session-widgets/lockcontent.h index a9ba4428..afdf2442 100644 --- a/src/session-widgets/lockcontent.h +++ b/src/session-widgets/lockcontent.h @@ -5,7 +5,6 @@ #ifndef LOCKCONTENT_H #define LOCKCONTENT_H -#include #include #include @@ -13,9 +12,8 @@ #include "mediawidget.h" #include "sessionbasemodel.h" #include "sessionbasewindow.h" -#include "systemmonitor.h" -#include "wm_interface.h" +#include "wminterface.h" class AuthWidget; class MFAWidget; diff --git a/src/session-widgets/sessionbasemodel.cpp b/src/session-widgets/sessionbasemodel.cpp index a1440853..dbc63bf8 100644 --- a/src/session-widgets/sessionbasemodel.cpp +++ b/src/session-widgets/sessionbasemodel.cpp @@ -7,7 +7,6 @@ #include #include -#include #define SessionManagerService "org.deepin.dde.SessionManager1" #define SessionManagerPath "/org/deepin/dde/SessionManager1" @@ -441,7 +440,7 @@ void SessionBaseModel::updateLastLogoutUser(const uid_t uid) return user->uid() == uid; }); if (it != userList.end()) { - updateLastLogoutUser(it.i->t()); + updateLastLogoutUser(*it); } } diff --git a/src/session-widgets/sessionbasewindow.cpp b/src/session-widgets/sessionbasewindow.cpp index 88e396c9..138fdf02 100644 --- a/src/session-widgets/sessionbasewindow.cpp +++ b/src/session-widgets/sessionbasewindow.cpp @@ -128,7 +128,7 @@ void SessionBaseWindow::initUI() { //整理代码顺序,让子部件层级清晰明了, //同时方便计算中间区域的大小,使用QFrame替换了QScrollArea - m_topLayout->setMargin(0); + m_topLayout->setContentsMargins(0, 0, 0, 0); m_topLayout->setSpacing(0); m_TopFrame->setAccessibleName("CenterTopFrame"); @@ -136,7 +136,7 @@ void SessionBaseWindow::initUI() m_TopFrame->setFixedHeight(autoScaledSize(LOCK_CONTENT_TOPBOTTOM_WIDGET_HEIGHT)); m_TopFrame->setAutoFillBackground(false); - m_centerLayout->setMargin(0); + m_centerLayout->setContentsMargins(0, 0, 0, 0); m_centerLayout->setSpacing(0); m_centerLayout->addSpacerItem(m_centerSpacerItem); m_centerLayout->setAlignment(Qt::AlignTop | Qt::AlignHCenter); @@ -145,15 +145,15 @@ void SessionBaseWindow::initUI() m_centerFrame->setLayout(m_centerLayout); m_centerFrame->setAutoFillBackground(false); - m_leftBottomLayout->setMargin(0); + m_leftBottomLayout->setContentsMargins(0, 0, 0, 0); m_leftBottomLayout->setSpacing(0); - m_centerBottomLayout->setMargin(0); + m_centerBottomLayout->setContentsMargins(0, 0, 0, 0); m_centerBottomLayout->setSpacing(0); - m_rightBottomLayout->setMargin(0); + m_rightBottomLayout->setContentsMargins(0, 0, 0, 0); m_rightBottomLayout->setSpacing(0); QHBoxLayout *bottomLayout = new QHBoxLayout; - bottomLayout->setMargin(0); + bottomLayout->setContentsMargins(0, 0, 0, 0); bottomLayout->setSpacing(0); bottomLayout->addLayout(m_leftBottomLayout, 3); bottomLayout->addLayout(m_centerBottomLayout, 2); diff --git a/src/session-widgets/user_widget.cpp b/src/session-widgets/user_widget.cpp index edfb3eeb..cf6a168e 100644 --- a/src/session-widgets/user_widget.cpp +++ b/src/session-widgets/user_widget.cpp @@ -5,6 +5,8 @@ #include "user_widget.h" #include "useravatar.h" +#include + #include #include diff --git a/src/session-widgets/userinfo.cpp b/src/session-widgets/userinfo.cpp index 75da1b8b..fd46556f 100644 --- a/src/session-widgets/userinfo.cpp +++ b/src/session-widgets/userinfo.cpp @@ -6,6 +6,8 @@ #include "constants.h" +#include + #include #include #include diff --git a/src/session-widgets/userinfo.h b/src/session-widgets/userinfo.h index 5d3da8d1..6975d897 100644 --- a/src/session-widgets/userinfo.h +++ b/src/session-widgets/userinfo.h @@ -5,10 +5,9 @@ #ifndef USERINFO_H #define USERINFO_H -#include "constants.h" #include "public_func.h" -#include "accountsuser_interface.h" +#include "userinterface.h" #include diff --git a/src/widgets/controlwidget.cpp b/src/widgets/controlwidget.cpp index 1cb13b10..d79545ba 100644 --- a/src/widgets/controlwidget.cpp +++ b/src/widgets/controlwidget.cpp @@ -242,7 +242,7 @@ void ControlWidget::addModule(module::BaseModuleInterface *module) QHBoxLayout *layout = new QHBoxLayout(button); layout->setAlignment(Qt::AlignCenter); layout->setSpacing(0); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(trayWidget); button->setPluginItem(trayWidget); } else { diff --git a/src/widgets/fullscreenbackground.cpp b/src/widgets/fullscreenbackground.cpp index 01cf6e40..65679827 100644 --- a/src/widgets/fullscreenbackground.cpp +++ b/src/widgets/fullscreenbackground.cpp @@ -3,7 +3,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "fullscreenbackground.h" - #include "black_widget.h" #include "public_func.h" #include "sessionbasemodel.h" @@ -273,7 +272,7 @@ void FullscreenBackground::tryActiveWindow(int count/* = 9*/) QTimer::singleShot(50 , this, std::bind(&FullscreenBackground::tryActiveWindow, this, count -1)); } -void FullscreenBackground::enterEvent(QEvent *event) +void FullscreenBackground::enterEvent(QEnterEvent *event) { if (m_primaryShowFinished && m_enableEnterEvent && m_model->visible()) { m_content->show(); @@ -421,7 +420,7 @@ const QPixmap& FullscreenBackground::getPixmap(int type) auto findPixmap = [size](QList> &list) -> const QPixmap & { auto it = std::find_if(list.begin(), list.end(), [size](QPair pair) { return pair.first == size; }); - return it != list.end() ? it.i->t().second : pixmap; + return it != list.end() ? it->second : pixmap; }; if (PIXMAP_TYPE_BACKGROUND == type) @@ -476,9 +475,12 @@ void FullscreenBackground::updatePixmap() }; auto updateFunc = [ isNoUsefunc ] (QList> &list) { - for (auto &pair : list) { - if (isNoUsefunc(pair.first)) - list.removeAll(pair); + for (auto it = list.begin(); it != list.end(); /* no increment here */) { + if (isNoUsefunc(it->first)) { + list.erase(it); + } else { + ++it; + } } }; diff --git a/src/widgets/fullscreenbackground.h b/src/widgets/fullscreenbackground.h index 97adea3b..6639cc9d 100644 --- a/src/widgets/fullscreenbackground.h +++ b/src/widgets/fullscreenbackground.h @@ -10,7 +10,7 @@ #include Q_DECLARE_LOGGING_CATEGORY(DDE_SS) -#include "imageeffect_interface.h" +#include "imageeffect1interface.h" using ImageEffectInter = org::deepin::dde::ImageEffect1; @@ -50,7 +50,7 @@ public slots: private: void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE; - void enterEvent(QEvent *event) Q_DECL_OVERRIDE; + void enterEvent(QEnterEvent *event) Q_DECL_OVERRIDE; void leaveEvent(QEvent *event) Q_DECL_OVERRIDE; void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; const QPixmap pixmapHandle(const QPixmap &pixmap); diff --git a/src/widgets/logowidget.cpp b/src/widgets/logowidget.cpp index ff6b3f54..18a0262a 100644 --- a/src/widgets/logowidget.cpp +++ b/src/widgets/logowidget.cpp @@ -2,12 +2,7 @@ // // SPDX-License-Identifier: GPL-3.0-or-later -#include -#include -#include -#include -#include -#include +#include #include #include "public_func.h" #include "util_updateui.h" @@ -97,7 +92,7 @@ QString LogoWidget::getVersion() if (DSysInfo::uosType() == DSysInfo::UosServer) { version = QString("%1").arg(DSysInfo::majorVersion()); } else if (DSysInfo::isDeepin()) { - version = QString("%1 %2").arg(DSysInfo::majorVersion()).arg(DSysInfo::uosEditionName(m_locale)); + version = QString("%1 %2").arg(DSysInfo::majorVersion()).arg(DSysInfo::uosEditionName(QLocale(m_locale))); } else { version = QString("%1 %2").arg(DSysInfo::productVersion()).arg(DSysInfo::productTypeString()); } diff --git a/src/widgets/mediawidget.cpp b/src/widgets/mediawidget.cpp index b13cf489..9ebdba01 100644 --- a/src/widgets/mediawidget.cpp +++ b/src/widgets/mediawidget.cpp @@ -20,7 +20,7 @@ void MediaWidget::initUI() m_dmprisWidget->setAccessibleName("MPRISWidget"); m_dmprisWidget->setPictureVisible(false); QVBoxLayout *mainlayout = new QVBoxLayout; - mainlayout->setMargin(0); + mainlayout->setContentsMargins(0, 0, 0, 0); mainlayout->addWidget(m_dmprisWidget); setLayout(mainlayout); diff --git a/src/widgets/rounditembutton.cpp b/src/widgets/rounditembutton.cpp index b8bb675d..88a88887 100644 --- a/src/widgets/rounditembutton.cpp +++ b/src/widgets/rounditembutton.cpp @@ -2,10 +2,10 @@ // // SPDX-License-Identifier: GPL-3.0-or-later +#include "rounditembutton.h" + #include #include -#include "rounditembutton.h" -#include "../global_util/gsettingwatcher.h" #include @@ -76,7 +76,7 @@ void RoundItemButton::initUI() DFontSizeManager::instance()->bind(this, DFontSizeManager::T6); } -void RoundItemButton::enterEvent(QEvent* event) +void RoundItemButton::enterEvent(QEnterEvent* event) { Q_UNUSED(event) diff --git a/src/widgets/rounditembutton.h b/src/widgets/rounditembutton.h index 840b2879..2c83fd67 100644 --- a/src/widgets/rounditembutton.h +++ b/src/widgets/rounditembutton.h @@ -57,7 +57,7 @@ private slots: protected: void paintEvent(QPaintEvent* event) Q_DECL_OVERRIDE; - void enterEvent(QEvent* event) Q_DECL_OVERRIDE; + void enterEvent(QEnterEvent* event) Q_DECL_OVERRIDE; void leaveEvent(QEvent* event) Q_DECL_OVERRIDE; void mousePressEvent(QMouseEvent* event) Q_DECL_OVERRIDE; void mouseReleaseEvent(QMouseEvent* e) Q_DECL_OVERRIDE; diff --git a/src/widgets/roundpopupwidget.cpp b/src/widgets/roundpopupwidget.cpp index b301c1a7..56faef9e 100644 --- a/src/widgets/roundpopupwidget.cpp +++ b/src/widgets/roundpopupwidget.cpp @@ -30,7 +30,7 @@ void RoundPopupWidget::initUI() setBlurRectYRadius(RADIUS); setMaskColor(DBlurEffectWidget::LightColor); setMaskAlpha(BlurMaskAlpha); - m_mainLayout->setMargin(0); + m_mainLayout->setContentsMargins(0, 0, 0, 0); m_mainLayout->setContentsMargins(MARGIN, MARGIN, MARGIN, MARGIN); setLayout(m_mainLayout); } @@ -77,7 +77,7 @@ bool RoundPopupWidget::eventFilter(QObject *watched, QEvent *event) QSize newSize = resizeEvent->size() + QSize(MARGIN * 2, MARGIN * 2); // Recalculate the geometry QRect oldGeometry = geometry(); - QPoint anchor = parentWidget()->mapToGlobal({oldGeometry.left() + oldGeometry.width() / 2 - 1, oldGeometry.bottom()}); + QPoint anchor = parentWidget()->mapToGlobal(QPoint(oldGeometry.left() + oldGeometry.width() / 2 - 1, oldGeometry.bottom())); // Bound to screen and margin. If we can't show the popup fully, assume it's a scroll area, we just set a max height. QRect boundary = topLevelWidget()->frameGeometry(); boundary.adjust((boundary.width() + DDESESSIONCC::PASSWDLINEEIDT_WIDTH) / 2 + Popup::HorizontalMargin, Popup::VerticalMargin, -Popup::HorizontalMargin, 0); diff --git a/src/widgets/shutdownwidget.cpp b/src/widgets/shutdownwidget.cpp index e78d4611..c4e046f5 100644 --- a/src/widgets/shutdownwidget.cpp +++ b/src/widgets/shutdownwidget.cpp @@ -4,8 +4,8 @@ #include "shutdownwidget.h" #include "multiuserswarningview.h" -#include "../global_util/gsettingwatcher.h" -#include "../global_util/public_func.h" +#include "dconfigwatcher.h" +#include "public_func.h" #include @@ -31,10 +31,10 @@ ShutdownWidget::ShutdownWidget(QWidget *parent) initUI(); initConnect(); - onEnable("systemShutdown", enableState(GSettingWatcher::instance()->getStatus("systemShutdown"))); - onEnable("systemSuspend", enableState(GSettingWatcher::instance()->getStatus("systemSuspend"))); - onEnable("systemHibernate", enableState(GSettingWatcher::instance()->getStatus("systemHibernate"))); - onEnable("systemLock", enableState(GSettingWatcher::instance()->getStatus("systemLock"))); + onEnable("systemShutdown", enableState(DConfigWatcher::instance()->getStatus("systemShutdown"))); + onEnable("systemSuspend", enableState(DConfigWatcher::instance()->getStatus("systemSuspend"))); + onEnable("systemHibernate", enableState(DConfigWatcher::instance()->getStatus("systemHibernate"))); + onEnable("systemLock", enableState(DConfigWatcher::instance()->getStatus("systemLock"))); std::function function = std::bind(&ShutdownWidget::onOtherPageChanged, this, std::placeholders::_1); int index = m_frameDataBind->registerFunction("ShutdownWidget", function); @@ -47,9 +47,9 @@ ShutdownWidget::ShutdownWidget(QWidget *parent) ShutdownWidget::~ShutdownWidget() { - GSettingWatcher::instance()->erase("systemSuspend"); - GSettingWatcher::instance()->erase("systemHibernate"); - GSettingWatcher::instance()->erase("systemShutdown"); + DConfigWatcher::instance()->erase("systemSuspend"); + DConfigWatcher::instance()->erase("systemHibernate"); + DConfigWatcher::instance()->erase("systemShutdown"); } void ShutdownWidget::initConnect() @@ -89,7 +89,7 @@ void ShutdownWidget::initConnect() onRequirePowerAction(SessionBaseModel::PowerAction::RequireLogout, false); }); - connect(GSettingWatcher::instance(), &GSettingWatcher::enableChanged, this, &ShutdownWidget::onEnable); + connect(DConfigWatcher::instance(), &DConfigWatcher::enableChanged, this, &ShutdownWidget::onEnable); if (m_systemMonitor) { connect(m_systemMonitor, &SystemMonitor::requestShowSystemMonitor, this, &ShutdownWidget::runSystemMonitor); @@ -109,25 +109,25 @@ void ShutdownWidget::updateTr(RoundItemButton *widget, const QString &tr) m_trList << std::pair, QString>(std::bind(&RoundItemButton::setText, widget, std::placeholders::_1), tr); } -bool ShutdownWidget::enableState(const QString &gsettingsValue) +bool ShutdownWidget::enableState(int settingsValue) { - if ("Disabled" == gsettingsValue) + if (Status_Disabled == settingsValue) return false; - else - return true; + + return true; } -void ShutdownWidget::onEnable(const QString &gsettingsName, bool enable) +void ShutdownWidget::onEnable(const QString &key, bool enable) { - if ("systemShutdown" == gsettingsName) { + if ("systemShutdown" == key) { m_requireShutdownButton->setDisabled(!enable); - } else if ("systemSuspend" == gsettingsName) { + } else if ("systemSuspend" == key) { m_requireSuspendButton->setDisabled(!enable); m_requireSuspendButton->setCheckable(enable); - } else if ("systemHibernate" == gsettingsName) { + } else if ("systemHibernate" == key) { m_requireHibernateButton->setDisabled(!enable); m_requireHibernateButton->setCheckable(enable); - } else if ("systemLock" == gsettingsName) { + } else if ("systemLock" == key) { m_requireLockButton->setDisabled(!enable); } } @@ -184,12 +184,12 @@ void ShutdownWidget::enterKeyPushed() void ShutdownWidget::enableHibernateBtn(bool enable) { - m_requireHibernateButton->setVisible(enable && (GSettingWatcher::instance()->getStatus("systemHibernate") != "Hiden")); + m_requireHibernateButton->setVisible(enable && (DConfigWatcher::instance()->getStatus("systemHibernate") != Status_Hidden)); } void ShutdownWidget::enableSleepBtn(bool enable) { - m_requireSuspendButton->setVisible(enable && (GSettingWatcher::instance()->getStatus("systemSuspend") != "Hiden")); + m_requireSuspendButton->setVisible(enable && (DConfigWatcher::instance()->getStatus("systemSuspend") != Status_Hidden)); } void ShutdownWidget::initUI() @@ -201,7 +201,7 @@ void ShutdownWidget::initUI() m_requireShutdownButton->setAccessibleName("RequireShutDownButton"); m_requireShutdownButton->setAutoExclusive(true); updateTr(m_requireShutdownButton, "Shut down"); - GSettingWatcher::instance()->bind("systemShutdown", m_requireShutdownButton); // GSettings配置项 + DConfigWatcher::instance()->bind("systemShutdown", m_requireShutdownButton); m_requireRestartButton = new RoundItemButton(tr("Reboot"), this); m_requireRestartButton->setFocusPolicy(Qt::NoFocus); @@ -216,7 +216,7 @@ void ShutdownWidget::initUI() m_requireSuspendButton->setAccessibleName("RequireSuspendButton"); m_requireSuspendButton->setAutoExclusive(true); updateTr(m_requireSuspendButton, "Suspend"); - GSettingWatcher::instance()->bind("systemSuspend", m_requireSuspendButton); // GSettings配置项 + DConfigWatcher::instance()->bind("systemSuspend", m_requireSuspendButton); m_requireHibernateButton = new RoundItemButton(tr("Hibernate"), this); m_requireHibernateButton->setFocusPolicy(Qt::NoFocus); @@ -224,7 +224,7 @@ void ShutdownWidget::initUI() m_requireHibernateButton->setObjectName("RequireHibernateButton"); m_requireHibernateButton->setAutoExclusive(true); updateTr(m_requireHibernateButton, "Hibernate"); - GSettingWatcher::instance()->bind("systemHibernate", m_requireHibernateButton); // GSettings配置项 + DConfigWatcher::instance()->bind("systemHibernate", m_requireHibernateButton); m_requireLockButton = new RoundItemButton(tr("Lock")); m_requireLockButton->setFocusPolicy(Qt::NoFocus); @@ -232,7 +232,7 @@ void ShutdownWidget::initUI() m_requireLockButton->setObjectName("RequireLockButton"); m_requireLockButton->setAutoExclusive(true); updateTr(m_requireLockButton, "Lock"); - GSettingWatcher::instance()->bind("systemLock", m_requireLockButton); // GSettings配置项 + DConfigWatcher::instance()->bind("systemLock", m_requireLockButton); m_requireLogoutButton = new RoundItemButton(tr("Log out")); m_requireLogoutButton->setFocusPolicy(Qt::NoFocus); @@ -271,7 +271,7 @@ void ShutdownWidget::initUI() m_btnList.append(m_requireLogoutButton); m_shutdownLayout = new QHBoxLayout; - m_shutdownLayout->setMargin(0); + m_shutdownLayout->setContentsMargins(0, 0, 0, 0); m_shutdownLayout->setSpacing(10); m_shutdownLayout->addStretch(); m_shutdownLayout->addWidget(m_requireShutdownButton); @@ -291,7 +291,7 @@ void ShutdownWidget::initUI() m_shutdownFrame->setLayout(m_shutdownLayout); m_actionLayout = new QVBoxLayout; - m_actionLayout->setMargin(0); + m_actionLayout->setContentsMargins(0, 0, 0, 0); m_actionLayout->setSpacing(10); m_actionLayout->addStretch(); m_actionLayout->addWidget(m_shutdownFrame); @@ -318,7 +318,7 @@ void ShutdownWidget::initUI() m_actionFrame->setLayout(m_actionLayout); m_mainLayout = new QStackedLayout; - m_mainLayout->setMargin(0); + m_mainLayout->setContentsMargins(0, 0, 0, 0); m_mainLayout->setSpacing(0); m_mainLayout->addWidget(m_actionFrame); m_mainLayout->setAlignment(m_actionFrame, Qt::AlignCenter); @@ -395,7 +395,7 @@ void ShutdownWidget::onStatusChanged(SessionBaseModel::ModeStatus status) { RoundItemButton *roundItemButton; if (m_model->currentModeState() == SessionBaseModel::ModeStatus::ShutDownMode) { - m_requireLockButton->setVisible(GSettingWatcher::instance()->getStatus("systemLock") != "Hiden"); + m_requireLockButton->setVisible(DConfigWatcher::instance()->getStatus("systemLock") != Status_Hidden); m_requireSwitchUserBtn->setVisible(m_switchUserEnable); if (m_requireSwitchSystemBtn) { m_requireSwitchSystemBtn->setVisible(true); @@ -455,11 +455,11 @@ void ShutdownWidget::recoveryLayout() { //关机或重启确认前会隐藏所有按钮,取消重启或关机后隐藏界面时重置按钮可见状态 //同时需要判断切换用户按钮是否允许可见 - m_requireShutdownButton->setVisible(true && (GSettingWatcher::instance()->getStatus("systemShutdown") != "Hiden")); + m_requireShutdownButton->setVisible(true && (DConfigWatcher::instance()->getStatus("systemShutdown") != Status_Hidden)); m_requireRestartButton->setVisible(true); enableHibernateBtn(m_model->hasSwap()); enableSleepBtn(m_model->canSleep()); - m_requireLockButton->setVisible(true && (GSettingWatcher::instance()->getStatus("systemLock") != "Hiden")); + m_requireLockButton->setVisible(true && (DConfigWatcher::instance()->getStatus("systemLock") != Status_Hidden)); m_requireSwitchUserBtn->setVisible(m_switchUserEnable); if (m_systemMonitor) { diff --git a/src/widgets/shutdownwidget.h b/src/widgets/shutdownwidget.h index 50fab23d..a2934563 100644 --- a/src/widgets/shutdownwidget.h +++ b/src/widgets/shutdownwidget.h @@ -18,7 +18,7 @@ #include "systemmonitor.h" #include "public_func.h" -#include "huaweiswitchos_interface.h" +#include "switchosinterface.h" DCORE_BEGIN_NAMESPACE class DConfig; @@ -34,7 +34,7 @@ class ShutdownWidget: public QFrame ~ShutdownWidget() override; void setModel(SessionBaseModel * const model); void onStatusChanged(SessionBaseModel::ModeStatus status); - bool enableState(const QString &gsettingsValue); + bool enableState(int settingsValue); public slots: void leftKeySwitch(); @@ -42,7 +42,7 @@ public slots: void runSystemMonitor(); void recoveryLayout(); void setUserSwitchEnable(bool enable); - void onEnable(const QString &gsettingsName, bool enable); + void onEnable(const QString &key, bool enable); void updateLocale(std::shared_ptr user); signals: diff --git a/src/widgets/systemmonitor.cpp b/src/widgets/systemmonitor.cpp index f8db442a..7cb3cdf9 100644 --- a/src/widgets/systemmonitor.cpp +++ b/src/widgets/systemmonitor.cpp @@ -45,7 +45,7 @@ void SystemMonitor::setState(const State state) update(); } -void SystemMonitor::enterEvent(QEvent *event) +void SystemMonitor::enterEvent(QEnterEvent *event) { m_state = Enter; update(); diff --git a/src/widgets/systemmonitor.h b/src/widgets/systemmonitor.h index c249fd90..cd994390 100644 --- a/src/widgets/systemmonitor.h +++ b/src/widgets/systemmonitor.h @@ -28,7 +28,7 @@ class SystemMonitor : public QWidget void requestShowSystemMonitor(); protected: - void enterEvent(QEvent *event) override; + void enterEvent(QEnterEvent *event) override; void leaveEvent(QEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent *event) override; diff --git a/src/widgets/timewidget.cpp b/src/widgets/timewidget.cpp index d77846ef..e84ea3d1 100644 --- a/src/widgets/timewidget.cpp +++ b/src/widgets/timewidget.cpp @@ -81,7 +81,7 @@ void TimeWidget::refreshTime() } // "Ap"/"aP"->"AP" - m_shortTimeFormat.replace(QRegExp("a?p", Qt::CaseInsensitive), "AP"); + m_shortTimeFormat.replace(QRegularExpression("a?p", QRegularExpression::CaseInsensitiveOption), "AP"); QString date_format = shortDateFormat.at(m_shortDateIndex) + " " + weekdayFormat.at(m_weekdayIndex); m_dateLabel->setText(m_locale.toString(QDateTime::currentDateTime(), date_format)); diff --git a/src/widgets/useravatar.cpp b/src/widgets/useravatar.cpp index 8b4e9690..78274f0e 100644 --- a/src/widgets/useravatar.cpp +++ b/src/widgets/useravatar.cpp @@ -3,10 +3,11 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "useravatar.h" -#include "dthememanager.h" + #include #include #include +#include #define AVATAR_ROUND_RADIUS (18) diff --git a/src/widgets/useravatar.h b/src/widgets/useravatar.h index bcb80b4d..b6f680d3 100644 --- a/src/widgets/useravatar.h +++ b/src/widgets/useravatar.h @@ -5,16 +5,10 @@ #ifndef USERAVATAR_H #define USERAVATAR_H -#include #include #include -#include #include #include -#include -#include - -#include class UserAvatar : public QPushButton { diff --git a/src/widgets/userbutton.cpp b/src/widgets/userbutton.cpp index 136e9bf6..5e1358fd 100644 --- a/src/widgets/userbutton.cpp +++ b/src/widgets/userbutton.cpp @@ -79,14 +79,14 @@ void UserButton::initUI() m_nameLayout = new QHBoxLayout; m_nameLayout->setSpacing(5); - m_nameLayout->setMargin(0); + m_nameLayout->setContentsMargins(0, 0, 0, 0); m_nameLayout->addStretch(); m_nameLayout->addWidget(m_checkedMark); m_nameLayout->addWidget(m_userNameLabel); m_nameLayout->addStretch(); m_centralLayout = new QVBoxLayout; - m_centralLayout->setMargin(0); + m_centralLayout->setContentsMargins(0, 0, 0, 0); m_centralLayout->setSpacing(0); m_centralLayout->addWidget(m_userAvatar); m_centralLayout->setAlignment(m_userAvatar, Qt::AlignHCenter); diff --git a/src/widgets/userbutton.h b/src/widgets/userbutton.h index a8b92655..aed84b48 100644 --- a/src/widgets/userbutton.h +++ b/src/widgets/userbutton.h @@ -5,19 +5,14 @@ #ifndef USERBUTTON_H #define USERBUTTON_H -#include #include -#include #include #include -#include -#include -#include #include #include "useravatar.h" -#include "accountsuser_interface.h" +#include "userinterface.h" using UserInter = org::deepin::dde::accounts1::User; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index dd4356dd..afd94e7b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -find_package(Qt5 COMPONENTS Test DBus REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Test DBus REQUIRED) find_package(GTest REQUIRED) ADD_COMPILE_OPTIONS(-fno-access-control) diff --git a/tests/dde-lock/CMakeLists.txt b/tests/dde-lock/CMakeLists.txt index bce1466c..ec8db1af 100644 --- a/tests/dde-lock/CMakeLists.txt +++ b/tests/dde-lock/CMakeLists.txt @@ -27,13 +27,8 @@ add_executable(${BIN_NAME} ) target_include_directories(${BIN_NAME} PUBLIC - ${DTKWIDGET_INCLUDE_DIR} - ${DTKCORE_INCLUDE_DIR} - ${Qt5Gui_PRIVATE_INCLUDE_DIRS} - ${QGSettings_INCLUDE_DIRS} ${PAM_INCLUDE_DIR} ${XCB_EWMH_INCLUDE_DIRS} - ${Qt5X11Extras_INCLUDE_DIRS} ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/src/dde-lock ${PROJECT_SOURCE_DIR}/src/dde-lock/dbus @@ -41,20 +36,14 @@ target_include_directories(${BIN_NAME} PUBLIC ) target_link_libraries(${BIN_NAME} PRIVATE - ${Qt5Test_LIBRARIES} - ${DtkWidget_LIBRARIES} - ${DtkCore_LIBRARIES} - ${Qt5Widgets_LIBRARIES} - ${Qt5DBus_LIBRARIES} - ${QGSettings_LIBRARIES} + Dtk${DTK_VERSION_MAJOR}::Widget + Dtk${DTK_VERSION_MAJOR}::Core ${GTEST_LIBRARIES} ${Qt_LIBS} ${PAM_LIBRARIES} ${XCB_EWMH_LIBRARIES} - ${Qt5Concurrent_LIBRARIES} - ${Qt5X11Extras_LIBRARIES} - ${Qt5Network_LIBRARIES} ${Greeter_LIBRARIES} + Qt${QT_VERSION_MAJOR}::Test -lpthread -lm ) diff --git a/tests/lightdm-deepin-greeter/CMakeLists.txt b/tests/lightdm-deepin-greeter/CMakeLists.txt index a929e78f..dc281688 100644 --- a/tests/lightdm-deepin-greeter/CMakeLists.txt +++ b/tests/lightdm-deepin-greeter/CMakeLists.txt @@ -32,13 +32,8 @@ add_executable(${BIN_NAME} target_include_directories(${BIN_NAME} PUBLIC ${PAM_INCLUDE_DIR} - ${DTKWIDGET_INCLUDE_DIR} - ${DTKCORE_INCLUDE_DIR} ${XCB_EWMH_INCLUDE_DIRS} - ${Qt5Gui_PRIVATE_INCLUDE_DIRS} ${PROJECT_BINARY_DIR} - ${QGSettings_INCLUDE_DIRS} - ${Qt5X11Extras_INCLUDE_DIRS} ${Greeter_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/src/lightdm-deepin-greeter ) @@ -51,16 +46,10 @@ target_link_libraries(${BIN_NAME} PRIVATE ${Qt_LIBS} ${PAM_LIBRARIES} ${XCB_EWMH_LIBRARIES} - ${DtkWidget_LIBRARIES} - ${DtkCore_LIBRARIES} - ${Qt5Widgets_LIBRARIES} - ${Qt5Concurrent_LIBRARIES} - ${Qt5X11Extras_LIBRARIES} - ${Qt5DBus_LIBRARIES} - ${Qt5Network_LIBRARIES} - ${QGSettings_LIBRARIES} + Dtk${DTK_VERSION_MAJOR}::Widget + Dtk${DTK_VERSION_MAJOR}::Core ${Greeter_LIBRARIES} - ${Qt5Test_LIBRARIES} + Qt${QT_VERSION_MAJOR}::Test ${GTEST_LIBRARIES} ${DEEPIN_PW_CHECK} -lpthread