@ -16,7 +16,7 @@ import org.kde.plasma.extras 2.0 as PlasmaExtras
PlasmaExtras . Representation {
id: dialog
property alias model: batteryList . model
property alias model: batteryRepeater . model
property bool pluggedIn
property int remainingTime
@ -48,6 +48,8 @@ PlasmaExtras.Representation {
collapseMarginsHint: true
KeyNavigation.down: pmSwitch . pmCheckBox
header: PlasmaExtras . PlasmoidHeading {
leftPadding: PlasmaCore . Units . smallSpacing
contentItem: PowerManagementItem {
@ -57,60 +59,58 @@ PlasmaExtras.Representation {
inhibitsLidAction: dialog . inhibitsLidAction
pluggedIn: dialog . pluggedIn
onDisabledChanged: powerManagementChanged ( disabled )
KeyNavigation.tab: if ( batteryList . headerItem ) {
if ( isBrightnessAvailable ) {
return batteryList . headerItem . children [ 1 ] ;
} else if ( isKeyboardBrightnessAvailable ) {
return batteryList . headerItem . children [ 2 ] ;
} else if ( dialog . profiles . length > 0 ) {
return batteryList . headerItem . children [ 3 ] ;
} else {
return batteryList ;
}
}
}
}
PlasmaComponents3 . ScrollView {
focus: true
anchors.fill: parent
contentItem: PlasmaComponents3 . ScrollView {
id: scrollView
focus: false
/ / H A C K : w o r k a r o u n d f o r h t t p s : / / b u g r e p o r t s . q t . i o / b r o w s e / Q T B U G - 8 3 8 9 0
PlasmaComponents3.ScrollBar.horizontal.policy: PlasmaComponents3 . ScrollBar . AlwaysOff
contentItem: ListView {
Column {
id: batteryList
keyNavigationEnabled: true
leftMargin: PlasmaCore . Units . smallSpacing * 2
rightMargin: PlasmaCore . Units . smallSpacing * 2
topMargin: PlasmaCore . Units . smallSpacing * 2
bottomMargin: PlasmaCore . Units . smallSpacing * 2
spacing: PlasmaCore . Units . smallSpacing
/ / h e a d e r s o t h a t i t s c r o l l w i t h t h e c o n t e n t o f t h e L i s t V i e w
header: ColumnLayout {
spacing: PlasmaCore . Units . smallSpacing * 2
width: parent . width
readonly property Item firstHeaderItem: {
if ( brightnessSlider . visible ) {
return brightnessSlider ;
} else if ( keyboardBrightnessSlider . visible ) {
return keyboardBrightnessSlider ;
} else if ( powerProfileItem . visible ) {
return powerProfileItem ;
}
return null ;
}
readonly property Item lastHeaderItem: {
if ( powerProfileItem . visible ) {
return powerProfileItem ;
} else if ( keyboardBrightnessSlider . visible ) {
return keyboardBrightnessSlider ;
} else if ( brightnessSlider . visible ) {
return brightnessSlider ;
}
return null ;
}
BrightnessItem {
id: brightnessSlider
Layout.fillWidth: true
width: scrollView . availableWidth
icon: "video-display-brightness"
label: i18n ( "Display Brightness" )
icon.name : "video-display-brightness"
text : i18n ( "Display Brightness" )
visible: isBrightnessAvailable
value: batterymonitor . screenBrightness
maximumValue: batterymonitor . maximumScreenBrightness
KeyNavigation.tab: if ( isKeyboardBrightnessAvailable ) {
return keyboardBrightnessSlider ;
} else if ( dialog . profiles . length > 0 ) {
return powerProfileItem
} else {
return batteryList
}
KeyNavigation.up: pmSwitch . pmCheckBox
KeyNavigation.down: keyboardBrightnessSlider . visible ? keyboardBrightnessSlider : keyboardBrightnessSlider . KeyNavigation . down
KeyNavigation.backtab: KeyNavigation . up
KeyNavigation.tab: KeyNavigation . down
stepSize: batterymonitor . maximumScreenBrightness / 100
onMoved: batterymonitor . screenBrightness = value
@ -127,19 +127,19 @@ PlasmaExtras.Representation {
BrightnessItem {
id: keyboardBrightnessSlider
Layout.fillWidth: true
width: scrollView . availableWidth
icon: "input-keyboard-brightness"
label : i18n ( "Keyboard Brightness" )
icon.name : "input-keyboard-brightness"
text : i18n ( "Keyboard Brightness" )
showPercentage: false
value: batterymonitor . keyboardBrightness
maximumValue: batterymonitor . maximumKeyboardBrightness
visible: isKeyboardBrightnessAvailable
KeyNavigation.tab: if ( dialog . profiles . length > 0 ) {
return powerProfileItem
} else {
return batteryList
}
KeyNavigation.up: brightnessSlider . visible ? brightnessSlider : brightnessSlider . KeyNavigation . up
KeyNavigation.down: powerProfileItem . visible ? powerProfileItem : powerProfileItem . KeyNavigation . down
KeyNavigation.backtab: KeyNavigation . up
KeyNavigation.tab: KeyNavigation . down
onMoved: batterymonitor . keyboardBrightness = value
@ -154,9 +154,14 @@ PlasmaExtras.Representation {
PowerProfileItem {
id: powerProfileItem
Layout.fillWidth: true
KeyNavigation.tab: batteryList
width: scrollView . availableWidth
KeyNavigation.up: keyboardBrightnessSlider . visible ? keyboardBrightnessSlider : keyboardBrightnessSlider . KeyNavigation . up
KeyNavigation.down: batteryRepeater . count > 0 ? batteryRepeater . itemAt ( 0 ) : null
KeyNavigation.backtab: KeyNavigation . up
KeyNavigation.tab: KeyNavigation . down
activeProfile: dialog . activeProfile
inhibitionReason: dialog . inhibitionReason
visible: dialog . profiles . length > 0
@ -164,20 +169,24 @@ PlasmaExtras.Representation {
profileHolds: dialog . profileHolds
onActivateProfileRequested: dialog . activateProfileRequested ( profile )
}
Item {
Layout.fillWidth: true
/ / a d d i t i o n a l m a r g i n , b e c a u s e t h e b o t t o m o f P o w e r P r o f i l e I t e m
/ / a n d t h e t o p o f B a t t e r y I t e m a r e m o r e d e n s e .
}
}
Repeater {
id: batteryRepeater
delegate: BatteryItem {
width: ListView . view . width - PlasmaCore . Units . smallSpacing * 4
width: scrollView . availableWidth
battery: model
remainingTime: dialog . remainingTime
matchHeightOfSlider: ListView . view . headerItem ? ListView . view . headerItem . children [ 1 ] . slider : null
matchHeightOfSlider: batteryList . firstHeaderItem ? batteryList.firstHeaderItem.slider : null
KeyNavigation.up: index === 0 ? batteryList.lastHeaderItem : batteryRepeater . itemAt ( index - 1 )
KeyNavigation.down: index + 1 < batteryRepeater . count ? batteryRepeater . itemAt ( index + 1 ) : null
KeyNavigation.backtab: KeyNavigation . up
KeyNavigation.tab: KeyNavigation . down
}
}
}
}
}