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.

184 lines
6.1 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.clock
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
import org.kde.plasma.private.mobileshell.state as MobileShellState
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
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
Clock {
id: clockSource
}
2024-01-21 07:23:17 +00:00
MobileShellState.PanelSettingsDBusClient {
id: panelSettings
screenName: Screen.name
}
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 + panelSettings.statusBarLeftPadding
leftPadding: Kirigami.Units.smallSpacing * 3 + panelSettings.statusBarRightPadding
2023-09-29 03:41:18 +00:00
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.defaultTopPanelHeight - Kirigami.Units.smallSpacing * 2
2023-09-29 03:41:18 +00:00
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
2023-09-29 03:41:18 +00:00
Layout.preferredHeight: rowHeight
spacing: 0
// clock
ClockText {
visible: root.showTime
Layout.fillHeight: true
fontPixelSize: textPixelSize
clockSource: clockSource
2023-09-29 03:41:18 +00:00
}
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 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(clockSource.dateTime, "ddd. MMMM d")
2023-09-29 03:41:18 +00:00
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
}
}
}
}
}