X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/d1963d22718380854d8a948f64bc5e0c4c8813d4..5593c252e8d9638c86dcc2bb9edd394ea14f8ba1:/src/dolphincontextmenu.cpp diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index bb26c7aae..dfec76144 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -24,48 +24,42 @@ #include "dolphinnewfilemenu.h" #include "dolphinviewcontainer.h" #include "dolphin_generalsettings.h" +#include "dolphinremoveaction.h" #include -#include -#include -#include +#include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include -#include #include -#include -#include #include -#include -#include +#include #include -#include #include +#include +#include +#include +#include +#include + #include #include -#include -#include -#include #include "views/dolphinview.h" #include "views/viewmodecontroller.h" -K_GLOBAL_STATIC(KModifierKeyInfo, m_keyInfo) - DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent, const QPoint& pos, const KFileItem& fileInfo, - const KUrl& baseUrl) : - QObject(parent), + const QUrl& baseUrl) : + QMenu(parent), m_pos(pos), m_mainWindow(parent), m_fileInfo(fileInfo), @@ -76,37 +70,19 @@ DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent, m_context(NoContext), m_copyToMenu(parent), m_customActions(), - m_popup(0), m_command(None), - m_shiftPressed(false), m_removeAction(0) { // The context menu either accesses the URLs of the selected items // or the items itself. To increase the performance both lists are cached. const DolphinView* view = m_mainWindow->activeViewContainer()->view(); m_selectedItems = view->selectedItems(); - - if (m_keyInfo) { - if (m_keyInfo->isKeyPressed(Qt::Key_Shift) || m_keyInfo->isKeyLatched(Qt::Key_Shift)) { - m_shiftPressed = true; - } - connect(m_keyInfo, SIGNAL(keyPressed(Qt::Key,bool)), - this, SLOT(slotKeyModifierPressed(Qt::Key,bool))); - } - - m_removeAction = new QAction(this); - connect(m_removeAction, SIGNAL(triggered()), this, SLOT(slotRemoveActionTriggered())); - - m_popup = new KMenu(m_mainWindow); } DolphinContextMenu::~DolphinContextMenu() { delete m_selectedItemsProperties; m_selectedItemsProperties = 0; - - delete m_popup; - m_popup = 0; } void DolphinContextMenu::setCustomActions(const QList& actions) @@ -117,7 +93,7 @@ void DolphinContextMenu::setCustomActions(const QList& actions) DolphinContextMenu::Command DolphinContextMenu::open() { // get the context information - if (m_baseUrl.protocol() == QLatin1String("trash")) { + if (m_baseUrl.scheme() == QLatin1String("trash")) { m_context |= TrashContext; } @@ -143,48 +119,46 @@ DolphinContextMenu::Command DolphinContextMenu::open() return m_command; } -void DolphinContextMenu::initializeModifierKeyInfo() +void DolphinContextMenu::keyPressEvent(QKeyEvent *ev) { - // Access m_keyInfo, so that it gets instantiated by - // K_GLOBAL_STATIC - KModifierKeyInfo* keyInfo = m_keyInfo; - Q_UNUSED(keyInfo); -} - -void DolphinContextMenu::slotKeyModifierPressed(Qt::Key key, bool pressed) -{ - m_shiftPressed = (key == Qt::Key_Shift) && pressed; - updateRemoveAction(); + if (m_removeAction && ev->key() == Qt::Key_Shift) { + m_removeAction->update(); + } + QMenu::keyPressEvent(ev); } -void DolphinContextMenu::slotRemoveActionTriggered() +void DolphinContextMenu::keyReleaseEvent(QKeyEvent *ev) { - const KActionCollection* collection = m_mainWindow->actionCollection(); - if (moveToTrash()) { - collection->action("move_to_trash")->trigger(); - } else { - collection->action("delete")->trigger(); + if (m_removeAction && ev->key() == Qt::Key_Shift) { + m_removeAction->update(); } + QMenu::keyReleaseEvent(ev); } void DolphinContextMenu::openTrashContextMenu() { Q_ASSERT(m_context & TrashContext); - QAction* emptyTrashAction = new QAction(KIcon("trash-empty"), i18nc("@action:inmenu", "Empty Trash"), m_popup); - KConfig trashConfig("trashrc", KConfig::SimpleConfig); + QAction* emptyTrashAction = new QAction(QIcon::fromTheme(QStringLiteral("trash-empty")), i18nc("@action:inmenu", "Empty Trash"), this); + KConfig trashConfig(QStringLiteral("trashrc"), KConfig::SimpleConfig); emptyTrashAction->setEnabled(!trashConfig.group("Status").readEntry("Empty", true)); - m_popup->addAction(emptyTrashAction); + addAction(emptyTrashAction); addCustomActions(); - QAction* propertiesAction = m_mainWindow->actionCollection()->action("properties"); - m_popup->addAction(propertiesAction); + QAction* propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties")); + addAction(propertiesAction); addShowMenuBarAction(); - if (m_popup->exec(m_pos) == emptyTrashAction) { - KonqOperations::emptyTrash(m_mainWindow); + if (exec(m_pos) == emptyTrashAction) { + KIO::JobUiDelegate uiDelegate; + uiDelegate.setWindow(m_mainWindow); + if (uiDelegate.askDeleteConfirmation(QList(), KIO::JobUiDelegate::EmptyTrash, KIO::JobUiDelegate::DefaultConfirmation)) { + KIO::Job* job = KIO::emptyTrash(); + KJobWidgets::setWindow(job, m_mainWindow); + job->ui()->setAutoErrorHandlingEnabled(true); + } } } @@ -194,21 +168,24 @@ void DolphinContextMenu::openTrashItemContextMenu() Q_ASSERT(m_context & ItemContext); QAction* restoreAction = new QAction(i18nc("@action:inmenu", "Restore"), m_mainWindow); - m_popup->addAction(restoreAction); + addAction(restoreAction); - QAction* deleteAction = m_mainWindow->actionCollection()->action("delete"); - m_popup->addAction(deleteAction); + QAction* deleteAction = m_mainWindow->actionCollection()->action(QStringLiteral("delete")); + addAction(deleteAction); - QAction* propertiesAction = m_mainWindow->actionCollection()->action("properties"); - m_popup->addAction(propertiesAction); + QAction* propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties")); + addAction(propertiesAction); - if (m_popup->exec(m_pos) == restoreAction) { - KUrl::List selectedUrls; + if (exec(m_pos) == restoreAction) { + QList selectedUrls; + selectedUrls.reserve(m_selectedItems.count()); foreach (const KFileItem &item, m_selectedItems) { selectedUrls.append(item.url()); } - KonqOperations::restoreTrashedItems(selectedUrls, m_mainWindow); + KIO::RestoreJob *job = KIO::restoreFromTrash(selectedUrls); + KJobWidgets::setWindow(job, m_mainWindow); + job->uiDelegate()->setAutoErrorHandlingEnabled(true); } } @@ -216,62 +193,92 @@ void DolphinContextMenu::openItemContextMenu() { Q_ASSERT(!m_fileInfo.isNull()); + QAction* openParentAction = 0; QAction* openParentInNewWindowAction = 0; QAction* openParentInNewTabAction = 0; QAction* addToPlacesAction = 0; + const KFileItemListProperties& selectedItemsProps = selectedItemsProperties(); + if (m_selectedItems.count() == 1) { if (m_fileInfo.isDir()) { // setup 'Create New' menu - DolphinNewFileMenu* newFileMenu = new DolphinNewFileMenu(m_mainWindow); + DolphinNewFileMenu* newFileMenu = new DolphinNewFileMenu(m_mainWindow->actionCollection(), m_mainWindow); const DolphinView* view = m_mainWindow->activeViewContainer()->view(); newFileMenu->setViewShowsHiddenFiles(view->hiddenFilesShown()); newFileMenu->checkUpToDate(); newFileMenu->setPopupFiles(m_fileInfo.url()); - newFileMenu->setEnabled(selectedItemsProperties().supportsWriting()); - connect(newFileMenu, SIGNAL(fileCreated(KUrl)), newFileMenu, SLOT(deleteLater())); - connect(newFileMenu, SIGNAL(directoryCreated(KUrl)), newFileMenu, SLOT(deleteLater())); + newFileMenu->setEnabled(selectedItemsProps.supportsWriting()); + connect(newFileMenu, &DolphinNewFileMenu::fileCreated, newFileMenu, &DolphinNewFileMenu::deleteLater); + connect(newFileMenu, &DolphinNewFileMenu::directoryCreated, newFileMenu, &DolphinNewFileMenu::deleteLater); - KMenu* menu = newFileMenu->menu(); + QMenu* menu = newFileMenu->menu(); menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New")); - menu->setIcon(KIcon("document-new")); - m_popup->addMenu(menu); - m_popup->addSeparator(); + menu->setIcon(QIcon::fromTheme(QStringLiteral("document-new"))); + addMenu(menu); + addSeparator(); // insert 'Open in new window' and 'Open in new tab' entries - m_popup->addAction(m_mainWindow->actionCollection()->action("open_in_new_window")); - m_popup->addAction(m_mainWindow->actionCollection()->action("open_in_new_tab")); + addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_new_window"))); + addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_new_tab"))); // insert 'Add to Places' entry if (!placeExists(m_fileInfo.url())) { - addToPlacesAction = m_popup->addAction(KIcon("bookmark-new"), + addToPlacesAction = addAction(QIcon::fromTheme(QStringLiteral("bookmark-new")), i18nc("@action:inmenu Add selected folder to places", "Add to Places")); } - m_popup->addSeparator(); - } else if (m_baseUrl.protocol().contains("search")) { - openParentInNewWindowAction = new QAction(KIcon("window-new"), + addSeparator(); + } else if (m_baseUrl.scheme().contains(QStringLiteral("search")) || m_baseUrl.scheme().contains(QStringLiteral("timeline"))) { + openParentAction = new QAction(QIcon::fromTheme(QStringLiteral("document-open-folder")), + i18nc("@action:inmenu", + "Open Path"), + this); + addAction(openParentAction); + + openParentInNewWindowAction = new QAction(QIcon::fromTheme(QStringLiteral("window-new")), i18nc("@action:inmenu", "Open Path in New Window"), this); - m_popup->addAction(openParentInNewWindowAction); + addAction(openParentInNewWindowAction); - openParentInNewTabAction = new QAction(KIcon("tab-new"), + openParentInNewTabAction = new QAction(QIcon::fromTheme(QStringLiteral("tab-new")), i18nc("@action:inmenu", "Open Path in New Tab"), this); - m_popup->addAction(openParentInNewTabAction); + addAction(openParentInNewTabAction); + + addSeparator(); + } else if (!DolphinView::openItemAsFolderUrl(m_fileInfo).isEmpty()) { + // insert 'Open in new window' and 'Open in new tab' entries + addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_new_window"))); + addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_new_tab"))); - m_popup->addSeparator(); + addSeparator(); + } + } else { + bool selectionHasOnlyDirs = true; + foreach (const KFileItem& item, m_selectedItems) { + const QUrl& url = DolphinView::openItemAsFolderUrl(item); + if (url.isEmpty()) { + selectionHasOnlyDirs = false; + break; + } + } + + if (selectionHasOnlyDirs) { + // insert 'Open in new tab' entry + addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_new_tabs"))); + addSeparator(); } } - insertDefaultItemActions(); + insertDefaultItemActions(selectedItemsProps); - m_popup->addSeparator(); + addSeparator(); KFileItemActions fileItemActions; - fileItemActions.setItemListProperties(selectedItemsProperties()); + fileItemActions.setItemListProperties(selectedItemsProps); addServiceActions(fileItemActions); addFileItemPluginActions(); @@ -280,25 +287,29 @@ void DolphinContextMenu::openItemContextMenu() // insert 'Copy To' and 'Move To' sub menus if (GeneralSettings::showCopyMoveMenu()) { - m_copyToMenu.setItems(m_selectedItems); - m_copyToMenu.setReadOnly(!selectedItemsProperties().supportsWriting()); - m_copyToMenu.addActionsTo(m_popup); + m_copyToMenu.setUrls(m_selectedItems.urlList()); + m_copyToMenu.setReadOnly(!selectedItemsProps.supportsWriting()); + m_copyToMenu.setAutoErrorHandlingEnabled(true); + m_copyToMenu.addActionsTo(this); } // insert 'Properties...' entry - QAction* propertiesAction = m_mainWindow->actionCollection()->action("properties"); - m_popup->addAction(propertiesAction); + QAction* propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties")); + addAction(propertiesAction); - QAction* activatedAction = m_popup->exec(m_pos); + QAction* activatedAction = exec(m_pos); if (activatedAction) { if (activatedAction == addToPlacesAction) { - const KUrl selectedUrl(m_fileInfo.url()); + const QUrl selectedUrl(m_fileInfo.url()); if (selectedUrl.isValid()) { PlacesItemModel model; const QString text = selectedUrl.fileName(); PlacesItem* item = model.createPlacesItem(text, selectedUrl); model.appendItemToGroup(item); + model.saveBookmarks(); } + } else if (activatedAction == openParentAction) { + m_command = OpenParentFolder; } else if (activatedAction == openParentInNewWindowAction) { m_command = OpenParentFolderInNewWindow; } else if (activatedAction == openParentInNewTabAction) { @@ -315,26 +326,26 @@ void DolphinContextMenu::openViewportContextMenu() newFileMenu->setViewShowsHiddenFiles(view->hiddenFilesShown()); newFileMenu->checkUpToDate(); newFileMenu->setPopupFiles(m_baseUrl); - m_popup->addMenu(newFileMenu->menu()); - m_popup->addSeparator(); + addMenu(newFileMenu->menu()); + addSeparator(); // Insert 'New Window' and 'New Tab' entries. Don't use "open_in_new_window" and // "open_in_new_tab" here, as the current selection should get ignored. - m_popup->addAction(m_mainWindow->actionCollection()->action("new_window")); - m_popup->addAction(m_mainWindow->actionCollection()->action("new_tab")); + addAction(m_mainWindow->actionCollection()->action(QStringLiteral("new_window"))); + addAction(m_mainWindow->actionCollection()->action(QStringLiteral("new_tab"))); // Insert 'Add to Places' entry if exactly one item is selected QAction* addToPlacesAction = 0; if (!placeExists(m_mainWindow->activeViewContainer()->url())) { - addToPlacesAction = m_popup->addAction(KIcon("bookmark-new"), + addToPlacesAction = addAction(QIcon::fromTheme(QStringLiteral("bookmark-new")), i18nc("@action:inmenu Add current folder to places", "Add to Places")); } - m_popup->addSeparator(); + addSeparator(); QAction* pasteAction = createPasteAction(); - m_popup->addAction(pasteAction); - m_popup->addSeparator(); + addAction(pasteAction); + addSeparator(); // Insert service actions const KFileItemListProperties baseUrlProperties(KFileItemList() << baseFileItem()); @@ -348,12 +359,12 @@ void DolphinContextMenu::openViewportContextMenu() addCustomActions(); - QAction* propertiesAction = m_mainWindow->actionCollection()->action("properties"); - m_popup->addAction(propertiesAction); + QAction* propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties")); + addAction(propertiesAction); addShowMenuBarAction(); - QAction* action = m_popup->exec(m_pos); + QAction* action = exec(m_pos); if (addToPlacesAction && (action == addToPlacesAction)) { const DolphinViewContainer* container = m_mainWindow->activeViewContainer(); if (container->url().isValid()) { @@ -361,32 +372,47 @@ void DolphinContextMenu::openViewportContextMenu() PlacesItem* item = model.createPlacesItem(container->placesText(), container->url()); model.appendItemToGroup(item); + model.saveBookmarks(); } } } -void DolphinContextMenu::insertDefaultItemActions() +void DolphinContextMenu::insertDefaultItemActions(const KFileItemListProperties& properties) { const KActionCollection* collection = m_mainWindow->actionCollection(); // Insert 'Cut', 'Copy' and 'Paste' - m_popup->addAction(collection->action(KStandardAction::name(KStandardAction::Cut))); - m_popup->addAction(collection->action(KStandardAction::name(KStandardAction::Copy))); - m_popup->addAction(createPasteAction()); + addAction(collection->action(KStandardAction::name(KStandardAction::Cut))); + addAction(collection->action(KStandardAction::name(KStandardAction::Copy))); + addAction(createPasteAction()); - m_popup->addSeparator(); + addSeparator(); // Insert 'Rename' - QAction* renameAction = collection->action("rename"); - m_popup->addAction(renameAction); + QAction* renameAction = collection->action(QStringLiteral("rename")); + addAction(renameAction); // Insert 'Move to Trash' and/or 'Delete' - if (KGlobal::config()->group("KDE").readEntry("ShowDeleteCommand", false)) { - m_popup->addAction(collection->action("move_to_trash")); - m_popup->addAction(collection->action("delete")); - } else { - m_popup->addAction(m_removeAction); - updateRemoveAction(); + if (properties.supportsDeleting()) { + const bool showDeleteAction = (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) || + !properties.isLocal()); + const bool showMoveToTrashAction = (properties.isLocal() && + properties.supportsMoving()); + + if (showDeleteAction && showMoveToTrashAction) { + delete m_removeAction; + m_removeAction = 0; + addAction(m_mainWindow->actionCollection()->action(QStringLiteral("move_to_trash"))); + addAction(m_mainWindow->actionCollection()->action(QStringLiteral("delete"))); + } else if (showDeleteAction && !showMoveToTrashAction) { + addAction(m_mainWindow->actionCollection()->action(QStringLiteral("delete"))); + } else { + if (!m_removeAction) { + m_removeAction = new DolphinRemoveAction(this, m_mainWindow->actionCollection()); + } + addAction(m_removeAction); + m_removeAction->update(); + } } } @@ -395,23 +421,18 @@ void DolphinContextMenu::addShowMenuBarAction() const KActionCollection* ac = m_mainWindow->actionCollection(); QAction* showMenuBar = ac->action(KStandardAction::name(KStandardAction::ShowMenubar)); if (!m_mainWindow->menuBar()->isVisible() && !m_mainWindow->toolBar()->isVisible()) { - m_popup->addSeparator(); - m_popup->addAction(showMenuBar); + addSeparator(); + addAction(showMenuBar); } } -bool DolphinContextMenu::placeExists(const KUrl& url) const +bool DolphinContextMenu::placeExists(const QUrl& url) const { - PlacesItemModel model; - - const int count = model.count(); - for (int i = 0; i < count; ++i) { - const KUrl placeUrl = model.placesItem(i)->url(); - if (placeUrl.equals(url, KUrl::CompareWithoutTrailingSlash)) { - return true; - } - } - + // Creating up a PlacesItemModel to find out if 'url' is one of the Places + // can be expensive because the model asks Solid for the devices which are + // available, which can take some time. + // TODO: Consider restoring this check if the handling of Places and devices + // will be decoupled in the future. return false; } @@ -420,11 +441,12 @@ QAction* DolphinContextMenu::createPasteAction() QAction* action = 0; const bool isDir = !m_fileInfo.isNull() && m_fileInfo.isDir(); if (isDir && (m_selectedItems.count() == 1)) { - action = new QAction(KIcon("edit-paste"), i18nc("@action:inmenu", "Paste Into Folder"), this); - const QMimeData* mimeData = QApplication::clipboard()->mimeData(); - const KUrl::List pasteData = KUrl::List::fromMimeData(mimeData); - action->setEnabled(!pasteData.isEmpty() && selectedItemsProperties().supportsWriting()); - connect(action, SIGNAL(triggered()), m_mainWindow, SLOT(pasteIntoFolder())); + const QMimeData *mimeData = QApplication::clipboard()->mimeData(); + bool canPaste; + const QString text = KIO::pasteActionText(mimeData, &canPaste, m_fileInfo); + action = new QAction(QIcon::fromTheme(QStringLiteral("edit-paste")), text, this); + action->setEnabled(canPaste); + connect(action, &QAction::triggered, m_mainWindow, &DolphinMainWindow::pasteIntoFolder); } else { action = m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::Paste)); } @@ -443,7 +465,7 @@ KFileItemListProperties& DolphinContextMenu::selectedItemsProperties() const KFileItem DolphinContextMenu::baseFileItem() { if (!m_baseFileItem) { - m_baseFileItem = new KFileItem(KFileItem::Unknown, KFileItem::Unknown, m_baseUrl); + m_baseFileItem = new KFileItem(m_baseUrl); } return *m_baseFileItem; } @@ -453,10 +475,10 @@ void DolphinContextMenu::addServiceActions(KFileItemActions& fileItemActions) fileItemActions.setParentWidget(m_mainWindow); // insert 'Open With...' action or sub menu - fileItemActions.addOpenWithActionsTo(m_popup, "DesktopEntryName != 'dolphin'"); + fileItemActions.addOpenWithActionsTo(this, QStringLiteral("DesktopEntryName != 'dolphin'")); // insert 'Actions' sub menu - fileItemActions.addServiceActionsTo(m_popup); + fileItemActions.addServiceActionsTo(this); } void DolphinContextMenu::addFileItemPluginActions() @@ -470,34 +492,27 @@ void DolphinContextMenu::addFileItemPluginActions() QString commonMimeType = props.mimeType(); if (commonMimeType.isEmpty()) { - commonMimeType = QLatin1String("application/octet-stream"); + commonMimeType = QStringLiteral("application/octet-stream"); } - const KService::List pluginServices = KMimeTypeTrader::self()->query(commonMimeType, "KFileItemAction/Plugin", "exist Library"); + const KService::List pluginServices = KMimeTypeTrader::self()->query(commonMimeType, QStringLiteral("KFileItemAction/Plugin"), QStringLiteral("exist Library")); if (pluginServices.isEmpty()) { return; } - const KConfig config("kservicemenurc", KConfig::NoGlobals); + const KConfig config(QStringLiteral("kservicemenurc"), KConfig::NoGlobals); const KConfigGroup showGroup = config.group("Show"); - foreach (const KSharedPtr& service, pluginServices) { + foreach (const KService::Ptr& service, pluginServices) { if (!showGroup.readEntry(service->desktopEntryName(), true)) { // The plugin has been disabled continue; } - // Old API (kdelibs-4.6.0 only) - KFileItemActionPlugin* plugin = service->createInstance(); - if (plugin) { - plugin->setParent(m_popup); - m_popup->addActions(plugin->actions(props, m_mainWindow)); - } - // New API (kdelibs >= 4.6.1) KAbstractFileItemActionPlugin* abstractPlugin = service->createInstance(); if (abstractPlugin) { - abstractPlugin->setParent(m_popup); - m_popup->addActions(abstractPlugin->actions(props, m_mainWindow)); + abstractPlugin->setParent(this); + addActions(abstractPlugin->actions(props, m_mainWindow)); } } } @@ -507,42 +522,13 @@ void DolphinContextMenu::addVersionControlPluginActions() const DolphinView* view = m_mainWindow->activeViewContainer()->view(); const QList versionControlActions = view->versionControlActions(m_selectedItems); if (!versionControlActions.isEmpty()) { - foreach (QAction* action, versionControlActions) { - m_popup->addAction(action); - } - m_popup->addSeparator(); + addActions(versionControlActions); + addSeparator(); } } void DolphinContextMenu::addCustomActions() { - foreach (QAction* action, m_customActions) { - m_popup->addAction(action); - } -} - -void DolphinContextMenu::updateRemoveAction() -{ - const KActionCollection* collection = m_mainWindow->actionCollection(); - - // Using m_removeAction->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. - const QAction* action = 0; - if (moveToTrash()) { - action = collection->action("move_to_trash"); - m_removeAction->setText(i18nc("@action:inmenu", "&Move to Trash")); - } else { - action = collection->action("delete"); - m_removeAction->setText(i18nc("@action:inmenu", "&Delete")); - } - m_removeAction->setIcon(action->icon()); - m_removeAction->setShortcuts(action->shortcuts()); -} - -bool DolphinContextMenu::moveToTrash() const -{ - return !m_shiftPressed; + addActions(m_customActions); } -#include "dolphincontextmenu.moc"