initial commit for repositioning bar, currently broken
This commit is contained in:
+38
-17
@@ -9,18 +9,24 @@ import qs.Modules.SysTray
|
||||
import qs.Modules.Network
|
||||
import qs.Modules.Updates
|
||||
|
||||
RowLayout {
|
||||
GridLayout {
|
||||
id: root
|
||||
|
||||
required property bool fullscreen
|
||||
required property bool horizontal
|
||||
required property Wrapper popouts
|
||||
required property ClipWrapper popoutsWrapper
|
||||
required property ShellScreen screen
|
||||
readonly property int vPadding: 6
|
||||
required property PersistentProperties visibilities
|
||||
|
||||
function checkPopout(x: real): void {
|
||||
const ch = childAt(x, height / 2) as EntryWrapper;
|
||||
function axisCenterOf(item: Item): real {
|
||||
const c = item.mapToItem(root, item.implicitWidth / 2, item.implicitHeight / 2);
|
||||
return horizontal ? c.x : c.y;
|
||||
}
|
||||
|
||||
function checkPopout(pos: real): void {
|
||||
const ch = (horizontal ? childAt(pos, height / 2) : childAt(width / 2, pos)) as EntryWrapper;
|
||||
const id = ch?.entryId;
|
||||
|
||||
if (!ch || id === undefined) {
|
||||
@@ -34,26 +40,21 @@ RowLayout {
|
||||
|
||||
if (id === "statusIcons" && Config.bar.popouts.statusIcons) {
|
||||
const items = (ch.item as StatusIcons).items;
|
||||
const localX = mapToItem(items, x, 0).x;
|
||||
const icon = items.childAt(localX, items.height / 2);
|
||||
const icon = horizontal ? items.childAt(mapToItem(items, pos, 0).x, items.height / 2) : items.childAt(items.width / 2, mapToItem(items, 0, pos).y);
|
||||
if (icon) {
|
||||
popouts.currentName = icon.name;
|
||||
popouts.currentCenter = Qt.binding(() => icon.mapToItem(root, icon.implicitWidth / 2, 0).x);
|
||||
popouts.currentCenter = Qt.binding(() => axisCenterOf(icon));
|
||||
popouts.hasCurrent = true;
|
||||
}
|
||||
} else if (id === "tray" && Config.bar.popouts.tray && Config.bar.tray.showOnHover) {
|
||||
const tray = ch.item as TrayIcons;
|
||||
const layout = tray.layout;
|
||||
const localX = mapToItem(layout, x, 0).x;
|
||||
const trayItem = layout.childAt(localX, layout.height / 2);
|
||||
const trayItem = horizontal ? layout.childAt(mapToItem(layout, pos, 0).x, layout.height / 2) : layout.childAt(items.width / 2, mapToItem(layout, 0, pos).y);
|
||||
|
||||
if (trayItem) {
|
||||
const idx = trayItem.index;
|
||||
popouts.currentName = `traymenu${idx}`;
|
||||
popouts.currentCenter = Qt.binding(() => {
|
||||
const it = tray.items.itemAt(idx);
|
||||
return it ? it.mapToItem(root, it.implicitWidth / 2, 0).x : popouts.currentCenter;
|
||||
});
|
||||
popouts.currentCenter = Qt.binding(() => axisCenterOf(trayItem));
|
||||
popouts.hasCurrent = true;
|
||||
}
|
||||
|
||||
@@ -63,12 +64,19 @@ RowLayout {
|
||||
|
||||
if (id === "updates") {
|
||||
popouts.currentName = "updates";
|
||||
popouts.currentCenter = Qt.binding(() => ch.item.mapToItem(root, (ch.item as Item).implicitWidth / 2, 0).x);
|
||||
popouts.currentCenter = Qt.binding(() => axisCenterOf(ch.item as Item));
|
||||
popouts.hasCurrent = true;
|
||||
}
|
||||
}
|
||||
|
||||
spacing: Appearance.spacing.small
|
||||
function entryAt(pos: real): string {
|
||||
const ch = (horizontal ? childAt(pos, height / 2) : childAt(width / 2, pos)) as EntryWrapper;
|
||||
return ch?.entryId ?? "";
|
||||
}
|
||||
|
||||
columnSpacing: Appearance.spacing.small
|
||||
columns: horizontal ? -1 : 1
|
||||
rowSpacing: Appearance.spacing.small
|
||||
|
||||
Repeater {
|
||||
id: repeater
|
||||
@@ -94,7 +102,8 @@ RowLayout {
|
||||
roleValue: "spacer"
|
||||
|
||||
delegate: EntryWrapper {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: !root.horizontal
|
||||
Layout.fillWidth: root.horizontal
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,6 +112,7 @@ RowLayout {
|
||||
|
||||
delegate: EntryWrapper {
|
||||
Workspaces {
|
||||
horizontal: root.horizontal
|
||||
screen: root.screen
|
||||
visible: !root.fullscreen
|
||||
}
|
||||
@@ -114,6 +124,7 @@ RowLayout {
|
||||
|
||||
delegate: EntryWrapper {
|
||||
TrayIcons {
|
||||
horizontal: root.horizontal
|
||||
loader: root
|
||||
popouts: root.popouts
|
||||
visible: !root.fullscreen
|
||||
@@ -126,6 +137,7 @@ RowLayout {
|
||||
|
||||
delegate: EntryWrapper {
|
||||
StatusIcons {
|
||||
horizontal: root.horizontal
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,6 +147,7 @@ RowLayout {
|
||||
|
||||
delegate: EntryWrapper {
|
||||
Resources {
|
||||
horizontal: root.horizontal
|
||||
visibilities: root.visibilities
|
||||
visible: !root.fullscreen
|
||||
}
|
||||
@@ -146,6 +159,7 @@ RowLayout {
|
||||
|
||||
delegate: EntryWrapper {
|
||||
UpdatesWidget {
|
||||
horizontal: root.horizontal
|
||||
visible: !root.fullscreen
|
||||
}
|
||||
}
|
||||
@@ -156,6 +170,7 @@ RowLayout {
|
||||
|
||||
delegate: EntryWrapper {
|
||||
NotifBell {
|
||||
horizontal: root.horizontal
|
||||
popouts: root.popouts
|
||||
visibilities: root.visibilities
|
||||
visible: !root.fullscreen
|
||||
@@ -168,6 +183,7 @@ RowLayout {
|
||||
|
||||
delegate: EntryWrapper {
|
||||
Clock {
|
||||
horizontal: root.horizontal
|
||||
loader: root
|
||||
popouts: root.popouts
|
||||
visibilities: root.visibilities
|
||||
@@ -182,6 +198,7 @@ RowLayout {
|
||||
delegate: EntryWrapper {
|
||||
WindowTitle {
|
||||
bar: root
|
||||
horizontal: root.horizontal
|
||||
visible: !root.fullscreen
|
||||
}
|
||||
}
|
||||
@@ -192,6 +209,7 @@ RowLayout {
|
||||
|
||||
delegate: EntryWrapper {
|
||||
NetworkWidget {
|
||||
horizontal: root.horizontal
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -201,6 +219,7 @@ RowLayout {
|
||||
|
||||
delegate: EntryWrapper {
|
||||
MediaWidget {
|
||||
horizontal: root.horizontal
|
||||
visible: !root.fullscreen
|
||||
}
|
||||
}
|
||||
@@ -215,8 +234,10 @@ RowLayout {
|
||||
required property var modelData
|
||||
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
Layout.leftMargin: index === 0 ? root.vPadding : (entryId === "statusIcons") ? -root.spacing + Appearance.spacing.extraSmall : 0
|
||||
Layout.rightMargin: index === repeater.count - 1 ? root.vPadding : 0
|
||||
Layout.bottomMargin: !root.horizontal && index === repeater.count - 1 ? root.vPadding : 0
|
||||
Layout.leftMargin: root.horizontal && index === 0 ? root.vPadding : (entryId === "statusIcons") ? -root.rowSpacing + Appearance.spacing.extraSmall : 0
|
||||
Layout.rightMargin: root.horizontal && index === repeater.count - 1 ? root.vPadding : 0
|
||||
Layout.topMargin: !root.horizontal && index === 0 ? root.vPadding : (entryId === "statusIcons") ? -root.columnSpacing + Appearance.spacing.extraSmall : 0
|
||||
children: item
|
||||
implicitHeight: item?.implicitHeight ?? 0
|
||||
implicitWidth: item?.implicitWidth ?? 0
|
||||
|
||||
Reference in New Issue
Block a user