2025-04-23 10:22:03 +00:00
|
|
|
// SPDX-FileCopyrightText: 2022-2025 Devin Lin <devin@kde.org>
|
|
|
|
|
// SPDX-License-Identifier: LGPL-2.0-or-later
|
2022-02-11 04:20:04 +00:00
|
|
|
|
2023-03-17 02:44:36 +00:00
|
|
|
import org.kde.plasma.private.mobileshell.quicksettingsplugin as QS
|
2025-04-23 10:22:03 +00:00
|
|
|
import org.kde.plasma.private.batterymonitor
|
2022-02-11 04:20:04 +00:00
|
|
|
|
2023-03-17 02:44:36 +00:00
|
|
|
QS.QuickSetting {
|
2022-02-11 04:20:04 +00:00
|
|
|
text: i18n("Caffeine")
|
|
|
|
|
icon: "system-suspend-hibernate"
|
|
|
|
|
status: enabled ? i18n("Tap to disable sleep suspension") : i18n("Tap to suspend sleep")
|
2025-04-23 10:22:03 +00:00
|
|
|
enabled: inhibitionControl.isManuallyInhibited
|
2022-02-11 04:20:04 +00:00
|
|
|
|
2025-04-23 10:22:03 +00:00
|
|
|
InhibitionControl {
|
|
|
|
|
id: inhibitionControl
|
|
|
|
|
isSilent: false
|
2022-02-11 04:20:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggle() {
|
2025-04-23 10:22:03 +00:00
|
|
|
if (enabled) {
|
|
|
|
|
inhibitionControl.uninhibit();
|
2022-02-11 04:20:04 +00:00
|
|
|
} else {
|
2025-04-23 10:22:03 +00:00
|
|
|
const reason = i18nc("@info", "Plasma Mobile has enabled system-wide inhibition");
|
|
|
|
|
inhibitionControl.inhibit(reason);
|
2022-02-11 04:20:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|