internal: remove padded rect
This commit is contained in:
parent
01b38be6af
commit
72101f4e86
3 changed files with 67 additions and 107 deletions
|
|
@ -3,59 +3,65 @@ import "root:/services"
|
|||
import "root:/config"
|
||||
import QtQuick
|
||||
|
||||
PaddedRect {
|
||||
Item {
|
||||
id: root
|
||||
|
||||
required property Actions.Action modelData
|
||||
required property var list
|
||||
|
||||
implicitHeight: LauncherConfig.sizes.itemHeight
|
||||
padding: [Appearance.padding.smaller, Appearance.padding.larger]
|
||||
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
StateLayer {
|
||||
radius: Appearance.rounding.normal
|
||||
radius: Appearance.rounding.full
|
||||
|
||||
function onClicked(): void {
|
||||
root.modelData.onClicked(root.list);
|
||||
}
|
||||
}
|
||||
|
||||
MaterialIcon {
|
||||
id: icon
|
||||
|
||||
text: root.modelData.icon
|
||||
font.pointSize: Appearance.font.size.extraLarge
|
||||
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
Item {
|
||||
anchors.left: icon.right
|
||||
anchors.leftMargin: Appearance.spacing.larger
|
||||
anchors.verticalCenter: icon.verticalCenter
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: Appearance.padding.larger
|
||||
anchors.rightMargin: Appearance.padding.larger
|
||||
anchors.margins: Appearance.padding.smaller
|
||||
|
||||
implicitWidth: parent.width - icon.width
|
||||
implicitHeight: childrenRect.height
|
||||
MaterialIcon {
|
||||
id: icon
|
||||
|
||||
StyledText {
|
||||
id: name
|
||||
text: root.modelData.icon
|
||||
font.pointSize: Appearance.font.size.extraLarge
|
||||
|
||||
text: root.modelData.name
|
||||
font.pointSize: Appearance.font.size.normal
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: root.modelData.desc
|
||||
font.pointSize: Appearance.font.size.small
|
||||
color: Colours.alpha(Colours.palette.m3outline, true)
|
||||
Item {
|
||||
anchors.left: icon.right
|
||||
anchors.leftMargin: Appearance.spacing.larger
|
||||
anchors.verticalCenter: icon.verticalCenter
|
||||
|
||||
elide: Text.ElideRight
|
||||
width: root.width - icon.width - Appearance.rounding.normal * 2
|
||||
implicitWidth: parent.width - icon.width
|
||||
implicitHeight: childrenRect.height
|
||||
|
||||
anchors.top: name.bottom
|
||||
StyledText {
|
||||
id: name
|
||||
|
||||
text: root.modelData.name
|
||||
font.pointSize: Appearance.font.size.normal
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: root.modelData.desc
|
||||
font.pointSize: Appearance.font.size.small
|
||||
color: Colours.alpha(Colours.palette.m3outline, true)
|
||||
|
||||
elide: Text.ElideRight
|
||||
width: root.width - icon.width - Appearance.rounding.normal * 2
|
||||
|
||||
anchors.top: name.bottom
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,14 +5,13 @@ import Quickshell
|
|||
import Quickshell.Widgets
|
||||
import QtQuick
|
||||
|
||||
PaddedRect {
|
||||
Item {
|
||||
id: root
|
||||
|
||||
required property DesktopEntry modelData
|
||||
required property PersistentProperties visibilities
|
||||
|
||||
implicitHeight: LauncherConfig.sizes.itemHeight
|
||||
padding: [Appearance.padding.smaller, Appearance.padding.normal]
|
||||
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
|
@ -26,39 +25,46 @@ PaddedRect {
|
|||
}
|
||||
}
|
||||
|
||||
IconImage {
|
||||
id: icon
|
||||
|
||||
source: Quickshell.iconPath(root.modelData.icon, "image-missing")
|
||||
implicitSize: parent.height * 0.8
|
||||
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
Item {
|
||||
anchors.left: icon.right
|
||||
anchors.leftMargin: Appearance.spacing.normal
|
||||
anchors.verticalCenter: icon.verticalCenter
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: Appearance.padding.larger
|
||||
anchors.rightMargin: Appearance.padding.larger
|
||||
anchors.margins: Appearance.padding.smaller
|
||||
|
||||
implicitWidth: parent.width - icon.width
|
||||
implicitHeight: childrenRect.height
|
||||
IconImage {
|
||||
id: icon
|
||||
|
||||
StyledText {
|
||||
id: name
|
||||
source: Quickshell.iconPath(root.modelData.icon, "image-missing")
|
||||
implicitSize: parent.height * 0.8
|
||||
|
||||
text: root.modelData.name
|
||||
font.pointSize: Appearance.font.size.normal
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: root.modelData.comment || root.modelData.genericName || root.modelData.name
|
||||
font.pointSize: Appearance.font.size.small
|
||||
color: Colours.alpha(Colours.palette.m3outline, true)
|
||||
Item {
|
||||
anchors.left: icon.right
|
||||
anchors.leftMargin: Appearance.spacing.normal
|
||||
anchors.verticalCenter: icon.verticalCenter
|
||||
|
||||
elide: Text.ElideRight
|
||||
width: root.width - icon.width - Appearance.rounding.normal * 2
|
||||
implicitWidth: parent.width - icon.width
|
||||
implicitHeight: childrenRect.height
|
||||
|
||||
anchors.top: name.bottom
|
||||
StyledText {
|
||||
id: name
|
||||
|
||||
text: root.modelData.name
|
||||
font.pointSize: Appearance.font.size.normal
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: root.modelData.comment || root.modelData.genericName || root.modelData.name
|
||||
font.pointSize: Appearance.font.size.small
|
||||
color: Colours.alpha(Colours.palette.m3outline, true)
|
||||
|
||||
elide: Text.ElideRight
|
||||
width: root.width - icon.width - Appearance.rounding.normal * 2
|
||||
|
||||
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