X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/53a778c1ebab4473da8ae7b18fd2f2ac75b9690a..dd7f3fb783a2164e282d88140f301bf8c0af9e5b:/src/dolphincontextmenu.cpp diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index 4b287981c..01e1a4109 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -31,9 +31,9 @@ #include #include #include -#include #include #include +#include #include #include @@ -64,7 +64,7 @@ DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent, const DolphinView* view = m_mainWindow->activeViewContainer()->view(); m_selectedItems = view->selectedItems(); - installEventFilter(this); + QApplication::instance()->installEventFilter(this); static_cast(m_mainWindow->actionCollection()-> action(QStringLiteral("hamburger_menu")))->addToMenu(this); @@ -116,28 +116,23 @@ DolphinContextMenu::Command DolphinContextMenu::open() return m_command; } -void DolphinContextMenu::childEvent(QChildEvent* event) +bool DolphinContextMenu::eventFilter(QObject* object, QEvent* event) { - if(event->added()) { - event->child()->installEventFilter(this); - } - QMenu::childEvent(event); -} + Q_UNUSED(object) -bool DolphinContextMenu::eventFilter(QObject* dest, QEvent* event) -{ if(event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) { QKeyEvent* keyEvent = static_cast(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); } - return true; } } - return QMenu::eventFilter(dest, event); + + return false; } void DolphinContextMenu::openTrashContextMenu() @@ -211,7 +206,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->setIcon(QIcon::fromTheme(QStringLiteral("list-add"))); addMenu(menu); addSeparator(); @@ -228,6 +223,11 @@ void DolphinContextMenu::openItemContextMenu() KFileItemActions fileItemActions; fileItemActions.setParentWidget(m_mainWindow); +#if KIO_VERSION >= QT_VERSION_CHECK(5, 82, 0) + connect(&fileItemActions, &KFileItemActions::error, this, [this](const QString &errorMessage) { + m_mainWindow->activeViewContainer()->showMessage(errorMessage, DolphinViewContainer::Error); + }); +#endif fileItemActions.setItemListProperties(selectedItemsProps); if (m_selectedItems.count() == 1) { @@ -319,6 +319,11 @@ void DolphinContextMenu::openViewportContextMenu() const KFileItemListProperties baseUrlProperties(KFileItemList() << baseFileItem()); KFileItemActions fileItemActions; fileItemActions.setParentWidget(m_mainWindow); +#if KIO_VERSION >= QT_VERSION_CHECK(5, 82, 0) + connect(&fileItemActions, &KFileItemActions::error, this, [this](const QString &errorMessage) { + m_mainWindow->activeViewContainer()->showMessage(errorMessage, DolphinViewContainer::Error); + }); +#endif fileItemActions.setItemListProperties(baseUrlProperties); // Set up and insert 'Create New' menu