From 58eb7e2d1b81a1498a212e64d1aeeb8f19942371 Mon Sep 17 00:00:00 2001 From: liudun Date: Fri, 17 Nov 2023 15:50:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B0=83=E7=94=A8usd?= =?UTF-8?q?=E5=BF=AB=E6=8D=B7=E9=94=AE=E5=90=8E=E7=AB=AF=E5=8D=A1=E6=AD=BB?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20=E5=8E=BB=E9=99=A4paintevent?= =?UTF-8?q?=E9=83=A8=E5=88=86=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dbusifs/usdhelper.cpp | 6 +-- src/widgets/fullbackgroundwidget.cpp | 28 +++++----- src/widgets/lockwidget.cpp | 79 +++++++++++++++------------- 3 files changed, 58 insertions(+), 55 deletions(-) diff --git a/src/dbusifs/usdhelper.cpp b/src/dbusifs/usdhelper.cpp index 859fc96..9ee2731 100644 --- a/src/dbusifs/usdhelper.cpp +++ b/src/dbusifs/usdhelper.cpp @@ -26,9 +26,9 @@ UsdHelper::~UsdHelper() bool UsdHelper::usdExternalDoAction(int actionType) { - QDBusMessage result = usdInterface->call("externalDoAction", actionType, "screensaver"); - if (result.type() == QDBusMessage::ErrorMessage) { - qWarning() << "setDefaultDevice error:" << result.errorMessage(); + QDBusPendingCall result = usdInterface->asyncCall("externalDoAction", actionType, "screensaver"); + if (result.error().type() == QDBusMessage::ErrorMessage) { + qWarning() << "usdExternalDoAction error~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ; return false; } return true; diff --git a/src/widgets/fullbackgroundwidget.cpp b/src/widgets/fullbackgroundwidget.cpp index 5c4385c..7dcea81 100644 --- a/src/widgets/fullbackgroundwidget.cpp +++ b/src/widgets/fullbackgroundwidget.cpp @@ -691,7 +691,7 @@ void FullBackgroundWidget::initCurrentBackground() QString FullBackgroundWidget::getDefaultBackgroundPath() { - qDebug() << __LINE__ << __FUNCTION__; +// qDebug() << __LINE__ << __FUNCTION__; QString default_background_path = "/usr/share/backgrounds/1-warty-final-ubuntukylin.jpg"; QFile file(default_background_path); @@ -717,7 +717,7 @@ void FullBackgroundWidget::loadingAllUserBackground() void FullBackgroundWidget::paintEvent(QPaintEvent *event) { - qDebug() << __LINE__ << __FUNCTION__; +// qDebug() << __LINE__ << __FUNCTION__; QPainter painter(this); @@ -764,7 +764,7 @@ void FullBackgroundWidget::paintEvent(QPaintEvent *event) bool FullBackgroundWidget::isOpenGradation() { - qDebug() << __LINE__ << __FUNCTION__; +// qDebug() << __LINE__ << __FUNCTION__; bool isOpenGradation = false; // return true;//test 一直触发渐变效果 if (m_currentUserName.isEmpty() || m_oldUserName.isEmpty()) @@ -833,7 +833,7 @@ void FullBackgroundWidget::startTransition() } void FullBackgroundWidget::stopTransition() { - qDebug() << __LINE__ << __FUNCTION__; +// qDebug() << __LINE__ << __FUNCTION__; if(m_backgrondGradationTimer && m_backgrondGradationTimer->isActive()) m_backgrondGradationTimer->stop(); @@ -844,7 +844,7 @@ void FullBackgroundWidget::stopTransition() void FullBackgroundWidget::drawBackground(QPixmap * backgroundBack, QPixmap * backgroundFront, const QRect &rect, float alpha) { - qDebug() << __LINE__ << __FUNCTION__; +// qDebug() << __LINE__ << __FUNCTION__; if(backgroundBack->isNull()) { @@ -887,13 +887,13 @@ void FullBackgroundWidget::drawBackground(QPixmap * backgroundBack, QPixmap * ba painter1.setPen(Qt::transparent); painter1.drawPath(path); } - qDebug() << __LINE__ << __FUNCTION__<< "===============2"; +// qDebug() << __LINE__ << __FUNCTION__<< "===============2"; } void FullBackgroundWidget::onRemoveUserBackground(const QString &strUserName) { - qDebug() << __LINE__ << __FUNCTION__; +// qDebug() << __LINE__ << __FUNCTION__; if (m_allBackgroundsMap.contains(strUserName)) m_allBackgroundsMap.remove(strUserName); @@ -901,13 +901,13 @@ void FullBackgroundWidget::onRemoveUserBackground(const QString &strUserName) QString FullBackgroundWidget::getUserBackgroundPath(const QString &strUserName) { - qDebug() << __LINE__ << __FUNCTION__; +// qDebug() << __LINE__ << __FUNCTION__; for (UserInfoPtr userInfo : m_modelLockDialog->usersInfo()) { if (strUserName == userInfo->name()) { - qDebug() << __LINE__ << __FUNCTION__ << userInfo->name() << userInfo->backGround(); +// qDebug() << __LINE__ << __FUNCTION__ << userInfo->name() << userInfo->backGround(); return userInfo->backGround(); } @@ -917,17 +917,17 @@ QString FullBackgroundWidget::getUserBackgroundPath(const QString &strUserName) void FullBackgroundWidget::addBackgroundData(const QString &bgPath) { - qDebug() << __LINE__ << __FUNCTION__; +// qDebug() << __LINE__ << __FUNCTION__; if (bgPath.isEmpty()) { - qDebug() << __LINE__ << __FUNCTION__ << bgPath << ":Path is Null"; +// qDebug() << __LINE__ << __FUNCTION__ << bgPath << ":Path is Null"; return; } QFile file(bgPath); if (!file.exists()) { - qDebug() << __LINE__ << __FUNCTION__ << "Add background file isn't exists"; +// qDebug() << __LINE__ << __FUNCTION__ << "Add background file isn't exists"; return; } int width = QApplication::primaryScreen()->geometry().width(); @@ -942,7 +942,7 @@ void FullBackgroundWidget::addBackgroundData(const QString &bgPath) bool FullBackgroundWidget::existsBackgroundData(const QString &bgPath) { - qDebug() << __LINE__ << __FUNCTION__; +// qDebug() << __LINE__ << __FUNCTION__; int width = QApplication::primaryScreen()->geometry().width(); int height = QApplication::primaryScreen()->geometry().height(); @@ -954,7 +954,7 @@ bool FullBackgroundWidget::existsBackgroundData(const QString &bgPath) void FullBackgroundWidget::onAddUserBackground(const QString &strUserName) { - qDebug() << __LINE__ << __FUNCTION__; +// qDebug() << __LINE__ << __FUNCTION__; FullBackgroundWidget::m_loadingOneBackgroundFuture = QtConcurrent::run([=](){ for (UserInfoPtr userInfo : m_modelLockDialog->usersInfo()) diff --git a/src/widgets/lockwidget.cpp b/src/widgets/lockwidget.cpp index be236d5..52de787 100644 --- a/src/widgets/lockwidget.cpp +++ b/src/widgets/lockwidget.cpp @@ -232,45 +232,48 @@ void LockWidget::keyReleaseEvent(QKeyEvent *e) onShowVirtualKeyboard(); } - // 监听按键事件实现快捷键功能 - switch (e->key()) { - case Qt::Key_VolumeMute: - Q_EMIT m_modelLockDialog->usdExternalDoAction(MIC_MUTE_KEY); - break; - case Qt::Key_VolumeDown: - Q_EMIT m_modelLockDialog->usdExternalDoAction(VOLUME_DOWN_KEY); - break; - case Qt::Key_VolumeUp: - Q_EMIT m_modelLockDialog->usdExternalDoAction(VOLUME_UP_KEY); - break; - case Qt::Key_MonBrightnessUp: - Q_EMIT m_modelLockDialog->usdExternalDoAction(BRIGHT_UP_KEY); - break; - case Qt::Key_MonBrightnessDown: - Q_EMIT m_modelLockDialog->usdExternalDoAction(BRIGHT_DOWN_KEY); - break; - case Qt::Key_TouchpadOn: - Q_EMIT m_modelLockDialog->usdExternalDoAction(TOUCHPAD_ON_KEY); - break; - case Qt::Key_TouchpadOff: - Q_EMIT m_modelLockDialog->usdExternalDoAction(TOUCHPAD_OFF_KEY); - break; - default: - break; - } - // 实现锁屏截图功能 - QKeySequence keySequence = QKeySequence(e->modifiers() + e->key()); - if (keySequence == listFromString(m_areaScreenShot)) { - Q_EMIT m_modelLockDialog->usdExternalDoAction(AREA_SCREENSHOT_KEY); - } else if (keySequence == listFromString(m_areaScreenShot2)) { - Q_EMIT m_modelLockDialog->usdExternalDoAction(AREA_SCREENSHOT_KEY); - } else if (keySequence == listFromString(m_screenShot)) { - Q_EMIT m_modelLockDialog->usdExternalDoAction(SCREENSHOT_KEY); - } else if (keySequence == listFromString(m_screenShot2)) { - Q_EMIT m_modelLockDialog->usdExternalDoAction(SCREENSHOT_KEY); - } else if (keySequence == listFromString(m_windowScreenshot)) { - Q_EMIT m_modelLockDialog->usdExternalDoAction(WINDOW_SCREENSHOT_KEY); + if (m_modelLockDialog->isUseWayland()) { + // 监听按键事件实现快捷键功能 + switch (e->key()) { + case Qt::Key_VolumeMute: + Q_EMIT m_modelLockDialog->usdExternalDoAction(MIC_MUTE_KEY); + break; + case Qt::Key_VolumeDown: + Q_EMIT m_modelLockDialog->usdExternalDoAction(VOLUME_DOWN_KEY); + break; + case Qt::Key_VolumeUp: + Q_EMIT m_modelLockDialog->usdExternalDoAction(VOLUME_UP_KEY); + break; + case Qt::Key_MonBrightnessUp: + Q_EMIT m_modelLockDialog->usdExternalDoAction(BRIGHT_UP_KEY); + break; + case Qt::Key_MonBrightnessDown: + Q_EMIT m_modelLockDialog->usdExternalDoAction(BRIGHT_DOWN_KEY); + break; + case Qt::Key_TouchpadOn: + Q_EMIT m_modelLockDialog->usdExternalDoAction(TOUCHPAD_ON_KEY); + break; + case Qt::Key_TouchpadOff: + Q_EMIT m_modelLockDialog->usdExternalDoAction(TOUCHPAD_OFF_KEY); + break; + default: + break; + } + + // 实现锁屏截图功能 + QKeySequence keySequence = QKeySequence(e->modifiers() + e->key()); + if (keySequence == listFromString(m_areaScreenShot)) { + Q_EMIT m_modelLockDialog->usdExternalDoAction(AREA_SCREENSHOT_KEY); + } else if (keySequence == listFromString(m_areaScreenShot2)) { + Q_EMIT m_modelLockDialog->usdExternalDoAction(AREA_SCREENSHOT_KEY); + } else if (keySequence == listFromString(m_screenShot)) { + Q_EMIT m_modelLockDialog->usdExternalDoAction(SCREENSHOT_KEY); + } else if (keySequence == listFromString(m_screenShot2)) { + Q_EMIT m_modelLockDialog->usdExternalDoAction(SCREENSHOT_KEY); + } else if (keySequence == listFromString(m_windowScreenshot)) { + Q_EMIT m_modelLockDialog->usdExternalDoAction(WINDOW_SCREENSHOT_KEY); + } } }