Skip to content

Commit

Permalink
Added battery indicator support
Browse files Browse the repository at this point in the history
- Added support for battery indicator.
- Fixed layout when Pegasus is not in fullscreen mode.
- Time and battery now only will show when in fullscreen mode.
  • Loading branch information
David Fumberger committed Apr 10, 2021
1 parent ce677fa commit 194c13c
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 8 deletions.
Binary file added assets/images/battery-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/battery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions components/BatteryIndicator.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import QtQuick 2.12
import QtGraphicalEffects 1.12
import QtGraphicalEffects 1.0
import QtQuick.Layouts 1.15
Item {
width: 26
height: 14

property var lightStyle : false

property var percent: {
api.device ? api.device.batteryPercent : 0
}

Image {
id: iconImage
source: lightStyle ? "../assets/images/battery.png" : "../assets/images/battery-dark.png"
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
}

Rectangle {
anchors.leftMargin: 2
anchors.topMargin: 3
anchors.top: parent.top
anchors.left: parent.left
color: lightStyle ? "#ffffff" : "#000000"
radius: 2
width: Math.max(percent * 17.6, 2)
height: 8
}
}
29 changes: 25 additions & 4 deletions components/HeaderHome.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ Rectangle {

property var light: false

property var showStatusInfo : {
return layoutScreen.height >= 480
}

property var showBattery : {
return showStatusInfo && (api.device != null && api.device.batteryPercent)
}

id: home_header
color: "transparent"
width: parent.width
Expand Down Expand Up @@ -86,17 +94,30 @@ Rectangle {
KeyNavigation.down: mainFocus
}


BatteryIndicator {
id: battery_indicator
anchors.right: parent.right
anchors.top: parent.top
anchors.topMargin: 20
anchors.rightMargin: 32
opacity: 0.5
lightStyle: light
visible: showBattery
}

Text {
id: header_time
text: Qt.formatTime(new Date(), "hh:mm")
anchors.right: parent.right
anchors.right: parent.right
anchors.top: parent.top
anchors.topMargin: 16
anchors.rightMargin: 32
anchors.rightMargin: showBattery ? 70 : 32
color: light ? "#60ffffff" : "#60000000"
font.pixelSize: 18
font.letterSpacing: -0.3
font.bold: true
font.bold: true
visible: showStatusInfo
}

}
4 changes: 2 additions & 2 deletions components/SystemsListLarge.qml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ ListView {
Rectangle {
property int bgIndex: -1
id: systemsBackground
width: 640
height: 480
width: layoutScreen.width
height: layoutScreen.height
anchors.top: parent.top
anchors.left: parent.left
anchors.topMargin: -55
Expand Down
4 changes: 2 additions & 2 deletions theme.qml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ FocusScope {

property var layoutScreen : {
"width": 640,
"height": 480,
"height": parent.height,
"background": theme.background,
}

Expand All @@ -235,7 +235,7 @@ FocusScope {

property var layoutContainer : {
"width": layoutScreen.width,
"height": layoutScreen.height - layoutHeader.height - layoutHeader.height,
"height": parent.height - layoutHeader.height - layoutHeader.height,
"background": "transparent",

}
Expand Down

0 comments on commit 194c13c

Please sign in to comment.