diff --git a/extension/extension-kdeconnect.js b/extension/extension-kdeconnect.js index ce509c26..f978c388 100644 --- a/extension/extension-kdeconnect.js +++ b/extension/extension-kdeconnect.js @@ -1,70 +1,98 @@ /* Copyright (C) 2017 Kai Uwe Broulik This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ var kdeConnectMenuIdPrefix = "kdeconnect_page_"; var kdeConnectDevices = {}; chrome.contextMenus.onClicked.addListener(function (info) { if (!info.menuItemId.startsWith(kdeConnectMenuIdPrefix)) { return; } var deviceId = info.menuItemId.substr(kdeConnectMenuIdPrefix.length); var url = info.linkUrl || info.srcUrl || info.pageUrl; console.log("Send url", url, "to kdeconnect device", deviceId); if (!url) { return; } port.postMessage({ subsystem: "kdeconnect", event: "shareUrl", url: url, deviceId: deviceId }); }); addCallback("kdeconnect", "deviceAdded", function(message) { let deviceId = message.id; let name = message.name; let type = message.type; let menuEntryTitle = chrome.i18n.getMessage("kdeconnect_open_device", name); let menuId = kdeConnectMenuIdPrefix + deviceId; - chrome.contextMenus.create({ + let props = { id: menuId, contexts: ["link", "page", "image", "audio", "video"], title: menuEntryTitle, - }); + }; + + if (IS_FIREFOX) { + let iconName = ""; + switch (type) { + case "smartphone": + case "phone": + iconName = "smartphone-symbolic"; + break; + case "tablet": + iconName = "tablet-symbolic"; + break; + case "desktop": + case "tv": // at this size you can't really tell desktop monitor icon from a TV + iconName = "computer-symbolic"; + break; + case "laptop": + iconName = "computer-laptop-symbolic"; + break; + } + + if (iconName) { + props.icons = { + "16": "icons/" + iconName + ".svg" + }; + } + } + + chrome.contextMenus.create(props); kdeConnectDevices[deviceId] = { name, type }; }); addCallback("kdeconnect", "deviceRemoved", function(message) { let deviceId = message.id; if (!kdeConnectDevices[deviceId]) { return; } delete kdeConnectDevices[deviceId]; chrome.contextMenus.remove(kdeConnectMenuIdPrefix + deviceId); }); diff --git a/extension/icons/computer-laptop-symbolic.svg b/extension/icons/computer-laptop-symbolic.svg new file mode 100644 index 00000000..641d6576 --- /dev/null +++ b/extension/icons/computer-laptop-symbolic.svg @@ -0,0 +1,13 @@ + + + + + + diff --git a/extension/icons/computer-symbolic.svg b/extension/icons/computer-symbolic.svg new file mode 100644 index 00000000..4f3e49c5 --- /dev/null +++ b/extension/icons/computer-symbolic.svg @@ -0,0 +1,13 @@ + + + + + + diff --git a/extension/icons/smartphone-symbolic.svg b/extension/icons/smartphone-symbolic.svg new file mode 100644 index 00000000..aaa163a7 --- /dev/null +++ b/extension/icons/smartphone-symbolic.svg @@ -0,0 +1,13 @@ + + + + + + diff --git a/extension/icons/tablet-symbolic.svg b/extension/icons/tablet-symbolic.svg new file mode 100644 index 00000000..49512ee3 --- /dev/null +++ b/extension/icons/tablet-symbolic.svg @@ -0,0 +1,8 @@ + + + + + +