Verified Commit a0533d12 authored by ivan tkachenko's avatar ivan tkachenko
Browse files

plasmoid: Copy InhibitionHint from battery applet

parent 280b8537
Pipeline #178164 passed with stage
in 1 minute and 59 seconds
/*
SPDX-FileCopyrightText: 2015 Kai Uwe Broulik <kde@privat.broulik.de>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
import QtQuick 2.15
import QtQuick.Layouts 1.15
import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.plasma.core 2.1 as PlasmaCore
// everything like in battery applet, but slightly bigger
RowLayout {
property alias iconSource: iconItem.source
property alias text: label.text
spacing: PlasmaCore.Units.smallSpacing * 2
PlasmaCore.IconItem {
id: iconItem
Layout.preferredWidth: PlasmaCore.Units.iconSizes.medium
Layout.preferredHeight: PlasmaCore.Units.iconSizes.medium
visible: valid
}
PlasmaComponents3.Label {
id: label
Layout.fillWidth: true
Layout.maximumWidth: Math.min(PlasmaCore.Units.gridUnit * 20, implicitWidth)
font: PlasmaCore.Theme.smallestFont
textFormat: Text.PlainText
wrapMode: Text.WordWrap
elide: Text.ElideRight
maximumLineCount: 4
}
}
......@@ -62,44 +62,29 @@ ColumnLayout {
wrapMode: Text.WordWrap
}
RowLayout {
InhibitionHint {
Layout.fillWidth: true
Layout.leftMargin: checkBox.indicator.width + checkBox.spacing
spacing: PlasmaCore.Units.smallSpacing
PlasmaCore.IconItem {
Layout.preferredWidth: PlasmaCore.Units.iconSizes.medium
Layout.preferredHeight: PlasmaCore.Units.iconSizes.medium
source: pmSource.inhibitions.length > 0 ? pmSource.inhibitions[0].Icon || "" : ""
visible: valid
}
PlasmaComponents3.Label {
Layout.fillWidth: true
Layout.maximumWidth: Math.min(PlasmaCore.Units.gridUnit * 20, implicitWidth)
font: PlasmaCore.Theme.smallestFont
wrapMode: Text.WordWrap
elide: Text.ElideRight
textFormat: Text.PlainText
text: {
const inhibitions = pmSource.inhibitions;
const inhibition = inhibitions[0];
if (inhibitions.length > 1) {
return i18ncp("Some Application and n others enforce presentation mode",
"%2 and %1 other application are enforcing presentation mode.",
"%2 and %1 other applications are enforcing presentation mode.",
inhibitions.length - 1, inhibition.Name) // plural only works on %1
} else if (inhibitions.length === 1) {
if (!inhibition.Reason) {
return i18nc("Some Application enforce presentation mode",
"%1 is enforcing presentation mode.", inhibition.Name)
} else {
return i18nc("Some Application enforce presentation mode: Reason provided by the app",
"%1 is enforcing presentation mode: %2", inhibition.Name, inhibition.Reason)
}
iconSource: pmSource.inhibitions.length > 0 ? pmSource.inhibitions[0].Icon || "" : ""
text: {
const inhibitions = pmSource.inhibitions;
const inhibition = inhibitions[0];
if (inhibitions.length > 1) {
return i18ncp("Some Application and n others enforce presentation mode",
"%2 and %1 other application are enforcing presentation mode.",
"%2 and %1 other applications are enforcing presentation mode.",
inhibitions.length - 1, inhibition.Name) // plural only works on %1
} else if (inhibitions.length === 1) {
if (!inhibition.Reason) {
return i18nc("Some Application enforce presentation mode",
"%1 is enforcing presentation mode.", inhibition.Name)
} else {
return "";
return i18nc("Some Application enforce presentation mode: Reason provided by the app",
"%1 is enforcing presentation mode: %2", inhibition.Name, inhibition.Reason)
}
} else {
return "";
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment