-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
55 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
/* | ||
SPDX-FileCopyrightText: 2023 Dmitry Ilyich Sidorov <[email protected]> | ||
SPDX-FileCopyrightText: 2023, 2024 Dmitry Ilyich Sidorov <[email protected]> | ||
SPDX-License-Identifier: LGPL-3.0-or-later | ||
*/ | ||
|
||
import QtQuick 2.0 | ||
|
||
import org.kde.plasma.configuration 2.0 | ||
import QtQuick | ||
import org.kde.plasma.configuration | ||
|
||
ConfigModel { | ||
ConfigCategory { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
/* | ||
SPDX-FileCopyrightText: 2012-2013 Daniel Nicoletti <[email protected]> | ||
SPDX-FileCopyrightText: 2013, 2015 Kai Uwe Broulik <[email protected]> | ||
SPDX-FileCopyrightText: 2024 Dmitry Ilyich Sidorov <[email protected]> | ||
SPDX-License-Identifier: LGPL-2.0-or-later | ||
*/ | ||
|
||
import QtQuick 2.15 | ||
import QtQuick.Layouts 1.15 | ||
import QtQuick | ||
import QtQuick.Layouts | ||
|
||
import org.kde.plasma.components 3.0 as PlasmaComponents3 | ||
import org.kde.plasma.core 2.1 as PlasmaCore | ||
import org.kde.plasma.components as PlasmaComponents | ||
import org.kde.plasma.core as PlasmaCore | ||
import org.kde.kirigami as Kirigami | ||
|
||
PlasmaComponents3.ItemDelegate { | ||
PlasmaComponents.ItemDelegate { | ||
id: root | ||
|
||
property alias slider: control | ||
|
@@ -33,13 +35,13 @@ PlasmaComponents3.ItemDelegate { | |
Keys.forwardTo: [slider] | ||
|
||
contentItem: RowLayout { | ||
spacing: PlasmaCore.Units.gridUnit | ||
spacing: Kirigami.Units.gridUnit | ||
|
||
PlasmaCore.IconItem { | ||
Kirigami.Icon { | ||
id: image | ||
Layout.alignment: Qt.AlignTop | ||
Layout.preferredWidth: PlasmaCore.Units.iconSizes.medium | ||
Layout.preferredHeight: PlasmaCore.Units.iconSizes.medium | ||
Layout.preferredWidth: Kirigami.Units.iconSizes.medium | ||
Layout.preferredHeight: Kirigami.Units.iconSizes.medium | ||
source: root.icon.name | ||
} | ||
|
||
|
@@ -50,22 +52,22 @@ PlasmaComponents3.ItemDelegate { | |
|
||
RowLayout { | ||
Layout.fillWidth: true | ||
spacing: PlasmaCore.Units.smallSpacing | ||
spacing: Kirigami.Units.smallSpacing | ||
|
||
PlasmaComponents3.Label { | ||
PlasmaComponents.Label { | ||
id: title | ||
Layout.fillWidth: true | ||
text: root.text | ||
} | ||
|
||
PlasmaComponents3.Label { | ||
PlasmaComponents.Label { | ||
id: percent | ||
Layout.alignment: Qt.AlignRight | ||
text: i18nc("Placeholder is brightness percentage", "%1%", root.percentage) | ||
} | ||
} | ||
|
||
PlasmaComponents3.Slider { | ||
PlasmaComponents.Slider { | ||
id: control | ||
Layout.fillWidth: true | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,16 @@ | ||
/* | ||
SPDX-FileCopyrightText: 2023 Dmitry Ilyich Sidorov <[email protected]> | ||
SPDX-FileCopyrightText: 2023, 2024 Dmitry Ilyich Sidorov <[email protected]> | ||
SPDX-License-Identifier: LGPL-3.0-or-later | ||
*/ | ||
|
||
import QtQuick 2.0 | ||
import QtQuick.Controls 2.5 | ||
import QtQuick.Layouts 1.12 | ||
import org.kde.kirigami 2.4 as Kirigami | ||
|
||
Item { | ||
id: page | ||
width: childrenRect.width | ||
height: childrenRect.height | ||
import QtQuick | ||
import QtQuick.Controls | ||
import QtQuick.Layouts | ||
import org.kde.kirigami as Kirigami | ||
import org.kde.kcmutils as KCM | ||
|
||
KCM.SimpleKCM { | ||
signal configurationChanged | ||
|
||
function saveConfig() { | ||
|
@@ -32,4 +29,3 @@ Item { | |
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
/* | ||
SPDX-FileCopyrightText: 2023 Dmitry Ilyich Sidorov <[email protected]> | ||
SPDX-FileCopyrightText: 2023, 2024 Dmitry Ilyich Sidorov <[email protected]> | ||
SPDX-License-Identifier: LGPL-3.0-or-later | ||
*/ | ||
|
||
import QtQuick 2.0 | ||
import QtQuick.Layouts 1.0 | ||
import QtQuick | ||
import QtQuick.Layouts | ||
import QtQuick.Dialogs | ||
import org.kde.plasma.core as PlasmaCore | ||
import org.kde.kirigami as Kirigami | ||
import org.kde.plasma.extras as PlasmaExtras | ||
import org.kde.plasma.plasmoid | ||
import org.kde.plasma.plasma5support as Plasma5Support | ||
|
||
import org.kde.plasma.core 2.1 as PlasmaCore | ||
import org.kde.plasma.components 3.0 as PC3 | ||
import org.kde.plasma.extras 2.0 as PlasmaExtras | ||
import org.kde.plasma.plasmoid 2.0 | ||
import QtQuick.Dialogs 1.2 | ||
|
||
Item { | ||
PlasmoidItem { | ||
id: main | ||
|
||
property string displayName: i18n("plasma_applet_org.kde.plasma.battery", "Brightness") | ||
property string displayName: i18n("plasma_applet_org.kde.plasma.brightness", "Brightness") | ||
|
||
property int minimumScreenBrightness: plasmoid.configuration.minimumBrightness | ||
property int maximumScreenBrightness: 100 | ||
|
@@ -27,25 +27,24 @@ Item { | |
id: errorDialog | ||
title: "An error occuried" | ||
text: "Failed to get the current brightness and output values with xrandr." | ||
icon: StandardIcon.Critical | ||
} | ||
|
||
Plasmoid.preferredRepresentation: Plasmoid.compactRepresentation | ||
preferredRepresentation: compactRepresentation | ||
|
||
Plasmoid.fullRepresentation: PlasmaExtras.Representation { | ||
fullRepresentation: PlasmaExtras.Representation { | ||
id: dialogItem | ||
|
||
Layout.minimumWidth: PlasmaCore.Units.gridUnit * 10 | ||
Layout.maximumWidth: PlasmaCore.Units.gridUnit * 80 | ||
Layout.preferredWidth: PlasmaCore.Units.gridUnit * 20 | ||
Layout.minimumWidth: Kirigami.Units.gridUnit * 10 | ||
Layout.maximumWidth: Kirigami.Units.gridUnit * 80 | ||
Layout.preferredWidth: Kirigami.Units.gridUnit * 20 | ||
|
||
Layout.preferredHeight: implicitHeight | ||
|
||
contentItem: BrightnessItem { | ||
id: brightnessSlider | ||
|
||
icon.name: "video-display-brightness" | ||
text: i18nd("plasma_applet_org.kde.plasma.battery", "Display Brightness") | ||
text: i18nd("plasma_applet_org.kde.plasma.brightness", "Display Brightness") | ||
value: screenBrightness | ||
maximumValue: maximumScreenBrightness | ||
|
||
|
@@ -61,20 +60,20 @@ Item { | |
} | ||
|
||
executable.exec(`xrandr --output ${screenOutput} --brightness ${screenBrightness / 100}`) | ||
console.log(`xrandr --output ${screenOutput} --brightness ${screenBrightness / 100}`) | ||
} | ||
|
||
} | ||
} | ||
|
||
Plasmoid.compactRepresentation: PlasmaCore.IconItem { | ||
compactRepresentation: Kirigami.Icon { | ||
source: Plasmoid.icon | ||
MouseArea { | ||
anchors.fill: parent | ||
acceptedButtons: Qt.LeftButton | ||
onClicked: { | ||
onClicked: function (mouse) { | ||
if (mouse.button === Qt.LeftButton) { | ||
if (plasmoid.expanded) { | ||
plasmoid.expanded = false | ||
if (main.expanded) { | ||
main.expanded = false | ||
} else { | ||
executable.exec("xrandr --verbose | grep -m 2 -i \" connected\\|brightness\"") | ||
} | ||
|
@@ -85,7 +84,7 @@ Item { | |
|
||
Connections { | ||
target: executable | ||
onExited: { | ||
onExited: function(exitCode, exitStatus, stdout, stderr) { | ||
if (exitCode == 0 && exitStatus == 0) { | ||
if (stdout != null && stdout.length > 5) { | ||
var lines = stdout.trim().split('\n') | ||
|
@@ -99,8 +98,8 @@ Item { | |
} | ||
} | ||
|
||
if (!plasmoid.expanded) { | ||
plasmoid.expanded = true | ||
if (!main.expanded) { | ||
main.expanded = true | ||
} | ||
} | ||
} | ||
|
@@ -110,11 +109,11 @@ Item { | |
} | ||
} | ||
|
||
PlasmaCore.DataSource { | ||
Plasma5Support.DataSource { | ||
id: executable | ||
engine: "executable" | ||
connectedSources: [] | ||
onNewData: { | ||
onNewData: function(sourceName, data) { | ||
var exitCode = data["exit code"] | ||
var exitStatus = data["exit status"] | ||
var stdout = data["stdout"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters