X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/39fcc8945051365ae240e0bf92fcb3403d77caed..2fd85facf85b39f84eeada10bcf80060bb72ab51:/src/dolphinremoveaction.cpp diff --git a/src/dolphinremoveaction.cpp b/src/dolphinremoveaction.cpp index 7e8a353f0..ce3059934 100644 --- a/src/dolphinremoveaction.cpp +++ b/src/dolphinremoveaction.cpp @@ -1,5 +1,6 @@ /*************************************************************************** - * Copyright (C) 2013 by Dawit Alemayehu * + * Copyright (C) 2017 by Elvis Angelaccio * * * * 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,21 +40,31 @@ void DolphinRemoveAction::slotRemoveActionTriggered() } } -void DolphinRemoveAction::update() +void DolphinRemoveAction::update(ShiftState shiftState) { - Q_ASSERT(m_collection); - // Using setText(action->text()) does not apply the &-shortcut. - // This is only done until the original action has been shown at least once. To - // bypass this issue, the text and &-shortcut is applied manually. - if (qApp->queryKeyboardModifiers() & Qt::ShiftModifier) { - m_action = m_collection ? m_collection->action(KStandardAction::name(KStandardAction::DeleteFile)) : 0; - setText(i18nc("@action:inmenu", "&Delete")); - } else { - m_action = m_collection ? m_collection->action(KStandardAction::name(KStandardAction::MoveToTrash)) : 0; - setText(i18nc("@action:inmenu", "&Move to Trash")); + 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) { + setText(m_action->text()); setIcon(m_action->icon()); m_collection->setDefaultShortcuts(this, m_action->shortcuts()); setEnabled(m_action->isEnabled());