summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJekyll Wu <adaptee@gmail.com>2012-01-26 16:05:08 (GMT)
committerJekyll Wu <adaptee@gmail.com>2012-01-26 16:06:49 (GMT)
commitc08484f40a424825490cb297e33046cb5ffdad5a (patch)
tree436d0a6eec5f5eb4626395d72eb7b866ff8e3aa2
parent95b8d5551e9cf7dae76854b9f31d1374c5e3aee5 (diff)
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
-rw-r--r--src/TerminalDisplay.cpp28
-rw-r--r--src/TerminalDisplay.h2
2 files changed, 30 insertions, 0 deletions
diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp
index 38c3cae..af49d75 100644
--- a/src/TerminalDisplay.cpp
+++ b/src/TerminalDisplay.cpp
@@ -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;
diff --git a/src/TerminalDisplay.h b/src/TerminalDisplay.h
index 91b61a7c..4c52370 100644
--- a/src/TerminalDisplay.h
+++ b/src/TerminalDisplay.h
@@ -557,6 +557,8 @@ public slots:
*/
void dropMenuPasteTriggered();
+ void dropMenuCdActionTriggered();
+
signals:
/**