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 bool inPanel: (plasmoid.location == PlasmaCore.Types.TopEdge | ||||
29 | || plasmoid.location == PlasmaCore.Types.RightEdge | ||||
30 | || plasmoid.location == PlasmaCore.Types.BottomEdge | ||||
31 | || plasmoid.location == PlasmaCore.Types.LeftEdge) | ||||
28 | readonly property bool vertical: (plasmoid.formFactor == PlasmaCore.Types.Vertical) | 32 | readonly property bool vertical: (plasmoid.formFactor == PlasmaCore.Types.Vertical) | ||
29 | readonly property bool useCustomButtonImage: (plasmoid.configuration.useCustomButtonImage | 33 | readonly property bool useCustomButtonImage: (plasmoid.configuration.useCustomButtonImage | ||
30 | && plasmoid.configuration.customButtonImage.length != 0) | 34 | && plasmoid.configuration.customButtonImage.length != 0) | ||
31 | property QtObject dashWindow: null | 35 | property QtObject dashWindow: null | ||
32 | 36 | | |||
33 | onWidthChanged: updateSizeHints() | 37 | onWidthChanged: updateSizeHints() | ||
34 | onHeightChanged: updateSizeHints() | 38 | onHeightChanged: updateSizeHints() | ||
35 | 39 | | |||
36 | onDashWindowChanged: { | 40 | onDashWindowChanged: { | ||
37 | if (dashWindow) { | 41 | if (dashWindow) { | ||
38 | dashWindow.visualParent = root; | 42 | dashWindow.visualParent = root; | ||
39 | } | 43 | } | ||
40 | } | 44 | } | ||
41 | 45 | | |||
42 | function updateSizeHints() { | 46 | function updateSizeHints() { | ||
43 | if (useCustomButtonImage) { | 47 | if (useCustomButtonImage) { | ||
44 | if (vertical) { | 48 | if (vertical) { | ||
45 | var scaledHeight = Math.floor(parent.width * (buttonIcon.implicitHeight / buttonIcon.implicitWidth)); | 49 | var scaledHeight = Math.floor(parent.width * (buttonIcon.implicitHeight / buttonIcon.implicitWidth)); | ||
46 | root.Layout.minimumHeight = scaledHeight; | 50 | root.Layout.minimumHeight = scaledHeight; | ||
47 | root.Layout.maximumHeight = scaledHeight; | 51 | root.Layout.maximumHeight = scaledHeight; | ||
48 | root.Layout.minimumWidth = units.iconSizes.small; | 52 | root.Layout.minimumWidth = units.iconSizes.small; | ||
49 | root.Layout.maximumWidth = undefined; | 53 | root.Layout.maximumWidth = inPanel ? units.iconSizeHints.panel : undefined; | ||
50 | } else { | 54 | } else { | ||
51 | var scaledWidth = Math.floor(parent.height * (buttonIcon.implicitWidth / buttonIcon.implicitHeight)); | 55 | var scaledWidth = Math.floor(parent.height * (buttonIcon.implicitWidth / buttonIcon.implicitHeight)); | ||
52 | root.Layout.minimumWidth = scaledWidth; | 56 | root.Layout.minimumWidth = scaledWidth; | ||
53 | root.Layout.maximumWidth = scaledWidth; | 57 | root.Layout.maximumWidth = scaledWidth; | ||
54 | root.Layout.minimumHeight = units.iconSizes.small; | 58 | root.Layout.minimumHeight = units.iconSizes.small; | ||
55 | root.Layout.maximumHeight = undefined; | 59 | root.Layout.maximumHeight = inPanel ? units.iconSizeHints.panel : undefined; | ||
56 | } | 60 | } | ||
57 | } else { | 61 | } else { | ||
58 | root.Layout.minimumWidth = units.iconSizes.small; | 62 | root.Layout.minimumWidth = units.iconSizes.small; | ||
59 | root.Layout.maximumWidth = undefined; | 63 | root.Layout.maximumWidth = inPanel ? units.iconSizeHints.panel : undefined; | ||
60 | root.Layout.minimumHeight = units.iconSizes.small | 64 | root.Layout.minimumHeight = units.iconSizes.small | ||
61 | root.Layout.maximumHeight = undefined; | 65 | root.Layout.maximumHeight = inPanel ? units.iconSizeHints.panel : undefined; | ||
62 | } | 66 | } | ||
63 | } | 67 | } | ||
64 | 68 | | |||
65 | PlasmaCore.IconItem { | 69 | PlasmaCore.IconItem { | ||
66 | id: buttonIcon | 70 | id: buttonIcon | ||
67 | 71 | | |||
68 | anchors.fill: parent | 72 | anchors.fill: parent | ||
69 | 73 | | |||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |