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 id: brightnessSlider
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignTop Layout.alignment: Qt.AlignVCenter
spacing: 0 onMoved: brightnessRoot.moved()
from: 1
PC3.Label { }
id: brightnessLabel
width: parent.width PlasmaCore.IconItem {
height: paintedHeight Layout.alignment: Qt.AlignVCenter
} Layout.rightMargin: Kirigami.Units.largeSpacing
Layout.preferredWidth: units.iconSizes.medium
PC3.Slider { Layout.preferredHeight: width
id: brightnessSlider source: "high-brightness"
width: parent.width
onMoved: brightnessRoot.moved()
from: 1
//stepSize: 1
}
} }
} }

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,61 +309,69 @@ 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))
Flow { ColumnLayout {
id: flow id: column
anchors { anchors.fill: parent
fill: parent
margins: units.largeSpacing
}
readonly property real cellSizeHint: units.iconSizes.large + units.smallSpacing * 6
readonly property real columnWidth: Math.floor(width / Math.floor(width / cellSizeHint))
spacing: 0 spacing: 0
Repeater {
model: settingsModel Flow {
delegate: Delegate { id: flow
id: delegateItem Layout.fillWidth: true
Layout.leftMargin: units.smallSpacing + (units.largeSpacing - units.smallSpacing) * root.expandedRatio
Layout.rightMargin: units.largeSpacing
Layout.topMargin: units.largeSpacing
//FIXME: why this is needed? readonly property real cellSizeHint: units.iconSizes.large + units.smallSpacing * 6
width: flow.columnWidth - (y > 0 ? 0 : (flow.columnWidth/Math.floor(flow.width / flow.columnWidth)) * (1 - root.expandedRatio)) readonly property real columnWidth: Math.floor(width / Math.floor(width / cellSizeHint))
height: item ? item.implicitHeight : 0 spacing: 0
Repeater {
model: settingsModel
delegate: Delegate {
id: delegateItem
labelOpacity: y > 0 ? 1 : root.expandedRatio //FIXME: why this is needed?
width: flow.columnWidth - (y > 0 ? 0 : (flow.columnWidth/Math.floor(flow.width / flow.columnWidth)) * (1 - root.expandedRatio))
height: item ? item.implicitHeight : 0
opacity: y <= 0 ? 1 : root.expandedRatio labelOpacity: y > 0 ? 1 : root.expandedRatio
transform: Translate {
y: otherRowsHeight * (1 - root.expandedRatio) opacity: y <= 0 ? 1 : root.expandedRatio
transform: Translate {
y: otherRowsHeight * (1 - root.expandedRatio)
}
Connections {
target: delegateItem
onCloseRequested: root.closeRequested();
}
Connections {
target: root
onClosed: delegateItem.panelClosed();
}
} }
}
Connections { move: Transition {
target: delegateItem NumberAnimation {
onCloseRequested: root.closeRequested(); duration: units.shortDuration
} //Here a linear easing actually looks better
Connections { //easing.type: Easing.InOutQuad
target: root properties: "x,y"
onClosed: delegateItem.panelClosed();
} }
} }
} }
move: Transition {
NumberAnimation {
duration: units.shortDuration
//Here a linear easing actually looks better
//easing.type: Easing.InOutQuad
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
transform: Translate{ transform: Translate {
y: otherRowsHeight * (1 - root.expandedRatio) y: otherRowsHeight * (1 - root.expandedRatio)
} }