mirror of
https://github.com/tomasriveral/nixos.git
synced 2026-08-12 10:30:44 +02:00
ported some quickshell stuff from rivendell-hyprdots
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import QtQuick
|
||||
import QtQuick.Shapes
|
||||
import "../.."
|
||||
|
||||
Rectangle {
|
||||
property var checkState: Qt.Unchecked
|
||||
implicitHeight: 18
|
||||
implicitWidth: 18
|
||||
radius: 3
|
||||
color: checkState == Qt.Checked ? "#C5E3EE" : "#90ACAD"
|
||||
|
||||
Shape {
|
||||
visible: checkState == Qt.Checked
|
||||
anchors.fill: parent
|
||||
layer.enabled: true
|
||||
layer.samples: 10
|
||||
|
||||
ShapePath {
|
||||
strokeWidth: 2
|
||||
capStyle: ShapePath.RoundCap
|
||||
joinStyle: ShapePath.RoundJoin
|
||||
fillColor: "transparent"
|
||||
|
||||
startX: start.x
|
||||
startY: start.y
|
||||
|
||||
PathLine {
|
||||
id: start
|
||||
x: width * 0.8
|
||||
y: height * 0.2
|
||||
}
|
||||
|
||||
PathLine {
|
||||
x: width * 0.35
|
||||
y: height * 0.8
|
||||
}
|
||||
|
||||
PathLine {
|
||||
x: width * 0.2
|
||||
y: height * 0.6
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import QtQuick
|
||||
import QtQuick.Shapes
|
||||
import Quickshell
|
||||
|
||||
Item {
|
||||
property bool expanded: false;
|
||||
|
||||
readonly property bool open: progress != 0;
|
||||
readonly property bool animating: internalProgress != (expanded ? 101 : -1);
|
||||
|
||||
implicitHeight: 16
|
||||
implicitWidth: 16
|
||||
property var xStart: Math.round(width * 0.3)
|
||||
property var yStart: Math.round(height * 0.1)
|
||||
property var xEnd: Math.round(width * 0.7)
|
||||
property var yEnd: Math.round(height * 0.9)
|
||||
|
||||
property real internalProgress: expanded ? 101 : -1;
|
||||
Behavior on internalProgress { SmoothedAnimation { velocity: 300 } }
|
||||
|
||||
EasingCurve {
|
||||
id: curve
|
||||
curve.type: Easing.InOutQuad
|
||||
}
|
||||
|
||||
readonly property real progress: curve.valueAt(Math.min(100, Math.max(internalProgress, 0)) * 0.01)
|
||||
|
||||
rotation: progress * 90;
|
||||
|
||||
Shape {
|
||||
anchors.fill: parent
|
||||
|
||||
layer.enabled: true
|
||||
layer.samples: 3
|
||||
|
||||
ShapePath {
|
||||
strokeWidth: 2
|
||||
capStyle: ShapePath.RoundCap
|
||||
joinStyle: ShapePath.MiterJoin
|
||||
fillColor: "transparent"
|
||||
|
||||
startX: xStart
|
||||
startY: yStart
|
||||
|
||||
PathLine {
|
||||
x: xEnd
|
||||
y: height / 2
|
||||
}
|
||||
|
||||
PathLine {
|
||||
y: yEnd
|
||||
x: xStart
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Widgets
|
||||
import Quickshell.DBusMenu
|
||||
import "../.."
|
||||
|
||||
MouseArea {
|
||||
id: root
|
||||
required property QsMenuEntry entry
|
||||
property alias expanded: childrenRevealer.expanded
|
||||
property bool animating: childrenRevealer.animating || (childMenuLoader?.item?.animating ?? false)
|
||||
// appears it won't actually create the handler when only used from MenuItemList.
|
||||
onExpandedChanged: {}
|
||||
onAnimatingChanged: {}
|
||||
|
||||
signal close
|
||||
|
||||
implicitWidth: row.implicitWidth + 4
|
||||
implicitHeight: row.implicitHeight + 4
|
||||
|
||||
hoverEnabled: true
|
||||
onClicked: {
|
||||
if (entry.hasChildren)
|
||||
childrenRevealer.expanded = !childrenRevealer.expanded;
|
||||
else {
|
||||
entry.triggered();
|
||||
if (entry.toggleType == ToggleButtonType.None)
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
visible: root.containsMouse || childrenRevealer.expanded
|
||||
|
||||
color: "#824524"
|
||||
}
|
||||
ColumnLayout {
|
||||
id: row
|
||||
anchors.fill: parent
|
||||
anchors.margins: 2
|
||||
spacing: 0
|
||||
|
||||
RowLayout {
|
||||
id: innerRow
|
||||
|
||||
Item {
|
||||
implicitWidth: 22
|
||||
implicitHeight: 22
|
||||
|
||||
MenuCheckBox {
|
||||
anchors.centerIn: parent
|
||||
visible: entry.buttonType == QsMenuButtonType.CheckBox
|
||||
checkState: entry.checkState
|
||||
}
|
||||
|
||||
MenuRadioButton {
|
||||
anchors.centerIn: parent
|
||||
visible: entry.buttonType == QsMenuButtonType.RadioButton
|
||||
checkState: entry.checkState
|
||||
}
|
||||
|
||||
MenuChildrenRevealer {
|
||||
id: childrenRevealer
|
||||
anchors.centerIn: parent
|
||||
visible: entry.hasChildren
|
||||
onOpenChanged: entry.showChildren = open
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
text: entry.text
|
||||
color: entry.enabled ? "white" : "#bbbbbb"
|
||||
}
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
implicitWidth: 22
|
||||
implicitHeight: 22
|
||||
|
||||
IconImage {
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
source: entry.icon
|
||||
visible: source != ""
|
||||
implicitSize: parent.height
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: childMenuLoader
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: active ? item.implicitHeight * childrenRevealer.progress : 0
|
||||
|
||||
readonly property real widthDifference: {
|
||||
Math.max(0, (item?.implicitWidth ?? 0) - innerRow.implicitWidth);
|
||||
}
|
||||
Layout.preferredWidth: active ? innerRow.implicitWidth + (widthDifference * childrenRevealer.progress) : 0
|
||||
|
||||
active: root.expanded || root.animating
|
||||
clip: true
|
||||
|
||||
sourceComponent: MenuView {
|
||||
id: childrenList
|
||||
menu: entry
|
||||
onClose: root.close()
|
||||
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import QtQuick
|
||||
import "../.."
|
||||
|
||||
Rectangle {
|
||||
property var checkState: Qt.Unchecked
|
||||
implicitHeight: 18
|
||||
implicitWidth: 18
|
||||
radius: width / 2
|
||||
color: checkState == Qt.Checked ? "#C5E3EE" : "#90ACAD"
|
||||
|
||||
Rectangle {
|
||||
x: parent.width * 0.25
|
||||
y: parent.height * 0.25
|
||||
visible: checkState == Qt.Checked
|
||||
width: parent.width * 0.5
|
||||
height: width
|
||||
radius: width / 2
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
|
||||
ColumnLayout {
|
||||
id: root
|
||||
property alias menu: menuView.menu
|
||||
property Item animatingItem: null
|
||||
property bool animating: animatingItem != null
|
||||
|
||||
signal close
|
||||
signal submenuExpanded(item: var)
|
||||
|
||||
QsMenuOpener {
|
||||
id: menuView
|
||||
}
|
||||
|
||||
spacing: 0
|
||||
|
||||
Repeater {
|
||||
model: menuView.children
|
||||
|
||||
Loader {
|
||||
required property var modelData
|
||||
|
||||
property var item: Component {
|
||||
BoundComponent {
|
||||
id: itemComponent
|
||||
source: "MenuItem.qml"
|
||||
|
||||
property var entry: modelData
|
||||
|
||||
function onClose() {
|
||||
root.close();
|
||||
}
|
||||
|
||||
function onExpandedChanged() {
|
||||
if (item.expanded)
|
||||
root.submenuExpanded(item);
|
||||
}
|
||||
|
||||
function onAnimatingChanged() {
|
||||
if (item.animating) {
|
||||
root.animatingItem = this;
|
||||
} else if (root.animatingItem == this) {
|
||||
root.animatingItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: root
|
||||
|
||||
function onSubmenuExpanded(expandedItem) {
|
||||
if (item != expandedItem)
|
||||
item.expanded = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
property var separator: Component {
|
||||
Rectangle {
|
||||
color: "#824524"
|
||||
implicitHeight: 4
|
||||
}
|
||||
}
|
||||
|
||||
sourceComponent: modelData.isSeparator ? separator : item
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Effects
|
||||
import Quickshell
|
||||
import Quickshell.Services.SystemTray
|
||||
import ".."
|
||||
import "../.."
|
||||
import "../../components"
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
required property var bar
|
||||
implicitWidth: row.implicitWidth + 10
|
||||
Layout.fillHeight: true
|
||||
|
||||
color: "transparent"
|
||||
|
||||
RowLayout {
|
||||
id: row
|
||||
implicitWidth: childrenRect.width
|
||||
spacing: 5
|
||||
|
||||
anchors {
|
||||
fill: parent
|
||||
margins: 5
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: SystemTray.items
|
||||
|
||||
Item {
|
||||
id: item
|
||||
required property SystemTrayItem modelData
|
||||
|
||||
property bool targetMenuOpen: false
|
||||
|
||||
Layout.fillHeight: true
|
||||
implicitWidth: height
|
||||
|
||||
Image {
|
||||
anchors {
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
width: height
|
||||
source: item.modelData.icon
|
||||
scale: item.targetMenuOpen ? 0.8 : 1
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
|
||||
|
||||
// showPressed: item.targetMenuOpen || (pressedButtons & ~Qt.RightButton)
|
||||
// fillWindowWidth: true
|
||||
// extraVerticalMargin: row.spacing / 2
|
||||
|
||||
onClicked: event => {
|
||||
event.accepted = true;
|
||||
|
||||
if (event.button == Qt.LeftButton) {
|
||||
item.modelData.activate();
|
||||
} else if (event.button == Qt.MiddleButton) {
|
||||
item.modelData.secondaryActivate();
|
||||
}
|
||||
}
|
||||
|
||||
onPressed: event => {
|
||||
if (event.button == Qt.RightButton && item.modelData.hasMenu) {
|
||||
item.targetMenuOpen = !item.targetMenuOpen;
|
||||
}
|
||||
}
|
||||
|
||||
onWheel: event => {
|
||||
event.accepted = true;
|
||||
const points = event.angleDelta.y / 120;
|
||||
item.modelData.scroll(points, false);
|
||||
}
|
||||
|
||||
// property var tooltip: TooltipItem {
|
||||
// tooltip: root.bar.tooltip
|
||||
// owner: mouseArea
|
||||
//
|
||||
// show: mouseArea.containsMouse
|
||||
//
|
||||
// Text {
|
||||
// id: tooltipText
|
||||
// text: item.modelData.tooltipTitle != "" ? item.modelData.tooltipTitle : item.modelData.id
|
||||
// color: "white"
|
||||
// }
|
||||
// }
|
||||
|
||||
LazyLoader {
|
||||
active: item.targetMenuOpen
|
||||
|
||||
PopupWindow {
|
||||
id: rightclickMenu
|
||||
anchor.window: root.bar
|
||||
visible: true
|
||||
|
||||
Component.onCompleted: () => {
|
||||
root.bar.focusable = true;
|
||||
const pos = mouseArea.mapToGlobal(mouseArea.x, mouseArea.y);
|
||||
anchor.rect.x = pos.x;
|
||||
anchor.rect.y = pos.y + mouseArea.height;
|
||||
}
|
||||
Connections {
|
||||
target: item
|
||||
function onTargetMenuOpenChanged() {
|
||||
root.bar.focusable = false;
|
||||
}
|
||||
}
|
||||
contentItem {
|
||||
focus: true
|
||||
Keys.onEscapePressed: item.targetMenuOpen = false
|
||||
}
|
||||
|
||||
implicitWidth: Math.max(1, menuView.implicitWidth)
|
||||
implicitHeight: Math.max(1, menuView.implicitHeight)
|
||||
color: "transparent"
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "#9B5B36"
|
||||
MenuView {
|
||||
id: menuView
|
||||
anchors.fill: parent
|
||||
menu: item.modelData.menu
|
||||
onClose: item.targetMenuOpen = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user