overview: Make the deactivation gesture to be the inverse of the activation
It is not intuitive that one needs to use the same gesture to activate and deactivate an effect. Make the deactivation the inverse of the activation instead.
This commit is contained in:
parent
6cf26c615a
commit
4c3d3053ab
2 changed files with 26 additions and 12 deletions
|
@ -33,20 +33,24 @@ OverviewEffect::OverviewEffect()
|
|||
KGlobalAccel::self()->setShortcut(m_toggleAction, {defaultToggleShortcut});
|
||||
m_toggleShortcut = KGlobalAccel::self()->shortcut(m_toggleAction);
|
||||
|
||||
m_realtimeToggleAction = new QAction(this);
|
||||
connect(m_realtimeToggleAction, &QAction::triggered, this, [this]() {
|
||||
m_activateAction = new QAction(this);
|
||||
connect(m_activateAction, &QAction::triggered, this, [this]() {
|
||||
if (m_status == Status::Activating) {
|
||||
if (m_partialActivationFactor > 0.5) {
|
||||
activate();
|
||||
} else {
|
||||
cancelPartialActivate();
|
||||
}
|
||||
}
|
||||
});
|
||||
m_deactivateAction = new QAction(this);
|
||||
connect(m_deactivateAction, &QAction::triggered, this, [this]() {
|
||||
if (m_status == Status::Deactivating) {
|
||||
if (m_partialActivationFactor < 0.5) {
|
||||
deactivate();
|
||||
} else {
|
||||
cancelPartialDeactivate();
|
||||
}
|
||||
} else if (m_status == Status::Activating) {
|
||||
if (m_partialActivationFactor > 0.5) {
|
||||
activate();
|
||||
} else {
|
||||
cancelPartialActivate();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -57,6 +61,13 @@ OverviewEffect::OverviewEffect()
|
|||
case Status::Activating:
|
||||
partialActivate(progress);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
auto progressCallbackInv = [this](qreal progress) {
|
||||
if (!effects->hasActiveFullScreenEffect() || effects->activeFullScreenEffect() == this) {
|
||||
switch (m_status) {
|
||||
case Status::Active:
|
||||
case Status::Deactivating:
|
||||
partialDeactivate(progress);
|
||||
|
@ -65,8 +76,10 @@ OverviewEffect::OverviewEffect()
|
|||
}
|
||||
};
|
||||
|
||||
effects->registerTouchpadPinchShortcut(PinchDirection::Contracting, 4, m_realtimeToggleAction, progressCallback);
|
||||
effects->registerTouchscreenSwipeShortcut(SwipeDirection::Up, 3, m_realtimeToggleAction, progressCallback);
|
||||
effects->registerTouchpadPinchShortcut(PinchDirection::Contracting, 4, m_activateAction, progressCallback);
|
||||
effects->registerTouchpadPinchShortcut(PinchDirection::Expanding, 4, m_deactivateAction, progressCallbackInv);
|
||||
effects->registerTouchscreenSwipeShortcut(SwipeDirection::Up, 3, m_activateAction, progressCallback);
|
||||
effects->registerTouchscreenSwipeShortcut(SwipeDirection::Down, 3, m_deactivateAction, progressCallbackInv);
|
||||
|
||||
connect(effects, &EffectsHandler::screenAboutToLock, this, &OverviewEffect::realDeactivate);
|
||||
|
||||
|
@ -106,7 +119,7 @@ void OverviewEffect::reconfigure(ReconfigureFlags)
|
|||
const QList<int> touchActivateBorders = OverviewConfig::touchBorderActivate();
|
||||
for (const int &border : touchActivateBorders) {
|
||||
m_touchBorderActivate.append(ElectricBorder(border));
|
||||
effects->registerRealtimeTouchBorder(ElectricBorder(border), m_realtimeToggleAction, [this](ElectricBorder border, const QPointF &deltaProgress, const EffectScreen *screen) {
|
||||
effects->registerRealtimeTouchBorder(ElectricBorder(border), m_deactivateAction, [this](ElectricBorder border, const QPointF &deltaProgress, const EffectScreen *screen) {
|
||||
if (m_status == Status::Active) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,8 @@ private:
|
|||
|
||||
QTimer *m_shutdownTimer;
|
||||
QAction *m_toggleAction = nullptr;
|
||||
QAction *m_realtimeToggleAction = nullptr;
|
||||
QAction *m_deactivateAction = nullptr;
|
||||
QAction *m_activateAction = nullptr;
|
||||
QList<QKeySequence> m_toggleShortcut;
|
||||
QList<ElectricBorder> m_borderActivate;
|
||||
QList<ElectricBorder> m_touchBorderActivate;
|
||||
|
|
Loading…
Reference in a new issue