1import QtQuick 2.0 2import QtQuick.Layouts 1.3 3import QtQuick.Controls 2.12 4import org.kde.plasma.core 2.0 as PlasmaCore 5import org.kde.plasma.components 3.0 as PlasmaComponents 6import org.kde.plasma.plasmoid 2.0 7import org.kde.plasma.extras 2.0 as PlasmaExtras 8import com.github.uim 1.0 9import "messageProcessor.js" as MessageProcessor 10 11Item { 12 property var dataModel: [{ 13 "value": '?', 14 "title": 'Unable to connect to uim' 15 }] 16 17 id: root 18 19 Plasmoid.associatedApplication: "uim-pref-qt5" 20 Plasmoid.preferredRepresentation: Plasmoid.compactRepresentation 21 Plasmoid.fullRepresentation: Plasmoid.compactRepresentation 22 23 Plasmoid.compactRepresentation: Row { 24 id: compactRoot 25 26 Layout.minimumWidth: childrenRect.width 27 Layout.maximumWidth: Layout.minimumWidth 28 29 Repeater { 30 id: repeater 31 model: root.dataModel 32 33 PlasmaComponents.Label { 34 text: modelData.value 35 font.pixelSize: parent.height 36 fontSizeMode: "Fit" 37 38 height: parent.height 39 width: Math.max(paintedWidth, parent.height) 40 41 horizontalAlignment: "AlignHCenter" 42 } 43 } 44 } 45 46 Plasmoid.toolTipSubText: 47 root.dataModel.map(e => `<b>${e.title}</b> (${e.value})<br/>${e.comment}<br/>`).join('<br/>') 48 Plasmoid.toolTipTextFormat: Text.RichText 49 Plasmoid.icon: '/usr/share/uim/pixmaps/uim-icon64.png' //TODO: resolve this using uim resources 50 51 resources: UimSocket { 52 id: socket 53 onMessageReceived: { 54 // If the method returns null, it means the new model is the same as old 55 const newModel = MessageProcessor.getUpdatedModel(msg, root.dataModel); 56 if (newModel) { 57 // only set this if model is new, to avoid unnecessary re-paints 58 root.dataModel = newModel; 59 } 60 } 61 } 62} 63