Use high-brightness and low-brightness icons in the top panel, and remove label

This commit is contained in:
Devin Lin 2021-03-09 12:28:30 -05:00
parent 113fe48caf
commit 7f7bea091e
2 changed files with 73 additions and 69 deletions

View file

@ -1,11 +1,13 @@
/* /*
* SPDX-FileCopyrightText: 2012-2013 Daniel Nicoletti <dantti12@gmail.com> * SPDX-FileCopyrightText: 2012-2013 Daniel Nicoletti <dantti12@gmail.com>
* SPDX-FileCopyrightText: 2013, 2015 Kai Uwe Broulik <kde@privat.broulik.de> * SPDX-FileCopyrightText: 2013, 2015 Kai Uwe Broulik <kde@privat.broulik.de>
* SPDX-FileCopyrightText: 2021 Devin Lin <espidev@gmail.com>
* *
* SPDX-License-Identifier: LGPL-2.0-or-later * SPDX-License-Identifier: LGPL-2.0-or-later
*/ */
import QtQuick 2.0 import QtQuick 2.0
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.core 2.0 as PlasmaCore
@ -13,40 +15,34 @@ import org.kde.plasma.components 3.0 as PC3
RowLayout { RowLayout {
id: brightnessRoot id: brightnessRoot
property alias icon: brightnessIcon.source
property alias label: brightnessLabel.text
property alias value: brightnessSlider.value property alias value: brightnessSlider.value
property alias maximumValue: brightnessSlider.to property alias maximumValue: brightnessSlider.to
signal moved signal moved
spacing: units.gridUnit spacing: units.smallSpacing
PlasmaCore.IconItem { PlasmaCore.IconItem {
id: brightnessIcon Layout.alignment: Qt.AlignVCenter
Layout.alignment: Qt.AlignTop Layout.leftMargin: Kirigami.Units.largeSpacing
Layout.preferredWidth: units.iconSizes.medium Layout.preferredWidth: units.iconSizes.medium
Layout.preferredHeight: width Layout.preferredHeight: width
source: "low-brightness"
} }
Column { Slider {
id: brightnessColumn
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop
spacing: 0
PC3.Label {
id: brightnessLabel
width: parent.width
height: paintedHeight
}
PC3.Slider {
id: brightnessSlider id: brightnessSlider
width: parent.width Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
onMoved: brightnessRoot.moved() onMoved: brightnessRoot.moved()
from: 1 from: 1
//stepSize: 1 }
}
PlasmaCore.IconItem {
Layout.alignment: Qt.AlignVCenter
Layout.rightMargin: Kirigami.Units.largeSpacing
Layout.preferredWidth: units.iconSizes.medium
Layout.preferredHeight: width
source: "high-brightness"
} }
} }

View file

@ -19,8 +19,8 @@ import org.kde.plasma.components 3.0 as PC3
Item { Item {
id: root id: root
implicitWidth: flow.implicitWidth + units.smallSpacing * 6 implicitWidth: column.implicitWidth + units.smallSpacing * 6
implicitHeight: flow.implicitHeight + units.smallSpacing * 6 implicitHeight: column.implicitHeight + units.smallSpacing * 2
signal closeRequested signal closeRequested
signal closed signal closed
@ -32,9 +32,9 @@ Item {
? (root.height - collapsedHeight) * (1 - expandedRatio) ? (root.height - collapsedHeight) * (1 - expandedRatio)
: (expandedMode ? 0 : root.height - collapsedHeight) : (expandedMode ? 0 : root.height - collapsedHeight)
readonly property real collapsedHeight: firstRowHeight + PlasmaCore.Units.largeSpacing * 2 readonly property real collapsedHeight: firstRowHeight + PlasmaCore.Units.smallSpacing * 2
readonly property real firstRowHeight: flow.children[0].height readonly property real firstRowHeight: flow.children[0].height
readonly property real otherRowsHeight: flow.height - firstRowHeight readonly property real otherRowsHeight: column.height - firstRowHeight
Connections { Connections {
target: root.parentSlidingPanel target: root.parentSlidingPanel
@ -297,7 +297,7 @@ Item {
right: parent.right right: parent.right
bottom: parent.bottom bottom: parent.bottom
} }
height: firstRowHeight + units.largeSpacing*2 + otherRowsHeight * root.expandedRatio height: firstRowHeight + otherRowsHeight * root.expandedRatio
} }
Item { Item {
@ -309,12 +309,17 @@ Item {
readonly property real cellSizeHint: units.iconSizes.large + units.smallSpacing * 6 readonly property real cellSizeHint: units.iconSizes.large + units.smallSpacing * 6
readonly property real columnWidth: Math.floor(width / Math.floor(width / cellSizeHint)) readonly property real columnWidth: Math.floor(width / Math.floor(width / cellSizeHint))
ColumnLayout {
id: column
anchors.fill: parent
spacing: 0
Flow { Flow {
id: flow id: flow
anchors { Layout.fillWidth: true
fill: parent Layout.leftMargin: units.smallSpacing + (units.largeSpacing - units.smallSpacing) * root.expandedRatio
margins: units.largeSpacing Layout.rightMargin: units.largeSpacing
} Layout.topMargin: units.largeSpacing
readonly property real cellSizeHint: units.iconSizes.large + units.smallSpacing * 6 readonly property real cellSizeHint: units.iconSizes.large + units.smallSpacing * 6
readonly property real columnWidth: Math.floor(width / Math.floor(width / cellSizeHint)) readonly property real columnWidth: Math.floor(width / Math.floor(width / cellSizeHint))
@ -354,12 +359,15 @@ Item {
properties: "x,y" properties: "x,y"
} }
} }
}
BrightnessItem { BrightnessItem {
id: brightnessSlider id: brightnessSlider
width: flow.width
icon: "video-display-brightness" Layout.bottomMargin: units.largeSpacing
label: i18n("Display Brightness") Layout.leftMargin: units.largeSpacing
Layout.rightMargin: units.largeSpacing
Layout.fillWidth: true
value: root.screenBrightness value: root.screenBrightness
maximumValue: root.maximumScreenBrightness maximumValue: root.maximumScreenBrightness
opacity: root.expandedRatio opacity: root.expandedRatio