mirror of
https://invent.kde.org/system/dolphin
synced 2024-10-02 14:45:04 +00:00
Fix delete action switching via 'Shift' when sub-context-menu is open
Switching the 'Move to Trash' action to 'Delete' using the shift key does not work when the mouse hovers a submenu. This fix resolves the issue by using an event filter instead of the key event functions. BUG: 425997
This commit is contained in:
parent
c3b238bbe9
commit
9e4642d435
|
@ -61,6 +61,8 @@ DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent,
|
|||
// or the items itself. To increase the performance both lists are cached.
|
||||
const DolphinView* view = m_mainWindow->activeViewContainer()->view();
|
||||
m_selectedItems = view->selectedItems();
|
||||
|
||||
installEventFilter(this);
|
||||
}
|
||||
|
||||
DolphinContextMenu::~DolphinContextMenu()
|
||||
|
@ -110,20 +112,28 @@ DolphinContextMenu::Command DolphinContextMenu::open()
|
|||
return m_command;
|
||||
}
|
||||
|
||||
void DolphinContextMenu::keyPressEvent(QKeyEvent *ev)
|
||||
void DolphinContextMenu::childEvent(QChildEvent* event)
|
||||
{
|
||||
if (m_removeAction && ev->key() == Qt::Key_Shift) {
|
||||
m_removeAction->update(DolphinRemoveAction::ShiftState::Pressed);
|
||||
if(event->added()) {
|
||||
event->child()->installEventFilter(this);
|
||||
}
|
||||
QMenu::keyPressEvent(ev);
|
||||
QMenu::childEvent(event);
|
||||
}
|
||||
|
||||
void DolphinContextMenu::keyReleaseEvent(QKeyEvent *ev)
|
||||
bool DolphinContextMenu::eventFilter(QObject* dest, QEvent* event)
|
||||
{
|
||||
if (m_removeAction && ev->key() == Qt::Key_Shift) {
|
||||
m_removeAction->update(DolphinRemoveAction::ShiftState::Released);
|
||||
if(event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) {
|
||||
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
|
||||
if(m_removeAction && keyEvent->key() == Qt::Key_Shift) {
|
||||
if(event->type() == QEvent::KeyPress) {
|
||||
m_removeAction->update(DolphinRemoveAction::ShiftState::Pressed);
|
||||
} else {
|
||||
m_removeAction->update(DolphinRemoveAction::ShiftState::Released);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
QMenu::keyReleaseEvent(ev);
|
||||
return QMenu::eventFilter(dest, event);
|
||||
}
|
||||
|
||||
void DolphinContextMenu::openTrashContextMenu()
|
||||
|
@ -198,6 +208,7 @@ void DolphinContextMenu::addDirectoryItemContextMenu(KFileItemActions &fileItemA
|
|||
QMenu* menu = newFileMenu->menu();
|
||||
menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
|
||||
menu->setIcon(QIcon::fromTheme(QStringLiteral("document-new")));
|
||||
menu->setParent(this, Qt::Popup);
|
||||
addMenu(menu);
|
||||
|
||||
addSeparator();
|
||||
|
|
|
@ -74,8 +74,8 @@ public:
|
|||
Command open();
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *ev) override;
|
||||
void keyReleaseEvent(QKeyEvent *ev) override;
|
||||
void childEvent(QChildEvent* event) override;
|
||||
bool eventFilter(QObject* dest, QEvent* event) override;
|
||||
|
||||
private:
|
||||
void openTrashContextMenu();
|
||||
|
|
Loading…
Reference in a new issue