kwin/kcmkwin/kwindecoration/package/contents/ui/ButtonGroup.qml
Nate Graham 592c82abeb [kcmkwin/kwindecoration] Clean up QML code
Various fixes:
- Remove unneeded PlasmaCore import
- Re-arrange imports to be alphabetical and grouped consistently
- Use standard import names
- Use Kirigami units explicitly
- Remove unused ids
- Remove unneeded cases of setting aproperty to its default value
- Use Layouts where appropriate instead of lots of anchors
- Reduce number of unnecessary items
- Fix inappropriate mutation of `width` and `height` inside layouts

Visual changes are extremely minor and of a bugfixy nature.

BUG: 428883
FIXED-IN: 5.21
2020-11-18 14:53:11 +00:00

63 lines
2.3 KiB
QML

/*
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
import QtQuick 2.7
import org.kde.kwin.private.kdecoration 1.0 as KDecoration
ListView {
id: view
property string key
property bool dragging: false
property int iconSize: units.iconSizes.small
orientation: ListView.Horizontal
interactive: false
spacing: units.smallSpacing
implicitHeight: iconSize
implicitWidth: count * (iconSize + units.smallSpacing) - Math.min(1, count) * units.smallSpacing
delegate: Item {
width: view.iconSize
height: view.iconSize
KDecoration.Button {
id: button
property int itemIndex: index
property var buttonsModel: parent.ListView.view.model
bridge: bridgeItem.bridge
settings: settingsItem
type: model["button"]
width: view.iconSize
height: view.iconSize
anchors.fill: Drag.active ? undefined : parent
Drag.keys: [ "decoButtonRemove", view.key ]
Drag.active: dragArea.drag.active
Drag.onActiveChanged: view.dragging = Drag.active
color: palette.windowText
opacity: parent.enabled ? 1.0 : 0.3
}
MouseArea {
id: dragArea
cursorShape: Qt.SizeAllCursor
anchors.fill: parent
drag.target: button
onReleased: {
if (drag.target.Drag.target) {
drag.target.Drag.drop();
} else {
drag.target.Drag.cancel();
}
}
}
}
add: Transition {
NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: units.longDuration/2 }
NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: units.longDuration/2 }
}
move: Transition {
NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: units.longDuration/2 }
NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: units.longDuration/2 }
}
displaced: Transition {
NumberAnimation { properties: "x,y"; duration: units.longDuration; easing.type: Easing.OutBounce }
}
}