Compare commits
47
Commits
v0.5.0
..
34d4c6a57a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34d4c6a57a | ||
|
|
e54f64516a | ||
|
|
c2428d1d76 | ||
|
|
f41075d316 | ||
|
|
dc77ea44a4 | ||
|
|
613242ae50 | ||
|
|
f2ce4862cc | ||
|
|
4c3d38f023 | ||
|
|
5618ba9e6b | ||
|
|
cc9aeca98b | ||
|
|
9ea1f846ae | ||
|
|
a1d96b60f6 | ||
|
|
25bee293b0 | ||
|
|
84d5abcaab | ||
|
|
7bc1db7f19 | ||
|
|
62c39a1c0c | ||
|
|
d9e1e5ede3 | ||
|
|
f4f57d03cf | ||
|
|
512aeb4ab9 | ||
|
|
99949ff255 | ||
|
|
a3178ad9cd | ||
|
|
02254a10d8 | ||
|
|
54d4676ddf | ||
|
|
cd3da1941b | ||
|
|
34dde4bbfb | ||
|
|
fcb848b6d2 | ||
|
|
ae5c1fa148 | ||
|
|
b254000737 | ||
|
|
04fe8b1e43 | ||
|
|
dfa6b010e6 | ||
|
|
8a4e9bac31 | ||
|
|
f20fa45b29 | ||
|
|
53a3c76dc0 | ||
|
|
617e87d64f | ||
|
|
ef2fb95fab | ||
|
|
2150859847 | ||
|
|
c9f7856982
|
||
|
|
51dc0fc026 | ||
|
|
cef91caebc | ||
|
|
c5a089adaf | ||
|
|
52feb6006a | ||
|
|
dbb51ceadd | ||
|
|
487615f482 | ||
|
|
d4e936a7e2 | ||
|
|
703d804746 | ||
|
|
327270f3fa | ||
|
|
8a66c3b064 |
@@ -1,5 +0,0 @@
|
|||||||
CompileFlags:
|
|
||||||
Remove:
|
|
||||||
# GCC-only flags from the system's default spec that clang/clangd cannot
|
|
||||||
# parse. They appear in compile_commands.json but are not set by the project.
|
|
||||||
- -mno-direct-extern-access
|
|
||||||
@@ -38,6 +38,7 @@ body:
|
|||||||
attributes:
|
attributes:
|
||||||
label: OS
|
label: OS
|
||||||
options:
|
options:
|
||||||
|
- NixOS
|
||||||
- Arch
|
- Arch
|
||||||
- Debian / Ubuntu
|
- Debian / Ubuntu
|
||||||
- Fedora
|
- Fedora
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ body:
|
|||||||
- Refactor / style
|
- Refactor / style
|
||||||
- CI / build / tooling
|
- CI / build / tooling
|
||||||
- Documentation
|
- Documentation
|
||||||
- Other (Describe in description box with header "Issue type")
|
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
|
|||||||
+2
-11
@@ -61,12 +61,10 @@ set(CMAKE_INSTALL_MESSAGE NEVER)
|
|||||||
|
|
||||||
add_compile_options(
|
add_compile_options(
|
||||||
-Wall -Wextra -Wpedantic -Wshadow -Wconversion
|
-Wall -Wextra -Wpedantic -Wshadow -Wconversion
|
||||||
-Wnull-dereference -Wdouble-promotion
|
-Wold-style-cast -Wnull-dereference -Wdouble-promotion
|
||||||
-Wformat=2 -Wfloat-equal
|
-Wformat=2 -Wfloat-equal -Woverloaded-virtual
|
||||||
-Wsign-conversion -Wredundant-decls -Wswitch
|
-Wsign-conversion -Wredundant-decls -Wswitch
|
||||||
-Wunreachable-code
|
-Wunreachable-code
|
||||||
$<$<COMPILE_LANGUAGE:CXX>:-Wold-style-cast>
|
|
||||||
$<$<COMPILE_LANGUAGE:CXX>:-Woverloaded-virtual>
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -190,11 +188,4 @@ if("m3shapes" IN_LIST ENABLE_MODULES)
|
|||||||
if(TARGET m3shapesplugin)
|
if(TARGET m3shapesplugin)
|
||||||
set_target_properties(m3shapesplugin PROPERTIES INSTALL_RPATH "$ORIGIN")
|
set_target_properties(m3shapesplugin PROPERTIES INSTALL_RPATH "$ORIGIN")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Silence warnings that come from m3shapes files we do not manage.
|
|
||||||
foreach(m3shapes_target m3shapes_core m3shapes_morph m3shapes_shapes m3shapes m3shapesplugin)
|
|
||||||
if(TARGET ${m3shapes_target})
|
|
||||||
target_compile_options(${m3shapes_target} PRIVATE -Wno-shadow -Wno-float-equal)
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ BusyIndicator {
|
|||||||
property int animState
|
property int animState
|
||||||
property color bgColor: Colors.palette.m3secondaryContainer
|
property color bgColor: Colors.palette.m3secondaryContainer
|
||||||
property color fgColor: Colors.palette.m3primary
|
property color fgColor: Colors.palette.m3primary
|
||||||
property real implicitSize: Tokens.font.body.medium.pointSize * 3
|
property real implicitSize: Tokens.font.size.normal * 3
|
||||||
property real internalStrokeWidth: strokeWidth
|
property real internalStrokeWidth: strokeWidth
|
||||||
readonly property alias progress: manager.progress
|
readonly property alias progress: manager.progress
|
||||||
property real strokeWidth: Tokens.padding.extraSmall * 0.8
|
property real strokeWidth: Tokens.padding.extraSmall * 0.8
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ Flickable {
|
|||||||
|
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
root.doneFakeFlick = false;
|
root.doneFakeFlick = false;
|
||||||
root.returnToBounds();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ ScrollBar {
|
|||||||
property bool inverted
|
property bool inverted
|
||||||
|
|
||||||
enabled: !ShellState.forActive().isDrawing
|
enabled: !ShellState.forActive().isDrawing
|
||||||
|
|
||||||
implicitWidth: size === 1 ? 0 : isHorizontal ? 0 : Tokens.padding.extraSmall * 2
|
implicitWidth: size === 1 ? 0 : isHorizontal ? 0 : Tokens.padding.extraSmall * 2
|
||||||
implicitHeight: size === 1 ? 0 : isHorizontal ? Tokens.padding.extraSmall * 2 : 0
|
implicitHeight: size === 1 ? 0 : isHorizontal ? Tokens.padding.extraSmall * 2 : 0
|
||||||
|
|
||||||
|
|||||||
@@ -16,12 +16,11 @@ Text {
|
|||||||
color: Colors.palette.m3onSurface
|
color: Colors.palette.m3onSurface
|
||||||
font: Tokens.font.body.small
|
font: Tokens.font.body.small
|
||||||
linkColor: Colors.palette.m3onPrimaryFixedVariant
|
linkColor: Colors.palette.m3onPrimaryFixedVariant
|
||||||
renderType: Text.QtRendering
|
renderType: Text.NativeRendering
|
||||||
textFormat: Text.PlainText
|
textFormat: Text.PlainText
|
||||||
|
|
||||||
Behavior on color {
|
Behavior on color {
|
||||||
CAnim {
|
CAnim {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Behavior on text {
|
Behavior on text {
|
||||||
enabled: root.animate
|
enabled: root.animate
|
||||||
@@ -33,8 +32,7 @@ Text {
|
|||||||
type: Anim.FastEffects
|
type: Anim.FastEffects
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyAction {
|
PropertyAction {}
|
||||||
}
|
|
||||||
|
|
||||||
TAnim {
|
TAnim {
|
||||||
target: root
|
target: root
|
||||||
|
|||||||
Regular → Executable
@@ -9,6 +9,5 @@ CustomText {
|
|||||||
property int grade: Colors.light ? 0 : -25
|
property int grade: Colors.light ? 0 : -25
|
||||||
property font fontStyle: Tokens.font.icon.small
|
property font fontStyle: Tokens.font.icon.small
|
||||||
|
|
||||||
renderType: Text.NativeRendering
|
|
||||||
font: Tokens.font.icon.size(fontStyle.pointSize).weight(fontStyle.weight).vaxes(fontStyle.variableAxes).fill(fill.toFixed(1)).grade(grade).build()
|
font: Tokens.font.icon.size(fontStyle.pointSize).weight(fontStyle.weight).vaxes(fontStyle.variableAxes).fill(fill.toFixed(1)).grade(grade).build()
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-13
@@ -124,7 +124,7 @@ MouseArea {
|
|||||||
model: root.items
|
model: root.items
|
||||||
|
|
||||||
CustomRect {
|
CustomRect {
|
||||||
id: menuItem
|
id: item
|
||||||
|
|
||||||
readonly property bool active: modelData === root?.active
|
readonly property bool active: modelData === root?.active
|
||||||
required property int index
|
required property int index
|
||||||
@@ -142,13 +142,13 @@ MouseArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
StateLayer {
|
StateLayer {
|
||||||
color: menuItem.active ? Colors.palette.m3onTertiaryContainer : Colors.palette.m3onSurface
|
color: item.active ? Colors.palette.m3onTertiaryContainer : Colors.palette.m3onSurface
|
||||||
enabled: root.expanded
|
enabled: root.expanded
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.itemSelected(menuItem.modelData);
|
root.itemSelected(item.modelData);
|
||||||
root.active = menuItem.modelData;
|
root.active = item.modelData;
|
||||||
menuItem.modelData.clicked();
|
item.modelData.clicked();
|
||||||
root.expanded = false;
|
root.expanded = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,27 +162,26 @@ MouseArea {
|
|||||||
|
|
||||||
MaterialIcon {
|
MaterialIcon {
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
color: menuItem.active ? Colors.palette.m3onTertiaryContainer : Colors.palette.m3onSurfaceVariant
|
color: item.active ? Colors.palette.m3onTertiaryContainer : Colors.palette.m3onSurfaceVariant
|
||||||
text: menuItem.modelData?.icon ?? ""
|
text: item.modelData?.icon ?? ""
|
||||||
visible: text !== ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomText {
|
CustomText {
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
color: menuItem.active ? Colors.palette.m3onTertiaryContainer : Colors.palette.m3onSurface
|
color: item.active ? Colors.palette.m3onTertiaryContainer : Colors.palette.m3onSurface
|
||||||
text: menuItem.modelData?.text ?? ""
|
text: item.modelData?.text ?? ""
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
active: menuItem.modelData?.trailingIcon.length > 0
|
active: item.modelData?.trailingIcon.length > 0
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
visible: active
|
visible: active
|
||||||
|
|
||||||
sourceComponent: MaterialIcon {
|
sourceComponent: MaterialIcon {
|
||||||
color: menuItem.active ? Colors.palette.m3onTertiaryContainer : Colors.palette.m3onSurfaceVariant
|
color: item.active ? Colors.palette.m3onTertiaryContainer : Colors.palette.m3onSurfaceVariant
|
||||||
text: menuItem.modelData.trailingIcon
|
text: item.modelData.trailingIcon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ PersistentProperties {
|
|||||||
property bool sidebar
|
property bool sidebar
|
||||||
|
|
||||||
// Dashboard state
|
// Dashboard state
|
||||||
property int dashboardTab: 0
|
property int dashboardTab
|
||||||
property date dashboardDate: new Date()
|
property date dashboardDate: new Date()
|
||||||
|
|
||||||
// Sidebar state
|
// Sidebar state
|
||||||
property int sidebarTab: 0
|
property int sidebarTab
|
||||||
property list<string> expandedNotifs: []
|
property list<string> expandedNotifs: []
|
||||||
|
|
||||||
// Utilities state
|
// Utilities state
|
||||||
@@ -34,7 +34,4 @@ PersistentProperties {
|
|||||||
// Drawing state
|
// Drawing state
|
||||||
property color penColor: "white"
|
property color penColor: "white"
|
||||||
property int penWidth: 4
|
property int penWidth: 4
|
||||||
|
|
||||||
// Screenshot state
|
|
||||||
property bool screenshot
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,55 +2,62 @@ import QtQuick
|
|||||||
import ZShell.Config
|
import ZShell.Config
|
||||||
import qs.Services
|
import qs.Services
|
||||||
|
|
||||||
CustomClippingRect {
|
Item {
|
||||||
id: track
|
id: track
|
||||||
|
|
||||||
required property var scrollBar
|
required property var scrollBar
|
||||||
required property var mouseArea
|
required property CustomMouseArea mouseArea
|
||||||
|
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
implicitWidth: handle.implicitWidth
|
implicitWidth: Tokens.padding.extraSmall * 2
|
||||||
radius: Tokens.rounding.full
|
|
||||||
|
|
||||||
CustomRect {
|
|
||||||
id: handle
|
|
||||||
|
|
||||||
|
CustomClippingRect {
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
color: Colors.palette.m3secondary
|
anchors.top: parent.top
|
||||||
implicitHeight: track.scrollBar.height * track.scrollBar.effectiveSize
|
|
||||||
implicitWidth: track.mouseArea.pressed || track.mouseArea.containsMouse ? Tokens.padding.extraSmall * 2 : Tokens.padding.extraSmall
|
|
||||||
opacity: {
|
|
||||||
if (!track.scrollBar.enabled)
|
|
||||||
return 0;
|
|
||||||
if (track.scrollBar.size === 1)
|
|
||||||
return 0;
|
|
||||||
if (track.mouseArea.pressed)
|
|
||||||
return 1;
|
|
||||||
if (track.mouseArea.containsMouse)
|
|
||||||
return 0.8;
|
|
||||||
if (track.scrollBar.policy === CustomScrollBar.AlwaysOn || track.scrollBar.shouldBeActive)
|
|
||||||
return 0.6;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
radius: Tokens.rounding.full
|
radius: Tokens.rounding.full
|
||||||
y: track.scrollBar.reversed ? track.scrollBar.height * (1 + track.scrollBar.nonAnimY) * track.scrollBar.travelScale : track.scrollBar.height * track.scrollBar.nonAnimY * track.scrollBar.travelScale
|
implicitWidth: handle.implicitWidth
|
||||||
|
|
||||||
Behavior on implicitWidth {
|
CustomRect {
|
||||||
Anim {}
|
id: handle
|
||||||
}
|
|
||||||
Behavior on opacity {
|
color: Colors.palette.m3secondary
|
||||||
Anim {
|
implicitHeight: track.scrollBar.height * track.scrollBar.effectiveSize
|
||||||
type: Anim.DefaultEffects
|
implicitWidth: track.mouseArea.pressed || track.mouseArea.containsMouse ? Tokens.padding.extraSmall * 2 : Tokens.padding.extraSmall
|
||||||
|
anchors.right: parent.right
|
||||||
|
opacity: {
|
||||||
|
if (!track.scrollBar.enabled)
|
||||||
|
return 0;
|
||||||
|
if (track.scrollBar.size === 1)
|
||||||
|
return 0;
|
||||||
|
if (track.mouseArea.pressed)
|
||||||
|
return 1;
|
||||||
|
if (track.mouseArea.containsMouse)
|
||||||
|
return 0.8;
|
||||||
|
if (track.scrollBar.policy === CustomScrollBar.AlwaysOn || track.scrollBar.shouldBeActive)
|
||||||
|
return 0.6;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
radius: Tokens.rounding.full
|
||||||
|
y: track.scrollBar.reversed ? track.scrollBar.height * (1 + track.scrollBar.nonAnimY) * track.scrollBar.travelScale : track.scrollBar.height * track.scrollBar.nonAnimY * track.scrollBar.travelScale
|
||||||
|
|
||||||
MouseArea {
|
Behavior on implicitWidth {
|
||||||
acceptedButtons: Qt.NoButton
|
Anim {}
|
||||||
anchors.fill: parent
|
}
|
||||||
cursorShape: Qt.PointingHandCursor
|
Behavior on opacity {
|
||||||
hoverEnabled: true
|
Anim {
|
||||||
|
type: Anim.DefaultEffects
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
acceptedButtons: Qt.NoButton
|
||||||
|
anchors.fill: parent
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
hoverEnabled: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+39
-36
@@ -11,18 +11,19 @@ CustomMouseArea {
|
|||||||
|
|
||||||
required property Item bar
|
required property Item bar
|
||||||
required property real borderThickness
|
required property real borderThickness
|
||||||
property bool dashboardShortcutActive
|
required property ScreenState screenState
|
||||||
property point dragStart
|
|
||||||
required property Drawing drawing
|
required property Drawing drawing
|
||||||
required property EdgeGeometry geometry
|
required property EdgeGeometry geometry
|
||||||
property bool osdShortcutActive
|
|
||||||
required property Panels panels
|
required property Panels panels
|
||||||
required property Wrapper popouts
|
required property Wrapper popouts
|
||||||
required property ShellScreen screen
|
required property ShellScreen screen
|
||||||
required property ScreenState screenState
|
|
||||||
property bool setInitialPoint: false
|
property bool dashboardShortcutActive
|
||||||
|
property bool osdShortcutActive
|
||||||
property bool singleGestureTriggered: false
|
property bool singleGestureTriggered: false
|
||||||
property bool utilitiesShortcutActive
|
property bool utilitiesShortcutActive
|
||||||
|
property bool setInitialPoint: false
|
||||||
|
property point dragStart
|
||||||
|
|
||||||
function inBottomPanel(panel: Item, x: real, y: real): bool {
|
function inBottomPanel(panel: Item, x: real, y: real): bool {
|
||||||
const panelHeight = panel.height * (1 - (panel.offsetScale ?? 0));
|
const panelHeight = panel.height * (1 - (panel.offsetScale ?? 0));
|
||||||
@@ -59,10 +60,39 @@ CustomMouseArea {
|
|||||||
return x >= panelX && x <= panelX + panel.width;
|
return x >= panelX && x <= panelX + panel.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
acceptedButtons: bar.fullscreen ? Qt.NoButton : Qt.AllButtons
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
acceptedButtons: bar.fullscreen ? Qt.NoButton : Qt.AllButtons
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
|
|
||||||
|
onPressed: event => {
|
||||||
|
dragStart = Qt.point(event.x, event.y);
|
||||||
|
|
||||||
|
if (screenState.isDrawing) {
|
||||||
|
if (event.button & Qt.RightButton) {
|
||||||
|
drawing.content.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!inLeftPanel(panels.drawing, mouseX, mouseY))
|
||||||
|
drawing.content.beginStroke(event.x, event.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onPressedChanged: {
|
||||||
|
if (!pressed) {
|
||||||
|
if (screenState.isDrawing) {
|
||||||
|
setInitialPoint = false;
|
||||||
|
drawing.content.endStroke();
|
||||||
|
if (!inLeftPanel(panels.drawing, mouseX, mouseY))
|
||||||
|
drawing.content.showHover(mouseX, mouseY);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (screenState.isDrawing) {
|
||||||
|
panels.drawing.collapse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onContainsMouseChanged: {
|
onContainsMouseChanged: {
|
||||||
if (!containsMouse) {
|
if (!containsMouse) {
|
||||||
if (!osdShortcutActive) {
|
if (!osdShortcutActive) {
|
||||||
@@ -81,6 +111,7 @@ CustomMouseArea {
|
|||||||
screenState.dashboard = false;
|
screenState.dashboard = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onPositionChanged: event => {
|
onPositionChanged: event => {
|
||||||
const x = event.x;
|
const x = event.x;
|
||||||
const y = event.y;
|
const y = event.y;
|
||||||
@@ -113,8 +144,7 @@ CustomMouseArea {
|
|||||||
if (pressed && dragStart.y >= screen.height - Config.bar.border && dragStart.x > screen.width / 5 && dragY < -Config.launcher.dragThreshold)
|
if (pressed && dragStart.y >= screen.height - Config.bar.border && dragStart.x > screen.width / 5 && dragY < -Config.launcher.dragThreshold)
|
||||||
screenState.launcher = true;
|
screenState.launcher = true;
|
||||||
|
|
||||||
const entryAt = bar.entryAt(geometry.axisPos(x, y));
|
const showDashboard = Config.dashboard.showOnHover && inTopPanel(panels.dashboardWrapper, x, y);
|
||||||
const showDashboard = Config.dashboard.showOnHover && inTopPanel(panels.dashboardWrapper, x, y) && (!entryAt || entryAt === "activeWindow");
|
|
||||||
|
|
||||||
if (!dashboardShortcutActive) {
|
if (!dashboardShortcutActive) {
|
||||||
screenState.dashboard = showDashboard;
|
screenState.dashboard = showDashboard;
|
||||||
@@ -129,7 +159,7 @@ CustomMouseArea {
|
|||||||
screenState.dashboard = false;
|
screenState.dashboard = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pressed && geometry.insetTop(borderThickness) > dragStart.y && !inTopPanel(panels.dashboardWrapper, dragStart.x, dragStart.y)) {
|
if (pressed && geometry.insetTop(borderThickness) > dragStart.y && (Config.dashboard.showOnHover || !inTopPanel(panels.dashboardWrapper, dragStart.x, dragStart.y))) {
|
||||||
if (dragY > 20) {
|
if (dragY > 20) {
|
||||||
screenState.settings = true;
|
screenState.settings = true;
|
||||||
} else if (dragY < -20) {
|
} else if (dragY < -20) {
|
||||||
@@ -182,33 +212,6 @@ CustomMouseArea {
|
|||||||
if (geometry.barContains(x, y))
|
if (geometry.barContains(x, y))
|
||||||
bar.checkPopout(geometry.axisPos(x, y));
|
bar.checkPopout(geometry.axisPos(x, y));
|
||||||
}
|
}
|
||||||
onPressed: event => {
|
|
||||||
dragStart = Qt.point(event.x, event.y);
|
|
||||||
|
|
||||||
if (screenState.isDrawing) {
|
|
||||||
if (event.button & Qt.RightButton) {
|
|
||||||
drawing.content.clear();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!inLeftPanel(panels.drawing, mouseX, mouseY))
|
|
||||||
drawing.content.beginStroke(event.x, event.y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onPressedChanged: {
|
|
||||||
if (!pressed) {
|
|
||||||
if (screenState.isDrawing) {
|
|
||||||
setInitialPoint = false;
|
|
||||||
drawing.content.endStroke();
|
|
||||||
if (!inLeftPanel(panels.drawing, mouseX, mouseY))
|
|
||||||
drawing.content.showHover(mouseX, mouseY);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (screenState.isDrawing) {
|
|
||||||
panels.drawing.collapse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: unhideTimer
|
id: unhideTimer
|
||||||
|
|||||||
+6
-6
@@ -37,12 +37,12 @@ Item {
|
|||||||
readonly property alias resources: resources
|
readonly property alias resources: resources
|
||||||
readonly property alias resourcesWrapper: resourcesWrapper
|
readonly property alias resourcesWrapper: resourcesWrapper
|
||||||
required property ShellScreen screen
|
required property ShellScreen screen
|
||||||
required property ScreenState screenState
|
|
||||||
readonly property alias settings: settings
|
readonly property alias settings: settings
|
||||||
readonly property alias settingsWrapper: settingsWrapper
|
readonly property alias settingsWrapper: settingsWrapper
|
||||||
readonly property alias sidebar: sidebar
|
readonly property alias sidebar: sidebar
|
||||||
readonly property alias toasts: toasts
|
readonly property alias toasts: toasts
|
||||||
readonly property alias utilities: utilities
|
readonly property alias utilities: utilities
|
||||||
|
required property ScreenState screenState
|
||||||
|
|
||||||
anchors.bottomMargin: geometry.insetBottom(borderThickness)
|
anchors.bottomMargin: geometry.insetBottom(borderThickness)
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@@ -84,8 +84,8 @@ Item {
|
|||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
screen: root.screen
|
screen: root.screen
|
||||||
screenState: root.screenState
|
|
||||||
sidebarOrSessionVisible: sidebar.visible
|
sidebarOrSessionVisible: sidebar.visible
|
||||||
|
screenState: root.screenState
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,8 +121,8 @@ Item {
|
|||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
panels: root
|
panels: root
|
||||||
screenState: root.screenState
|
|
||||||
sidebarPanel: sidebar
|
sidebarPanel: sidebar
|
||||||
|
screenState: root.screenState
|
||||||
}
|
}
|
||||||
|
|
||||||
Launcher.Wrapper {
|
Launcher.Wrapper {
|
||||||
@@ -140,8 +140,8 @@ Item {
|
|||||||
|
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
screenState: root.screenState
|
|
||||||
sidebar: sidebar
|
sidebar: sidebar
|
||||||
|
screenState: root.screenState
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
@@ -149,9 +149,9 @@ Item {
|
|||||||
|
|
||||||
property real offsetScale: dashboard.shouldBeActive ? 0 : 1
|
property real offsetScale: dashboard.shouldBeActive ? 0 : 1
|
||||||
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
clip: offsetScale > 0
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
clip: true
|
||||||
implicitHeight: dashboard.implicitHeight * (1 - offsetScale)
|
implicitHeight: dashboard.implicitHeight * (1 - offsetScale)
|
||||||
implicitWidth: dashboard.implicitWidth
|
implicitWidth: dashboard.implicitWidth
|
||||||
|
|
||||||
|
|||||||
+45
-43
@@ -52,14 +52,15 @@ CustomWindow {
|
|||||||
property var root: Quickshell.shellDir
|
property var root: Quickshell.shellDir
|
||||||
readonly property ScreenState screenState: ShellState.forScreen(screen)
|
readonly property ScreenState screenState: ShellState.forScreen(screen)
|
||||||
readonly property real sdfBorderOffset: 2 * fsTransitionProg
|
readonly property real sdfBorderOffset: 2 * fsTransitionProg
|
||||||
readonly property real shadowOpacity: 0.5 * (1 - (bar.isHovered ? 0 : fsTransitionProg))
|
readonly property real shadowOpacity: 0.7 * (1 - (bar.isHovered ? 0 : fsTransitionProg))
|
||||||
property color surfaceColor: Colors.tPalette.m3surface
|
property color surfaceColor: Colors.tPalette.m3surface
|
||||||
|
|
||||||
WlrLayershell.exclusionMode: ExclusionMode.Ignore
|
WlrLayershell.exclusionMode: ExclusionMode.Ignore
|
||||||
WlrLayershell.keyboardFocus: screenState.screenshot ? WlrKeyboardFocus.Exclusive : screenState.launcher || screenState.settings || screenState.sidebar ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None
|
WlrLayershell.keyboardFocus: screenState.launcher || screenState.settings || screenState.sidebar ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None
|
||||||
WlrLayershell.layer: (fsTransitionProg > 0 && Config.general.showOverFullscreen) || (hasSpecialWorkspace && hasFullscreenOnNormalWs) ? WlrLayer.Overlay : WlrLayer.Top
|
WlrLayershell.layer: (fsTransitionProg > 0 && Config.general.showOverFullscreen) || (hasSpecialWorkspace && hasFullscreenOnNormalWs) ? WlrLayer.Overlay : WlrLayer.Top
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
mask: screenState.isDrawing || screenState.screenshot ? null : (hasFullscreen && !bar.isHovered ? emptyRegion : regions)
|
contentItem.focus: true
|
||||||
|
mask: screenState.isDrawing ? null : (hasFullscreen && !bar.isHovered ? emptyRegion : regions)
|
||||||
name: "Bar"
|
name: "Bar"
|
||||||
|
|
||||||
Behavior on fsTransitionProg {
|
Behavior on fsTransitionProg {
|
||||||
@@ -142,6 +143,7 @@ CustomWindow {
|
|||||||
HyprlandFocusGrab {
|
HyprlandFocusGrab {
|
||||||
id: focusGrab
|
id: focusGrab
|
||||||
|
|
||||||
|
windows: [root]
|
||||||
active: {
|
active: {
|
||||||
const s = root.screenState;
|
const s = root.screenState;
|
||||||
const c = Config;
|
const c = Config;
|
||||||
@@ -158,7 +160,6 @@ CustomWindow {
|
|||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
windows: [root]
|
|
||||||
|
|
||||||
onCleared: {
|
onCleared: {
|
||||||
root.screenState.launcher = false;
|
root.screenState.launcher = false;
|
||||||
@@ -184,19 +185,23 @@ CustomWindow {
|
|||||||
id: surface
|
id: surface
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
layer.enabled: true
|
||||||
opacity: root.surfaceColor.a
|
opacity: root.surfaceColor.a
|
||||||
|
|
||||||
BlobGroup2 {
|
layer.effect: MultiEffect {
|
||||||
|
blurMax: 32
|
||||||
|
shadowColor: Qt.alpha(Colors.palette.m3shadow, Math.max(0, root.shadowOpacity))
|
||||||
|
shadowEnabled: true
|
||||||
|
}
|
||||||
|
|
||||||
|
BlobGroup {
|
||||||
id: blobGroup
|
id: blobGroup
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
color: root.surfaceColor
|
color: root.surfaceColor
|
||||||
shadowColor: Qt.alpha(Colors.palette.m3shadow, Math.max(0, root.shadowOpacity))
|
|
||||||
shadowRadius: 18
|
|
||||||
smoothing: Config.bar.smoothing
|
smoothing: Config.bar.smoothing
|
||||||
}
|
}
|
||||||
|
|
||||||
BlobInvertedRect2 {
|
BlobInvertedRect {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: -50
|
anchors.margins: -50
|
||||||
borderBottom: geometry.insetBottom(root.borderThickness) - anchors.margins - root.sdfBorderOffset
|
borderBottom: geometry.insetBottom(root.borderThickness) - anchors.margins - root.sdfBorderOffset
|
||||||
@@ -246,7 +251,6 @@ CustomWindow {
|
|||||||
PanelBg {
|
PanelBg {
|
||||||
id: osdBg
|
id: osdBg
|
||||||
|
|
||||||
atRestOverride: panels.osd.offsetScale < 0.99
|
|
||||||
deformAmount: 0.1
|
deformAmount: 0.1
|
||||||
implicitHeight: panels.osd.height
|
implicitHeight: panels.osd.height
|
||||||
implicitWidth: panels.osd.width
|
implicitWidth: panels.osd.width
|
||||||
@@ -258,7 +262,6 @@ CustomWindow {
|
|||||||
PanelBg {
|
PanelBg {
|
||||||
id: notifsBg
|
id: notifsBg
|
||||||
|
|
||||||
atRestOverride: panel.implicitHeight > 0
|
|
||||||
panel: panels.notifications
|
panel: panels.notifications
|
||||||
radius: Tokens.rounding.large
|
radius: Tokens.rounding.large
|
||||||
}
|
}
|
||||||
@@ -293,16 +296,13 @@ CustomWindow {
|
|||||||
PanelBg {
|
PanelBg {
|
||||||
id: resourcesBg
|
id: resourcesBg
|
||||||
|
|
||||||
property real extraExtent: 0.2
|
|
||||||
|
|
||||||
atRestOverride: panels.resources.offsetScale < 0.99
|
|
||||||
deformAmount: 0.05
|
deformAmount: 0.05
|
||||||
implicitHeight: panels.resources.height * (1 + extraExtent)
|
implicitHeight: panels.resources.height
|
||||||
implicitWidth: panels.resources.width * (1 + extraExtent)
|
implicitWidth: panels.resources.width
|
||||||
panel: panels.resourcesWrapper
|
panel: panels.resourcesWrapper
|
||||||
radius: Tokens.rounding.largeIncreased + Tokens.padding.small
|
radius: Tokens.rounding.largeIncreased + Tokens.padding.small
|
||||||
x: panels.resourcesWrapper.x + panels.resources.x + geometry.insetLeft(root.borderThickness) - panels.resources.width * extraExtent
|
x: panels.resourcesWrapper.x + panels.resources.x + geometry.insetLeft(root.borderThickness)
|
||||||
y: panels.resourcesWrapper.y + panels.resources.y + geometry.insetTop(root.borderThickness) - panels.resources.height * extraExtent
|
y: panels.resourcesWrapper.y + panels.resources.y + geometry.insetTop(root.borderThickness)
|
||||||
}
|
}
|
||||||
|
|
||||||
PanelBg {
|
PanelBg {
|
||||||
@@ -332,15 +332,9 @@ CustomWindow {
|
|||||||
PanelBg {
|
PanelBg {
|
||||||
id: clipboardBg
|
id: clipboardBg
|
||||||
|
|
||||||
property real extraExtent: 0.2
|
|
||||||
|
|
||||||
deformAmount: 0.03
|
deformAmount: 0.03
|
||||||
implicitHeight: panels.clipboard.height * (1 + extraExtent)
|
|
||||||
implicitWidth: panels.clipboard.width * (1 + extraExtent)
|
|
||||||
panel: panels.clipboard
|
panel: panels.clipboard
|
||||||
radius: 29
|
radius: 29
|
||||||
x: panels.clipboard.x + geometry.insetLeft(root.borderThickness) - panels.clipboard.width * extraExtent
|
|
||||||
y: panels.clipboard.y + geometry.insetTop(root.borderThickness)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,8 +342,34 @@ CustomWindow {
|
|||||||
id: drawing
|
id: drawing
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
layer.enabled: true
|
||||||
screenState: root.screenState
|
screenState: root.screenState
|
||||||
z: 2
|
z: 2
|
||||||
|
|
||||||
|
layer.effect: MultiEffect {
|
||||||
|
maskEnabled: true
|
||||||
|
maskInverted: true
|
||||||
|
maskSource: maskSource
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: maskSource
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
layer.enabled: true
|
||||||
|
visible: false
|
||||||
|
|
||||||
|
CustomRect {
|
||||||
|
readonly property int extraWidth: radius
|
||||||
|
|
||||||
|
color: "white"
|
||||||
|
implicitHeight: panels.drawing.height
|
||||||
|
implicitWidth: panels.drawing.width + extraWidth
|
||||||
|
radius: drawingBg.radius
|
||||||
|
x: -extraWidth + root.borderThickness + panels.drawing.x
|
||||||
|
y: panels.drawing.y + bar.implicitHeight
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Interactions2 {
|
Interactions2 {
|
||||||
@@ -429,28 +449,10 @@ CustomWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LazyLoader {
|
component PanelBg: BlobRect {
|
||||||
id: loader
|
|
||||||
|
|
||||||
property bool closing: !root.screenState.screenshot
|
|
||||||
|
|
||||||
onClosingChanged: if (!closing)
|
|
||||||
activeAsync = true
|
|
||||||
|
|
||||||
Picker {
|
|
||||||
loader: loader
|
|
||||||
parent: root.contentItem
|
|
||||||
screen: root.screen
|
|
||||||
screenState: root.screenState
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
component PanelBg: BlobRect2 {
|
|
||||||
property real deformAmount: 0.15
|
property real deformAmount: 0.15
|
||||||
required property Item panel
|
required property Item panel
|
||||||
|
|
||||||
atRestOverride: panel?.offsetScale < 0.99 ?? false
|
|
||||||
damping: 28.3
|
|
||||||
deformScale: (deformAmount * Config.appearance.deform.scale) / 10000
|
deformScale: (deformAmount * Config.appearance.deform.scale) / 10000
|
||||||
group: blobGroup
|
group: blobGroup
|
||||||
implicitHeight: panel.height
|
implicitHeight: panel.height
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Wayland
|
||||||
|
import Quickshell.Io
|
||||||
|
import Quickshell.Hyprland
|
||||||
|
import ZShell
|
||||||
|
import qs.Components
|
||||||
|
|
||||||
|
Scope {
|
||||||
|
LazyLoader {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property bool closing
|
||||||
|
property bool freeze
|
||||||
|
|
||||||
|
Variants {
|
||||||
|
model: Quickshell.screens
|
||||||
|
|
||||||
|
PanelWindow {
|
||||||
|
id: win
|
||||||
|
|
||||||
|
required property ShellScreen modelData
|
||||||
|
|
||||||
|
WlrLayershell.exclusionMode: ExclusionMode.Ignore
|
||||||
|
WlrLayershell.keyboardFocus: root.closing ? WlrKeyboardFocus.None : WlrKeyboardFocus.Exclusive
|
||||||
|
WlrLayershell.layer: WlrLayer.Overlay
|
||||||
|
WlrLayershell.namespace: "areapicker"
|
||||||
|
color: "transparent"
|
||||||
|
mask: root.closing ? empty : null
|
||||||
|
screen: modelData
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
bottom: true
|
||||||
|
left: true
|
||||||
|
right: true
|
||||||
|
top: true
|
||||||
|
}
|
||||||
|
|
||||||
|
Region {
|
||||||
|
id: empty
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Picker {
|
||||||
|
loader: root
|
||||||
|
screen: win.modelData
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IpcHandler {
|
||||||
|
function open(): void {
|
||||||
|
root.freeze = false;
|
||||||
|
root.closing = false;
|
||||||
|
root.activeAsync = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function openFreeze(): void {
|
||||||
|
root.freeze = true;
|
||||||
|
root.closing = false;
|
||||||
|
root.activeAsync = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
target: "picker"
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomShortcut {
|
||||||
|
name: "screenshot"
|
||||||
|
|
||||||
|
onPressed: {
|
||||||
|
root.freeze = false;
|
||||||
|
root.closing = false;
|
||||||
|
root.activeAsync = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomShortcut {
|
||||||
|
name: "screenshotFreeze"
|
||||||
|
|
||||||
|
onPressed: {
|
||||||
|
root.freeze = true;
|
||||||
|
root.closing = false;
|
||||||
|
root.activeAsync = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+36
-82
@@ -41,7 +41,6 @@ Item {
|
|||||||
property real rsy: Math.min(sy, ey)
|
property real rsy: Math.min(sy, ey)
|
||||||
readonly property real scaleRatio: Hypr.monitorFor(screen).scale
|
readonly property real scaleRatio: Hypr.monitorFor(screen).scale
|
||||||
required property ShellScreen screen
|
required property ShellScreen screen
|
||||||
required property ScreenState screenState
|
|
||||||
property real sh: Math.abs(sy - ey)
|
property real sh: Math.abs(sy - ey)
|
||||||
readonly property color shadowColor: Hypr.options.decoration.shadow?.color ?? "black"
|
readonly property color shadowColor: Hypr.options.decoration.shadow?.color ?? "black"
|
||||||
readonly property bool shadowEnabled: Hypr.options.decoration.shadow.enabled
|
readonly property bool shadowEnabled: Hypr.options.decoration.shadow.enabled
|
||||||
@@ -98,6 +97,10 @@ Item {
|
|||||||
const args = Config.screenshot.mode === "auto" ? ["--rounding", `${rounding}`, "--radius", root.cornerRadius, "--shadow", root.shadowEnabled, "--shadow-blur", `${shadow_blur}`, "--shadow-color", `${r},${g},${b},${a}`, "--shadow-offset-x", root.shadowOffset[0], "--shadow-offset-y", root.shadowOffset[1]] : [];
|
const args = Config.screenshot.mode === "auto" ? ["--rounding", `${rounding}`, "--radius", root.cornerRadius, "--shadow", root.shadowEnabled, "--shadow-blur", `${shadow_blur}`, "--shadow-color", `${r},${g},${b},${a}`, "--shadow-offset-x", root.shadowOffset[0], "--shadow-offset-y", root.shadowOffset[1]] : [];
|
||||||
const postCmd = Config.screenshot.enable_pp ? ["zshell-img-tools", "--scale", root.scaleRatio, ...args, "--image"] : null;
|
const postCmd = Config.screenshot.enable_pp ? ["zshell-img-tools", "--scale", root.scaleRatio, ...args, "--image"] : null;
|
||||||
|
|
||||||
|
overlay.visible = border.visible = false;
|
||||||
|
handles.visible = false;
|
||||||
|
toolbar.visible = false;
|
||||||
|
|
||||||
ZShellIo.saveItem(captureLayer, tmpfile, Qt.rect(Math.ceil(rsx), Math.ceil(rsy), Math.floor(sw), Math.floor(sh)), path => {
|
ZShellIo.saveItem(captureLayer, tmpfile, Qt.rect(Math.ceil(rsx), Math.ceil(rsy), Math.floor(sw), Math.floor(sh)), path => {
|
||||||
const finalize = finalPath => {
|
const finalize = finalPath => {
|
||||||
if (copyToClipboard) {
|
if (copyToClipboard) {
|
||||||
@@ -126,22 +129,22 @@ Item {
|
|||||||
Behavior on rsx {
|
Behavior on rsx {
|
||||||
enabled: !selectArea.pressed && root.mode === "select"
|
enabled: !selectArea.pressed && root.mode === "select"
|
||||||
|
|
||||||
Anim {}
|
ExAnim {}
|
||||||
}
|
}
|
||||||
Behavior on rsy {
|
Behavior on rsy {
|
||||||
enabled: !selectArea.pressed && root.mode === "select"
|
enabled: !selectArea.pressed && root.mode === "select"
|
||||||
|
|
||||||
Anim {}
|
ExAnim {}
|
||||||
}
|
}
|
||||||
Behavior on sh {
|
Behavior on sh {
|
||||||
enabled: !selectArea.pressed && root.mode === "select"
|
enabled: !selectArea.pressed && root.mode === "select"
|
||||||
|
|
||||||
Anim {}
|
ExAnim {}
|
||||||
}
|
}
|
||||||
Behavior on sw {
|
Behavior on sw {
|
||||||
enabled: !selectArea.pressed && root.mode === "select"
|
enabled: !selectArea.pressed && root.mode === "select"
|
||||||
|
|
||||||
Anim {}
|
ExAnim {}
|
||||||
}
|
}
|
||||||
Behavior on opacity {
|
Behavior on opacity {
|
||||||
Anim {
|
Anim {
|
||||||
@@ -151,7 +154,7 @@ Item {
|
|||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
Hypr.extras.refreshOptions();
|
Hypr.extras.refreshOptions();
|
||||||
root.forceActiveFocus();
|
screencopy.active = true;
|
||||||
|
|
||||||
opacity = 1;
|
opacity = 1;
|
||||||
|
|
||||||
@@ -216,63 +219,13 @@ Item {
|
|||||||
onReleased: root.enterEditMode()
|
onReleased: root.enterEditMode()
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
|
||||||
function onClosingChanged(): void {
|
|
||||||
if (root.loader.closing)
|
|
||||||
closeAnim.start();
|
|
||||||
else {
|
|
||||||
closeAnim.stop();
|
|
||||||
returnAnim.start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
target: root.loader
|
|
||||||
}
|
|
||||||
|
|
||||||
ParallelAnimation {
|
|
||||||
id: returnAnim
|
|
||||||
|
|
||||||
Anim {
|
|
||||||
duration: 300
|
|
||||||
property: "opacity"
|
|
||||||
target: root
|
|
||||||
to: 1
|
|
||||||
}
|
|
||||||
|
|
||||||
Anim {
|
|
||||||
property: "rsx"
|
|
||||||
target: root
|
|
||||||
to: Math.min(root.sx, root.ex)
|
|
||||||
}
|
|
||||||
|
|
||||||
Anim {
|
|
||||||
property: "rsy"
|
|
||||||
target: root
|
|
||||||
to: Math.min(root.sy, root.ey)
|
|
||||||
}
|
|
||||||
|
|
||||||
Anim {
|
|
||||||
property: "sw"
|
|
||||||
target: root
|
|
||||||
to: Math.abs(root.sx - root.ex)
|
|
||||||
}
|
|
||||||
|
|
||||||
Anim {
|
|
||||||
property: "sh"
|
|
||||||
target: root
|
|
||||||
to: Math.abs(root.sy - root.ey)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SequentialAnimation {
|
SequentialAnimation {
|
||||||
id: closeAnim
|
id: closeAnim
|
||||||
|
|
||||||
ScriptAction {
|
PropertyAction {
|
||||||
script: {
|
property: "closing"
|
||||||
const states = ShellState.allStates();
|
target: root.loader
|
||||||
for (const s of states)
|
value: true
|
||||||
s.screenshot = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ParallelAnimation {
|
ParallelAnimation {
|
||||||
@@ -283,19 +236,19 @@ Item {
|
|||||||
to: 0
|
to: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
Anim {
|
ExAnim {
|
||||||
properties: "rsx,rsy"
|
properties: "rsx,rsy"
|
||||||
target: root
|
target: root
|
||||||
to: 0
|
to: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
Anim {
|
ExAnim {
|
||||||
property: "sw"
|
property: "sw"
|
||||||
target: root
|
target: root
|
||||||
to: root.screen.width
|
to: root.screen.width
|
||||||
}
|
}
|
||||||
|
|
||||||
Anim {
|
ExAnim {
|
||||||
property: "sh"
|
property: "sh"
|
||||||
target: root
|
target: root
|
||||||
to: root.screen.height
|
to: root.screen.height
|
||||||
@@ -314,12 +267,17 @@ Item {
|
|||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
ScreencopyView {
|
Loader {
|
||||||
id: screencopy
|
id: screencopy
|
||||||
|
|
||||||
|
active: false
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
captureSource: root.screen
|
asynchronous: true
|
||||||
paintCursor: false
|
|
||||||
|
sourceComponent: ScreencopyView {
|
||||||
|
captureSource: root.screen
|
||||||
|
paintCursor: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AnnotationCanvas {
|
AnnotationCanvas {
|
||||||
@@ -328,7 +286,6 @@ Item {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
inkColor: root.inkColor
|
inkColor: root.inkColor
|
||||||
layer.enabled: true
|
layer.enabled: true
|
||||||
selection: selectionRect
|
|
||||||
tool: root.mode === "edit" && root.tool !== "move" ? root.tool : "none"
|
tool: root.mode === "edit" && root.tool !== "move" ? root.tool : "none"
|
||||||
|
|
||||||
layer.effect: MultiEffect {
|
layer.effect: MultiEffect {
|
||||||
@@ -340,14 +297,15 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomRect {
|
Rectangle {
|
||||||
id: overlay
|
id: overlay
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: "white"
|
color: "white"
|
||||||
layer.enabled: true
|
layer.enabled: true
|
||||||
opacity: 0.3
|
opacity: 0.3
|
||||||
visible: screencopy.hasContent
|
radius: root.realRounding
|
||||||
|
visible: screencopy.item?.hasContent ?? false
|
||||||
|
|
||||||
layer.effect: MultiEffect {
|
layer.effect: MultiEffect {
|
||||||
maskEnabled: true
|
maskEnabled: true
|
||||||
@@ -376,15 +334,16 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomRect {
|
Rectangle {
|
||||||
id: border
|
id: border
|
||||||
|
|
||||||
border.color: Colors.palette.m3primary
|
border.color: Colors.palette.m3primary
|
||||||
border.width: root.realBorderWidth
|
border.width: root.realBorderWidth
|
||||||
|
color: "transparent"
|
||||||
implicitHeight: selectionRect.implicitHeight + root.realBorderWidth * 2
|
implicitHeight: selectionRect.implicitHeight + root.realBorderWidth * 2
|
||||||
implicitWidth: selectionRect.implicitWidth + root.realBorderWidth * 2
|
implicitWidth: selectionRect.implicitWidth + root.realBorderWidth * 2
|
||||||
radius: root.realRounding > 0 ? root.realRounding + root.realBorderWidth : 0
|
radius: root.realRounding > 0 ? root.realRounding + root.realBorderWidth : 0
|
||||||
visible: screencopy.hasContent
|
visible: screencopy.item?.hasContent ?? false
|
||||||
x: selectionRect.x - root.realBorderWidth
|
x: selectionRect.x - root.realBorderWidth
|
||||||
y: selectionRect.y - root.realBorderWidth
|
y: selectionRect.y - root.realBorderWidth
|
||||||
|
|
||||||
@@ -396,24 +355,17 @@ Item {
|
|||||||
SelectionHandles {
|
SelectionHandles {
|
||||||
id: handles
|
id: handles
|
||||||
|
|
||||||
border: root.realBorderWidth
|
|
||||||
selH: root.sh
|
selH: root.sh
|
||||||
selW: root.sw
|
selW: root.sw
|
||||||
selX: root.rsx
|
selX: root.rsx
|
||||||
selY: root.rsy
|
selY: root.rsy
|
||||||
selection: selectionRect
|
|
||||||
tool: root.tool
|
|
||||||
visible: root.mode === "edit" && root.tool === "move"
|
visible: root.mode === "edit" && root.tool === "move"
|
||||||
|
|
||||||
onBoundsChanged: (x, y, w, h) => {
|
onBoundsChanged: (x, y, w, h) => {
|
||||||
let nx = Math.max(0, x);
|
root.sx = x;
|
||||||
let ny = Math.max(0, y);
|
root.sy = y;
|
||||||
let nw = Math.min(w, root.screen.width - nx);
|
root.ex = x + w;
|
||||||
let nh = Math.min(h, root.screen.height - ny);
|
root.ey = y + h;
|
||||||
root.sx = nx;
|
|
||||||
root.sy = ny;
|
|
||||||
root.ex = nx + nw;
|
|
||||||
root.ey = ny + nh;
|
|
||||||
}
|
}
|
||||||
onMoveBy: (dx, dy) => {
|
onMoveBy: (dx, dy) => {
|
||||||
const w = root.sw, h = root.sh;
|
const w = root.sw, h = root.sh;
|
||||||
@@ -444,4 +396,6 @@ Item {
|
|||||||
onToolSelected: t => root.tool = t
|
onToolSelected: t => root.tool = t
|
||||||
onUndoRequested: annotations.undo()
|
onUndoRequested: annotations.undo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
component ExAnim: Anim {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ Item {
|
|||||||
|
|
||||||
property color inkColor: "#ff3b30"
|
property color inkColor: "#ff3b30"
|
||||||
property real inkWidth: 4
|
property real inkWidth: 4
|
||||||
required property Rectangle selection
|
|
||||||
property string tool: "none"
|
property string tool: "none"
|
||||||
|
|
||||||
signal changed
|
signal changed
|
||||||
|
|
||||||
function clearAll() {
|
function clearAll() {
|
||||||
canvas.clear();
|
committedCanvas.clear();
|
||||||
|
previewCanvas.clear();
|
||||||
changed();
|
changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,85 +54,90 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function undo() {
|
function undo() {
|
||||||
canvas.undoLastGroup();
|
committedCanvas.undoLastGroup();
|
||||||
changed();
|
changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
enabled: tool !== "none"
|
|
||||||
|
|
||||||
StrokeCanvas {
|
StrokeCanvas {
|
||||||
id: canvas
|
id: committedCanvas
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
penColor: root.inkColor
|
penColor: root.inkColor
|
||||||
penWidth: root.inkWidth
|
penWidth: root.inkWidth
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
StrokeCanvas {
|
||||||
|
id: previewCanvas
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
penColor: root.inkColor
|
||||||
|
penWidth: root.inkWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
PointHandler {
|
||||||
id: drawHandler
|
id: drawHandler
|
||||||
|
|
||||||
property real startX
|
property real startX
|
||||||
property real startY
|
property real startY
|
||||||
|
property bool started: false
|
||||||
|
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
anchors.fill: parent
|
enabled: root.tool !== "none"
|
||||||
cursorShape: undefined
|
|
||||||
enabled: root.enabled
|
|
||||||
|
|
||||||
onPositionChanged: e => {
|
onActiveChanged: {
|
||||||
const x = e.x;
|
if (active)
|
||||||
const y = e.y;
|
|
||||||
|
|
||||||
if (!pressed)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (root.tool === "pen") {
|
if (root.tool === "pen") {
|
||||||
canvas.appendPoint(x, y);
|
committedCanvas.endStroke();
|
||||||
|
} else if (started) {
|
||||||
|
const pts = root.sampleShape(root.tool, startX, startY, point.position.x, point.position.y);
|
||||||
|
if (pts.length > 0) {
|
||||||
|
committedCanvas.beginStroke(pts[0][0], pts[0][1], true);
|
||||||
|
for (let i = 1; i < pts.length; i++)
|
||||||
|
committedCanvas.appendPoint(pts[i][0], pts[i][1]);
|
||||||
|
committedCanvas.endStroke();
|
||||||
|
}
|
||||||
|
previewCanvas.clear();
|
||||||
|
}
|
||||||
|
started = false;
|
||||||
|
root.changed();
|
||||||
|
}
|
||||||
|
onPointChanged: {
|
||||||
|
if (!active)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (point.pressedButtons & Qt.RightButton) {
|
||||||
|
root.clearAll();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const pts = root.sampleShape(root.tool, startX, startY, x, y);
|
|
||||||
if (pts.length > 0) {
|
|
||||||
canvas.beginStroke(pts[0][0], pts[0][1], true);
|
|
||||||
for (let i = 1; i < pts.length; i++)
|
|
||||||
canvas.appendPoint(pts[i][0], pts[i][1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onPressed: e => {
|
|
||||||
if (e.button & Qt.LeftButton) {
|
|
||||||
startX = e.x;
|
|
||||||
startY = e.y;
|
|
||||||
canvas.beginStroke(e.x, e.y);
|
|
||||||
} else if (e.button & Qt.RightButton) {
|
|
||||||
root.clearAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onPressedChanged: if (!pressed)
|
|
||||||
canvas.endStroke()
|
|
||||||
}
|
|
||||||
|
|
||||||
HoverHandler {
|
|
||||||
cursorShape: {
|
|
||||||
if (root.tool === "none")
|
|
||||||
return undefined;
|
|
||||||
|
|
||||||
const x = point.position.x;
|
const x = point.position.x;
|
||||||
const y = point.position.y;
|
const y = point.position.y;
|
||||||
const withinXWidth = x > root.selection.x && x < root.selection.x + root.selection.implicitWidth;
|
|
||||||
const withinYHeight = y > root.selection.y && y < root.selection.y + root.selection.implicitHeight;
|
|
||||||
|
|
||||||
if (withinXWidth && withinYHeight) {
|
if (root.tool === "pen") {
|
||||||
if (!drawHandler.pressed)
|
if (!started) {
|
||||||
canvas.showHover(x, y);
|
started = true;
|
||||||
else
|
committedCanvas.beginStroke(x, y);
|
||||||
canvas.showHover(drawHandler.mouseX, drawHandler.mouseY);
|
return;
|
||||||
return Qt.BlankCursor;
|
}
|
||||||
} else {
|
committedCanvas.appendPoint(x, y);
|
||||||
canvas.hideHover();
|
return;
|
||||||
return undefined;
|
}
|
||||||
|
|
||||||
|
if (!started) {
|
||||||
|
started = true;
|
||||||
|
startX = point.pressPosition.x;
|
||||||
|
startY = point.pressPosition.y;
|
||||||
|
}
|
||||||
|
const pts = root.sampleShape(root.tool, startX, startY, x, y);
|
||||||
|
if (pts.length > 0) {
|
||||||
|
previewCanvas.beginStroke(pts[0][0], pts[0][1], true);
|
||||||
|
for (let i = 1; i < pts.length; i++)
|
||||||
|
previewCanvas.appendPoint(pts[i][0], pts[i][1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
enabled: root.enabled
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,18 @@
|
|||||||
pragma ComponentBehavior: Bound
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import ZShell.Internal
|
|
||||||
import qs.Services
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
required property int border
|
property color handleBorder: "#3584e4"
|
||||||
property color handleBorder: Colors.palette.m3primary
|
property color handleFill: "white"
|
||||||
property color handleFill: Colors.palette.m3onPrimary
|
|
||||||
property real hs: 12
|
property real hs: 12
|
||||||
property real minSize: 24
|
property real minSize: 24
|
||||||
required property real selH
|
required property real selH
|
||||||
required property real selW
|
required property real selW
|
||||||
required property real selX
|
required property real selX
|
||||||
required property real selY
|
required property real selY
|
||||||
required property Rectangle selection
|
|
||||||
required property string tool
|
|
||||||
|
|
||||||
signal boundsChanged(x: real, y: real, w: real, h: real)
|
signal boundsChanged(x: real, y: real, w: real, h: real)
|
||||||
signal dragFinished
|
signal dragFinished
|
||||||
@@ -28,16 +23,12 @@ Item {
|
|||||||
x: selX
|
x: selX
|
||||||
y: selY
|
y: selY
|
||||||
|
|
||||||
Component.onDestruction: Cursor.clearOverride()
|
|
||||||
|
|
||||||
DragHandler {
|
DragHandler {
|
||||||
id: moveHandler
|
id: moveHandler
|
||||||
|
|
||||||
property real accumX: 0
|
property real accumX: 0
|
||||||
property real accumY: 0
|
property real accumY: 0
|
||||||
|
|
||||||
cursorShape: undefined
|
|
||||||
dragThreshold: 0
|
|
||||||
target: null
|
target: null
|
||||||
|
|
||||||
onActiveChanged: {
|
onActiveChanged: {
|
||||||
@@ -54,63 +45,51 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HoverHandler {
|
|
||||||
cursorShape: {
|
|
||||||
if (root.tool !== "move")
|
|
||||||
return undefined;
|
|
||||||
|
|
||||||
if ((moveHandler.centroid.pressedButtons & Qt.LeftButton) && moveHandler.active)
|
|
||||||
return Qt.ClosedHandCursor;
|
|
||||||
else
|
|
||||||
return Qt.OpenHandCursor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Handle {
|
Handle {
|
||||||
edge: "tl"
|
edge: "tl"
|
||||||
x: -(root.hs + root.border) / 2
|
x: -root.hs / 2
|
||||||
y: -(root.hs + root.border) / 2
|
y: -root.hs / 2
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle {
|
Handle {
|
||||||
edge: "t"
|
edge: "t"
|
||||||
x: root.width / 2 - root.hs / 2
|
x: root.width / 2 - root.hs / 2
|
||||||
y: -(root.hs + root.border) / 2
|
y: -root.hs / 2
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle {
|
Handle {
|
||||||
edge: "tr"
|
edge: "tr"
|
||||||
x: root.width - root.hs / 2 + root.border / 2
|
x: root.width - root.hs / 2
|
||||||
y: -(root.hs + root.border) / 2
|
y: -root.hs / 2
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle {
|
Handle {
|
||||||
edge: "r"
|
edge: "r"
|
||||||
x: root.width - root.hs / 2 + root.border / 2
|
x: root.width - root.hs / 2
|
||||||
y: root.height / 2 - root.hs / 2
|
y: root.height / 2 - root.hs / 2
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle {
|
Handle {
|
||||||
edge: "br"
|
edge: "br"
|
||||||
x: root.width - root.hs / 2 + root.border / 2
|
x: root.width - root.hs / 2
|
||||||
y: root.height - root.hs / 2 + root.border / 2
|
y: root.height - root.hs / 2
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle {
|
Handle {
|
||||||
edge: "b"
|
edge: "b"
|
||||||
x: root.width / 2 - root.hs / 2
|
x: root.width / 2 - root.hs / 2
|
||||||
y: root.height - root.hs / 2 + root.border / 2
|
y: root.height - root.hs / 2
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle {
|
Handle {
|
||||||
edge: "bl"
|
edge: "bl"
|
||||||
x: -(root.hs + root.border) / 2
|
x: -root.hs / 2
|
||||||
y: root.height - root.hs / 2 + root.border / 2
|
y: root.height - root.hs / 2
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle {
|
Handle {
|
||||||
edge: "l"
|
edge: "l"
|
||||||
x: -(root.hs + root.border) / 2
|
x: -root.hs / 2
|
||||||
y: root.height / 2 - root.hs / 2
|
y: root.height / 2 - root.hs / 2
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,8 +107,6 @@ Item {
|
|||||||
z: 10
|
z: 10
|
||||||
|
|
||||||
HoverHandler {
|
HoverHandler {
|
||||||
id: hover
|
|
||||||
|
|
||||||
cursorShape: {
|
cursorShape: {
|
||||||
switch (handle.edge) {
|
switch (handle.edge) {
|
||||||
case "tl":
|
case "tl":
|
||||||
@@ -155,7 +132,6 @@ Item {
|
|||||||
property real startX
|
property real startX
|
||||||
property real startY
|
property real startY
|
||||||
|
|
||||||
dragThreshold: 0
|
|
||||||
grabPermissions: PointerHandler.CanTakeOverFromAnything | PointerHandler.TakeOverForbidden
|
grabPermissions: PointerHandler.CanTakeOverFromAnything | PointerHandler.TakeOverForbidden
|
||||||
target: null
|
target: null
|
||||||
|
|
||||||
@@ -165,10 +141,8 @@ Item {
|
|||||||
startY = root.y;
|
startY = root.y;
|
||||||
startW = root.width;
|
startW = root.width;
|
||||||
startH = root.height;
|
startH = root.height;
|
||||||
Cursor.setOverride(hover.cursorShape);
|
|
||||||
} else {
|
} else {
|
||||||
root.dragFinished();
|
root.dragFinished();
|
||||||
Cursor.clearOverride();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onTranslationChanged: {
|
onTranslationChanged: {
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ import Quickshell
|
|||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import ZShell.Models
|
import ZShell.Models
|
||||||
import ZShell.Internal
|
|
||||||
import ZShell.Config
|
import ZShell.Config
|
||||||
import qs.Components
|
|
||||||
import qs.Services
|
import qs.Services
|
||||||
import qs.Helpers
|
import qs.Helpers
|
||||||
import qs.Paths
|
import qs.Paths
|
||||||
@@ -142,40 +140,4 @@ Searcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WallpaperService {
|
|
||||||
id: wallpaper
|
|
||||||
|
|
||||||
path: root.current
|
|
||||||
}
|
|
||||||
|
|
||||||
Variants {
|
|
||||||
model: Quickshell.screens
|
|
||||||
|
|
||||||
WallpaperObject {
|
|
||||||
readonly property var crops: root.getCrop(modelData.name)
|
|
||||||
required property var modelData
|
|
||||||
|
|
||||||
cropHeight: crops?.height ?? 1.0
|
|
||||||
cropWidth: crops?.width ?? 1.0
|
|
||||||
cropX: crops?.x ?? 0.0
|
|
||||||
cropY: crops?.y ?? 0.0
|
|
||||||
screen: modelData.name
|
|
||||||
service: wallpaper
|
|
||||||
zoom: crops?.zoom ?? 1.0
|
|
||||||
|
|
||||||
Behavior on cropHeight {
|
|
||||||
Anim {}
|
|
||||||
}
|
|
||||||
Behavior on cropWidth {
|
|
||||||
Anim {}
|
|
||||||
}
|
|
||||||
Behavior on cropX {
|
|
||||||
Anim {}
|
|
||||||
}
|
|
||||||
Behavior on cropY {
|
|
||||||
Anim {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-4
@@ -17,12 +17,12 @@ GridLayout {
|
|||||||
required property Wrapper popouts
|
required property Wrapper popouts
|
||||||
required property ClipWrapper popoutsWrapper
|
required property ClipWrapper popoutsWrapper
|
||||||
required property ShellScreen screen
|
required property ShellScreen screen
|
||||||
required property ScreenState screenState
|
|
||||||
readonly property int vPadding: 6
|
readonly property int vPadding: 6
|
||||||
|
required property ScreenState screenState
|
||||||
|
|
||||||
function axisCenterOf(item: Item): real {
|
function axisCenterOf(item: Item): real {
|
||||||
const c = item.mapToItem(root, item.implicitWidth / 2, item.implicitHeight / 2);
|
const c = item.mapToItem(root, item.implicitWidth / 2, item.implicitHeight / 2);
|
||||||
return horizontal ? Math.floor(c.x) : Math.floor(c.y);
|
return horizontal ? c.x : c.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkPopout(pos: real): void {
|
function checkPopout(pos: real): void {
|
||||||
@@ -210,8 +210,7 @@ GridLayout {
|
|||||||
roleValue: "network"
|
roleValue: "network"
|
||||||
|
|
||||||
delegate: EntryWrapper {
|
delegate: EntryWrapper {
|
||||||
NetworkWidget {
|
NetworkWidget {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import Quickshell
|
import QtQuick.Shapes
|
||||||
import qs.Components
|
import qs.Components
|
||||||
import ZShell.Config
|
import ZShell.Config
|
||||||
import qs.Services
|
import qs.Services
|
||||||
@@ -12,7 +12,6 @@ GridLayout {
|
|||||||
property real animatedPercentage: 0
|
property real animatedPercentage: 0
|
||||||
readonly property real arcStartAngle: 0.75 * Math.PI
|
readonly property real arcStartAngle: 0.75 * Math.PI
|
||||||
readonly property real arcSweep: 1.5 * Math.PI
|
readonly property real arcSweep: 1.5 * Math.PI
|
||||||
readonly property real dpr: (QsWindow.window as QsWindow)?.devicePixelRatio ?? 1
|
|
||||||
required property bool horizontal
|
required property bool horizontal
|
||||||
property string icon
|
property string icon
|
||||||
required property color iconColor
|
required property color iconColor
|
||||||
@@ -23,17 +22,12 @@ GridLayout {
|
|||||||
property bool warning: percentage * 100 >= warningThreshold
|
property bool warning: percentage * 100 >= warningThreshold
|
||||||
property int warningThreshold: 80
|
property int warningThreshold: 80
|
||||||
|
|
||||||
function snap(v) {
|
|
||||||
return Math.round(v * dpr) / dpr;
|
|
||||||
}
|
|
||||||
|
|
||||||
columnSpacing: Tokens.spacing.medium
|
columnSpacing: Tokens.spacing.medium
|
||||||
columns: horizontal ? -1 : 1
|
columns: horizontal ? -1 : 1
|
||||||
percentage: 0
|
percentage: 0
|
||||||
|
|
||||||
Behavior on animatedPercentage {
|
Behavior on animatedPercentage {
|
||||||
Anim {
|
Anim {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: animatedPercentage = percentage
|
Component.onCompleted: animatedPercentage = percentage
|
||||||
@@ -53,35 +47,27 @@ GridLayout {
|
|||||||
text: root.icon
|
text: root.icon
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomRect {
|
CustomClippingRect {
|
||||||
id: track
|
|
||||||
|
|
||||||
Layout.preferredHeight: root.horizontal ? icon.implicitHeight - Tokens.padding.extraSmall : 4
|
Layout.preferredHeight: root.horizontal ? icon.implicitHeight - Tokens.padding.extraSmall : 4
|
||||||
Layout.preferredWidth: root.horizontal ? 4 : icon.implicitWidth
|
Layout.preferredWidth: root.horizontal ? 4 : icon.implicitWidth
|
||||||
color: Colors.layer(Colors.palette.m3surfaceContainerHigh, 2)
|
color: Colors.layer(Colors.palette.m3surfaceContainerHigh, 2)
|
||||||
radius: Math.min(width, height) / 2
|
radius: Tokens.rounding.full
|
||||||
|
|
||||||
Item {
|
CustomRect {
|
||||||
id: clipper
|
id: fill
|
||||||
|
|
||||||
anchors.bottom: root.horizontal ? parent.bottom : undefined
|
anchors.bottom: parent.bottom
|
||||||
anchors.horizontalCenter: root.horizontal ? parent.horizontalCenter : undefined
|
anchors.left: parent.left
|
||||||
anchors.left: root.horizontal ? undefined : parent.left
|
anchors.right: root.horizontal ? parent.right : undefined
|
||||||
anchors.verticalCenter: root.horizontal ? undefined : parent.verticalCenter
|
anchors.top: root.horizontal ? undefined : parent.top
|
||||||
clip: true
|
color: root.mainColor
|
||||||
height: root.horizontal ? root.snap(root.percentage * track.height) : track.height * 2
|
implicitHeight: root.horizontal ? Math.ceil(root.percentage * parent.height) : 0
|
||||||
width: root.horizontal ? track.width * 2 : root.snap(root.percentage * track.width)
|
implicitWidth: root.horizontal ? 0 : Math.ceil(root.percentage * parent.width)
|
||||||
|
|
||||||
CustomRect {
|
// Behavior on implicitHeight {
|
||||||
anchors.bottom: root.horizontal ? parent.bottom : undefined
|
// Anim {
|
||||||
anchors.horizontalCenter: root.horizontal ? parent.horizontalCenter : undefined
|
// }
|
||||||
anchors.left: root.horizontal ? undefined : parent.left
|
// }
|
||||||
anchors.verticalCenter: root.horizontal ? undefined : parent.verticalCenter
|
|
||||||
color: root.mainColor
|
|
||||||
height: track.height
|
|
||||||
radius: track.radius
|
|
||||||
width: track.width
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ CustomClippingRect {
|
|||||||
MaterialIcon {
|
MaterialIcon {
|
||||||
id: noUpdatesIcon
|
id: noUpdatesIcon
|
||||||
|
|
||||||
anchors.centerIn: parent
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
anchors.verticalCenterOffset: -noUpdatesText.implicitHeight
|
anchors.top: parent.top
|
||||||
color: Colors.tPalette.m3onSurfaceVariant
|
color: Colors.tPalette.m3onSurfaceVariant
|
||||||
fontStyle: Tokens.font.icon.builders.large.size(48).weight(Font.DemiBold).build()
|
fontStyle: Tokens.font.icon.builders.large.size(48).weight(Font.DemiBold).build()
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
@@ -45,8 +45,6 @@ CustomClippingRect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CustomText {
|
CustomText {
|
||||||
id: noUpdatesText
|
|
||||||
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
anchors.top: noUpdatesIcon.bottom
|
anchors.top: noUpdatesIcon.bottom
|
||||||
color: Colors.tPalette.m3onSurfaceVariant
|
color: Colors.tPalette.m3onSurfaceVariant
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
pragma ComponentBehavior: Bound
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
import Quickshell.Widgets
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import ZShell.Config
|
import ZShell.Config
|
||||||
@@ -10,6 +11,11 @@ import qs.Components
|
|||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
readonly property real nonAnimWidth: view.implicitWidth + viewWrapper.anchors.margins * 2
|
||||||
|
readonly property real nonAnimHeight: tabs.implicitHeight + tabs.anchors.topMargin + view.implicitHeight + viewWrapper.anchors.margins + viewWrapper.anchors.topMargin
|
||||||
|
|
||||||
|
required property ScreenState screenState
|
||||||
|
|
||||||
readonly property var dashboardTabs: {
|
readonly property var dashboardTabs: {
|
||||||
const allTabs = [
|
const allTabs = [
|
||||||
{
|
{
|
||||||
@@ -39,12 +45,9 @@ Item {
|
|||||||
];
|
];
|
||||||
return allTabs.filter(tab => tab.enabled);
|
return allTabs.filter(tab => tab.enabled);
|
||||||
}
|
}
|
||||||
readonly property real nonAnimHeight: tabs.implicitHeight + tabs.anchors.topMargin + view.implicitHeight + viewWrapper.anchors.margins + viewWrapper.anchors.topMargin
|
|
||||||
readonly property real nonAnimWidth: view.implicitWidth + viewWrapper.anchors.margins * 2
|
|
||||||
required property ScreenState screenState
|
|
||||||
|
|
||||||
implicitHeight: nonAnimHeight
|
|
||||||
implicitWidth: nonAnimWidth
|
implicitWidth: nonAnimWidth
|
||||||
|
implicitHeight: nonAnimHeight
|
||||||
|
|
||||||
Behavior on implicitHeight {
|
Behavior on implicitHeight {
|
||||||
Anim {
|
Anim {
|
||||||
@@ -60,14 +63,15 @@ Item {
|
|||||||
Tabs {
|
Tabs {
|
||||||
id: tabs
|
id: tabs
|
||||||
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.margins: Tokens.padding.small
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.topMargin: ZUtils.clamp(anchors.margins - Config.bar.border, 0, anchors.margins)
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
|
||||||
nonAnimWidth: view.implicitWidth
|
nonAnimWidth: view.implicitWidth
|
||||||
screenState: root.screenState
|
screenState: root.screenState
|
||||||
tabs: root.dashboardTabs
|
tabs: root.dashboardTabs
|
||||||
|
anchors.topMargin: ZUtils.clamp(anchors.margins - Config.bar.border, 0, anchors.margins)
|
||||||
|
anchors.margins: Tokens.padding.small
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
@@ -75,15 +79,15 @@ Item {
|
|||||||
|
|
||||||
property int radius: Tokens.rounding.extraLarge - anchors.margins
|
property int radius: Tokens.rounding.extraLarge - anchors.margins
|
||||||
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.margins: Tokens.padding.small
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.top: tabs.bottom
|
anchors.top: tabs.bottom
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
anchors.topMargin: Tokens.spacing.small
|
anchors.topMargin: Tokens.spacing.small
|
||||||
clip: view.currentIndex !== 3 || (!view.currentItem?.settled ?? true)
|
anchors.margins: Tokens.padding.small
|
||||||
|
clip: true
|
||||||
|
|
||||||
Item {
|
Flickable {
|
||||||
id: view
|
id: view
|
||||||
|
|
||||||
readonly property int currentIndex: root.screenState.dashboardTab
|
readonly property int currentIndex: root.screenState.dashboardTab
|
||||||
@@ -93,50 +97,64 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
implicitHeight: currentItem?.implicitHeight ?? 0
|
|
||||||
implicitWidth: currentItem?.implicitWidth ?? 0
|
implicitWidth: currentItem?.implicitWidth ?? 0
|
||||||
|
implicitHeight: currentItem?.implicitHeight ?? 0
|
||||||
|
|
||||||
Repeater {
|
contentX: currentItem?.x ?? 0
|
||||||
id: repeater
|
contentWidth: row.implicitWidth
|
||||||
|
contentHeight: row.implicitHeight
|
||||||
|
|
||||||
delegate: Loader {
|
interactive: false
|
||||||
id: paneLoader
|
|
||||||
|
|
||||||
required property int index
|
onContentXChanged: {
|
||||||
required property var modelData
|
if (!moving || !currentItem)
|
||||||
|
return;
|
||||||
|
|
||||||
readonly property real targetX: index < view.currentIndex ? -view.implicitWidth : index > view.currentIndex ? view.implicitWidth : 0
|
const x = contentX - currentItem.x;
|
||||||
readonly property bool settled: x === targetX
|
if (x > currentItem.implicitWidth / 2)
|
||||||
|
root.screenState.dashboardTab = Math.min(root.screenState.dashboardTab + 1, tabs.count - 1);
|
||||||
|
else if (x < -currentItem.implicitWidth / 2)
|
||||||
|
root.screenState.dashboardTab = Math.max(root.screenState.dashboardTab - 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
active: index === view.currentIndex || opacity > 0
|
RowLayout {
|
||||||
opacity: index === view.currentIndex ? 1 : 0
|
id: row
|
||||||
sourceComponent: modelData.component
|
|
||||||
visible: opacity > 0
|
|
||||||
x: targetX
|
|
||||||
y: 0
|
|
||||||
|
|
||||||
Behavior on opacity {
|
Repeater {
|
||||||
Anim {
|
id: repeater
|
||||||
type: Anim.DefaultEffects
|
|
||||||
}
|
model: ScriptModel {
|
||||||
|
values: root.dashboardTabs
|
||||||
}
|
}
|
||||||
Behavior on x {
|
|
||||||
Anim {
|
delegate: Loader {
|
||||||
type: Anim.DefaultEffects
|
id: paneLoader
|
||||||
}
|
|
||||||
|
required property int index
|
||||||
|
required property var modelData
|
||||||
|
|
||||||
|
Layout.alignment: Qt.AlignTop
|
||||||
|
|
||||||
|
sourceComponent: modelData.component
|
||||||
|
|
||||||
|
Component.onCompleted: active = Qt.binding(() => {
|
||||||
|
if (index === view.currentIndex)
|
||||||
|
return true;
|
||||||
|
const vx = Math.floor(view.visibleArea.xPosition * view.contentWidth);
|
||||||
|
const vex = Math.floor(vx + view.visibleArea.widthRatio * view.contentWidth);
|
||||||
|
return (vx >= x && vx <= x + implicitWidth) || (vex >= x && vex <= x + implicitWidth);
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
model: ScriptModel {
|
|
||||||
values: root.dashboardTabs
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: dashComponent
|
id: dashComponent
|
||||||
|
|
||||||
Dash {
|
Dash {
|
||||||
radius: viewWrapper.radius
|
|
||||||
screenState: root.screenState
|
screenState: root.screenState
|
||||||
|
radius: viewWrapper.radius
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,8 +170,8 @@ Item {
|
|||||||
id: mediaComponent
|
id: mediaComponent
|
||||||
|
|
||||||
Media {
|
Media {
|
||||||
radius: viewWrapper.radius
|
|
||||||
screenState: root.screenState
|
screenState: root.screenState
|
||||||
|
radius: viewWrapper.radius
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,6 +182,12 @@ Item {
|
|||||||
radius: viewWrapper.radius
|
radius: viewWrapper.radius
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Behavior on contentX {
|
||||||
|
Anim {
|
||||||
|
type: Anim.DefaultEffects
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ Item {
|
|||||||
Layout.alignment: ChatState.isWindow ? Qt.AlignCenter : Qt.AlignLeft | Qt.AlignVCenter
|
Layout.alignment: ChatState.isWindow ? Qt.AlignCenter : Qt.AlignLeft | Qt.AlignVCenter
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
font: Tokens.font.title.medium
|
font: Tokens.font.title.medium
|
||||||
text: qsTr(root.chatData?.title || ChatState.title)
|
text: qsTr(root.chatData.title)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,17 +540,14 @@ Item {
|
|||||||
anchors.margins: Tokens.padding.medium
|
anchors.margins: Tokens.padding.medium
|
||||||
bg.border.color: Colors.palette.m3outlineVariant
|
bg.border.color: Colors.palette.m3outlineVariant
|
||||||
bg.color: Colors.tPalette.m3surfaceContainerLowest
|
bg.color: Colors.tPalette.m3surfaceContainerLowest
|
||||||
fastGlow: LlmClient.busy
|
fastGlow: Chat.busy
|
||||||
glow.opacity: input.activeFocus && (!LlmClient.busy || ChatState.isWindow)
|
|
||||||
font: Tokens.font.body.small
|
font: Tokens.font.body.small
|
||||||
implicitHeight: Math.min(root.height / 5, contentHeight + topPadding + bottomPadding)
|
implicitHeight: Math.min(root.height / 5, contentHeight + topPadding + bottomPadding)
|
||||||
focus: true
|
focus: true
|
||||||
placeholderText: qsTr("Send a message")
|
placeholderText: qsTr("Send a message")
|
||||||
sendIcon.font: Tokens.font.icon.medium
|
sendIcon.font: Tokens.font.icon.medium
|
||||||
sendIcon.icon: LlmClient.busy ? "stop" : "arrow_upward"
|
sendIcon.icon: "arrow_upward"
|
||||||
sendIcon.padding: Tokens.padding.extraSmall
|
sendIcon.padding: Tokens.padding.extraSmall
|
||||||
sendIcon.opacity: text || LlmClient.busy ? 1.0 : 0.5
|
|
||||||
sendIcon.enabled: text || LlmClient.busy
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
root.focusInput();
|
root.focusInput();
|
||||||
@@ -571,11 +568,6 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onButtonPressed: {
|
onSendPressed: root.send(text)
|
||||||
if (LlmClient.busy)
|
|
||||||
LlmClient.stop();
|
|
||||||
else
|
|
||||||
root.send(text);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ CustomClippingRect {
|
|||||||
anchors.leftMargin: readOnly ? 0 : Tokens.padding.large
|
anchors.leftMargin: readOnly ? 0 : Tokens.padding.large
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.topMargin: readOnly ? Tokens.padding.small : Tokens.padding.extraSmall * 2
|
anchors.topMargin: readOnly ? Tokens.padding.small : Tokens.padding.extraSmall * 2
|
||||||
font: Tokens.font.body.medium
|
font: Tokens.font.title.medium
|
||||||
text: root.modelData.title || qsTr("New chat")
|
text: root.modelData.title || qsTr("New chat")
|
||||||
readOnly: true
|
readOnly: true
|
||||||
color: Colors.palette.m3onSurface
|
color: Colors.palette.m3onSurface
|
||||||
@@ -161,6 +161,10 @@ CustomClippingRect {
|
|||||||
CustomRect {
|
CustomRect {
|
||||||
id: fadeMask
|
id: fadeMask
|
||||||
|
|
||||||
|
// anchors.top: titleText.top
|
||||||
|
// anchors.bottom: titleText.bottom
|
||||||
|
// anchors.left: titleText.left
|
||||||
|
// anchors.right: parent.right
|
||||||
anchors.fill: titleWrapper
|
anchors.fill: titleWrapper
|
||||||
|
|
||||||
layer.enabled: true
|
layer.enabled: true
|
||||||
@@ -188,7 +192,6 @@ CustomClippingRect {
|
|||||||
anchors.topMargin: Tokens.spacing.extraSmall
|
anchors.topMargin: Tokens.spacing.extraSmall
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
font: Tokens.font.label.small
|
|
||||||
color: Colors.palette.m3onSurfaceVariant
|
color: Colors.palette.m3onSurfaceVariant
|
||||||
text: qsTr("Created on: %1").arg(root.modelData.createdAt.toLocaleString(Qt.locale("en_US"), "MMM d, yyyy - h:mm AP"))
|
text: qsTr("Created on: %1").arg(root.modelData.createdAt.toLocaleString(Qt.locale("en_US"), "MMM d, yyyy - h:mm AP"))
|
||||||
opacity: root.expanded ? 1 : 0
|
opacity: root.expanded ? 1 : 0
|
||||||
@@ -204,7 +207,6 @@ CustomClippingRect {
|
|||||||
anchors.top: created.bottom
|
anchors.top: created.bottom
|
||||||
anchors.topMargin: Tokens.spacing.small
|
anchors.topMargin: Tokens.spacing.small
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
font: Tokens.font.label.small
|
|
||||||
color: Colors.palette.m3onSurfaceVariant
|
color: Colors.palette.m3onSurfaceVariant
|
||||||
text: qsTr("Updated on: ")
|
text: qsTr("Updated on: ")
|
||||||
opacity: root.expanded ? 1 : 0
|
opacity: root.expanded ? 1 : 0
|
||||||
@@ -221,7 +223,6 @@ CustomClippingRect {
|
|||||||
anchors.top: title.bottom
|
anchors.top: title.bottom
|
||||||
anchors.topMargin: Tokens.spacing.extraSmall
|
anchors.topMargin: Tokens.spacing.extraSmall
|
||||||
color: Colors.palette.m3onSurfaceVariant
|
color: Colors.palette.m3onSurfaceVariant
|
||||||
font: Tokens.font.label.small
|
|
||||||
text: root.modelData.updatedAt.toLocaleString(Qt.locale("en_US"), "MMM d, yyyy - h:mm AP")
|
text: root.modelData.updatedAt.toLocaleString(Qt.locale("en_US"), "MMM d, yyyy - h:mm AP")
|
||||||
|
|
||||||
states: State {
|
states: State {
|
||||||
@@ -252,10 +253,9 @@ CustomClippingRect {
|
|||||||
y: infoContainer.implicitHeight + topMargin
|
y: infoContainer.implicitHeight + topMargin
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
color: Colors.palette.m3onSurfaceVariant
|
color: Colors.palette.m3onSurfaceVariant
|
||||||
font: Tokens.font.body.small
|
|
||||||
maximumLineCount: 1
|
maximumLineCount: 1
|
||||||
opacity: !root.expanded && !root.slim ? 1 : 0
|
opacity: !root.expanded && !root.slim ? 1 : 0
|
||||||
text: root.modelData.messagesModel.lastMessage?.content.replace(/\s+/g, " ").trim() ?? qsTr("No messages yet")
|
text: root.modelData.messagesModel.lastMessage?.activeGeneration.content.replace(/\s+/g, " ").trim() ?? qsTr("No messages yet")
|
||||||
|
|
||||||
Behavior on y {
|
Behavior on y {
|
||||||
Anim {}
|
Anim {}
|
||||||
@@ -280,7 +280,7 @@ CustomClippingRect {
|
|||||||
color: Colors.palette.m3onSurfaceVariant
|
color: Colors.palette.m3onSurfaceVariant
|
||||||
maximumLineCount: 5
|
maximumLineCount: 5
|
||||||
opacity: root.expanded ? 1 : 0
|
opacity: root.expanded ? 1 : 0
|
||||||
text: root.modelData.messagesModel.lastMessage?.content ?? qsTr("No messages yet")
|
text: root.modelData.messagesModel.lastMessage?.activeGeneration.content ?? qsTr("No messages yet")
|
||||||
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
||||||
|
|
||||||
Behavior on y {
|
Behavior on y {
|
||||||
|
|||||||
@@ -8,11 +8,10 @@ TextAreaBase {
|
|||||||
|
|
||||||
readonly property alias bg: bg
|
readonly property alias bg: bg
|
||||||
readonly property alias sendIcon: sendIcon
|
readonly property alias sendIcon: sendIcon
|
||||||
readonly property alias glow: glow
|
|
||||||
|
|
||||||
property bool fastGlow: false
|
property bool fastGlow: false
|
||||||
|
|
||||||
signal buttonPressed
|
signal sendPressed
|
||||||
|
|
||||||
bottomPadding: Tokens.padding.large
|
bottomPadding: Tokens.padding.large
|
||||||
leftPadding: Tokens.padding.extraLarge
|
leftPadding: Tokens.padding.extraLarge
|
||||||
@@ -40,7 +39,6 @@ TextAreaBase {
|
|||||||
GeminiGlow {
|
GeminiGlow {
|
||||||
id: glow
|
id: glow
|
||||||
glowSize: 32
|
glowSize: 32
|
||||||
z: 5
|
|
||||||
|
|
||||||
opacity: root.activeFocus ? 1 : 0
|
opacity: root.activeFocus ? 1 : 0
|
||||||
visible: opacity > 0
|
visible: opacity > 0
|
||||||
@@ -133,7 +131,7 @@ TextAreaBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: root.buttonPressed()
|
onClicked: root.sendPressed()
|
||||||
}
|
}
|
||||||
|
|
||||||
TapHandler {
|
TapHandler {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import QtQuick
|
|||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import ZShell.Llm
|
import ZShell.Llm
|
||||||
import ZShell.Config
|
import ZShell.Config
|
||||||
import qs.Modules.Notifications.Sidebar.Chat.Content
|
|
||||||
import qs.Services
|
import qs.Services
|
||||||
import qs.Components
|
import qs.Components
|
||||||
|
|
||||||
@@ -22,22 +21,15 @@ Item {
|
|||||||
signal loadChatRequest(content: ChatSession, index: int)
|
signal loadChatRequest(content: ChatSession, index: int)
|
||||||
signal newChatRequest
|
signal newChatRequest
|
||||||
|
|
||||||
onSlimChanged: {
|
|
||||||
if (slim)
|
|
||||||
modelsContainer.open = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
CustomText {
|
CustomText {
|
||||||
id: chatHeader
|
id: header
|
||||||
|
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.margins: Tokens.padding.extraSmall
|
anchors.margins: Tokens.padding.extraSmall
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
color: Colors.palette.m3outline
|
color: Colors.palette.m3outline
|
||||||
font.family: "CaskaydiaCove NF"
|
font: Tokens.font.label.large
|
||||||
font.pointSize: 13
|
|
||||||
font.weight: 500
|
|
||||||
text: qsTr("%1 Chat%2").arg(list.count).arg(list.count > 1 ? "s" : "")
|
text: qsTr("%1 Chat%2").arg(list.count).arg(list.count > 1 ? "s" : "")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +39,7 @@ Item {
|
|||||||
anchors.bottom: modelsContainer.top
|
anchors.bottom: modelsContainer.top
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.top: chatHeader.bottom
|
anchors.top: header.bottom
|
||||||
anchors.topMargin: Tokens.spacing.medium
|
anchors.topMargin: Tokens.spacing.medium
|
||||||
clip: true
|
clip: true
|
||||||
spacing: Tokens.spacing.medium
|
spacing: Tokens.spacing.medium
|
||||||
@@ -104,24 +96,156 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelsContainer {
|
CustomClippingRect {
|
||||||
id: modelsContainer
|
id: modelsContainer
|
||||||
|
|
||||||
|
property bool expanded: false
|
||||||
|
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: fabRoot.left
|
anchors.right: fabRoot.left
|
||||||
anchors.margins: Tokens.padding.small
|
anchors.margins: Tokens.padding.small
|
||||||
anchors.rightMargin: Tokens.spacing.small
|
anchors.rightMargin: Tokens.spacing.small
|
||||||
|
|
||||||
rootParent: root
|
implicitHeight: expanded ? 400 : fabRoot.implicitHeight
|
||||||
fabRoot: fabRoot
|
radius: modelLayer.pressed ? Tokens.rounding.small : modelName.implicitHeight / 2
|
||||||
|
|
||||||
opacity: root.slim ? 0 : 1
|
function prettyModelName(): string {
|
||||||
visible: opacity > 0
|
if (modelsList.count < 1)
|
||||||
|
return qsTr("No models found");
|
||||||
|
|
||||||
Behavior on opacity {
|
const pathList = Chat.model.split("\/");
|
||||||
Anim {
|
const name = pathList[pathList.length - 1];
|
||||||
type: Anim.DefaultEffects
|
|
||||||
|
if (!name)
|
||||||
|
return qsTr("No model selected");
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
Behavior on implicitHeight {
|
||||||
|
Anim {}
|
||||||
|
}
|
||||||
|
|
||||||
|
Behavior on radius {
|
||||||
|
Anim {}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: modelName
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: parent.top
|
||||||
|
implicitHeight: fabRoot.implicitHeight
|
||||||
|
|
||||||
|
CustomText {
|
||||||
|
id: label
|
||||||
|
text: modelsContainer.prettyModelName()
|
||||||
|
color: Colors.palette.m3onSurfaceVariant
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.leftMargin: Tokens.padding.large
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialIcon {
|
||||||
|
color: Colors.palette.m3onSurfaceVariant
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.rightMargin: Tokens.padding.large
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
text: modelsContainer.expanded ? "unfold_less" : "unfold_more"
|
||||||
|
animate: true
|
||||||
|
fontStyle: Tokens.font.icon.medium
|
||||||
|
visible: modelsList.count > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
StateLayer {
|
||||||
|
id: modelLayer
|
||||||
|
enabled: modelsList.count > 0
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
ChatState.fabExpanded = false;
|
||||||
|
modelsContainer.expanded = !modelsContainer.expanded;
|
||||||
|
}
|
||||||
|
radius: modelsContainer.radius
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VerticalFadeListView {
|
||||||
|
id: modelsList
|
||||||
|
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.top: modelName.bottom
|
||||||
|
anchors.margins: Tokens.padding.medium
|
||||||
|
anchors.topMargin: Tokens.spacing.medium
|
||||||
|
model: Chat.availableModels
|
||||||
|
opacity: modelsContainer.expanded ? 1 : 0
|
||||||
|
currentIndex: Chat.availableModels.indexOf(Chat.model)
|
||||||
|
visible: opacity > 0
|
||||||
|
|
||||||
|
Behavior on opacity {
|
||||||
|
Anim {}
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomScrollBar.vertical: CustomScrollBar {
|
||||||
|
flickable: modelsList
|
||||||
|
}
|
||||||
|
|
||||||
|
delegate: CustomRect {
|
||||||
|
id: model
|
||||||
|
|
||||||
|
required property var modelData
|
||||||
|
required property int index
|
||||||
|
readonly property bool selected: model.ListView.view.currentIndex === model.index
|
||||||
|
|
||||||
|
implicitWidth: ListView.view.width
|
||||||
|
implicitHeight: layout.implicitHeight + Tokens.padding.small * 2
|
||||||
|
radius: stateLayer.pressed ? Tokens.rounding.extraSmall : selected ? Tokens.rounding.largeIncreased : Tokens.rounding.medium
|
||||||
|
color: Qt.alpha(Colors.palette.m3tertiaryContainer, selected ? 1 : 0)
|
||||||
|
|
||||||
|
Behavior on radius {
|
||||||
|
Anim {
|
||||||
|
type: Anim.SlowEffects
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: layout
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: Tokens.padding.small
|
||||||
|
anchors.leftMargin: Tokens.padding.large
|
||||||
|
anchors.rightMargin: Tokens.padding.large
|
||||||
|
|
||||||
|
CustomText {
|
||||||
|
text: model.modelData
|
||||||
|
color: model.selected ? Colors.palette.m3onTertiaryContainer : Colors.palette.m3onSurface
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialIcon {
|
||||||
|
Layout.alignment: Qt.AlignRight
|
||||||
|
visible: model.selected
|
||||||
|
color: Colors.palette.m3onTertiaryContainer
|
||||||
|
fontStyle: Tokens.font.icon.medium
|
||||||
|
opacity: model.selected ? 1 : 0
|
||||||
|
text: "check"
|
||||||
|
|
||||||
|
Behavior on opacity {
|
||||||
|
Anim {
|
||||||
|
type: Anim.SlowEffects
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StateLayer {
|
||||||
|
id: stateLayer
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
Chat.selectModel(model.modelData);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,14 +257,22 @@ Item {
|
|||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.margins: Tokens.padding.small
|
anchors.margins: Tokens.padding.small
|
||||||
padding: 8
|
padding: 8
|
||||||
font.pointSize: Math.round(18 * 1.2)
|
font: Tokens.font.icon.large
|
||||||
icon: root.slim ? "left_panel_open" : "add"
|
icon: root.slim ? "left_panel_open" : "add"
|
||||||
isRound: ChatState.fabExpanded
|
isRound: ChatState.fabExpanded
|
||||||
|
// opacity: root.slim ? 0 : 1
|
||||||
|
// visible: opacity > 0
|
||||||
|
//
|
||||||
|
// Behavior on opacity {
|
||||||
|
// Anim {
|
||||||
|
// type: Anim.DefaultEffects
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
label.transform: Rotation {
|
label.transform: Rotation {
|
||||||
origin.y: fabRoot.label.height / 2
|
origin.y: fabRoot.label.height / 2
|
||||||
origin.x: fabRoot.label.width / 2
|
origin.x: fabRoot.label.width / 2
|
||||||
angle: ChatState.fabExpanded && (ChatState.narrowSidebarExpanded && !ChatState.isWide || !ChatState.isWindow) ? 135 : 0
|
angle: ChatState.fabExpanded ? 135 : 0
|
||||||
|
|
||||||
Behavior on angle {
|
Behavior on angle {
|
||||||
Anim {}
|
Anim {}
|
||||||
@@ -153,6 +285,7 @@ Item {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
modelsContainer.expanded = false;
|
||||||
ChatState.fabExpanded = !ChatState.fabExpanded;
|
ChatState.fabExpanded = !ChatState.fabExpanded;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,7 +403,7 @@ Item {
|
|||||||
MaterialIcon {
|
MaterialIcon {
|
||||||
text: fabMenuItem.modelData.icon
|
text: fabMenuItem.modelData.icon
|
||||||
color: Colors.palette.m3onPrimaryContainer
|
color: Colors.palette.m3onPrimaryContainer
|
||||||
fontStyle: Tokens.font.icon.large
|
fontStyle: Tokens.font.icon.medium
|
||||||
fill: 1
|
fill: 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,26 +17,15 @@ Item {
|
|||||||
anchors.margins: Tokens.padding.small
|
anchors.margins: Tokens.padding.small
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (ChatState.firstOpen) {
|
|
||||||
ChatState.openDraft();
|
|
||||||
stack.push(chatList);
|
|
||||||
stack.push(chatContent);
|
|
||||||
ChatState.firstOpen = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ChatState.inChat) {
|
if (ChatState.inChat) {
|
||||||
stack.push(chatList);
|
stack.push(chatList);
|
||||||
stack.push(chatContent);
|
stack.push(chatContent, {
|
||||||
|
"chatData": ChatState.chatSession
|
||||||
|
});
|
||||||
} else
|
} else
|
||||||
stack.push(chatList);
|
stack.push(chatList);
|
||||||
}
|
}
|
||||||
|
|
||||||
function openChat(): void {
|
|
||||||
if (stack.depth < 2)
|
|
||||||
stack.push(chatContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
StackView {
|
StackView {
|
||||||
id: stack
|
id: stack
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@@ -46,23 +35,27 @@ Item {
|
|||||||
id: chatList
|
id: chatList
|
||||||
|
|
||||||
ChatList {
|
ChatList {
|
||||||
model: LlmClient.chats
|
model: ScriptModel {
|
||||||
|
values: Chat.chats.values
|
||||||
|
}
|
||||||
|
|
||||||
onDeleteChatRequest: chat => {
|
onDeleteChatRequest: chat => {
|
||||||
const wasCurrent = chat === ChatState.chatSession;
|
Chat.chats.remove(chat);
|
||||||
LlmClient.chats.remove(chat);
|
|
||||||
if (wasCurrent)
|
|
||||||
ChatState.openDraft();
|
|
||||||
}
|
}
|
||||||
onLoadChatRequest: (chat, index) => {
|
onLoadChatRequest: (chat, index) => {
|
||||||
ChatState.chatSession = chat;
|
stack.push(chatContent, {
|
||||||
openChat();
|
"chatData": chat
|
||||||
|
});
|
||||||
ChatState.inChat = true;
|
ChatState.inChat = true;
|
||||||
|
ChatState.chatSession = chat;
|
||||||
}
|
}
|
||||||
onNewChatRequest: {
|
onNewChatRequest: {
|
||||||
ChatState.openDraft();
|
const data = Chat.chats.insert();
|
||||||
openChat();
|
stack.push(chatContent, {
|
||||||
|
"chatData": data
|
||||||
|
});
|
||||||
ChatState.inChat = true;
|
ChatState.inChat = true;
|
||||||
|
ChatState.chatSession = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -71,12 +64,9 @@ Item {
|
|||||||
id: chatContent
|
id: chatContent
|
||||||
|
|
||||||
ChatContent {
|
ChatContent {
|
||||||
chatData: ChatState.chatSession
|
|
||||||
|
|
||||||
onRequestClose: {
|
onRequestClose: {
|
||||||
stack.pop();
|
stack.pop();
|
||||||
ChatState.inChat = false;
|
ChatState.inChat = false;
|
||||||
ChatState.openDraft();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,10 +8,9 @@ import qs.Services
|
|||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property ChatSession chatSession: LlmClient.chats.draft()
|
property ChatSession chatSession
|
||||||
readonly property string title: chatSession?.title || "Chat"
|
readonly property string title: chatSession ? chatSession.title : "Chat"
|
||||||
property int currentIdx: -1
|
property int currentIdx: -1
|
||||||
property bool firstOpen: true
|
|
||||||
property bool inChat: false
|
property bool inChat: false
|
||||||
property bool fabExpanded: false
|
property bool fabExpanded: false
|
||||||
property bool isWindow: false
|
property bool isWindow: false
|
||||||
@@ -23,11 +22,6 @@ Singleton {
|
|||||||
property ShellScreen screen
|
property ShellScreen screen
|
||||||
property bool sidebarVisible: ShellState.forActive().sidebar
|
property bool sidebarVisible: ShellState.forActive().sidebar
|
||||||
|
|
||||||
function openDraft(): void {
|
|
||||||
root.chatSession = LlmClient.chats.draft();
|
|
||||||
root.currentIdx = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
onSidebarVisibleChanged: if (!sidebarVisible)
|
onSidebarVisibleChanged: if (!sidebarVisible)
|
||||||
fabExpanded = false
|
fabExpanded = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,12 @@ import qs.Services
|
|||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
required property ChatGeneration current
|
||||||
required property TextEdit edit
|
required property TextEdit edit
|
||||||
required property bool hovered
|
required property bool hovered
|
||||||
required property bool isUser
|
required property bool isUser
|
||||||
required property ChatMessage message
|
required property ChatMessage message
|
||||||
required property bool running
|
required property LlmSegment segment
|
||||||
|
|
||||||
implicitHeight: editButton.implicitHeight
|
implicitHeight: editButton.implicitHeight
|
||||||
implicitWidth: generationTools.implicitWidth + editTools.implicitWidth + Tokens.spacing.small
|
implicitWidth: generationTools.implicitWidth + editTools.implicitWidth + Tokens.spacing.small
|
||||||
@@ -28,7 +29,6 @@ Item {
|
|||||||
enabled: root.message.generationCount > 1 && root.message.activeGenerationIndex !== 0
|
enabled: root.message.generationCount > 1 && root.message.activeGenerationIndex !== 0
|
||||||
icon: "chevron_left"
|
icon: "chevron_left"
|
||||||
type: IconButton.Tonal
|
type: IconButton.Tonal
|
||||||
isRound: true
|
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (!root.edit.readOnly)
|
if (!root.edit.readOnly)
|
||||||
@@ -40,7 +40,7 @@ Item {
|
|||||||
IconButton {
|
IconButton {
|
||||||
enabled: false
|
enabled: false
|
||||||
icon: `${root.message.activeGenerationIndex + 1}`
|
icon: `${root.message.activeGenerationIndex + 1}`
|
||||||
label.font: Tokens.font.body.small
|
label.font: Tokens.font.label.small
|
||||||
type: IconButton.Text
|
type: IconButton.Text
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +48,6 @@ Item {
|
|||||||
enabled: root.message.generationCount > 1 && root.message.activeGenerationIndex !== root.message.generationCount - 1
|
enabled: root.message.generationCount > 1 && root.message.activeGenerationIndex !== root.message.generationCount - 1
|
||||||
icon: "chevron_right"
|
icon: "chevron_right"
|
||||||
type: IconButton.Tonal
|
type: IconButton.Tonal
|
||||||
isRound: true
|
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (!root.edit.readOnly)
|
if (!root.edit.readOnly)
|
||||||
@@ -62,7 +61,7 @@ Item {
|
|||||||
id: editTools
|
id: editTools
|
||||||
|
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
opacity: !root.running && root.hovered ? 1 : 0
|
opacity: !root.current.streaming && root.hovered ? 1 : 0
|
||||||
spacing: Tokens.spacing.small
|
spacing: Tokens.spacing.small
|
||||||
visible: opacity > 0
|
visible: opacity > 0
|
||||||
|
|
||||||
@@ -76,7 +75,6 @@ Item {
|
|||||||
inactiveOnColor: Colors.palette.m3onSecondary
|
inactiveOnColor: Colors.palette.m3onSecondary
|
||||||
scale: root.edit.readOnly ? 1 : 0
|
scale: root.edit.readOnly ? 1 : 0
|
||||||
visible: !root.isUser
|
visible: !root.isUser
|
||||||
isRound: true
|
|
||||||
|
|
||||||
Behavior on scale {
|
Behavior on scale {
|
||||||
Anim {}
|
Anim {}
|
||||||
@@ -92,13 +90,12 @@ Item {
|
|||||||
inactiveColor: Colors.palette.m3secondary
|
inactiveColor: Colors.palette.m3secondary
|
||||||
inactiveOnColor: Colors.palette.m3onSecondary
|
inactiveOnColor: Colors.palette.m3onSecondary
|
||||||
scale: root.edit.readOnly ? 1 : 0
|
scale: root.edit.readOnly ? 1 : 0
|
||||||
isRound: true
|
|
||||||
|
|
||||||
Behavior on scale {
|
Behavior on scale {
|
||||||
Anim {}
|
Anim {}
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: Quickshell.clipboardText = root.message.content
|
onClicked: Quickshell.clipboardText = root.current.content
|
||||||
}
|
}
|
||||||
|
|
||||||
IconButton {
|
IconButton {
|
||||||
@@ -108,7 +105,6 @@ Item {
|
|||||||
inactiveColor: Colors.palette.m3tertiary
|
inactiveColor: Colors.palette.m3tertiary
|
||||||
inactiveOnColor: Colors.palette.m3onTertiary
|
inactiveOnColor: Colors.palette.m3onTertiary
|
||||||
visible: root.isUser
|
visible: root.isUser
|
||||||
isRound: true
|
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.edit.readOnly = !root.edit.readOnly;
|
root.edit.readOnly = !root.edit.readOnly;
|
||||||
|
|||||||
@@ -1,400 +0,0 @@
|
|||||||
pragma ComponentBehavior: Bound
|
|
||||||
|
|
||||||
import QtQuick
|
|
||||||
import QtQuick.Layouts
|
|
||||||
import ZShell.Config
|
|
||||||
import ZShell.Components
|
|
||||||
import ZShell.Llm
|
|
||||||
import ZShell.Blobs
|
|
||||||
import qs.Components
|
|
||||||
import qs.Services
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
required property Item rootParent
|
|
||||||
required property ChatGeneration current
|
|
||||||
|
|
||||||
implicitHeight: approvalLayout.implicitHeight + approvalLayout.anchors.margins * 2
|
|
||||||
|
|
||||||
CustomRect {
|
|
||||||
id: approvalBg
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
radius: Tokens.rounding.medium
|
|
||||||
color: Colors.palette.m3surface
|
|
||||||
border.width: 1
|
|
||||||
border.color: Colors.palette.m3outlineVariant
|
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
id: approvalLayout
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.margins: Tokens.padding.medium
|
|
||||||
spacing: Tokens.spacing.small
|
|
||||||
|
|
||||||
CustomText {
|
|
||||||
id: requestHeader
|
|
||||||
text: qsTr("Tool call request")
|
|
||||||
font: Tokens.font.headline.medium
|
|
||||||
color: Colors.palette.m3onSurface
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: toolsBg
|
|
||||||
|
|
||||||
property bool open: false
|
|
||||||
property int maxHeight: root.rootParent.height - Tokens.padding.medium * 2
|
|
||||||
property int openHeight: Math.min(toolsContent.item?.implicitHeight, maxHeight)
|
|
||||||
property int openWidth: root.rootParent.width - Tokens.padding.medium * 2
|
|
||||||
property real openHeightProg: openHeight / maxHeight
|
|
||||||
property int collapsedY: 0
|
|
||||||
|
|
||||||
implicitHeight: toolList.implicitHeight + toolList.anchors.margins * 2
|
|
||||||
z: open || dialogTransition.running ? 2 : 0
|
|
||||||
Layout.fillWidth: true
|
|
||||||
|
|
||||||
function reparentWrapper(): void {
|
|
||||||
const newParent = open ? root.rootParent : toolsBg;
|
|
||||||
const c = toolsWrapper.parent.mapToItem(newParent, toolsWrapper.x + toolsWrapper.width / 2, toolsWrapper.y + toolsWrapper.height / 2);
|
|
||||||
toolsBg.collapsedY = toolsWrapper.y;
|
|
||||||
toolsWrapper.parent = newParent;
|
|
||||||
toolsWrapper.x = c.x - toolsWrapper.width / 2;
|
|
||||||
toolsWrapper.y = c.y - toolsWrapper.height / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
onOpenChanged: {
|
|
||||||
if (open)
|
|
||||||
root.rootParent.interactive = false;
|
|
||||||
else
|
|
||||||
root.rootParent.interactive = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
BlobGroup {
|
|
||||||
id: blobGroup
|
|
||||||
|
|
||||||
color: toolsBg.open ? Colors.palette.m3surfaceContainerHighest : Colors.tPalette.m3primaryContainer
|
|
||||||
|
|
||||||
Behavior on color {
|
|
||||||
CAnim {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: backdrop
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
enabled: false
|
|
||||||
hoverEnabled: enabled
|
|
||||||
preventStealing: true
|
|
||||||
parent: toolsBg.open ? root.rootParent : toolsBg
|
|
||||||
|
|
||||||
onClicked: toolsBg.open = false
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: toolsWrapper
|
|
||||||
|
|
||||||
width: toolsBg.width
|
|
||||||
height: toolBox.implicitHeight
|
|
||||||
rotation: parent === root.rootParent ? 180 : 0
|
|
||||||
z: 1
|
|
||||||
|
|
||||||
states: State {
|
|
||||||
name: "open"
|
|
||||||
when: toolsBg.open
|
|
||||||
|
|
||||||
PropertyChanges {
|
|
||||||
backdrop.enabled: true
|
|
||||||
toolsBackground.bottomLeftRadius: Tokens.rounding.largeIncreased
|
|
||||||
toolsBackground.bottomRightRadius: Tokens.rounding.largeIncreased
|
|
||||||
toolsBackground.topRightRadius: Tokens.rounding.largeIncreased
|
|
||||||
toolsBackground.topLeftRadius: Tokens.rounding.largeIncreased
|
|
||||||
toolsContent.opacity: 1
|
|
||||||
toolsWrapper.height: toolsBg.openHeight
|
|
||||||
toolsWrapper.width: toolsBg.openWidth
|
|
||||||
toolsWrapper.x: (root.rootParent.width - toolsBg.openWidth) / 2
|
|
||||||
toolsWrapper.y: (confirmationRow.implicitHeight + Tokens.spacing.small + Tokens.padding.medium) * (1 - toolsBg.openHeightProg) + Tokens.padding.medium
|
|
||||||
elevation.opacity: 1
|
|
||||||
toolBox.opacity: 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
transitions: Transition {
|
|
||||||
id: dialogTransition
|
|
||||||
|
|
||||||
SequentialAnimation {
|
|
||||||
ScriptAction {
|
|
||||||
script: toolsBg.reparentWrapper()
|
|
||||||
}
|
|
||||||
|
|
||||||
Anim {
|
|
||||||
properties: "x,y"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PropertyAction {
|
|
||||||
property: "enabled"
|
|
||||||
}
|
|
||||||
|
|
||||||
Anim {
|
|
||||||
properties: "opacity,topLeftRadius,topRightRadius,bottomLeftRadius,bottomRightRadius"
|
|
||||||
type: Anim.DefaultEffects
|
|
||||||
}
|
|
||||||
|
|
||||||
Anim {
|
|
||||||
properties: "width,height"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Elevation {
|
|
||||||
id: elevation
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
bottomLeftRadius: toolsBackground.bottomLeftRadius
|
|
||||||
bottomRightRadius: toolsBackground.bottomRightRadius
|
|
||||||
level: 4
|
|
||||||
opacity: 0
|
|
||||||
radius: toolsBackground.radius
|
|
||||||
|
|
||||||
transform: Matrix4x4 {
|
|
||||||
matrix: toolsBackground.deformMatrix
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BlobRect {
|
|
||||||
id: toolsBackground
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
bottomLeftRadius: toolsBg.open ? Tokens.rounding.largeIncreased : Tokens.rounding.small
|
|
||||||
bottomRightRadius: toolsBg.open ? Tokens.rounding.largeIncreased : Tokens.rounding.small
|
|
||||||
topRightRadius: toolsBg.open ? Tokens.rounding.largeIncreased : Tokens.rounding.small
|
|
||||||
topLeftRadius: toolsBg.open ? Tokens.rounding.largeIncreased : Tokens.rounding.small
|
|
||||||
deformScale: 0
|
|
||||||
group: blobGroup
|
|
||||||
opacity: blobGroup.color.a * (root.enabled ? 1 : 0.5)
|
|
||||||
}
|
|
||||||
|
|
||||||
CustomRect {
|
|
||||||
id: toolBox
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
height: Math.min(implicitHeight, parent.height)
|
|
||||||
implicitHeight: toolList.implicitHeight + Tokens.padding.medium * 2
|
|
||||||
radius: Tokens.rounding.small
|
|
||||||
|
|
||||||
StateLayer {
|
|
||||||
onClicked: {
|
|
||||||
toolsBg.open = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
id: toolList
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
anchors.margins: Tokens.padding.medium
|
|
||||||
|
|
||||||
Repeater {
|
|
||||||
id: repeater
|
|
||||||
|
|
||||||
model: root.current.pendingToolCalls?.slice(0, 4) ?? []
|
|
||||||
|
|
||||||
delegate: RowLayout {
|
|
||||||
id: toolText
|
|
||||||
|
|
||||||
required property var modelData
|
|
||||||
required property int index
|
|
||||||
|
|
||||||
spacing: Tokens.spacing.medium
|
|
||||||
|
|
||||||
function toolTarget(seg: var): string {
|
|
||||||
var a = null;
|
|
||||||
try {
|
|
||||||
a = JSON.parse(seg.arguments);
|
|
||||||
} catch (e) {}
|
|
||||||
if (a && typeof a === "object") {
|
|
||||||
const v = a.url ?? a.path;
|
|
||||||
if (v !== undefined && v !== null)
|
|
||||||
return String(v);
|
|
||||||
}
|
|
||||||
return String(seg.arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
MaterialIcon {
|
|
||||||
color: Colors.palette.m3onPrimaryContainer
|
|
||||||
text: toolText.modelData.name === "webfetch" ? "web" : "text_snippet"
|
|
||||||
fill: 1
|
|
||||||
}
|
|
||||||
|
|
||||||
CustomText {
|
|
||||||
color: Colors.palette.m3onPrimaryContainer
|
|
||||||
text: qsTr("%1").arg(toolText.modelData.name)
|
|
||||||
}
|
|
||||||
|
|
||||||
MaterialIcon {
|
|
||||||
color: Colors.palette.m3onPrimaryContainer
|
|
||||||
text: "arrow_right_alt"
|
|
||||||
}
|
|
||||||
|
|
||||||
CustomText {
|
|
||||||
color: Colors.palette.m3onPrimaryContainer
|
|
||||||
text: qsTr("%1").arg(toolText.toolTarget(toolText.modelData))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CustomText {
|
|
||||||
color: Colors.palette.m3onPrimaryContainer
|
|
||||||
text: qsTr("And %1 more").arg(root.current.pendingToolCalls.slice(4).length)
|
|
||||||
visible: repeater.count < root.current.pendingToolCalls.length
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Loader {
|
|
||||||
id: toolsContent
|
|
||||||
|
|
||||||
active: opacity > 0
|
|
||||||
anchors.fill: parent
|
|
||||||
asynchronous: false
|
|
||||||
opacity: 0
|
|
||||||
|
|
||||||
sourceComponent: MouseArea {
|
|
||||||
onWheel: event => event.accepted = true
|
|
||||||
preventStealing: true
|
|
||||||
implicitHeight: innerLayout.contentHeight + innerLayout.anchors.margins * 2
|
|
||||||
|
|
||||||
VerticalFadeListView {
|
|
||||||
id: innerLayout
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.margins: Tokens.padding.small
|
|
||||||
cacheBuffer: height * 10
|
|
||||||
fadeAmount: 0.1
|
|
||||||
fadeEnabled: interactive
|
|
||||||
spacing: 0
|
|
||||||
clip: true
|
|
||||||
interactive: contentHeight > toolsBg.maxHeight
|
|
||||||
|
|
||||||
model: root.current.pendingToolCalls ?? []
|
|
||||||
|
|
||||||
delegate: Item {
|
|
||||||
id: toolCall
|
|
||||||
|
|
||||||
required property var modelData
|
|
||||||
property bool expanded: false
|
|
||||||
|
|
||||||
implicitWidth: CustomListView.view.width
|
|
||||||
implicitHeight: collapsedRow.implicitHeight + collapsedRow.anchors.margins + (expanded ? expandedTool.implicitHeight + expandedTool.anchors.margins + expandedTool.anchors.topMargin : collapsedRow.anchors.margins)
|
|
||||||
|
|
||||||
function toolTarget(seg: var): string {
|
|
||||||
var a = null;
|
|
||||||
try {
|
|
||||||
a = JSON.parse(seg.arguments);
|
|
||||||
} catch (e) {}
|
|
||||||
if (a && typeof a === "object") {
|
|
||||||
const v = a.url ?? a.path;
|
|
||||||
if (v !== undefined && v !== null)
|
|
||||||
return String(v);
|
|
||||||
}
|
|
||||||
return String(seg.arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on implicitHeight {
|
|
||||||
Anim {}
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
id: collapsedRow
|
|
||||||
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.margins: Tokens.padding.medium
|
|
||||||
|
|
||||||
IconButton {
|
|
||||||
id: toolExpandBtn
|
|
||||||
|
|
||||||
font: Tokens.font.icon.medium
|
|
||||||
icon: "keyboard_arrow_down"
|
|
||||||
inactiveOnColor: hovered ? Colors.palette.m3onSurface : Colors.palette.m3outline
|
|
||||||
rotation: toolCall.expanded ? 180 : 0
|
|
||||||
type: IconButton.Text
|
|
||||||
|
|
||||||
Behavior on rotation {
|
|
||||||
Anim {}
|
|
||||||
}
|
|
||||||
|
|
||||||
onClicked: toolCall.expanded = !toolCall.expanded
|
|
||||||
}
|
|
||||||
|
|
||||||
CustomText {
|
|
||||||
id: preview
|
|
||||||
|
|
||||||
Layout.fillWidth: true
|
|
||||||
|
|
||||||
text: toolCall.modelData.name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CustomClippingRect {
|
|
||||||
id: expandedTool
|
|
||||||
|
|
||||||
anchors.top: collapsedRow.bottom
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
anchors.margins: Tokens.padding.medium
|
|
||||||
anchors.topMargin: Tokens.spacing.medium
|
|
||||||
|
|
||||||
implicitHeight: fullToolCall.implicitHeight + fullToolCall.anchors.margins * 2
|
|
||||||
radius: Tokens.rounding.medium
|
|
||||||
color: Colors.palette.m3surfaceContainerLow
|
|
||||||
|
|
||||||
CustomText {
|
|
||||||
id: fullToolCall
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.margins: Tokens.padding.medium
|
|
||||||
|
|
||||||
text: toolCall.toolTarget(toolCall.modelData)
|
|
||||||
wrapMode: CustomText.WrapAtWordBoundaryOrAnywhere
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ButtonRow {
|
|
||||||
id: confirmationRow
|
|
||||||
Layout.alignment: Qt.AlignRight
|
|
||||||
spacing: Tokens.spacing.medium
|
|
||||||
|
|
||||||
IconTextButton {
|
|
||||||
icon: "check_circle"
|
|
||||||
text: qsTr("Allow")
|
|
||||||
horizontalPadding: Tokens.padding.large
|
|
||||||
verticalPadding: Tokens.padding.small
|
|
||||||
isRound: true
|
|
||||||
shapeMorph: true
|
|
||||||
onClicked: root.current.approveTools()
|
|
||||||
}
|
|
||||||
|
|
||||||
IconTextButton {
|
|
||||||
icon: "cancel"
|
|
||||||
text: qsTr("Deny")
|
|
||||||
isRound: true
|
|
||||||
shapeMorph: true
|
|
||||||
inactiveColor: Colors.palette.m3error
|
|
||||||
inactiveOnColor: Colors.palette.m3onError
|
|
||||||
horizontalPadding: Tokens.padding.large
|
|
||||||
verticalPadding: Tokens.padding.small
|
|
||||||
onClicked: root.current.denyTools()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -34,12 +34,8 @@ Item {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const attach = () => {
|
const attach = () => {
|
||||||
incubator.object.anchors.top = container.top;
|
incubator.object.anchors.fill = container;
|
||||||
incubator.object.anchors.bottom = container.bottom;
|
|
||||||
incubator.object.anchors.margins = Tokens.padding.medium;
|
|
||||||
incubator.object.anchors.horizontalCenter = container.horizontalCenter;
|
|
||||||
incubator.object.requestClose.connect(root.requestClose);
|
incubator.object.requestClose.connect(root.requestClose);
|
||||||
incubator.object.implicitWidth = Qt.binding(() => Math.max(Math.min(container.width - Tokens.padding.medium * 2, 800), Config.sidebar.sizes.width));
|
|
||||||
currentItem = incubator.object;
|
currentItem = incubator.object;
|
||||||
root.loading = false;
|
root.loading = false;
|
||||||
if (!noAnim)
|
if (!noAnim)
|
||||||
@@ -70,7 +66,7 @@ Item {
|
|||||||
|
|
||||||
LoadingIndicator {
|
LoadingIndicator {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
implicitSize: Tokens.font.icon.extraLarge.pointSize * 4
|
implicitSize: Tokens.font.icon.large.pointSize * 4
|
||||||
opacity: root.loading ? 1 : 0
|
opacity: root.loading ? 1 : 0
|
||||||
visible: opacity > 0
|
visible: opacity > 0
|
||||||
|
|
||||||
|
|||||||
@@ -10,13 +10,12 @@ Item {
|
|||||||
id: root
|
id: root
|
||||||
|
|
||||||
required property bool isUser
|
required property bool isUser
|
||||||
required property string text
|
required property LlmSegment segment
|
||||||
required property var blocks
|
|
||||||
required property bool running
|
|
||||||
required property bool hovered
|
required property bool hovered
|
||||||
required property Repeater repeater
|
required property Repeater repeater
|
||||||
required property int index
|
required property int index
|
||||||
required property ChatMessage message
|
required property ChatMessage message
|
||||||
|
required property ChatGeneration current
|
||||||
|
|
||||||
readonly property real contentMaxWidth: width - Tokens.spacing.extraSmall - Tokens.spacing.extraLarge
|
readonly property real contentMaxWidth: width - Tokens.spacing.extraSmall - Tokens.spacing.extraLarge
|
||||||
|
|
||||||
@@ -35,7 +34,7 @@ Item {
|
|||||||
radius: Tokens.rounding.medium
|
radius: Tokens.rounding.medium
|
||||||
color: root.isUser ? Colors.palette.m3primary : Colors.palette.m3surfaceContainer
|
color: root.isUser ? Colors.palette.m3primary : Colors.palette.m3surfaceContainer
|
||||||
implicitWidth: layoutFrozen ? frozenWidth : layoutWidth
|
implicitWidth: layoutFrozen ? frozenWidth : layoutWidth
|
||||||
implicitHeight: root.isUser ? msgText.contentHeight + Tokens.padding.medium * 2 : markdown.implicitHeight + markdown.anchors.topMargin * 2
|
implicitHeight: root.isUser ? msgText.contentHeight + Tokens.padding.medium * 2 : blocks.implicitHeight + blocks.anchors.topMargin * 2
|
||||||
anchors.right: root.isUser ? parent.right : undefined
|
anchors.right: root.isUser ? parent.right : undefined
|
||||||
layer.enabled: false
|
layer.enabled: false
|
||||||
layer.smooth: true
|
layer.smooth: true
|
||||||
@@ -75,7 +74,7 @@ Item {
|
|||||||
TextEditBase {
|
TextEditBase {
|
||||||
id: msgText
|
id: msgText
|
||||||
|
|
||||||
property string cachedText: root.text
|
property string cachedText: root.segment.text
|
||||||
property bool cancelled: false
|
property bool cancelled: false
|
||||||
|
|
||||||
visible: root.isUser
|
visible: root.isUser
|
||||||
@@ -89,7 +88,7 @@ Item {
|
|||||||
font: Tokens.font.body.small
|
font: Tokens.font.body.small
|
||||||
readOnly: true
|
readOnly: true
|
||||||
selectionColor: Qt.alpha((root.isUser ? Colors.palette.m3onPrimary : Colors.palette.m3primary), 0.4)
|
selectionColor: Qt.alpha((root.isUser ? Colors.palette.m3onPrimary : Colors.palette.m3primary), 0.4)
|
||||||
text: root.isUser ? root.text : ""
|
text: root.isUser ? root.segment.text : ""
|
||||||
textFormat: CustomText.MarkdownText
|
textFormat: CustomText.MarkdownText
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
|
|
||||||
@@ -130,22 +129,23 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Assistant content: parsed markdown blocks.
|
||||||
MarkdownBlocks {
|
MarkdownBlocks {
|
||||||
id: markdown
|
id: blocks
|
||||||
|
|
||||||
visible: !root.isUser
|
visible: !root.isUser
|
||||||
anchors.topMargin: Tokens.padding.medium
|
anchors.topMargin: Tokens.padding.medium
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
blocks: root.blocks
|
blocks: root.segment.markdown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Actions {
|
Actions {
|
||||||
id: actionsRow
|
id: actionsRow
|
||||||
|
|
||||||
readonly property bool shouldBeActive: !root.running && root.repeater.count === (root.index + 1)
|
readonly property bool shouldBeActive: (root.segment.type === LlmSegment.Type.Content) && !root.segment.running && root.repeater.count === (root.index + 1)
|
||||||
|
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: (implicitWidth > bubble.implicitWidth) ? undefined : bubble.right
|
anchors.right: (implicitWidth > bubble.implicitWidth) ? undefined : bubble.right
|
||||||
@@ -156,7 +156,8 @@ Item {
|
|||||||
edit: msgText
|
edit: msgText
|
||||||
hovered: root.hovered
|
hovered: root.hovered
|
||||||
isUser: root.isUser
|
isUser: root.isUser
|
||||||
running: root.running
|
segment: root.segment
|
||||||
|
current: root.current
|
||||||
message: root.message
|
message: root.message
|
||||||
|
|
||||||
Behavior on opacity {
|
Behavior on opacity {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ ColumnLayout {
|
|||||||
MaterialIcon {
|
MaterialIcon {
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
color: Colors.tPalette.m3outlineVariant
|
color: Colors.tPalette.m3outlineVariant
|
||||||
fontStyle: Tokens.font.icon.extraLarge
|
fontStyle: Tokens.font.icon.large
|
||||||
text: "chat"
|
text: "chat"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ Item {
|
|||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
font: Tokens.font.headline.small
|
font: Tokens.font.title.large
|
||||||
elide: CustomText.ElideRight
|
elide: CustomText.ElideRight
|
||||||
color: Colors.palette.m3onErrorContainer
|
color: Colors.palette.m3onErrorContainer
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ Item {
|
|||||||
wrapMode: CustomText.WordWrap
|
wrapMode: CustomText.WordWrap
|
||||||
color: Colors.palette.m3onErrorContainer
|
color: Colors.palette.m3onErrorContainer
|
||||||
|
|
||||||
text: root.current.errorMessage || LlmClient.serverError
|
text: root.current.errorMessage || Chat.serverError
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,10 +23,10 @@ Column {
|
|||||||
role: "type"
|
role: "type"
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MarkdownBlock.Type.Code
|
roleValue: LlmMarkdown.Type.Code
|
||||||
|
|
||||||
delegate: CodeBlockView {
|
delegate: CodeBlockView {
|
||||||
required property MarkdownBlock modelData
|
required property var modelData
|
||||||
|
|
||||||
language: modelData.language
|
language: modelData.language
|
||||||
code: modelData.code
|
code: modelData.code
|
||||||
@@ -37,10 +37,10 @@ Column {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MarkdownBlock.Type.Math
|
roleValue: LlmMarkdown.Type.Math
|
||||||
|
|
||||||
delegate: MathBlockView {
|
delegate: MathBlockView {
|
||||||
required property MarkdownBlock modelData
|
required property var modelData
|
||||||
|
|
||||||
latex: modelData.latex
|
latex: modelData.latex
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
@@ -50,10 +50,10 @@ Column {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MarkdownBlock.Type.Heading
|
roleValue: LlmMarkdown.Type.Heading
|
||||||
|
|
||||||
delegate: TextEditBase {
|
delegate: TextEditBase {
|
||||||
required property MarkdownBlock modelData
|
required property var modelData
|
||||||
|
|
||||||
color: Colors.palette.m3onSurface
|
color: Colors.palette.m3onSurface
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
@@ -64,20 +64,20 @@ Column {
|
|||||||
readOnly: true
|
readOnly: true
|
||||||
font: {
|
font: {
|
||||||
if (modelData.level <= 1)
|
if (modelData.level <= 1)
|
||||||
return Tokens.font.title.builders.large.weight(Font.Bold).build();
|
return Tokens.font.headline.builders.small.weight(Font.Bold).build();
|
||||||
if (modelData.level === 2)
|
if (modelData.level === 2)
|
||||||
return Tokens.font.title.builders.medium.weight(Font.Bold).build();
|
return Tokens.font.headline.builders.small.size(18).weight(Font.DemiBold).build();
|
||||||
return Tokens.font.title.builders.small.weight(Font.Bold).build();
|
return Tokens.font.body.medium;
|
||||||
}
|
}
|
||||||
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MarkdownBlock.Type.Text
|
roleValue: LlmMarkdown.Type.Text
|
||||||
|
|
||||||
delegate: BubbleEdit {
|
delegate: BubbleEdit {
|
||||||
required property MarkdownBlock modelData
|
required property var modelData
|
||||||
|
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ Item {
|
|||||||
|
|
||||||
required property string latex
|
required property string latex
|
||||||
property color mathColor: Colors.palette.m3onSurface
|
property color mathColor: Colors.palette.m3onSurface
|
||||||
property font font: Tokens.font.headline.medium
|
property real fontSize: Tokens.font.body.large.pointSize
|
||||||
|
|
||||||
implicitHeight: Math.max(equationImage.height, fallbackText.contentHeight) + Tokens.padding.small * 2
|
implicitHeight: Math.max(equationImage.height, fallbackText.contentHeight) + Tokens.padding.small * 2
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ Item {
|
|||||||
|
|
||||||
latex: root.latex
|
latex: root.latex
|
||||||
color: root.mathColor
|
color: root.mathColor
|
||||||
fontPointSize: root.font.pointSize
|
fontPointSize: root.fontSize
|
||||||
devicePixelRatio: Screen.devicePixelRatio
|
devicePixelRatio: Screen.devicePixelRatio
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ Item {
|
|||||||
|
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
color: root.mathColor
|
color: root.mathColor
|
||||||
font: Tokens.font.mono.medium
|
font: Tokens.font.mono.small
|
||||||
text: root.latex
|
text: root.latex
|
||||||
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
||||||
visible: !math.ok
|
visible: !math.ok
|
||||||
|
|||||||
@@ -19,16 +19,7 @@ MouseArea {
|
|||||||
required property ChatListView chatList
|
required property ChatListView chatList
|
||||||
|
|
||||||
readonly property bool isUser: modelData.role === ChatMessage.Role.User
|
readonly property bool isUser: modelData.role === ChatMessage.Role.User
|
||||||
|
readonly property var blocks: blockify(current.segments, current.error)
|
||||||
readonly property var blocks: root.isUser ? [
|
|
||||||
{
|
|
||||||
kind: "content",
|
|
||||||
id: 0,
|
|
||||||
text: root.modelData.content,
|
|
||||||
markdown: [],
|
|
||||||
running: false
|
|
||||||
}
|
|
||||||
] : blockify(current.segments, current.error)
|
|
||||||
|
|
||||||
property ChatGeneration current: modelData.activeGeneration
|
property ChatGeneration current: modelData.activeGeneration
|
||||||
property bool reasoningExpanded: false
|
property bool reasoningExpanded: false
|
||||||
@@ -63,9 +54,7 @@ MouseArea {
|
|||||||
blocks.push({
|
blocks.push({
|
||||||
kind: "content",
|
kind: "content",
|
||||||
id: i,
|
id: i,
|
||||||
text: seg.text,
|
segments: [seg]
|
||||||
markdown: seg.markdown,
|
|
||||||
running: seg.running
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const last = blocks.length ? blocks[blocks.length - 1] : null;
|
const last = blocks.length ? blocks[blocks.length - 1] : null;
|
||||||
@@ -242,7 +231,7 @@ MouseArea {
|
|||||||
|
|
||||||
MaterialIcon {
|
MaterialIcon {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
fontStyle: Tokens.font.icon.extraLarge
|
fontStyle: Tokens.font.icon.large
|
||||||
text: thumb.fileIcon(thumb.modelData?.mimeType ?? "")
|
text: thumb.fileIcon(thumb.modelData?.mimeType ?? "")
|
||||||
visible: !thumb.modelData?.isImage ?? false
|
visible: !thumb.modelData?.isImage ?? false
|
||||||
}
|
}
|
||||||
@@ -341,12 +330,11 @@ MouseArea {
|
|||||||
required property var modelData
|
required property var modelData
|
||||||
|
|
||||||
isUser: root.isUser
|
isUser: root.isUser
|
||||||
text: modelData.text
|
segment: modelData.segments[0]
|
||||||
blocks: modelData.markdown
|
|
||||||
running: modelData.running
|
|
||||||
width: root.width
|
width: root.width
|
||||||
repeater: segmentRep
|
repeater: segmentRep
|
||||||
message: root.modelData
|
message: root.modelData
|
||||||
|
current: root.current
|
||||||
hovered: root.containsMouse
|
hovered: root.containsMouse
|
||||||
|
|
||||||
onEdit: text => {
|
onEdit: text => {
|
||||||
|
|||||||
@@ -1,351 +0,0 @@
|
|||||||
pragma ComponentBehavior: Bound
|
|
||||||
|
|
||||||
import QtQuick
|
|
||||||
import QtQuick.Layouts
|
|
||||||
import ZShell.Config
|
|
||||||
import ZShell.Components
|
|
||||||
import ZShell.Llm
|
|
||||||
import ZShell.Blobs
|
|
||||||
import qs.Modules.Notifications.Sidebar.Chat
|
|
||||||
import qs.Components
|
|
||||||
import qs.Services
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
required property Item rootParent
|
|
||||||
required property Item fabRoot
|
|
||||||
|
|
||||||
property bool open: false
|
|
||||||
|
|
||||||
property int maxHeight: root.rootParent.height - Tokens.padding.medium * 2
|
|
||||||
property int openHeight: Math.min(modelsContent.item?.implicitHeight, maxHeight)
|
|
||||||
property int openWidth: root.rootParent.width - Tokens.padding.medium * 2
|
|
||||||
property real openHeightProg: openHeight / maxHeight
|
|
||||||
property int collapsedY: 0
|
|
||||||
|
|
||||||
property int horizontalContentMargin
|
|
||||||
property string header: qsTr("Available models")
|
|
||||||
property string acceptLabel: qsTr("Accept")
|
|
||||||
|
|
||||||
z: open || dialogTransition.running ? 2 : 0
|
|
||||||
Layout.fillWidth: true
|
|
||||||
|
|
||||||
implicitHeight: fabRoot.implicitHeight
|
|
||||||
|
|
||||||
function prettyModelName(): string {
|
|
||||||
if (modelsContent.item?.modelsList.count < 1)
|
|
||||||
return qsTr("No models found");
|
|
||||||
|
|
||||||
const pathList = LlmClient.model.split("\/");
|
|
||||||
const name = pathList[pathList.length - 1];
|
|
||||||
|
|
||||||
if (!name)
|
|
||||||
return qsTr("No model selected");
|
|
||||||
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on implicitHeight {
|
|
||||||
Anim {}
|
|
||||||
}
|
|
||||||
|
|
||||||
function reparentWrapper(): void {
|
|
||||||
const newParent = open ? root.rootParent : root;
|
|
||||||
const c = modelsWrapper.parent.mapToItem(newParent, modelsWrapper.x + modelsWrapper.width / 2, modelsWrapper.y + modelsWrapper.height / 2);
|
|
||||||
root.collapsedY = modelsWrapper.y;
|
|
||||||
modelsWrapper.parent = newParent;
|
|
||||||
modelsWrapper.x = c.x - modelsWrapper.width / 2;
|
|
||||||
modelsWrapper.y = c.y - modelsWrapper.height / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
BlobGroup {
|
|
||||||
id: blobGroup
|
|
||||||
|
|
||||||
color: root.open ? Colors.palette.m3surfaceContainerHighest : Colors.tPalette.m3surfaceContainer
|
|
||||||
|
|
||||||
Behavior on color {
|
|
||||||
CAnim {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: backdrop
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
enabled: false
|
|
||||||
hoverEnabled: enabled
|
|
||||||
preventStealing: true
|
|
||||||
parent: root.open ? root.rootParent : root
|
|
||||||
|
|
||||||
onClicked: root.open = false
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: modelsWrapper
|
|
||||||
|
|
||||||
width: root.width
|
|
||||||
height: modelBox.implicitHeight
|
|
||||||
z: 1
|
|
||||||
|
|
||||||
states: State {
|
|
||||||
name: "open"
|
|
||||||
when: root.open
|
|
||||||
|
|
||||||
PropertyChanges {
|
|
||||||
backdrop.enabled: true
|
|
||||||
modelsBackground.radius: Tokens.rounding.largeIncreased
|
|
||||||
modelsContent.opacity: 1
|
|
||||||
modelsWrapper.height: root.openHeight
|
|
||||||
modelsWrapper.width: root.openWidth
|
|
||||||
modelsWrapper.x: (root.rootParent.width - root.openWidth) / 2
|
|
||||||
modelsWrapper.y: root.rootParent.height - root.openHeight - Tokens.spacing.medium - Tokens.padding.medium - root.fabRoot.implicitHeight
|
|
||||||
elevation.opacity: 1
|
|
||||||
modelBox.opacity: 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
transitions: Transition {
|
|
||||||
id: dialogTransition
|
|
||||||
|
|
||||||
SequentialAnimation {
|
|
||||||
ScriptAction {
|
|
||||||
script: root.reparentWrapper()
|
|
||||||
}
|
|
||||||
|
|
||||||
Anim {
|
|
||||||
properties: "x,y"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PropertyAction {
|
|
||||||
property: "enabled"
|
|
||||||
}
|
|
||||||
|
|
||||||
Anim {
|
|
||||||
properties: "opacity,radius"
|
|
||||||
type: Anim.DefaultEffects
|
|
||||||
}
|
|
||||||
|
|
||||||
Anim {
|
|
||||||
properties: "width,height"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Elevation {
|
|
||||||
id: elevation
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
level: 4
|
|
||||||
opacity: 0
|
|
||||||
radius: modelsBackground.radius
|
|
||||||
|
|
||||||
transform: Matrix4x4 {
|
|
||||||
matrix: modelsBackground.deformMatrix
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BlobRect {
|
|
||||||
id: modelsBackground
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
radius: modelLayer.pressed ? Tokens.rounding.small : Tokens.rounding.extraLarge
|
|
||||||
deformScale: 0
|
|
||||||
group: blobGroup
|
|
||||||
opacity: blobGroup.color.a * (root.enabled ? 1 : 0.5)
|
|
||||||
|
|
||||||
Behavior on radius {
|
|
||||||
Anim {
|
|
||||||
type: Anim.DefaultEffects
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CustomRect {
|
|
||||||
id: modelBox
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.top: parent.top
|
|
||||||
implicitHeight: root.fabRoot.implicitHeight
|
|
||||||
radius: modelsBackground.radius
|
|
||||||
|
|
||||||
CustomText {
|
|
||||||
id: label
|
|
||||||
text: root.prettyModelName()
|
|
||||||
color: Colors.palette.m3onSurfaceVariant
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.leftMargin: Tokens.padding.large
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
|
|
||||||
MaterialIcon {
|
|
||||||
color: Colors.palette.m3onSurfaceVariant
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.rightMargin: Tokens.padding.large
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
text: "unfold_more"
|
|
||||||
fontStyle: Tokens.font.icon.large
|
|
||||||
}
|
|
||||||
|
|
||||||
StateLayer {
|
|
||||||
id: modelLayer
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
ChatState.fabExpanded = false;
|
|
||||||
root.open = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Loader {
|
|
||||||
id: modelsContent
|
|
||||||
|
|
||||||
active: opacity > 0
|
|
||||||
anchors.fill: parent
|
|
||||||
asynchronous: false
|
|
||||||
opacity: 0
|
|
||||||
|
|
||||||
sourceComponent: MouseArea {
|
|
||||||
readonly property alias modelsList: modelsList
|
|
||||||
|
|
||||||
onWheel: event => event.accepted = true
|
|
||||||
preventStealing: true
|
|
||||||
clip: true
|
|
||||||
implicitHeight: innerLayout.implicitHeight + innerLayout.anchors.margins * 2
|
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
id: innerLayout
|
|
||||||
anchors.bottomMargin: Tokens.padding.largeIncreased
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.margins: Tokens.padding.extraLarge
|
|
||||||
spacing: 0
|
|
||||||
|
|
||||||
CustomText {
|
|
||||||
font: Tokens.font.title.builders.large.weight(Font.Normal).build()
|
|
||||||
text: root.header
|
|
||||||
}
|
|
||||||
|
|
||||||
VerticalFadeListView {
|
|
||||||
id: modelsList
|
|
||||||
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.leftMargin: root.horizontalContentMargin
|
|
||||||
Layout.topMargin: Tokens.spacing.medium
|
|
||||||
Layout.bottomMargin: Tokens.spacing.medium
|
|
||||||
Layout.rightMargin: root.horizontalContentMargin
|
|
||||||
Layout.preferredHeight: 400
|
|
||||||
Layout.maximumHeight: 400
|
|
||||||
model: LlmClient.availableModels
|
|
||||||
currentIndex: LlmClient.availableModels.indexOf(LlmClient.model)
|
|
||||||
visible: opacity > 0
|
|
||||||
|
|
||||||
Behavior on opacity {
|
|
||||||
Anim {}
|
|
||||||
}
|
|
||||||
|
|
||||||
CustomScrollBar.vertical: CustomScrollBar {
|
|
||||||
flickable: modelsList
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate: CustomRect {
|
|
||||||
id: model
|
|
||||||
|
|
||||||
required property var modelData
|
|
||||||
required property int index
|
|
||||||
readonly property bool selected: ListView.view.currentIndex === model.index
|
|
||||||
|
|
||||||
implicitWidth: ListView.view.width
|
|
||||||
implicitHeight: name.implicitHeight + Tokens.padding.small * 2
|
|
||||||
radius: stateLayer.pressed ? Tokens.rounding.extraSmall : selected ? Tokens.rounding.largeIncreased : Tokens.rounding.medium
|
|
||||||
color: Qt.alpha(Colors.palette.m3tertiaryContainer, selected ? 1 : 0)
|
|
||||||
|
|
||||||
Behavior on radius {
|
|
||||||
Anim {
|
|
||||||
type: Anim.SlowEffects
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
id: layout
|
|
||||||
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
anchors.margins: Tokens.padding.small
|
|
||||||
anchors.leftMargin: Tokens.padding.large
|
|
||||||
anchors.rightMargin: Tokens.padding.large
|
|
||||||
|
|
||||||
CustomText {
|
|
||||||
id: name
|
|
||||||
|
|
||||||
text: model.modelData
|
|
||||||
elide: CustomText.ElideRight
|
|
||||||
color: model.selected ? Colors.palette.m3onTertiaryContainer : Colors.palette.m3onSurface
|
|
||||||
|
|
||||||
Layout.fillWidth: true
|
|
||||||
}
|
|
||||||
|
|
||||||
MaterialIcon {
|
|
||||||
id: check
|
|
||||||
|
|
||||||
color: Colors.palette.m3onTertiaryContainer
|
|
||||||
fontStyle: Tokens.font.icon.medium
|
|
||||||
opacity: model.selected ? 1 : 0
|
|
||||||
visible: opacity > 0
|
|
||||||
text: "check"
|
|
||||||
|
|
||||||
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
|
|
||||||
|
|
||||||
Behavior on opacity {
|
|
||||||
Anim {
|
|
||||||
type: Anim.SlowEffects
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
StateLayer {
|
|
||||||
id: stateLayer
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
model.ListView.view.currentIndex = model.index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
Layout.alignment: Qt.AlignRight
|
|
||||||
spacing: Tokens.spacing.extraSmall
|
|
||||||
|
|
||||||
TextButton {
|
|
||||||
horizontalPadding: Tokens.padding.largeIncreased
|
|
||||||
isRound: true
|
|
||||||
text: qsTr("Cancel")
|
|
||||||
type: TextButton.Text
|
|
||||||
verticalPadding: Tokens.padding.small
|
|
||||||
stateLayer.preventStealing: true
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
root.open = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TextButton {
|
|
||||||
horizontalPadding: Tokens.padding.largeIncreased
|
|
||||||
isRound: true
|
|
||||||
text: root.acceptLabel
|
|
||||||
type: TextButton.Text
|
|
||||||
stateLayer.preventStealing: true
|
|
||||||
verticalPadding: Tokens.padding.small
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
LlmClient.selectModel(modelsList.currentItem.modelData);
|
|
||||||
root.open = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,9 +18,9 @@ Item {
|
|||||||
required property ChatGeneration current
|
required property ChatGeneration current
|
||||||
readonly property bool isActive: index === blocks.length - 1
|
readonly property bool isActive: index === blocks.length - 1
|
||||||
property bool expanded: false
|
property bool expanded: false
|
||||||
readonly property var lastSegment: root.segments[root.segments.length - 1]
|
readonly property LlmSegment lastSegment: root.segments[root.segments.length - 1]
|
||||||
readonly property real totalElapsedMs: root.segments.reduce((sum, s) => sum + (s.elapsedMs ?? 0), 0)
|
readonly property real totalElapsedMs: root.segments.reduce((sum, s) => sum + (s.elapsedMs ?? 0), 0)
|
||||||
readonly property bool pendingApproval: current.toolApprovalPending && segments.some(s => s.type === LlmSegment.Type.ToolCall && s.status === LlmToolCall.Status.Pending)
|
readonly property bool pendingApproval: current.toolApprovalPending && segments.filter(s => s.type === LlmSegment.Type.ToolCall).some(s => current.pendingToolCalls.includes(s))
|
||||||
|
|
||||||
implicitHeight: {
|
implicitHeight: {
|
||||||
const expand = expandedRect.implicitHeight + layout.implicitHeight + expandedRect.anchors.topMargin;
|
const expand = expandedRect.implicitHeight + layout.implicitHeight + expandedRect.anchors.topMargin;
|
||||||
@@ -91,7 +91,6 @@ Item {
|
|||||||
id: collapsedText
|
id: collapsedText
|
||||||
|
|
||||||
color: Colors.palette.m3outline
|
color: Colors.palette.m3outline
|
||||||
font: Tokens.font.label.small
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.leftMargin: Tokens.spacing.medium
|
Layout.leftMargin: Tokens.spacing.medium
|
||||||
text: {
|
text: {
|
||||||
@@ -112,17 +111,396 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ApprovalPrompt {
|
Item {
|
||||||
id: approvalPrompt
|
id: approvalPrompt
|
||||||
|
|
||||||
anchors.top: layout.bottom
|
anchors.top: layout.bottom
|
||||||
anchors.topMargin: Tokens.spacing.small
|
anchors.topMargin: Tokens.spacing.small
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
implicitHeight: approvalLayout.implicitHeight + approvalLayout.anchors.margins * 2
|
||||||
visible: root.pendingApproval
|
visible: root.pendingApproval
|
||||||
|
|
||||||
rootParent: root.rootParent
|
CustomRect {
|
||||||
current: root.current
|
id: approvalBg
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
radius: Tokens.rounding.medium
|
||||||
|
color: Colors.palette.m3surface
|
||||||
|
border.width: 1
|
||||||
|
border.color: Colors.palette.m3outlineVariant
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
id: approvalLayout
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: Tokens.padding.medium
|
||||||
|
spacing: Tokens.spacing.small
|
||||||
|
|
||||||
|
CustomText {
|
||||||
|
id: requestHeader
|
||||||
|
text: qsTr("Tool call request")
|
||||||
|
font: Tokens.font.headline.medium
|
||||||
|
color: Colors.palette.m3onSurface
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: toolsBg
|
||||||
|
|
||||||
|
property bool open: false
|
||||||
|
property Item rootParent: root.rootParent
|
||||||
|
property int maxHeight: rootParent.height - Tokens.padding.medium * 2
|
||||||
|
property int openHeight: Math.min(toolsContent.item?.implicitHeight, maxHeight)
|
||||||
|
property int openWidth: toolsBg.rootParent.width - Tokens.padding.medium * 2
|
||||||
|
property real openHeightProg: openHeight / maxHeight
|
||||||
|
property int collapsedY: 0
|
||||||
|
|
||||||
|
implicitHeight: toolList.implicitHeight + toolList.anchors.margins * 2
|
||||||
|
z: open || dialogTransition.running ? 2 : 0
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
function reparentWrapper(): void {
|
||||||
|
const newParent = open ? toolsBg.rootParent : toolsBg;
|
||||||
|
const c = toolsWrapper.parent.mapToItem(newParent, toolsWrapper.x + toolsWrapper.width / 2, toolsWrapper.y + toolsWrapper.height / 2);
|
||||||
|
toolsBg.collapsedY = toolsWrapper.y;
|
||||||
|
toolsWrapper.parent = newParent;
|
||||||
|
toolsWrapper.x = c.x - toolsWrapper.width / 2;
|
||||||
|
toolsWrapper.y = c.y - toolsWrapper.height / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
onOpenChanged: {
|
||||||
|
if (open)
|
||||||
|
toolsBg.rootParent.interactive = false;
|
||||||
|
else
|
||||||
|
toolsBg.rootParent.interactive = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlobGroup {
|
||||||
|
id: blobGroup
|
||||||
|
|
||||||
|
color: toolsBg.open ? Colors.palette.m3surfaceContainerHighest : Colors.tPalette.m3primaryContainer
|
||||||
|
|
||||||
|
Behavior on color {
|
||||||
|
CAnim {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: backdrop
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
enabled: false
|
||||||
|
hoverEnabled: enabled
|
||||||
|
preventStealing: true
|
||||||
|
parent: toolsBg.open ? toolsBg.rootParent : toolsBg
|
||||||
|
|
||||||
|
onClicked: toolsBg.open = false
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: toolsWrapper
|
||||||
|
|
||||||
|
width: toolsBg.width
|
||||||
|
height: toolBox.implicitHeight
|
||||||
|
rotation: parent === toolsBg.rootParent ? 180 : 0
|
||||||
|
z: 1
|
||||||
|
|
||||||
|
states: State {
|
||||||
|
name: "open"
|
||||||
|
when: toolsBg.open
|
||||||
|
|
||||||
|
PropertyChanges {
|
||||||
|
backdrop.enabled: true
|
||||||
|
toolsBackground.bottomLeftRadius: Tokens.rounding.largeIncreased
|
||||||
|
toolsBackground.bottomRightRadius: Tokens.rounding.largeIncreased
|
||||||
|
toolsBackground.topRightRadius: Tokens.rounding.largeIncreased
|
||||||
|
toolsBackground.topLeftRadius: Tokens.rounding.largeIncreased
|
||||||
|
toolsContent.opacity: 1
|
||||||
|
toolsWrapper.height: toolsBg.openHeight
|
||||||
|
toolsWrapper.width: toolsBg.openWidth
|
||||||
|
toolsWrapper.x: (toolsBg.rootParent.width - toolsBg.openWidth) / 2
|
||||||
|
toolsWrapper.y: (confirmationRow.implicitHeight + Tokens.spacing.small + Tokens.padding.medium) * (1 - toolsBg.openHeightProg) + Tokens.padding.medium
|
||||||
|
elevation.opacity: 1
|
||||||
|
toolBox.opacity: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
transitions: Transition {
|
||||||
|
id: dialogTransition
|
||||||
|
|
||||||
|
SequentialAnimation {
|
||||||
|
ScriptAction {
|
||||||
|
script: toolsBg.reparentWrapper()
|
||||||
|
}
|
||||||
|
|
||||||
|
Anim {
|
||||||
|
properties: "x,y"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyAction {
|
||||||
|
property: "enabled"
|
||||||
|
}
|
||||||
|
|
||||||
|
Anim {
|
||||||
|
properties: "opacity,topLeftRadius,topRightRadius,bottomLeftRadius,bottomRightRadius"
|
||||||
|
type: Anim.DefaultEffects
|
||||||
|
}
|
||||||
|
|
||||||
|
Anim {
|
||||||
|
properties: "width,height"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Elevation {
|
||||||
|
id: elevation
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
bottomLeftRadius: toolsBackground.bottomLeftRadius
|
||||||
|
bottomRightRadius: toolsBackground.bottomRightRadius
|
||||||
|
level: 4
|
||||||
|
opacity: 0
|
||||||
|
radius: toolsBackground.radius
|
||||||
|
|
||||||
|
transform: Matrix4x4 {
|
||||||
|
matrix: toolsBackground.deformMatrix
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BlobRect {
|
||||||
|
id: toolsBackground
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
bottomLeftRadius: toolsBg.open ? Tokens.rounding.largeIncreased : Tokens.rounding.small
|
||||||
|
bottomRightRadius: toolsBg.open ? Tokens.rounding.largeIncreased : Tokens.rounding.small
|
||||||
|
topRightRadius: toolsBg.open ? Tokens.rounding.largeIncreased : Tokens.rounding.small
|
||||||
|
topLeftRadius: toolsBg.open ? Tokens.rounding.largeIncreased : Tokens.rounding.small
|
||||||
|
deformScale: 0
|
||||||
|
group: blobGroup
|
||||||
|
opacity: blobGroup.color.a * (root.enabled ? 1 : 0.5)
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomRect {
|
||||||
|
id: toolBox
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
height: Math.min(implicitHeight, parent.height)
|
||||||
|
implicitHeight: toolList.implicitHeight + Tokens.padding.medium * 2
|
||||||
|
radius: Tokens.rounding.small
|
||||||
|
|
||||||
|
StateLayer {
|
||||||
|
onClicked: {
|
||||||
|
toolsBg.open = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
id: toolList
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
anchors.margins: Tokens.padding.medium
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
id: repeater
|
||||||
|
|
||||||
|
model: root.current.pendingToolCalls?.slice(0, 4) ?? []
|
||||||
|
|
||||||
|
delegate: RowLayout {
|
||||||
|
id: toolText
|
||||||
|
|
||||||
|
required property LlmSegment modelData
|
||||||
|
required property int index
|
||||||
|
|
||||||
|
spacing: Tokens.spacing.medium
|
||||||
|
|
||||||
|
function toolTarget(seg: LlmSegment): string {
|
||||||
|
var a = null;
|
||||||
|
try {
|
||||||
|
a = JSON.parse(seg.arguments);
|
||||||
|
} catch (e) {}
|
||||||
|
if (a && typeof a === "object") {
|
||||||
|
const v = a.url ?? a.path;
|
||||||
|
if (v !== undefined && v !== null)
|
||||||
|
return String(v);
|
||||||
|
}
|
||||||
|
return String(seg.arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialIcon {
|
||||||
|
color: Colors.palette.m3onPrimaryContainer
|
||||||
|
text: toolText.modelData.name === "webfetch" ? "web" : "text_snippet"
|
||||||
|
fill: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomText {
|
||||||
|
color: Colors.palette.m3onPrimaryContainer
|
||||||
|
text: qsTr("%1").arg(toolText.modelData.name)
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialIcon {
|
||||||
|
color: Colors.palette.m3onPrimaryContainer
|
||||||
|
text: "arrow_right_alt"
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomText {
|
||||||
|
color: Colors.palette.m3onPrimaryContainer
|
||||||
|
text: qsTr("%1").arg(toolText.toolTarget(toolText.modelData))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomText {
|
||||||
|
color: Colors.palette.m3onPrimaryContainer
|
||||||
|
text: qsTr("And %1 more").arg(root.current.pendingToolCalls.slice(4).length)
|
||||||
|
visible: repeater.count < root.current.pendingToolCalls.length
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Loader {
|
||||||
|
id: toolsContent
|
||||||
|
|
||||||
|
active: opacity > 0
|
||||||
|
anchors.fill: parent
|
||||||
|
asynchronous: false
|
||||||
|
opacity: 0
|
||||||
|
|
||||||
|
sourceComponent: MouseArea {
|
||||||
|
onWheel: event => event.accepted = true
|
||||||
|
preventStealing: true
|
||||||
|
implicitHeight: innerLayout.contentHeight + innerLayout.anchors.margins * 2
|
||||||
|
|
||||||
|
VerticalFadeListView {
|
||||||
|
id: innerLayout
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: Tokens.padding.small
|
||||||
|
cacheBuffer: height * 10
|
||||||
|
fadeAmount: 0.1
|
||||||
|
fadeEnabled: interactive
|
||||||
|
spacing: 0
|
||||||
|
clip: true
|
||||||
|
interactive: contentHeight > toolsBg.maxHeight
|
||||||
|
|
||||||
|
model: root.current.pendingToolCalls ?? []
|
||||||
|
|
||||||
|
delegate: Item {
|
||||||
|
id: toolCall
|
||||||
|
|
||||||
|
required property LlmSegment modelData
|
||||||
|
property bool expanded: false
|
||||||
|
|
||||||
|
implicitWidth: CustomListView.view.width
|
||||||
|
implicitHeight: collapsedRow.implicitHeight + collapsedRow.anchors.margins + (expanded ? expandedTool.implicitHeight + expandedTool.anchors.margins + expandedTool.anchors.topMargin : collapsedRow.anchors.margins)
|
||||||
|
|
||||||
|
function toolTarget(seg: LlmSegment): string {
|
||||||
|
var a = null;
|
||||||
|
try {
|
||||||
|
a = JSON.parse(seg.arguments);
|
||||||
|
} catch (e) {}
|
||||||
|
if (a && typeof a === "object") {
|
||||||
|
const v = a.url ?? a.path;
|
||||||
|
if (v !== undefined && v !== null)
|
||||||
|
return String(v);
|
||||||
|
}
|
||||||
|
return String(seg.arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
Behavior on implicitHeight {
|
||||||
|
Anim {}
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: collapsedRow
|
||||||
|
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.margins: Tokens.padding.medium
|
||||||
|
|
||||||
|
IconButton {
|
||||||
|
id: toolExpandBtn
|
||||||
|
|
||||||
|
font: Tokens.font.icon.medium
|
||||||
|
icon: "keyboard_arrow_down"
|
||||||
|
inactiveOnColor: hovered ? Colors.palette.m3onSurface : Colors.palette.m3outline
|
||||||
|
rotation: toolCall.expanded ? 180 : 0
|
||||||
|
type: IconButton.Text
|
||||||
|
|
||||||
|
Behavior on rotation {
|
||||||
|
Anim {}
|
||||||
|
}
|
||||||
|
|
||||||
|
onClicked: toolCall.expanded = !toolCall.expanded
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomText {
|
||||||
|
id: preview
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
text: toolCall.modelData.name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomClippingRect {
|
||||||
|
id: expandedTool
|
||||||
|
|
||||||
|
anchors.top: collapsedRow.bottom
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.margins: Tokens.padding.medium
|
||||||
|
anchors.topMargin: Tokens.spacing.medium
|
||||||
|
|
||||||
|
implicitHeight: fullToolCall.implicitHeight + fullToolCall.anchors.margins * 2
|
||||||
|
radius: Tokens.rounding.medium
|
||||||
|
color: Colors.palette.m3surfaceContainerLow
|
||||||
|
|
||||||
|
CustomText {
|
||||||
|
id: fullToolCall
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: Tokens.padding.medium
|
||||||
|
|
||||||
|
text: toolCall.toolTarget(toolCall.modelData)
|
||||||
|
wrapMode: CustomText.WrapAtWordBoundaryOrAnywhere
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ButtonRow {
|
||||||
|
id: confirmationRow
|
||||||
|
Layout.alignment: Qt.AlignRight
|
||||||
|
spacing: Tokens.spacing.medium
|
||||||
|
|
||||||
|
IconTextButton {
|
||||||
|
icon: "check_circle"
|
||||||
|
text: qsTr("Allow")
|
||||||
|
horizontalPadding: Tokens.padding.large
|
||||||
|
verticalPadding: Tokens.padding.small
|
||||||
|
isRound: true
|
||||||
|
shapeMorph: true
|
||||||
|
onClicked: root.current.approveTools()
|
||||||
|
}
|
||||||
|
|
||||||
|
IconTextButton {
|
||||||
|
icon: "cancel"
|
||||||
|
text: qsTr("Deny")
|
||||||
|
isRound: true
|
||||||
|
shapeMorph: true
|
||||||
|
inactiveColor: Colors.palette.m3error
|
||||||
|
inactiveOnColor: Colors.palette.m3onError
|
||||||
|
horizontalPadding: Tokens.padding.large
|
||||||
|
verticalPadding: Tokens.padding.small
|
||||||
|
onClicked: root.current.denyTools()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomClippingRect {
|
CustomClippingRect {
|
||||||
@@ -154,7 +532,7 @@ Item {
|
|||||||
delegate: Item {
|
delegate: Item {
|
||||||
id: segment
|
id: segment
|
||||||
|
|
||||||
required property var modelData
|
required property LlmSegment modelData
|
||||||
required property int index
|
required property int index
|
||||||
|
|
||||||
implicitWidth: ListView.view.width
|
implicitWidth: ListView.view.width
|
||||||
@@ -181,7 +559,7 @@ Item {
|
|||||||
CustomText {
|
CustomText {
|
||||||
id: content
|
id: content
|
||||||
|
|
||||||
function toolTarget(seg: var): string {
|
function toolTarget(seg: LlmSegment): string {
|
||||||
var a = null;
|
var a = null;
|
||||||
try {
|
try {
|
||||||
a = JSON.parse(seg.arguments);
|
a = JSON.parse(seg.arguments);
|
||||||
@@ -194,29 +572,29 @@ Item {
|
|||||||
return String(seg.arguments);
|
return String(seg.arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
function prettyTool(seg: var): string {
|
function prettyTool(seg: LlmSegment): string {
|
||||||
if (seg.name === "webfetch") {
|
if (seg.name === "webfetch") {
|
||||||
switch (seg.status) {
|
switch (seg.status) {
|
||||||
case LlmToolCall.Status.Running:
|
case LlmSegment.Status.Running:
|
||||||
return qsTr("Fetching");
|
return qsTr("Fetching");
|
||||||
case LlmToolCall.Status.Pending:
|
case LlmSegment.Status.Pending:
|
||||||
return qsTr("Pending fetch");
|
return qsTr("Pending fetch");
|
||||||
case LlmToolCall.Status.Success:
|
case LlmSegment.Status.Success:
|
||||||
return qsTr("Fetched");
|
return qsTr("Fetched");
|
||||||
case LlmToolCall.Status.Error:
|
case LlmSegment.Status.Error:
|
||||||
return qsTr("Failed to fetch");
|
return qsTr("Failed to fetch");
|
||||||
default:
|
default:
|
||||||
return qsTr("Fetched website");
|
return qsTr("Fetched website");
|
||||||
}
|
}
|
||||||
} else if (seg.name === "readfile") {
|
} else if (seg.name === "readfile") {
|
||||||
switch (seg.status) {
|
switch (seg.status) {
|
||||||
case LlmToolCall.Status.Running:
|
case LlmSegment.Status.Running:
|
||||||
return qsTr("Reading");
|
return qsTr("Reading");
|
||||||
case LlmToolCall.Status.Pending:
|
case LlmSegment.Status.Pending:
|
||||||
return qsTr("Pending read");
|
return qsTr("Pending read");
|
||||||
case LlmToolCall.Status.Success:
|
case LlmSegment.Status.Success:
|
||||||
return qsTr("Read");
|
return qsTr("Read");
|
||||||
case LlmToolCall.Status.Error:
|
case LlmSegment.Status.Error:
|
||||||
return qsTr("Failed to read");
|
return qsTr("Failed to read");
|
||||||
default:
|
default:
|
||||||
return qsTr("Read file");
|
return qsTr("Read file");
|
||||||
@@ -230,7 +608,6 @@ Item {
|
|||||||
anchors.topMargin: Tokens.spacing.small
|
anchors.topMargin: Tokens.spacing.small
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
color: Colors.palette.m3outline
|
color: Colors.palette.m3outline
|
||||||
font: Tokens.font.body.small
|
|
||||||
wrapMode: CustomText.WrapAtWordBoundaryOrAnywhere
|
wrapMode: CustomText.WrapAtWordBoundaryOrAnywhere
|
||||||
text: segment.modelData.type === LlmSegment.Type.Reasoning ? segment.modelData.text : qsTr("%1 %2").arg(content.prettyTool(segment.modelData)).arg(content.toolTarget(segment.modelData))
|
text: segment.modelData.type === LlmSegment.Type.Reasoning ? segment.modelData.text : qsTr("%1 %2").arg(content.prettyTool(segment.modelData)).arg(content.toolTarget(segment.modelData))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ pragma Singleton
|
|||||||
import Quickshell
|
import Quickshell
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import ZShell.Config
|
import ZShell.Config
|
||||||
import qs.Helpers
|
import qs.Services
|
||||||
import qs.Services
|
import qs.Services
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
|
|||||||
@@ -65,7 +65,9 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
model: LlmClient.chats
|
model: ScriptModel {
|
||||||
|
values: Chat.chats.values
|
||||||
|
}
|
||||||
|
|
||||||
onLoadChatRequest: (chat, index) => {
|
onLoadChatRequest: (chat, index) => {
|
||||||
ChatState.currentIdx = index;
|
ChatState.currentIdx = index;
|
||||||
@@ -73,13 +75,17 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onDeleteChatRequest: chat => {
|
onDeleteChatRequest: chat => {
|
||||||
const wasCurrent = chat === ChatState.chatSession;
|
if (chat === ChatState.chatSession) {
|
||||||
LlmClient.chats.remove(chat);
|
ChatState.chatSession = null;
|
||||||
|
ChatState.currentIdx = -1;
|
||||||
if (wasCurrent)
|
}
|
||||||
ChatState.openDraft();
|
Chat.chats.remove(chat);
|
||||||
|
}
|
||||||
|
onNewChatRequest: {
|
||||||
|
const data = Chat.chats.insert();
|
||||||
|
ChatState.currentIdx = 0;
|
||||||
|
ChatState.chatSession = data;
|
||||||
}
|
}
|
||||||
onNewChatRequest: ChatState.openDraft()
|
|
||||||
|
|
||||||
onRequestExpand: {
|
onRequestExpand: {
|
||||||
ChatState.narrowSidebarExpanded = true;
|
ChatState.narrowSidebarExpanded = true;
|
||||||
@@ -120,8 +126,9 @@ Item {
|
|||||||
z: 0
|
z: 0
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.margins: Tokens.padding.medium
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
implicitWidth: root.width - leftMargin - sidebar.anchors.margins - Tokens.spacing.medium * 2
|
implicitWidth: root.width - leftMargin - sidebar.anchors.margins - Tokens.spacing.medium * 2 - anchors.margins * 2
|
||||||
|
|
||||||
states: State {
|
states: State {
|
||||||
name: "wide"
|
name: "wide"
|
||||||
@@ -144,13 +151,40 @@ Item {
|
|||||||
ChatHost {
|
ChatHost {
|
||||||
id: convHost
|
id: convHost
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.top: parent.top
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
implicitWidth: Math.max(Math.min(parent.width, 800), Config.sidebar.sizes.width)
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
onLoadingChanged: if (!loading)
|
onLoadingChanged: if (!loading)
|
||||||
root.chatOpen = true
|
root.chatOpen = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
id: noChatLayout
|
||||||
|
anchors.centerIn: parent
|
||||||
|
opacity: ChatState.chatSession ? 0 : 1
|
||||||
|
visible: opacity > 0
|
||||||
|
|
||||||
|
Behavior on opacity {
|
||||||
|
Anim {}
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialIcon {
|
||||||
|
Layout.alignment: Qt.AlignCenter
|
||||||
|
text: "chat_bubble_off"
|
||||||
|
fontStyle: Tokens.font.icon.extraLarge
|
||||||
|
color: Colors.tPalette.m3onSurfaceVariant
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomText {
|
||||||
|
Layout.alignment: Qt.AlignCenter
|
||||||
|
text: qsTr("Start or create a chat")
|
||||||
|
color: Colors.tPalette.m3onSurfaceVariant
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: dimArea
|
id: dimArea
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@@ -162,10 +196,8 @@ Item {
|
|||||||
const x = mouseX;
|
const x = mouseX;
|
||||||
const margin = root.width - contentArea.implicitWidth - contentArea.anchors.margins * 2;
|
const margin = root.width - contentArea.implicitWidth - contentArea.anchors.margins * 2;
|
||||||
|
|
||||||
if (x > invertedRect.borderLeft - margin) {
|
if (x > invertedRect.borderLeft - margin)
|
||||||
ChatState.narrowSidebarExpanded = false;
|
ChatState.narrowSidebarExpanded = false;
|
||||||
ChatState.fabExpanded = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HoverHandler {
|
HoverHandler {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
pragma ComponentBehavior: Bound
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import ZShell.Config
|
import ZShell.Config
|
||||||
import ZShell.Llm
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import qs.Components
|
import qs.Components
|
||||||
@@ -36,10 +35,10 @@ Item {
|
|||||||
visible: height > 0
|
visible: height > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
CustomClippingRect {
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
clip: true
|
radius: Tokens.rounding.small
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: pages
|
id: pages
|
||||||
@@ -59,7 +58,6 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CustomRect {
|
CustomRect {
|
||||||
id: bg
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: Colors.tPalette.m3surfaceContainerLow
|
color: Colors.tPalette.m3surfaceContainerLow
|
||||||
radius: Tokens.rounding.small
|
radius: Tokens.rounding.small
|
||||||
@@ -98,63 +96,11 @@ Item {
|
|||||||
CustomRect {
|
CustomRect {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: Colors.tPalette.m3surfaceContainerLow
|
color: Colors.tPalette.m3surfaceContainerLow
|
||||||
radius: Tokens.rounding.large
|
radius: Tokens.rounding.small
|
||||||
|
|
||||||
ChatPanel {
|
ChatPanel {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
}
|
}
|
||||||
|
|
||||||
GeminiGlow {
|
|
||||||
innerGlow: 50
|
|
||||||
z: 5
|
|
||||||
opacity: LlmClient.busy ? 1.0 : 0.0
|
|
||||||
glowSize: 0
|
|
||||||
visible: opacity > 0 && !ChatState.isWindow
|
|
||||||
|
|
||||||
layer.enabled: true
|
|
||||||
layer.effect: OpacityMask {
|
|
||||||
maskSource: fadeMask
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on opacity {
|
|
||||||
Anim {
|
|
||||||
type: Anim.DefaultEffects
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: fadeMask
|
|
||||||
|
|
||||||
readonly property real fadeStartPos: {
|
|
||||||
const h = Math.max(1, height);
|
|
||||||
const nh = (h - h / 3) / h;
|
|
||||||
return nh;
|
|
||||||
}
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
layer.enabled: true
|
|
||||||
visible: false
|
|
||||||
|
|
||||||
gradient: Gradient {
|
|
||||||
orientation: Gradient.Vertical
|
|
||||||
|
|
||||||
GradientStop {
|
|
||||||
color: Qt.rgba(0, 0, 0, 0)
|
|
||||||
position: 0
|
|
||||||
}
|
|
||||||
|
|
||||||
GradientStop {
|
|
||||||
color: Qt.rgba(0, 0, 0, 0)
|
|
||||||
position: fadeMask.fadeStartPos
|
|
||||||
}
|
|
||||||
|
|
||||||
GradientStop {
|
|
||||||
color: Qt.rgba(0, 0, 0, 1.0)
|
|
||||||
position: 1.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onCurrentIndexChanged: root.state.currentTab = currentIndex
|
onCurrentIndexChanged: root.screenState.sidebarTab = currentIndex
|
||||||
|
|
||||||
Tab {
|
Tab {
|
||||||
iconName: "notifications"
|
iconName: "notifications"
|
||||||
@@ -118,7 +118,7 @@ Item {
|
|||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
color: tab.current ? Colors.palette.m3primary : Colors.palette.m3onSurfaceVariant
|
color: tab.current ? Colors.palette.m3primary : Colors.palette.m3onSurfaceVariant
|
||||||
fill: tab.current ? 1 : 0
|
fill: tab.current ? 1 : 0
|
||||||
fontStyle: Tokens.font.icon.large
|
fontStyle: Tokens.font.icon.medium
|
||||||
text: tab.iconName
|
text: tab.iconName
|
||||||
|
|
||||||
Behavior on fill {
|
Behavior on fill {
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ CustomRect {
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
required property ScreenState screenState
|
|
||||||
readonly property int splitIndex: Math.ceil(quickToggles.length / 2)
|
readonly property int splitIndex: Math.ceil(quickToggles.length / 2)
|
||||||
|
required property ScreenState screenState
|
||||||
|
|
||||||
color: Colors.tPalette.m3surfaceContainer
|
color: Colors.tPalette.m3surfaceContainer
|
||||||
implicitHeight: layout.implicitHeight + Tokens.padding.extraLargeIncreased
|
implicitHeight: layout.implicitHeight + Tokens.padding.extraLargeIncreased
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import Quickshell
|
import Quickshell
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import ZShell.Config
|
|
||||||
import qs.Components
|
import qs.Components
|
||||||
import qs.Modules.Notifications.Sidebar.Utils.Cards
|
import qs.Modules.Notifications.Sidebar.Utils.Cards
|
||||||
|
import ZShell.Config
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ Item {
|
|||||||
id: root
|
id: root
|
||||||
|
|
||||||
property real offsetScale: shouldBeActive ? 0 : 1
|
property real offsetScale: shouldBeActive ? 0 : 1
|
||||||
required property ScreenState screenState
|
|
||||||
readonly property bool shouldBeActive: screenState.sidebar && !sidebar.chatActive
|
readonly property bool shouldBeActive: screenState.sidebar && !sidebar.chatActive
|
||||||
required property Item sidebar
|
required property Item sidebar
|
||||||
|
required property ScreenState screenState
|
||||||
|
|
||||||
anchors.bottomMargin: (-implicitHeight - 5) * offsetScale
|
anchors.bottomMargin: (-implicitHeight - 5) * offsetScale
|
||||||
implicitHeight: content.implicitHeight + Tokens.padding.small * 2
|
implicitHeight: content.implicitHeight + Tokens.padding.small * 2
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ import QtQuick
|
|||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
readonly property bool chatActive: screenState.sidebarTab === 1
|
|
||||||
property real offsetScale: shouldBeActive ? 0 : 1
|
property real offsetScale: shouldBeActive ? 0 : 1
|
||||||
required property var panels
|
required property var panels
|
||||||
required property ScreenState screenState
|
|
||||||
readonly property bool shouldBeActive: root.screenState.sidebar && Config.sidebar.enabled
|
readonly property bool shouldBeActive: root.screenState.sidebar && Config.sidebar.enabled
|
||||||
|
readonly property bool chatActive: screenState.sidebarTab === 1
|
||||||
|
required property ScreenState screenState
|
||||||
|
|
||||||
anchors.rightMargin: (-implicitWidth - 5) * offsetScale
|
anchors.rightMargin: (-implicitWidth - 5) * offsetScale
|
||||||
implicitWidth: Config.sidebar.sizes.width
|
implicitWidth: Config.sidebar.sizes.width
|
||||||
@@ -30,9 +30,9 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: LlmClient
|
target: Chat
|
||||||
|
|
||||||
function onGenerationFailed(session: ChatSession, message: string): void {
|
function onErrorOccurred(message: string): void {
|
||||||
if (root.shouldBeActive && root.chatActive)
|
if (root.shouldBeActive && root.chatActive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -51,8 +51,7 @@ CustomRect {
|
|||||||
value: Memory.percentage
|
value: Memory.percentage
|
||||||
|
|
||||||
Behavior on clampedVal {
|
Behavior on clampedVal {
|
||||||
Anim {
|
Anim {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
|
|||||||
@@ -121,6 +121,6 @@ CustomRect {
|
|||||||
|
|
||||||
activeIcon: "storage"
|
activeIcon: "storage"
|
||||||
icon: modelData === Storage.primaryDisk ? "check" : ""
|
icon: modelData === Storage.primaryDisk ? "check" : ""
|
||||||
text: modelData.name
|
text: modelData.mount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
import Quickshell
|
|
||||||
import QtQuick
|
|
||||||
import qs.Helpers
|
|
||||||
|
|
||||||
Scope {
|
|
||||||
Component.onCompleted: {
|
|
||||||
Wallpapers;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,7 +17,7 @@ CustomRect {
|
|||||||
bottomLeftRadius: last ? Tokens.rounding.largeIncreased : Tokens.rounding.extraSmall
|
bottomLeftRadius: last ? Tokens.rounding.largeIncreased : Tokens.rounding.extraSmall
|
||||||
bottomRightRadius: last ? Tokens.rounding.largeIncreased : Tokens.rounding.extraSmall
|
bottomRightRadius: last ? Tokens.rounding.largeIncreased : Tokens.rounding.extraSmall
|
||||||
color: Colors.tPalette.m3surfaceContainer
|
color: Colors.tPalette.m3surfaceContainer
|
||||||
opacity: enabled && (parent?.enabled ?? false) ? 1 : 0.5
|
opacity: enabled && parent.enabled ? 1 : 0.5
|
||||||
topLeftRadius: first ? Tokens.rounding.largeIncreased : Tokens.rounding.extraSmall
|
topLeftRadius: first ? Tokens.rounding.largeIncreased : Tokens.rounding.extraSmall
|
||||||
topRightRadius: first ? Tokens.rounding.largeIncreased : Tokens.rounding.extraSmall
|
topRightRadius: first ? Tokens.rounding.largeIncreased : Tokens.rounding.extraSmall
|
||||||
|
|
||||||
|
|||||||
@@ -10,25 +10,24 @@ import qs.Services
|
|||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property bool acceptAllowed: true
|
||||||
required property string acceptLabel
|
required property string acceptLabel
|
||||||
required property Component content
|
required property Component content
|
||||||
required property string header
|
required property string header
|
||||||
required property string label
|
|
||||||
required property Item rootParent
|
|
||||||
required property string settingAnchor
|
|
||||||
|
|
||||||
property bool acceptAllowed: true
|
|
||||||
property bool first: false
|
|
||||||
property int horizontalContentMargin
|
property int horizontalContentMargin
|
||||||
property string icon
|
property string icon
|
||||||
|
required property string label
|
||||||
property alias iconLabel: openButton.iconLabel
|
property alias iconLabel: openButton.iconLabel
|
||||||
|
property alias rowButton: openButton
|
||||||
property string subtext: ""
|
property string subtext: ""
|
||||||
property bool last: false
|
|
||||||
property bool open
|
property bool open
|
||||||
property real openHeight: Math.min(rootParent.height * 0.8, 600)
|
property real openHeight: Math.min(rootParent.height * 0.8, 600)
|
||||||
property real openWidth: Math.min(rootParent.width * 0.8, 400)
|
property real openWidth: Math.min(rootParent.width * 0.8, 400)
|
||||||
property alias rowButton: openButton
|
required property Item rootParent
|
||||||
property bool separateContent
|
property bool separateContent
|
||||||
|
required property string settingAnchor
|
||||||
|
property bool first: false
|
||||||
|
property bool last: false
|
||||||
|
|
||||||
signal accepted
|
signal accepted
|
||||||
signal cancelled
|
signal cancelled
|
||||||
@@ -61,8 +60,8 @@ Item {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
enabled: false
|
enabled: false
|
||||||
hoverEnabled: enabled
|
hoverEnabled: enabled
|
||||||
parent: root.open ? root.rootParent : root
|
|
||||||
preventStealing: true
|
preventStealing: true
|
||||||
|
parent: root.open ? root.rootParent : root
|
||||||
|
|
||||||
onClicked: root.open = false
|
onClicked: root.open = false
|
||||||
}
|
}
|
||||||
@@ -82,8 +81,8 @@ Item {
|
|||||||
backdrop.enabled: true
|
backdrop.enabled: true
|
||||||
dialogBg.bottomLeftRadius: Tokens.rounding.largeIncreased
|
dialogBg.bottomLeftRadius: Tokens.rounding.largeIncreased
|
||||||
dialogBg.bottomRightRadius: Tokens.rounding.largeIncreased
|
dialogBg.bottomRightRadius: Tokens.rounding.largeIncreased
|
||||||
dialogBg.topLeftRadius: Tokens.rounding.largeIncreased
|
|
||||||
dialogBg.topRightRadius: Tokens.rounding.largeIncreased
|
dialogBg.topRightRadius: Tokens.rounding.largeIncreased
|
||||||
|
dialogBg.topLeftRadius: Tokens.rounding.largeIncreased
|
||||||
dialogContent.opacity: 1
|
dialogContent.opacity: 1
|
||||||
dialogWrapper.height: root.openHeight
|
dialogWrapper.height: root.openHeight
|
||||||
dialogWrapper.width: root.openWidth
|
dialogWrapper.width: root.openWidth
|
||||||
@@ -141,11 +140,11 @@ Item {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
bottomLeftRadius: root.last ? Tokens.rounding.largeIncreased : Tokens.rounding.extraSmall
|
bottomLeftRadius: root.last ? Tokens.rounding.largeIncreased : Tokens.rounding.extraSmall
|
||||||
bottomRightRadius: root.last ? Tokens.rounding.largeIncreased : Tokens.rounding.extraSmall
|
bottomRightRadius: root.last ? Tokens.rounding.largeIncreased : Tokens.rounding.extraSmall
|
||||||
|
topRightRadius: root.first ? Tokens.rounding.largeIncreased : Tokens.rounding.extraSmall
|
||||||
|
topLeftRadius: root.first ? Tokens.rounding.largeIncreased : Tokens.rounding.extraSmall
|
||||||
deformScale: 0
|
deformScale: 0
|
||||||
group: blobGroup
|
group: blobGroup
|
||||||
opacity: blobGroup.color.a * (root.enabled ? 1 : 0.5)
|
opacity: blobGroup.color.a * (root.enabled ? 1 : 0.5)
|
||||||
topLeftRadius: root.first ? Tokens.rounding.largeIncreased : Tokens.rounding.extraSmall
|
|
||||||
topRightRadius: root.first ? Tokens.rounding.largeIncreased : Tokens.rounding.extraSmall
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RowButton {
|
RowButton {
|
||||||
@@ -154,11 +153,11 @@ Item {
|
|||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
first: root.first
|
|
||||||
height: Math.min(implicitHeight, parent.height)
|
height: Math.min(implicitHeight, parent.height)
|
||||||
icon: root.icon
|
icon: root.icon
|
||||||
last: root.last
|
|
||||||
subtext: root.subtext
|
subtext: root.subtext
|
||||||
|
last: root.last
|
||||||
|
first: root.first
|
||||||
text: root.label
|
text: root.label
|
||||||
|
|
||||||
transform: Matrix4x4 {
|
transform: Matrix4x4 {
|
||||||
@@ -177,9 +176,8 @@ Item {
|
|||||||
opacity: 0
|
opacity: 0
|
||||||
|
|
||||||
sourceComponent: MouseArea {
|
sourceComponent: MouseArea {
|
||||||
preventStealing: true
|
|
||||||
|
|
||||||
onWheel: event => event.accepted = true
|
onWheel: event => event.accepted = true
|
||||||
|
preventStealing: true
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.bottomMargin: Tokens.padding.largeIncreased
|
anchors.bottomMargin: Tokens.padding.largeIncreased
|
||||||
@@ -229,10 +227,10 @@ Item {
|
|||||||
TextButton {
|
TextButton {
|
||||||
horizontalPadding: Tokens.padding.largeIncreased
|
horizontalPadding: Tokens.padding.largeIncreased
|
||||||
isRound: true
|
isRound: true
|
||||||
stateLayer.preventStealing: true
|
|
||||||
text: qsTr("Cancel")
|
text: qsTr("Cancel")
|
||||||
type: TextButton.Text
|
type: TextButton.Text
|
||||||
verticalPadding: Tokens.padding.small
|
verticalPadding: Tokens.padding.small
|
||||||
|
stateLayer.preventStealing: true
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.cancelled();
|
root.cancelled();
|
||||||
@@ -244,9 +242,9 @@ Item {
|
|||||||
enabled: root.acceptAllowed
|
enabled: root.acceptAllowed
|
||||||
horizontalPadding: Tokens.padding.largeIncreased
|
horizontalPadding: Tokens.padding.largeIncreased
|
||||||
isRound: true
|
isRound: true
|
||||||
stateLayer.preventStealing: true
|
|
||||||
text: root.acceptLabel
|
text: root.acceptLabel
|
||||||
type: TextButton.Text
|
type: TextButton.Text
|
||||||
|
stateLayer.preventStealing: true
|
||||||
verticalPadding: Tokens.padding.small
|
verticalPadding: Tokens.padding.small
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
|||||||
@@ -9,9 +9,8 @@ DialogRowButton {
|
|||||||
id: root
|
id: root
|
||||||
|
|
||||||
required property var model
|
required property var model
|
||||||
|
|
||||||
property var initialSelect
|
|
||||||
property var selectedItem
|
property var selectedItem
|
||||||
|
property var initialSelect
|
||||||
|
|
||||||
function keyFor(item: var): string {
|
function keyFor(item: var): string {
|
||||||
return item.id;
|
return item.id;
|
||||||
|
|||||||
@@ -178,9 +178,6 @@ Item {
|
|||||||
sourceComponent: MouseArea {
|
sourceComponent: MouseArea {
|
||||||
onWheel: event => event.accepted = true
|
onWheel: event => event.accepted = true
|
||||||
preventStealing: true
|
preventStealing: true
|
||||||
acceptedButtons: Qt.NoButton
|
|
||||||
cursorShape: undefined
|
|
||||||
enabled: dialogContent.opacity > 0
|
|
||||||
clip: true
|
clip: true
|
||||||
implicitWidth: innerLayout.implicitWidth + innerLayout.anchors.margins * 2
|
implicitWidth: innerLayout.implicitWidth + innerLayout.anchors.margins * 2
|
||||||
implicitHeight: innerLayout.implicitHeight + innerLayout.anchors.margins + innerLayout.anchors.bottomMargin
|
implicitHeight: innerLayout.implicitHeight + innerLayout.anchors.margins + innerLayout.anchors.bottomMargin
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ ConnectedRect {
|
|||||||
property string iconText: "open_in_new"
|
property string iconText: "open_in_new"
|
||||||
property int verticalPadding: Tokens.padding.small
|
property int verticalPadding: Tokens.padding.small
|
||||||
|
|
||||||
signal clicked
|
signal clicked(event: MouseEvent)
|
||||||
signal toggled(checked: bool)
|
signal toggled(checked: bool)
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
@@ -56,7 +56,7 @@ ConnectedRect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
StateLayer {
|
StateLayer {
|
||||||
onClicked: root.clicked()
|
onClicked: e => root.clicked(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomSwitch {
|
CustomSwitch {
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ import qs.Services
|
|||||||
Item {
|
Item {
|
||||||
id: wrapper
|
id: wrapper
|
||||||
|
|
||||||
property int buttonRowHeight: Tokens.padding.large * 3
|
readonly property var currentScreen: screens.length > selectedScreenIndex ? screens[selectedScreenIndex] : null
|
||||||
|
readonly property real maxZoom: 5.0
|
||||||
|
|
||||||
readonly property bool changesMade: {
|
readonly property bool changesMade: {
|
||||||
cropRevision;
|
cropRevision;
|
||||||
|
|
||||||
@@ -25,13 +27,21 @@ Item {
|
|||||||
|
|
||||||
return Math.abs(r.x - t.x) > 0.5 || Math.abs(r.y - t.y) > 0.5 || Math.abs(r.zoom - t.zoom) > 0.001;
|
return Math.abs(r.x - t.x) > 0.5 || Math.abs(r.y - t.y) > 0.5 || Math.abs(r.zoom - t.zoom) > 0.001;
|
||||||
}
|
}
|
||||||
|
|
||||||
property int cropRevision: 0
|
property int cropRevision: 0
|
||||||
readonly property var currentScreen: screens.length > selectedScreenIndex ? screens[selectedScreenIndex] : null
|
property int buttonRowHeight: Tokens.padding.large * 3
|
||||||
readonly property real maxZoom: 5.0
|
|
||||||
property var screens: []
|
property var screens: []
|
||||||
property int selectedScreenIndex: 0
|
property int selectedScreenIndex: 0
|
||||||
property bool shouldBeActive: true
|
property bool shouldBeActive: true
|
||||||
|
|
||||||
|
function zoomFromSlider(t: real): real {
|
||||||
|
return 1 / (1 - t * (1 - 1 / maxZoom));
|
||||||
|
}
|
||||||
|
|
||||||
|
function sliderFromZoom(zoom: real): real {
|
||||||
|
return (1 - 1 / zoom) / (1 - 1 / maxZoom);
|
||||||
|
}
|
||||||
|
|
||||||
function applyCrop(): void {
|
function applyCrop(): void {
|
||||||
if (!cropRectLoader.item || !currentScreen)
|
if (!cropRectLoader.item || !currentScreen)
|
||||||
return;
|
return;
|
||||||
@@ -62,10 +72,6 @@ Item {
|
|||||||
Qt.callLater(syncCropToScreen);
|
Qt.callLater(syncCropToScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sliderFromZoom(zoom: real): real {
|
|
||||||
return (1 - 1 / zoom) / (1 - 1 / maxZoom);
|
|
||||||
}
|
|
||||||
|
|
||||||
function syncCropToScreen(): void {
|
function syncCropToScreen(): void {
|
||||||
if (cropRectLoader.item)
|
if (cropRectLoader.item)
|
||||||
cropRectLoader.item.restoreFromData();
|
cropRectLoader.item.restoreFromData();
|
||||||
@@ -88,10 +94,6 @@ Item {
|
|||||||
cropRect.clampToBounds();
|
cropRect.clampToBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
function zoomFromSlider(t: real): real {
|
|
||||||
return 1 / (1 - t * (1 - 1 / maxZoom));
|
|
||||||
}
|
|
||||||
|
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
implicitHeight: shouldBeActive ? 430 : 0
|
implicitHeight: shouldBeActive ? 430 : 0
|
||||||
@@ -100,16 +102,13 @@ Item {
|
|||||||
visible: opacity > 0
|
visible: opacity > 0
|
||||||
|
|
||||||
Behavior on opacity {
|
Behavior on opacity {
|
||||||
Anim {
|
Anim {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Behavior on scale {
|
Behavior on scale {
|
||||||
Anim {
|
Anim {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Behavior on y {
|
Behavior on y {
|
||||||
Anim {
|
Anim {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
@@ -141,12 +140,12 @@ Item {
|
|||||||
required property var modelData
|
required property var modelData
|
||||||
|
|
||||||
fillWidth: true
|
fillWidth: true
|
||||||
font: Tokens.font.body.builders.large.weight(Font.DemiBold).build()
|
|
||||||
inactiveColor: isCurrent ? Colors.palette.m3primary : Qt.alpha(Colors.palette.m3surfaceContainer, 0.7)
|
inactiveColor: isCurrent ? Colors.palette.m3primary : Qt.alpha(Colors.palette.m3surfaceContainer, 0.7)
|
||||||
inactiveOnColor: isCurrent ? Colors.palette.m3onPrimary : Qt.alpha(Colors.palette.m3onSurface, 0.7)
|
inactiveOnColor: isCurrent ? Colors.palette.m3onPrimary : Qt.alpha(Colors.palette.m3onSurface, 0.7)
|
||||||
isRound: true
|
isRound: true
|
||||||
shapeMorph: true
|
shapeMorph: true
|
||||||
text: modelData.name
|
text: modelData.name
|
||||||
|
font: Tokens.font.body.builders.large.weight(Font.DemiBold).build()
|
||||||
|
|
||||||
onClicked: wrapper.selectScreen(index)
|
onClicked: wrapper.selectScreen(index)
|
||||||
}
|
}
|
||||||
@@ -181,15 +180,15 @@ Item {
|
|||||||
spacing: Tokens.spacing.medium
|
spacing: Tokens.spacing.medium
|
||||||
|
|
||||||
IconTextButton {
|
IconTextButton {
|
||||||
enabled: wrapper.changesMade
|
isRound: true
|
||||||
font: Tokens.font.body.large
|
|
||||||
horizontalPadding: Tokens.padding.large
|
|
||||||
icon: "close"
|
icon: "close"
|
||||||
|
text: qsTr("Cancel")
|
||||||
|
font: Tokens.font.body.large
|
||||||
|
shapeMorph: true
|
||||||
|
horizontalPadding: Tokens.padding.large
|
||||||
inactiveColor: Colors.layer(Colors.palette.m3surfaceContainerHighest, 2)
|
inactiveColor: Colors.layer(Colors.palette.m3surfaceContainerHighest, 2)
|
||||||
inactiveOnColor: Colors.palette.m3onSurfaceVariant
|
inactiveOnColor: Colors.palette.m3onSurfaceVariant
|
||||||
isRound: true
|
enabled: wrapper.changesMade
|
||||||
shapeMorph: true
|
|
||||||
text: qsTr("Cancel")
|
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
wrapper.syncCropToScreen();
|
wrapper.syncCropToScreen();
|
||||||
@@ -197,15 +196,15 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IconTextButton {
|
IconTextButton {
|
||||||
enabled: wrapper.changesMade
|
isRound: true
|
||||||
font: Tokens.font.body.large
|
|
||||||
horizontalPadding: Tokens.padding.large
|
|
||||||
icon: "check"
|
icon: "check"
|
||||||
|
text: qsTr("Apply")
|
||||||
|
font: Tokens.font.body.large
|
||||||
|
shapeMorph: true
|
||||||
|
horizontalPadding: Tokens.padding.large
|
||||||
inactiveColor: Colors.palette.m3secondary
|
inactiveColor: Colors.palette.m3secondary
|
||||||
inactiveOnColor: Colors.palette.m3onSecondary
|
inactiveOnColor: Colors.palette.m3onSecondary
|
||||||
isRound: true
|
enabled: wrapper.changesMade
|
||||||
shapeMorph: true
|
|
||||||
text: qsTr("Apply")
|
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
wrapper.applyCrop();
|
wrapper.applyCrop();
|
||||||
@@ -228,37 +227,42 @@ Item {
|
|||||||
id: fitBox
|
id: fitBox
|
||||||
|
|
||||||
readonly property real aspect: scaledImg.implicitHeight > 0 ? scaledImg.implicitWidth / scaledImg.implicitHeight : 1
|
readonly property real aspect: scaledImg.implicitHeight > 0 ? scaledImg.implicitWidth / scaledImg.implicitHeight : 1
|
||||||
readonly property real fitW: imageSlot.height * aspect
|
readonly property real fitW: Math.min(imageSlot.width, imageSlot.height * aspect)
|
||||||
|
|
||||||
anchors.centerIn: parent
|
|
||||||
implicitHeight: Math.round(fitW / aspect)
|
implicitHeight: Math.round(fitW / aspect)
|
||||||
implicitWidth: Math.round(fitW)
|
implicitWidth: Math.round(fitW)
|
||||||
|
x: Math.round((imageSlot.width - width) / 2)
|
||||||
|
y: Math.round((imageSlot.height - height) / 2)
|
||||||
radius: Tokens.rounding.largeIncreased
|
radius: Tokens.rounding.largeIncreased
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
active: opacity > 0
|
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
opacity: scaledImg.status === Image.Ready ? 0 : 1
|
|
||||||
|
|
||||||
Behavior on opacity {
|
opacity: scaledImg.status === Image.Ready ? 0 : 1
|
||||||
Anim {
|
active: opacity > 0
|
||||||
type: Anim.DefaultEffects
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sourceComponent: CustomRect {
|
sourceComponent: CustomRect {
|
||||||
color: Colors.palette.m3primaryContainer
|
|
||||||
implicitHeight: loadingIndicator.implicitSize + Tokens.padding.large * 2
|
|
||||||
implicitWidth: loadingIndicator.implicitSize + Tokens.padding.large * 2
|
implicitWidth: loadingIndicator.implicitSize + Tokens.padding.large * 2
|
||||||
|
implicitHeight: loadingIndicator.implicitSize + Tokens.padding.large * 2
|
||||||
|
|
||||||
|
color: Colors.palette.m3primaryContainer
|
||||||
radius: Tokens.rounding.full
|
radius: Tokens.rounding.full
|
||||||
|
|
||||||
LoadingIndicator {
|
LoadingIndicator {
|
||||||
id: loadingIndicator
|
id: loadingIndicator
|
||||||
|
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
|
|
||||||
containsIcon: true
|
containsIcon: true
|
||||||
implicitSize: Math.min(fitBox.width, fitBox.height) * 0.3
|
implicitSize: Math.min(fitBox.width, fitBox.height) * 0.3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Behavior on opacity {
|
||||||
|
Anim {
|
||||||
|
type: Anim.DefaultEffects
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
@@ -266,16 +270,14 @@ Item {
|
|||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
fillMode: Image.PreserveAspectFit
|
fillMode: Image.Stretch
|
||||||
mipmap: true
|
|
||||||
opacity: status === Image.Ready ? 1 : 0
|
|
||||||
retainWhileLoading: true
|
|
||||||
smooth: true
|
|
||||||
source: Wallpapers.current
|
source: Wallpapers.current
|
||||||
sourceSize.height: {
|
sourceSize: {
|
||||||
const dpr = (QsWindow.window as QsWindow)?.devicePixelRatio ?? 1;
|
const dpr = (QsWindow.window as QsWindow)?.devicePixelRatio ?? 1;
|
||||||
return imageSlot.height * dpr;
|
return Qt.size(width * dpr, height * dpr);
|
||||||
}
|
}
|
||||||
|
retainWhileLoading: true
|
||||||
|
opacity: status === Image.Ready ? 1 : 0
|
||||||
|
|
||||||
Behavior on opacity {
|
Behavior on opacity {
|
||||||
Anim {
|
Anim {
|
||||||
@@ -295,6 +297,7 @@ Item {
|
|||||||
|
|
||||||
property real aspectRatio: wrapper.currentScreen ? wrapper.currentScreen.width / wrapper.currentScreen.height : 1
|
property real aspectRatio: wrapper.currentScreen ? wrapper.currentScreen.width / wrapper.currentScreen.height : 1
|
||||||
readonly property real baseHeight: baseWidth / aspectRatio
|
readonly property real baseHeight: baseWidth / aspectRatio
|
||||||
|
|
||||||
readonly property real baseWidth: {
|
readonly property real baseWidth: {
|
||||||
let fittedHeight = imageH;
|
let fittedHeight = imageH;
|
||||||
let fittedWidth = fittedHeight * aspectRatio;
|
let fittedWidth = fittedHeight * aspectRatio;
|
||||||
@@ -306,6 +309,7 @@ Item {
|
|||||||
|
|
||||||
return fittedWidth;
|
return fittedWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly property real imageH: Math.round(fitBox.height)
|
readonly property real imageH: Math.round(fitBox.height)
|
||||||
readonly property real imageW: Math.round(fitBox.width)
|
readonly property real imageW: Math.round(fitBox.width)
|
||||||
readonly property real imageX: 0
|
readonly property real imageX: 0
|
||||||
@@ -323,13 +327,6 @@ Item {
|
|||||||
y = Math.max(imageY, Math.min(y, imageY + imageH - height));
|
y = Math.max(imageY, Math.min(y, imageY + imageH - height));
|
||||||
}
|
}
|
||||||
|
|
||||||
function restoreFromData() {
|
|
||||||
const t = savedTarget();
|
|
||||||
zoom = t.zoom;
|
|
||||||
x = t.x;
|
|
||||||
y = t.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Where the rect should be according to saved data (same rules as a restore).
|
// Where the rect should be according to saved data (same rules as a restore).
|
||||||
function savedTarget() {
|
function savedTarget() {
|
||||||
const data = Wallpapers.getCrop(wrapper.currentScreen.name);
|
const data = Wallpapers.getCrop(wrapper.currentScreen.name);
|
||||||
@@ -352,13 +349,19 @@ Item {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
color: zoomSlider.dragging || mouse.pressed ? Qt.alpha(Colors.palette.m3tertiary, 0.3) : "transparent"
|
function restoreFromData() {
|
||||||
|
const t = savedTarget();
|
||||||
|
zoom = t.zoom;
|
||||||
|
x = t.x;
|
||||||
|
y = t.y;
|
||||||
|
}
|
||||||
|
|
||||||
height: Math.round(baseHeight / zoom)
|
height: Math.round(baseHeight / zoom)
|
||||||
width: Math.round(baseWidth / zoom)
|
width: Math.round(baseWidth / zoom)
|
||||||
|
color: zoomSlider.dragging || mouse.pressed ? Qt.alpha(Colors.palette.m3tertiary, 0.3) : "transparent"
|
||||||
|
|
||||||
Behavior on color {
|
Behavior on color {
|
||||||
CAnim {
|
CAnim {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
@@ -371,19 +374,21 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ShaderEffect {
|
ShaderEffect {
|
||||||
property color borderColor: Colors.palette.m3tertiary
|
anchors.fill: parent
|
||||||
property real borderWidth: 2
|
|
||||||
property real cornerRadius: fitBox.radius
|
|
||||||
property vector4d cropBox: cropRectLoader.item ? Qt.vector4d(snap(cropRectLoader.item.x), snap(cropRectLoader.item.y), snap(cropRectLoader.item.width), snap(cropRectLoader.item.height)) : Qt.vector4d(0, 0, 0, 0)
|
|
||||||
readonly property real dpr: (QsWindow.window as QsWindow)?.devicePixelRatio ?? 1
|
readonly property real dpr: (QsWindow.window as QsWindow)?.devicePixelRatio ?? 1
|
||||||
property vector2d itemSize: Qt.vector2d(width, height)
|
|
||||||
property real pixelScale: dpr
|
|
||||||
|
|
||||||
function snap(v: real): real {
|
function snap(v: real): real {
|
||||||
return Math.round(v * dpr) / dpr;
|
return Math.round(v * dpr) / dpr;
|
||||||
}
|
}
|
||||||
|
|
||||||
anchors.fill: parent
|
property color borderColor: Colors.palette.m3tertiary
|
||||||
|
property vector4d cropBox: cropRectLoader.item ? Qt.vector4d(snap(cropRectLoader.item.x), snap(cropRectLoader.item.y), snap(cropRectLoader.item.width), snap(cropRectLoader.item.height)) : Qt.vector4d(0, 0, 0, 0)
|
||||||
|
property real borderWidth: 2
|
||||||
|
property real cornerRadius: fitBox.radius
|
||||||
|
property vector2d itemSize: Qt.vector2d(width, height)
|
||||||
|
property real pixelScale: dpr
|
||||||
|
|
||||||
fragmentShader: Qt.resolvedUrl(`${Quickshell.shellDir}/assets/shaders/crop_sdf.frag.qsb`)
|
fragmentShader: Qt.resolvedUrl(`${Quickshell.shellDir}/assets/shaders/crop_sdf.frag.qsb`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -393,6 +398,14 @@ Item {
|
|||||||
property real grabX: 0
|
property real grabX: 0
|
||||||
property real grabY: 0
|
property real grabY: 0
|
||||||
|
|
||||||
|
function insideCropRect(mx, my): bool {
|
||||||
|
const r = cropRectLoader.item;
|
||||||
|
if (!r)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return mx >= r.x && mx <= r.x + r.width && my >= r.y && my <= r.y + r.height;
|
||||||
|
}
|
||||||
|
|
||||||
function beginGrab(mx, my): void {
|
function beginGrab(mx, my): void {
|
||||||
const r = cropRectLoader.item;
|
const r = cropRectLoader.item;
|
||||||
if (!r)
|
if (!r)
|
||||||
@@ -409,14 +422,6 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function insideCropRect(mx, my): bool {
|
|
||||||
const r = cropRectLoader.item;
|
|
||||||
if (!r)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return mx >= r.x && mx <= r.x + r.width && my >= r.y && my <= r.y + r.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateCrop(mx, my): void {
|
function updateCrop(mx, my): void {
|
||||||
if (!cropRectLoader.item)
|
if (!cropRectLoader.item)
|
||||||
return;
|
return;
|
||||||
@@ -434,10 +439,11 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
cursorShape: pressed ? Qt.ClosedHandCursor : insideCropRect(mouseX, mouseY) ? Qt.OpenHandCursor : Qt.PointingHandCursor
|
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
preventStealing: true
|
preventStealing: true
|
||||||
|
|
||||||
|
cursorShape: pressed ? Qt.ClosedHandCursor : insideCropRect(mouseX, mouseY) ? Qt.OpenHandCursor : Qt.PointingHandCursor
|
||||||
|
|
||||||
onPositionChanged: mouse => {
|
onPositionChanged: mouse => {
|
||||||
if (pressed) {
|
if (pressed) {
|
||||||
updateCrop(mouse.x, mouse.y);
|
updateCrop(mouse.x, mouse.y);
|
||||||
|
|||||||
@@ -42,6 +42,18 @@ Item {
|
|||||||
objectName: "PageContainer"
|
objectName: "PageContainer"
|
||||||
|
|
||||||
Component.onCompleted: root.loadPage(root.sState.currentPageIdx)
|
Component.onCompleted: root.loadPage(root.sState.currentPageIdx)
|
||||||
|
|
||||||
|
// CustomRect {
|
||||||
|
// anchors.fill: parent
|
||||||
|
// color: Qt.alpha(Colors.palette.m3shadow, 0.3)
|
||||||
|
// opacity: root.sState.dimmed ? 1 : 0
|
||||||
|
// visible: opacity > 0
|
||||||
|
// z: 0
|
||||||
|
//
|
||||||
|
// Behavior on opacity {
|
||||||
|
// Anim {}
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
|
|||||||
@@ -52,11 +52,11 @@ PageBase {
|
|||||||
anchors.leftMargin: Tokens.padding.largeIncreased
|
anchors.leftMargin: Tokens.padding.largeIncreased
|
||||||
anchors.margins: Tokens.padding.small
|
anchors.margins: Tokens.padding.small
|
||||||
anchors.rightMargin: Tokens.padding.largeIncreased
|
anchors.rightMargin: Tokens.padding.largeIncreased
|
||||||
spacing: Tokens.spacing.medium
|
spacing: Tokens.spacing.small
|
||||||
|
|
||||||
IconImage {
|
IconImage {
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
implicitSize: Math.round(Tokens.font.icon.large.pointSize * 1.8)
|
implicitSize: Math.round(Tokens.font.icon.large * 1.8)
|
||||||
source: Quickshell.iconPath(appItem.modelData.icon, "image-missing")
|
source: Quickshell.iconPath(appItem.modelData.icon, "image-missing")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ PageBase {
|
|||||||
enabled: Object.keys(model).length > 0
|
enabled: Object.keys(model).length > 0
|
||||||
header: qsTr("Add new entry")
|
header: qsTr("Add new entry")
|
||||||
icon: "add"
|
icon: "add"
|
||||||
|
settingAnchor: "panels-bar-status-icons-add-item"
|
||||||
|
onOpenChanged: {
|
||||||
|
root.sState.dimmed = open;
|
||||||
|
}
|
||||||
last: true
|
last: true
|
||||||
label: qsTr("Add entry")
|
label: qsTr("Add entry")
|
||||||
model: {
|
model: {
|
||||||
@@ -65,7 +69,6 @@ PageBase {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
rootParent: root.flickable
|
rootParent: root.flickable
|
||||||
settingAnchor: "panels-bar-status-icons-add-item"
|
|
||||||
|
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
if (!selectedItem)
|
if (!selectedItem)
|
||||||
|
|||||||
@@ -88,12 +88,19 @@ PageBase {
|
|||||||
id: selectScheme
|
id: selectScheme
|
||||||
|
|
||||||
acceptLabel: qsTr("Confirm")
|
acceptLabel: qsTr("Confirm")
|
||||||
settingAnchor: "panels-sidebar-llm-scheme"
|
|
||||||
enabled: Object.keys(model).length > 0
|
enabled: Object.keys(model).length > 0
|
||||||
|
settingAnchor: "panels-sidebar-select-scheme"
|
||||||
|
separateContent: false
|
||||||
header: qsTr("Select scheme")
|
header: qsTr("Select scheme")
|
||||||
first: true
|
first: true
|
||||||
last: true
|
last: true
|
||||||
icon: "add"
|
icon: "format_paint"
|
||||||
|
iconLabel.fontStyle: Tokens.font.icon.large
|
||||||
|
rowButton.trailingIcon: "open_in_new"
|
||||||
|
onOpenChanged: {
|
||||||
|
root.sState.dimmed = open;
|
||||||
|
}
|
||||||
|
rowButton.activeItem: root.schemes.find(s => s.id === Config.llm.appearance.scheme).label
|
||||||
label: qsTr("Color scheme")
|
label: qsTr("Color scheme")
|
||||||
subtext: qsTr("Select the color scheme used for code blocks")
|
subtext: qsTr("Select the color scheme used for code blocks")
|
||||||
model: root.schemes
|
model: root.schemes
|
||||||
|
|||||||
@@ -25,6 +25,18 @@ PageBase {
|
|||||||
text: qsTr("None")
|
text: qsTr("None")
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
readonly property list<string> gpuValues: ["", "NVIDIA", "GENERIC", "None"]
|
||||||
|
|
||||||
|
function gpuKeyToIndex(key: string): int {
|
||||||
|
const u = (key ?? "").trim().toUpperCase();
|
||||||
|
if (u === "")
|
||||||
|
return 0; // Auto
|
||||||
|
if (u === "NVIDIA")
|
||||||
|
return 1;
|
||||||
|
if (u === "GENERIC")
|
||||||
|
return 2;
|
||||||
|
return 3; // None
|
||||||
|
}
|
||||||
|
|
||||||
title: qsTr("Services")
|
title: qsTr("Services")
|
||||||
|
|
||||||
@@ -199,7 +211,7 @@ PageBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SelectRow {
|
SelectRow {
|
||||||
active: root.gpuItems[Config.services.gpuType]
|
active: root.gpuItems[root.gpuKeyToIndex(Config.services.gpuType)]
|
||||||
last: true
|
last: true
|
||||||
menuItems: root.gpuItems
|
menuItems: root.gpuItems
|
||||||
menuOnTop: true
|
menuOnTop: true
|
||||||
@@ -207,7 +219,7 @@ PageBase {
|
|||||||
subtext: Gpu.name ? qsTr("Monitoring: %1").arg(Gpu.name) : qsTr("Override for GPU type")
|
subtext: Gpu.name ? qsTr("Monitoring: %1").arg(Gpu.name) : qsTr("Override for GPU type")
|
||||||
text: qsTr("GPU")
|
text: qsTr("GPU")
|
||||||
|
|
||||||
onSelected: item => Config.services.gpuType = root.gpuItems.indexOf(item)
|
onSelected: item => Config.services.gpuType = root.gpuValues[root.gpuItems.indexOf(item)]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ PageBase {
|
|||||||
spacing: Tokens.spacing.small
|
spacing: Tokens.spacing.small
|
||||||
|
|
||||||
IconTextButton {
|
IconTextButton {
|
||||||
|
|
||||||
|
property string settingAnchor: "style-wallpapers"
|
||||||
|
|
||||||
enabled: Config.background.enabled
|
enabled: Config.background.enabled
|
||||||
horizontalPadding: Tokens.padding.extraLarge
|
horizontalPadding: Tokens.padding.extraLarge
|
||||||
icon: "wallpaper"
|
icon: "wallpaper"
|
||||||
@@ -51,6 +54,9 @@ PageBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IconTextButton {
|
IconTextButton {
|
||||||
|
|
||||||
|
property string settingAnchor: "style-colors-fonts"
|
||||||
|
|
||||||
enabled: Config.background.enabled
|
enabled: Config.background.enabled
|
||||||
horizontalPadding: Tokens.padding.extraLarge
|
horizontalPadding: Tokens.padding.extraLarge
|
||||||
icon: "palette"
|
icon: "palette"
|
||||||
|
|||||||
@@ -11,18 +11,6 @@ Scope {
|
|||||||
readonly property bool hasFullscreen: Hypr.focusedWorkspace?.toplevels.values.some(t => t.lastIpcObject.fullscreen === 2) ?? false
|
readonly property bool hasFullscreen: Hypr.focusedWorkspace?.toplevels.values.some(t => t.lastIpcObject.fullscreen === 2) ?? false
|
||||||
property bool launcherInterrupted
|
property bool launcherInterrupted
|
||||||
|
|
||||||
CustomShortcut {
|
|
||||||
description: "Open screenshot"
|
|
||||||
name: "screenshot"
|
|
||||||
|
|
||||||
onPressed: {
|
|
||||||
const states = ShellState.allStates();
|
|
||||||
for (const s of states) {
|
|
||||||
s.screenshot = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CustomShortcut {
|
CustomShortcut {
|
||||||
description: "Toggle launcher"
|
description: "Toggle launcher"
|
||||||
name: "toggle-launcher"
|
name: "toggle-launcher"
|
||||||
@@ -38,7 +26,6 @@ Scope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CustomShortcut {
|
CustomShortcut {
|
||||||
description: "Toggle drawing"
|
|
||||||
name: "toggle-drawing"
|
name: "toggle-drawing"
|
||||||
|
|
||||||
onPressed: {
|
onPressed: {
|
||||||
@@ -48,7 +35,6 @@ Scope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CustomShortcut {
|
CustomShortcut {
|
||||||
description: "Toggle sidebar"
|
|
||||||
name: "toggle-nc"
|
name: "toggle-nc"
|
||||||
|
|
||||||
onPressed: {
|
onPressed: {
|
||||||
@@ -58,7 +44,6 @@ Scope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CustomShortcut {
|
CustomShortcut {
|
||||||
description: "Show On-Screen-Display"
|
|
||||||
name: "show-osd"
|
name: "show-osd"
|
||||||
|
|
||||||
onPressed: {
|
onPressed: {
|
||||||
@@ -68,7 +53,6 @@ Scope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CustomShortcut {
|
CustomShortcut {
|
||||||
description: "Toggle settings"
|
|
||||||
name: "toggle-settings"
|
name: "toggle-settings"
|
||||||
|
|
||||||
onPressed: {
|
onPressed: {
|
||||||
@@ -78,7 +62,6 @@ Scope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CustomShortcut {
|
CustomShortcut {
|
||||||
description: "Toggle clipboard"
|
|
||||||
name: "toggle-clipboard"
|
name: "toggle-clipboard"
|
||||||
|
|
||||||
onPressed: {
|
onPressed: {
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Hyprland
|
||||||
|
import QtQuick
|
||||||
|
import qs.Components
|
||||||
|
import qs.Helpers
|
||||||
|
import ZShell.Internal
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
readonly property var displayData: Wallpapers.getCrop(screen.name)
|
||||||
|
required property ShellScreen screen
|
||||||
|
property size screenResolution: Qt.size(screen.width * screenScale, screen.height * screenScale)
|
||||||
|
property real screenScale: Hyprland.monitorFor(screen).scale
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
Component.onCompleted: Hyprland.refreshMonitors()
|
||||||
|
|
||||||
|
WallpaperImage {
|
||||||
|
id: img
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
cropHeight: root.displayData?.height ?? 1.0
|
||||||
|
cropWidth: root.displayData?.width ?? 1.0
|
||||||
|
cropX: root.displayData?.x ?? 0.0
|
||||||
|
cropY: root.displayData?.y ?? 0.0
|
||||||
|
fadeDuration: 150
|
||||||
|
screenResolution: root.screenResolution
|
||||||
|
source: Wallpapers.current
|
||||||
|
|
||||||
|
Behavior on cropHeight {
|
||||||
|
Anim {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Behavior on cropWidth {
|
||||||
|
Anim {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Behavior on cropX {
|
||||||
|
Anim {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Behavior on cropY {
|
||||||
|
Anim {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
import Quickshell
|
||||||
|
import QtQuick
|
||||||
|
import Quickshell.Wayland
|
||||||
|
import ZShell.Config
|
||||||
|
import qs.Modules.DesktopIcons
|
||||||
|
|
||||||
|
Loader {
|
||||||
|
active: Config.background.enabled
|
||||||
|
asynchronous: false
|
||||||
|
|
||||||
|
sourceComponent: Variants {
|
||||||
|
model: Quickshell.screens
|
||||||
|
|
||||||
|
PanelWindow {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
required property var modelData
|
||||||
|
|
||||||
|
WlrLayershell.exclusionMode: ExclusionMode.Ignore
|
||||||
|
WlrLayershell.layer: WlrLayer.Background
|
||||||
|
WlrLayershell.namespace: "ZShell-Wallpaper"
|
||||||
|
color: "transparent"
|
||||||
|
screen: modelData
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
bottom: true
|
||||||
|
left: true
|
||||||
|
right: true
|
||||||
|
top: true
|
||||||
|
}
|
||||||
|
|
||||||
|
WallBackground {
|
||||||
|
screen: root.screen
|
||||||
|
}
|
||||||
|
|
||||||
|
Loader {
|
||||||
|
id: loader
|
||||||
|
|
||||||
|
active: Config.general.desktopIcons
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
sourceComponent: DesktopIcons {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-22
@@ -1,25 +1,5 @@
|
|||||||
find_package(Qt6 REQUIRED COMPONENTS
|
find_package(Qt6 REQUIRED COMPONENTS ShaderTools Core Qml Gui Quick QuickPrivate Concurrent Sql Network DBus CanvasPainter)
|
||||||
ShaderTools
|
|
||||||
Core
|
|
||||||
Qml
|
|
||||||
Gui
|
|
||||||
GuiPrivate
|
|
||||||
Quick
|
|
||||||
CanvasPainter
|
|
||||||
QuickPrivate
|
|
||||||
Concurrent
|
|
||||||
Sql
|
|
||||||
Network
|
|
||||||
DBus
|
|
||||||
CanvasPainter
|
|
||||||
WaylandClient
|
|
||||||
WaylandClientPrivate
|
|
||||||
)
|
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_check_modules(WAYLAND_CLIENT REQUIRED IMPORTED_TARGET wayland-client)
|
|
||||||
pkg_check_modules(EGL REQUIRED IMPORTED_TARGET egl)
|
|
||||||
pkg_check_modules(WAYLAND_EGL REQUIRED IMPORTED_TARGET wayland-egl)
|
|
||||||
pkg_check_modules(GL REQUIRED IMPORTED_TARGET gl)
|
|
||||||
pkg_check_modules(Qalculate IMPORTED_TARGET libqalculate REQUIRED)
|
pkg_check_modules(Qalculate IMPORTED_TARGET libqalculate REQUIRED)
|
||||||
pkg_check_modules(Pipewire IMPORTED_TARGET libpipewire-0.3 REQUIRED)
|
pkg_check_modules(Pipewire IMPORTED_TARGET libpipewire-0.3 REQUIRED)
|
||||||
pkg_check_modules(Aubio IMPORTED_TARGET aubio REQUIRED)
|
pkg_check_modules(Aubio IMPORTED_TARGET aubio REQUIRED)
|
||||||
@@ -37,7 +17,6 @@ qt_standard_project_setup(REQUIRES 6.9)
|
|||||||
|
|
||||||
include(cmake/pch.cmake)
|
include(cmake/pch.cmake)
|
||||||
include(cmake/qml-module.cmake)
|
include(cmake/qml-module.cmake)
|
||||||
include(cmake/wayland-protocol.cmake)
|
|
||||||
|
|
||||||
add_library(zshell-util INTERFACE)
|
add_library(zshell-util INTERFACE)
|
||||||
target_include_directories(zshell-util INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
target_include_directories(zshell-util INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||||
|
|||||||
@@ -1,24 +1,20 @@
|
|||||||
qml_module(ZShell-blobs
|
qml_module(ZShell-blobs
|
||||||
URI ZShell.Blobs
|
URI ZShell.Blobs
|
||||||
SOURCES
|
SOURCES
|
||||||
blobgroup.cpp
|
blobgroup.cpp
|
||||||
blobshape.cpp
|
blobshape.cpp
|
||||||
blobrect.cpp
|
blobrect.cpp
|
||||||
blobinvertedrect.cpp
|
blobinvertedrect.cpp
|
||||||
blobgroup2.cpp
|
blobmaterial.cpp
|
||||||
blobshape2.cpp
|
LIBRARIES
|
||||||
blobrect2.cpp
|
Qt::Quick
|
||||||
blobinvertedrect2.cpp
|
|
||||||
blobmaterial.cpp
|
|
||||||
LIBRARIES
|
|
||||||
Qt::Quick
|
|
||||||
)
|
)
|
||||||
|
|
||||||
qt_add_shaders(ZShell-blobs "blob_shaders"
|
qt_add_shaders(ZShell-blobs "blob_shaders"
|
||||||
BATCHABLE OPTIMIZED NOHLSL NOMSL
|
BATCHABLE OPTIMIZED NOHLSL NOMSL
|
||||||
GLSL "300es,330"
|
GLSL "300es,330"
|
||||||
PREFIX "/"
|
PREFIX "/"
|
||||||
FILES
|
FILES
|
||||||
shaders/blob.frag
|
shaders/blob.frag
|
||||||
shaders/blob.vert
|
shaders/blob.vert
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,387 +0,0 @@
|
|||||||
#include "blobgroup2.hpp"
|
|
||||||
#include "blobinvertedrect2.hpp"
|
|
||||||
#include "blobshape2.hpp"
|
|
||||||
|
|
||||||
#include <qsggeometry.h>
|
|
||||||
#include <qsgnode.h>
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cmath>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
static float cpuSdBox(
|
|
||||||
float px, float py, float cx, float cy, float hw, float hh) {
|
|
||||||
const float dx = std::abs(px - cx) - hw;
|
|
||||||
const float dy = std::abs(py - cy) - hh;
|
|
||||||
const float mdx = std::max(dx, 0.0f);
|
|
||||||
const float mdy = std::max(dy, 0.0f);
|
|
||||||
return std::sqrt(mdx * mdx + mdy * mdy) + std::min(std::max(dx, dy), 0.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
static float cpuSmoothstep(float edge0, float edge1, float x) {
|
|
||||||
const float t = std::clamp((x - edge0) / (edge1 - edge0), 0.0f, 1.0f);
|
|
||||||
return t * t * (3.0f - 2.0f * t);
|
|
||||||
}
|
|
||||||
|
|
||||||
static float cornerFillFactor(float sd, float smoothFactor) {
|
|
||||||
const float outside = cpuSmoothstep(0.0f, smoothFactor, sd);
|
|
||||||
const float inside = cpuSmoothstep(0.0f, -smoothFactor, sd);
|
|
||||||
return std::max(outside, inside);
|
|
||||||
}
|
|
||||||
|
|
||||||
BlobGroup2::BlobGroup2(QQuickItem* parent) : QQuickItem(parent) {
|
|
||||||
setFlag(ItemHasContents);
|
|
||||||
}
|
|
||||||
|
|
||||||
BlobGroup2::~BlobGroup2() {
|
|
||||||
for (auto* shape : std::as_const(m_shapes))
|
|
||||||
shape->m_group = nullptr;
|
|
||||||
if (m_invertedRect)
|
|
||||||
static_cast<BlobShape2*>(m_invertedRect)->m_group = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobGroup2::setSmoothing(qreal s) {
|
|
||||||
if (qFuzzyCompare(m_smoothing, s)) return;
|
|
||||||
m_smoothing = s;
|
|
||||||
emit smoothingChanged();
|
|
||||||
markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobGroup2::setColor(const QColor& c) {
|
|
||||||
if (m_color == c) return;
|
|
||||||
m_color = c;
|
|
||||||
emit colorChanged();
|
|
||||||
markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobGroup2::setCornerFill(bool e) {
|
|
||||||
if (m_cornerFill == e) return;
|
|
||||||
m_cornerFill = e;
|
|
||||||
emit cornerFillChanged();
|
|
||||||
markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobGroup2::setShadowColor(const QColor& c) {
|
|
||||||
if (m_shadowColor == c) return;
|
|
||||||
m_shadowColor = c;
|
|
||||||
emit shadowColorChanged();
|
|
||||||
markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobGroup2::setShadowRadius(qreal r) {
|
|
||||||
if (qFuzzyCompare(m_shadowRadius, r)) return;
|
|
||||||
m_shadowRadius = r;
|
|
||||||
emit shadowRadiusChanged();
|
|
||||||
markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobGroup2::addShape(BlobShape2* shape) {
|
|
||||||
if (!shape || m_shapes.contains(shape)) return;
|
|
||||||
m_shapes.append(shape);
|
|
||||||
markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobGroup2::removeShape(BlobShape2* shape) {
|
|
||||||
m_shapes.removeOne(shape);
|
|
||||||
markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobGroup2::setInvertedRect(BlobInvertedRect2* rect) {
|
|
||||||
if (m_invertedRect == rect) return;
|
|
||||||
m_invertedRect = rect;
|
|
||||||
markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobGroup2::clearInvertedRect(BlobInvertedRect2* rect) {
|
|
||||||
if (m_invertedRect != rect) return;
|
|
||||||
m_invertedRect = nullptr;
|
|
||||||
markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobGroup2::markDirty() {
|
|
||||||
m_physicsUpdated = false;
|
|
||||||
m_dataBuilt = false;
|
|
||||||
// Physics runs during polish, before the render pass. The panel content is
|
|
||||||
// transformed by deformMatrix from QML, so the matrix has to be final for this
|
|
||||||
// frame; building the data in updatePaintNode would let the transform lag one
|
|
||||||
// frame behind the material.
|
|
||||||
polish();
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobGroup2::updatePolish() {
|
|
||||||
// The group is the only thing that draws, so it also drives the shapes'
|
|
||||||
// physics.
|
|
||||||
ensureDataBuilt();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobGroup2::ensurePhysicsUpdated() {
|
|
||||||
if (m_physicsUpdated) return;
|
|
||||||
m_physicsUpdated = true;
|
|
||||||
for (auto* shape : std::as_const(m_shapes))
|
|
||||||
shape->updatePhysics();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobGroup2::ensureDataBuilt() {
|
|
||||||
if (m_dataBuilt) return;
|
|
||||||
ensurePhysicsUpdated();
|
|
||||||
|
|
||||||
// Physics can request the next frame through markDirty(); the data is
|
|
||||||
// refreshed here anyway, so the flag is set after it runs.
|
|
||||||
m_dataBuilt = true;
|
|
||||||
m_data.rects.clear();
|
|
||||||
m_bounds = QRectF();
|
|
||||||
|
|
||||||
const float smoothFactor = static_cast<float>(m_smoothing);
|
|
||||||
// The same reach the shader uses to decide whether a rect can contribute, plus
|
|
||||||
// the shadow, so every pixel the shader can give a value to is inside the node.
|
|
||||||
const double extent = static_cast<double>(smoothFactor) * 1.5 +
|
|
||||||
static_cast<double>(m_shadowRadius);
|
|
||||||
|
|
||||||
// Group order, no pruning by proximity: the shader sees this list for every pixel. A
|
|
||||||
// shape that is not pushing is not in the list at all: shapes here are data for the
|
|
||||||
// group draw, so leaving a panel at rest out means it cannot define any part of the
|
|
||||||
// edge. A closing panel is still in the list while its curve runs out, even with no
|
|
||||||
// size left, which is what keeps the bounce.
|
|
||||||
// entryShapes maps a shared entry back to the shape it came from.
|
|
||||||
QVector<BlobShape2*> entryShapes;
|
|
||||||
|
|
||||||
for (auto* shape : std::as_const(m_shapes)) {
|
|
||||||
if (!shape->isMoving()) continue;
|
|
||||||
if (shape->width() <= 0 || shape->height() <= 0) continue;
|
|
||||||
if (static_cast<int>(m_data.rects.size()) >= BlobGroupData::kMaxRects)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
const QPointF scene = shape->mapToScene(QPointF(0, 0));
|
|
||||||
const QMatrix4x4& dm = shape->m_deformMatrix;
|
|
||||||
|
|
||||||
BlobRectData r;
|
|
||||||
r.cx = static_cast<float>(scene.x() + shape->width() / 2.0);
|
|
||||||
r.cy = static_cast<float>(scene.y() + shape->height() / 2.0);
|
|
||||||
r.hw = static_cast<float>(shape->width()) * 0.5f;
|
|
||||||
r.hh = static_cast<float>(shape->height()) * 0.5f;
|
|
||||||
shape->cornerRadii(r.radius);
|
|
||||||
r.offsetX = dm(0, 3);
|
|
||||||
r.offsetY = dm(1, 3);
|
|
||||||
|
|
||||||
const float a = dm(0, 0), b = dm(1, 0);
|
|
||||||
const float c = dm(0, 1), e = dm(1, 1);
|
|
||||||
const float det = a * e - c * b;
|
|
||||||
const float invDet = std::abs(det) > 1e-6f ? 1.0f / det : 1.0f;
|
|
||||||
r.invDeform[0] = e * invDet;
|
|
||||||
r.invDeform[1] = -b * invDet;
|
|
||||||
r.invDeform[2] = -c * invDet;
|
|
||||||
r.invDeform[3] = a * invDet;
|
|
||||||
|
|
||||||
const float halfTr = 0.5f * (a + e);
|
|
||||||
const float halfDiff = 0.5f * (a - e);
|
|
||||||
r.minEig = halfTr - std::sqrt(halfDiff * halfDiff + c * c);
|
|
||||||
|
|
||||||
r.screenHalfX = std::abs(a) * r.hw + std::abs(c) * r.hh;
|
|
||||||
r.screenHalfY = std::abs(b) * r.hw + std::abs(e) * r.hh;
|
|
||||||
|
|
||||||
m_data.rects.append(r);
|
|
||||||
m_bounds = m_bounds.united(QRectF(
|
|
||||||
static_cast<double>(r.cx) + static_cast<double>(r.offsetX) -
|
|
||||||
static_cast<double>(r.screenHalfX) - extent,
|
|
||||||
static_cast<double>(r.cy) + static_cast<double>(r.offsetY) -
|
|
||||||
static_cast<double>(r.screenHalfY) - extent,
|
|
||||||
2.0 * (static_cast<double>(r.screenHalfX) + extent),
|
|
||||||
2.0 * (static_cast<double>(r.screenHalfY) + extent)));
|
|
||||||
|
|
||||||
entryShapes.append(shape);
|
|
||||||
}
|
|
||||||
|
|
||||||
const int count = static_cast<int>(m_data.rects.size());
|
|
||||||
|
|
||||||
// Exclusion gates only the smooth blend.
|
|
||||||
for (int i = 0; i < count; ++i) {
|
|
||||||
int mask = 0;
|
|
||||||
BlobShape2* const si = entryShapes[i];
|
|
||||||
for (int j = 0; j < count; ++j) {
|
|
||||||
if (j == i) continue;
|
|
||||||
BlobShape2* const sj = entryShapes[j];
|
|
||||||
if (si->isExcluded(sj) || sj->isExcluded(si)) mask |= (1 << j);
|
|
||||||
}
|
|
||||||
m_data.rects[i].excludeMask = mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr float minR = 2.0f;
|
|
||||||
const bool cornerFill = m_cornerFill;
|
|
||||||
|
|
||||||
for (int i = 0; i < count; ++i) {
|
|
||||||
auto& ri = m_data.rects[i];
|
|
||||||
BlobShape2* const si = entryShapes[i];
|
|
||||||
float fTr = 1.0f, fBr = 1.0f, fBl = 1.0f, fTl = 1.0f;
|
|
||||||
|
|
||||||
const float cTrX = ri.cx + ri.hw, cTrY = ri.cy - ri.hh;
|
|
||||||
const float cBrX = ri.cx + ri.hw, cBrY = ri.cy + ri.hh;
|
|
||||||
const float cBlX = ri.cx - ri.hw, cBlY = ri.cy + ri.hh;
|
|
||||||
const float cTlX = ri.cx - ri.hw, cTlY = ri.cy - ri.hh;
|
|
||||||
|
|
||||||
if (cornerFill) {
|
|
||||||
for (int j = 0; j < count; ++j) {
|
|
||||||
if (j == i) continue;
|
|
||||||
if (ri.excludeMask & (1 << j)) continue;
|
|
||||||
BlobShape2* const sj = entryShapes[j];
|
|
||||||
if (si->isCornerExcluded(sj) || sj->isCornerExcluded(si))
|
|
||||||
continue;
|
|
||||||
const auto& rj = m_data.rects[j];
|
|
||||||
fTr = std::min(
|
|
||||||
fTr,
|
|
||||||
cornerFillFactor(
|
|
||||||
cpuSdBox(cTrX, cTrY, rj.cx, rj.cy, rj.hw, rj.hh),
|
|
||||||
smoothFactor));
|
|
||||||
fBr = std::min(
|
|
||||||
fBr,
|
|
||||||
cornerFillFactor(
|
|
||||||
cpuSdBox(cBrX, cBrY, rj.cx, rj.cy, rj.hw, rj.hh),
|
|
||||||
smoothFactor));
|
|
||||||
fBl = std::min(
|
|
||||||
fBl,
|
|
||||||
cornerFillFactor(
|
|
||||||
cpuSdBox(cBlX, cBlY, rj.cx, rj.cy, rj.hw, rj.hh),
|
|
||||||
smoothFactor));
|
|
||||||
fTl = std::min(
|
|
||||||
fTl,
|
|
||||||
cornerFillFactor(
|
|
||||||
cpuSdBox(cTlX, cTlY, rj.cx, rj.cy, rj.hw, rj.hh),
|
|
||||||
smoothFactor));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ri.radius[0] = std::max(ri.radius[0] * fTr, minR);
|
|
||||||
ri.radius[1] = std::max(ri.radius[1] * fBr, minR);
|
|
||||||
ri.radius[2] = std::max(ri.radius[2] * fBl, minR);
|
|
||||||
ri.radius[3] = std::max(ri.radius[3] * fTl, minR);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inverted rect. The frame term is evaluated for every pixel in the bounds,
|
|
||||||
// so the group flag cannot be gated per shape.
|
|
||||||
if (!m_invertedRect) return;
|
|
||||||
|
|
||||||
auto* inv = static_cast<BlobShape2*>(m_invertedRect);
|
|
||||||
if (inv->width() <= 0 || inv->height() <= 0) return;
|
|
||||||
|
|
||||||
const QPointF invScene = inv->mapToScene(QPointF(0, 0));
|
|
||||||
const float outerCX = static_cast<float>(invScene.x() + inv->width() / 2.0);
|
|
||||||
const float outerCY =
|
|
||||||
static_cast<float>(invScene.y() + inv->height() / 2.0);
|
|
||||||
const float outerHW = static_cast<float>(inv->width()) * 0.5f;
|
|
||||||
const float outerHH = static_cast<float>(inv->height()) * 0.5f;
|
|
||||||
|
|
||||||
const auto* invRect = m_invertedRect;
|
|
||||||
const float innerCX =
|
|
||||||
outerCX + static_cast<float>(
|
|
||||||
(invRect->borderLeft() - invRect->borderRight()) / 2.0);
|
|
||||||
const float innerCY =
|
|
||||||
outerCY + static_cast<float>(
|
|
||||||
(invRect->borderTop() - invRect->borderBottom()) / 2.0);
|
|
||||||
const float innerHW =
|
|
||||||
outerHW - static_cast<float>(
|
|
||||||
(invRect->borderLeft() + invRect->borderRight()) / 2.0);
|
|
||||||
const float innerHH =
|
|
||||||
outerHH - static_cast<float>(
|
|
||||||
(invRect->borderTop() + invRect->borderBottom()) / 2.0);
|
|
||||||
|
|
||||||
m_data.hasInverted = true;
|
|
||||||
m_data.invertedRadius = static_cast<float>(invRect->radius());
|
|
||||||
|
|
||||||
m_data.invertedOuter[0] = outerCX;
|
|
||||||
m_data.invertedOuter[1] = outerCY;
|
|
||||||
m_data.invertedOuter[2] = outerHW;
|
|
||||||
m_data.invertedOuter[3] = outerHH;
|
|
||||||
|
|
||||||
m_data.invertedInner[0] = innerCX;
|
|
||||||
m_data.invertedInner[1] = innerCY;
|
|
||||||
m_data.invertedInner[2] = innerHW;
|
|
||||||
m_data.invertedInner[3] = innerHH;
|
|
||||||
|
|
||||||
m_bounds = m_bounds.united(QRectF(
|
|
||||||
static_cast<double>(outerCX) - static_cast<double>(outerHW) - extent,
|
|
||||||
static_cast<double>(outerCY) - static_cast<double>(outerHH) - extent,
|
|
||||||
2.0 * (static_cast<double>(outerHW) + extent),
|
|
||||||
2.0 * (static_cast<double>(outerHH) + extent)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobGroup2::fillMaterial(BlobMaterial* material) {
|
|
||||||
material->m_paddedX = static_cast<float>(m_bounds.x());
|
|
||||||
material->m_paddedY = static_cast<float>(m_bounds.y());
|
|
||||||
material->m_paddedW = static_cast<float>(m_bounds.width());
|
|
||||||
material->m_paddedH = static_cast<float>(m_bounds.height());
|
|
||||||
|
|
||||||
material->m_smoothFactor = static_cast<float>(m_smoothing);
|
|
||||||
// The single group draw has no owner, so the shader skips the ownership test.
|
|
||||||
material->m_myIndex = -2;
|
|
||||||
material->m_color = m_color;
|
|
||||||
material->m_hasInverted = m_data.hasInverted ? 1 : 0;
|
|
||||||
material->m_invertedRadius = data().invertedRadius;
|
|
||||||
memcpy(
|
|
||||||
material->m_invertedOuter,
|
|
||||||
data().invertedOuter,
|
|
||||||
sizeof(data().invertedOuter));
|
|
||||||
memcpy(
|
|
||||||
material->m_invertedInner,
|
|
||||||
data().invertedInner,
|
|
||||||
sizeof(data().invertedInner));
|
|
||||||
|
|
||||||
material->m_shadowRadius = static_cast<float>(m_shadowRadius);
|
|
||||||
material->m_shadowColor[0] = static_cast<float>(m_shadowColor.redF());
|
|
||||||
material->m_shadowColor[1] = static_cast<float>(m_shadowColor.greenF());
|
|
||||||
material->m_shadowColor[2] = static_cast<float>(m_shadowColor.blueF());
|
|
||||||
material->m_shadowColor[3] = static_cast<float>(m_shadowColor.alphaF());
|
|
||||||
|
|
||||||
const int count =
|
|
||||||
static_cast<int>(qMin(data().rects.size(), qsizetype(16)));
|
|
||||||
material->m_rectCount = count;
|
|
||||||
for (int i = 0; i < count; ++i)
|
|
||||||
material->m_rects[i] = data().rects[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
QSGNode* BlobGroup2::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*) {
|
|
||||||
// Data is built during polish. This only covers a render pass that happens
|
|
||||||
// without one.
|
|
||||||
ensureDataBuilt();
|
|
||||||
|
|
||||||
if (m_data.rects.isEmpty() && !m_data.hasInverted) {
|
|
||||||
delete oldNode;
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto* node = static_cast<QSGGeometryNode*>(oldNode);
|
|
||||||
if (!node) {
|
|
||||||
node = new QSGGeometryNode;
|
|
||||||
|
|
||||||
auto* geometry =
|
|
||||||
new QSGGeometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4);
|
|
||||||
geometry->setDrawingMode(QSGGeometry::DrawTriangleStrip);
|
|
||||||
node->setGeometry(geometry);
|
|
||||||
node->setFlag(QSGNode::OwnsGeometry);
|
|
||||||
|
|
||||||
auto* material = new BlobMaterial;
|
|
||||||
material->setFlag(QSGMaterial::Blending);
|
|
||||||
node->setMaterial(material);
|
|
||||||
node->setFlag(QSGNode::OwnsMaterial);
|
|
||||||
}
|
|
||||||
|
|
||||||
// The shader evaluates the field at the scene position a vertex maps to, so
|
|
||||||
// the group item itself must not be transformed. The vertex positions are the
|
|
||||||
// bounds in this item's frame; the material carries the same rect in scene
|
|
||||||
// coordinates.
|
|
||||||
auto* v = node->geometry()->vertexDataAsTexturedPoint2D();
|
|
||||||
const QPointF p0 = mapFromScene(m_bounds.topLeft());
|
|
||||||
const QPointF p1 = mapFromScene(m_bounds.bottomRight());
|
|
||||||
|
|
||||||
v[0].set(static_cast<float>(p0.x()), static_cast<float>(p0.y()), 0.0f, 0.0f);
|
|
||||||
v[1].set(static_cast<float>(p1.x()), static_cast<float>(p0.y()), 1.0f, 0.0f);
|
|
||||||
v[2].set(static_cast<float>(p0.x()), static_cast<float>(p1.y()), 0.0f, 1.0f);
|
|
||||||
v[3].set(static_cast<float>(p1.x()), static_cast<float>(p1.y()), 1.0f, 1.0f);
|
|
||||||
|
|
||||||
node->markDirty(QSGNode::DirtyGeometry);
|
|
||||||
|
|
||||||
fillMaterial(static_cast<BlobMaterial*>(node->material()));
|
|
||||||
|
|
||||||
node->markDirty(QSGNode::DirtyMaterial);
|
|
||||||
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "blobmaterial.hpp"
|
|
||||||
|
|
||||||
#include <qcolor.h>
|
|
||||||
#include <qlist.h>
|
|
||||||
#include <qobject.h>
|
|
||||||
#include <qqmlengine.h>
|
|
||||||
#include <qquickitem.h>
|
|
||||||
#include <qrect.h>
|
|
||||||
#include <qsgnode.h>
|
|
||||||
#include <qvector.h>
|
|
||||||
|
|
||||||
class BlobShape2;
|
|
||||||
class BlobInvertedRect2;
|
|
||||||
|
|
||||||
// One shared valuation for a whole group, drawn by one node.
|
|
||||||
//
|
|
||||||
// The shapes here are data only: they say where the material should be. The group
|
|
||||||
// draws a single quad over everything the shader can evaluate, so a pixel cannot
|
|
||||||
// be evaluated by one shape and missed by another, and no second draw can
|
|
||||||
// disagree with the first. That is what makes overlapping shapes read as one
|
|
||||||
// surface - one value, one writer, one alpha per pixel.
|
|
||||||
struct BlobGroupData {
|
|
||||||
// The shader reads rectData[80] = 16 entries, and excludeMask is a 32-bit
|
|
||||||
// mask. The shared list is capped at 16, in group order, so the cap is the
|
|
||||||
// same list for every pixel.
|
|
||||||
static constexpr int kMaxRects = 16;
|
|
||||||
|
|
||||||
QVector<BlobRectData> rects;
|
|
||||||
bool hasInverted = false;
|
|
||||||
float invertedRadius = 0;
|
|
||||||
float invertedOuter[4] = {};
|
|
||||||
float invertedInner[4] = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
class BlobGroup2 : public QQuickItem {
|
|
||||||
Q_OBJECT
|
|
||||||
QML_ELEMENT
|
|
||||||
Q_PROPERTY(
|
|
||||||
qreal smoothing READ smoothing WRITE setSmoothing NOTIFY
|
|
||||||
smoothingChanged)
|
|
||||||
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
|
|
||||||
Q_PROPERTY(
|
|
||||||
bool cornerFill READ cornerFill WRITE setCornerFill NOTIFY
|
|
||||||
cornerFillChanged)
|
|
||||||
Q_PROPERTY(
|
|
||||||
QColor shadowColor READ shadowColor WRITE setShadowColor NOTIFY
|
|
||||||
shadowColorChanged)
|
|
||||||
Q_PROPERTY(
|
|
||||||
qreal shadowRadius READ shadowRadius WRITE setShadowRadius NOTIFY
|
|
||||||
shadowRadiusChanged)
|
|
||||||
|
|
||||||
friend class BlobShape2;
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit BlobGroup2(QQuickItem* parent = nullptr);
|
|
||||||
~BlobGroup2() override;
|
|
||||||
|
|
||||||
[[nodiscard]] qreal smoothing() const { return m_smoothing; }
|
|
||||||
|
|
||||||
void setSmoothing(qreal s);
|
|
||||||
|
|
||||||
[[nodiscard]] QColor color() const { return m_color; }
|
|
||||||
|
|
||||||
void setColor(const QColor& c);
|
|
||||||
|
|
||||||
[[nodiscard]] bool cornerFill() const { return m_cornerFill; }
|
|
||||||
|
|
||||||
void setCornerFill(bool e);
|
|
||||||
|
|
||||||
[[nodiscard]] QColor shadowColor() const { return m_shadowColor; }
|
|
||||||
|
|
||||||
void setShadowColor(const QColor& c);
|
|
||||||
|
|
||||||
[[nodiscard]] qreal shadowRadius() const { return m_shadowRadius; }
|
|
||||||
|
|
||||||
void setShadowRadius(qreal r);
|
|
||||||
|
|
||||||
void addShape(BlobShape2* shape);
|
|
||||||
void removeShape(BlobShape2* shape);
|
|
||||||
|
|
||||||
void setInvertedRect(BlobInvertedRect2* rect);
|
|
||||||
void clearInvertedRect(BlobInvertedRect2* rect);
|
|
||||||
|
|
||||||
[[nodiscard]] const QList<BlobShape2*>& shapes() const { return m_shapes; }
|
|
||||||
|
|
||||||
[[nodiscard]] BlobInvertedRect2* invertedRect() const {
|
|
||||||
return m_invertedRect;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] const BlobGroupData& data() const { return m_data; }
|
|
||||||
|
|
||||||
// One draw per group, so a change to any shape changes the value for every
|
|
||||||
// pixel. Refresh the whole group.
|
|
||||||
void markDirty();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void smoothingChanged();
|
|
||||||
void colorChanged();
|
|
||||||
void cornerFillChanged();
|
|
||||||
void shadowColorChanged();
|
|
||||||
void shadowRadiusChanged();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void updatePolish() override;
|
|
||||||
QSGNode* updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void ensurePhysicsUpdated();
|
|
||||||
void ensureDataBuilt();
|
|
||||||
void fillMaterial(BlobMaterial* material);
|
|
||||||
|
|
||||||
qreal m_smoothing = 32.0;
|
|
||||||
QColor m_color{0x44, 0x88, 0xff};
|
|
||||||
bool m_cornerFill = true;
|
|
||||||
QColor m_shadowColor{0, 0, 0, 128};
|
|
||||||
qreal m_shadowRadius = 0.0;
|
|
||||||
QList<BlobShape2*> m_shapes;
|
|
||||||
BlobInvertedRect2* m_invertedRect = nullptr;
|
|
||||||
bool m_physicsUpdated = false;
|
|
||||||
bool m_dataBuilt = false;
|
|
||||||
BlobGroupData m_data;
|
|
||||||
|
|
||||||
// Scene-space union of what the shader can evaluate for any shape. The node
|
|
||||||
// covers exactly this, so gaps are not possible.
|
|
||||||
QRectF m_bounds;
|
|
||||||
};
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
#include "blobinvertedrect2.hpp"
|
|
||||||
#include "blobgroup2.hpp"
|
|
||||||
|
|
||||||
BlobInvertedRect2::BlobInvertedRect2(QQuickItem* parent) : BlobShape2(parent) {}
|
|
||||||
|
|
||||||
BlobInvertedRect2::~BlobInvertedRect2() {
|
|
||||||
if (m_group) m_group->clearInvertedRect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobInvertedRect2::setBorderLeft(qreal v) {
|
|
||||||
if (qFuzzyCompare(m_borderLeft, v)) return;
|
|
||||||
m_borderLeft = v;
|
|
||||||
emit borderLeftChanged();
|
|
||||||
if (m_group) m_group->markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobInvertedRect2::setBorderRight(qreal v) {
|
|
||||||
if (qFuzzyCompare(m_borderRight, v)) return;
|
|
||||||
m_borderRight = v;
|
|
||||||
emit borderRightChanged();
|
|
||||||
if (m_group) m_group->markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobInvertedRect2::setBorderTop(qreal v) {
|
|
||||||
if (qFuzzyCompare(m_borderTop, v)) return;
|
|
||||||
m_borderTop = v;
|
|
||||||
emit borderTopChanged();
|
|
||||||
if (m_group) m_group->markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobInvertedRect2::setBorderBottom(qreal v) {
|
|
||||||
if (qFuzzyCompare(m_borderBottom, v)) return;
|
|
||||||
m_borderBottom = v;
|
|
||||||
emit borderBottomChanged();
|
|
||||||
if (m_group) m_group->markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobInvertedRect2::registerWithGroup() {
|
|
||||||
if (m_group) m_group->setInvertedRect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobInvertedRect2::unregisterFromGroup() {
|
|
||||||
if (m_group) m_group->clearInvertedRect(this);
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "blobshape2.hpp"
|
|
||||||
|
|
||||||
#include <qqmlengine.h>
|
|
||||||
|
|
||||||
class BlobInvertedRect2 : public BlobShape2 {
|
|
||||||
Q_OBJECT
|
|
||||||
QML_ELEMENT
|
|
||||||
Q_PROPERTY(
|
|
||||||
qreal borderLeft READ borderLeft WRITE setBorderLeft NOTIFY
|
|
||||||
borderLeftChanged)
|
|
||||||
Q_PROPERTY(
|
|
||||||
qreal borderRight READ borderRight WRITE setBorderRight NOTIFY
|
|
||||||
borderRightChanged)
|
|
||||||
Q_PROPERTY(
|
|
||||||
qreal borderTop READ borderTop WRITE setBorderTop NOTIFY
|
|
||||||
borderTopChanged)
|
|
||||||
Q_PROPERTY(
|
|
||||||
qreal borderBottom READ borderBottom WRITE setBorderBottom NOTIFY
|
|
||||||
borderBottomChanged)
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit BlobInvertedRect2(QQuickItem* parent = nullptr);
|
|
||||||
~BlobInvertedRect2() override;
|
|
||||||
|
|
||||||
[[nodiscard]] qreal borderLeft() const { return m_borderLeft; }
|
|
||||||
|
|
||||||
void setBorderLeft(qreal v);
|
|
||||||
|
|
||||||
[[nodiscard]] qreal borderRight() const { return m_borderRight; }
|
|
||||||
|
|
||||||
void setBorderRight(qreal v);
|
|
||||||
|
|
||||||
[[nodiscard]] qreal borderTop() const { return m_borderTop; }
|
|
||||||
|
|
||||||
void setBorderTop(qreal v);
|
|
||||||
|
|
||||||
[[nodiscard]] qreal borderBottom() const { return m_borderBottom; }
|
|
||||||
|
|
||||||
void setBorderBottom(qreal v);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void borderLeftChanged();
|
|
||||||
void borderRightChanged();
|
|
||||||
void borderTopChanged();
|
|
||||||
void borderBottomChanged();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void registerWithGroup() override;
|
|
||||||
void unregisterFromGroup() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
qreal m_borderLeft = 0;
|
|
||||||
qreal m_borderRight = 0;
|
|
||||||
qreal m_borderTop = 0;
|
|
||||||
qreal m_borderBottom = 0;
|
|
||||||
};
|
|
||||||
@@ -33,7 +33,7 @@ bool BlobMaterialShader::updateUniformData(
|
|||||||
Q_UNUSED(oldMaterial);
|
Q_UNUSED(oldMaterial);
|
||||||
auto* mat = static_cast<BlobMaterial*>(newMaterial);
|
auto* mat = static_cast<BlobMaterial*>(newMaterial);
|
||||||
QByteArray* buf = state.uniformData();
|
QByteArray* buf = state.uniformData();
|
||||||
Q_ASSERT(buf->size() >= 1472);
|
Q_ASSERT(buf->size() >= 1440);
|
||||||
|
|
||||||
if (state.isMatrixDirty()) {
|
if (state.isMatrixDirty()) {
|
||||||
const QMatrix4x4 m = state.combinedMatrix();
|
const QMatrix4x4 m = state.combinedMatrix();
|
||||||
@@ -56,7 +56,7 @@ bool BlobMaterialShader::updateUniformData(
|
|||||||
// Rect count (offset 88)
|
// Rect count (offset 88)
|
||||||
memcpy(buf->data() + 88, &mat->m_rectCount, 4);
|
memcpy(buf->data() + 88, &mat->m_rectCount, 4);
|
||||||
|
|
||||||
// My index (offset 92). -2 skips the ownership test in the shader.
|
// My index (offset 92)
|
||||||
memcpy(buf->data() + 92, &mat->m_myIndex, 4);
|
memcpy(buf->data() + 92, &mat->m_myIndex, 4);
|
||||||
|
|
||||||
// Color as vec4 (offset 96, 16 bytes)
|
// Color as vec4 (offset 96, 16 bytes)
|
||||||
@@ -100,10 +100,5 @@ bool BlobMaterialShader::updateUniformData(
|
|||||||
memcpy(buf->data() + base + 64, r.radius, 16);
|
memcpy(buf->data() + base + 64, r.radius, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shadow: after rectData, which ends at 1440. shadowColor is 16-byte aligned,
|
|
||||||
// so it lands at 1456.
|
|
||||||
memcpy(buf->data() + 1440, &mat->m_shadowRadius, 4);
|
|
||||||
memcpy(buf->data() + 1456, mat->m_shadowColor, 16);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,17 +32,12 @@ class BlobMaterial : public QSGMaterial {
|
|||||||
float m_paddedH = 0;
|
float m_paddedH = 0;
|
||||||
float m_smoothFactor = 32.0f;
|
float m_smoothFactor = 32.0f;
|
||||||
int m_rectCount = 0;
|
int m_rectCount = 0;
|
||||||
// -2 means no owner test: the single group draw writes every pixel it covers.
|
|
||||||
int m_myIndex = -2;
|
int m_myIndex = -2;
|
||||||
QColor m_color{0x44, 0x88, 0xff};
|
QColor m_color{0x44, 0x88, 0xff};
|
||||||
int m_hasInverted = 0;
|
int m_hasInverted = 0;
|
||||||
float m_invertedRadius = 0;
|
float m_invertedRadius = 0;
|
||||||
float m_invertedOuter[4] = {};
|
float m_invertedOuter[4] = {};
|
||||||
float m_invertedInner[4] = {};
|
float m_invertedInner[4] = {};
|
||||||
// Phase 2: shadow around the material edges. Matches the uniform block, which
|
|
||||||
// puts these after rectData.
|
|
||||||
float m_shadowRadius = 0.0f;
|
|
||||||
float m_shadowColor[4] = {0.0f, 0.0f, 0.0f, 0.5f};
|
|
||||||
BlobRectData m_rects[16] = {};
|
BlobRectData m_rects[16] = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,6 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <qnamespace.h>
|
#include <qnamespace.h>
|
||||||
|
|
||||||
namespace {
|
|
||||||
constexpr float k_retireMs = 120.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
BlobRect::BlobRect(QQuickItem* parent) : BlobShape(parent) {}
|
BlobRect::BlobRect(QQuickItem* parent) : BlobShape(parent) {}
|
||||||
|
|
||||||
BlobRect::~BlobRect() {
|
BlobRect::~BlobRect() {
|
||||||
@@ -16,75 +12,41 @@ BlobRect::~BlobRect() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BlobRect::updatePolish() {
|
void BlobRect::updatePolish() {
|
||||||
BlobShape::updatePolish();
|
if (m_physicsActive) {
|
||||||
|
float totalDelta = std::abs(m_dm00 - 1.0f) + std::abs(m_dm01) +
|
||||||
|
std::abs(m_dm11 - 1.0f);
|
||||||
|
float totalVel =
|
||||||
|
std::abs(m_dmVel00) + std::abs(m_dmVel01) + std::abs(m_dmVel11);
|
||||||
|
|
||||||
if (!m_physicsActive) return;
|
if (totalDelta < 0.004f && totalVel < 0.05f) {
|
||||||
|
|
||||||
if (m_retiring) {
|
|
||||||
const float t = std::clamp(
|
|
||||||
static_cast<float>(m_retireElapsed.elapsed()) / k_retireMs,
|
|
||||||
0.0f,
|
|
||||||
1.0f);
|
|
||||||
const float s = t * t * (3.0f - 2.0f * t);
|
|
||||||
|
|
||||||
if (t >= 1.0f) {
|
|
||||||
m_dm00 = 1.0f;
|
m_dm00 = 1.0f;
|
||||||
m_dm01 = 0.0f;
|
m_dm01 = 0.0f;
|
||||||
m_dm11 = 1.0f;
|
m_dm11 = 1.0f;
|
||||||
|
m_dmVel00 = m_dmVel01 = m_dmVel11 = 0.0f;
|
||||||
m_deformMatrix = QMatrix4x4();
|
m_deformMatrix = QMatrix4x4();
|
||||||
m_retiring = false;
|
emit rawDeformMatrixChanged();
|
||||||
|
updateCenteredDeformMatrix();
|
||||||
m_physicsActive = false;
|
m_physicsActive = false;
|
||||||
|
|
||||||
|
if (m_group) {
|
||||||
|
QMetaObject::invokeMethod(
|
||||||
|
this,
|
||||||
|
[this]() {
|
||||||
|
if (m_group) m_group->markDirty();
|
||||||
|
},
|
||||||
|
Qt::QueuedConnection);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
m_dm00 = m_retire00 + (1.0f - m_retire00) * s;
|
QMetaObject::invokeMethod(
|
||||||
m_dm01 = m_retire01 - m_retire01 * s;
|
this,
|
||||||
m_dm11 = m_retire11 + (1.0f - m_retire11) * s;
|
[this]() {
|
||||||
m_deformMatrix = QMatrix4x4(
|
if (m_physicsActive && m_group) m_group->markDirty();
|
||||||
m_dm00,
|
},
|
||||||
m_dm01,
|
Qt::QueuedConnection);
|
||||||
0,
|
|
||||||
0,
|
|
||||||
m_dm01,
|
|
||||||
m_dm11,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
emit rawDeformMatrixChanged();
|
|
||||||
updateCenteredDeformMatrix();
|
|
||||||
|
|
||||||
if (!m_physicsActive) return;
|
|
||||||
} else {
|
|
||||||
const float totalDelta = std::abs(m_dm00 - 1.0f) + std::abs(m_dm01) +
|
|
||||||
std::abs(m_dm11 - 1.0f);
|
|
||||||
const float totalVel =
|
|
||||||
std::abs(m_dmVel00) + std::abs(m_dmVel01) + std::abs(m_dmVel11);
|
|
||||||
|
|
||||||
if (totalDelta < 0.004f && totalVel < 0.05f) beginRetire();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QMetaObject::invokeMethod(
|
BlobShape::updatePolish();
|
||||||
this,
|
|
||||||
[this]() {
|
|
||||||
if (m_physicsActive && m_group) m_group->markDirty();
|
|
||||||
},
|
|
||||||
Qt::QueuedConnection);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobRect::beginRetire() {
|
|
||||||
m_retire00 = m_dm00;
|
|
||||||
m_retire01 = m_dm01;
|
|
||||||
m_retire11 = m_dm11;
|
|
||||||
m_dmVel00 = m_dmVel01 = m_dmVel11 = 0.0f;
|
|
||||||
m_retireElapsed.start();
|
|
||||||
m_retiring = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlobRect::updatePhysics() {
|
void BlobRect::updatePhysics() {
|
||||||
@@ -112,13 +74,6 @@ void BlobRect::updatePhysics() {
|
|||||||
|
|
||||||
const float speed = std::sqrt(velX * velX + velY * velY);
|
const float speed = std::sqrt(velX * velX + velY * velY);
|
||||||
|
|
||||||
if (m_retiring) {
|
|
||||||
if (speed > 5.0f)
|
|
||||||
m_retiring = false;
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_physicsActive) {
|
if (!m_physicsActive) {
|
||||||
if (speed < 5.0f) return;
|
if (speed < 5.0f) return;
|
||||||
m_physicsActive = true;
|
m_physicsActive = true;
|
||||||
@@ -342,8 +297,6 @@ void BlobRect::excludeCornersRemoveLast(QQmlListProperty<BlobRect>* prop) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BlobRect::checkAtRest(float speed) {
|
void BlobRect::checkAtRest(float speed) {
|
||||||
if (m_retiring) return;
|
|
||||||
|
|
||||||
constexpr float kEpsilon = 0.002f;
|
constexpr float kEpsilon = 0.002f;
|
||||||
const bool atRest =
|
const bool atRest =
|
||||||
std::abs(m_dm00 - 1.0f) < kEpsilon && std::abs(m_dm01) < kEpsilon &&
|
std::abs(m_dm00 - 1.0f) < kEpsilon && std::abs(m_dm01) < kEpsilon &&
|
||||||
@@ -351,5 +304,25 @@ void BlobRect::checkAtRest(float speed) {
|
|||||||
std::abs(m_dmVel01) < kEpsilon && std::abs(m_dmVel11) < kEpsilon &&
|
std::abs(m_dmVel01) < kEpsilon && std::abs(m_dmVel11) < kEpsilon &&
|
||||||
speed < 5.0f;
|
speed < 5.0f;
|
||||||
|
|
||||||
if (atRest) beginRetire();
|
if (atRest) {
|
||||||
|
m_dm00 = 1.0f;
|
||||||
|
m_dm01 = 0.0f;
|
||||||
|
m_dm11 = 1.0f;
|
||||||
|
m_dmVel00 = 0.0f;
|
||||||
|
m_dmVel01 = 0.0f;
|
||||||
|
m_dmVel11 = 0.0f;
|
||||||
|
m_deformMatrix = QMatrix4x4();
|
||||||
|
emit rawDeformMatrixChanged();
|
||||||
|
updateCenteredDeformMatrix();
|
||||||
|
m_physicsActive = false;
|
||||||
|
|
||||||
|
if (m_group) {
|
||||||
|
QMetaObject::invokeMethod(
|
||||||
|
this,
|
||||||
|
[this]() {
|
||||||
|
if (m_group) m_group->markDirty();
|
||||||
|
},
|
||||||
|
Qt::QueuedConnection);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ class BlobRect : public BlobShape {
|
|||||||
|
|
||||||
[[nodiscard]] qreal damping() const { return m_damping; }
|
[[nodiscard]] qreal damping() const { return m_damping; }
|
||||||
|
|
||||||
void setDamping(qreal value) {
|
void setDamping(qreal d) {
|
||||||
if (!qFuzzyCompare(m_damping, value)) {
|
if (!qFuzzyCompare(m_damping, d)) {
|
||||||
m_damping = value;
|
m_damping = d;
|
||||||
emit dampingChanged();
|
emit dampingChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,23 +108,20 @@ class BlobRect : public BlobShape {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void checkAtRest(float speed);
|
void checkAtRest(float speed);
|
||||||
void beginRetire();
|
|
||||||
|
|
||||||
|
// Physics state
|
||||||
QPointF m_prevScenePos;
|
QPointF m_prevScenePos;
|
||||||
QElapsedTimer m_elapsed;
|
QElapsedTimer m_elapsed;
|
||||||
bool m_physicsActive = false;
|
bool m_physicsActive = false;
|
||||||
bool m_hasPrevPos = false;
|
bool m_hasPrevPos = false;
|
||||||
|
|
||||||
bool m_retiring = false;
|
// Symmetric 2x2 deformation matrix components (3 independent: m00, m01,
|
||||||
QElapsedTimer m_retireElapsed;
|
// m11) Rest state is identity: m00=1, m01=0, m11=1
|
||||||
float m_retire00 = 1.0f;
|
|
||||||
float m_retire01 = 0.0f;
|
|
||||||
float m_retire11 = 1.0f;
|
|
||||||
|
|
||||||
float m_dm00 = 1.0f;
|
float m_dm00 = 1.0f;
|
||||||
float m_dm01 = 0.0f;
|
float m_dm01 = 0.0f;
|
||||||
float m_dm11 = 1.0f;
|
float m_dm11 = 1.0f;
|
||||||
|
|
||||||
|
// Spring velocities for each component
|
||||||
float m_dmVel00 = 0.0f;
|
float m_dmVel00 = 0.0f;
|
||||||
float m_dmVel01 = 0.0f;
|
float m_dmVel01 = 0.0f;
|
||||||
float m_dmVel11 = 0.0f;
|
float m_dmVel11 = 0.0f;
|
||||||
|
|||||||
@@ -1,353 +0,0 @@
|
|||||||
#include "blobrect2.hpp"
|
|
||||||
#include "blobgroup2.hpp"
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
constexpr float k_retireMs = 120.0f;
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
BlobRect2::BlobRect2(QQuickItem* parent) : BlobShape2(parent) {}
|
|
||||||
|
|
||||||
BlobRect2::~BlobRect2() {
|
|
||||||
if (m_group) m_group->removeShape(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobRect2::finishAtIdentity() {
|
|
||||||
m_dm00 = 1.0f;
|
|
||||||
m_dm01 = 0.0f;
|
|
||||||
m_dm11 = 1.0f;
|
|
||||||
m_deformMatrix = QMatrix4x4();
|
|
||||||
m_retiring = false;
|
|
||||||
m_physicsActive = false;
|
|
||||||
emit rawDeformMatrixChanged();
|
|
||||||
updateCenteredDeformMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobRect2::beginRetire() {
|
|
||||||
// The settle check would otherwise re-enter this every frame and restart the
|
|
||||||
// curve timer, so the curve never reaches t = 1.
|
|
||||||
if (m_retiring) return;
|
|
||||||
|
|
||||||
m_retire00 = m_dm00;
|
|
||||||
m_retire01 = m_dm01;
|
|
||||||
m_retire11 = m_dm11;
|
|
||||||
m_dmVel00 = m_dmVel01 = m_dmVel11 = 0.0f;
|
|
||||||
m_retireElapsed.start();
|
|
||||||
m_retiring = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobRect2::updatePhysics() {
|
|
||||||
// Shapes are data only, so the group drives physics here.
|
|
||||||
if (m_retiring) {
|
|
||||||
const float t = std::clamp(
|
|
||||||
static_cast<float>(m_retireElapsed.elapsed()) / k_retireMs,
|
|
||||||
0.0f,
|
|
||||||
1.0f);
|
|
||||||
const float s = t * t * (3.0f - 2.0f * t);
|
|
||||||
|
|
||||||
if (t >= 1.0f) {
|
|
||||||
finishAtIdentity();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_dm00 = m_retire00 + (1.0f - m_retire00) * s;
|
|
||||||
m_dm01 = m_retire01 - m_retire01 * s;
|
|
||||||
m_dm11 = m_retire11 + (1.0f - m_retire11) * s;
|
|
||||||
m_deformMatrix = QMatrix4x4(
|
|
||||||
m_dm00, m_dm01, 0, 0, m_dm01, m_dm11, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
|
|
||||||
emit rawDeformMatrixChanged();
|
|
||||||
updateCenteredDeformMatrix();
|
|
||||||
|
|
||||||
if (!m_physicsActive) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// No "not active" guard here: an inactive shape still has to be evaluated so it
|
|
||||||
// can see the panel start moving and become active. The frame loop is only kept
|
|
||||||
// alive while active, and it is requested before anything can return early —
|
|
||||||
// requesting it at the end lets a shape stop being evaluated with the matrix
|
|
||||||
// still off identity, which is what left the panel contents blurry.
|
|
||||||
if (m_physicsActive && m_group) m_group->markDirty();
|
|
||||||
|
|
||||||
const QPointF scenePos = mapToScene(QPointF(width() / 2.0, height() / 2.0));
|
|
||||||
|
|
||||||
if (!m_hasPrevPos) {
|
|
||||||
m_prevScenePos = scenePos;
|
|
||||||
m_elapsed.start();
|
|
||||||
m_hasPrevPos = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const float dt = static_cast<float>(m_elapsed.restart()) / 1000.0f;
|
|
||||||
if (dt > 0.1f || dt < 0.001f) {
|
|
||||||
m_prevScenePos = scenePos;
|
|
||||||
if (m_physicsActive) checkAtRest(0.0f);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const float velX =
|
|
||||||
static_cast<float>(scenePos.x() - m_prevScenePos.x()) / dt;
|
|
||||||
const float velY =
|
|
||||||
static_cast<float>(scenePos.y() - m_prevScenePos.y()) / dt;
|
|
||||||
m_prevScenePos = scenePos;
|
|
||||||
|
|
||||||
const float speed = std::sqrt(velX * velX + velY * velY);
|
|
||||||
|
|
||||||
if (m_retiring) {
|
|
||||||
if (speed > 5.0f)
|
|
||||||
m_retiring = false;
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_physicsActive) {
|
|
||||||
if (speed < 5.0f) return;
|
|
||||||
m_physicsActive = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const float kStretchFactor = static_cast<float>(m_deformScale);
|
|
||||||
constexpr float kMaxStretch = 0.35f;
|
|
||||||
|
|
||||||
float target00 = 1.0f;
|
|
||||||
float target01 = 0.0f;
|
|
||||||
float target11 = 1.0f;
|
|
||||||
|
|
||||||
if (speed > 5.0f) {
|
|
||||||
const float targetStretch =
|
|
||||||
1.0f + std::min(speed * kStretchFactor, kMaxStretch);
|
|
||||||
const float targetCompress = 1.0f / targetStretch;
|
|
||||||
|
|
||||||
const float cosA = velX / speed;
|
|
||||||
const float sinA = velY / speed;
|
|
||||||
const float cos2 = cosA * cosA;
|
|
||||||
const float sin2 = sinA * sinA;
|
|
||||||
const float cs = cosA * sinA;
|
|
||||||
|
|
||||||
target00 = targetStretch * cos2 + targetCompress * sin2;
|
|
||||||
target01 = (targetStretch - targetCompress) * cs;
|
|
||||||
target11 = targetStretch * sin2 + targetCompress * cos2;
|
|
||||||
}
|
|
||||||
|
|
||||||
const float kStiffness = static_cast<float>(m_stiffness);
|
|
||||||
const float kDamping = static_cast<float>(m_damping);
|
|
||||||
const float invDamp = 1.0f / (1.0f + kDamping * dt);
|
|
||||||
|
|
||||||
m_dmVel00 = (m_dmVel00 - kStiffness * (m_dm00 - target00) * dt) * invDamp;
|
|
||||||
m_dm00 += m_dmVel00 * dt;
|
|
||||||
|
|
||||||
m_dmVel01 = (m_dmVel01 - kStiffness * (m_dm01 - target01) * dt) * invDamp;
|
|
||||||
m_dm01 += m_dmVel01 * dt;
|
|
||||||
|
|
||||||
m_dmVel11 = (m_dmVel11 - kStiffness * (m_dm11 - target11) * dt) * invDamp;
|
|
||||||
m_dm11 += m_dmVel11 * dt;
|
|
||||||
|
|
||||||
m_deformMatrix = QMatrix4x4(
|
|
||||||
m_dm00, m_dm01, 0, 0, m_dm01, m_dm11, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
|
|
||||||
emit rawDeformMatrixChanged();
|
|
||||||
updateCenteredDeformMatrix();
|
|
||||||
|
|
||||||
// Start the retire as soon as the matrix is close to identity, as in v1. Waiting
|
|
||||||
// for every term to fall below kEpsilon keeps the matrix just off identity for
|
|
||||||
// longer, and the panel content is transformed by it, which reads as blur on
|
|
||||||
// text.
|
|
||||||
const float totalDelta =
|
|
||||||
std::abs(m_dm00 - 1.0f) + std::abs(m_dm01) + std::abs(m_dm11 - 1.0f);
|
|
||||||
const float totalVel =
|
|
||||||
std::abs(m_dmVel00) + std::abs(m_dmVel01) + std::abs(m_dmVel11);
|
|
||||||
// The residual is already inside the rest epsilon, so the eased curve would only
|
|
||||||
// be aborted or restarted every frame by the panel creeping. Snap instead.
|
|
||||||
if (totalDelta < 0.004f && totalVel < 0.05f) {
|
|
||||||
finishAtIdentity();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
checkAtRest(speed);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobRect2::setTopLeftRadius(qreal r) {
|
|
||||||
if (!qFuzzyCompare(m_topLeftRadius, r)) {
|
|
||||||
m_topLeftRadius = r;
|
|
||||||
emit topLeftRadiusChanged();
|
|
||||||
if (m_group) m_group->markDirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobRect2::setTopRightRadius(qreal r) {
|
|
||||||
if (!qFuzzyCompare(m_topRightRadius, r)) {
|
|
||||||
m_topRightRadius = r;
|
|
||||||
emit topRightRadiusChanged();
|
|
||||||
if (m_group) m_group->markDirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobRect2::setBottomLeftRadius(qreal r) {
|
|
||||||
if (!qFuzzyCompare(m_bottomLeftRadius, r)) {
|
|
||||||
m_bottomLeftRadius = r;
|
|
||||||
emit bottomLeftRadiusChanged();
|
|
||||||
if (m_group) m_group->markDirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobRect2::setBottomRightRadius(qreal r) {
|
|
||||||
if (!qFuzzyCompare(m_bottomRightRadius, r)) {
|
|
||||||
m_bottomRightRadius = r;
|
|
||||||
emit bottomRightRadiusChanged();
|
|
||||||
if (m_group) m_group->markDirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobRect2::cornerRadii(float out[4]) const {
|
|
||||||
const auto maxR = static_cast<float>(std::min(width(), height())) * 0.5f;
|
|
||||||
const auto base = std::min(static_cast<float>(m_radius), maxR);
|
|
||||||
out[0] = std::min(
|
|
||||||
m_topRightRadius >= 0 ? static_cast<float>(m_topRightRadius) : base,
|
|
||||||
maxR);
|
|
||||||
out[1] = std::min(
|
|
||||||
m_bottomRightRadius >= 0 ? static_cast<float>(m_bottomRightRadius)
|
|
||||||
: base,
|
|
||||||
maxR);
|
|
||||||
out[2] = std::min(
|
|
||||||
m_bottomLeftRadius >= 0 ? static_cast<float>(m_bottomLeftRadius) : base,
|
|
||||||
maxR);
|
|
||||||
out[3] = std::min(
|
|
||||||
m_topLeftRadius >= 0 ? static_cast<float>(m_topLeftRadius) : base,
|
|
||||||
maxR);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BlobRect2::isExcluded(const BlobShape2* other) const {
|
|
||||||
for (const auto& ptr : m_exclude) {
|
|
||||||
if (ptr == other) return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BlobRect2::isCornerExcluded(const BlobShape2* other) const {
|
|
||||||
for (const auto& ptr : m_excludeCorners) {
|
|
||||||
if (ptr == other) return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QQmlListProperty<BlobRect2> BlobRect2::exclude() {
|
|
||||||
return QQmlListProperty<BlobRect2>(
|
|
||||||
this,
|
|
||||||
nullptr,
|
|
||||||
&excludeAppend,
|
|
||||||
&excludeCount,
|
|
||||||
&excludeAt,
|
|
||||||
&excludeClear,
|
|
||||||
&excludeReplace,
|
|
||||||
&excludeRemoveLast);
|
|
||||||
}
|
|
||||||
|
|
||||||
QQmlListProperty<BlobRect2> BlobRect2::excludeCorners() {
|
|
||||||
return QQmlListProperty<BlobRect2>(
|
|
||||||
this,
|
|
||||||
nullptr,
|
|
||||||
&excludeCornersAppend,
|
|
||||||
&excludeCornersCount,
|
|
||||||
&excludeCornersAt,
|
|
||||||
&excludeCornersClear,
|
|
||||||
&excludeCornersReplace,
|
|
||||||
&excludeCornersRemoveLast);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobRect2::excludeAppend(
|
|
||||||
QQmlListProperty<BlobRect2>* prop, BlobRect2* rect) {
|
|
||||||
auto* self = static_cast<BlobRect2*>(prop->object);
|
|
||||||
self->m_exclude.append(rect);
|
|
||||||
if (self->m_group) self->m_group->markDirty();
|
|
||||||
emit self->excludeChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
qsizetype BlobRect2::excludeCount(QQmlListProperty<BlobRect2>* prop) {
|
|
||||||
auto* self = static_cast<BlobRect2*>(prop->object);
|
|
||||||
return self->m_exclude.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
BlobRect2* BlobRect2::excludeAt(
|
|
||||||
QQmlListProperty<BlobRect2>* prop, qsizetype index) {
|
|
||||||
auto* self = static_cast<BlobRect2*>(prop->object);
|
|
||||||
return self->m_exclude.at(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobRect2::excludeClear(QQmlListProperty<BlobRect2>* prop) {
|
|
||||||
auto* self = static_cast<BlobRect2*>(prop->object);
|
|
||||||
if (self->m_exclude.isEmpty()) return;
|
|
||||||
self->m_exclude.clear();
|
|
||||||
if (self->m_group) self->m_group->markDirty();
|
|
||||||
emit self->excludeChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobRect2::excludeReplace(
|
|
||||||
QQmlListProperty<BlobRect2>* prop, qsizetype index, BlobRect2* rect) {
|
|
||||||
auto* self = static_cast<BlobRect2*>(prop->object);
|
|
||||||
self->m_exclude[index] = rect;
|
|
||||||
if (self->m_group) self->m_group->markDirty();
|
|
||||||
emit self->excludeChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobRect2::excludeRemoveLast(QQmlListProperty<BlobRect2>* prop) {
|
|
||||||
auto* self = static_cast<BlobRect2*>(prop->object);
|
|
||||||
if (self->m_exclude.isEmpty()) return;
|
|
||||||
self->m_exclude.removeLast();
|
|
||||||
if (self->m_group) self->m_group->markDirty();
|
|
||||||
emit self->excludeChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobRect2::excludeCornersAppend(
|
|
||||||
QQmlListProperty<BlobRect2>* prop, BlobRect2* rect) {
|
|
||||||
auto* self = static_cast<BlobRect2*>(prop->object);
|
|
||||||
self->m_excludeCorners.append(rect);
|
|
||||||
if (self->m_group) self->m_group->markDirty();
|
|
||||||
emit self->excludeCornersChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
qsizetype BlobRect2::excludeCornersCount(QQmlListProperty<BlobRect2>* prop) {
|
|
||||||
auto* self = static_cast<BlobRect2*>(prop->object);
|
|
||||||
return self->m_excludeCorners.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
BlobRect2* BlobRect2::excludeCornersAt(
|
|
||||||
QQmlListProperty<BlobRect2>* prop, qsizetype index) {
|
|
||||||
auto* self = static_cast<BlobRect2*>(prop->object);
|
|
||||||
return self->m_excludeCorners.at(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobRect2::excludeCornersClear(QQmlListProperty<BlobRect2>* prop) {
|
|
||||||
auto* self = static_cast<BlobRect2*>(prop->object);
|
|
||||||
if (self->m_excludeCorners.isEmpty()) return;
|
|
||||||
self->m_excludeCorners.clear();
|
|
||||||
if (self->m_group) self->m_group->markDirty();
|
|
||||||
emit self->excludeCornersChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobRect2::excludeCornersReplace(
|
|
||||||
QQmlListProperty<BlobRect2>* prop, qsizetype index, BlobRect2* rect) {
|
|
||||||
auto* self = static_cast<BlobRect2*>(prop->object);
|
|
||||||
self->m_excludeCorners[index] = rect;
|
|
||||||
if (self->m_group) self->m_group->markDirty();
|
|
||||||
emit self->excludeCornersChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobRect2::excludeCornersRemoveLast(QQmlListProperty<BlobRect2>* prop) {
|
|
||||||
auto* self = static_cast<BlobRect2*>(prop->object);
|
|
||||||
if (self->m_excludeCorners.isEmpty()) return;
|
|
||||||
self->m_excludeCorners.removeLast();
|
|
||||||
if (self->m_group) self->m_group->markDirty();
|
|
||||||
emit self->excludeCornersChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobRect2::checkAtRest(float speed) {
|
|
||||||
if (m_retiring) return;
|
|
||||||
|
|
||||||
constexpr float kEpsilon = 0.002f;
|
|
||||||
const bool atRest =
|
|
||||||
std::abs(m_dm00 - 1.0f) < kEpsilon && std::abs(m_dm01) < kEpsilon &&
|
|
||||||
std::abs(m_dm11 - 1.0f) < kEpsilon && std::abs(m_dmVel00) < kEpsilon &&
|
|
||||||
std::abs(m_dmVel01) < kEpsilon && std::abs(m_dmVel11) < kEpsilon &&
|
|
||||||
speed < 5.0f;
|
|
||||||
|
|
||||||
if (atRest) beginRetire();
|
|
||||||
}
|
|
||||||
@@ -1,191 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "blobshape2.hpp"
|
|
||||||
|
|
||||||
#include <qelapsedtimer.h>
|
|
||||||
#include <qpointer.h>
|
|
||||||
#include <qqmlengine.h>
|
|
||||||
#include <qqmllist.h>
|
|
||||||
|
|
||||||
class BlobRect2 : public BlobShape2 {
|
|
||||||
Q_OBJECT
|
|
||||||
QML_ELEMENT
|
|
||||||
Q_PROPERTY(
|
|
||||||
qreal stiffness READ stiffness WRITE setStiffness NOTIFY
|
|
||||||
stiffnessChanged)
|
|
||||||
Q_PROPERTY(qreal damping READ damping WRITE setDamping NOTIFY dampingChanged)
|
|
||||||
Q_PROPERTY(
|
|
||||||
qreal deformScale READ deformScale WRITE setDeformScale NOTIFY
|
|
||||||
deformScaleChanged)
|
|
||||||
Q_PROPERTY(
|
|
||||||
QQmlListProperty<BlobRect2> exclude READ exclude NOTIFY excludeChanged)
|
|
||||||
Q_PROPERTY(
|
|
||||||
QQmlListProperty<BlobRect2> excludeCorners READ excludeCorners NOTIFY
|
|
||||||
excludeCornersChanged)
|
|
||||||
Q_PROPERTY(
|
|
||||||
bool atRestOverride READ atRestOverride WRITE setAtRestOverride NOTIFY
|
|
||||||
atRestOverrideChanged)
|
|
||||||
Q_PROPERTY(
|
|
||||||
qreal topLeftRadius READ topLeftRadius WRITE setTopLeftRadius NOTIFY
|
|
||||||
topLeftRadiusChanged)
|
|
||||||
Q_PROPERTY(
|
|
||||||
qreal topRightRadius READ topRightRadius WRITE setTopRightRadius NOTIFY
|
|
||||||
topRightRadiusChanged)
|
|
||||||
Q_PROPERTY(
|
|
||||||
qreal bottomLeftRadius READ bottomLeftRadius WRITE setBottomLeftRadius
|
|
||||||
NOTIFY bottomLeftRadiusChanged)
|
|
||||||
Q_PROPERTY(
|
|
||||||
qreal bottomRightRadius READ bottomRightRadius WRITE
|
|
||||||
setBottomRightRadius NOTIFY bottomRightRadiusChanged)
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit BlobRect2(QQuickItem* parent = nullptr);
|
|
||||||
~BlobRect2() override;
|
|
||||||
|
|
||||||
[[nodiscard]] qreal stiffness() const { return m_stiffness; }
|
|
||||||
|
|
||||||
void setStiffness(qreal s) {
|
|
||||||
if (!qFuzzyCompare(m_stiffness, s)) {
|
|
||||||
m_stiffness = s;
|
|
||||||
emit stiffnessChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] qreal damping() const { return m_damping; }
|
|
||||||
|
|
||||||
void setDamping(qreal value) {
|
|
||||||
if (!qFuzzyCompare(m_damping, value)) {
|
|
||||||
m_damping = value;
|
|
||||||
emit dampingChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] qreal deformScale() const { return m_deformScale; }
|
|
||||||
|
|
||||||
void setDeformScale(qreal s) {
|
|
||||||
if (!qFuzzyCompare(m_deformScale, s)) {
|
|
||||||
m_deformScale = s;
|
|
||||||
emit deformScaleChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QQmlListProperty<BlobRect2> exclude();
|
|
||||||
QQmlListProperty<BlobRect2> excludeCorners();
|
|
||||||
|
|
||||||
[[nodiscard]] bool atRestOverride() const { return m_atRestOverride; }
|
|
||||||
|
|
||||||
void setAtRestOverride(bool o) {
|
|
||||||
if (m_atRestOverride == o) return;
|
|
||||||
m_atRestOverride = o;
|
|
||||||
emit atRestOverrideChanged();
|
|
||||||
if (m_group) m_group->markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isExcluded(const BlobShape2* other) const override;
|
|
||||||
bool isCornerExcluded(const BlobShape2* other) const override;
|
|
||||||
// The shape that is pushing is the one that can shape the bar edge. A shape that is
|
|
||||||
// retiring still counts, because the retire curve is still moving the surface.
|
|
||||||
// atRestOverride keeps the shape in the group's data even at rest; when it is false
|
|
||||||
// the actual spring state decides, so it is not an override of the state itself.
|
|
||||||
bool isMoving() const override {
|
|
||||||
return m_atRestOverride || m_physicsActive || m_retiring;
|
|
||||||
}
|
|
||||||
void cornerRadii(float out[4]) const override;
|
|
||||||
|
|
||||||
[[nodiscard]] qreal topLeftRadius() const { return m_topLeftRadius; }
|
|
||||||
|
|
||||||
void setTopLeftRadius(qreal r);
|
|
||||||
|
|
||||||
[[nodiscard]] qreal topRightRadius() const { return m_topRightRadius; }
|
|
||||||
|
|
||||||
void setTopRightRadius(qreal r);
|
|
||||||
|
|
||||||
[[nodiscard]] qreal bottomLeftRadius() const { return m_bottomLeftRadius; }
|
|
||||||
|
|
||||||
void setBottomLeftRadius(qreal r);
|
|
||||||
|
|
||||||
[[nodiscard]] qreal bottomRightRadius() const {
|
|
||||||
return m_bottomRightRadius;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setBottomRightRadius(qreal r);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void stiffnessChanged();
|
|
||||||
void dampingChanged();
|
|
||||||
void deformScaleChanged();
|
|
||||||
void excludeChanged();
|
|
||||||
void excludeCornersChanged();
|
|
||||||
void atRestOverrideChanged();
|
|
||||||
void topLeftRadiusChanged();
|
|
||||||
void topRightRadiusChanged();
|
|
||||||
void bottomLeftRadiusChanged();
|
|
||||||
void bottomRightRadiusChanged();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void updatePhysics() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void checkAtRest(float speed);
|
|
||||||
void beginRetire();
|
|
||||||
void finishAtIdentity();
|
|
||||||
|
|
||||||
// Physics state
|
|
||||||
QPointF m_prevScenePos;
|
|
||||||
QElapsedTimer m_elapsed;
|
|
||||||
bool m_physicsActive = false;
|
|
||||||
bool m_hasPrevPos = false;
|
|
||||||
|
|
||||||
// Set from QML. Keeps the shape in the group's data while it is at rest; when it is
|
|
||||||
// false the spring state decides on its own.
|
|
||||||
bool m_atRestOverride = false;
|
|
||||||
|
|
||||||
bool m_retiring = false;
|
|
||||||
QElapsedTimer m_retireElapsed;
|
|
||||||
float m_retire00 = 1.0f;
|
|
||||||
float m_retire01 = 0.0f;
|
|
||||||
float m_retire11 = 1.0f;
|
|
||||||
|
|
||||||
// Symmetric 2x2 deformation matrix components (3 independent: m00, m01,
|
|
||||||
// m11) Rest state is identity: m00=1, m01=0, m11=1
|
|
||||||
float m_dm00 = 1.0f;
|
|
||||||
float m_dm01 = 0.0f;
|
|
||||||
float m_dm11 = 1.0f;
|
|
||||||
|
|
||||||
// Spring velocities for each component
|
|
||||||
float m_dmVel00 = 0.0f;
|
|
||||||
float m_dmVel01 = 0.0f;
|
|
||||||
float m_dmVel11 = 0.0f;
|
|
||||||
|
|
||||||
qreal m_stiffness = 200.0;
|
|
||||||
qreal m_damping = 16.0;
|
|
||||||
qreal m_deformScale = 0.0005;
|
|
||||||
|
|
||||||
qreal m_topLeftRadius = -1;
|
|
||||||
qreal m_topRightRadius = -1;
|
|
||||||
qreal m_bottomLeftRadius = -1;
|
|
||||||
qreal m_bottomRightRadius = -1;
|
|
||||||
|
|
||||||
QList<QPointer<BlobRect2>> m_exclude;
|
|
||||||
QList<QPointer<BlobRect2>> m_excludeCorners;
|
|
||||||
|
|
||||||
static void excludeAppend(
|
|
||||||
QQmlListProperty<BlobRect2>* prop, BlobRect2* rect);
|
|
||||||
static qsizetype excludeCount(QQmlListProperty<BlobRect2>* prop);
|
|
||||||
static BlobRect2* excludeAt(
|
|
||||||
QQmlListProperty<BlobRect2>* prop, qsizetype index);
|
|
||||||
static void excludeClear(QQmlListProperty<BlobRect2>* prop);
|
|
||||||
static void excludeReplace(
|
|
||||||
QQmlListProperty<BlobRect2>* prop, qsizetype index, BlobRect2* rect);
|
|
||||||
static void excludeRemoveLast(QQmlListProperty<BlobRect2>* prop);
|
|
||||||
|
|
||||||
static void excludeCornersAppend(
|
|
||||||
QQmlListProperty<BlobRect2>* prop, BlobRect2* rect);
|
|
||||||
static qsizetype excludeCornersCount(QQmlListProperty<BlobRect2>* prop);
|
|
||||||
static BlobRect2* excludeCornersAt(
|
|
||||||
QQmlListProperty<BlobRect2>* prop, qsizetype index);
|
|
||||||
static void excludeCornersClear(QQmlListProperty<BlobRect2>* prop);
|
|
||||||
static void excludeCornersReplace(
|
|
||||||
QQmlListProperty<BlobRect2>* prop, qsizetype index, BlobRect2* rect);
|
|
||||||
static void excludeCornersRemoveLast(QQmlListProperty<BlobRect2>* prop);
|
|
||||||
};
|
|
||||||
@@ -168,6 +168,8 @@ void BlobShape::updatePolish() {
|
|||||||
|
|
||||||
if (other->width() <= 0 || other->height() <= 0) continue;
|
if (other->width() <= 0 || other->height() <= 0) continue;
|
||||||
|
|
||||||
|
if (isExcluded(other)) continue;
|
||||||
|
|
||||||
const QPointF otherScene = other->mapToScene(QPointF(0, 0));
|
const QPointF otherScene = other->mapToScene(QPointF(0, 0));
|
||||||
|
|
||||||
bool include = false;
|
bool include = false;
|
||||||
@@ -192,7 +194,7 @@ void BlobShape::updatePolish() {
|
|||||||
|
|
||||||
const QMatrix4x4& dm = other->m_deformMatrix;
|
const QMatrix4x4& dm = other->m_deformMatrix;
|
||||||
const float a = dm(0, 0), b = dm(1, 0);
|
const float a = dm(0, 0), b = dm(1, 0);
|
||||||
const float c = dm(0, 1), e = dm(1, 1);
|
const float c = dm(0, 1), d = dm(1, 1);
|
||||||
|
|
||||||
BlobRectData r;
|
BlobRectData r;
|
||||||
r.cx = static_cast<float>(otherScene.x() + other->width() / 2.0);
|
r.cx = static_cast<float>(otherScene.x() + other->width() / 2.0);
|
||||||
@@ -203,19 +205,19 @@ void BlobShape::updatePolish() {
|
|||||||
r.offsetX = dm(0, 3);
|
r.offsetX = dm(0, 3);
|
||||||
r.offsetY = dm(1, 3);
|
r.offsetY = dm(1, 3);
|
||||||
|
|
||||||
const float det = a * e - c * b;
|
const float det = a * d - c * b;
|
||||||
const float invDet = std::abs(det) > 1e-6f ? 1.0f / det : 1.0f;
|
const float invDet = std::abs(det) > 1e-6f ? 1.0f / det : 1.0f;
|
||||||
r.invDeform[0] = e * invDet;
|
r.invDeform[0] = d * invDet;
|
||||||
r.invDeform[1] = -b * invDet;
|
r.invDeform[1] = -b * invDet;
|
||||||
r.invDeform[2] = -c * invDet;
|
r.invDeform[2] = -c * invDet;
|
||||||
r.invDeform[3] = a * invDet;
|
r.invDeform[3] = a * invDet;
|
||||||
|
|
||||||
const float halfTr = 0.5f * (a + e);
|
const float halfTr = 0.5f * (a + d);
|
||||||
const float halfDiff = 0.5f * (a - e);
|
const float halfDiff = 0.5f * (a - d);
|
||||||
r.minEig = halfTr - std::sqrt(halfDiff * halfDiff + c * c);
|
r.minEig = halfTr - std::sqrt(halfDiff * halfDiff + c * c);
|
||||||
|
|
||||||
r.screenHalfX = std::abs(a) * r.hw + std::abs(c) * r.hh;
|
r.screenHalfX = std::abs(a) * r.hw + std::abs(c) * r.hh;
|
||||||
r.screenHalfY = std::abs(b) * r.hw + std::abs(e) * r.hh;
|
r.screenHalfY = std::abs(b) * r.hw + std::abs(d) * r.hh;
|
||||||
|
|
||||||
m_cachedRects.append(r);
|
m_cachedRects.append(r);
|
||||||
rectShapes.append(other);
|
rectShapes.append(other);
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
#include "blobshape2.hpp"
|
|
||||||
#include "blobgroup2.hpp"
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
BlobShape2::BlobShape2(QQuickItem* parent) : QQuickItem(parent) {}
|
|
||||||
|
|
||||||
void BlobShape2::setGroup(BlobGroup2* g) {
|
|
||||||
if (m_group == g) return;
|
|
||||||
if (m_group && isComponentComplete()) unregisterFromGroup();
|
|
||||||
m_group = g;
|
|
||||||
if (m_group && isComponentComplete()) registerWithGroup();
|
|
||||||
emit groupChanged();
|
|
||||||
if (m_group) m_group->markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobShape2::setRadius(qreal r) {
|
|
||||||
if (qFuzzyCompare(m_radius, r)) return;
|
|
||||||
m_radius = r;
|
|
||||||
emit radiusChanged();
|
|
||||||
if (m_group) m_group->markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobShape2::componentComplete() {
|
|
||||||
QQuickItem::componentComplete();
|
|
||||||
if (m_group) registerWithGroup();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobShape2::geometryChange(
|
|
||||||
const QRectF& newGeometry, const QRectF& oldGeometry) {
|
|
||||||
QQuickItem::geometryChange(newGeometry, oldGeometry);
|
|
||||||
updateCenteredDeformMatrix();
|
|
||||||
|
|
||||||
// One draw covers the whole group, so any shape change is a group change.
|
|
||||||
if (m_group) m_group->markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobShape2::updateCenteredDeformMatrix() {
|
|
||||||
const auto cx = static_cast<float>(width()) * 0.5f;
|
|
||||||
const auto cy = static_cast<float>(height()) * 0.5f;
|
|
||||||
QMatrix4x4 result;
|
|
||||||
result.translate(cx, cy);
|
|
||||||
result *= m_deformMatrix;
|
|
||||||
result.translate(-cx, -cy);
|
|
||||||
if (m_centeredDeformMatrix != result) {
|
|
||||||
m_centeredDeformMatrix = result;
|
|
||||||
emit deformMatrixChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobShape2::cornerRadii(float out[4]) const {
|
|
||||||
const auto maxR = static_cast<float>(std::min(width(), height())) * 0.5f;
|
|
||||||
const auto r = std::min(static_cast<float>(m_radius), maxR);
|
|
||||||
out[0] = r;
|
|
||||||
out[1] = r;
|
|
||||||
out[2] = r;
|
|
||||||
out[3] = r;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobShape2::registerWithGroup() {
|
|
||||||
if (m_group) m_group->addShape(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlobShape2::unregisterFromGroup() {
|
|
||||||
if (m_group) m_group->removeShape(this);
|
|
||||||
}
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "blobgroup2.hpp"
|
|
||||||
|
|
||||||
#include <qmatrix4x4.h>
|
|
||||||
#include <qquickitem.h>
|
|
||||||
|
|
||||||
class BlobGroup2;
|
|
||||||
|
|
||||||
// Data-only shape.
|
|
||||||
//
|
|
||||||
// The group draws a single node for the whole group, so a shape here contributes
|
|
||||||
// only what the shader needs: position, radii, exclusion, physics. A shape does
|
|
||||||
// not create a render node, so no pixel can be evaluated by one shape and missed
|
|
||||||
// by another.
|
|
||||||
class BlobShape2 : public QQuickItem {
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(BlobGroup2* group READ group WRITE setGroup NOTIFY groupChanged)
|
|
||||||
Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged)
|
|
||||||
Q_PROPERTY(
|
|
||||||
QMatrix4x4 deformMatrix READ deformMatrix NOTIFY deformMatrixChanged)
|
|
||||||
Q_PROPERTY(
|
|
||||||
QMatrix4x4 rawDeformMatrix READ rawDeformMatrix NOTIFY
|
|
||||||
rawDeformMatrixChanged)
|
|
||||||
|
|
||||||
friend class BlobGroup2;
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit BlobShape2(QQuickItem* parent = nullptr);
|
|
||||||
~BlobShape2() override = default;
|
|
||||||
|
|
||||||
[[nodiscard]] BlobGroup2* group() const { return m_group; }
|
|
||||||
|
|
||||||
void setGroup(BlobGroup2* g);
|
|
||||||
|
|
||||||
[[nodiscard]] qreal radius() const { return m_radius; }
|
|
||||||
|
|
||||||
void setRadius(qreal r);
|
|
||||||
|
|
||||||
[[nodiscard]] QMatrix4x4 deformMatrix() const {
|
|
||||||
return m_centeredDeformMatrix;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] QMatrix4x4 rawDeformMatrix() const { return m_deformMatrix; }
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void groupChanged();
|
|
||||||
void radiusChanged();
|
|
||||||
void deformMatrixChanged();
|
|
||||||
void rawDeformMatrixChanged();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void componentComplete() override;
|
|
||||||
void geometryChange(
|
|
||||||
const QRectF& newGeometry, const QRectF& oldGeometry) override;
|
|
||||||
|
|
||||||
virtual bool isExcluded(const BlobShape2*) const { return false; }
|
|
||||||
|
|
||||||
// Whether this shape is part of the group's data. Only a pushing shape is, so a shape
|
|
||||||
// at rest has no part in the draw. BlobRect2 also honours the QML atRestOverride.
|
|
||||||
virtual bool isMoving() const { return false; }
|
|
||||||
|
|
||||||
virtual bool isCornerExcluded(const BlobShape2* /*other*/) const {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void cornerRadii(float out[4]) const;
|
|
||||||
|
|
||||||
// Called by the group when it rebuilds the shared data, once per frame.
|
|
||||||
virtual void updatePhysics() {}
|
|
||||||
|
|
||||||
virtual void registerWithGroup();
|
|
||||||
virtual void unregisterFromGroup();
|
|
||||||
void updateCenteredDeformMatrix();
|
|
||||||
|
|
||||||
BlobGroup2* m_group = nullptr;
|
|
||||||
qreal m_radius = 0;
|
|
||||||
QMatrix4x4 m_deformMatrix; // identity by default
|
|
||||||
QMatrix4x4 m_centeredDeformMatrix;
|
|
||||||
};
|
|
||||||
@@ -19,8 +19,6 @@ layout(std140, binding = 0) uniform buf {
|
|||||||
vec4 invertedOuter;
|
vec4 invertedOuter;
|
||||||
vec4 invertedInner;
|
vec4 invertedInner;
|
||||||
vec4 rectData[80];
|
vec4 rectData[80];
|
||||||
float shadowRadius;
|
|
||||||
vec4 shadowColor;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
float sdRoundedBox(vec2 p, vec2 center, vec2 halfSize, float radius) {
|
float sdRoundedBox(vec2 p, vec2 center, vec2 halfSize, float radius) {
|
||||||
@@ -65,10 +63,9 @@ float smaxSharpA(float a, float b, float k) {
|
|||||||
void main() {
|
void main() {
|
||||||
vec2 pixel = vec2(paddedX, paddedY) + qt_TexCoord0 * vec2(paddedW, paddedH);
|
vec2 pixel = vec2(paddedX, paddedY) + qt_TexCoord0 * vec2(paddedW, paddedH);
|
||||||
|
|
||||||
// Phase 1: compute per-rect SDF, and track which rect owns the pixel for the
|
// Phase 1: compute per-rect SDF, track owner. We can't smin yet because
|
||||||
// per-shape path (BlobGroup). The single group draw (BlobGroup2) has no owner:
|
// excluded pairs need to skip the smooth blend, which requires pairwise pass
|
||||||
// myIndex stays -2, so the ownership test is skipped and this pass writes every
|
// below.
|
||||||
// pixel the quad covers. Excluded pairs still need the pairwise pass below.
|
|
||||||
float dArr[16];
|
float dArr[16];
|
||||||
int owner = -2;
|
int owner = -2;
|
||||||
float minDist = 1e10;
|
float minDist = 1e10;
|
||||||
@@ -85,10 +82,8 @@ void main() {
|
|||||||
// Offset center for asymmetric deformation
|
// Offset center for asymmetric deformation
|
||||||
vec2 center = rect.xy + props.yz;
|
vec2 center = rect.xy + props.yz;
|
||||||
|
|
||||||
// AABB early-out: skip rects far from this pixel. The reach has to include the
|
// AABB early-out: skip rects far from this pixel
|
||||||
// shadow, otherwise a rect that is only inside the shadow range would be
|
vec2 extent = sh.xy + vec2(smoothFactor * 1.5);
|
||||||
// skipped and its distance could not be used.
|
|
||||||
vec2 extent = sh.xy + vec2(smoothFactor * 1.5 + shadowRadius);
|
|
||||||
if (abs(pixel.x - center.x) > extent.x ||
|
if (abs(pixel.x - center.x) > extent.x ||
|
||||||
abs(pixel.y - center.y) > extent.y) {
|
abs(pixel.y - center.y) > extent.y) {
|
||||||
dArr[i] = 1e10;
|
dArr[i] = 1e10;
|
||||||
@@ -256,39 +251,14 @@ void main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A pixel this far from every rect cannot have a value, so it is not written.
|
// Each renderer only outputs pixels it owns, but allow rendering
|
||||||
// The one-unit margin keeps the outermost pixels of the quad out of the AA: their
|
// blend zones to prevent gaps (mergedSdf < smoothFactor means in blend)
|
||||||
// derivatives are undefined (the quad neighbour is outside the primitive), which
|
// myIndex == -1: inverted rect renders border-owned pixels
|
||||||
// is what drew a line along the coverage edge.
|
// myIndex >= 0: individual rect renders its owned pixels
|
||||||
float reach = max(smoothFactor, shadowRadius);
|
if (owner != myIndex && mergedSdf > smoothFactor)
|
||||||
if (mergedSdf > reach - 1.0)
|
|
||||||
discard;
|
discard;
|
||||||
|
|
||||||
// Only the owner writes a pixel, which is what makes the per-shape path look
|
float fw = fwidth(mergedSdf);
|
||||||
// like one surface: qt_Opacity is applied once per pixel instead of once per
|
float alpha = 1.0 - smoothstep(-fw, fw, mergedSdf);
|
||||||
// overlapping draw. The single group draw has no owner (myIndex == -2), so the
|
fragColor = vec4(color.rgb * alpha, alpha) * qt_Opacity;
|
||||||
// test is skipped and the value below is the only value a pixel can have.
|
|
||||||
if (myIndex >= -1 && owner != myIndex)
|
|
||||||
discard;
|
|
||||||
|
|
||||||
// Fixed-width AA: fwidth is capped at one unit, so a bad derivative near the quad
|
|
||||||
// boundary cannot make a wide edge.
|
|
||||||
float fw = min(fwidth(mergedSdf), 1.0);
|
|
||||||
float materialAlpha = 1.0 - smoothstep(-fw, fw, mergedSdf);
|
|
||||||
|
|
||||||
// Phase 2: the shadow, as a distance falloff from the merged surface. The
|
|
||||||
// quadratic reaches zero with zero slope at its outer edge, so that edge needs no
|
|
||||||
// AA of its own. Only the single group draw writes a shadow: in the per-shape
|
|
||||||
// path overlapping draws would darken the same area twice.
|
|
||||||
float shadowAlpha = 0.0;
|
|
||||||
if (shadowRadius > 0.0 && myIndex == -2) {
|
|
||||||
float t = clamp(mergedSdf / shadowRadius, 0.0, 1.0);
|
|
||||||
shadowAlpha = (1.0 - t) * (1.0 - t) * shadowColor.a;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Material over shadow, premultiplied.
|
|
||||||
float totalAlpha = materialAlpha + shadowAlpha * (1.0 - materialAlpha);
|
|
||||||
vec3 rgb = color.rgb * materialAlpha
|
|
||||||
+ shadowColor.rgb * shadowAlpha * (1.0 - materialAlpha);
|
|
||||||
fragColor = vec4(rgb, totalAlpha) * qt_Opacity;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,16 +4,14 @@ qml_module(ZShell-components
|
|||||||
lazylistview.hpp lazylistview.cpp
|
lazylistview.hpp lazylistview.cpp
|
||||||
chatlistview.hpp chatlistview.cpp
|
chatlistview.hpp chatlistview.cpp
|
||||||
wavyline.hpp wavyline.cpp
|
wavyline.hpp wavyline.cpp
|
||||||
wavylinerenderer.hpp wavylinerenderer.cpp
|
|
||||||
buttonrow.hpp buttonrow.cpp
|
buttonrow.hpp buttonrow.cpp
|
||||||
carouselview.hpp carouselview.cpp
|
carouselview.hpp carouselview.cpp
|
||||||
|
wheelinverter.hpp
|
||||||
sparklinecontent.hpp sparklinecontent.cpp
|
sparklinecontent.hpp sparklinecontent.cpp
|
||||||
sparklineitem.hpp sparklineitem.cpp
|
sparklineitem.hpp sparklineitem.cpp
|
||||||
sparklinesceneitem.hpp sparklinesceneitem.cpp
|
sparklinesceneitem.hpp sparklinesceneitem.cpp
|
||||||
wheelinverter.hpp
|
|
||||||
LIBRARIES
|
LIBRARIES
|
||||||
Qt::Quick
|
Qt::Quick
|
||||||
Qt::QuickPrivate
|
Qt::QuickPrivate
|
||||||
Qt::CanvasPainter
|
|
||||||
ZShell-internal
|
ZShell-internal
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ void CarouselView::setModel(const QVariantList& m) {
|
|||||||
|
|
||||||
emit modelChanged();
|
emit modelChanged();
|
||||||
|
|
||||||
const int newCount = static_cast<int>(m_model.size());
|
const int newCount = m_model.size();
|
||||||
|
|
||||||
if (newCount == 0) {
|
if (newCount == 0) {
|
||||||
m_currentRealIndex = -1;
|
m_currentRealIndex = -1;
|
||||||
@@ -647,7 +647,7 @@ qreal CarouselView::sampleSize(qreal childLoc) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int CarouselView::realIndexOf(int virtualIndex) const {
|
int CarouselView::realIndexOf(int virtualIndex) const {
|
||||||
const int count = static_cast<int>(m_model.size());
|
const int count = m_model.size();
|
||||||
|
|
||||||
if (count == 0) return -1;
|
if (count == 0) return -1;
|
||||||
|
|
||||||
@@ -668,7 +668,7 @@ qreal CarouselView::snapTargetX(qreal x) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CarouselView::wrapContentIfNeeded() {
|
void CarouselView::wrapContentIfNeeded() {
|
||||||
const int count = static_cast<int>(m_model.size());
|
const int count = m_model.size();
|
||||||
|
|
||||||
if (count == 0) return;
|
if (count == 0) return;
|
||||||
|
|
||||||
@@ -707,7 +707,7 @@ void CarouselView::wrapContentIfNeeded() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CarouselView::updateCurrentIndexFromContentX(bool emitPreview) {
|
void CarouselView::updateCurrentIndexFromContentX(bool emitPreview) {
|
||||||
const int count = static_cast<int>(m_model.size());
|
const int count = m_model.size();
|
||||||
|
|
||||||
if (count == 0) return;
|
if (count == 0) return;
|
||||||
|
|
||||||
@@ -856,8 +856,8 @@ void CarouselView::positionSlot(const Slot& slot) const {
|
|||||||
return rightIndex == n ? m_arrangement.outerSpacing : m_itemSpacing;
|
return rightIndex == n ? m_arrangement.outerSpacing : m_itemSpacing;
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto leftGap = [this, n](int gapIndex) {
|
const auto leftGap = [this, n](int leftIndex) {
|
||||||
return gapIndex == -n ? m_arrangement.outerSpacing : m_itemSpacing;
|
return leftIndex == -n ? m_arrangement.outerSpacing : m_itemSpacing;
|
||||||
};
|
};
|
||||||
|
|
||||||
qreal center = 0;
|
qreal center = 0;
|
||||||
@@ -974,7 +974,7 @@ void CarouselView::releaseAllItems() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CarouselView::relayout() {
|
void CarouselView::relayout() {
|
||||||
const int count = static_cast<int>(m_model.size());
|
const int count = m_model.size();
|
||||||
|
|
||||||
if (count == 0 || width() <= 0 || m_focalWidth <= 0) {
|
if (count == 0 || width() <= 0 || m_focalWidth <= 0) {
|
||||||
for (Slot& s : m_slots) {
|
for (Slot& s : m_slots) {
|
||||||
@@ -1038,7 +1038,7 @@ void CarouselView::relayout() {
|
|||||||
m_slots.append(Slot{});
|
m_slots.append(Slot{});
|
||||||
slotUsedThisPass.append(false);
|
slotUsedThisPass.append(false);
|
||||||
|
|
||||||
freeSlot = static_cast<int>(m_slots.size()) - 1;
|
freeSlot = m_slots.size() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSlotContent(m_slots[freeSlot], v);
|
updateSlotContent(m_slots[freeSlot], v);
|
||||||
@@ -1092,7 +1092,7 @@ void CarouselView::snapToNearest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CarouselView::goToIndex(int realIndex) {
|
void CarouselView::goToIndex(int realIndex) {
|
||||||
const int count = static_cast<int>(m_model.size());
|
const int count = m_model.size();
|
||||||
|
|
||||||
if (count == 0) return;
|
if (count == 0) return;
|
||||||
|
|
||||||
@@ -1126,7 +1126,7 @@ void CarouselView::decrementCurrentIndex() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CarouselView::centerInstantlyOnReal(int realIndex) {
|
void CarouselView::centerInstantlyOnReal(int realIndex) {
|
||||||
const int count = static_cast<int>(m_model.size());
|
const int count = m_model.size();
|
||||||
|
|
||||||
if (count == 0) return;
|
if (count == 0) return;
|
||||||
|
|
||||||
@@ -1220,7 +1220,7 @@ qreal CarouselView::sampledVelocity() const {
|
|||||||
const VelocitySample& oldest = m_velocitySamples.first();
|
const VelocitySample& oldest = m_velocitySamples.first();
|
||||||
const VelocitySample& newest = m_velocitySamples.last();
|
const VelocitySample& newest = m_velocitySamples.last();
|
||||||
|
|
||||||
const qreal dt = static_cast<qreal>(newest.t - oldest.t);
|
const qreal dt = newest.t - oldest.t;
|
||||||
|
|
||||||
if (dt < 8) return 0;
|
if (dt < 8) return 0;
|
||||||
|
|
||||||
|
|||||||
@@ -252,6 +252,8 @@ int ChatListView::count() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ChatListView::event(QEvent* e) {
|
bool ChatListView::event(QEvent* e) {
|
||||||
|
// qDebug() << "ChatListView::event() runs";
|
||||||
|
|
||||||
return QQuickItem::event(e);
|
return QQuickItem::event(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,6 +366,7 @@ void ChatListView::updatePolish() {
|
|||||||
m_animateY = false;
|
m_animateY = false;
|
||||||
const int layoutSize = static_cast<int>(m_layout.size());
|
const int layoutSize = static_cast<int>(m_layout.size());
|
||||||
const qint64 now = m_clock.elapsed();
|
const qint64 now = m_clock.elapsed();
|
||||||
|
bool wrote = false;
|
||||||
for (auto& entry : m_delegates) {
|
for (auto& entry : m_delegates) {
|
||||||
if (!entry.item || entry.pendingRemoval || entry.pendingInsert)
|
if (!entry.item || entry.pendingRemoval || entry.pendingInsert)
|
||||||
continue;
|
continue;
|
||||||
@@ -394,6 +397,7 @@ void ChatListView::updatePolish() {
|
|||||||
entry.item->setY(target);
|
entry.item->setY(target);
|
||||||
entry.hasPropY = false;
|
entry.hasPropY = false;
|
||||||
}
|
}
|
||||||
|
wrote = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
applyAnchor();
|
applyAnchor();
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ void SparklineContent::setLine2(internal::CircularBuffer* buffer) {
|
|||||||
|
|
||||||
void SparklineContent::connectBuffer(internal::CircularBuffer* buffer) {
|
void SparklineContent::connectBuffer(internal::CircularBuffer* buffer) {
|
||||||
if (!buffer) return;
|
if (!buffer) return;
|
||||||
|
// New data, or the buffer's own smoothingRadius changed (it re-emits
|
||||||
|
// valuesChanged in that case too) -> geometry is stale.
|
||||||
connect(
|
connect(
|
||||||
buffer,
|
buffer,
|
||||||
&internal::CircularBuffer::valuesChanged,
|
&internal::CircularBuffer::valuesChanged,
|
||||||
@@ -65,7 +67,7 @@ void SparklineContent::connectBuffer(internal::CircularBuffer* buffer) {
|
|||||||
void SparklineContent::setLine1Color(const QColor& color) {
|
void SparklineContent::setLine1Color(const QColor& color) {
|
||||||
if (m_line1Color == color) return;
|
if (m_line1Color == color) return;
|
||||||
m_line1Color = color;
|
m_line1Color = color;
|
||||||
update();
|
update(); // visual-only, no geometry rebuild needed
|
||||||
}
|
}
|
||||||
|
|
||||||
void SparklineContent::setLine2Color(const QColor& color) {
|
void SparklineContent::setLine2Color(const QColor& color) {
|
||||||
@@ -171,7 +173,7 @@ SparklineContent::LineGeometry SparklineContent::buildGeometry(
|
|||||||
if (m_curveSmoothing && points.size() > 2) {
|
if (m_curveSmoothing && points.size() > 2) {
|
||||||
const qreal tension = 1.0;
|
const qreal tension = 1.0;
|
||||||
const qreal k = tension / 6.0;
|
const qreal k = tension / 6.0;
|
||||||
const int n = static_cast<int>(points.size());
|
const int n = points.size();
|
||||||
|
|
||||||
for (int i = 0; i < n - 1; ++i) {
|
for (int i = 0; i < n - 1; ++i) {
|
||||||
const QPointF& p0 = points[qMax(i - 1, 0)];
|
const QPointF& p0 = points[qMax(i - 1, 0)];
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ SparklineSceneItem::LineSample SparklineSceneItem::buildSample(
|
|||||||
points.reserve(len);
|
points.reserve(len);
|
||||||
|
|
||||||
for (int i = 0; i < len; ++i) {
|
for (int i = 0; i < len; ++i) {
|
||||||
|
// Already smoothed once, incrementally, by the buffer itself.
|
||||||
const qreal value =
|
const qreal value =
|
||||||
qBound<qreal>(0.0, buffer->smoothedAt(i), m_maxValue);
|
qBound<qreal>(0.0, buffer->smoothedAt(i), m_maxValue);
|
||||||
|
|
||||||
@@ -98,7 +99,7 @@ SparklineSceneItem::LineSample SparklineSceneItem::buildSample(
|
|||||||
if (m_curveSmoothing && points.size() > 2) {
|
if (m_curveSmoothing && points.size() > 2) {
|
||||||
const qreal tension = 1.0;
|
const qreal tension = 1.0;
|
||||||
const qreal k = tension / 6.0;
|
const qreal k = tension / 6.0;
|
||||||
const int n = static_cast<int>(points.size());
|
const int n = points.size();
|
||||||
for (int i = 0; i < n - 1; ++i) {
|
for (int i = 0; i < n - 1; ++i) {
|
||||||
const QPointF& p0 = points[qMax(i - 1, 0)];
|
const QPointF& p0 = points[qMax(i - 1, 0)];
|
||||||
const QPointF& p1 = points[i];
|
const QPointF& p1 = points[i];
|
||||||
@@ -124,6 +125,9 @@ SparklineSceneItem::LineSample SparklineSceneItem::buildSample(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Flatten the curve to a polyline once, here, on data change only.
|
||||||
|
// This is CPU math only -- no QPainter draw calls, no image, no
|
||||||
|
// texture upload happen as a result of this.
|
||||||
const auto subpaths = path.toSubpathPolygons();
|
const auto subpaths = path.toSubpathPolygons();
|
||||||
if (subpaths.isEmpty()) return sample;
|
if (subpaths.isEmpty()) return sample;
|
||||||
|
|
||||||
@@ -135,7 +139,7 @@ SparklineSceneItem::LineSample SparklineSceneItem::buildSample(
|
|||||||
|
|
||||||
void SparklineSceneItem::writeFillGeometry(
|
void SparklineSceneItem::writeFillGeometry(
|
||||||
QSGGeometryNode* node, const LineSample& sample) {
|
QSGGeometryNode* node, const LineSample& sample) {
|
||||||
const int n = static_cast<int>(sample.polyline.size());
|
const int n = sample.polyline.size();
|
||||||
auto* geometry = node->geometry();
|
auto* geometry = node->geometry();
|
||||||
geometry->allocate(n * 2);
|
geometry->allocate(n * 2);
|
||||||
geometry->setDrawingMode(QSGGeometry::DrawTriangleStrip);
|
geometry->setDrawingMode(QSGGeometry::DrawTriangleStrip);
|
||||||
@@ -143,10 +147,8 @@ void SparklineSceneItem::writeFillGeometry(
|
|||||||
auto* vertices = geometry->vertexDataAsPoint2D();
|
auto* vertices = geometry->vertexDataAsPoint2D();
|
||||||
for (int i = 0; i < n; ++i) {
|
for (int i = 0; i < n; ++i) {
|
||||||
const QPointF& p = sample.polyline[i];
|
const QPointF& p = sample.polyline[i];
|
||||||
vertices[i * 2].set(
|
vertices[i * 2].set(p.x(), p.y());
|
||||||
static_cast<float>(p.x()), static_cast<float>(p.y()));
|
vertices[i * 2 + 1].set(p.x(), sample.fillBottom);
|
||||||
vertices[i * 2 + 1].set(
|
|
||||||
static_cast<float>(p.x()), static_cast<float>(sample.fillBottom));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
node->markDirty(QSGNode::DirtyGeometry);
|
node->markDirty(QSGNode::DirtyGeometry);
|
||||||
@@ -154,7 +156,7 @@ void SparklineSceneItem::writeFillGeometry(
|
|||||||
|
|
||||||
void SparklineSceneItem::writeStrokeGeometry(
|
void SparklineSceneItem::writeStrokeGeometry(
|
||||||
QSGGeometryNode* node, const LineSample& sample, qreal lineWidth) {
|
QSGGeometryNode* node, const LineSample& sample, qreal lineWidth) {
|
||||||
const int n = static_cast<int>(sample.polyline.size());
|
const int n = sample.polyline.size();
|
||||||
auto* geometry = node->geometry();
|
auto* geometry = node->geometry();
|
||||||
geometry->allocate(n * 2);
|
geometry->allocate(n * 2);
|
||||||
geometry->setDrawingMode(QSGGeometry::DrawTriangleStrip);
|
geometry->setDrawingMode(QSGGeometry::DrawTriangleStrip);
|
||||||
@@ -177,12 +179,8 @@ void SparklineSceneItem::writeStrokeGeometry(
|
|||||||
|
|
||||||
const QPointF& p = sample.polyline[i];
|
const QPointF& p = sample.polyline[i];
|
||||||
const QPointF offset = normal * half;
|
const QPointF offset = normal * half;
|
||||||
vertices[i * 2].set(
|
vertices[i * 2].set(p.x() + offset.x(), p.y() + offset.y());
|
||||||
static_cast<float>(p.x() + offset.x()),
|
vertices[i * 2 + 1].set(p.x() - offset.x(), p.y() - offset.y());
|
||||||
static_cast<float>(p.y() + offset.y()));
|
|
||||||
vertices[i * 2 + 1].set(
|
|
||||||
static_cast<float>(p.x() - offset.x()),
|
|
||||||
static_cast<float>(p.y() - offset.y()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
node->markDirty(QSGNode::DirtyGeometry);
|
node->markDirty(QSGNode::DirtyGeometry);
|
||||||
@@ -245,7 +243,7 @@ QSGNode* SparklineSceneItem::updatePaintNode(
|
|||||||
}
|
}
|
||||||
|
|
||||||
QMatrix4x4 matrix;
|
QMatrix4x4 matrix;
|
||||||
matrix.translate(static_cast<float>(-stepX() * m_slideProgress), 0.0f);
|
matrix.translate(-stepX() * m_slideProgress, 0);
|
||||||
transformNode->setMatrix(matrix);
|
transformNode->setMatrix(matrix);
|
||||||
|
|
||||||
const bool needsGeometryWrite = samplesRebuilt || justCreated;
|
const bool needsGeometryWrite = samplesRebuilt || justCreated;
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
#include "wavyline.hpp"
|
#include "wavyline.hpp"
|
||||||
#include "wavylinerenderer.hpp"
|
|
||||||
|
#include <qpainter.h>
|
||||||
|
#include <qpainterpath.h>
|
||||||
|
|
||||||
namespace ZShell::controls {
|
namespace ZShell::controls {
|
||||||
|
|
||||||
WavyLine::WavyLine(QQuickItem* parent)
|
WavyLine::WavyLine(QQuickItem* parent)
|
||||||
: QCanvasPainterItem(parent)
|
: QQuickPaintedItem(parent)
|
||||||
, m_lineWidth(4)
|
, m_lineWidth(4)
|
||||||
, m_amplitudeMultiplier(0.5)
|
, m_amplitudeMultiplier(0.5)
|
||||||
, m_frequency(6)
|
, m_frequency(6)
|
||||||
@@ -16,13 +18,10 @@ WavyLine::WavyLine(QQuickItem* parent)
|
|||||||
, m_startAngle(0)
|
, m_startAngle(0)
|
||||||
, m_fullAngle(360)
|
, m_fullAngle(360)
|
||||||
, m_radius(-1)
|
, m_radius(-1)
|
||||||
, m_value(1) {
|
, m_value(1)
|
||||||
setFillColor(Qt::transparent);
|
, m_startAngleRad(0)
|
||||||
setAlphaBlending(true);
|
, m_fullAngleRad(2 * M_PI) {
|
||||||
}
|
setAntialiasing(true);
|
||||||
|
|
||||||
QCanvasPainterItemRenderer* WavyLine::createItemRenderer() const {
|
|
||||||
return new WavyLineRenderer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int WavyLine::lineWidth() const {
|
int WavyLine::lineWidth() const {
|
||||||
@@ -128,6 +127,7 @@ qreal WavyLine::startAngle() const {
|
|||||||
void WavyLine::setStartAngle(qreal startAngle) {
|
void WavyLine::setStartAngle(qreal startAngle) {
|
||||||
if (!qFuzzyCompare(m_startAngle + 1.0, startAngle + 1.0)) {
|
if (!qFuzzyCompare(m_startAngle + 1.0, startAngle + 1.0)) {
|
||||||
m_startAngle = startAngle;
|
m_startAngle = startAngle;
|
||||||
|
m_startAngleRad = startAngle * M_PI / 180.0;
|
||||||
emit startAngleChanged();
|
emit startAngleChanged();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@@ -140,6 +140,7 @@ qreal WavyLine::fullAngle() const {
|
|||||||
void WavyLine::setFullAngle(qreal fullAngle) {
|
void WavyLine::setFullAngle(qreal fullAngle) {
|
||||||
if (!qFuzzyCompare(m_fullAngle + 1.0, fullAngle + 1.0)) {
|
if (!qFuzzyCompare(m_fullAngle + 1.0, fullAngle + 1.0)) {
|
||||||
m_fullAngle = fullAngle;
|
m_fullAngle = fullAngle;
|
||||||
|
m_fullAngleRad = fullAngle * M_PI / 180.0;
|
||||||
emit fullAngleChanged();
|
emit fullAngleChanged();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@@ -169,4 +170,90 @@ void WavyLine::setValue(qreal value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WavyLine::paint(QPainter* painter) {
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
|
painter->setPen(QPen(m_color, m_lineWidth, Qt::SolidLine, Qt::RoundCap));
|
||||||
|
|
||||||
|
if (m_pathType == Arc) {
|
||||||
|
paintArc(painter);
|
||||||
|
} else {
|
||||||
|
paintLinear(painter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WavyLine::paintLinear(QPainter* painter) {
|
||||||
|
const auto amplitude = m_lineWidth * m_amplitudeMultiplier;
|
||||||
|
const auto phase = m_waveProgress * 2 * M_PI;
|
||||||
|
const auto centerY = height() / 2;
|
||||||
|
const auto len = m_fullLength > 0 ? m_fullLength : 1;
|
||||||
|
const auto start = m_lineWidth / 2.0;
|
||||||
|
const auto fullEnd = width() - m_lineWidth / 2.0;
|
||||||
|
const auto drawEnd = start + (fullEnd - start) * m_value;
|
||||||
|
|
||||||
|
QPainterPath path;
|
||||||
|
bool first = true;
|
||||||
|
|
||||||
|
for (int x = m_lineWidth / 2; x <= drawEnd; ++x) {
|
||||||
|
const auto theta =
|
||||||
|
m_frequency * 2 * M_PI * (x + m_startX) / len + phase;
|
||||||
|
const auto waveY = centerY + amplitude * qSin(theta);
|
||||||
|
if (first) {
|
||||||
|
path.moveTo(x, waveY);
|
||||||
|
first = false;
|
||||||
|
} else {
|
||||||
|
path.lineTo(x, waveY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
painter->drawPath(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WavyLine::paintArc(QPainter* painter) {
|
||||||
|
if (m_fullAngleRad <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto amplitude = m_lineWidth * m_amplitudeMultiplier;
|
||||||
|
const auto cx = width() / 2.0;
|
||||||
|
const auto cy = height() / 2.0;
|
||||||
|
const auto radius =
|
||||||
|
m_radius > 0
|
||||||
|
? m_radius
|
||||||
|
: (qMin(width(), height()) - m_lineWidth - 2 * amplitude) / 2.0;
|
||||||
|
|
||||||
|
if (radius <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto phase = m_waveProgress * 2 * M_PI;
|
||||||
|
const auto arcLen = radius * m_fullAngleRad;
|
||||||
|
const auto len = m_fullLength > 0 ? m_fullLength : arcLen;
|
||||||
|
const auto drawAngleRad = m_fullAngleRad * m_value;
|
||||||
|
|
||||||
|
if (drawAngleRad <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto N = qMax(64, qCeil(radius * drawAngleRad));
|
||||||
|
const auto dTheta = drawAngleRad / N;
|
||||||
|
|
||||||
|
QPainterPath path;
|
||||||
|
|
||||||
|
for (int i = 0; i <= N; ++i) {
|
||||||
|
const auto theta = m_startAngleRad + i * dTheta;
|
||||||
|
const auto s = i * dTheta * radius;
|
||||||
|
const auto phi = m_frequency * 2 * M_PI * (s + m_startX) / len + phase;
|
||||||
|
const auto r = radius + amplitude * qSin(phi);
|
||||||
|
const auto px = cx + r * qCos(theta);
|
||||||
|
const auto py = cy + r * qSin(theta);
|
||||||
|
if (i == 0) {
|
||||||
|
path.moveTo(px, py);
|
||||||
|
} else {
|
||||||
|
path.lineTo(px, py);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
painter->drawPath(path);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ZShell::controls
|
} // namespace ZShell::controls
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <qqmlintegration.h>
|
#include <qqmlintegration.h>
|
||||||
#include <QCanvasPainterItem>
|
#include <qquickpainteditem.h>
|
||||||
#include <QColor>
|
|
||||||
|
|
||||||
namespace ZShell::controls {
|
namespace ZShell::controls {
|
||||||
|
|
||||||
class WavyLineRenderer;
|
class WavyLine : public QQuickPaintedItem {
|
||||||
|
|
||||||
class WavyLine : public QCanvasPainterItem {
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
QML_ELEMENT
|
QML_ELEMENT
|
||||||
|
|
||||||
@@ -85,6 +82,8 @@ class WavyLine : public QCanvasPainterItem {
|
|||||||
[[nodiscard]] qreal value() const;
|
[[nodiscard]] qreal value() const;
|
||||||
void setValue(qreal value);
|
void setValue(qreal value);
|
||||||
|
|
||||||
|
void paint(QPainter* painter) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void lineWidthChanged();
|
void lineWidthChanged();
|
||||||
void amplitudeMultiplierChanged();
|
void amplitudeMultiplierChanged();
|
||||||
@@ -99,12 +98,9 @@ class WavyLine : public QCanvasPainterItem {
|
|||||||
void radiusChanged();
|
void radiusChanged();
|
||||||
void valueChanged();
|
void valueChanged();
|
||||||
|
|
||||||
protected:
|
|
||||||
[[nodiscard]] QCanvasPainterItemRenderer* createItemRenderer()
|
|
||||||
const override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class WavyLineRenderer;
|
void paintLinear(QPainter* painter);
|
||||||
|
void paintArc(QPainter* painter);
|
||||||
|
|
||||||
int m_lineWidth;
|
int m_lineWidth;
|
||||||
qreal m_amplitudeMultiplier;
|
qreal m_amplitudeMultiplier;
|
||||||
@@ -118,6 +114,8 @@ class WavyLine : public QCanvasPainterItem {
|
|||||||
qreal m_fullAngle;
|
qreal m_fullAngle;
|
||||||
qreal m_radius;
|
qreal m_radius;
|
||||||
qreal m_value;
|
qreal m_value;
|
||||||
|
qreal m_startAngleRad;
|
||||||
|
qreal m_fullAngleRad;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ZShell::controls
|
} // namespace ZShell::controls
|
||||||
|
|||||||
@@ -1,116 +0,0 @@
|
|||||||
#include "wavylinerenderer.hpp"
|
|
||||||
#include "wavyline.hpp"
|
|
||||||
#include <qcanvaspainter.h>
|
|
||||||
|
|
||||||
namespace ZShell::controls {
|
|
||||||
|
|
||||||
void WavyLineRenderer::synchronizeData(QCanvasPainterItem* item) {
|
|
||||||
auto* wavyLine = static_cast<WavyLine*>(item);
|
|
||||||
|
|
||||||
m_lineWidth = wavyLine->m_lineWidth;
|
|
||||||
m_amplitudeMultiplier = wavyLine->m_amplitudeMultiplier;
|
|
||||||
m_frequency = wavyLine->m_frequency;
|
|
||||||
m_startX = wavyLine->m_startX;
|
|
||||||
m_fullLength = wavyLine->m_fullLength;
|
|
||||||
m_color = wavyLine->m_color;
|
|
||||||
m_waveProgress = wavyLine->m_waveProgress;
|
|
||||||
m_pathType = wavyLine->m_pathType;
|
|
||||||
m_startAngle = wavyLine->m_startAngle;
|
|
||||||
m_fullAngle = wavyLine->m_fullAngle;
|
|
||||||
m_radius = wavyLine->m_radius;
|
|
||||||
m_value = wavyLine->m_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WavyLineRenderer::paint(QCanvasPainter* painter) {
|
|
||||||
painter->clearRect(0, 0, width(), height());
|
|
||||||
|
|
||||||
painter->setStrokeStyle(m_color);
|
|
||||||
painter->setLineWidth(m_lineWidth);
|
|
||||||
painter->setLineCap(QCanvasPainter::LineCap::Round);
|
|
||||||
|
|
||||||
if (m_pathType == WavyLine::Arc) {
|
|
||||||
paintArc(painter);
|
|
||||||
} else {
|
|
||||||
paintLinear(painter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WavyLineRenderer::paintLinear(QCanvasPainter* painter) {
|
|
||||||
const auto amplitude = m_lineWidth * m_amplitudeMultiplier;
|
|
||||||
const auto phase = m_waveProgress * 2 * M_PI;
|
|
||||||
const auto centerY = height() / 2;
|
|
||||||
const auto len = m_fullLength > 0 ? m_fullLength : 1;
|
|
||||||
const auto start = m_lineWidth / 2.0;
|
|
||||||
const auto fullEnd = width() - m_lineWidth / 2.0;
|
|
||||||
const auto drawEnd = start + (fullEnd - start) * m_value;
|
|
||||||
|
|
||||||
painter->beginPath();
|
|
||||||
|
|
||||||
bool first = true;
|
|
||||||
for (int x = m_lineWidth / 2; x <= drawEnd; ++x) {
|
|
||||||
const auto theta =
|
|
||||||
m_frequency * 2 * M_PI * (x + m_startX) / len + phase;
|
|
||||||
const auto waveY = centerY + amplitude * qSin(theta);
|
|
||||||
if (first) {
|
|
||||||
painter->moveTo(x, waveY);
|
|
||||||
first = false;
|
|
||||||
} else {
|
|
||||||
painter->lineTo(x, waveY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
painter->stroke();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WavyLineRenderer::paintArc(QCanvasPainter* painter) {
|
|
||||||
if (m_fullAngle <= 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto startAngleRad = m_startAngle * M_PI / 180.0;
|
|
||||||
const auto fullAngleRad = m_fullAngle * M_PI / 180.0;
|
|
||||||
|
|
||||||
const auto amplitude = m_lineWidth * m_amplitudeMultiplier;
|
|
||||||
const auto cx = width() / 2.0;
|
|
||||||
const auto cy = height() / 2.0;
|
|
||||||
const auto radius =
|
|
||||||
m_radius > 0
|
|
||||||
? m_radius
|
|
||||||
: (qMin(width(), height()) - m_lineWidth - 2 * amplitude) / 2.0;
|
|
||||||
|
|
||||||
if (radius <= 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto phase = m_waveProgress * 2 * M_PI;
|
|
||||||
const auto arcLen = radius * fullAngleRad;
|
|
||||||
const auto len = m_fullLength > 0 ? m_fullLength : arcLen;
|
|
||||||
const auto drawAngleRad = fullAngleRad * m_value;
|
|
||||||
|
|
||||||
if (drawAngleRad <= 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto N = qMax(64, qCeil(radius * drawAngleRad));
|
|
||||||
const auto dTheta = drawAngleRad / N;
|
|
||||||
|
|
||||||
painter->beginPath();
|
|
||||||
|
|
||||||
for (int i = 0; i <= N; ++i) {
|
|
||||||
const auto theta = startAngleRad + i * dTheta;
|
|
||||||
const auto s = i * dTheta * radius;
|
|
||||||
const auto phi = m_frequency * 2 * M_PI * (s + m_startX) / len + phase;
|
|
||||||
const auto r = radius + amplitude * qSin(phi);
|
|
||||||
const auto px = cx + r * qCos(theta);
|
|
||||||
const auto py = cy + r * qSin(theta);
|
|
||||||
if (i == 0) {
|
|
||||||
painter->moveTo(px, py);
|
|
||||||
} else {
|
|
||||||
painter->lineTo(px, py);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
painter->stroke();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace ZShell::controls
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QCanvasPainterItemRenderer>
|
|
||||||
#include <QColor>
|
|
||||||
#include "wavyline.hpp"
|
|
||||||
|
|
||||||
namespace ZShell::controls {
|
|
||||||
|
|
||||||
class WavyLineRenderer final : public QCanvasPainterItemRenderer {
|
|
||||||
public:
|
|
||||||
void synchronizeData(QCanvasPainterItem* item) override;
|
|
||||||
void paint(QCanvasPainter* painter) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void paintLinear(QCanvasPainter* painter);
|
|
||||||
void paintArc(QCanvasPainter* painter);
|
|
||||||
|
|
||||||
int m_lineWidth;
|
|
||||||
qreal m_amplitudeMultiplier;
|
|
||||||
int m_frequency;
|
|
||||||
qreal m_startX;
|
|
||||||
qreal m_fullLength;
|
|
||||||
QColor m_color;
|
|
||||||
qreal m_waveProgress;
|
|
||||||
WavyLine::PathType m_pathType;
|
|
||||||
qreal m_startAngle;
|
|
||||||
qreal m_fullAngle;
|
|
||||||
qreal m_radius;
|
|
||||||
qreal m_value;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace ZShell::controls
|
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
qml_module(ZShell-config
|
qml_module(ZShell-config
|
||||||
URI ZShell.Config
|
URI ZShell.Config
|
||||||
INCLUDE_PREFIX config
|
INCLUDE_PREFIX config
|
||||||
|
DEPENDENCIES
|
||||||
|
ZShell.Settings
|
||||||
SOURCES
|
SOURCES
|
||||||
rootnodes.hpp rootnodes.cpp
|
|
||||||
common.hpp common.cpp
|
common.hpp common.cpp
|
||||||
|
rootnodes.hpp rootnodes.cpp
|
||||||
migration.hpp migration.cpp
|
migration.hpp migration.cpp
|
||||||
anim.hpp anim.cpp
|
anim.hpp anim.cpp
|
||||||
fontbuilder.hpp fontbuilder.cpp
|
fontbuilder.hpp fontbuilder.cpp
|
||||||
@@ -28,8 +30,6 @@ qml_module(ZShell-config
|
|||||||
services.hpp
|
services.hpp
|
||||||
sidebar.hpp
|
sidebar.hpp
|
||||||
utilities.hpp
|
utilities.hpp
|
||||||
DEPENDENCIES
|
|
||||||
ZShell.Settings
|
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(ZShell-config PUBLIC
|
target_link_libraries(ZShell-config PUBLIC
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include "common.hpp"
|
||||||
#include <qhashfunctions.h>
|
#include <qhashfunctions.h>
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
#include <qqmlintegration.h>
|
#include <qqmlintegration.h>
|
||||||
|
|
||||||
#include "common.hpp"
|
|
||||||
|
|
||||||
namespace ZShell::config {
|
namespace ZShell::config {
|
||||||
|
|
||||||
class LlmAppearance : public settings::ObjectNode {
|
class LlmAppearance : public settings::ObjectNode {
|
||||||
|
|||||||
@@ -1,8 +1,3 @@
|
|||||||
wl_proto(wlp-layer-shell wlr-layer-shell-unstable-v1 "${CMAKE_CURRENT_SOURCE_DIR}/protocols")
|
|
||||||
wl_proto(wlp-viewporter viewporter "${WAYLAND_PROTOCOLS}/stable/viewporter")
|
|
||||||
wl_proto(wlp-fractional-scale fractional-scale-v1 "${WAYLAND_PROTOCOLS}/staging/fractional-scale")
|
|
||||||
wl_proto(wlp-xdg-shell xdg-shell "${WAYLAND_PROTOCOLS}/stable/xdg-shell")
|
|
||||||
|
|
||||||
qml_module(ZShell-internal
|
qml_module(ZShell-internal
|
||||||
URI ZShell.Internal
|
URI ZShell.Internal
|
||||||
INCLUDE_PREFIX internal
|
INCLUDE_PREFIX internal
|
||||||
@@ -14,9 +9,6 @@ qml_module(ZShell-internal
|
|||||||
circularbuffer.hpp circularbuffer.cpp
|
circularbuffer.hpp circularbuffer.cpp
|
||||||
arcgauge.hpp arcgauge.cpp
|
arcgauge.hpp arcgauge.cpp
|
||||||
wallpaperimage.hpp wallpaperimage.cpp
|
wallpaperimage.hpp wallpaperimage.cpp
|
||||||
wallpaperservice.hpp wallpaperservice.cpp
|
|
||||||
wallpapersurface.hpp wallpapersurface.cpp
|
|
||||||
wallpaperobject.hpp wallpaperobject.cpp
|
|
||||||
lidwatcher.hpp lidwatcher.cpp
|
lidwatcher.hpp lidwatcher.cpp
|
||||||
visualizerbars.hpp visualizerbars.cpp
|
visualizerbars.hpp visualizerbars.cpp
|
||||||
linearindicatormanager.hpp linearindicatormanager.cpp
|
linearindicatormanager.hpp linearindicatormanager.cpp
|
||||||
@@ -31,12 +23,4 @@ qml_module(ZShell-internal
|
|||||||
Qt::Network
|
Qt::Network
|
||||||
Qt::DBus
|
Qt::DBus
|
||||||
Qt::CanvasPainter
|
Qt::CanvasPainter
|
||||||
Qt::GuiPrivate
|
|
||||||
wlp-layer-shell
|
|
||||||
wlp-xdg-shell
|
|
||||||
wlp-viewporter
|
|
||||||
wlp-fractional-scale
|
|
||||||
PkgConfig::EGL
|
|
||||||
PkgConfig::WAYLAND_EGL
|
|
||||||
PkgConfig::GL
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -182,10 +182,10 @@ static QString buildHlConfigCall(const QString& key, const QVariant& value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static QColor colorFromInt(quint32 value) {
|
static QColor colorFromInt(quint32 value) {
|
||||||
const int a = static_cast<int>(value >> 24) & 0xFF;
|
const int a = (value >> 24) & 0xFF;
|
||||||
const int r = static_cast<int>(value >> 16) & 0xFF;
|
const int r = (value >> 16) & 0xFF;
|
||||||
const int g = static_cast<int>(value >> 8) & 0xFF;
|
const int g = (value >> 8) & 0xFF;
|
||||||
const int b = static_cast<int>(value) & 0xFF;
|
const int b = value & 0xFF;
|
||||||
|
|
||||||
return QColor(r, g, b, a);
|
return QColor(r, g, b, a);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,407 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<protocol name="wlr_layer_shell_unstable_v1">
|
|
||||||
<copyright>
|
|
||||||
Copyright © 2017 Drew DeVault
|
|
||||||
|
|
||||||
Permission to use, copy, modify, distribute, and sell this
|
|
||||||
software and its documentation for any purpose is hereby granted
|
|
||||||
without fee, provided that the above copyright notice appear in
|
|
||||||
all copies and that both that copyright notice and this permission
|
|
||||||
notice appear in supporting documentation, and that the name of
|
|
||||||
the copyright holders not be used in advertising or publicity
|
|
||||||
pertaining to distribution of the software without specific,
|
|
||||||
written prior permission. The copyright holders make no
|
|
||||||
representations about the suitability of this software for any
|
|
||||||
purpose. It is provided "as is" without express or implied
|
|
||||||
warranty.
|
|
||||||
|
|
||||||
THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
|
||||||
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
||||||
FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
||||||
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
|
||||||
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
|
||||||
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
||||||
THIS SOFTWARE.
|
|
||||||
</copyright>
|
|
||||||
|
|
||||||
<interface name="zwlr_layer_shell_v1" version="5">
|
|
||||||
<description summary="create surfaces that are layers of the desktop">
|
|
||||||
Clients can use this interface to assign the surface_layer role to
|
|
||||||
wl_surfaces. Such surfaces are assigned to a "layer" of the output and
|
|
||||||
rendered with a defined z-depth respective to each other. They may also be
|
|
||||||
anchored to the edges and corners of a screen and specify input handling
|
|
||||||
semantics. This interface should be suitable for the implementation of
|
|
||||||
many desktop shell components, and a broad number of other applications
|
|
||||||
that interact with the desktop.
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<request name="get_layer_surface">
|
|
||||||
<description summary="create a layer_surface from a surface">
|
|
||||||
Create a layer surface for an existing surface. This assigns the role of
|
|
||||||
layer_surface, or raises a protocol error if another role is already
|
|
||||||
assigned.
|
|
||||||
|
|
||||||
Creating a layer surface from a wl_surface which has a buffer attached
|
|
||||||
or committed is a client error, and any attempts by a client to attach
|
|
||||||
or manipulate a buffer prior to the first layer_surface.configure call
|
|
||||||
must also be treated as errors.
|
|
||||||
|
|
||||||
After creating a layer_surface object and setting it up, the client
|
|
||||||
must perform an initial commit without any buffer attached.
|
|
||||||
The compositor will reply with a layer_surface.configure event.
|
|
||||||
The client must acknowledge it and is then allowed to attach a buffer
|
|
||||||
to map the surface.
|
|
||||||
|
|
||||||
You may pass NULL for output to allow the compositor to decide which
|
|
||||||
output to use. Generally this will be the one that the user most
|
|
||||||
recently interacted with.
|
|
||||||
|
|
||||||
Clients can specify a namespace that defines the purpose of the layer
|
|
||||||
surface.
|
|
||||||
</description>
|
|
||||||
<arg name="id" type="new_id" interface="zwlr_layer_surface_v1"/>
|
|
||||||
<arg name="surface" type="object" interface="wl_surface"/>
|
|
||||||
<arg name="output" type="object" interface="wl_output" allow-null="true"/>
|
|
||||||
<arg name="layer" type="uint" enum="layer" summary="layer to add this surface to"/>
|
|
||||||
<arg name="namespace_" type="string" summary="namespace for the layer surface"/>
|
|
||||||
</request>
|
|
||||||
|
|
||||||
<enum name="error">
|
|
||||||
<entry name="role" value="0" summary="wl_surface has another role"/>
|
|
||||||
<entry name="invalid_layer" value="1" summary="layer value is invalid"/>
|
|
||||||
<entry name="already_constructed" value="2" summary="wl_surface has a buffer attached or committed"/>
|
|
||||||
</enum>
|
|
||||||
|
|
||||||
<enum name="layer">
|
|
||||||
<description summary="available layers for surfaces">
|
|
||||||
These values indicate which layers a surface can be rendered in. They
|
|
||||||
are ordered by z depth, bottom-most first. Traditional shell surfaces
|
|
||||||
will typically be rendered between the bottom and top layers.
|
|
||||||
Fullscreen shell surfaces are typically rendered at the top layer.
|
|
||||||
Multiple surfaces can share a single layer, and ordering within a
|
|
||||||
single layer is undefined.
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<entry name="background" value="0"/>
|
|
||||||
<entry name="bottom" value="1"/>
|
|
||||||
<entry name="top" value="2"/>
|
|
||||||
<entry name="overlay" value="3"/>
|
|
||||||
</enum>
|
|
||||||
|
|
||||||
<!-- Version 3 additions -->
|
|
||||||
|
|
||||||
<request name="destroy" type="destructor" since="3">
|
|
||||||
<description summary="destroy the layer_shell object">
|
|
||||||
This request indicates that the client will not use the layer_shell
|
|
||||||
object any more. Objects that have been created through this instance
|
|
||||||
are not affected.
|
|
||||||
</description>
|
|
||||||
</request>
|
|
||||||
</interface>
|
|
||||||
|
|
||||||
<interface name="zwlr_layer_surface_v1" version="5">
|
|
||||||
<description summary="layer metadata interface">
|
|
||||||
An interface that may be implemented by a wl_surface, for surfaces that
|
|
||||||
are designed to be rendered as a layer of a stacked desktop-like
|
|
||||||
environment.
|
|
||||||
|
|
||||||
Layer surface state (layer, size, anchor, exclusive zone,
|
|
||||||
margin, interactivity) is double-buffered, and will be applied at the
|
|
||||||
time wl_surface.commit of the corresponding wl_surface is called.
|
|
||||||
|
|
||||||
Attaching a null buffer to a layer surface unmaps it.
|
|
||||||
|
|
||||||
Unmapping a layer_surface means that the surface cannot be shown by the
|
|
||||||
compositor until it is explicitly mapped again. The layer_surface
|
|
||||||
returns to the state it had right after layer_shell.get_layer_surface.
|
|
||||||
The client can re-map the surface by performing a commit without any
|
|
||||||
buffer attached, waiting for a configure event and handling it as usual.
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<request name="set_size">
|
|
||||||
<description summary="sets the size of the surface">
|
|
||||||
Sets the size of the surface in surface-local coordinates. The
|
|
||||||
compositor will display the surface centered with respect to its
|
|
||||||
anchors.
|
|
||||||
|
|
||||||
If you pass 0 for either value, the compositor will assign it and
|
|
||||||
inform you of the assignment in the configure event. You must set your
|
|
||||||
anchor to opposite edges in the dimensions you omit; not doing so is a
|
|
||||||
protocol error. Both values are 0 by default.
|
|
||||||
|
|
||||||
Size is double-buffered, see wl_surface.commit.
|
|
||||||
</description>
|
|
||||||
<arg name="width" type="uint"/>
|
|
||||||
<arg name="height" type="uint"/>
|
|
||||||
</request>
|
|
||||||
|
|
||||||
<request name="set_anchor">
|
|
||||||
<description summary="configures the anchor point of the surface">
|
|
||||||
Requests that the compositor anchor the surface to the specified edges
|
|
||||||
and corners. If two orthogonal edges are specified (e.g. 'top' and
|
|
||||||
'left'), then the anchor point will be the intersection of the edges
|
|
||||||
(e.g. the top left corner of the output); otherwise the anchor point
|
|
||||||
will be centered on that edge, or in the center if none is specified.
|
|
||||||
|
|
||||||
Anchor is double-buffered, see wl_surface.commit.
|
|
||||||
</description>
|
|
||||||
<arg name="anchor" type="uint" enum="anchor"/>
|
|
||||||
</request>
|
|
||||||
|
|
||||||
<request name="set_exclusive_zone">
|
|
||||||
<description summary="configures the exclusive geometry of this surface">
|
|
||||||
Requests that the compositor avoids occluding an area with other
|
|
||||||
surfaces. The compositor's use of this information is
|
|
||||||
implementation-dependent - do not assume that this region will not
|
|
||||||
actually be occluded.
|
|
||||||
|
|
||||||
A positive value is only meaningful if the surface is anchored to one
|
|
||||||
edge or an edge and both perpendicular edges. If the surface is not
|
|
||||||
anchored, anchored to only two perpendicular edges (a corner), anchored
|
|
||||||
to only two parallel edges or anchored to all edges, a positive value
|
|
||||||
will be treated the same as zero.
|
|
||||||
|
|
||||||
A positive zone is the distance from the edge in surface-local
|
|
||||||
coordinates to consider exclusive.
|
|
||||||
|
|
||||||
Surfaces that do not wish to have an exclusive zone may instead specify
|
|
||||||
how they should interact with surfaces that do. If set to zero, the
|
|
||||||
surface indicates that it would like to be moved to avoid occluding
|
|
||||||
surfaces with a positive exclusive zone. If set to -1, the surface
|
|
||||||
indicates that it would not like to be moved to accommodate for other
|
|
||||||
surfaces, and the compositor should extend it all the way to the edges
|
|
||||||
it is anchored to.
|
|
||||||
|
|
||||||
For example, a panel might set its exclusive zone to 10, so that
|
|
||||||
maximized shell surfaces are not shown on top of it. A notification
|
|
||||||
might set its exclusive zone to 0, so that it is moved to avoid
|
|
||||||
occluding the panel, but shell surfaces are shown underneath it. A
|
|
||||||
wallpaper or lock screen might set their exclusive zone to -1, so that
|
|
||||||
they stretch below or over the panel.
|
|
||||||
|
|
||||||
The default value is 0.
|
|
||||||
|
|
||||||
Exclusive zone is double-buffered, see wl_surface.commit.
|
|
||||||
</description>
|
|
||||||
<arg name="zone" type="int"/>
|
|
||||||
</request>
|
|
||||||
|
|
||||||
<request name="set_margin">
|
|
||||||
<description summary="sets a margin from the anchor point">
|
|
||||||
Requests that the surface be placed some distance away from the anchor
|
|
||||||
point on the output, in surface-local coordinates. Setting this value
|
|
||||||
for edges you are not anchored to has no effect.
|
|
||||||
|
|
||||||
The exclusive zone includes the margin.
|
|
||||||
|
|
||||||
Margin is double-buffered, see wl_surface.commit.
|
|
||||||
</description>
|
|
||||||
<arg name="top" type="int"/>
|
|
||||||
<arg name="right" type="int"/>
|
|
||||||
<arg name="bottom" type="int"/>
|
|
||||||
<arg name="left" type="int"/>
|
|
||||||
</request>
|
|
||||||
|
|
||||||
<enum name="keyboard_interactivity">
|
|
||||||
<description summary="types of keyboard interaction possible for a layer shell surface">
|
|
||||||
Types of keyboard interaction possible for layer shell surfaces. The
|
|
||||||
rationale for this is twofold: (1) some applications are not interested
|
|
||||||
in keyboard events and not allowing them to be focused can improve the
|
|
||||||
desktop experience; (2) some applications will want to take exclusive
|
|
||||||
keyboard focus.
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<entry name="none" value="0">
|
|
||||||
<description summary="no keyboard focus is possible">
|
|
||||||
This value indicates that this surface is not interested in keyboard
|
|
||||||
events and the compositor should never assign it the keyboard focus.
|
|
||||||
|
|
||||||
This is the default value, set for newly created layer shell surfaces.
|
|
||||||
|
|
||||||
This is useful for e.g. desktop widgets that display information or
|
|
||||||
only have interaction with non-keyboard input devices.
|
|
||||||
</description>
|
|
||||||
</entry>
|
|
||||||
<entry name="exclusive" value="1">
|
|
||||||
<description summary="request exclusive keyboard focus">
|
|
||||||
Request exclusive keyboard focus if this surface is above the shell surface layer.
|
|
||||||
|
|
||||||
For the top and overlay layers, the seat will always give
|
|
||||||
exclusive keyboard focus to the top-most layer which has keyboard
|
|
||||||
interactivity set to exclusive. If this layer contains multiple
|
|
||||||
surfaces with keyboard interactivity set to exclusive, the compositor
|
|
||||||
determines the one receiving keyboard events in an implementation-
|
|
||||||
defined manner. In this case, no guarantee is made when this surface
|
|
||||||
will receive keyboard focus (if ever).
|
|
||||||
|
|
||||||
For the bottom and background layers, the compositor is allowed to use
|
|
||||||
normal focus semantics.
|
|
||||||
|
|
||||||
This setting is mainly intended for applications that need to ensure
|
|
||||||
they receive all keyboard events, such as a lock screen or a password
|
|
||||||
prompt.
|
|
||||||
</description>
|
|
||||||
</entry>
|
|
||||||
<entry name="on_demand" value="2" since="4">
|
|
||||||
<description summary="request regular keyboard focus semantics">
|
|
||||||
This requests the compositor to allow this surface to be focused and
|
|
||||||
unfocused by the user in an implementation-defined manner. The user
|
|
||||||
should be able to unfocus this surface even regardless of the layer
|
|
||||||
it is on.
|
|
||||||
|
|
||||||
Typically, the compositor will want to use its normal mechanism to
|
|
||||||
manage keyboard focus between layer shell surfaces with this setting
|
|
||||||
and regular toplevels on the desktop layer (e.g. click to focus).
|
|
||||||
Nevertheless, it is possible for a compositor to require a special
|
|
||||||
interaction to focus or unfocus layer shell surfaces (e.g. requiring
|
|
||||||
a click even if focus follows the mouse normally, or providing a
|
|
||||||
keybinding to switch focus between layers).
|
|
||||||
|
|
||||||
This setting is mainly intended for desktop shell components (e.g.
|
|
||||||
panels) that allow keyboard interaction. Using this option can allow
|
|
||||||
implementing a desktop shell that can be fully usable without the
|
|
||||||
mouse.
|
|
||||||
</description>
|
|
||||||
</entry>
|
|
||||||
</enum>
|
|
||||||
|
|
||||||
<request name="set_keyboard_interactivity">
|
|
||||||
<description summary="requests keyboard events">
|
|
||||||
Set how keyboard events are delivered to this surface. By default,
|
|
||||||
layer shell surfaces do not receive keyboard events; this request can
|
|
||||||
be used to change this.
|
|
||||||
|
|
||||||
This setting is inherited by child surfaces set by the get_popup
|
|
||||||
request.
|
|
||||||
|
|
||||||
Layer surfaces receive pointer, touch, and tablet events normally. If
|
|
||||||
you do not want to receive them, set the input region on your surface
|
|
||||||
to an empty region.
|
|
||||||
|
|
||||||
Keyboard interactivity is double-buffered, see wl_surface.commit.
|
|
||||||
</description>
|
|
||||||
<arg name="keyboard_interactivity" type="uint" enum="keyboard_interactivity"/>
|
|
||||||
</request>
|
|
||||||
|
|
||||||
<request name="get_popup">
|
|
||||||
<description summary="assign this layer_surface as an xdg_popup parent">
|
|
||||||
This assigns an xdg_popup's parent to this layer_surface. This popup
|
|
||||||
should have been created via xdg_surface::get_popup with the parent set
|
|
||||||
to NULL, and this request must be invoked before committing the popup's
|
|
||||||
initial state.
|
|
||||||
|
|
||||||
See the documentation of xdg_popup for more details about what an
|
|
||||||
xdg_popup is and how it is used.
|
|
||||||
</description>
|
|
||||||
<arg name="popup" type="object" interface="xdg_popup"/>
|
|
||||||
</request>
|
|
||||||
|
|
||||||
<request name="ack_configure">
|
|
||||||
<description summary="ack a configure event">
|
|
||||||
When a configure event is received, if a client commits the
|
|
||||||
surface in response to the configure event, then the client
|
|
||||||
must make an ack_configure request sometime before the commit
|
|
||||||
request, passing along the serial of the configure event.
|
|
||||||
|
|
||||||
If the client receives multiple configure events before it
|
|
||||||
can respond to one, it only has to ack the last configure event.
|
|
||||||
|
|
||||||
A client is not required to commit immediately after sending
|
|
||||||
an ack_configure request - it may even ack_configure several times
|
|
||||||
before its next surface commit.
|
|
||||||
|
|
||||||
A client may send multiple ack_configure requests before committing, but
|
|
||||||
only the last request sent before a commit indicates which configure
|
|
||||||
event the client really is responding to.
|
|
||||||
</description>
|
|
||||||
<arg name="serial" type="uint" summary="the serial from the configure event"/>
|
|
||||||
</request>
|
|
||||||
|
|
||||||
<request name="destroy" type="destructor">
|
|
||||||
<description summary="destroy the layer_surface">
|
|
||||||
This request destroys the layer surface.
|
|
||||||
</description>
|
|
||||||
</request>
|
|
||||||
|
|
||||||
<event name="configure">
|
|
||||||
<description summary="suggest a surface change">
|
|
||||||
The configure event asks the client to resize its surface.
|
|
||||||
|
|
||||||
Clients should arrange their surface for the new states, and then send
|
|
||||||
an ack_configure request with the serial sent in this configure event at
|
|
||||||
some point before committing the new surface.
|
|
||||||
|
|
||||||
The client is free to dismiss all but the last configure event it
|
|
||||||
received.
|
|
||||||
|
|
||||||
The width and height arguments specify the size of the window in
|
|
||||||
surface-local coordinates.
|
|
||||||
|
|
||||||
The size is a hint, in the sense that the client is free to ignore it if
|
|
||||||
it doesn't resize, pick a smaller size (to satisfy aspect ratio or
|
|
||||||
resize in steps of NxM pixels). If the client picks a smaller size and
|
|
||||||
is anchored to two opposite anchors (e.g. 'top' and 'bottom'), the
|
|
||||||
surface will be centered on this axis.
|
|
||||||
|
|
||||||
If the width or height arguments are zero, it means the client should
|
|
||||||
decide its own window dimension.
|
|
||||||
</description>
|
|
||||||
<arg name="serial" type="uint"/>
|
|
||||||
<arg name="width" type="uint"/>
|
|
||||||
<arg name="height" type="uint"/>
|
|
||||||
</event>
|
|
||||||
|
|
||||||
<event name="closed">
|
|
||||||
<description summary="surface should be closed">
|
|
||||||
The closed event is sent by the compositor when the surface will no
|
|
||||||
longer be shown. The output may have been destroyed or the user may
|
|
||||||
have asked for it to be removed. Further changes to the surface will be
|
|
||||||
ignored. The client should destroy the resource after receiving this
|
|
||||||
event, and create a new surface if they so choose.
|
|
||||||
</description>
|
|
||||||
</event>
|
|
||||||
|
|
||||||
<enum name="error">
|
|
||||||
<entry name="invalid_surface_state" value="0" summary="provided surface state is invalid"/>
|
|
||||||
<entry name="invalid_size" value="1" summary="size is invalid"/>
|
|
||||||
<entry name="invalid_anchor" value="2" summary="anchor bitfield is invalid"/>
|
|
||||||
<entry name="invalid_keyboard_interactivity" value="3" summary="keyboard interactivity is invalid"/>
|
|
||||||
<entry name="invalid_exclusive_edge" value="4" summary="exclusive edge is invalid given the surface anchors"/>
|
|
||||||
</enum>
|
|
||||||
|
|
||||||
<enum name="anchor" bitfield="true">
|
|
||||||
<entry name="top" value="1" summary="the top edge of the anchor rectangle"/>
|
|
||||||
<entry name="bottom" value="2" summary="the bottom edge of the anchor rectangle"/>
|
|
||||||
<entry name="left" value="4" summary="the left edge of the anchor rectangle"/>
|
|
||||||
<entry name="right" value="8" summary="the right edge of the anchor rectangle"/>
|
|
||||||
</enum>
|
|
||||||
|
|
||||||
<!-- Version 2 additions -->
|
|
||||||
|
|
||||||
<request name="set_layer" since="2">
|
|
||||||
<description summary="change the layer of the surface">
|
|
||||||
Change the layer that the surface is rendered on.
|
|
||||||
|
|
||||||
Layer is double-buffered, see wl_surface.commit.
|
|
||||||
</description>
|
|
||||||
<arg name="layer" type="uint" enum="zwlr_layer_shell_v1.layer" summary="layer to move this surface to"/>
|
|
||||||
</request>
|
|
||||||
|
|
||||||
<!-- Version 5 additions -->
|
|
||||||
|
|
||||||
<request name="set_exclusive_edge" since="5">
|
|
||||||
<description summary="set the edge the exclusive zone will be applied to">
|
|
||||||
Requests an edge for the exclusive zone to apply. The exclusive
|
|
||||||
edge will be automatically deduced from anchor points when possible,
|
|
||||||
but when the surface is anchored to a corner, it will be necessary
|
|
||||||
to set it explicitly to disambiguate, as it is not possible to deduce
|
|
||||||
which one of the two corner edges should be used.
|
|
||||||
|
|
||||||
The edge must be one the surface is anchored to, otherwise the
|
|
||||||
invalid_exclusive_edge protocol error will be raised.
|
|
||||||
</description>
|
|
||||||
<arg name="edge" type="uint" enum="anchor"/>
|
|
||||||
</request>
|
|
||||||
</interface>
|
|
||||||
</protocol>
|
|
||||||
@@ -72,7 +72,7 @@ static QCanvasPath buildStrokePath(
|
|||||||
void StrokeCanvasItem::undoLastGroup() {
|
void StrokeCanvasItem::undoLastGroup() {
|
||||||
if (m_strokes.isEmpty()) return;
|
if (m_strokes.isEmpty()) return;
|
||||||
const int lastGroup = m_strokes.last().groupId;
|
const int lastGroup = m_strokes.last().groupId;
|
||||||
for (int i = static_cast<int>(m_strokes.size()) - 1;
|
for (int i = m_strokes.size() - 1;
|
||||||
i >= 0 && m_strokes[i].groupId == lastGroup;
|
i >= 0 && m_strokes[i].groupId == lastGroup;
|
||||||
--i)
|
--i)
|
||||||
m_strokes.remove(i);
|
m_strokes.remove(i);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#include "strokecanvasrenderer.hpp"
|
#include "strokecanvasrenderer.hpp"
|
||||||
#include "strokecanvasitem.hpp"
|
#include "strokecanvasitem.hpp"
|
||||||
#include <qcolor.h>
|
#include <qcolor.h>
|
||||||
#include <QSet>
|
|
||||||
|
|
||||||
namespace ZShell::internal {
|
namespace ZShell::internal {
|
||||||
|
|
||||||
@@ -149,27 +148,14 @@ void StrokeCanvasRenderer::synchronizeData(QCanvasPainterItem* item) {
|
|||||||
m_penColor = canvas->m_penColor;
|
m_penColor = canvas->m_penColor;
|
||||||
m_penWidth = canvas->m_penWidth;
|
m_penWidth = canvas->m_penWidth;
|
||||||
|
|
||||||
// Detect removed strokes: present in renderer but no longer in canvas
|
while (m_strokes.size() < canvas->m_strokes.size())
|
||||||
QSet<int> canvasGroupIds;
|
m_strokes.append(canvas->m_strokes[m_strokes.size()]);
|
||||||
for (const auto& stroke : canvas->m_strokes)
|
|
||||||
canvasGroupIds.insert(stroke.groupId);
|
|
||||||
|
|
||||||
for (int i = static_cast<int>(m_strokes.size()) - 1; i >= 0; --i) {
|
if (canvas->m_strokes.isEmpty() && !m_strokes.isEmpty()) {
|
||||||
if (!canvasGroupIds.contains(m_strokes[i].groupId)) {
|
for (const auto& stroke : m_strokes)
|
||||||
if (m_strokes[i].groupId >= 0)
|
if (stroke.groupId >= 0)
|
||||||
m_pendingGroupRemovals.append(m_strokes[i].groupId);
|
m_pendingGroupRemovals.append(stroke.groupId);
|
||||||
m_strokes.remove(i);
|
m_strokes.clear();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Detect added strokes: present in canvas but not yet in renderer
|
|
||||||
QSet<int> rendererGroupIds;
|
|
||||||
for (const auto& stroke : m_strokes)
|
|
||||||
rendererGroupIds.insert(stroke.groupId);
|
|
||||||
|
|
||||||
for (const auto& stroke : canvas->m_strokes) {
|
|
||||||
if (!rendererGroupIds.contains(stroke.groupId))
|
|
||||||
m_strokes.append(stroke);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_currentStroke = canvas->m_currentStroke;
|
m_currentStroke = canvas->m_currentStroke;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user