Commit c08484f4 authored by Jekyll Wu's avatar Jekyll Wu

Add action "Change Directory to" for cding into dropped directory.

That action is shown only when:
1). only one item is selected and dropped
2). that item is local instead of remote
3). that item is a directory instead of file

FEATURE: 197867
FIXED-IN: 4.9
parent 95b8d555
......@@ -30,6 +30,7 @@
#include <QtGui/QKeyEvent>
#include <QtCore/QEvent>
#include <QtCore/QTime>
#include <QtCore/QFileInfo>
#include <QtGui/QGridLayout>
#include <QtGui/QLabel>
#include <QtGui/QLayout>
......@@ -2774,6 +2775,23 @@ void TerminalDisplay::dropEvent(QDropEvent* event)
QList<QAction*> additionalActions;
additionalActions.append(pasteAction);
if ( urls.count() == 1 ) {
const KUrl url = KIO::NetAccess::mostLocalUrl(urls[0] , 0);
if ( url.isLocalFile() ) {
const QFileInfo fileInfo(url.path());
if ( fileInfo.isDir() ) {
QAction* cdAction = new QAction(i18n("&Change Directory to"), this);
dropText = QLatin1String(" cd ") + dropText + QChar('\n');
cdAction->setData(dropText);
connect(cdAction, SIGNAL(triggered()), this, SLOT(dropMenuCdActionTriggered()));
additionalActions.append(cdAction);
}
}
}
KUrl target(_sessionController->currentDir());
KonqOperations::doDrop(KFileItem(), target, event, this, additionalActions);
......@@ -2801,6 +2819,16 @@ void TerminalDisplay::dropMenuPasteTriggered()
}
}
void TerminalDisplay::dropMenuCdActionTriggered()
{
if (sender()) {
const QAction* action = dynamic_cast<const QAction*>(sender());
if (action) {
emit sendStringToEmu(action->data().toString().toLocal8Bit());
}
}
}
void TerminalDisplay::doDrag()
{
_dragInfo.state = diDragging;
......
......@@ -557,6 +557,8 @@ public slots:
*/
void dropMenuPasteTriggered();
void dropMenuCdActionTriggered();
signals:
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment