diff --git a/src/effects/overview/overvieweffect.cpp b/src/effects/overview/overvieweffect.cpp index a01c17c650..7faea2e155 100644 --- a/src/effects/overview/overvieweffect.cpp +++ b/src/effects/overview/overvieweffect.cpp @@ -30,6 +30,18 @@ OverviewEffect::OverviewEffect() m_shutdownTimer->setSingleShot(true); connect(m_shutdownTimer, &QTimer::timeout, this, &OverviewEffect::realDeactivate); + m_realtimeToggleAction = new QAction(this); + connect(m_realtimeToggleAction, &QAction::triggered, this, [this]() { + if (isRunning() && m_partialActivationFactor > 0.5) { + activate(); + } else { + deactivate(); + } + m_partialActivationFactor = 0; + Q_EMIT gestureInProgressChanged(); + Q_EMIT partialActivationFactorChanged(); + }); + const QKeySequence defaultToggleShortcut = Qt::META | Qt::Key_W; m_toggleAction = new QAction(this); connect(m_toggleAction, &QAction::triggered, this, &OverviewEffect::toggle); @@ -39,10 +51,26 @@ OverviewEffect::OverviewEffect() KGlobalAccel::self()->setShortcut(m_toggleAction, {defaultToggleShortcut}); m_toggleShortcut = KGlobalAccel::self()->shortcut(m_toggleAction); effects->registerGlobalShortcut({defaultToggleShortcut}, m_toggleAction); - effects->registerTouchpadSwipeShortcut(SwipeDirection::Up, 4, m_toggleAction); effects->registerTouchscreenSwipeShortcut(SwipeDirection::Up, 3, m_toggleAction); effects->registerTouchscreenSwipeShortcut(SwipeDirection::Down, 3, m_toggleAction); + auto progressCallback = [this](qreal progress) { + if (m_status == Status::Active) { + return; + } + const bool wasInProgress = m_partialActivationFactor > 0; + m_partialActivationFactor = progress; + Q_EMIT partialActivationFactorChanged(); + if (!wasInProgress) { + Q_EMIT gestureInProgressChanged(); + } + if (!isRunning()) { + partialActivate(); + } + }; + + effects->registerRealtimeTouchpadSwipeShortcut(SwipeDirection::Up, 4, m_realtimeToggleAction, progressCallback); + connect(effects, &EffectsHandler::screenAboutToLock, this, &OverviewEffect::realDeactivate); initConfig(); @@ -90,7 +118,7 @@ void OverviewEffect::reconfigure(ReconfigureFlags) const QList touchActivateBorders = OverviewConfig::touchBorderActivate(); for (const int &border : touchActivateBorders) { m_touchBorderActivate.append(ElectricBorder(border)); - effects->registerRealtimeTouchBorder(ElectricBorder(border), m_toggleAction, [this](ElectricBorder border, const QSizeF &deltaProgress, const EffectScreen *screen) { + effects->registerRealtimeTouchBorder(ElectricBorder(border), m_realtimeToggleAction, [this](ElectricBorder border, const QSizeF &deltaProgress, const EffectScreen *screen) { Q_UNUSED(screen) if (m_status == Status::Active) { return; diff --git a/src/effects/overview/overvieweffect.h b/src/effects/overview/overvieweffect.h index af9c03acd4..979f23d2d4 100644 --- a/src/effects/overview/overvieweffect.h +++ b/src/effects/overview/overvieweffect.h @@ -71,6 +71,7 @@ private: QTimer *m_shutdownTimer; QAction *m_toggleAction = nullptr; + QAction *m_realtimeToggleAction = nullptr; QList m_toggleShortcut; QList m_borderActivate; QList m_touchBorderActivate; diff --git a/src/effects/presentwindows/presentwindows.cpp b/src/effects/presentwindows/presentwindows.cpp index e7ff5e5dd5..7dfdd14234 100644 --- a/src/effects/presentwindows/presentwindows.cpp +++ b/src/effects/presentwindows/presentwindows.cpp @@ -82,9 +82,17 @@ PresentWindowsEffect::PresentWindowsEffect() KGlobalAccel::self()->setShortcut(exposeAllAction, QList() << (Qt::CTRL | Qt::Key_F10) << Qt::Key_LaunchC); shortcutAll = KGlobalAccel::self()->shortcut(exposeAllAction); effects->registerGlobalShortcut(Qt::CTRL + Qt::Key_F10, exposeAllAction); - effects->registerTouchpadSwipeShortcut(SwipeDirection::Down, 4, exposeAllAction); connect(exposeAllAction, &QAction::triggered, this, &PresentWindowsEffect::toggleActiveAllDesktops); + effects->registerRealtimeTouchpadSwipeShortcut(SwipeDirection::Down, 4, new QAction(this), [this](qreal progress) { + m_mode = ModeAllDesktops; + if (progress > .2 && !m_activated) { + setActive(true); + } else if (progress <= .2 && m_activated) { + setActive(false); + } + }); + QAction *exposeClassAction = m_exposeClassAction; exposeClassAction->setObjectName(QStringLiteral("ExposeClass")); exposeClassAction->setText(i18n("Toggle Present Windows (Window class)"));