diff options
| author | Elvis Angelaccio <[email protected]> | 2017-08-24 18:33:27 +0200 |
|---|---|---|
| committer | Elvis Angelaccio <[email protected]> | 2017-09-07 21:31:42 +0200 |
| commit | 2fd85facf85b39f84eeada10bcf80060bb72ab51 (patch) | |
| tree | f72067d82a5f6f15486cbb6ae4f7aa806c4ff5a2 /src/dolphinremoveaction.cpp | |
| parent | 735b171451a05cdda77f711ff1ef23408e9389ed (diff) | |
Fix DolphinRemoveAction Shift toggling on Wayland
QGuiApplication::queryKeyboardModifiers() does not work on Wayland [1].
We don't need it in the first place, since we already know (thanks to
the key events) whether Shift has been pressed or released.
So we can just pass this information to DolphinRemoveAction::update().
BUG: 354301
[1]: https://bugreports.qt.io/browse/QTBUG-62786
Differential Revision: https://phabricator.kde.org/D7519
Diffstat (limited to 'src/dolphinremoveaction.cpp')
| -rw-r--r-- | src/dolphinremoveaction.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/dolphinremoveaction.cpp b/src/dolphinremoveaction.cpp index c471b2df6..ce3059934 100644 --- a/src/dolphinremoveaction.cpp +++ b/src/dolphinremoveaction.cpp @@ -1,5 +1,6 @@ /*************************************************************************** - * Copyright (C) 2013 by Dawit Alemayehu <[email protected] * + * Copyright (C) 2013 by Dawit Alemayehu <[email protected]> * + * Copyright (C) 2017 by Elvis Angelaccio <[email protected]> * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -39,13 +40,27 @@ void DolphinRemoveAction::slotRemoveActionTriggered() } } -void DolphinRemoveAction::update() +void DolphinRemoveAction::update(ShiftState shiftState) { - Q_ASSERT(m_collection); - if (qApp->queryKeyboardModifiers() & Qt::ShiftModifier) { - m_action = m_collection ? m_collection->action(KStandardAction::name(KStandardAction::DeleteFile)) : 0; - } else { - m_action = m_collection ? m_collection->action(KStandardAction::name(KStandardAction::MoveToTrash)) : 0; + if (!m_collection) { + m_action = nullptr; + return; + } + + if (shiftState == ShiftState::Unknown) { + shiftState = QGuiApplication::keyboardModifiers() & Qt::ShiftModifier ? ShiftState::Pressed : ShiftState::Released; + } + + switch (shiftState) { + case ShiftState::Pressed: + m_action = m_collection->action(KStandardAction::name(KStandardAction::DeleteFile)); + break; + case ShiftState::Released: + m_action = m_collection->action(KStandardAction::name(KStandardAction::MoveToTrash)); + break; + case ShiftState::Unknown: + Q_UNREACHABLE(); + break; } if (m_action) { |
