Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 96f3b700 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Make it possible to copy urls from a url into the clipboard

parent 13f5d531
......@@ -38,6 +38,7 @@
#include <QSortFilterProxyModel>
#include <QTimer>
#include <QSessionManager>
#include <QClipboard>
// KDE includes
#include <KAboutApplicationDialog>
......@@ -459,4 +460,10 @@ void DiscoverObject::showPassiveNotification(const QString& msg)
});
}
void DiscoverObject::copyTextToClipboard(const QString& text)
{
qGuiApp->clipboard()->setText(text);
}
#include "DiscoverObject.moc"
......@@ -67,6 +67,8 @@ class DiscoverObject : public QObject
void openMode(const QString& mode);
void openLocalPackage(const QUrl &localfile);
void copyTextToClipboard(const QString &text);
private Q_SLOTS:
void reportBug();
void switchApplicationLanguage();
......
......@@ -6,6 +6,7 @@ QQC2.Label {
id: control
property QtObject action: null //some older Qt versions don't support the namespacing in Kirigami.Action
property alias acceptedButtons: area.acceptedButtons
text: action ? action.text : ""
enabled: !action || action.enabled
onClicked: if (action) action.trigger()
......@@ -16,8 +17,9 @@ QQC2.Label {
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
signal clicked()
signal clicked(QtObject mouse)
MouseArea {
id: area
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
......@@ -26,6 +28,6 @@ QQC2.Label {
control.font.underline = containsMouse && control.enabled
}
onClicked: control.clicked()
onClicked: control.clicked(mouse)
}
}
......@@ -4,8 +4,24 @@ import QtQuick.Controls 2.1 as QQC2
LinkButton
{
id: button
property string url
text: url
visible: text.length>0
onClicked: Qt.openUrlExternally(url)
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: {
if (mouse.button === Qt.RightButton)
menu.popup()
else
Qt.openUrlExternally(url)
}
QQC2.Menu {
id: menu
QQC2.MenuItem {
text: i18n("Copy link address")
onClicked: app.copyTextToClipboard(button.url)
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment