C++ / fmt (pull_request) Successful in 3s
JS/TS / fmt (pull_request) Successful in 17s
JS/TS / lint (pull_request) Successful in 20s
Python / fmt (pull_request) Successful in 31s
Python / lint (pull_request) Successful in 30s
Python / test (pull_request) Successful in 1m40s
Python / typecheck (pull_request) Successful in 1m38s
C++ / build (pull_request) Successful in 2m15s
Rust / build (pull_request) Successful in 1m41s
Rust / fmt (pull_request) Successful in 59s
Python / buildcheck (pull_request) Successful in 2m40s
Rust / clippy (pull_request) Successful in 2m15s
C++ / clang-tidy (pull_request) Successful in 6m29s
99 lines
2.7 KiB
QML
99 lines
2.7 KiB
QML
pragma ComponentBehavior: Bound
|
|
|
|
import QtQuick
|
|
import ZShell.Config
|
|
import qs.Components
|
|
import qs.Helpers
|
|
import qs.Services
|
|
|
|
Item {
|
|
id: root
|
|
|
|
required property var bar
|
|
property color color: Colors.palette.m3primary
|
|
property Title current: text1
|
|
required property bool horizontal
|
|
// readonly property int maxWidth: 300
|
|
readonly property int maxSize: {
|
|
const otherModules = bar.children.filter(c => c.enabled && c.entryId && c.item !== this && c.entryId !== "spacer");
|
|
const otherSize = otherModules.reduce((acc, curr) => acc + (horizontal ? (curr.item?.nonAnimWidth ?? curr.width ?? 0) : (curr.item.nonAnimHeight ?? curr.height ?? 0)), 0);
|
|
return horizontal ? (bar.width - otherSize - bar.columnSpacing * (bar.children.length - 1) - bar.vPadding * 2) : (bar.height - otherSize - bar.rowSpacing * (bar.children.length - 1) - bar.vPadding * 4);
|
|
}
|
|
|
|
clip: true
|
|
implicitHeight: horizontal ? current.implicitHeight : current.implicitWidth + current.anchors.topMargin
|
|
implicitWidth: horizontal ? current.implicitWidth + current.anchors.leftMargin : current.implicitHeight + current.anchors.topMargin
|
|
|
|
Behavior on implicitHeight {
|
|
enabled: !root.horizontal
|
|
|
|
Anim {
|
|
type: Anim.DefaultEffects
|
|
}
|
|
}
|
|
Behavior on implicitWidth {
|
|
enabled: root.horizontal
|
|
|
|
Anim {
|
|
type: Anim.DefaultEffects
|
|
}
|
|
}
|
|
|
|
Title {
|
|
id: text1
|
|
}
|
|
|
|
Title {
|
|
id: text2
|
|
}
|
|
|
|
TextMetrics {
|
|
id: metrics
|
|
|
|
elide: Qt.ElideRight
|
|
elideWidth: root.maxSize - (root.horizontal ? root.current.anchors.leftMargin : 0)
|
|
font.family: "Rubik"
|
|
font.pointSize: Tokens.font.size.normal
|
|
text: Hypr.activeToplevel?.title ?? qsTr("Desktop")
|
|
|
|
onElideWidthChanged: root.current.text = elidedText
|
|
onTextChanged: {
|
|
const next = root.current === text1 ? text2 : text1;
|
|
next.text = elidedText;
|
|
root.current = next;
|
|
}
|
|
}
|
|
|
|
component Title: CustomText {
|
|
id: text
|
|
|
|
anchors.horizontalCenter: root.horizontal ? undefined : parent.horizontalCenter
|
|
anchors.left: root.horizontal ? parent.left : undefined
|
|
anchors.leftMargin: root.horizontal ? Tokens.spacing.small : 0
|
|
anchors.top: root.horizontal ? undefined : parent.top
|
|
anchors.topMargin: root.horizontal ? 0 : Tokens.spacing.small
|
|
anchors.verticalCenter: root.horizontal ? parent.verticalCenter : undefined
|
|
color: root.color
|
|
font.family: metrics.font.family
|
|
font.pointSize: metrics.font.pointSize
|
|
height: root.horizontal ? implicitHeight : implicitWidth
|
|
opacity: root.current === this ? 1 : 0
|
|
width: root.horizontal ? implicitWidth : implicitHeight
|
|
|
|
Behavior on opacity {
|
|
Anim {
|
|
}
|
|
}
|
|
transform: [
|
|
Translate {
|
|
x: !root.horizontal ? -text.implicitWidth + text.implicitHeight : 0
|
|
},
|
|
Rotation {
|
|
angle: root.horizontal ? 0 : 270
|
|
origin.x: text.implicitHeight / 2
|
|
origin.y: text.implicitHeight / 2
|
|
}
|
|
]
|
|
}
|
|
}
|