diff --git a/applets/kimpanel/package/contents/ui/StatusIcon.qml b/applets/kimpanel/package/contents/ui/StatusIcon.qml index 8ba9fe94c..a334aef6c 100644 --- a/applets/kimpanel/package/contents/ui/StatusIcon.qml +++ b/applets/kimpanel/package/contents/ui/StatusIcon.qml @@ -1,86 +1,99 @@ /* * Copyright 2014 Weng Xuetian * * 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 2 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, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. */ import QtQuick 2.0 import QtQuick.Layouts 1.1 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.kquickcontrolsaddons 2.0 Item { id: statusIcon property string icon; property string label; property string tip; property string hint; signal triggered(variant button); property int iconSize: units.roundToIconSize(Math.min(parent.width, parent.height)) - width: iconSize - height: iconSize opacity: 'disable' == hint ? 0.3 : 1 function extractLabelString(l) { if (l.length >= 2 && l.charCodeAt(0) < 127 && l.charCodeAt(1) < 127) { return l.substring(0, 2); } else { return l.substring(0, 1); } } + function iconPath(p) { + if (p.length > 0) { + if (p[0] === '/') { + return p; + } else { + return "image://icon/" + p; + } + } + return p; + } + PlasmaCore.IconItem { id: imageIcon - anchors.fill: parent + anchors.centerIn: parent + width: iconSize + height: iconSize scale: mouseArea.pressed ? 0.9 : 1 source: statusIcon.icon visible: statusIcon.icon.length > 0 animated: false // active: mouseArea.containsMouse } PlasmaComponents.Label { id: textIcon - anchors.fill: parent + anchors.centerIn: parent + width: iconSize + height: iconSize scale: (mouseArea.pressed ? 0.9 : 1) // a reasonable large size to make Text.Fit work - minimumPointSize: theme.smallestFont.pointSize + minimumPointSize: 0 font.pointSize: 1024 fontSizeMode: Text.Fit verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter text: extractLabelString(label) visible: icon.length == 0 } MouseArea { id: mouseArea anchors.fill: parent hoverEnabled: true acceptedButtons: Qt.LeftButton | Qt.RightButton onClicked: { statusIcon.triggered(mouse.button); } PlasmaCore.ToolTipArea { anchors.fill: parent mainText: statusIcon.label subText: statusIcon.tip icon: statusIcon.icon } } } diff --git a/applets/kimpanel/package/contents/ui/main.qml b/applets/kimpanel/package/contents/ui/main.qml index 13698f962..da5d0a43f 100644 --- a/applets/kimpanel/package/contents/ui/main.qml +++ b/applets/kimpanel/package/contents/ui/main.qml @@ -1,226 +1,214 @@ /* * Copyright 2014 Weng Xuetian * * 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 2 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, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. */ import QtQuick 2.0 import QtQuick.Layouts 1.1 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.kquickcontrolsaddons 2.0 -import org.kde.plasma.workspace.keyboardlayout 1.0 Item { id: kimpanel property int visibleButtons: 0 property bool vertical: plasmoid.formFactor === PlasmaCore.Types.Vertical LayoutMirroring.enabled: !vertical && Qt.application.layoutDirection === Qt.RightToLeft LayoutMirroring.childrenInherit: true Layout.minimumWidth: vertical ? units.iconSizes.small : items.implicitWidth Layout.minimumHeight: !vertical ? units.iconSizes.small : items.implicitHeight Layout.preferredHeight: Layout.minimumHeight Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation InputPanel { } Flow { id: items width: parent.width height: parent.height - anchors.centerIn: parent + x: (parent.width - childrenRect.width) / 2 + y: (parent.height - childrenRect.height) / 2 flow: kimpanel.vertical ? Flow.LeftToRight : Flow.TopToBottom - property int iconSize: units.roundToIconSize(Math.min(width, height)) - - StatusIcon { - readonly property QtObject kl: KeyboardLayout { - id: layout - function nextLayout() { - var layouts = layout.layouts; - var index = (layouts.indexOf(layout.currentLayout)+1) % layouts.length; - layout.currentLayout = layouts[index]; - } - } - - width: visible ? items.iconSize : 0 - height: items.iconSize - visible: list.count === 0 - label: layout.currentLayout.substr(0, 2).toLowerCase() - tip: layout.currentLayout - onTriggered: if (button === Qt.LeftButton) { - layout.nextLayout() - } - } + property int iconSize: Math.min(units.iconSizeHints.panel, units.roundToIconSize(Math.min(width, height))) Repeater { model: ListModel { id: list dynamicRoles: true } - delegate: StatusIcon { - id: statusIcon - label: model.label - tip: model.tip - icon: model.icon - hint: model.hint - onTriggered : { - if (button === Qt.LeftButton) { - clickHandler(model.key); - // clickHandler will trigger the menu, but we have to wait for - // the menu data. So we have to set the visual parent ahead. - actionMenu.visualParent = statusIcon; - } else { - contextMenu.open(statusIcon, {key: model.key, label: model.label}); + delegate: Item { + id: iconDelegate + width: items.iconSize + height: items.iconSize + StatusIcon { + id: statusIcon + anchors.centerIn: parent + width: items.iconSize + height: items.iconSize + label: model.label + tip: model.tip + icon: model.icon + hint: model.hint + onTriggered : { + if (button === Qt.LeftButton) { + clickHandler(model.key); + // clickHandler will trigger the menu, but we have to wait for + // the menu data. So we have to set the visual parent ahead. + actionMenu.visualParent = statusIcon; + } else { + contextMenu.open(statusIcon, {key: model.key, label: model.label}); + } } } } } } function clickHandler(key) { var service = dataEngine.serviceForSource("statusbar"); var operation = service.operationDescription("TriggerProperty"); operation.key = key; service.startOperationCall(operation); } function action(key) { var service = dataEngine.serviceForSource("statusbar"); var operation = service.operationDescription(key); service.startOperationCall(operation); } function hideAction(key) { // We must use assignment to change the configuration property, // otherwise it won't get notified. var hiddenList = plasmoid.configuration.hiddenList; if (hiddenList.indexOf(key) === -1) { hiddenList.push(key); plasmoid.configuration.hiddenList = hiddenList; } timer.restart(); } function showAction(key) { // We must use assignment to change the configuration property, // otherwise it won't get notified. var hiddenList = plasmoid.configuration.hiddenList; var index = hiddenList.indexOf(key); if (index !== -1) { hiddenList.splice(index, 1); plasmoid.configuration.hiddenList = hiddenList; } timer.restart(); } function showMenu(menu, menuData) { if (!menuData) { return; } if (menuData["timestamp"] > menu.timestamp) { menu.timestamp = menuData["timestamp"]; var actionList = []; for (var i = 0; i < menuData["props"].length; i++ ) { actionList.push({"actionId": menuData["props"][i].key, "icon": menuData["props"][i].icon, "text": menuData["props"][i].label, hint: menuData["props"][i].hint}); } if (actionList.length > 0) { menu.actionList = actionList; menu.open(); } } } ActionMenu { property var timestamp: 0; id: actionMenu onActionClicked: { clickHandler(actionId); } } ContextMenu { id: contextMenu } Timer { id: timer interval: 50 onTriggered: { var data = dataEngine.data["statusbar"]["Properties"]; if (!data) { return; } var count = list.count; var c = 0, i; var hiddenActions = []; for (i = 0; i < data.length; i ++) { if (plasmoid.configuration.hiddenList.indexOf(data[i].key) !== -1) { hiddenActions.push({'key': data[i].key, 'icon': data[i].icon, 'label': data[i].label}); } else { c = c + 1; } } if (c < count) { list.remove(c, count - c); } kimpanel.visibleButtons = c; c = 0; for (i = 0; i < data.length; i ++) { if (plasmoid.configuration.hiddenList.indexOf(data[i].key) !== -1) { continue; } var itemData = {'key': data[i].key, 'icon': data[i].icon, 'label': data[i].label, 'tip': data[i].tip, 'hint': data[i].hint }; if (c < count) { list.set(c, itemData); } else { list.append(itemData); } c = c + 1; } contextMenu.actionList = hiddenActions; } } PlasmaCore.DataSource { id: dataEngine engine: "kimpanel" connectedSources: ["statusbar"] onDataChanged: { showMenu(actionMenu, dataEngine.data["statusbar"]["Menu"]); var data = dataEngine.data["statusbar"]["Properties"]; if (!data) { kimpanel.visibleButtons = 0; return; } timer.restart(); } } } diff --git a/layout-templates/org.kde.plasma.desktop.defaultPanel/contents/layout.js b/layout-templates/org.kde.plasma.desktop.defaultPanel/contents/layout.js index a465526fc..048671ef4 100644 --- a/layout-templates/org.kde.plasma.desktop.defaultPanel/contents/layout.js +++ b/layout-templates/org.kde.plasma.desktop.defaultPanel/contents/layout.js @@ -1,41 +1,84 @@ var panel = new Panel var panelScreen = panel.screen var freeEdges = {"bottom": true, "top": true, "left": true, "right": true} for (i = 0; i < panelIds.length; ++i) { var tmpPanel = panelById(panelIds[i]) if (tmpPanel.screen == panelScreen) { // Ignore the new panel if (tmpPanel.id != panel.id) { freeEdges[tmpPanel.location] = false; } } } if (freeEdges["bottom"] == true) { panel.location = "bottom"; } else if (freeEdges["top"] == true) { panel.location = "top"; } else if (freeEdges["left"] == true) { panel.location = "left"; } else if (freeEdges["right"] == true) { panel.location = "right"; } else { // There is no free edge, so leave the default value panel.location = "top"; } panel.height = gridUnit * 2 var kickoff = panel.addWidget("org.kde.plasma.kickoff") kickoff.currentConfigGroup = ["Shortcuts"] kickoff.writeConfig("global", "Alt+F1") //panel.addWidget("org.kde.plasma.showActivityManager") panel.addWidget("org.kde.plasma.pager") panel.addWidget("org.kde.plasma.taskmanager") -panel.addWidget("org.kde.plasma.kimpanel"); + +/* Next up is determining whether to add the Input Method Panel + * widget to the panel or not. This is done based on whether + * the system locale's language id is a member of the following + * white list of languages which are known to pull in one of + * our supported IME backends when chosen during installation + * of common distributions. */ + +var langIds = ["as", // Assamese + "bn", // Bengali + "bo", // Tibetan + "brx", // Bodo + "doi", // Dogri + "gu", // Gujarati + "hi", // Hindi + "ja", // Japanese + "kn", // Kannada + "ko", // Korean + "kok", // Konkani + "ks", // Kashmiri + "lep", // Lepcha + "mai", // Maithili + "ml", // Malayalam + "mni", // Manipuri + "mr", // Marathi + "ne", // Nepali + "or", // Odia + "pa", // Punjabi + "sa", // Sanskrit + "sat", // Santali + "sd", // Sindhi + "si", // Sinhala + "ta", // Tamil + "te", // Telugu + "th", // Thai + "ur", // Urdu + "vi", // Vietnamese + "zh_CN", // Simplified Chinese + "zh_TW"] // Traditional Chinese + +if (langIds.indexOf(languageId) != -1) { + panel.addWidget("org.kde.plasma.kimpanel"); +} + panel.addWidget("org.kde.plasma.systemtray") panel.addWidget("org.kde.plasma.digitalclock") panel.addWidget("org.kde.plasma.showdesktop")