mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
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
This commit is contained in:
parent
0ce1c983b5
commit
9bf03a3c48
|
@ -34,8 +34,8 @@
|
||||||
#include <KIO/RestoreJob>
|
#include <KIO/RestoreJob>
|
||||||
#include <KIO/EmptyTrashJob>
|
#include <KIO/EmptyTrashJob>
|
||||||
#include <KIO/JobUiDelegate>
|
#include <KIO/JobUiDelegate>
|
||||||
|
#include <KIO/Paste>
|
||||||
#include <KJobWidgets>
|
#include <KJobWidgets>
|
||||||
#include <QMenu>
|
|
||||||
#include <KMimeTypeTrader>
|
#include <KMimeTypeTrader>
|
||||||
#include <KNewFileMenu>
|
#include <KNewFileMenu>
|
||||||
#include <konq_operations.h>
|
#include <konq_operations.h>
|
||||||
|
@ -44,7 +44,11 @@
|
||||||
#include <KStandardAction>
|
#include <KStandardAction>
|
||||||
#include <KToolBar>
|
#include <KToolBar>
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QClipboard>
|
||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
#include <panels/places/placesitem.h>
|
#include <panels/places/placesitem.h>
|
||||||
#include <panels/places/placesitemmodel.h>
|
#include <panels/places/placesitemmodel.h>
|
||||||
|
|
||||||
|
@ -439,9 +443,11 @@ QAction* DolphinContextMenu::createPasteAction()
|
||||||
QAction* action = 0;
|
QAction* action = 0;
|
||||||
const bool isDir = !m_fileInfo.isNull() && m_fileInfo.isDir();
|
const bool isDir = !m_fileInfo.isNull() && m_fileInfo.isDir();
|
||||||
if (isDir && (m_selectedItems.count() == 1)) {
|
if (isDir && (m_selectedItems.count() == 1)) {
|
||||||
const QPair<bool, QString> pasteInfo = KonqOperations::pasteInfo(m_fileInfo.url());
|
const QMimeData *mimeData = QApplication::clipboard()->mimeData();
|
||||||
action = new QAction(QIcon::fromTheme("edit-paste"), i18nc("@action:inmenu", "Paste Into Folder"), this);
|
bool canPaste;
|
||||||
action->setEnabled(pasteInfo.first);
|
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);
|
connect(action, &QAction::triggered, m_mainWindow, &DolphinMainWindow::pasteIntoFolder);
|
||||||
} else {
|
} else {
|
||||||
action = m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
|
action = m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
|
||||||
|
|
|
@ -70,10 +70,12 @@ void TreeViewContextMenu::open()
|
||||||
QAction* copyAction = new QAction(QIcon::fromTheme("edit-copy"), i18nc("@action:inmenu", "Copy"), this);
|
QAction* copyAction = new QAction(QIcon::fromTheme("edit-copy"), i18nc("@action:inmenu", "Copy"), this);
|
||||||
connect(copyAction, &QAction::triggered, this, &TreeViewContextMenu::copy);
|
connect(copyAction, &QAction::triggered, this, &TreeViewContextMenu::copy);
|
||||||
|
|
||||||
const QPair<bool, QString> pasteInfo = KonqOperations::pasteInfo(m_fileItem.url());
|
const QMimeData *mimeData = QApplication::clipboard()->mimeData();
|
||||||
QAction* pasteAction = new QAction(QIcon::fromTheme("edit-paste"), pasteInfo.second, this);
|
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);
|
connect(pasteAction, &QAction::triggered, this, &TreeViewContextMenu::paste);
|
||||||
pasteAction->setEnabled(pasteInfo.first);
|
pasteAction->setEnabled(canPaste);
|
||||||
|
|
||||||
popup->addAction(cutAction);
|
popup->addAction(cutAction);
|
||||||
popup->addAction(copyAction);
|
popup->addAction(copyAction);
|
||||||
|
|
|
@ -1149,7 +1149,10 @@ void DolphinView::updateSortFoldersFirst(bool foldersFirst)
|
||||||
|
|
||||||
QPair<bool, QString> DolphinView::pasteInfo() const
|
QPair<bool, QString> DolphinView::pasteInfo() const
|
||||||
{
|
{
|
||||||
return KonqOperations::pasteInfo(url());
|
const QMimeData *mimeData = QApplication::clipboard()->mimeData();
|
||||||
|
QPair<bool, QString> info;
|
||||||
|
info.second = KIO::pasteActionText(mimeData, &info.first, rootItem());
|
||||||
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::setTabsForFilesEnabled(bool tabsForFiles)
|
void DolphinView::setTabsForFilesEnabled(bool tabsForFiles)
|
||||||
|
|
Loading…
Reference in a new issue