barmodule: own hoverpanel internally, modules supply content as component
This commit is contained in:
parent
26476dc930
commit
6fd36c812f
17 changed files with 367 additions and 453 deletions
|
|
@ -16,6 +16,53 @@ M.BarModule {
|
|||
return "Bluetooth: off";
|
||||
return "Bluetooth: on";
|
||||
}
|
||||
panelNamespace: "nova-bluetooth"
|
||||
panelTitle: "Bluetooth"
|
||||
panelContentWidth: 250
|
||||
titleActionsComponent: Component {
|
||||
Item {
|
||||
width: 20
|
||||
height: 20
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "\uF011"
|
||||
color: S.BluetoothService.enabled ? root.accentColor : S.Theme.base04
|
||||
font.pixelSize: S.Theme.fontSize
|
||||
font.family: S.Theme.iconFontFamily
|
||||
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: 100
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HoverHandler {
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
onTapped: S.BluetoothService.setPower(!S.BluetoothService.enabled)
|
||||
}
|
||||
}
|
||||
}
|
||||
panelComponent: Component {
|
||||
C.BluetoothApplet {
|
||||
width: parent.width
|
||||
accentColor: root.accentColor
|
||||
}
|
||||
}
|
||||
|
||||
on_ShowPanelChanged: if (_showPanel)
|
||||
S.BluetoothService.refresh()
|
||||
|
||||
Connections {
|
||||
target: S.BluetoothService
|
||||
function onDevicesChanged() {
|
||||
root.keepPanelOpen(500);
|
||||
}
|
||||
}
|
||||
|
||||
M.BarIcon {
|
||||
icon: "\uF294"
|
||||
|
|
@ -27,59 +74,4 @@ M.BarModule {
|
|||
label: S.BluetoothService.device + (S.BluetoothService.batteryPct >= 0 ? " " + S.BluetoothService.batteryPct + "%" : "")
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: S.BluetoothService
|
||||
function onDevicesChanged() {
|
||||
hoverPanel.keepOpen(500);
|
||||
}
|
||||
}
|
||||
|
||||
M.HoverPanel {
|
||||
id: hoverPanel
|
||||
showPanel: root._showPanel
|
||||
screen: QsWindow.window?.screen ?? null
|
||||
anchorItem: root
|
||||
accentColor: root.accentColor
|
||||
panelNamespace: "nova-bluetooth"
|
||||
panelTitle: "Bluetooth"
|
||||
contentWidth: 250
|
||||
onDismissed: root.dismissPanel()
|
||||
titleActionsComponent: Component {
|
||||
Item {
|
||||
width: 20
|
||||
height: 20
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "\uF011"
|
||||
color: S.BluetoothService.enabled ? hoverPanel.accentColor : S.Theme.base04
|
||||
font.pixelSize: S.Theme.fontSize
|
||||
font.family: S.Theme.iconFontFamily
|
||||
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: 100
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HoverHandler {
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
onTapped: S.BluetoothService.setPower(!S.BluetoothService.enabled)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onVisibleChanged: if (visible)
|
||||
S.BluetoothService.refresh()
|
||||
|
||||
C.BluetoothApplet {
|
||||
width: hoverPanel.contentWidth
|
||||
accentColor: root.accentColor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue