Send a Qt::Key_PowerDown when long pressing the power button
Summary: This will be useful to be able to show a menu on long press and just lock the screen on normal press, especially useful on phones and tablets. Test Plan: Could not test much because on laptops doesn't work. Would need more investigation. discussed further on the plasma mailing list. Reviewers: #plasma, davidedmundson Reviewed By: #plasma, davidedmundson Subscribers: z3ntu, davidedmundson, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D26899
This commit is contained in:
parent
6fe7f9281a
commit
b9423a033c
1 changed files with 13 additions and 1 deletions
14
input.cpp
14
input.cpp
|
@ -759,7 +759,16 @@ public:
|
|||
return input()->shortcuts()->processAxis(event->modifiers(), direction);
|
||||
}
|
||||
bool keyEvent(QKeyEvent *event) override {
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
if (event->key() == Qt::Key_PowerOff) {
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
m_powerOffPress = event->timestamp();
|
||||
} else if (event->type() == QEvent::KeyRelease) {
|
||||
const uint duration = (event->timestamp() - m_powerOffPress);
|
||||
const Qt::Key key = duration > 1000 ? Qt::Key_PowerDown : Qt::Key_PowerOff;
|
||||
const auto shortcuts = static_cast<KeyEvent*>(event)->modifiersRelevantForGlobalShortcuts();
|
||||
return input()->shortcuts()->processKey(shortcuts, key | (event->key() & ~Qt::KeyboardModifierMask));
|
||||
}
|
||||
} else if (event->type() == QEvent::KeyPress) {
|
||||
return input()->shortcuts()->processKey(static_cast<KeyEvent*>(event)->modifiersRelevantForGlobalShortcuts(), event->key());
|
||||
}
|
||||
return false;
|
||||
|
@ -784,6 +793,9 @@ public:
|
|||
input()->shortcuts()->processSwipeEnd();
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
uint m_powerOffPress;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue