From 9bf03a3c48f4847b5e0417e3529bf071108cbf1e Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 21 Oct 2014 20:44:37 +0200 Subject: [PATCH] Dolphin: port to KIO::pasteInfoText(). DolphinContextMenu::createPasteAction used to be precise about destination ("Paste To Folder"), while now it's precise about the source (what to paste). It was decided that this was more useful and consistent anyway. REVIEW: 120695 --- src/dolphincontextmenu.cpp | 14 ++++++++++---- src/panels/folders/treeviewcontextmenu.cpp | 8 +++++--- src/views/dolphinview.cpp | 5 ++++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index b01346985e..cb389b19cc 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -34,8 +34,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -44,7 +44,11 @@ #include #include +#include +#include #include +#include + #include #include @@ -439,9 +443,11 @@ QAction* DolphinContextMenu::createPasteAction() QAction* action = 0; 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(QIcon::fromTheme("edit-paste"), i18nc("@action:inmenu", "Paste Into Folder"), this); - action->setEnabled(pasteInfo.first); + const QMimeData *mimeData = QApplication::clipboard()->mimeData(); + bool canPaste; + const QString text = KIO::pasteActionText(mimeData, &canPaste, m_fileInfo); + action = new QAction(QIcon::fromTheme("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)); diff --git a/src/panels/folders/treeviewcontextmenu.cpp b/src/panels/folders/treeviewcontextmenu.cpp index 4afe9e8e39..85d1215c68 100644 --- a/src/panels/folders/treeviewcontextmenu.cpp +++ b/src/panels/folders/treeviewcontextmenu.cpp @@ -70,10 +70,12 @@ void TreeViewContextMenu::open() QAction* copyAction = new QAction(QIcon::fromTheme("edit-copy"), i18nc("@action:inmenu", "Copy"), this); connect(copyAction, &QAction::triggered, this, &TreeViewContextMenu::copy); - const QPair pasteInfo = KonqOperations::pasteInfo(m_fileItem.url()); - QAction* pasteAction = new QAction(QIcon::fromTheme("edit-paste"), pasteInfo.second, this); + const QMimeData *mimeData = QApplication::clipboard()->mimeData(); + bool canPaste; + const QString text = KIO::pasteActionText(mimeData, &canPaste, m_fileItem); + QAction* pasteAction = new QAction(QIcon::fromTheme("edit-paste"), text, this); connect(pasteAction, &QAction::triggered, this, &TreeViewContextMenu::paste); - pasteAction->setEnabled(pasteInfo.first); + pasteAction->setEnabled(canPaste); popup->addAction(cutAction); popup->addAction(copyAction); diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index f35c9e6ca6..b330e5f5c3 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -1149,7 +1149,10 @@ void DolphinView::updateSortFoldersFirst(bool foldersFirst) QPair DolphinView::pasteInfo() const { - return KonqOperations::pasteInfo(url()); + const QMimeData *mimeData = QApplication::clipboard()->mimeData(); + QPair info; + info.second = KIO::pasteActionText(mimeData, &info.first, rootItem()); + return info; } void DolphinView::setTabsForFilesEnabled(bool tabsForFiles)