mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-29 16:02:51 -05:00
popout: fix sizing on older QT
This commit is contained in:
@@ -15,19 +15,19 @@ Rectangle {
|
|||||||
|
|
||||||
function isActiveProfile(profile) {
|
function isActiveProfile(profile) {
|
||||||
if (typeof PowerProfiles === "undefined") {
|
if (typeof PowerProfiles === "undefined") {
|
||||||
return false
|
return false;
|
||||||
}
|
}
|
||||||
return PowerProfiles.profile === profile
|
return PowerProfiles.profile === profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setProfile(profile) {
|
function setProfile(profile) {
|
||||||
if (typeof PowerProfiles === "undefined") {
|
if (typeof PowerProfiles === "undefined") {
|
||||||
ToastService.showError("power-profiles-daemon not available")
|
ToastService.showError("power-profiles-daemon not available");
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
PowerProfiles.profile = profile
|
PowerProfiles.profile = profile;
|
||||||
if (PowerProfiles.profile !== profile) {
|
if (PowerProfiles.profile !== profile) {
|
||||||
ToastService.showError("Failed to set power profile")
|
ToastService.showError("Failed to set power profile");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +42,6 @@ Rectangle {
|
|||||||
Row {
|
Row {
|
||||||
id: headerRow
|
id: headerRow
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: 48
|
|
||||||
spacing: Theme.spacingM
|
spacing: Theme.spacingM
|
||||||
|
|
||||||
DankIcon {
|
DankIcon {
|
||||||
@@ -50,10 +49,10 @@ Rectangle {
|
|||||||
size: Theme.iconSizeLarge
|
size: Theme.iconSizeLarge
|
||||||
color: {
|
color: {
|
||||||
if (BatteryService.isLowBattery && !BatteryService.isCharging)
|
if (BatteryService.isLowBattery && !BatteryService.isCharging)
|
||||||
return Theme.error
|
return Theme.error;
|
||||||
if (BatteryService.isCharging || BatteryService.isPluggedIn)
|
if (BatteryService.isCharging || BatteryService.isPluggedIn)
|
||||||
return Theme.primary
|
return Theme.primary;
|
||||||
return Theme.surfaceText
|
return Theme.surfaceText;
|
||||||
}
|
}
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
@@ -71,12 +70,12 @@ Rectangle {
|
|||||||
font.pixelSize: Theme.fontSizeXLarge
|
font.pixelSize: Theme.fontSizeXLarge
|
||||||
color: {
|
color: {
|
||||||
if (BatteryService.isLowBattery && !BatteryService.isCharging) {
|
if (BatteryService.isLowBattery && !BatteryService.isCharging) {
|
||||||
return Theme.error
|
return Theme.error;
|
||||||
}
|
}
|
||||||
if (BatteryService.isCharging) {
|
if (BatteryService.isCharging) {
|
||||||
return Theme.primary
|
return Theme.primary;
|
||||||
}
|
}
|
||||||
return Theme.surfaceText
|
return Theme.surfaceText;
|
||||||
}
|
}
|
||||||
font.weight: Font.Bold
|
font.weight: Font.Bold
|
||||||
}
|
}
|
||||||
@@ -86,12 +85,12 @@ Rectangle {
|
|||||||
font.pixelSize: Theme.fontSizeLarge
|
font.pixelSize: Theme.fontSizeLarge
|
||||||
color: {
|
color: {
|
||||||
if (BatteryService.isLowBattery && !BatteryService.isCharging) {
|
if (BatteryService.isLowBattery && !BatteryService.isCharging) {
|
||||||
return Theme.error
|
return Theme.error;
|
||||||
}
|
}
|
||||||
if (BatteryService.isCharging) {
|
if (BatteryService.isCharging) {
|
||||||
return Theme.primary
|
return Theme.primary;
|
||||||
}
|
}
|
||||||
return Theme.surfaceText
|
return Theme.surfaceText;
|
||||||
}
|
}
|
||||||
font.weight: Font.Medium
|
font.weight: Font.Medium
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
@@ -100,12 +99,13 @@ Rectangle {
|
|||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: {
|
text: {
|
||||||
if (!BatteryService.batteryAvailable) return "Power profile management available"
|
if (!BatteryService.batteryAvailable)
|
||||||
const time = BatteryService.formatTimeRemaining()
|
return "Power profile management available";
|
||||||
|
const time = BatteryService.formatTimeRemaining();
|
||||||
if (time !== "Unknown") {
|
if (time !== "Unknown") {
|
||||||
return BatteryService.isCharging ? `Time until full: ${time}` : `Time remaining: ${time}`
|
return BatteryService.isCharging ? `Time until full: ${time}` : `Time remaining: ${time}`;
|
||||||
}
|
}
|
||||||
return ""
|
return "";
|
||||||
}
|
}
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
color: Theme.surfaceTextMedium
|
color: Theme.surfaceTextMedium
|
||||||
@@ -145,10 +145,10 @@ Rectangle {
|
|||||||
font.pixelSize: Theme.fontSizeLarge
|
font.pixelSize: Theme.fontSizeLarge
|
||||||
color: {
|
color: {
|
||||||
if (BatteryService.batteryHealth === "N/A") {
|
if (BatteryService.batteryHealth === "N/A") {
|
||||||
return Theme.surfaceText
|
return Theme.surfaceText;
|
||||||
}
|
}
|
||||||
const healthNum = parseInt(BatteryService.batteryHealth)
|
const healthNum = parseInt(BatteryService.batteryHealth);
|
||||||
return healthNum < 80 ? Theme.error : Theme.surfaceText
|
return healthNum < 80 ? Theme.error : Theme.surfaceText;
|
||||||
}
|
}
|
||||||
font.weight: Font.Bold
|
font.weight: Font.Bold
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
@@ -189,8 +189,9 @@ Rectangle {
|
|||||||
DankButtonGroup {
|
DankButtonGroup {
|
||||||
property var profileModel: (typeof PowerProfiles !== "undefined") ? [PowerProfile.PowerSaver, PowerProfile.Balanced].concat(PowerProfiles.hasPerformanceProfile ? [PowerProfile.Performance] : []) : [PowerProfile.PowerSaver, PowerProfile.Balanced, PowerProfile.Performance]
|
property var profileModel: (typeof PowerProfiles !== "undefined") ? [PowerProfile.PowerSaver, PowerProfile.Balanced].concat(PowerProfiles.hasPerformanceProfile ? [PowerProfile.Performance] : []) : [PowerProfile.PowerSaver, PowerProfile.Balanced, PowerProfile.Performance]
|
||||||
property int currentProfileIndex: {
|
property int currentProfileIndex: {
|
||||||
if (typeof PowerProfiles === "undefined") return 1
|
if (typeof PowerProfiles === "undefined")
|
||||||
return profileModel.findIndex(profile => isActiveProfile(profile))
|
return 1;
|
||||||
|
return profileModel.findIndex(profile => isActiveProfile(profile));
|
||||||
}
|
}
|
||||||
|
|
||||||
model: profileModel.map(profile => Theme.getPowerProfileLabel(profile))
|
model: profileModel.map(profile => Theme.getPowerProfileLabel(profile))
|
||||||
@@ -198,8 +199,9 @@ Rectangle {
|
|||||||
selectionMode: "single"
|
selectionMode: "single"
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
onSelectionChanged: (index, selected) => {
|
onSelectionChanged: (index, selected) => {
|
||||||
if (!selected) return
|
if (!selected)
|
||||||
setProfile(profileModel[index])
|
return;
|
||||||
|
setProfile(profileModel[index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -433,7 +433,7 @@ Item {
|
|||||||
Loader {
|
Loader {
|
||||||
id: contentLoader
|
id: contentLoader
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
active: contentWindow.visible
|
active: shouldBeVisible || contentWindow.visible
|
||||||
asynchronous: false
|
asynchronous: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user