shift-shell/components/mobileshell/qml/statusbar/StatusBar.qml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

206 lines
6.7 KiB
QML
Raw Normal View History

/*
* SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org>
* SPDX-FileCopyrightText: 2021 Devin Lin <espidev@gmail.com>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
2023-05-13 02:07:48 +00:00
import QtQuick
import QtQuick.Layouts
import QtQuick.Effects
import QtQuick.Controls as Controls
import QtQml.Models
import org.kde.kirigami as Kirigami
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.plasma5support 2.0 as P5Support
import org.kde.plasma.private.systemtray as SystemTray
import org.kde.plasma.components 3.0 as PlasmaComponents
import org.kde.kitemmodels as KItemModels
import org.kde.plasma.private.mobileshell as MobileShell
import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings
Item {
id: root
2024-01-21 07:23:17 +00:00
/**
* Whether to show a drop shadow under the status bar.
*/
property bool showDropShadow: false
2024-01-21 07:23:17 +00:00
/**
* The background color of the status bar.
*/
property color backgroundColor: "transparent"
2024-01-21 07:23:17 +00:00
/**
* Whether to show a second row of the status bar, with more information.
*/
property bool showSecondRow: false // show extra row with date and mobile provider
2024-01-21 07:23:17 +00:00
/**
* Whether to show time. If set to false, the signal strength indicator is moved in its place.
*/
property bool showTime: true
2024-01-21 07:23:17 +00:00
/**
* Disables showing system tray indicators, preventing SIGABRT when used on the lockscreen.
*/
property bool disableSystemTray: false
2024-01-21 07:23:17 +00:00
property color colorScopeColor: Kirigami.Theme.backgroundColor
2024-01-21 07:23:17 +00:00
readonly property real textPixelSize: Math.round(11 * ShellSettings.Settings.statusBarScaleFactor)
readonly property real smallerTextPixelSize: Math.round(9 * ShellSettings.Settings.statusBarScaleFactor)
readonly property real elementSpacing: Math.round(Kirigami.Units.smallSpacing * 1.5)
2024-01-21 07:23:17 +00:00
P5Support.DataSource {
id: timeSource
engine: "time"
connectedSources: ["Local"]
interval: 1000
2023-03-09 15:45:30 +00:00
intervalAlignment: P5Support.Types.AlignToMinute
}
2024-01-21 07:23:17 +00:00
property alias statusNotifierSource: statusNotifierSourceLoader.item
2024-01-21 07:23:17 +00:00
Loader {
id: statusNotifierSourceLoader
active: !disableSystemTray
sourceComponent: SystemTray.StatusNotifierModel { }
}
2023-05-13 02:07:48 +00:00
// drop shadow for icons
MultiEffect {
2023-09-29 03:41:18 +00:00
anchors.fill: control
visible: showDropShadow
2023-09-29 03:41:18 +00:00
source: control
2023-05-13 02:07:48 +00:00
blurMax: 16
shadowEnabled: true
shadowVerticalOffset: 1
shadowOpacity: 0.8
}
// screen top panel
2023-09-29 03:41:18 +00:00
Controls.Control {
id: control
z: 1
2023-09-29 03:41:18 +00:00
topPadding: Kirigami.Units.smallSpacing
bottomPadding: Kirigami.Units.smallSpacing
rightPadding: Kirigami.Units.smallSpacing * 3
leftPadding: Kirigami.Units.smallSpacing * 3
anchors.fill: parent
2023-09-29 03:41:18 +00:00
background: Rectangle {
id: panelBackground
color: backgroundColor
}
2023-09-29 03:41:18 +00:00
contentItem: ColumnLayout {
spacing: Kirigami.Units.smallSpacing / 2
2023-09-29 03:41:18 +00:00
RowLayout {
id: mainRow
readonly property real rowHeight: MobileShell.Constants.topPanelHeight - Kirigami.Units.smallSpacing * 2
2023-09-29 03:41:18 +00:00
Layout.fillWidth: true
Layout.preferredHeight: rowHeight
spacing: 0
// clock
ClockText {
visible: root.showTime
Layout.fillHeight: true
fontPixelSize: textPixelSize
2023-09-29 03:41:18 +00:00
source: timeSource
}
MobileShell.SignalStrengthIndicator {
2023-09-29 03:41:18 +00:00
Layout.fillHeight: true
showLabel: true
visible: !root.showTime
textPixelSize: root.textPixelSize
}
// spacing in the middle
Item {
Layout.fillWidth: true
}
// system tray
Repeater {
id: statusNotifierRepeater
model: root.statusNotifierSource
2023-09-29 03:41:18 +00:00
delegate: TaskWidget {
Layout.leftMargin: root.elementSpacing
}
}
2023-09-29 03:41:18 +00:00
// system indicators
// using Layout.fillHeight here seems to cause polish loops, instead just define the height of the row
RowLayout {
2023-09-29 03:41:18 +00:00
id: indicators
Layout.leftMargin: Kirigami.Units.smallSpacing // applets have different spacing needs
Layout.maximumHeight: mainRow.rowHeight
spacing: root.elementSpacing
MobileShell.SignalStrengthIndicator {
2023-09-29 03:41:18 +00:00
showLabel: false
visible: root.showTime
2023-09-29 03:41:18 +00:00
internetIndicator: internetIndicatorItem
implicitHeight: mainRow.rowHeight
Layout.preferredWidth: height
}
MobileShell.BluetoothIndicator {
2023-09-29 03:41:18 +00:00
implicitHeight: mainRow.rowHeight
Layout.preferredWidth: height
}
MobileShell.InternetIndicator {
2023-09-29 03:41:18 +00:00
id: internetIndicatorItem
implicitHeight: mainRow.rowHeight
Layout.preferredWidth: height
}
MobileShell.VolumeIndicator {
2023-09-29 03:41:18 +00:00
implicitHeight: mainRow.rowHeight
Layout.preferredWidth: height
}
MobileShell.BatteryIndicator {
2023-09-29 03:41:18 +00:00
spacing: root.elementSpacing
textPixelSize: root.textPixelSize
implicitHeight: mainRow.rowHeight
Layout.preferredWidth: height
}
}
}
// extra row with date and mobile provider (for quicksettings panel)
RowLayout {
spacing: 0
visible: root.showSecondRow
Layout.fillWidth: true
PlasmaComponents.Label {
text: Qt.formatDate(timeSource.data.Local.DateTime, "ddd. MMMM d")
color: Kirigami.Theme.disabledTextColor
font.pixelSize: root.smallerTextPixelSize
}
Item { Layout.fillWidth: true }
PlasmaComponents.Label {
visible: root.showTime
text: MobileShell.SignalStrengthInfo.label
2023-09-29 03:41:18 +00:00
color: Kirigami.Theme.disabledTextColor
font.pixelSize: root.smallerTextPixelSize
horizontalAlignment: Qt.AlignRight
2021-07-14 16:21:31 +00:00
}
}
}
}
}