mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-28 14:43:09 +00:00
make the top panel use quick settings
This commit is contained in:
parent
e20569d1fd
commit
54d4d8dba9
2 changed files with 83 additions and 70 deletions
|
|
@ -35,6 +35,32 @@ Item {
|
||||||
|
|
||||||
Layout.minimumHeight: flow.implicitHeight + units.largeSpacing*2
|
Layout.minimumHeight: flow.implicitHeight + units.largeSpacing*2
|
||||||
|
|
||||||
|
property int screenBrightness
|
||||||
|
readonly property int maximumScreenBrightness: pmSource.data["PowerDevil"] ? pmSource.data["PowerDevil"]["Maximum Screen Brightness"] || 0 : 0
|
||||||
|
onScreenBrightnessChanged: {
|
||||||
|
var service = pmSource.serviceForSource("PowerDevil");
|
||||||
|
var operation = service.operationDescription("setBrightness");
|
||||||
|
operation.brightness = screenBrightness;
|
||||||
|
operation.silent = true
|
||||||
|
service.startOperationCall(operation);
|
||||||
|
}
|
||||||
|
|
||||||
|
PlasmaCore.DataSource {
|
||||||
|
id: pmSource
|
||||||
|
engine: "powermanagement"
|
||||||
|
connectedSources: ["PowerDevil"]
|
||||||
|
onSourceAdded: {
|
||||||
|
if (source === "PowerDevil") {
|
||||||
|
disconnectSource(source);
|
||||||
|
connectSource(source);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onDataChanged: {
|
||||||
|
root.screenBrightness = pmSource.data["PowerDevil"]["Screen Brightness"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ListModel {
|
ListModel {
|
||||||
id: settingsModel
|
id: settingsModel
|
||||||
|
|
||||||
|
|
@ -69,26 +95,13 @@ Item {
|
||||||
text: "Wireless"
|
text: "Wireless"
|
||||||
icon: "network-wireless-on"
|
icon: "network-wireless-on"
|
||||||
enabled: true
|
enabled: true
|
||||||
settingsCommand: "active-settings -m org.kde.plasma.phone.settings.wifi"
|
settingsCommand: "plasmawindowed org.kde.plasma.networkmanagement"
|
||||||
}
|
}
|
||||||
ListElement {
|
ListElement {
|
||||||
text: "Alarms"
|
text: "Alarms"
|
||||||
icon: "korgac"
|
icon: "korgac"
|
||||||
enabled: false
|
enabled: false
|
||||||
settingsCommand: ""
|
settingsCommand: "ktimer"
|
||||||
}
|
|
||||||
ListElement {
|
|
||||||
text: "Notifications"
|
|
||||||
icon: "preferences-desktop-notification"
|
|
||||||
enabled: true
|
|
||||||
settingsCommand: ""
|
|
||||||
}
|
|
||||||
ListElement {
|
|
||||||
text: "Brightness"
|
|
||||||
icon: "video-display-brightness"
|
|
||||||
enabled: false
|
|
||||||
settingsCommand: "active-settings -m org.kde.active.settings.powermanagement"
|
|
||||||
delegate: "BrightnessDelegate"
|
|
||||||
}
|
}
|
||||||
ListElement {
|
ListElement {
|
||||||
text: "Flashlight"
|
text: "Flashlight"
|
||||||
|
|
@ -126,5 +139,32 @@ Item {
|
||||||
properties: "x,y"
|
properties: "x,y"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
RowLayout {
|
||||||
|
width: flow.width
|
||||||
|
PlasmaCore.IconItem {
|
||||||
|
Layout.preferredWidth: units.iconSizes.small
|
||||||
|
Layout.preferredHeight: Layout.preferredWidth
|
||||||
|
//TODO: needs brightness
|
||||||
|
source: "contrast"
|
||||||
|
}
|
||||||
|
PlasmaComponents.Slider {
|
||||||
|
id: brightnessSlider
|
||||||
|
Layout.fillWidth: true
|
||||||
|
value: root.screenBrightness
|
||||||
|
onValueChanged: {
|
||||||
|
if (pressed) {
|
||||||
|
root.screenBrightness = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
minimumValue: maximumValue > 100 ? 1 : 0
|
||||||
|
maximumValue: root.maximumScreenBrightness
|
||||||
|
}
|
||||||
|
PlasmaCore.IconItem {
|
||||||
|
Layout.preferredWidth: units.iconSizes.small
|
||||||
|
Layout.preferredHeight: Layout.preferredWidth
|
||||||
|
//TODO: needs brightness
|
||||||
|
source: "contrast"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ PlasmaCore.ColorScope {
|
||||||
property Item toolBox
|
property Item toolBox
|
||||||
property int buttonHeight: width/4
|
property int buttonHeight: width/4
|
||||||
property bool reorderingApps: false
|
property bool reorderingApps: false
|
||||||
property QtObject expandedApplet
|
|
||||||
property var layoutManager: LayoutManager
|
property var layoutManager: LayoutManager
|
||||||
|
|
||||||
Containment.onAppletAdded: {
|
Containment.onAppletAdded: {
|
||||||
|
|
@ -44,17 +43,14 @@ PlasmaCore.ColorScope {
|
||||||
LayoutManager.save();
|
LayoutManager.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: expandedApplet
|
|
||||||
onExpandedChanged: {
|
|
||||||
if (!expanded) {
|
|
||||||
slidingPanel.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function addApplet(applet, x, y) {
|
function addApplet(applet, x, y) {
|
||||||
|
if (applet.pluginName == "org.kde.phone.quicksettings") {
|
||||||
|
applet.parent = quickSettingsParent;
|
||||||
|
quickSettingsParent.applet = applet;
|
||||||
|
applet.anchors.fill = quickSettingsParent;
|
||||||
|
applet.visible = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
var container = appletContainerComponent.createObject(appletIconsRow)
|
var container = appletContainerComponent.createObject(appletIconsRow)
|
||||||
print("Applet added: " + applet + " " + applet.title)
|
print("Applet added: " + applet + " " + applet.title)
|
||||||
container.width = units.iconSizes.medium
|
container.width = units.iconSizes.medium
|
||||||
|
|
@ -65,7 +61,12 @@ PlasmaCore.ColorScope {
|
||||||
applet.anchors.fill = container;
|
applet.anchors.fill = container;
|
||||||
applet.visible = true;
|
applet.visible = true;
|
||||||
container.visible = true;
|
container.visible = true;
|
||||||
|
if (applet.pluginName == "org.kde.plasma.notifications") {
|
||||||
|
applet.expanded = true;
|
||||||
|
applet.fullRepresentationItem.parent = notificationsParent;
|
||||||
|
notificationsParent.applet = applet.fullRepresentationItem;
|
||||||
|
applet.fullRepresentationItem.anchors.fill = notificationsParent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
|
@ -101,23 +102,6 @@ PlasmaCore.ColorScope {
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.minimumWidth: applet && applet.compactRepresentationItem ? Math.max(applet.compactRepresentationItem.Layout.minimumWidth, appletIconsRow.height) : appletIconsRow.height
|
Layout.minimumWidth: applet && applet.compactRepresentationItem ? Math.max(applet.compactRepresentationItem.Layout.minimumWidth, appletIconsRow.height) : appletIconsRow.height
|
||||||
Layout.maximumWidth: Layout.minimumWidth
|
Layout.maximumWidth: Layout.minimumWidth
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
z: 999
|
|
||||||
onClicked: {
|
|
||||||
if (root.expandedApplet != applet) {
|
|
||||||
//temp var needed for oldExpandedApplet not to catch one expandedChanged too much by our Connections
|
|
||||||
var oldExpandedApplet = root.expandedApplet;
|
|
||||||
root.expandedApplet = applet;
|
|
||||||
applet.expanded = true;
|
|
||||||
appletsStack.replace(applet.fullRepresentationItem);
|
|
||||||
if (oldExpandedApplet) {
|
|
||||||
oldExpandedApplet.expanded = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -140,9 +124,9 @@ PlasmaCore.ColorScope {
|
||||||
color: PlasmaCore.ColorScope.backgroundColor
|
color: PlasmaCore.ColorScope.backgroundColor
|
||||||
|
|
||||||
//used as is needed somebody to filter events
|
//used as is needed somebody to filter events
|
||||||
MouseArea {
|
/*MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
}
|
}*/
|
||||||
Loader {
|
Loader {
|
||||||
id: strengthLoader
|
id: strengthLoader
|
||||||
height: parent.height
|
height: parent.height
|
||||||
|
|
@ -185,15 +169,8 @@ PlasmaCore.ColorScope {
|
||||||
anchors {
|
anchors {
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
right: parent.right
|
right: parent.right
|
||||||
bottomMargin: slidingPanel.visible ? parent.height : 0
|
|
||||||
}
|
|
||||||
height: slidingPanel.visible ? units.iconSizes.large : parent.height
|
|
||||||
Behavior on height {
|
|
||||||
PropertyAnimation {
|
|
||||||
duration: units.longDuration
|
|
||||||
easing.type: Easing.InOutQuad
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
height: parent.height
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
|
@ -220,7 +197,6 @@ PlasmaCore.ColorScope {
|
||||||
var factor = 1;
|
var factor = 1;
|
||||||
slidingPanel.offset = slidingPanel.offset + (mouse.y - oldMouseY) * factor;
|
slidingPanel.offset = slidingPanel.offset + (mouse.y - oldMouseY) * factor;
|
||||||
oldMouseY = mouse.y;
|
oldMouseY = mouse.y;
|
||||||
root.expandedApplet.expanded = true;
|
|
||||||
}
|
}
|
||||||
onReleased: slidingPanel.updateState();
|
onReleased: slidingPanel.updateState();
|
||||||
}
|
}
|
||||||
|
|
@ -229,24 +205,21 @@ PlasmaCore.ColorScope {
|
||||||
id: slidingPanel
|
id: slidingPanel
|
||||||
width: plasmoid.availableScreenRect.width
|
width: plasmoid.availableScreenRect.width
|
||||||
height: plasmoid.availableScreenRect.height
|
height: plasmoid.availableScreenRect.height
|
||||||
contents: Item {
|
contents: ColumnLayout {
|
||||||
id: panelContents
|
id: panelContents
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
Item {
|
||||||
PlasmaComponents.PageStack {
|
id: quickSettingsParent
|
||||||
id: appletsStack
|
property var applet
|
||||||
anchors {
|
Layout.fillWidth: true
|
||||||
fill: parent
|
Layout.minimumHeight: applet ? applet.fullRepresentationItem.Layout.minimumHeight : 0
|
||||||
bottomMargin: units.iconSizes.large
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
Item {
|
||||||
onVisibleChanged: {
|
id: notificationsParent
|
||||||
if (visible && !root.expandedApplet) {
|
property var applet
|
||||||
var applet = appletIconsRow.children[0].applet;
|
clip: true
|
||||||
applet.expanded = true;
|
Layout.minimumHeight: applet ? applet.Layout.minimumHeight : 0
|
||||||
appletsStack.replace(applet.fullRepresentationItem);
|
Layout.fillWidth: true
|
||||||
root.expandedApplet = applet;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue