Skip to content

Commit

Permalink
Make Shutdown button work, remove unwanted item
Browse files Browse the repository at this point in the history
  • Loading branch information
prateekmedia committed Jun 29, 2021
1 parent e9013a2 commit 00d8386
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 32 deletions.
45 changes: 22 additions & 23 deletions contents/ui/Footer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ PlasmaExtras.PlasmoidHeading {
id: kuser
}

PlasmaCore.DataSource {
id: pmEngine
engine: "powermanagement"
connectedSources: ["PowerDevil", "Sleep States"]
function performOperation(what) {
var service = serviceForSource("PowerDevil")
var operation = service.operationDescription(what)
service.startOperationCall(operation)
}
}

state: "name"

states: [
Expand Down Expand Up @@ -165,7 +176,6 @@ PlasmaExtras.PlasmoidHeading {

PlasmaExtras.Heading {
id: infoLabel
anchors.fill: parent
level: 5
opacity: 0
text: kuser.os !== "" ? i18n("%2@%3 (%1)", kuser.os, kuser.loginName, kuser.host) : i18n("%1@%2", kuser.loginName, kuser.host)
Expand All @@ -192,32 +202,21 @@ PlasmaExtras.PlasmoidHeading {
// looks visually balanced that way
spacing: Math.round(PlasmaCore.Units.smallSpacing * 2.5)

PlasmaComponents.ToolButton {
id: leaveButton
icon.name: "system-shutdown"

// Make it look pressed while the menu is open
checked: contextMenu.status === PlasmaComponents2.DialogStatus.Open
onPressed: contextMenu.openRelative()
PlasmaComponents.RoundButton {
id: lockScreenButton
icon.name: "system-lock-screen"
onPressed: pmEngine.performOperation("lockScreen")
PlasmaComponents.ToolTip {
text: "Shutdown Options"
text: "Lock Screen"
}
}
}


PlasmaComponents2.Menu {
id: contextMenu
visualParent: leaveButton
placement: {
switch (plasmoid.location) {
case PlasmaCore.Types.LeftEdge:
case PlasmaCore.Types.RightEdge:
case PlasmaCore.Types.TopEdge:
return PlasmaCore.Types.BottomPosedRightAlignedPopup;
case PlasmaCore.Types.BottomEdge:
default:
return PlasmaCore.Types.TopPosedRightAlignedPopup;
PlasmaComponents.RoundButton {
id: leaveButton
icon.name: "system-shutdown"
onPressed: pmEngine.performOperation("requestShutDown")
PlasmaComponents.ToolTip {
text: "Shutdown"
}
}
}
Expand Down
17 changes: 8 additions & 9 deletions contents/ui/MainColumnItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.kde.kquickcontrolsaddons 2.0 as KQuickAddons

import QtQuick 2.12
import QtQuick.Layouts 1.12
import QtGraphicalEffects 1.0
//import org.kde.plasma.core 2.1 as PlasmaCore
import org.kde.plasma.components 3.0 as PlasmaComponents
import org.kde.kirigami 2.13 as Kirigami
Expand Down Expand Up @@ -68,7 +69,7 @@ Item {
id: playAllGrid
running: false
NumberAnimation { target: globalFavoritesGrid; property: "x"; from: 100; to: 0; duration: 500; easing.type: Easing.InOutQuad }
NumberAnimation { target: allAppsGrid; property: "x"; from: 100; to: 0; duration: 500; easing.type: Easing.InOutQuad }
NumberAnimation { target: allAppsGrid; property: "y"; from: 100; to: 0; duration: 500; easing.type: Easing.InOutQuad }
}

function reset() {
Expand All @@ -81,7 +82,6 @@ Item {
function reload() {
mainColumn.visible = false
recentItem.visible = false
bottomItem.visible = false
globalFavoritesGrid.model = null
documentsFavoritesGrid.model = null
preloadAllAppsTime.done = false
Expand Down Expand Up @@ -121,7 +121,6 @@ Item {
done = true;
mainColumn.visible = true
recentItem.visible = true
bottomItem.visible = true
playAllGrid.start()
}
function defer() {
Expand Down Expand Up @@ -246,22 +245,21 @@ Item {

ItemGridView {
id: globalFavoritesGrid
model: globalFavorites
width: parent.width
height: searching ? parent.height : tileSide * 2
cellWidth: tileSide
cellHeight: tileSide
iconSize: iconSize
square: true
model: globalFavorites
dropEnabled: true
usesPlasmaTheme: true
verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff
z: (opacity == 1.0) ? 1 : 0
enabled: (opacity == 1.0) ? 1 : 0
verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff
opacity: searching || showAllApps ? 0 : 1
onOpacityChanged: {
if (opacity == 1.0) {
//globalFavoritesGrid.flickableItem.contentY = 0;
mainColumn.visibleGrid = globalFavoritesGrid;
}
}
Expand All @@ -271,19 +269,20 @@ Item {

ItemGridView {
id: allAppsGrid
model: rootModel.modelForRow(2)
anchors.fill: parent
z: (opacity == 1.0) ? 1 : 0
width: parent.width
height: parent.height
enabled: (opacity == 1.0) ? 1 : 0
cellWidth: tileSide
cellHeight: tileSide
iconSize: iconSize
square: true
dropEnabled: true
usesPlasmaTheme: true
z: (opacity == 1.0) ? 1 : 0
enabled: (opacity == 1.0) ? 1 : 0
verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff
opacity: !searching && showAllApps ? 1 : 0
model: rootModel.modelForRow(2);
onOpacityChanged: {
if (opacity == 1.0) {
mainColumn.visibleGrid = allAppsGrid;
Expand Down

0 comments on commit 00d8386

Please sign in to comment.