File kdebase-pardus-kconsole-add-url-handling.patch of Package kdebase3
From 0ed0231329bd5a443936687e6dc0fda46249acdb Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ozan=20=C3=87a=C4=9Flayan?= <ozan@pardus.org.tr>
Date: Mon, 27 Jun 2011 05:32:43 +0000
Subject: [PATCH] konsole: Add URL handling
http://bugs.kde.org/show_bug.cgi?id=94075
---
konsole/konsole/TEmulation.cpp | 5 +++++
konsole/konsole/TEmulation.h | 1 +
konsole/konsole/konsole.cpp | 37 +++++++++++++++++++++++++++++++++++++
konsole/konsole/konsole.h | 7 +++++++
4 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/konsole/konsole/TEmulation.cpp b/konsole/konsole/TEmulation.cpp
index 0ff2a51..b7bd036 100644
--- a/konsole/konsole/TEmulation.cpp
+++ b/konsole/konsole/TEmulation.cpp
@@ -395,6 +395,11 @@ void TEmulation::copySelection() {
QApplication::clipboard()->setText(t);
}
+QString TEmulation::getSelection() {
+ if (connected) return scr->getSelText(true);
+ return QString::null;
+}
+
void TEmulation::streamHistory(QTextStream* stream) {
scr->streamHistory(stream);
}
diff --git a/konsole/konsole/TEmulation.h b/konsole/konsole/TEmulation.h
index 53f05c6..9a2acb7 100644
--- a/konsole/konsole/TEmulation.h
+++ b/konsole/konsole/TEmulation.h
@@ -59,6 +59,7 @@ public slots: // signals incoming from TEWidget
virtual void clearSelection();
virtual void copySelection();
+ virtual QString getSelection();
virtual void onSelectionBegin(const int x, const int y, const bool columnmode);
virtual void onSelectionExtend(const int x, const int y);
virtual void setSelection(const bool preserve_line_breaks);
diff --git a/konsole/konsole/konsole.cpp b/konsole/konsole/konsole.cpp
index 2f9abdf..2eb295d 100644
--- a/konsole/konsole/konsole.cpp
+++ b/konsole/konsole/konsole.cpp
@@ -114,6 +114,7 @@ Time to start a requirement list.
#include <knotifydialog.h>
#include <kprinter.h>
#include <kaccelmanager.h>
+#include <kurifilter.h>
#include <kaction.h>
#include <kshell.h>
@@ -268,6 +269,7 @@ Konsole::Konsole(const char* name, int histon, bool menubaron, bool tabbaron, bo
,sessionNumberMapper(0)
,sl_sessionShortCuts(0)
,s_workDir(workdir)
+,m_filterData(0)
{
isRestored = b_inRestore;
connect( &m_closeTimeout, SIGNAL(timeout()), this, SLOT(slotCouldNotClose()));
@@ -346,6 +348,8 @@ Konsole::Konsole(const char* name, int histon, bool menubaron, bool tabbaron, bo
Konsole::~Konsole()
{
+ delete m_filterData;
+
sessions.first();
while(sessions.current())
{
@@ -718,6 +722,11 @@ void Konsole::makeGUI()
m_copyClipboard->plug(m_rightButton);
m_pasteClipboard->plug(m_rightButton);
+
+ m_openSelection = new KPopupMenu(this);
+ m_rightButton->insertItem( i18n("&Open.."), m_openSelection );
+ connect(m_openSelection, SIGNAL(aboutToShow()), SLOT(slotOpenSelection()));
+
if (m_signals)
m_rightButton->insertItem(i18n("&Send Signal"), m_signals);
@@ -3950,6 +3959,34 @@ void Konsole::slotFindHistory()
m_finddialog->result();
}
+void Konsole::slotOpenSelection()
+{
+ delete m_filterData;
+
+ m_openSelection->clear();
+ disconnect(m_openSelection, SIGNAL(activated(int)), this, SLOT(slotOpenURI(int)));
+
+ QString selection = se->getEmulation()->getSelection();
+ QString curdir = baseURL().path();
+
+ if ( QFile::exists( curdir + selection ) ) {
+ selectedURL = QString(curdir + selection);
+ } else {
+ selectedURL = QString(selection);
+ }
+
+ m_filterData = new KURIFilterData( selectedURL );
+ KURIFilter::self()->filterURI( *(m_filterData) );
+ m_openSelection->insertItem( SmallIconSet( m_filterData->iconName() ),i18n( "%1" ).arg(m_filterData->uri().url()), 1 );
+
+ connect(m_openSelection, SIGNAL(activated(int)), SLOT(slotOpenURI(int)));
+}
+
+void Konsole::slotOpenURI(int)
+{
+ (void) new KRun( m_filterData->uri() );
+}
+
void Konsole::slotFindNext()
{
if( !m_finddialog ) {
diff --git a/konsole/konsole/konsole.h b/konsole/konsole/konsole.h
index df9157f..d9fc2fa 100644
--- a/konsole/konsole/konsole.h
+++ b/konsole/konsole/konsole.h
@@ -61,6 +61,7 @@ class KSelectAction;
class KRadioAction;
class KTabWidget;
class QToolButton;
+class KURIFilterData;
// Defined in main.C
const char *konsole_shell(QStrList &args);
@@ -200,6 +201,9 @@ private slots:
void loadScreenSessions();
void updateFullScreen(bool on);
+ void slotOpenSelection();
+ void slotOpenURI(int n);
+
void slotSaveSettings();
void slotSaveSessionsProfile();
void slotConfigureNotifications();
@@ -362,6 +366,7 @@ private:
KAction *m_print;
KAction *m_quit;
KAction *m_tabDetachSession;
+ KPopupMenu *m_openSelection;
KActionCollection *m_shortcuts;
@@ -372,6 +377,7 @@ private:
bool m_find_first;
bool m_find_found;
QString m_find_pattern;
+ QString selectedURL;
int cmd_serial;
int cmd_first_screen;
@@ -435,6 +441,7 @@ private:
QString s_workDir;
QColor m_tabColor;
+ KURIFilterData* m_filterData;
};
class QSpinBox;
--
1.6.1