dashboard: loader content
This commit is contained in:
parent
8ba5c83f7b
commit
1518b37b9b
3 changed files with 31 additions and 16 deletions
|
|
@ -9,11 +9,9 @@ Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
required property PersistentProperties visibilities
|
required property PersistentProperties visibilities
|
||||||
|
required property PersistentProperties state
|
||||||
readonly property real nonAnimWidth: view.implicitWidth + viewWrapper.anchors.margins * 2
|
readonly property real nonAnimWidth: view.implicitWidth + viewWrapper.anchors.margins * 2
|
||||||
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
|
|
||||||
implicitWidth: nonAnimWidth
|
implicitWidth: nonAnimWidth
|
||||||
implicitHeight: tabs.implicitHeight + tabs.anchors.topMargin + view.implicitHeight + viewWrapper.anchors.margins * 2
|
implicitHeight: tabs.implicitHeight + tabs.anchors.topMargin + view.implicitHeight + viewWrapper.anchors.margins * 2
|
||||||
|
|
||||||
|
|
@ -27,7 +25,7 @@ Item {
|
||||||
anchors.margins: Appearance.padding.large
|
anchors.margins: Appearance.padding.large
|
||||||
|
|
||||||
nonAnimWidth: root.nonAnimWidth - anchors.margins * 2
|
nonAnimWidth: root.nonAnimWidth - anchors.margins * 2
|
||||||
currentIndex: view.currentIndex
|
state: root.state
|
||||||
}
|
}
|
||||||
|
|
||||||
ClippingRectangle {
|
ClippingRectangle {
|
||||||
|
|
@ -45,7 +43,7 @@ Item {
|
||||||
Flickable {
|
Flickable {
|
||||||
id: view
|
id: view
|
||||||
|
|
||||||
readonly property int currentIndex: tabs.currentIndex
|
readonly property int currentIndex: root.state.currentTab
|
||||||
readonly property Item currentItem: row.children[currentIndex]
|
readonly property Item currentItem: row.children[currentIndex]
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
@ -65,17 +63,17 @@ Item {
|
||||||
|
|
||||||
const x = contentX - currentItem.x;
|
const x = contentX - currentItem.x;
|
||||||
if (x > currentItem.implicitWidth / 2)
|
if (x > currentItem.implicitWidth / 2)
|
||||||
tabs.bar.incrementCurrentIndex();
|
root.state.currentTab = Math.min(root.state.currentTab + 1, tabs.count - 1);
|
||||||
else if (x < -currentItem.implicitWidth / 2)
|
else if (x < -currentItem.implicitWidth / 2)
|
||||||
tabs.bar.decrementCurrentIndex();
|
root.state.currentTab = Math.max(root.state.currentTab - 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
onDragEnded: {
|
onDragEnded: {
|
||||||
const x = contentX - currentItem.x;
|
const x = contentX - currentItem.x;
|
||||||
if (x > currentItem.implicitWidth / 10)
|
if (x > currentItem.implicitWidth / 10)
|
||||||
tabs.bar.incrementCurrentIndex();
|
root.state.currentTab = Math.min(root.state.currentTab + 1, tabs.count - 1);
|
||||||
else if (x < -currentItem.implicitWidth / 10)
|
else if (x < -currentItem.implicitWidth / 10)
|
||||||
tabs.bar.decrementCurrentIndex();
|
root.state.currentTab = Math.max(root.state.currentTab - 1, 0);
|
||||||
else
|
else
|
||||||
contentX = Qt.binding(() => currentItem.x);
|
contentX = Qt.binding(() => currentItem.x);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import "root:/widgets"
|
import "root:/widgets"
|
||||||
import "root:/services"
|
import "root:/services"
|
||||||
import "root:/config"
|
import "root:/config"
|
||||||
|
import Quickshell
|
||||||
import Quickshell.Widgets
|
import Quickshell.Widgets
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
|
|
@ -9,8 +12,8 @@ Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
required property real nonAnimWidth
|
required property real nonAnimWidth
|
||||||
property alias currentIndex: bar.currentIndex
|
required property PersistentProperties state
|
||||||
readonly property TabBar bar: bar
|
readonly property alias count: bar.count
|
||||||
|
|
||||||
implicitHeight: bar.implicitHeight + indicator.implicitHeight + indicator.anchors.topMargin + separator.implicitHeight
|
implicitHeight: bar.implicitHeight + indicator.implicitHeight + indicator.anchors.topMargin + separator.implicitHeight
|
||||||
|
|
||||||
|
|
@ -21,6 +24,7 @@ Item {
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
|
|
||||||
|
currentIndex: root.state.currentTab
|
||||||
background: null
|
background: null
|
||||||
|
|
||||||
Tab {
|
Tab {
|
||||||
|
|
@ -108,7 +112,7 @@ Item {
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
|
||||||
onPressed: event => {
|
onPressed: event => {
|
||||||
tab.TabBar.tabBar.setCurrentIndex(tab.TabBar.index);
|
root.state.currentTab = tab.TabBar.index;
|
||||||
|
|
||||||
const stateY = stateWrapper.y;
|
const stateY = stateWrapper.y;
|
||||||
rippleAnim.x = event.x;
|
rippleAnim.x = event.x;
|
||||||
|
|
@ -122,9 +126,9 @@ Item {
|
||||||
}
|
}
|
||||||
onWheel: event => {
|
onWheel: event => {
|
||||||
if (event.angleDelta.y < 0)
|
if (event.angleDelta.y < 0)
|
||||||
tab.TabBar.tabBar.incrementCurrentIndex();
|
root.state.currentTab = Math.min(root.state.currentTab + 1, bar.count - 1);
|
||||||
else if (event.angleDelta.y > 0)
|
else if (event.angleDelta.y > 0)
|
||||||
tab.TabBar.tabBar.decrementCurrentIndex();
|
root.state.currentTab = Math.max(root.state.currentTab - 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SequentialAnimation {
|
SequentialAnimation {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import "root:/config"
|
import "root:/config"
|
||||||
|
|
@ -6,6 +8,9 @@ Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
required property PersistentProperties visibilities
|
required property PersistentProperties visibilities
|
||||||
|
readonly property PersistentProperties state: PersistentProperties {
|
||||||
|
property int currentTab
|
||||||
|
}
|
||||||
|
|
||||||
visible: height > 0
|
visible: height > 0
|
||||||
implicitHeight: 0
|
implicitHeight: 0
|
||||||
|
|
@ -47,9 +52,17 @@ Item {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Content {
|
Loader {
|
||||||
id: content
|
id: content
|
||||||
|
|
||||||
visibilities: root.visibilities
|
Component.onCompleted: active = Qt.binding(() => root.visibilities.dashboard || root.visible)
|
||||||
|
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
|
||||||
|
sourceComponent: Content {
|
||||||
|
visibilities: root.visibilities
|
||||||
|
state: root.state
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue