[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:19:37 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=cdede19

The following commit has been merged in the master branch:
commit cdede19e22f97ce0623c7116c36b904fc28a55d6
Author: Paolo Capriotti <paolo.capriotti at collabora.co.uk>
Date:   Sun Jul 17 16:37:20 2011 +0100

    Create custom menu for links.
    
    BUG: 276879
    REVIEW: 101899
---
 lib/adium-theme-view.cpp | 32 +++++++++++++++++++++++++++++++-
 lib/adium-theme-view.h   | 13 +++++++++++--
 2 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/lib/adium-theme-view.cpp b/lib/adium-theme-view.cpp
index 991bed3..9de0d65 100644
--- a/lib/adium-theme-view.cpp
+++ b/lib/adium-theme-view.cpp
@@ -28,12 +28,15 @@
 
 #include <QtCore/QFile>
 #include <QtCore/QTextCodec>
+#include <QtGui/QContextMenuEvent>
 #include <QtGui/QFontDatabase>
+#include <QtGui/QMenu>
 #include <QtWebKit/QWebFrame>
 #include <QtWebKit/QWebElement>
 #include <QtWebKit/QWebInspector>
 #include <QtWebKit/QWebSettings>
 
+#include <KAction>
 #include <KDebug>
 #include <KEmoticonsTheme>
 #include <KGlobal>
@@ -94,9 +97,31 @@ AdiumThemeView::AdiumThemeView(QWidget *parent)
     // don't let QWebView handle the links, we do
     page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
 
+    QAction *defaultOpenLinkAction = pageAction(QWebPage::OpenLink);
+    m_openLinkAction = new KAction(defaultOpenLinkAction->text(), this);
+    connect(m_openLinkAction, SIGNAL(triggered()),
+            this, SLOT(onOpenLinkActionTriggered()));
+
     connect(this, SIGNAL(linkClicked(QUrl)), this, SLOT(onLinkClicked(QUrl)));
 }
 
+void AdiumThemeView::contextMenuEvent(QContextMenuEvent *event)
+{
+    QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos());
+    QUrl url = r.linkUrl();
+    if (!url.isEmpty()) {
+        // save current link url in openLinkAction
+        m_openLinkAction->setData(url);
+
+        QMenu menu(this);
+        menu.addAction(m_openLinkAction);
+        menu.addAction(pageAction(QWebPage::CopyLinkToClipboard));
+        menu.exec(mapToGlobal(event->pos()));
+    } else {
+        QWebView::contextMenuEvent(event);
+    }
+}
+
 void AdiumThemeView::initialise(const AdiumThemeHeaderInfo &chatInfo)
 {
     QString headerHtml;
@@ -301,11 +326,16 @@ void AdiumThemeView::addStatusMessage(const AdiumThemeStatusInfo& statusMessage)
     appendNewMessage(styleHtml);
 }
 
-void AdiumThemeView::onLinkClicked(const QUrl& url)
+void AdiumThemeView::onLinkClicked(const QUrl &url)
 {
     KToolInvocation::invokeBrowser(url.toString());
 }
 
+void AdiumThemeView::onOpenLinkActionTriggered()
+{
+    QUrl url = m_openLinkAction->data().toUrl();
+    onLinkClicked(url);
+}
 
 /** Private */
 
diff --git a/lib/adium-theme-view.h b/lib/adium-theme-view.h
index 1810720..0507128 100644
--- a/lib/adium-theme-view.h
+++ b/lib/adium-theme-view.h
@@ -34,6 +34,10 @@ class AdiumThemeMessageInfo;
 class AdiumThemeStatusInfo;
 class ChatWindowStyle;
 
+class QContextMenuEvent;
+
+class KAction;
+
 class KDE_TELEPATHY_CHAT_EXPORT AdiumThemeView : public QWebView
 {
     Q_OBJECT
@@ -63,11 +67,15 @@ public:
 public slots:
     void addContentMessage(const AdiumThemeContentInfo&);
     void addStatusMessage(const AdiumThemeStatusInfo&);
-    void onLinkClicked(const QUrl&);
+    void onLinkClicked(const QUrl &);
+    void onOpenLinkActionTriggered();
     void onScrollEvent(QKeyEvent*);
 
+protected:
+    virtual void contextMenuEvent(QContextMenuEvent *event);
+
 private:
-    ChatWindowStyle* m_chatStyle;
+    ChatWindowStyle *m_chatStyle;
     QString m_variantPath;
     QString m_variantName;
     KEmoticons m_emoticons;
@@ -84,6 +92,7 @@ private:
     QString m_defaultAvatar;
     QString m_lastSender;
     bool m_displayHeader;
+    KAction *m_openLinkAction;
 
     void appendNewMessage(QString&);
     void appendNextMessage(QString&);

-- 
ktp-text-ui packaging



More information about the pkg-kde-commits mailing list