diff --git a/extension/_locales/en/messages.json b/extension/_locales/en/messages.json index ff2e0676..3b105356 100644 --- a/extension/_locales/en/messages.json +++ b/extension/_locales/en/messages.json @@ -1,115 +1,118 @@ { "options_title": { "description": "Title for settings page", "message": "Plasma Integration Settings" }, "options_save_failed": { "message": "Saving settings failed" }, "options_save_success": { "message": "Settings successfully saved" }, + "options_not_supported_os": { + "message": "This extension is not supported on this operating system." + }, "options_tab_general": { "description": "The 'General settings' tab in settings", "message": "General" }, "options_tab_about": { "description": "The 'About this plugin' tab in settings", "message": "About" }, "options_plugin_mpris_title": { "description": "Title for Media Controls plugin", "message": "Media Controls" }, "options_plugin_mpris_description": { "description": "Description for Media Controls plugin", "message": "Lets you control video and audio players in websites using the Media Controller plasmoid." }, "options_plugin_kdeconnect_title": { "description": "Title for KDE Connect plugin", "message": "Send via KDE Connect" }, "options_plugin_kdeconnect_description": { "description": "Description for KDE Connect plugin", "message": "Adds a context menu entry to links enabling you to send them to your phone and other paired devices using KDE Connect." }, "options_plugin_downloads_title": { "description": "Title for Downloads plugin", "message": "Show downloads in notification area" }, "options_plugin_tabsrunner_title": { "description": "Title for Browser Tabs KRunner plugin", "message": "Find browser tabs in “Run Command” window" }, "options_plugin_tabsrunner_description": { "description": "Description for Browser Tabs KRunner plugin", "message": "Make sure the “Browser Tabs” module is enabled in Plasma Search settings." }, "options_plugin_breezeScrollBars_title": { "description": "Title for Breeze style scroll bars plugin", "message": "Use Breeze-style scroll bars" }, "options_plugin_breezeScrollBars_description": { "description": "Description for Breeze style scroll bars plugin", "message": "This may interfere with the appearance of websites that already apply a custom styling to their scroll bars." }, "options_about_copyright": { "message": "© 2017, 2018 Kai Uwe Broulik and David Edmundson" }, "options_about_license": { "message": "License: GNU General Public License Version 3" }, "options_about_translated_by": { "message": "Translated by: $1" }, "options_about_translators": { "description": "Name of translators", "message": "Your names" }, "options_about_created_by_kde": { "message": "This browser extension was created by the KDE Community. You can find more information about this project on the KDE Community Wiki." }, "options_about_bugs": { "message": "If you find an issue, please check the list of open bugs and then file a bug report." }, "options_about_kde": { "description": "KDE description taken from kaboutkdedialog_p.h in kmxlgui", "message": "KDE is a world-wide network of software engineers, artists, writers, translators and facilitators who are committed to Free Software development. This community has created hundreds of Free Software applications as part of the KDE frameworks, workspaces and applications. KDE is a cooperative enterprise in which no single entity controls the efforts or products of KDE to the exclusion of others. Everyone is welcome to join and contribute to KDE, including you." }, "options_about_donate": { "message": "If you like what you saw, please consider donating to KDE, so we can continue to make the best free software possible." }, "kdeconnect_open_via": { "description": "Context menu, open link on device whose name we don't (yet) know", "message": "Open via KDE Connect" }, "kdeconnect_open_device": { "description": "Context menu, open link on device $1, similar to 'Open in New Tab'", "message": "Open on '$1'" }, "general_error_title": { "description": "Title message for most error notifications", "message": "Plasma Browser Integration Error" }, "general_error_unknown": { "description": "An unknown error occurred, usually used when an error message by the system is not provided", "message": "Unknown Error" }, "general_error_port_disconnect": { "description": "When the binary bridge between browser and Plasma quit (usually it crashed or was otherwise killed), placeholder is the reason", "message": "The native host disconnected unexpectedly: $1" }, "general_error_port_startupfail": { "description": "When the binary bridge between browser and Plasma failed to start (e.g. not installed)", "message": "Failed to connect to the native host. Make sure the 'plasma-browser-integration' package is installed." } } diff --git a/extension/options.css b/extension/options.css index 9c94224b..c871addb 100644 --- a/extension/options.css +++ b/extension/options.css @@ -1,69 +1,79 @@ body { min-width: 600px; /* prevent scroll bars*/ overflow: hidden; } +.not-supported-info { + display: none; +} +body.not-supported .not-supported-info { + display: block; +} +body.not-supported #extensions-selection { + display: none; +} + .tabbar { display: block; padding: 0; /* color of separator line below heading */ background-color: #d3d3d3; /* undo body side margins*/ margin: 0 -17px 0px -17px; padding: 0px 17px; } .tabbar > li { display: inline-block; /* TODO draw a nice tab-like thingie */ margin-top: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; border: 1px solid #999; border-bottom: none; } .tabbar > li > a { display: block; text-decoration: none; color: #333; /* can we just reset it to default text color?*/ padding: 4px 8px; } .tabbar > li > a.active { font-weight: bold; background-color: #fff; } .tab { display: none; } .tab.active { display: block; } #extensions-selection { padding: 0; } #extensions-selection > li { display: block; padding: 0; } #extensions-selection p { margin-top: 0; opacity: 0.7; line-height: 1.3; /* checkbox default width is 13px, try to align the description somewhat*/ padding-left: 18px; } .dialog-button-box { float: right; padding-bottom: 14px; } img.konqi { float: right; margin-right: -14px; } diff --git a/extension/options.html b/extension/options.html index 41549077..ce38d6a3 100644 --- a/extension/options.html +++ b/extension/options.html @@ -1,75 +1,77 @@
+

I18N

+

I18N
I18N
I18N

I18N

I18N

I18N

I18N

diff --git a/extension/options.js b/extension/options.js index d94312ca..51c584c2 100644 --- a/extension/options.js +++ b/extension/options.js @@ -1,172 +1,179 @@ /* 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 storage = (IS_FIREFOX ? chrome.storage.local : chrome.storage.sync); function sendMessage(action, payload) { (chrome.extension.sendMessage || browser.runtime.sendMessage)({ subsystem: "settings", action: action, payload: payload }); } function tabClicked(tabbar, tabbutton) { tabbar.buttons.forEach(function (button) { var tablink = button.dataset.tabLink var tabtarget = document.querySelector("[data-tab-id=" + tablink + "]"); if (tabbutton == button) { button.classList.add("active"); tabtarget.classList.add("active"); } else { button.classList.remove("active"); tabtarget.classList.remove("active"); } }); } function extensionCheckboxes() { return document.querySelectorAll("#extensions-selection input[type=checkbox][data-extension]"); } function loadSettings() { storage.get(DEFAULT_EXTENSION_SETTINGS, function (items) { if (chrome.runtime.lastError) { return; } for (var key in items) { if (!items.hasOwnProperty(key)) { continue; } var checkbox = document.querySelector("input[type=checkbox][data-extension=" + key + "]"); if (!checkbox) { console.warn("Failed to find checkbox for extension", key); continue; } var checked = !!items[key].enabled; checkbox.checked = checked; // TODO restore additional stuff if we have it } }); } function saveSettings(cb) { var settings = {}; for (var key in DEFAULT_EXTENSION_SETTINGS) { if (!DEFAULT_EXTENSION_SETTINGS.hasOwnProperty(key)) { continue; } var checkbox = document.querySelector("input[type=checkbox][data-extension=" + key + "]"); if (!checkbox) { console.warn("Failed to find checkbox for extension", key); continue; } settings[key] = { enabled: checkbox.checked }; // TODO save additional stuff if we have it } storage.set(settings, function () { return cb(chrome.runtime.lastError); }); } document.addEventListener("DOMContentLoaded", function () { // poor man's tab widget :) document.querySelectorAll(".tabbar").forEach(function (tabbar) { tabbar.buttons = []; tabbar.querySelectorAll("[data-tab-link]").forEach(function (button) { var tablink = button.dataset.tabLink var tabtarget = document.querySelector("[data-tab-id=" + tablink + "]"); button.addEventListener("click", function (event) { tabClicked(tabbar, button); event.preventDefault(); }); tabbar.buttons.push(button); // start with the one tab page that is active if (tabtarget.classList.contains("active")) { tabClicked(tabbar, button); } }); }); if (IS_FIREFOX) { document.querySelectorAll("[data-not-show-in=firefox]").forEach(function (item) { item.style.display = "none"; }); } - loadSettings(); - - // auto save when changing any setting - // TODO can we do that on closing, or does it not matter how often we do chrome storage sync thing? - document.querySelectorAll("input[type=checkbox]").forEach(function (item) { - item.addEventListener("click", function () { - var saveMessage = document.getElementById("save-message"); - saveMessage.innerText = ""; - - saveSettings(function (error) { - if (error) { - saveMessage.innerText = chrome.i18n.getMessage("options_save_failed"); - return; - } - - //saveMessage.innerText = chrome.i18n.getMessage("options_save_success"); - sendMessage("changed"); + // check whether the platform is supported before loading and activating settings + chrome.runtime.getPlatformInfo(function (info) { + if (!SUPPORTED_PLATFORMS.includes(info.os)) { + document.body.classList.add("not-supported"); + return; + } + + loadSettings(); + + // auto save when changing any setting + // TODO can we do that on closing, or does it not matter how often we do chrome storage sync thing? + document.querySelectorAll("input[type=checkbox]").forEach(function (item) { + item.addEventListener("click", function () { + var saveMessage = document.getElementById("save-message"); + saveMessage.innerText = ""; + + saveSettings(function (error) { + if (error) { + saveMessage.innerText = chrome.i18n.getMessage("options_save_failed"); + return; + } + + sendMessage("changed"); + }); }); }); }); document.getElementById("open-krunner-settings").addEventListener("click", function (event) { sendMessage("openKRunnerSettings"); event.preventDefault(); }); // Make translators credit behave like the one in KAboutData var translatorsAboutData = ""; var translators = chrome.i18n.getMessage("options_about_translators"); if (translators && translators !== "Your names") { translatorsAboutData = chrome.i18n.getMessage("options_about_translated_by", translators) } var translatorsAboutDataItem = document.getElementById("translators-aboutdata"); if (translatorsAboutData) { translatorsAboutDataItem.innerText = translatorsAboutData; } else { translatorsAboutDataItem.style.display = "none"; } });