You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
statusbar/qml/main.qml

219 lines
6.6 KiB
QML

5 years ago
import QtQuick 2.12
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.12
import Cutefish.StatusBar 1.0
5 years ago
import Cutefish.NetworkManagement 1.0 as NM
5 years ago
import MeuiKit 1.0 as Meui
Item {
id: rootItem
5 years ago
property int iconSize: 16
5 years ago
Rectangle {
id: background
anchors.fill: parent
color: Meui.Theme.backgroundColor
opacity: 0.6
5 years ago
Behavior on color {
ColorAnimation {
duration: 200
easing.type: Easing.Linear
}
}
5 years ago
}
Meui.PopupTips {
id: popupTips
backgroundColor: Meui.Theme.backgroundColor
backgroundOpacity: Meui.Theme.darkMode ? 0.3 : 0.4
}
RowLayout {
anchors.fill: parent
anchors.leftMargin: Meui.Units.smallSpacing
anchors.rightMargin: Meui.Units.smallSpacing
5 years ago
spacing: 0
5 years ago
StandardItem {
id: acticityItem
Layout.fillHeight: true
width: acticityLayout.implicitWidth + Meui.Units.largeSpacing
RowLayout {
id: acticityLayout
anchors.fill: parent
anchors.leftMargin: Meui.Units.smallSpacing
anchors.rightMargin: Meui.Units.smallSpacing
Label {
text: acticity.title
}
}
}
5 years ago
Item {
Layout.fillWidth: true
}
ListView {
id: trayView
orientation: Qt.Horizontal
layoutDirection: Qt.RightToLeft
interactive: false
clip: true
spacing: 0
property var itemSize: rootItem.height * 0.8
property var itemWidth: itemSize + Meui.Units.largeSpacing
Layout.fillHeight: true
Layout.preferredWidth: itemWidth * count
model: SystemTrayModel {
id: trayModel
}
delegate: StandardItem {
width: trayView.itemWidth
height: ListView.view.height
5 years ago
property bool darkMode: Meui.Theme.darkMode
onDarkModeChanged: updateTimer.restart()
Timer {
id: updateTimer
interval: 10
onTriggered: iconItem.updateIcon()
}
Meui.IconItem {
5 years ago
id: iconItem
5 years ago
anchors.centerIn: parent
5 years ago
width: rootItem.iconSize
5 years ago
height: width
source: model.iconName ? model.iconName : model.icon
5 years ago
}
onClicked: trayModel.leftButtonClick(model.id)
onRightClicked: trayModel.rightButtonClick(model.id)
popupText: model.toolTip ? model.toolTip : model.title
}
}
StandardItem {
id: controler
Layout.fillHeight: true
5 years ago
Layout.preferredWidth: _controlerLayout.implicitWidth + Meui.Units.largeSpacing
5 years ago
onClicked: {
if (controlDialog.visible)
controlDialog.visible = false
else {
// 先初始化用户可能会通过Alt鼠标左键移动位置
controlDialog.position = Qt.point(0, 0)
controlDialog.visible = true
controlDialog.position = Qt.point(mapToGlobal(0, 0).x, mapToGlobal(0, 0).y)
}
}
RowLayout {
id: _controlerLayout
anchors.fill: parent
5 years ago
anchors.leftMargin: Meui.Units.smallSpacing
anchors.rightMargin: Meui.Units.smallSpacing
5 years ago
spacing: Meui.Units.largeSpacing
Image {
id: volumeIcon
visible: volume.isValid && status === Image.Ready
source: "qrc:/images/" + (Meui.Theme.darkMode ? "dark/" : "light/") + volume.iconName + ".svg"
5 years ago
width: rootItem.iconSize
5 years ago
height: width
sourceSize: Qt.size(width, height)
asynchronous: true
Layout.alignment: Qt.AlignCenter
}
Image {
id: wirelessIcon
5 years ago
width: rootItem.iconSize
5 years ago
height: width
sourceSize: Qt.size(width, height)
source: network.wirelessIconName ? "qrc:/images/" + (Meui.Theme.darkMode ? "dark/" : "light/") + network.wirelessIconName + ".svg" : ""
asynchronous: true
Layout.alignment: Qt.AlignCenter
visible: network.enabled &&
network.wirelessEnabled &&
network.wirelessConnectionName !== "" &&
wirelessIcon.status === Image.Ready
}
Image {
id: batteryIcon
visible: battery.available && status === Image.Ready
5 years ago
height: rootItem.iconSize
5 years ago
width: height + 6
sourceSize: Qt.size(width, height)
source: "qrc:/images/" + (Meui.Theme.darkMode ? "dark/" : "light/") + battery.iconSource
Layout.alignment: Qt.AlignCenter
asynchronous: true
}
// Image {
// id: powerIcon
// height: rootItem.iconSize + 2
// width: height
// sourceSize: Qt.size(width, height)
// source: "qrc:/images/" + (Meui.Theme.darkMode ? "dark/" : "light/") + "system-shutdown-symbolic.svg"
// Layout.alignment: Qt.AlignCenter
// asynchronous: true
// }
5 years ago
Label {
id: timeLabel
Layout.alignment: Qt.AlignCenter
font.pixelSize: rootItem.height * 0.5
Timer {
interval: 1000
repeat: true
running: true
triggeredOnStart: true
onTriggered: {
timeLabel.text = new Date().toLocaleTimeString(Qt.locale(), Locale.ShortFormat)
}
}
}
}
}
}
// Components
ControlDialog {
id: controlDialog
}
Volume {
id: volume
}
Battery {
id: battery
}
NM.ConnectionIcon {
id: connectionIconProvider
}
NM.Network {
id: network
}
}