[Konsole-devel] Adding Zmodem download item contextual menu
Zhang Lei
zhanglei002 at gmail.com
Tue Sep 9 07:45:45 UTC 2014
Hello everyone,
I am interested in adding a zmodem download item in contextual, which
is very useful when you are connected with SSH. You can just select the
file you want to down and right click.This feature can be found in many
terminal emulators, xshell, for example.
I have used it for a while in my arch linux. please check the patch
file in the attachment.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/konsole-devel/attachments/20140909/1c84656a/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: zm_down.jpg
Type: image/jpeg
Size: 51029 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/konsole-devel/attachments/20140909/1c84656a/attachment-0001.jpg>
-------------- next part --------------
diff -r -u bak/konsole-4.13.1/desktop/sessionui.rc src/konsole-4.13.1/desktop/sessionui.rc
--- bak/konsole-4.13.1/desktop/sessionui.rc 2014-05-07 21:44:07.000000000 +0800
+++ src/konsole-4.13.1/desktop/sessionui.rc 2014-06-08 18:29:53.764554601 +0800
@@ -44,6 +44,7 @@
<Menu name="session-popup-menu">
<Action name="edit_copy"/>
<Action name="edit_paste"/>
+ <Action name="zmodem-download"/>
<Action name="web-search"/>
<Action name="open-browser"/>
<Separator/>
diff -r -u bak/konsole-4.13.1/src/SessionController.cpp src/konsole-4.13.1/src/SessionController.cpp
--- bak/konsole-4.13.1/src/SessionController.cpp 2014-05-07 21:44:07.000000000 +0800
+++ src/konsole-4.13.1/src/SessionController.cpp 2014-06-06 17:51:04.283544030 +0800
@@ -588,6 +588,9 @@
action->setText(i18n("Paste Selection"));
action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Insert));
+ action = collection->addAction("zmodem-download", this, SLOT(zmodemStartDownload()));
+ action->setText(i18n("ZModem Download"));
+
_webSearchMenu = new KActionMenu(i18n("Web Search"), this);
_webSearchMenu->setIcon(KIcon("preferences-web-browser-shortcuts"));
_webSearchMenu->setVisible(false);
@@ -1612,6 +1615,14 @@
return;
}
+void SessionController::zmodemStartDownload()
+{
+ if (_selectedText.isEmpty())
+ return;
+ _session->startZModemDownload(QString("sz ") + _selectedText + QString("\n"));
+ return;
+}
+
void SessionController::zmodemUpload()
{
if (_session->isZModemBusy()) {
diff -r -u bak/konsole-4.13.1/src/SessionController.h src/konsole-4.13.1/src/SessionController.h
--- bak/konsole-4.13.1/src/SessionController.h 2014-05-07 21:44:07.000000000 +0800
+++ src/konsole-4.13.1/src/SessionController.h 2014-06-06 16:00:48.243757707 +0800
@@ -280,6 +280,7 @@
void updateSearchFilter();
+ void zmodemStartDownload();
void zmodemDownload();
void zmodemUpload();
diff -r -u bak/konsole-4.13.1/src/Session.cpp src/konsole-4.13.1/src/Session.cpp
--- bak/konsole-4.13.1/src/Session.cpp 2014-05-07 21:44:07.000000000 +0800
+++ src/konsole-4.13.1/src/Session.cpp 2014-06-06 16:17:23.350392234 +0800
@@ -1179,6 +1179,10 @@
_zmodemBusy = false;
}
+void Session::startZModemDownload(const QString& files)
+{
+ _shellProcess->sendData(files.toUtf8().constData(), files.length());
+}
void Session::startZModem(const QString& zmodem, const QString& dir, const QStringList& list)
{
_zmodemBusy = true;
diff -r -u bak/konsole-4.13.1/src/Session.h src/konsole-4.13.1/src/Session.h
--- bak/konsole-4.13.1/src/Session.h 2014-05-07 21:44:07.000000000 +0800
+++ src/konsole-4.13.1/src/Session.h 2014-06-06 16:10:07.200406321 +0800
@@ -328,6 +328,7 @@
*/
void refresh();
+ void startZModemDownload(const QString& files);
void startZModem(const QString& rz, const QString& dir, const QStringList& list);
void cancelZModem();
bool isZModemBusy() {
More information about the konsole-devel
mailing list