summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLim Yuen Hoe <[email protected]>2017-02-25 22:44:12 +0800
committerLim Yuen Hoe <[email protected]>2017-03-01 01:24:04 +0800
commit8bab9c84ab9a9e577dbf40c4e80949b88f58f44c (patch)
tree590c87be17e93b1f2b54b606f4c2787e861676ed
parent1542ec4a051f44d046dee384360b2bb0ff91525d (diff)
Basic keyboard support in QuickShare Plasmoid
Fix Quickshare Paste action not working for urls Fix Quickshare crash when interacting with empty clipboard Differential Revision: https://phabricator.kde.org/D4805
-rw-r--r--applets/quickshare/plasmoid/contents/ui/ShareDialog.qml3
-rw-r--r--applets/quickshare/plasmoid/contents/ui/main.qml39
2 files changed, 29 insertions, 13 deletions
diff --git a/applets/quickshare/plasmoid/contents/ui/ShareDialog.qml b/applets/quickshare/plasmoid/contents/ui/ShareDialog.qml
index 2828d06..1a6d7db 100644
--- a/applets/quickshare/plasmoid/contents/ui/ShareDialog.qml
+++ b/applets/quickshare/plasmoid/contents/ui/ShareDialog.qml
@@ -51,6 +51,9 @@ PlasmaCore.Dialog
enabled: true
onClicked: view.createJob(index)
+ Keys.onReturnPressed: view.createJob(index)
+ Keys.onEnterPressed: view.createJob(index)
+ Keys.onEscapePressed: window.hide()
RowLayout {
anchors.left: parent.left
diff --git a/applets/quickshare/plasmoid/contents/ui/main.qml b/applets/quickshare/plasmoid/contents/ui/main.qml
index 15c829a..f871ffc 100644
--- a/applets/quickshare/plasmoid/contents/ui/main.qml
+++ b/applets/quickshare/plasmoid/contents/ui/main.qml
@@ -68,7 +68,8 @@ DropArea {
function objectToArray(object) {
var array = [];
for(var v in object) {
- array.push(object[v]);
+ // toString() here too because sometimes the contents are non-string (eg QUrl)
+ array.push(object[v].toString());
}
return array;
}
@@ -105,22 +106,30 @@ DropArea {
ContentTracker {
id: contentTracker
}
+
+ function activate() {
+ if (root.state == "configuration") {
+ root.state = "idle";
+ } else if (contentTracker.uri) {
+ var mime = contentTracker.mimeType;
+ if (!mime) {
+ mime = mimeDb.mimeTypeForUrl(contentTracker.uri).name;
+ }
+ sendData([contentTracker.uri], mime);
+ } else {
+ action_paste();
+ }
+ }
+
MouseArea {
anchors.fill: parent
onClicked: {
- if (root.state == "configuration") {
- root.state = "idle";
- } else if (contentTracker.uri) {
- var mime = contentTracker.mimeType;
- if (!mime) {
- mime = mimeDb.mimeTypeForUrl(contentTracker.uri).name;
- }
- sendData([contentTracker.uri], mime);
- } else {
- action_paste();
- }
+ activate();
}
}
+ Plasmoid.onActivated: {
+ activate();
+ }
ShowUrlDialog {
id: showUrl
@@ -214,8 +223,12 @@ DropArea {
}
function action_paste() {
+ if (clipboard.formats.length < 1) { // empty clipboard!
+ return; // do nothing (there's the tooltip!)
+ }
if (clipboard.formats.indexOf("text/uri-list")>=0) {
- sendData(clipboard.contentFormat("text/uri-list"));
+ var urls = objectToArray(clipboard.contentFormat("text/uri-list"))
+ sendData(urls, urlsMimetype(urls).name);
} else {
var mimetype = firstMimeType(clipboard.formats).name;
sendBase64Data(PurposeHelper.variantToBase64(clipboard.contentFormat(mimetype)), mimetype);