Lots of uncommitted changes
This commit is contained in:
parent
daace49bfc
commit
497ca48ada
27 changed files with 909 additions and 134 deletions
147
modules/user/modules/quickshell/shell/bar/systray/SysTray.qml
Normal file
147
modules/user/modules/quickshell/shell/bar/systray/SysTray.qml
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Effects
|
||||
import Quickshell
|
||||
import Quickshell.Services.SystemTray
|
||||
import ".."
|
||||
|
||||
OverlayWidget {
|
||||
id: root
|
||||
expandedWidth: 600
|
||||
expandedHeight: 800
|
||||
required property var bar;
|
||||
|
||||
BarWidgetInner {
|
||||
implicitHeight: column.implicitHeight + 10
|
||||
|
||||
ColumnLayout {
|
||||
id: column
|
||||
implicitHeight: childrenRect.height
|
||||
spacing: 5
|
||||
|
||||
anchors {
|
||||
fill: parent
|
||||
margins: 5
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: SystemTray.items;
|
||||
|
||||
Item {
|
||||
required property var modelData;
|
||||
readonly property alias menu: menuWatcher.menu;
|
||||
|
||||
SystemTrayMenuWatcher {
|
||||
id: menuWatcher;
|
||||
trayItem: modelData;
|
||||
}
|
||||
|
||||
property bool targetMenuOpen: false;
|
||||
onTargetMenuOpenChanged: menu.showChildren = targetMenuOpen
|
||||
|
||||
Layout.fillWidth: true
|
||||
implicitHeight: width
|
||||
Behavior on implicitHeight {
|
||||
SmoothedAnimation { velocity: 50 }
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
anchors {
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
width: height
|
||||
|
||||
hoverEnabled: true
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
|
||||
|
||||
Image {
|
||||
id: image
|
||||
anchors.fill: parent
|
||||
|
||||
anchors.margins: mouseArea.pressed || targetMenuOpen ? 3 : 0
|
||||
Behavior on anchors.margins { SmoothedAnimation { velocity: 30 } }
|
||||
|
||||
source: modelData.icon
|
||||
sourceSize.width: width
|
||||
sourceSize.height: height
|
||||
cache: false
|
||||
visible: false
|
||||
}
|
||||
|
||||
MultiEffect {
|
||||
anchors.fill: image
|
||||
source: image
|
||||
|
||||
property real targetBrightness: mouseArea.pressed || targetMenuOpen ? -25 : mouseArea.containsMouse ? 75 : 0
|
||||
Behavior on targetBrightness { SmoothedAnimation { velocity: 600 } }
|
||||
brightness: targetBrightness / 1000
|
||||
}
|
||||
|
||||
onClicked: event => {
|
||||
event.accepted = true;
|
||||
|
||||
if (event.button == Qt.LeftButton) {
|
||||
modelData.activate();
|
||||
} else if (event.button == Qt.MiddleButton) {
|
||||
modelData.secondaryActivate();
|
||||
} else if (event.button == Qt.RightButton && menu != null) {
|
||||
targetMenuOpen = !targetMenuOpen;
|
||||
}
|
||||
}
|
||||
|
||||
onWheel: event => {
|
||||
event.accepted = true;
|
||||
const points = event.angleDelta.y / 120
|
||||
modelData.scroll(points, false);
|
||||
}
|
||||
|
||||
property var tooltip: TooltipItem {
|
||||
anchors.fill: parent
|
||||
tooltip: bar.widgetSurface.tooltip
|
||||
owner: image
|
||||
|
||||
show: mouseArea.containsMouse
|
||||
implicitWidth: tooltipText.implicitWidth
|
||||
implicitHeight: tooltipText.implicitHeight
|
||||
|
||||
Text {
|
||||
id: tooltipText
|
||||
anchors.fill: parent
|
||||
text: modelData.tooltipTitle != "" ? modelData.tooltipTitle : modelData.id
|
||||
color: "white"
|
||||
}
|
||||
}
|
||||
|
||||
property var rightclickMenu: TooltipItem {
|
||||
anchors.fill: parent
|
||||
tooltip: bar.widgetSurface.tooltip
|
||||
owner: image
|
||||
|
||||
isMenu: true
|
||||
show: targetMenuOpen && menu.showChildren
|
||||
animateSize: !rightclickItems.animating
|
||||
implicitHeight: rightclickItems.implicitHeight
|
||||
implicitWidth: rightclickItems.implicitWidth
|
||||
|
||||
onVisibleChanged: {
|
||||
if (!visible) targetMenuOpen = false;
|
||||
}
|
||||
|
||||
onClose: targetMenuOpen = false;
|
||||
|
||||
MenuItemList {
|
||||
id: rightclickItems
|
||||
anchors.fill: parent
|
||||
items: menu == null ? [] : menu.children
|
||||
onClose: targetMenuOpen = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue