X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/9dc1513f8bae968a363ea74af90a4042382d3d20..6a09781a3b99bbca2b2c66ee3041208a02ead0ca:/src/dolphincontextmenu.cpp diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index e692c8fa9..d8f101454 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -34,19 +34,22 @@ #include #include #include -#include +#include +#include +#include +#include +#include #include #include #include #include +#include #include -#include #include #include #include #include #include -#include #include #include @@ -143,7 +146,7 @@ void DolphinContextMenu::openTrashContextMenu() { Q_ASSERT(m_context & TrashContext); - QAction* emptyTrashAction = new QAction(KIcon("trash-empty"), i18nc("@action:inmenu", "Empty Trash"), this); + QAction* emptyTrashAction = new QAction(QIcon::fromTheme("trash-empty"), i18nc("@action:inmenu", "Empty Trash"), this); KConfig trashConfig("trashrc", KConfig::SimpleConfig); emptyTrashAction->setEnabled(!trashConfig.group("Status").readEntry("Empty", true)); addAction(emptyTrashAction); @@ -156,7 +159,13 @@ void DolphinContextMenu::openTrashContextMenu() addShowMenuBarAction(); if (exec(m_pos) == emptyTrashAction) { - KonqOperations::emptyTrash(m_mainWindow); + 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); + } } } @@ -180,7 +189,9 @@ void DolphinContextMenu::openTrashItemContextMenu() selectedUrls.append(item.url()); } - KonqOperations::restoreTrashedItems(selectedUrls, m_mainWindow); + KIO::RestoreJob *job = KIO::restoreFromTrash(selectedUrls); + KJobWidgets::setWindow(job, m_mainWindow); + job->uiDelegate()->setAutoErrorHandlingEnabled(true); } } @@ -188,6 +199,7 @@ void DolphinContextMenu::openItemContextMenu() { Q_ASSERT(!m_fileInfo.isNull()); + QAction* openParentAction = 0; QAction* openParentInNewWindowAction = 0; QAction* openParentInNewTabAction = 0; QAction* addToPlacesAction = 0; @@ -202,12 +214,12 @@ void DolphinContextMenu::openItemContextMenu() newFileMenu->checkUpToDate(); newFileMenu->setPopupFiles(m_fileInfo.url()); newFileMenu->setEnabled(selectedItemsProps.supportsWriting()); - connect(newFileMenu, SIGNAL(fileCreated(KUrl)), newFileMenu, SLOT(deleteLater())); - connect(newFileMenu, SIGNAL(directoryCreated(KUrl)), newFileMenu, SLOT(deleteLater())); + 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")); + menu->setIcon(QIcon::fromTheme("document-new")); addMenu(menu); addSeparator(); @@ -217,20 +229,26 @@ void DolphinContextMenu::openItemContextMenu() // insert 'Add to Places' entry if (!placeExists(m_fileInfo.url())) { - addToPlacesAction = addAction(KIcon("bookmark-new"), + addToPlacesAction = addAction(QIcon::fromTheme("bookmark-new"), i18nc("@action:inmenu Add selected folder to places", "Add to Places")); } addSeparator(); - } else if (m_baseUrl.protocol().contains("search")) { - openParentInNewWindowAction = new QAction(KIcon("window-new"), + } else if (m_baseUrl.protocol().contains("search") || m_baseUrl.protocol().contains("timeline")) { + openParentAction = new QAction(QIcon::fromTheme("document-open-folder"), + i18nc("@action:inmenu", + "Open Path"), + this); + addAction(openParentAction); + + openParentInNewWindowAction = new QAction(QIcon::fromTheme("window-new"), i18nc("@action:inmenu", "Open Path in New Window"), this); addAction(openParentInNewWindowAction); - openParentInNewTabAction = new QAction(KIcon("tab-new"), + openParentInNewTabAction = new QAction(QIcon::fromTheme("tab-new"), i18nc("@action:inmenu", "Open Path in New Tab"), this); @@ -294,6 +312,8 @@ void DolphinContextMenu::openItemContextMenu() PlacesItem* item = model.createPlacesItem(text, selectedUrl); model.appendItemToGroup(item); } + } else if (activatedAction == openParentAction) { + m_command = OpenParentFolder; } else if (activatedAction == openParentInNewWindowAction) { m_command = OpenParentFolderInNewWindow; } else if (activatedAction == openParentInNewTabAction) { @@ -321,7 +341,7 @@ void DolphinContextMenu::openViewportContextMenu() // Insert 'Add to Places' entry if exactly one item is selected QAction* addToPlacesAction = 0; if (!placeExists(m_mainWindow->activeViewContainer()->url())) { - addToPlacesAction = addAction(KIcon("bookmark-new"), + addToPlacesAction = addAction(QIcon::fromTheme("bookmark-new"), i18nc("@action:inmenu Add current folder to places", "Add to Places")); } @@ -430,9 +450,9 @@ QAction* DolphinContextMenu::createPasteAction() const bool isDir = !m_fileInfo.isNull() && m_fileInfo.isDir(); if (isDir && (m_selectedItems.count() == 1)) { const QPair pasteInfo = KonqOperations::pasteInfo(m_fileInfo.url()); - action = new QAction(KIcon("edit-paste"), i18nc("@action:inmenu", "Paste Into Folder"), this); + action = new QAction(QIcon::fromTheme("edit-paste"), i18nc("@action:inmenu", "Paste Into Folder"), this); action->setEnabled(pasteInfo.first); - connect(action, SIGNAL(triggered()), m_mainWindow, SLOT(pasteIntoFolder())); + connect(action, &QAction::triggered, m_mainWindow, &DolphinMainWindow::pasteIntoFolder); } else { action = m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::Paste)); } @@ -489,7 +509,7 @@ void DolphinContextMenu::addFileItemPluginActions() const KConfig config("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; @@ -529,4 +549,3 @@ void DolphinContextMenu::addCustomActions() } } -#include "dolphincontextmenu.moc"