forked from Shinonome/dots-hyprland
bar: component loader
This commit is contained in:
@@ -16,11 +16,8 @@ Item {
|
||||
Side {
|
||||
id: centerSide
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
FallbackLoader {
|
||||
asynchronous: true
|
||||
source: "/home/end/.config/quickshell/ii/modules/ii/bar/WrongModuleName"
|
||||
fallbacks: ["/home/end/.config/quickshell/ii/modules/ii/bar/Workspaces.qml"]
|
||||
HBarUserFallbackComponentRepeater {
|
||||
componentNames: [["Workspaces"]]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import qs.modules.common as C
|
||||
import qs.modules.common.widgets as W
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
property bool startSide: false
|
||||
property bool endSide: false
|
||||
|
||||
property alias color: bg.color
|
||||
property real margins: 4
|
||||
property real padding: 4
|
||||
default property alias data: layout.data
|
||||
|
||||
readonly property bool vertical: C.Config.options.bar.vertical
|
||||
readonly property bool m3eRadius: C.Config.options.hefty.bar.m3ExpressiveGrouping
|
||||
readonly property real barUndirectionalWidth: C.Config.options.bar.vertical ? C.Appearance.sizes.baseVerticalBarWidth : C.Appearance.sizes.baseBarHeight
|
||||
|
||||
implicitWidth: vertical ? barUndirectionalWidth : layout.implicitWidth + (padding + margins) * 2
|
||||
implicitHeight: vertical ? layout.implicitHeight + (padding + margins) * 2 : barUndirectionalWidth
|
||||
|
||||
W.StyledRectangle {
|
||||
id: bg
|
||||
anchors.centerIn: parent
|
||||
contentLayer: W.StyledRectangle.ContentLayer.Pane
|
||||
|
||||
width: (root.vertical ? root.barUndirectionalWidth : root.width) - root.margins * 2
|
||||
height: (root.vertical ? root.height : root.barUndirectionalWidth) - root.margins * 2
|
||||
|
||||
property real fullRadius: Math.min(width, height) / 2
|
||||
function getRadius(atSide) {
|
||||
if (root.m3eRadius) {
|
||||
if (atSide) return fullRadius;
|
||||
else return C.Appearance.rounding.unsharpenmore;
|
||||
} else {
|
||||
return 12;
|
||||
}
|
||||
}
|
||||
property real startRadius: getRadius(root.startSide)
|
||||
property real endRadius: getRadius(root.endSide)
|
||||
topLeftRadius: startRadius
|
||||
topRightRadius: root.vertical ? startRadius : endRadius
|
||||
bottomLeftRadius: root.vertical ? endRadius : startRadius
|
||||
bottomRightRadius: endRadius
|
||||
}
|
||||
|
||||
GridLayout {
|
||||
id: layout
|
||||
columns: C.Config.options.bar.vertical ? 1 : -1
|
||||
anchors.centerIn: parent
|
||||
property real spacing: 0
|
||||
columnSpacing: spacing
|
||||
rowSpacing: spacing
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import qs.modules.common as C
|
||||
import qs.modules.common.widgets as W
|
||||
|
||||
Repeater {
|
||||
id: root
|
||||
|
||||
required property list<var> componentNames
|
||||
property string context: Quickshell.shellPath("modules/hefty/topLayer/bar/widgets")
|
||||
|
||||
model: {
|
||||
const m = componentNames.map(item => {
|
||||
if (item instanceof Array)
|
||||
return ({"type": "container", "value": item});
|
||||
else
|
||||
return ({"type": "component", "value": item});
|
||||
});
|
||||
for (var i = 0;i < m.length; i++) {
|
||||
const item = m[i];
|
||||
if (item.type === "container") {
|
||||
item.startSide = (i === 0) || (m[i - 1].type !== "container");
|
||||
item.endSide = (i + 1 >= m.length) || (m[i + 1].type !== "container");
|
||||
}
|
||||
}
|
||||
// print(JSON.stringify(m, null, 2));
|
||||
return m;
|
||||
}
|
||||
delegate: DelegateChooser {
|
||||
role: "type"
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: "component"
|
||||
delegate: W.UserFallbackLoader {
|
||||
required property var modelData
|
||||
componentName: modelData.value
|
||||
context: root.context
|
||||
}
|
||||
}
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: "container"
|
||||
delegate: HBarGroupContainer {
|
||||
id: group
|
||||
required property var modelData
|
||||
startSide: modelData.startSide
|
||||
endSide: modelData.endSide
|
||||
|
||||
Repeater {
|
||||
model: group.modelData.value
|
||||
delegate: W.UserFallbackLoader {
|
||||
required property var modelData
|
||||
componentName: modelData
|
||||
context: root.context
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import qs.modules.ii.bar as IIBar
|
||||
import qs.modules.common as C
|
||||
|
||||
IIBar.Workspaces {
|
||||
id: root
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||
implicitWidth: root.vertical ? C.Appearance.sizes.verticalBarWidth : (root.workspaceButtonWidth * root.workspacesShown - 2)
|
||||
implicitHeight: root.vertical ? (root.workspaceButtonWidth * root.workspacesShown - 2) : C.Appearance.sizes.barHeight
|
||||
}
|
||||
Reference in New Issue
Block a user