Commit 60d07446 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

Add device icons to KDE Connect context menu

Firefox supports setting icons on menus [1]. Chrome refuses to create a menu with unknown keys,
so this is guarded by IS_FIREFOX.
This uses the appropriate Breeze icons, except "computer-tablet" which I edited to have larger
padding to somewhat fit better with the rest of the icons.

[1] https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/menus#Icons

Differential Revision: https://phabricator.kde.org/D28837
parent 7f3bc46f
......@@ -47,11 +47,39 @@ addCallback("kdeconnect", "deviceAdded", function(message) {
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
......
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#232629;
}
</style>
</defs>
<path
style="fill:currentColor;fill-opacity:1;stroke:none"
d="M 3 4 L 3 11 L 2 11 C 2 11.554 2.446 12 3 12 L 13 12 C 13.554 12 14 11.554 14 11 L 13 11 L 13 4 L 3 4 z M 4 5 L 12 5 L 12 10 L 4 10 L 4 5 z "
class="ColorScheme-Text"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#232629;
}
</style>
</defs>
<path
style="fill:currentColor;fill-opacity:1;stroke:none"
d="M 2 3 L 2 11 L 7 11 L 7 12 L 5 12 L 5 13 L 11 13 L 11 12 L 9 12 L 9 11 L 14 11 L 14 3 L 2 3 z M 3 4 L 13 4 L 13 10 L 3 10 L 3 4 z "
class="ColorScheme-Text"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#232629;
}
</style>
</defs>
<path
style="fill:currentColor;fill-opacity:1;stroke:none"
d="M 4 2 L 4 14 L 12 14 L 12 2 L 4 2 z M 7 3 L 9 3 L 9 4 L 7 4 L 7 3 z M 5 5 L 11 5 L 11 12 L 5 12 L 5 5 z "
class="ColorScheme-Text"/>
</svg>
<svg version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
<defs>
<style id="current-color-scheme" type="text/css">.ColorScheme-Text {
color:#232629;
}</style>
</defs>
<path d="m1 3v10h14v-10zm3 2h8v6h-8zm-2 2h1v2h-1zm11 0h1v2h-1z" style="fill:currentColor;fill-opacity:1;stroke:none" class="ColorScheme-Text"/>
</svg>
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