refactor flexible grids into Box

This commit is contained in:
end-4
2026-03-09 11:03:56 +01:00
parent a81f52fcd7
commit 84d7928518
7 changed files with 37 additions and 16 deletions
@@ -0,0 +1,11 @@
pragma ComponentBehavior: Bound
import QtQuick
// A type that's both capable of being rows and columns
// Qt Row is just a locked down Grid smh
// Calling it a Box because that's how row-or-column widget is called in Gtk
Grid {
property bool vertical: false
columns: vertical ? 1 : -1
rows: vertical ? -1 : 1
}
@@ -0,0 +1,13 @@
pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Layouts
// Box, Layout version
// A type that's both capable of being rows and columns
// Qt Row is just a locked down Grid smh
// Calling it a Box because that's how row-or-column widget is called in Gtk
GridLayout {
property bool vertical: false
columns: vertical ? 1 : -1
rows: vertical ? -1 : 1
}
@@ -2,11 +2,10 @@ pragma ComponentBehavior: Bound
import QtQuick import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
GridLayout { BoxLayout {
id: root id: root
property bool vertical: true vertical: true
columns: vertical ? 1 : -1
property real totalDuration: 250 property real totalDuration: 250
property real interval: totalDuration / count property real interval: totalDuration / count
@@ -339,7 +339,7 @@ HBarWidgetContainer {
} }
/////////////////// Components /////////////////// /////////////////// Components ///////////////////
component WorkspaceLayout: Grid { component WorkspaceLayout: Box {
anchors { anchors {
top: !root.vertical ? parent.top : undefined top: !root.vertical ? parent.top : undefined
bottom: !root.vertical ? parent.bottom : undefined bottom: !root.vertical ? parent.bottom : undefined
@@ -349,8 +349,7 @@ HBarWidgetContainer {
rowSpacing: 0 rowSpacing: 0
columnSpacing: 0 columnSpacing: 0
columns: root.vertical ? 1 : -1 vertical: root.vertical
rows: root.vertical ? -1 : 1
} }
component WorkspaceItem: Item { component WorkspaceItem: Item {
@@ -1,4 +1,5 @@
import qs.modules.common import qs.modules.common
import qs.modules.common.widgets
import QtQuick import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
@@ -23,9 +24,9 @@ Item {
radius: Appearance.rounding.small radius: Appearance.rounding.small
} }
GridLayout { BoxLayout {
id: gridLayout id: gridLayout
columns: root.vertical ? 1 : -1 vertical: root.vertical
anchors { anchors {
verticalCenter: root.vertical ? undefined : parent.verticalCenter verticalCenter: root.vertical ? undefined : parent.verticalCenter
horizontalCenter: root.vertical ? parent.horizontalCenter : undefined horizontalCenter: root.vertical ? parent.horizontalCenter : undefined
@@ -65,9 +65,9 @@ Item {
} }
} }
GridLayout { BoxLayout {
id: gridLayout id: gridLayout
columns: root.vertical ? 1 : -1 vertical: root.vertical
anchors.fill: parent anchors.fill: parent
rowSpacing: 8 rowSpacing: 8
columnSpacing: 15 columnSpacing: 15
@@ -82,14 +82,13 @@ Item {
} }
// Workspaces - background // Workspaces - background
Grid { Box {
z: 1 z: 1
anchors.centerIn: parent anchors.centerIn: parent
rowSpacing: 0 rowSpacing: 0
columnSpacing: 0 columnSpacing: 0
columns: root.vertical ? 1 : -1 vertical: root.vertical
rows: root.vertical ? -1 : 1
Repeater { Repeater {
model: wsModel.shownCount model: wsModel.shownCount
@@ -160,13 +159,12 @@ Item {
} }
// Workspaces - numbers // Workspaces - numbers
Grid { Box {
id: wsNumbers id: wsNumbers
z: 3 z: 3
anchors.fill: parent anchors.fill: parent
columns: root.vertical ? 1 : -1 vertical: root.vertical
rows: root.vertical ? -1 : 1
columnSpacing: 0 columnSpacing: 0
rowSpacing: 0 rowSpacing: 0