functional tray
This commit is contained in:
parent
0d9392b744
commit
8ac31838d5
6 changed files with 96 additions and 49 deletions
|
|
@ -13,6 +13,7 @@ Singleton {
|
|||
property Clock clock: Clock {}
|
||||
property Workspace workspace: Workspace {}
|
||||
property Tray tray: Tray {}
|
||||
property TrayMenu trayMenu: TrayMenu {}
|
||||
|
||||
component Bar: QtObject {
|
||||
id: bar
|
||||
|
|
@ -65,4 +66,14 @@ Singleton {
|
|||
property int verticalPadding: 6
|
||||
property int horizontalPadding: 7
|
||||
}
|
||||
|
||||
component TrayMenu: QtObject {
|
||||
id: trayItem
|
||||
|
||||
property int fontSize: 10
|
||||
property int width: 30
|
||||
property int height: 30
|
||||
property int verticalPadding: 6
|
||||
property int horizontalPadding: 7
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import "../../config/"
|
|||
|
||||
Scope {
|
||||
PanelWindow {
|
||||
id: root
|
||||
id: parentWindow
|
||||
|
||||
anchors.top: true
|
||||
anchors.left: true
|
||||
|
|
|
|||
|
|
@ -10,6 +10,14 @@ Row {
|
|||
Repeater {
|
||||
model: SystemTray.items
|
||||
|
||||
TrayItem {}
|
||||
Loader {
|
||||
required property SystemTrayItem modelData
|
||||
active: true
|
||||
|
||||
sourceComponent: item
|
||||
property Component item: TrayItem {
|
||||
trayItem: modelData
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,50 +7,62 @@ import "../../../../config/"
|
|||
import "../../../../styled/"
|
||||
import "menu/"
|
||||
|
||||
Loader {
|
||||
required property SystemTrayItem modelData
|
||||
Clickable {
|
||||
id: root
|
||||
|
||||
active: modelData.hasMenu
|
||||
property SystemTrayItem trayItem
|
||||
property bool menuOpened: false
|
||||
|
||||
onLoaded: console.log(modelData.icon)
|
||||
sourceComponent: item
|
||||
property Component item: Clickable {
|
||||
id: clickable
|
||||
implicitWidth: Dimensions.tray.width
|
||||
implicitHeight: Dimensions.tray.height
|
||||
|
||||
property bool menuOpen
|
||||
onClicked: toggleMenu()
|
||||
|
||||
width: Dimensions.tray.width
|
||||
height: Dimensions.tray.height
|
||||
function toggleMenu() {
|
||||
menuOpened = !menuOpened;
|
||||
}
|
||||
|
||||
onClicked: menuOpen = !menuOpen
|
||||
|
||||
IconImage {
|
||||
id: icon
|
||||
anchors.margins: 6
|
||||
anchors.fill: parent
|
||||
asynchronous: true
|
||||
source: {
|
||||
let icon = modelData.icon;
|
||||
if (icon.includes("?path=")) {
|
||||
const [name, path] = icon.split("?path=");
|
||||
icon = `file://${path}/${name.slice(name.lastIndexOf("/") + 1)}`;
|
||||
}
|
||||
return icon;
|
||||
IconImage {
|
||||
id: icon
|
||||
anchors.margins: 6
|
||||
anchors.fill: parent
|
||||
asynchronous: true
|
||||
source: {
|
||||
let icon = modelData.icon;
|
||||
if (icon.includes("?path=")) {
|
||||
const [name, path] = icon.split("?path=");
|
||||
icon = `file://${path}/${name.slice(name.lastIndexOf("/") + 1)}`;
|
||||
}
|
||||
anchors.centerIn: parent
|
||||
return icon;
|
||||
}
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
|
||||
PopupWindow {
|
||||
id: popup
|
||||
|
||||
visible: root.menuOpened
|
||||
|
||||
color: 'transparent'
|
||||
|
||||
anchor.item: root
|
||||
anchor.rect.x: root.width / 2 - width / 2
|
||||
anchor.rect.y: root.height + 8
|
||||
|
||||
implicitWidth: menu.width
|
||||
implicitHeight: menu.height
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: Theme.palette.base300
|
||||
radius: 8
|
||||
}
|
||||
|
||||
// Loader {
|
||||
// active: menuOpen && modelData.hasMenu
|
||||
//
|
||||
// property Component menu: Menu {
|
||||
// menu: modelData.menu
|
||||
// }
|
||||
// }
|
||||
PopupWindow {
|
||||
Menu {
|
||||
id: menu
|
||||
|
||||
Menu {
|
||||
menu: modelData.menu
|
||||
menuOpener: QsMenuOpener {
|
||||
menu: trayItem.menu
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +1,29 @@
|
|||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import "../../../../../config/"
|
||||
import "../../../../../styled/"
|
||||
|
||||
ColumnLayout {
|
||||
property QsMenuOpener menu
|
||||
id: menu
|
||||
property QsMenuOpener menuOpener
|
||||
|
||||
anchors.margins: 8
|
||||
|
||||
Repeater {
|
||||
model: modelData.children
|
||||
|
||||
Loader {
|
||||
id: loader
|
||||
model: menuOpener.children
|
||||
delegate: Loader {
|
||||
required property QsMenuEntry modelData
|
||||
active: true
|
||||
|
||||
active: modelData.enabled
|
||||
|
||||
sourceComponent: menuItem
|
||||
sourceComponent: modelData.isSeparator ? menuSeperator : menuItem
|
||||
property Component menuSeperator: Rectangle {
|
||||
implicitHeight: 1
|
||||
implicitWidth: menu.width
|
||||
color: Theme.palette.basecontent
|
||||
}
|
||||
property Component menuItem: MenuItem {
|
||||
menuEntry: loader.modelData
|
||||
menuEntry: modelData
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import "../../../../../config/"
|
||||
import "../../../../../styled/"
|
||||
|
||||
Clickable {
|
||||
|
|
@ -8,11 +9,20 @@ Clickable {
|
|||
property QsMenuEntry menuEntry
|
||||
|
||||
implicitWidth: text.width
|
||||
implicitHeight: 30
|
||||
|
||||
Text {
|
||||
onClicked: menuEntry.triggered()
|
||||
|
||||
StyledText {
|
||||
id: text
|
||||
text: item.menuEntry.text
|
||||
|
||||
padding: 8
|
||||
font.pixelSize: Dimensions.clock.fontSize
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
topPadding: Dimensions.clock.verticalPadding
|
||||
bottomPadding: Dimensions.clock.verticalPadding
|
||||
leftPadding: Dimensions.clock.horizontalPadding
|
||||
rightPadding: Dimensions.clock.horizontalPadding
|
||||
|
||||
text: item.menuEntry.text
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue