2021-04-09 20:59:05 +00:00
/ *
* SPDX - FileCopyrightText: 2015 Marco Martin < notmart @ gmail . com >
* SPDX - FileCopyrightText: 2021 Devin Lin < espidev @ gmail . com >
*
* SPDX - License - Identifier: LGPL - 2.0 - or - later
* /
import QtQuick 2.14
import QtQuick . Layouts 1.1
import QtQuick . Window 2.2
import QtGraphicalEffects 1.12
import org . kde . kirigami 2.12 as Kirigami
import org . kde . plasma . core 2.0 as PlasmaCore
import org . kde . plasma . components 2.0 as PlasmaComponents
import org . kde . plasma . networkmanagement 0.2 as PlasmaNM
import org . kde . bluezqt 1.0 as BluezQt
import org . kde . colorcorrect 0.1 as CC
import org . kde . plasma . private . nanoshell 2.0 as NanoShell
import org . kde . plasma . components 3.0 as PC3
import "../"
Item {
id: root
implicitWidth: column . implicitWidth + PlasmaCore . Units . smallSpacing * 6
2021-06-16 09:30:28 +00:00
implicitHeight: expandedHeight
2021-04-09 20:59:05 +00:00
2021-06-09 08:44:48 +00:00
signal expandRequested
2021-04-09 20:59:05 +00:00
signal closeRequested
signal closed
property bool expandedMode: parentSlidingPanel . wideScreen
2021-06-16 09:30:28 +00:00
2021-06-09 08:44:48 +00:00
readonly property real expandedRatio: expandedMode
? 1
2021-06-16 09:30:28 +00:00
: Math . max ( 0 , Math . min ( 1 , ( parentSlidingPanel . offset - collapsedHeight ) / ( expandedHeight - collapsedHeight ) ) )
2021-04-09 20:59:05 +00:00
readonly property real topEmptyAreaHeight: parentSlidingPanel . userInteracting
? ( root . height - collapsedHeight ) * ( 1 - expandedRatio )
: ( expandedMode ? 0 : root . height - collapsedHeight )
2021-06-16 09:30:28 +00:00
2021-07-02 22:43:08 +00:00
readonly property real collapsedHeight: column . Layout . minimumHeight + background . margins . top + background . fixedMargins . bottom
2021-06-16 09:30:28 +00:00
2021-07-02 22:43:08 +00:00
readonly property real expandedHeight: column . Layout . maximumHeight + background . margins . top + background . fixedMargins . bottom
2021-06-16 09:30:28 +00:00
2021-04-09 20:59:05 +00:00
Connections {
target: root . parentSlidingPanel
function onUserInteractingChanged ( ) {
if ( ! parentSlidingPanel . userInteracting ) {
if ( root . expandedRatio > 0.7 ) {
root . expandedMode = true ;
}
}
}
}
property NanoShell . FullScreenOverlay parentSlidingPanel
Connections {
target: root . Window . window
function onVisibilityChanged ( ) {
root . expandedMode = parentSlidingPanel . wideScreen ;
}
}
signal plasmoidTriggered ( var applet , var id )
Layout.minimumHeight: flow . implicitHeight + units . largeSpacing * 2
onClosed: quickSettingsModel . panelClosed ( )
2021-07-14 13:39:43 +00:00
readonly property SettingsModel quickSettingsModel: SettingsModel { }
2021-04-09 20:59:05 +00:00
2021-06-09 08:44:48 +00:00
PlasmaCore . FrameSvgItem {
2021-04-09 20:59:05 +00:00
id: background
2021-06-16 09:30:28 +00:00
implicitHeight: root . expandedHeight
2021-06-09 08:44:48 +00:00
enabledBorders: parentSlidingPanel . wideScreen ? PlasmaCore.FrameSvg.AllBorders : PlasmaCore . FrameSvg . BottomBorder
2021-04-09 20:59:05 +00:00
anchors.fill: parent
2021-06-09 08:44:48 +00:00
imagePath: "widgets/background"
2021-04-09 20:59:05 +00:00
ColumnLayout {
id: column
2021-07-02 22:43:08 +00:00
2021-06-09 08:44:48 +00:00
anchors {
leftMargin: parent . fixedMargins . left
rightMargin: parent . fixedMargins . right
2021-07-02 22:43:08 +00:00
bottomMargin: parent . fixedMargins . bottom * ( parentSlidingPanel . wideScreen ? 1 : 0.5 ) // HACK: fix the bottom arrow not being centered, bottom margins aren't properly calculated it seems
2021-06-09 08:44:48 +00:00
left: parent . left
right: parent . right
bottom: parent . bottom
}
2021-07-02 22:43:08 +00:00
2021-04-09 20:59:05 +00:00
spacing: 0
2021-06-16 09:30:28 +00:00
height: Layout . minimumHeight * ( 1 - root . expandedRatio ) + ( Layout . maximumHeight * root . expandedRatio )
2021-04-09 20:59:05 +00:00
readonly property real cellSizeHint: units . iconSizes . large + units . smallSpacing * 6
readonly property real columnWidth: Math . floor ( width / Math . floor ( width / cellSizeHint ) )
2021-07-02 22:43:08 +00:00
// top indicators (clock, widgets, etc.)
2021-04-09 20:59:05 +00:00
IndicatorsRow {
id: indicatorsRow
z: 1
Layout.fillWidth: true
Layout.preferredHeight: parentSlidingPanel . topPanelHeight
colorGroup: PlasmaCore . Theme . NormalColorGroup
backgroundColor: "transparent"
showGradientBackground: false
showDropShadow: false
}
2021-07-02 22:43:08 +00:00
// quicksettings list
2021-06-16 09:30:28 +00:00
ColumnLayout {
clip: expandedRatio > 0 && expandedRatio < 1 // only clip when necessary to improve performance
2021-04-09 20:59:05 +00:00
Layout.fillWidth: true
2021-06-16 09:30:28 +00:00
Layout.fillHeight: true
Layout.minimumHeight: flow . Layout . minimumHeight
2021-04-09 20:59:05 +00:00
spacing: 0
2021-06-16 09:30:28 +00:00
Layout.topMargin: PlasmaCore . Units . largeSpacing
Flow {
id: flow
Layout.fillWidth: true
Layout.minimumHeight: cellSizeHint
Layout.preferredHeight: implicitHeight
Layout.maximumHeight: ( flow . cellSizeHint * Math . ceil ( ( flow . children . length - 1 ) / flow . columns ) )
2021-04-09 20:59:05 +00:00
2021-06-16 09:30:28 +00:00
readonly property real cellSizeHint: units . iconSizes . large + units . smallSpacing * 6
readonly property real columns: Math . floor ( width / cellSizeHint )
readonly property real columnWidth: Math . floor ( width / columns )
spacing: 0
Repeater {
2021-07-14 13:39:43 +00:00
model: quickSettingsModel
2021-06-16 09:30:28 +00:00
delegate: Delegate {
id: delegateItem
2021-07-14 00:20:15 +00:00
required property var modelData
2021-06-16 09:30:28 +00:00
width: root . expandedRatio < 0.4
? Math . max ( implicitWidth + PlasmaCore . Units . smallSpacing * 2 , flow . width / ( flow . columns + 1 ) )
: Math . max ( implicitWidth + PlasmaCore . Units . smallSpacing * 2 ,
( flow . width / ( flow . columns + 1 ) ) * ( 1 - root . expandedRatio ) + ( flow . width / flow . columns ) * root . expandedRatio )
labelOpacity: y > 0 ? 1 : root . expandedRatio
opacity: y <= 0 ? 1 : root . expandedRatio
2021-07-14 00:20:15 +00:00
text: modelData . text
icon: modelData . icon
enabled: modelData . enabled
settingsCommand: modelData . settingsCommand
toggleFunction: modelData . toggle
2021-06-16 09:30:28 +00:00
Connections {
target: delegateItem
onCloseRequested: root . closeRequested ( ) ;
}
Connections {
target: root
onClosed: delegateItem . panelClosed ( ) ;
}
2021-04-09 20:59:05 +00:00
}
}
2021-06-16 09:30:28 +00:00
move: Transition {
NumberAnimation {
duration: units . shortDuration
easing.type: Easing . Linear
properties: "x,y"
}
2021-04-09 20:59:05 +00:00
}
}
2021-06-16 09:30:28 +00:00
BrightnessItem {
id: brightnessSlider
Layout.topMargin: units . largeSpacing
Layout.bottomMargin: units . smallSpacing
Layout.leftMargin: units . largeSpacing
Layout.rightMargin: units . largeSpacing
Layout.fillWidth: true
opacity: root . expandedRatio
}
2021-04-09 20:59:05 +00:00
}
2021-06-16 09:30:28 +00:00
// bottom "handle bar"
2021-07-02 22:43:08 +00:00
ColumnLayout {
2021-06-16 09:30:28 +00:00
id: bottomBar
2021-07-02 22:43:08 +00:00
spacing: 0
2021-06-16 09:30:28 +00:00
visible: ! parentSlidingPanel . wideScreen
2021-07-02 22:43:08 +00:00
Layout.fillWidth: true
2021-06-16 09:30:28 +00:00
implicitHeight: visible ? Math . round ( PlasmaCore . Units . gridUnit * 1.3 ) : 0
2021-07-02 22:43:08 +00:00
2021-06-16 09:30:28 +00:00
Kirigami . Separator {
2021-07-02 22:43:08 +00:00
Layout.fillWidth: true
2021-06-16 09:30:28 +00:00
color: PlasmaCore . Theme . disabledTextColor
opacity: 0.3
}
2021-07-02 22:43:08 +00:00
2021-06-16 09:30:28 +00:00
Kirigami . Icon {
color: PlasmaCore . Theme . disabledTextColor
source: expandedRatio >= 0.5 ? "go-up-symbolic" : "go-down-symbolic"
implicitWidth: PlasmaCore . Units . gridUnit
implicitHeight: width
2021-07-02 22:43:08 +00:00
Layout.alignment: Qt . AlignCenter
Layout.topMargin: Kirigami . Units . smallSpacing
Layout.bottomMargin: Kirigami . Units . smallSpacing
2021-06-16 09:30:28 +00:00
}
2021-07-02 22:43:08 +00:00
2021-06-16 09:30:28 +00:00
TapHandler {
onTapped: {
if ( root . expandedMode ) {
root . closeRequested ( ) ;
} else {
root . expandRequested ( ) ;
root . expandedMode = true ;
}
}
2021-04-09 20:59:05 +00:00
}
}
}
}
}