internal: remove padded rect
This commit is contained in:
parent
01b38be6af
commit
72101f4e86
3 changed files with 67 additions and 107 deletions
|
|
@ -3,26 +3,31 @@ import "root:/services"
|
||||||
import "root:/config"
|
import "root:/config"
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
|
||||||
PaddedRect {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
required property Actions.Action modelData
|
required property Actions.Action modelData
|
||||||
required property var list
|
required property var list
|
||||||
|
|
||||||
implicitHeight: LauncherConfig.sizes.itemHeight
|
implicitHeight: LauncherConfig.sizes.itemHeight
|
||||||
padding: [Appearance.padding.smaller, Appearance.padding.larger]
|
|
||||||
|
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
||||||
StateLayer {
|
StateLayer {
|
||||||
radius: Appearance.rounding.normal
|
radius: Appearance.rounding.full
|
||||||
|
|
||||||
function onClicked(): void {
|
function onClicked(): void {
|
||||||
root.modelData.onClicked(root.list);
|
root.modelData.onClicked(root.list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.leftMargin: Appearance.padding.larger
|
||||||
|
anchors.rightMargin: Appearance.padding.larger
|
||||||
|
anchors.margins: Appearance.padding.smaller
|
||||||
|
|
||||||
MaterialIcon {
|
MaterialIcon {
|
||||||
id: icon
|
id: icon
|
||||||
|
|
||||||
|
|
@ -58,4 +63,5 @@ PaddedRect {
|
||||||
anchors.top: name.bottom
|
anchors.top: name.bottom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,14 +5,13 @@ import Quickshell
|
||||||
import Quickshell.Widgets
|
import Quickshell.Widgets
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
|
||||||
PaddedRect {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
required property DesktopEntry modelData
|
required property DesktopEntry modelData
|
||||||
required property PersistentProperties visibilities
|
required property PersistentProperties visibilities
|
||||||
|
|
||||||
implicitHeight: LauncherConfig.sizes.itemHeight
|
implicitHeight: LauncherConfig.sizes.itemHeight
|
||||||
padding: [Appearance.padding.smaller, Appearance.padding.normal]
|
|
||||||
|
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
@ -26,6 +25,12 @@ PaddedRect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.leftMargin: Appearance.padding.larger
|
||||||
|
anchors.rightMargin: Appearance.padding.larger
|
||||||
|
anchors.margins: Appearance.padding.smaller
|
||||||
|
|
||||||
IconImage {
|
IconImage {
|
||||||
id: icon
|
id: icon
|
||||||
|
|
||||||
|
|
@ -61,4 +66,5 @@ PaddedRect {
|
||||||
anchors.top: name.bottom
|
anchors.top: name.bottom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
import "root:/config"
|
|
||||||
import QtQuick
|
|
||||||
|
|
||||||
StyledRect {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
property var padding: 0
|
|
||||||
|
|
||||||
readonly property real paddingTop: getRealPadding().top
|
|
||||||
readonly property real paddingRight: getRealPadding().right
|
|
||||||
readonly property real paddingBottom: getRealPadding().bottom
|
|
||||||
readonly property real paddingLeft: getRealPadding().left
|
|
||||||
readonly property real paddingX: getRealPadding().x
|
|
||||||
readonly property real paddingY: getRealPadding().y
|
|
||||||
|
|
||||||
function getRealPadding() {
|
|
||||||
const pad = {};
|
|
||||||
|
|
||||||
if (Array.isArray(padding)) {
|
|
||||||
if (padding.length === 2) {
|
|
||||||
pad.top = pad.bottom = padding[0];
|
|
||||||
pad.left = pad.right = padding[1];
|
|
||||||
} else if (padding.length === 3) {
|
|
||||||
pad.top = padding[0];
|
|
||||||
pad.left = pad.right = padding[1];
|
|
||||||
pad.bottom = padding[2];
|
|
||||||
} else if (padding.length === 4) {
|
|
||||||
pad.top = padding[0];
|
|
||||||
pad.right = padding[1];
|
|
||||||
pad.bottom = padding[2];
|
|
||||||
pad.left = padding[3];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
pad.top = pad.bottom = pad.left = pad.right = padding;
|
|
||||||
}
|
|
||||||
|
|
||||||
pad.x = pad.left + pad.right;
|
|
||||||
pad.y = pad.top + pad.bottom;
|
|
||||||
|
|
||||||
return pad;
|
|
||||||
}
|
|
||||||
|
|
||||||
implicitWidth: childrenRect.width + paddingX
|
|
||||||
implicitHeight: childrenRect.height + paddingY
|
|
||||||
|
|
||||||
onChildrenChanged: {
|
|
||||||
for (const child of children) {
|
|
||||||
child.x = Qt.binding(() => paddingLeft);
|
|
||||||
child.y = Qt.binding(() => paddingTop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Reference in a new issue