[SCM] ktp-contact-applet packaging branch, master, updated. debian/16.04.2-1-67-g066859a

Maximiliano Curia maxy at moszumanska.debian.org
Tue Sep 12 14:08:30 UTC 2017


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-desktop-applets.git;a=commitdiff;h=8328a12

The following commit has been merged in the master branch:
commit 8328a1295a7bded16549998411af2446d774dc79
Author: Kai Uwe Broulik <kde at privat.broulik.de>
Date:   Tue Sep 27 14:49:40 2016 +0200

    [Quick Chat] Add context menu for copying text and links
    
    This allows to copy links by right clicking them and copying individual
    text snippets to the clipboard.
    
    REVIEW: 128089
---
 chat/org.kde.ktp-chat/contents/ui/ChatWidget.qml   | 43 ++++++++++++++++++++++
 chat/org.kde.ktp-chat/contents/ui/TextDelegate.qml |  7 +++-
 chat/qmlplugin/CMakeLists.txt                      |  2 +-
 .../{hide-window-component.cpp => htmlhelper.cpp}  | 19 ++++++----
 .../htmlhelper.h}                                  | 28 ++++++++------
 chat/qmlplugin/qmlplugin.cpp                       |  7 ++++
 6 files changed, 84 insertions(+), 22 deletions(-)

diff --git a/chat/org.kde.ktp-chat/contents/ui/ChatWidget.qml b/chat/org.kde.ktp-chat/contents/ui/ChatWidget.qml
index 7e41910..5ce61e2 100644
--- a/chat/org.kde.ktp-chat/contents/ui/ChatWidget.qml
+++ b/chat/org.kde.ktp-chat/contents/ui/ChatWidget.qml
@@ -23,6 +23,8 @@ import QtQuick.Layouts 1.1
 import org.kde.telepathy 0.1
 import org.kde.plasma.core 2.0 as PlasmaCore
 import org.kde.plasma.components 2.0 as PlasmaComponents
+import org.kde.kquickcontrolsaddons 2.0 as KQC
+import org.kde.ktpchat 0.1 as KTpChat
 
 FocusScope {
     id: chatWidget
@@ -125,6 +127,14 @@ FocusScope {
                         source = "TextDelegate.qml";
                 }
             }
+
+            Connections {
+                target: item
+                ignoreUnknownSignals: true
+                onContextMenuRequested: {
+                    contextMenu.show(item, x, y, item.linkAt(x, y))
+                }
+            }
         }
 
         model: conv.messages
@@ -137,6 +147,39 @@ FocusScope {
         }
     }
 
+    KQC.Clipboard {
+        id: clipboard
+    }
+
+    PlasmaComponents.ContextMenu {
+        id: contextMenu
+        property url link
+
+        function show(item, x, y, link) {
+            contextMenu.link = link || ""
+            visualParent = item
+            open(x, y)
+        }
+
+        PlasmaComponents.MenuItem {
+            text: i18n("Copy Link")
+            visible: contextMenu.link != ""
+            onClicked: clipboard.content = contextMenu.link
+        }
+
+        PlasmaComponents.MenuItem {
+            separator: true
+            visible: contextMenu.link != ""
+        }
+
+        PlasmaComponents.MenuItem {
+            text: i18n("Copy Text")
+            icon: "edit-copy"
+            enabled: contextMenu.visualParent && contextMenu.visualParent.text !== ""
+            onClicked: clipboard.content = KTpChat.HtmlHelper.decode(contextMenu.visualParent.text)
+        }
+    }
+
     PlasmaComponents.Label {
         id: disconnectedLabel
         visible: !conv.valid
diff --git a/chat/org.kde.ktp-chat/contents/ui/TextDelegate.qml b/chat/org.kde.ktp-chat/contents/ui/TextDelegate.qml
index fc2ead1..ea205df 100644
--- a/chat/org.kde.ktp-chat/contents/ui/TextDelegate.qml
+++ b/chat/org.kde.ktp-chat/contents/ui/TextDelegate.qml
@@ -22,6 +22,9 @@ import org.kde.plasma.components 2.0 as PlasmaComponents
 
 PlasmaComponents.Label {
     id: body
+
+    signal contextMenuRequested(int x, int y)
+
     wrapMode: Text.Wrap
     width: view.width
 
@@ -56,7 +59,7 @@ PlasmaComponents.Label {
         id: mouseArea
         anchors.fill: parent
         hoverEnabled: true
-        //we just want to know if the mouse is there, otherwise prevents links from being clicked
-        acceptedButtons: Qt.NoButton
+        acceptedButtons: Qt.NoButton | Qt.RightButton
+        onClicked: body.contextMenuRequested(mouse.x, mouse.y)
     }
 }
diff --git a/chat/qmlplugin/CMakeLists.txt b/chat/qmlplugin/CMakeLists.txt
index 52e79a0..145e164 100644
--- a/chat/qmlplugin/CMakeLists.txt
+++ b/chat/qmlplugin/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_library (ktpchatplugin SHARED hide-window-component.cpp qmlplugin.cpp)
+add_library (ktpchatplugin SHARED hide-window-component.cpp htmlhelper.cpp qmlplugin.cpp)
 
 target_link_libraries (ktpchatplugin
     Qt5::Qml
diff --git a/chat/qmlplugin/hide-window-component.cpp b/chat/qmlplugin/htmlhelper.cpp
similarity index 68%
copy from chat/qmlplugin/hide-window-component.cpp
copy to chat/qmlplugin/htmlhelper.cpp
index bf8f24b..ec0e396 100644
--- a/chat/qmlplugin/hide-window-component.cpp
+++ b/chat/qmlplugin/htmlhelper.cpp
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Aleix Pol Gonzalez <aleixpol at blue-systems.com>
+    Copyright (C) 2016 Kai Uwe Broulik <kde at privat.broulik.de>
 
     This library is free software; you can redistribute it and/or
     modify it under the terms of the GNU Lesser General Public
@@ -16,16 +16,21 @@
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
 
-#include "hide-window-component.h"
+#include "htmlhelper.h"
 
-#include <KWindowSystem>
+#include <QTextDocument>
+#include <QDebug>
 
-HideWindowComponent::HideWindowComponent(QObject *parent)
-    : QObject(parent)
+HtmlHelper::HtmlHelper(QObject *parent) : QObject(parent)
 {
+
 }
 
-void HideWindowComponent::hideWindowFromTaskbar(qulonglong winId)
+HtmlHelper::~HtmlHelper() = default;
+
+QString HtmlHelper::decode(const QString &text) const
 {
-    KWindowSystem::setState(winId, NET::SkipTaskbar | NET::SkipPager);
+    QTextDocument doc;
+    doc.setHtml(text);
+    return doc.toPlainText();
 }
diff --git a/chat/org.kde.ktp-chat/contents/ui/OutgoingDelegate.qml b/chat/qmlplugin/htmlhelper.h
similarity index 71%
copy from chat/org.kde.ktp-chat/contents/ui/OutgoingDelegate.qml
copy to chat/qmlplugin/htmlhelper.h
index 2144b5a..76082ae 100644
--- a/chat/org.kde.ktp-chat/contents/ui/OutgoingDelegate.qml
+++ b/chat/qmlplugin/htmlhelper.h
@@ -1,7 +1,6 @@
 /*
-    Copyright (C) 2012  Lasath Fernando <kde at lasath.org>
-    Copyright (C) 2012 David Edmundson <kde at davidedmundson.co.uk>
-    
+    Copyright (C) 2016 Kai Uwe Broulik <kde at privat.broulik.de>
+
     This library is free software; you can redistribute it and/or
     modify it under the terms of the GNU Lesser General Public
     License as published by the Free Software Foundation; either
@@ -17,13 +16,18 @@
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
 
-import QtQuick 2.1
+#pragma once
+
+#include <QObject>
+
+class HtmlHelper : public QObject
+{
+    Q_OBJECT
+
+  public:
+    explicit HtmlHelper(QObject *parent = nullptr);
+    ~HtmlHelper() override;
+
+    Q_INVOKABLE QString decode(const QString &text) const;
 
-TextDelegate {
-    Rectangle {
-        color: theme.viewBackgroundColor
-        anchors.fill: parent
-        z: parent.z-1
-        opacity: 0.7
-    }
-}
+};
diff --git a/chat/qmlplugin/qmlplugin.cpp b/chat/qmlplugin/qmlplugin.cpp
index 71a6495..eb1fce6 100644
--- a/chat/qmlplugin/qmlplugin.cpp
+++ b/chat/qmlplugin/qmlplugin.cpp
@@ -19,6 +19,12 @@
 #include <QQmlExtensionPlugin>
 #include <qqml.h>
 #include "hide-window-component.h"
+#include "htmlhelper.h"
+
+static QObject *htmlHelper_singleton_provider(QQmlEngine *, QJSEngine *)
+{
+    return new HtmlHelper();
+}
 
 class QmlPlugins : public QQmlExtensionPlugin
 {
@@ -29,6 +35,7 @@ class QmlPlugins : public QQmlExtensionPlugin
         virtual void initializeEngine(QQmlEngine */*engine*/, const char */*uri*/) {}
         virtual void registerTypes(const char *uri) {
             qmlRegisterType<HideWindowComponent>(uri, 0, 1, "HideWindowComponent");
+            qmlRegisterSingletonType<HtmlHelper>(uri, 0, 1, "HtmlHelper", htmlHelper_singleton_provider);
         }
 
 };

-- 
ktp-contact-applet packaging



More information about the pkg-kde-commits mailing list