/*************************************************************************** * Copyright (C) 2013 by Dawit Alemayehu #include DolphinRemoveAction::DolphinRemoveAction(QObject* parent, KActionCollection* collection) : QAction(parent), m_collection(collection) { update(); connect(this, &DolphinRemoveAction::triggered, this, &DolphinRemoveAction::slotRemoveActionTriggered); } void DolphinRemoveAction::slotRemoveActionTriggered() { if (m_action) { m_action->trigger(); } } void DolphinRemoveAction::update() { 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->keyboardModifiers() & Qt::ShiftModifier) { m_action = m_collection ? m_collection->action("delete") : 0; setText(i18nc("@action:inmenu", "&Delete")); } else { m_action = m_collection ? m_collection->action("move_to_trash") : 0; setText(i18nc("@action:inmenu", "&Move to Trash")); } if (m_action) { setIcon(m_action->icon()); setShortcuts(m_action->shortcuts()); setEnabled(m_action->isEnabled()); } }