Changeset View
Changeset View
Standalone View
Standalone View
applets/kicker/package/contents/ui/CompactRepresentation.qml
Show All 19 Lines | |||||
20 | import QtQuick 2.0 | 20 | import QtQuick 2.0 | ||
21 | import QtQuick.Layouts 1.1 | 21 | import QtQuick.Layouts 1.1 | ||
22 | 22 | | |||
23 | import org.kde.plasma.core 2.0 as PlasmaCore | 23 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
24 | 24 | | |||
25 | Item { | 25 | Item { | ||
26 | id: root | 26 | id: root | ||
27 | 27 | | |||
28 | readonly property var iconSizes: ["small", "smallMedium", "medium", "large", "huge", "enormous"]; | ||||
29 | | ||||
28 | readonly property bool vertical: (plasmoid.formFactor == PlasmaCore.Types.Vertical) | 30 | readonly property bool vertical: (plasmoid.formFactor == PlasmaCore.Types.Vertical) | ||
29 | readonly property bool useCustomButtonImage: (plasmoid.configuration.useCustomButtonImage | 31 | readonly property bool useCustomButtonImage: (plasmoid.configuration.useCustomButtonImage | ||
30 | && plasmoid.configuration.customButtonImage.length != 0) | 32 | && plasmoid.configuration.customButtonImage.length != 0) | ||
31 | property QtObject dashWindow: null | 33 | property QtObject dashWindow: null | ||
32 | 34 | | |||
33 | onWidthChanged: updateSizeHints() | 35 | onWidthChanged: updateSizeHints() | ||
34 | onHeightChanged: updateSizeHints() | 36 | onHeightChanged: updateSizeHints() | ||
35 | 37 | | |||
36 | onDashWindowChanged: { | 38 | onDashWindowChanged: { | ||
37 | if (dashWindow) { | 39 | if (dashWindow) { | ||
38 | dashWindow.visualParent = root; | 40 | dashWindow.visualParent = root; | ||
39 | } | 41 | } | ||
40 | } | 42 | } | ||
41 | 43 | | |||
42 | function updateSizeHints() { | 44 | function updateSizeHints() { | ||
43 | if (useCustomButtonImage) { | 45 | if (useCustomButtonImage) { | ||
44 | if (vertical) { | 46 | if (vertical) { | ||
45 | var scaledHeight = Math.floor(parent.width * (buttonIcon.implicitHeight / buttonIcon.implicitWidth)); | 47 | var scaledHeight = Math.floor(parent.width * (buttonIcon.implicitHeight / buttonIcon.implicitWidth)); | ||
46 | root.Layout.minimumHeight = scaledHeight; | 48 | root.Layout.minimumHeight = scaledHeight; | ||
47 | root.Layout.maximumHeight = scaledHeight; | 49 | root.Layout.maximumHeight = scaledHeight; | ||
48 | root.Layout.minimumWidth = units.iconSizes.small; | 50 | root.Layout.minimumWidth = units.iconSizes.small; | ||
49 | root.Layout.maximumWidth = undefined; | 51 | root.Layout.maximumWidth = units.iconSizes[iconSizes[plasmoid.configuration.iconSize]]; | ||
50 | } else { | 52 | } else { | ||
51 | var scaledWidth = Math.floor(parent.height * (buttonIcon.implicitWidth / buttonIcon.implicitHeight)); | 53 | var scaledWidth = Math.floor(parent.height * (buttonIcon.implicitWidth / buttonIcon.implicitHeight)); | ||
52 | root.Layout.minimumWidth = scaledWidth; | 54 | root.Layout.minimumWidth = scaledWidth; | ||
53 | root.Layout.maximumWidth = scaledWidth; | 55 | root.Layout.maximumWidth = scaledWidth; | ||
54 | root.Layout.minimumHeight = units.iconSizes.small; | 56 | root.Layout.minimumHeight = units.iconSizes.small; | ||
55 | root.Layout.maximumHeight = undefined; | 57 | root.Layout.maximumHeight = units.iconSizes[iconSizes[plasmoid.configuration.iconSize]]; | ||
56 | } | 58 | } | ||
57 | } else { | 59 | } else { | ||
58 | root.Layout.minimumWidth = units.iconSizes.small; | 60 | root.Layout.minimumWidth = units.iconSizes.small; | ||
59 | root.Layout.maximumWidth = undefined; | 61 | root.Layout.maximumWidth = vertical ? units.iconSizes[iconSizes[plasmoid.configuration.iconSize]] : undefined; | ||
60 | root.Layout.minimumHeight = units.iconSizes.small | 62 | root.Layout.minimumHeight = units.iconSizes.small | ||
61 | root.Layout.maximumHeight = undefined; | 63 | root.Layout.maximumHeight = vertical ? units.iconSizes[iconSizes[plasmoid.configuration.iconSize]] : undefined; | ||
62 | } | 64 | } | ||
63 | } | 65 | } | ||
64 | 66 | | |||
65 | PlasmaCore.IconItem { | 67 | PlasmaCore.IconItem { | ||
66 | id: buttonIcon | 68 | id: buttonIcon | ||
67 | 69 | | |||
68 | anchors.fill: parent | 70 | anchors.fill: parent | ||
69 | 71 | | |||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |