Repository navigation
Bar widget group #6961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
GeekyRiolu
wants to merge
20
commits into
omacom:quattro
Choose a base branch
from
GeekyRiolu:bar-widget-group
base: quattro
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+528
−2
Open
Bar widget group #6961
Changes from 13 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
998bff3
Add collapsible bar widget groups
GeekyRiolu b2d23b9
Migrate the tray drawer onto BarCollapsible
GeekyRiolu 45fdbaa
Give the widget group a distinct chevron from the tray
GeekyRiolu 3dd061b
Apply suggestions from code review
GeekyRiolu cb9d477
Return a real Array from groupItems() for cross-realm items
GeekyRiolu b87f5e2
Center the collapsible drawer content on the cross axis
GeekyRiolu 7795006
Loosen the collapsible animation test to tolerate reformatting
GeekyRiolu 2f7f16e
Seed the collapsible pinned state once, don't track collapsedByDefault
GeekyRiolu 81fb5b0
Align group detection in layout normalization with BarModel
GeekyRiolu 05ec0ff
Size the tray drawers explicitly
GeekyRiolu fc9424d
Return a fresh array from groupItems()
GeekyRiolu 9f662bc
Restore OMARCHY_PATH to its exact prior state in the group acceptance…
GeekyRiolu fdc41fa
Clarify the expandOnHover wording in the bar README
GeekyRiolu 0ad476e
Keep pinnedOpen a live binding so collapsed:false groups start expanded
GeekyRiolu e017902
Detect OMARCHY_PATH by presence, not value, in the group acceptance test
GeekyRiolu 2947f6d
Document why the group test uses source-regex structural checks
GeekyRiolu db2bb31
Merge upstream/quattro into bar-widget-group
GeekyRiolu b81e980
Assert real collapse behavior in the bar group acceptance test
GeekyRiolu 6fbb908
Merge upstream/quattro into bar-widget-group
GeekyRiolu cea31d8
Merge upstream/quattro into bar-widget-group
GeekyRiolu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| import QtQuick | ||
| import qs.Commons | ||
|
|
||
| // Collapsible bar container. Hides its content behind a chevron and reveals it | ||
| // with a hover-to-expand slide. This is the single source of the collapse/expand | ||
| // motion for the bar: the system tray drawer and the widget group both use it, | ||
| // so the two never drift. | ||
| // | ||
| // Two layout modes: | ||
| // reserveSpace: false (default, widget groups) — space-saving: collapsed the | ||
| // container is just the chevron and it grows to fit its content as it opens. | ||
| // reserveSpace: true (system tray) — the full extent is always reserved; the | ||
| // chevron migrates and the content slides in and out beneath it, and the | ||
| // empty reserved area is masked so it does not steal hover or clicks. | ||
| // | ||
| // Content is supplied as a Component (not default children) so the chevron and | ||
| // clip below are not swallowed by a default-property alias, and so the loaded | ||
| // item is available to measure for the drawer extent. | ||
| Item { | ||
| id: root | ||
|
|
||
| // Host bar, injected by the caller. Supplies vertical / barSize / theming for | ||
| // the chevron. Left null the component still lays out with Style fallbacks. | ||
| property var bar: null | ||
| readonly property bool vertical: bar ? bar.vertical : false | ||
| readonly property int barSize: bar ? bar.barSize : Style.bar.sizeHorizontal | ||
|
|
||
| // The content to reveal. Its implicit size along the bar axis is the extent | ||
| // the drawer opens to. | ||
| property Component contentComponent: null | ||
| readonly property Item body: contentLoader.item | ||
|
|
||
| property bool collapsedByDefault: true | ||
| property bool expandOnHover: true | ||
| // Reserve the full extent while collapsed (tray drawer) instead of shrinking | ||
| // to just the chevron (widget group). | ||
| property bool reserveSpace: false | ||
| // Left-click the chevron to pin the drawer open. The tray drives reveal by | ||
| // hover alone and uses the chevron's right button for its manage popup, so it | ||
| // turns this off and listens to chevronPressed instead. | ||
| property bool pinOnClick: true | ||
| // Chevron glyph (the same one the tray drawer uses). Escaped codepoint on | ||
| // purpose: raw Nerd Font glyphs can be mangled by file tooling, so the default | ||
| // stays stable this way. | ||
| property string icon: "\uf053" | ||
| property int animationDuration: 600 | ||
|
|
||
| signal chevronPressed(int button) | ||
|
|
||
| // A hover reveals transiently; a chevron click pins the drawer open so it | ||
| // survives the pointer leaving. collapsedByDefault only *seeds* the initial | ||
| // pinned state; freeze the binding on completion so a later collapsedByDefault | ||
| // change (e.g. a future in-place group update) can't retroactively flip it. | ||
| property bool pinnedOpen: !collapsedByDefault | ||
| Component.onCompleted: pinnedOpen = !collapsedByDefault | ||
| property bool hovered: false | ||
| readonly property bool open: pinnedOpen || (expandOnHover && hovered) | ||
|
|
||
| readonly property real drawerExtent: body ? (vertical ? body.implicitHeight : body.implicitWidth) : 0 | ||
| property real revealProgress: open ? 1 : 0 | ||
| readonly property real revealExtent: drawerExtent * revealProgress | ||
|
|
||
| // Extent occupied beyond the chevron: the full drawer when space is reserved, | ||
| // otherwise only the slice revealed so far. | ||
| readonly property real reservedExtent: reserveSpace ? drawerExtent : revealExtent | ||
| // In reserve mode the chevron migrates as the drawer opens and the content | ||
| // slides under it; in space-saving mode the chevron is fixed and the content | ||
| // is wiped in from it. | ||
| readonly property real chevronOffset: reserveSpace ? (drawerExtent - revealExtent) : 0 | ||
| readonly property real clipExtent: reserveSpace ? drawerExtent : revealExtent | ||
| readonly property real contentOffset: reserveSpace ? (drawerExtent - revealExtent) : 0 | ||
|
|
||
| Behavior on revealProgress { | ||
| NumberAnimation { duration: root.animationDuration; easing.type: Easing.OutCubic } | ||
| } | ||
|
|
||
| implicitWidth: vertical ? barSize : Math.round(chevron.implicitWidth + reservedExtent) | ||
| implicitHeight: vertical ? Math.round(chevron.implicitHeight + reservedExtent) : barSize | ||
|
|
||
| // Reserved-but-empty space must not react to the pointer, or hovering the gap | ||
| // beside a collapsed drawer would expand it and clicks would be swallowed. | ||
| // Only the chevron and the revealed content are live. Nothing to mask in | ||
| // space-saving mode, where the block shrinks to the chevron. | ||
| containmentMask: root.reserveSpace ? reserveMask : null | ||
| QtObject { | ||
| id: reserveMask | ||
| function contains(point: point): bool { | ||
| if (root.vertical) { | ||
| if (point.x < 0 || point.x > root.width) return false | ||
| return point.y >= root.chevronOffset && point.y <= root.height | ||
| } | ||
| if (point.y < 0 || point.y > root.height) return false | ||
| return point.x >= root.chevronOffset && point.x <= root.width | ||
| } | ||
| } | ||
|
|
||
| // Whole-container hover drives the transient reveal. A HoverHandler on the | ||
| // root sees the chevron and the revealed content as one region, so sliding | ||
| // from the chevron onto the content does not collapse it mid-motion. | ||
| HoverHandler { | ||
| enabled: root.expandOnHover | ||
| onHoveredChanged: root.hovered = hovered | ||
| } | ||
|
|
||
| BarIconButton { | ||
| id: chevron | ||
| bar: root.bar | ||
| x: root.vertical ? 0 : root.chevronOffset | ||
| y: root.vertical ? root.chevronOffset : 0 | ||
| width: implicitWidth | ||
| height: implicitHeight | ||
| text: root.icon | ||
| textRotation: root.vertical ? 90 : 0 | ||
| onPressed: function(button) { | ||
| root.chevronPressed(button) | ||
| if (root.pinOnClick && button === Qt.LeftButton) root.pinnedOpen = !root.pinnedOpen | ||
| } | ||
| } | ||
|
|
||
| // The revealed slice. Clipped so the content is wiped/slid in from the chevron | ||
| // as the slice grows, and so a partially-open drawer never paints past its edge. | ||
| Item { | ||
| id: revealClip | ||
| x: root.vertical ? 0 : chevron.implicitWidth | ||
| y: root.vertical ? chevron.implicitHeight : 0 | ||
| width: root.vertical ? root.barSize : Math.round(root.clipExtent) | ||
| height: root.vertical ? Math.round(root.clipExtent) : root.barSize | ||
| clip: true | ||
|
|
||
| // The content is laid out at its full extent regardless of how far the | ||
| // drawer has opened, so its widgets never reflow as it animates. On the | ||
| // cross axis it is sized to the content and centered, so content shorter | ||
| // than the bar (e.g. tray icons) sits centered like the pinned items rather | ||
| // than top/left-aligned — matching the tray drawer's original centering. | ||
| Loader { | ||
| id: contentLoader | ||
| sourceComponent: root.contentComponent | ||
| x: root.vertical ? Math.round((root.barSize - implicitWidth) / 2) : Math.round(root.contentOffset) | ||
| y: root.vertical ? Math.round(root.contentOffset) : Math.round((root.barSize - implicitHeight) / 2) | ||
| width: root.vertical ? implicitWidth : root.drawerExtent | ||
| height: root.vertical ? root.drawerExtent : implicitHeight | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import QtQuick | ||
| import qs.Ui | ||
| import "BarModel.js" as BarModel | ||
|
|
||
| // A collapsible group of bar widgets. Kept in its own file rather than an inline | ||
| // component of Bar.qml on purpose: a group contains widget slots, and a widget | ||
| // slot may itself be a group, so an inline component would make Bar.qml's | ||
| // components form a resolution cycle — which QML forbids ("Inline components | ||
| // form a cycle!"). A file type can be referenced recursively, so the recursion | ||
| // lives here. | ||
| // | ||
| // The children are rendered by a ModuleList handed in as `listComponent` (a | ||
| // runtime Component created by Bar.qml), so this file never names the bar's | ||
| // inline ModuleList / ModuleSlot types and the cycle stays broken. | ||
| Item { | ||
| id: root | ||
|
|
||
| property var bar: null | ||
| property var entry: null | ||
| property string region: "" | ||
| // A bare ModuleList component supplied by the bar; its entries/region are | ||
| // filled once it loads. | ||
| property Component listComponent: null | ||
|
|
||
| readonly property var groupSettings: BarModel.entrySettings(entry) | ||
|
|
||
| implicitWidth: collapsible.implicitWidth | ||
| implicitHeight: collapsible.implicitHeight | ||
|
|
||
| BarCollapsible { | ||
| id: collapsible | ||
| anchors.fill: parent | ||
| bar: root.bar | ||
| collapsedByDefault: root.groupSettings.collapsed !== false | ||
| expandOnHover: root.groupSettings.expandOnHover !== false | ||
| // A distinct default glyph so a group next to the tray drawer does not read | ||
| // as a second tray; an entry may override it via "icon". | ||
| icon: root.groupSettings.icon !== undefined && root.groupSettings.icon !== null | ||
| ? String(root.groupSettings.icon) : "\uf141" | ||
|
|
||
| contentComponent: Component { | ||
| Loader { | ||
| sourceComponent: root.listComponent | ||
| onLoaded: { | ||
| if (!item) return | ||
| item.entries = BarModel.groupItems(root.entry) | ||
| item.region = root.region | ||
| item.draggable = false | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.