Before this patch, the shift-action modifier in context menus did not
work when a sub-context menu is open, that does not have the main
context menu as its parent.
The new fix installs an event filter on QApplication whenever a new
context menu is opened to make the context menu aware of shift-presses
even when a sub-context menu is in focus.
BUG: 425997
FIXED-IN: 21.04
const DolphinView* view = m_mainWindow->activeViewContainer()->view();
m_selectedItems = view->selectedItems();
const DolphinView* view = m_mainWindow->activeViewContainer()->view();
m_selectedItems = view->selectedItems();
- installEventFilter(this);
+ QApplication::instance()->installEventFilter(this);
}
DolphinContextMenu::~DolphinContextMenu()
}
DolphinContextMenu::~DolphinContextMenu()
-void DolphinContextMenu::childEvent(QChildEvent* event)
+bool DolphinContextMenu::eventFilter(QObject* object, QEvent* event)
- if(event->added()) {
- event->child()->installEventFilter(this);
- }
- QMenu::childEvent(event);
-}
-bool DolphinContextMenu::eventFilter(QObject* dest, QEvent* event)
-{
if(event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) {
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
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) {
+
+ 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);
}
m_removeAction->update(DolphinRemoveAction::ShiftState::Pressed);
} else {
m_removeAction->update(DolphinRemoveAction::ShiftState::Released);
}
- return QMenu::eventFilter(dest, event);
}
void DolphinContextMenu::openTrashContextMenu()
}
void DolphinContextMenu::openTrashContextMenu()
Command open();
protected:
Command open();
protected:
- void childEvent(QChildEvent* event) override;
- bool eventFilter(QObject* dest, QEvent* event) override;
+ bool eventFilter(QObject* object, QEvent* event) override;
private:
void openTrashContextMenu();
private:
void openTrashContextMenu();