feat: new power dialog

pull/18/head
kate 5 years ago
parent 6d9c8a0bcd
commit 50aba9fab8

@ -56,6 +56,8 @@ set(SRCS
src/appmenu/dbusmenu_interface.cpp
src/appmenu/dbusmenu_interface.h
src/poweractions.cpp
qml.qrc
)

@ -0,0 +1,8 @@
<svg width="24" height="24" version="1.1" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<defs>
<style id="current-color-scheme" type="text/css">.ColorScheme-Text {
color:#363636;
}</style>
</defs>
<path class="ColorScheme-Text" d="m12 1c-6.0751 0-11 4.9249-11 11 0 6.0751 4.9249 11 11 11 6.0751 0 11-4.9249 11-11 0-6.0751-4.9249-11-11-11zm0 0.91667c5.5688 0 10.083 4.5145 10.083 10.083 0 5.5688-4.5145 10.083-10.083 10.083-5.5688 0-10.083-4.5145-10.083-10.083 0-5.5688 4.5145-10.083 10.083-10.083zm-0.0358 1.8333c-2.0313 0-3.6667 1.6353-3.6667 3.6667v3.6667h-1.0026c-0.94792 0-1.7116 0.81767-1.7116 1.8333v3.6667c0 1.0157 0.76363 1.8333 1.7116 1.8333h9.4105c0.94792 0 1.7116-0.81767 1.7116-1.8333v-3.6667c0-1.0157-0.76363-1.8333-1.7116-1.8333h-1.0742v-3.6667c0-2.0313-1.6353-3.6667-3.6667-3.6667zm0 0.91667c1.5235 0 2.75 1.4309 2.75 3.2083v3.2083h-5.5v-3.2083c0-1.7774 1.2265-3.2083 2.75-3.2083zm-4.5475 7.3333h9.1667c0.50783 0 0.91667 0.40883 0.91667 0.91667v3.6667c0 0.50783-0.40883 0.91667-0.91667 0.91667h-9.1667c-0.50783 0-0.91667-0.40883-0.91667-0.91667v-3.6667c0-0.50783 0.40883-0.91667 0.91667-0.91667z" fill="#fff" stroke-width=".91667"/>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -0,0 +1,8 @@
<svg width="24" height="24" version="1.1" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<defs>
<style id="current-color-scheme" type="text/css">.ColorScheme-Text {
color:#dedede;
}</style>
</defs>
<path class="ColorScheme-Text" d="m12 1a11 11 0 0 0-11 11 11 11 0 0 0 11 11 11 11 0 0 0 11-11 11 11 0 0 0-11-11zm0 0.91667a10.083 10.083 0 0 1 10.083 10.083 10.083 10.083 0 0 1-10.083 10.083 10.083 10.083 0 0 1-10.083-10.083 10.083 10.083 0 0 1 10.083-10.083zm2.997 2.75-7.5804 7.3333 7.5804 7.3333 0.6696-0.64167-6.9108-6.6917 6.9108-6.6917z" fill="#fff" stroke-width=".91667"/>
</svg>

After

Width:  |  Height:  |  Size: 613 B

@ -0,0 +1,8 @@
<svg width="24" height="24" version="1.1" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<defs>
<style id="current-color-scheme" type="text/css">.ColorScheme-Text {
color:#dedede;
}</style>
</defs>
<path class="ColorScheme-Text" d="m1 12a11 11 0 0 1 1.5326-5.577l4.9307 4.9289-0.65169 0.64811-4.0373-4.0373a10.083 10.083 0 0 0-0.85759 4.0373 10.083 10.083 0 0 0 10.083 10.083 10.083 10.083 0 0 0 4.9056-1.2873l0.66781 0.67138a11 11 0 0 1-5.5734 1.5326 11 11 0 0 1-11-11zm5.423-9.4673a11 11 0 0 1 5.577-1.5326 11 11 0 0 1 11 11 11 11 0 0 1-1.5326 5.577l-4.9307-4.9289 0.64811-0.64811 4.0373 4.039a10.083 10.083 0 0 0 0.86116-4.039 10.083 10.083 0 0 0-10.083-10.083 10.083 10.083 0 0 0-4.9056 1.2873z" fill="#fff" stroke-width=".91667"/>
</svg>

After

Width:  |  Height:  |  Size: 785 B

@ -0,0 +1,8 @@
<svg width="24" height="24" version="1.1" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<defs>
<style id="current-color-scheme" type="text/css">.ColorScheme-Text {
color:#dedede;
}</style>
</defs>
<path class="ColorScheme-Text" d="m11.083 1.0002v8.25h1.8333v-8.25h-1.8333zm2.75 0.15576v0.93638a10.083 10.083 0 0 1 8.25 9.9082 10.083 10.083 0 0 1-10.083 10.083 10.083 10.083 0 0 1-10.083-10.083 10.083 10.083 0 0 1 8.25-9.9101v-0.92382a11 11 0 0 0-9.1667 10.833 11 11 0 0 0 11 11 11 11 0 0 0 11-11 11 11 0 0 0-9.1667-10.844z" fill="#fff" stroke-width=".91667"/>
</svg>

After

Width:  |  Height:  |  Size: 597 B

@ -0,0 +1,9 @@
<svg width="24" height="24" version="1.1" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<style id="current-color-scheme" type="text/css">.ColorScheme-Text {
color:#dedede;
}</style>
<g class="ColorScheme-Text" transform="matrix(.9893 0 0 .9893 -2.9572 -4.7003)" fill="#fff">
<path d="m9.762 5.762a12 12 0 0 0-4e-3 8e-3 12 12 0 0 0-5.758 10.23 12 12 0 0 0 12 12 12 12 0 0 0 10.238-5.762l-0.732-0.732a11 11 0 0 1-5.506 1.494 11 11 0 0 1-11-11 11 11 0 0 1 1.486-5.502 11 11 0 0 1 8e-3 -4e-3zm-0.962 1.94a12 12 0 0 0-0.8 4.298 12 12 0 0 0 12 12 12 12 0 0 0 4.326-0.82 11 11 0 0 1-8.326 3.82 11 11 0 0 1-11-11 11 11 0 0 1 3.8-8.299zm13.2-1.702v1h2.293l-2.293 2.293v0.707h4v-1h-2.293l2.293-2.293v-0.707h-0.707z"/>
<path d="m20 13v1h2.293l-2.293 2.293v0.707h4v-1h-2.293l2.293-2.293v-0.707h-0.707zm-6-5v1h2.293l-2.293 2.293v0.707h4v-1h-2.293l2.293-2.293v-0.707h-0.707z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 913 B

@ -0,0 +1,8 @@
<svg width="24" height="24" version="1.1" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<defs>
<style id="current-color-scheme" type="text/css">.ColorScheme-Text {
color:#363636;
}</style>
</defs>
<path class="ColorScheme-Text" d="m12 1c-6.0751 0-11 4.9249-11 11 0 6.0751 4.9249 11 11 11 6.0751 0 11-4.9249 11-11 0-6.0751-4.9249-11-11-11zm0 0.91667c5.5688 0 10.083 4.5145 10.083 10.083 0 5.5688-4.5145 10.083-10.083 10.083-5.5688 0-10.083-4.5145-10.083-10.083 0-5.5688 4.5145-10.083 10.083-10.083zm-0.0358 1.8333c-2.0313 0-3.6667 1.6353-3.6667 3.6667v3.6667h-1.0026c-0.94792 0-1.7116 0.81767-1.7116 1.8333v3.6667c0 1.0157 0.76363 1.8333 1.7116 1.8333h9.4105c0.94792 0 1.7116-0.81767 1.7116-1.8333v-3.6667c0-1.0157-0.76363-1.8333-1.7116-1.8333h-1.0742v-3.6667c0-2.0313-1.6353-3.6667-3.6667-3.6667zm0 0.91667c1.5235 0 2.75 1.4309 2.75 3.2083v3.2083h-5.5v-3.2083c0-1.7774 1.2265-3.2083 2.75-3.2083zm-4.5475 7.3333h9.1667c0.50783 0 0.91667 0.40883 0.91667 0.91667v3.6667c0 0.50783-0.40883 0.91667-0.91667 0.91667h-9.1667c-0.50783 0-0.91667-0.40883-0.91667-0.91667v-3.6667c0-0.50783 0.40883-0.91667 0.91667-0.91667z" fill="#363636" stroke-width=".91667"/>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -0,0 +1,8 @@
<svg width="24" height="24" version="1.1" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<defs>
<style id="current-color-scheme" type="text/css">.ColorScheme-Text {
color:#dedede;
}</style>
</defs>
<path class="ColorScheme-Text" d="m12 1a11 11 0 0 0-11 11 11 11 0 0 0 11 11 11 11 0 0 0 11-11 11 11 0 0 0-11-11zm0 0.91667a10.083 10.083 0 0 1 10.083 10.083 10.083 10.083 0 0 1-10.083 10.083 10.083 10.083 0 0 1-10.083-10.083 10.083 10.083 0 0 1 10.083-10.083zm2.997 2.75-7.5804 7.3333 7.5804 7.3333 0.6696-0.64167-6.9108-6.6917 6.9108-6.6917z" fill="#363636" stroke-width=".91667"/>
</svg>

After

Width:  |  Height:  |  Size: 616 B

@ -0,0 +1,8 @@
<svg width="24" height="24" version="1.1" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<defs>
<style id="current-color-scheme" type="text/css">.ColorScheme-Text {
color:#dedede;
}</style>
</defs>
<path class="ColorScheme-Text" d="m1 12a11 11 0 0 1 1.5326-5.577l4.9307 4.9289-0.65169 0.64811-4.0373-4.0373a10.083 10.083 0 0 0-0.85759 4.0373 10.083 10.083 0 0 0 10.083 10.083 10.083 10.083 0 0 0 4.9056-1.2873l0.66781 0.67138a11 11 0 0 1-5.5734 1.5326 11 11 0 0 1-11-11zm5.423-9.4673a11 11 0 0 1 5.577-1.5326 11 11 0 0 1 11 11 11 11 0 0 1-1.5326 5.577l-4.9307-4.9289 0.64811-0.64811 4.0373 4.039a10.083 10.083 0 0 0 0.86116-4.039 10.083 10.083 0 0 0-10.083-10.083 10.083 10.083 0 0 0-4.9056 1.2873z" fill="#363636" stroke-width=".91667"/>
</svg>

After

Width:  |  Height:  |  Size: 788 B

@ -0,0 +1,8 @@
<svg width="24" height="24" version="1.1" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<defs>
<style id="current-color-scheme" type="text/css">.ColorScheme-Text {
color:#dedede;
}</style>
</defs>
<path class="ColorScheme-Text" d="m11.083 1.0002v8.25h1.8333v-8.25h-1.8333zm2.75 0.15576v0.93638a10.083 10.083 0 0 1 8.25 9.9082 10.083 10.083 0 0 1-10.083 10.083 10.083 10.083 0 0 1-10.083-10.083 10.083 10.083 0 0 1 8.25-9.9101v-0.92382a11 11 0 0 0-9.1667 10.833 11 11 0 0 0 11 11 11 11 0 0 0 11-11 11 11 0 0 0-9.1667-10.844z" fill="#363636" stroke-width=".91667"/>
</svg>

After

Width:  |  Height:  |  Size: 600 B

@ -0,0 +1,9 @@
<svg width="24" height="24" version="1.1" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<style id="current-color-scheme" type="text/css">.ColorScheme-Text {
color:#dedede;
}</style>
<g class="ColorScheme-Text" transform="matrix(.9893 0 0 .9893 -2.9572 -4.7003)" fill="#363636">
<path d="m9.762 5.762a12 12 0 0 0-4e-3 8e-3 12 12 0 0 0-5.758 10.23 12 12 0 0 0 12 12 12 12 0 0 0 10.238-5.762l-0.732-0.732a11 11 0 0 1-5.506 1.494 11 11 0 0 1-11-11 11 11 0 0 1 1.486-5.502 11 11 0 0 1 8e-3 -4e-3zm-0.962 1.94a12 12 0 0 0-0.8 4.298 12 12 0 0 0 12 12 12 12 0 0 0 4.326-0.82 11 11 0 0 1-8.326 3.82 11 11 0 0 1-11-11 11 11 0 0 1 3.8-8.299zm13.2-1.702v1h2.293l-2.293 2.293v0.707h4v-1h-2.293l2.293-2.293v-0.707h-0.707z"/>
<path d="m20 13v1h2.293l-2.293 2.293v0.707h4v-1h-2.293l2.293-2.293v-0.707h-0.707zm-6-5v1h2.293l-2.293 2.293v0.707h4v-1h-2.293l2.293-2.293v-0.707h-0.707z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 916 B

@ -111,5 +111,17 @@
<file>images/dark/notification-new-symbolic.svg</file>
<file>images/dark/notification-symbolic.svg</file>
<file>images/logo.svg</file>
<file>qml/ShutdownDialog.qml</file>
<file>images/light/system-lock-screen.svg</file>
<file>images/light/system-log-out.svg</file>
<file>images/light/system-reboot.svg</file>
<file>images/light/system-shutdown.svg</file>
<file>images/light/system-suspend.svg</file>
<file>images/dark/system-lock-screen.svg</file>
<file>images/dark/system-log-out.svg</file>
<file>images/dark/system-reboot.svg</file>
<file>images/dark/system-shutdown.svg</file>
<file>images/dark/system-suspend.svg</file>
<file>qml/StandardCard.qml</file>
</qresource>
</RCC>

@ -97,12 +97,17 @@ Item {
anchors.fill: parent
anchors.leftMargin: FishUI.Theme.smallRadius
anchors.rightMargin: FishUI.Theme.smallRadius
spacing: FishUI.Units.smallSpacing
Item {
Layout.fillHeight: true
}
Image {
id: _image
Layout.preferredWidth: control.height * 0.3
Layout.preferredHeight: control.height * 0.3
sourceSize: Qt.size(width, height)
Layout.preferredWidth: 28
Layout.preferredHeight: 28
sourceSize: Qt.size(28, 28)
asynchronous: true
Layout.alignment: Qt.AlignHCenter
Layout.topMargin: FishUI.Units.largeSpacing
@ -116,19 +121,12 @@ Item {
// }
}
Item {
Layout.fillHeight: true
}
Label {
id: _titleLabel
color: control.checked ? FishUI.Theme.highlightedTextColor : FishUI.Theme.textColor
Layout.preferredHeight: control.height * 0.15
Layout.alignment: Qt.AlignHCenter
}
Item {
Layout.fillHeight: true
visible: text
}
Label {
@ -139,6 +137,7 @@ Item {
Layout.alignment: Qt.AlignHCenter
Layout.maximumWidth: control.width - FishUI.Units.largeSpacing
Layout.bottomMargin: FishUI.Units.largeSpacing
visible: text
}
Item {

@ -212,17 +212,17 @@ ControlCenterDialog {
}
}
IconButton {
id: shutdownButton
implicitWidth: topItem.height
implicitHeight: topItem.height
Layout.alignment: Qt.AlignTop
source: "qrc:/images/" + (FishUI.Theme.darkMode ? "dark/" : "light/") + "system-shutdown-symbolic.svg"
onLeftButtonClicked: {
control.visible = false
process.startDetached("cutefish-shutdown")
}
}
// IconButton {
// id: shutdownButton
// implicitWidth: topItem.height
// implicitHeight: topItem.height
// Layout.alignment: Qt.AlignTop
// source: "qrc:/images/" + (FishUI.Theme.darkMode ? "dark/" : "light/") + "system-shutdown-symbolic.svg"
// onLeftButtonClicked: {
// control.visible = false
// process.startDetached("cutefish-shutdown")
// }
// }
}
}

@ -0,0 +1,180 @@
/*
* Copyright (C) 2021 - 2022 CutefishOS Team.
*
* Author: Kate Leet <kate@cutefishos.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Window 2.12
import QtQuick.Layouts 1.12
import QtGraphicalEffects 1.0
import Cutefish.Accounts 1.0 as Accounts
import Cutefish.Bluez 1.0 as Bluez
import Cutefish.StatusBar 1.0
import Cutefish.Audio 1.0
import FishUI 1.0 as FishUI
ControlCenterDialog {
id: control
width: _mainLayout.implicitWidth + FishUI.Units.largeSpacing * 3
height: _mainLayout.implicitHeight + FishUI.Units.largeSpacing * 3
onWidthChanged: adjustCorrectLocation()
onHeightChanged: adjustCorrectLocation()
onPositionChanged: adjustCorrectLocation()
property point position: Qt.point(0, 0)
property var margin: 4 * Screen.devicePixelRatio
property var borderColor: windowHelper.compositing ? FishUI.Theme.darkMode ? Qt.rgba(255, 255, 255, 0.3)
: Qt.rgba(0, 0, 0, 0.2) : FishUI.Theme.darkMode ? Qt.rgba(255, 255, 255, 0.15)
: Qt.rgba(0, 0, 0, 0.15)
FishUI.WindowBlur {
view: control
geometry: Qt.rect(control.x, control.y, control.width, control.height)
windowRadius: _background.radius
enabled: true
}
FishUI.WindowShadow {
view: control
geometry: Qt.rect(control.x, control.y, control.width, control.height)
radius: _background.radius
}
Rectangle {
id: _background
anchors.fill: parent
radius: windowHelper.compositing ? FishUI.Theme.bigRadius * 1.5 : 0
color: FishUI.Theme.darkMode ? "#4D4D4D" : "#FFFFFF"
opacity: windowHelper.compositing ? FishUI.Theme.darkMode ? 0.5 : 0.7 : 1.0
antialiasing: true
border.width: 1 / Screen.devicePixelRatio
border.pixelAligned: Screen.devicePixelRatio > 1 ? false : true
border.color: control.borderColor
Behavior on color {
ColorAnimation {
duration: 200
easing.type: Easing.Linear
}
}
}
GridLayout {
id: _mainLayout
anchors.fill: parent
anchors.margins: FishUI.Units.largeSpacing * 1.5
rowSpacing: FishUI.Units.largeSpacing
columnSpacing: FishUI.Units.largeSpacing
columns: 3
StandardCard {
Layout.preferredWidth: 96
Layout.preferredHeight: 96
icon: FishUI.Theme.darkMode ? "qrc:/images/dark/system-shutdown.svg"
: "qrc:/images/light/system-shutdown.svg"
visible: true
checked: false
text: qsTr("Shutdown")
onClicked: {
control.visible = false
actions.shutdown()
}
}
StandardCard {
Layout.preferredWidth: 96
Layout.preferredHeight: 96
icon: FishUI.Theme.darkMode ? "qrc:/images/dark/system-reboot.svg"
: "qrc:/images/light/system-reboot.svg"
visible: true
checked: false
text: qsTr("Reboot")
onClicked: {
control.visible = false
actions.reboot()
}
}
StandardCard {
Layout.preferredWidth: 96
Layout.preferredHeight: 96
icon: FishUI.Theme.darkMode ? "qrc:/images/dark/system-log-out.svg"
: "qrc:/images/light/system-log-out.svg"
visible: true
checked: false
text: qsTr("Log out")
onClicked: {
control.visible = false
actions.logout()
}
}
StandardCard {
Layout.preferredWidth: 96
Layout.preferredHeight: 96
icon: FishUI.Theme.darkMode ? "qrc:/images/dark/system-lock-screen.svg"
: "qrc:/images/light/system-lock-screen.svg"
visible: true
checked: false
text: qsTr("Lock Screen")
onClicked: {
control.visible = false
actions.lockScreen()
}
}
StandardCard {
Layout.preferredWidth: 96
Layout.preferredHeight: 96
icon: FishUI.Theme.darkMode ? "qrc:/images/dark/system-suspend.svg"
: "qrc:/images/light/system-suspend.svg"
visible: true
checked: false
text: qsTr("Suspend")
onClicked: {
control.visible = false
actions.suspend()
}
}
}
PowerActions {
id: actions
}
function adjustCorrectLocation() {
var posX = control.position.x
var posY = control.position.y
if (posX + control.width >= StatusBar.screenRect.x + StatusBar.screenRect.width)
posX = StatusBar.screenRect.x + StatusBar.screenRect.width - control.width - control.margin
posY = rootItem.y + rootItem.height + control.margin
control.x = posX
control.y = posY
}
}

@ -0,0 +1,139 @@
/*
* Copyright (C) 2021 CutefishOS Team.
*
* Author: Reion Wong <aj@cutefishos.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import QtGraphicalEffects 1.0
import FishUI 1.0 as FishUI
Item {
id: control
property bool checked: false
property alias icon: _image.source
property alias text: _label.text
signal clicked
signal pressAndHold
property var backgroundColor: FishUI.Theme.darkMode ? Qt.rgba(255, 255, 255, 0.1)
: Qt.rgba(0, 0, 0, 0.05)
property var hoverColor: FishUI.Theme.darkMode ? Qt.rgba(255, 255, 255, 0.15)
: Qt.rgba(0, 0, 0, 0.1)
property var pressedColor: FishUI.Theme.darkMode ? Qt.rgba(255, 255, 255, 0.2)
: Qt.rgba(0, 0, 0, 0.15)
property var highlightHoverColor: FishUI.Theme.darkMode ? Qt.lighter(FishUI.Theme.highlightColor, 1.1)
: Qt.darker(FishUI.Theme.highlightColor, 1.1)
property var highlightPressedColor: FishUI.Theme.darkMode ? Qt.lighter(FishUI.Theme.highlightColor, 1.1)
: Qt.darker(FishUI.Theme.highlightColor, 1.2)
MouseArea {
id: _mouseArea
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.LeftButton
onClicked: control.clicked()
onPressedChanged: {
control.scale = pressed ? 0.95 : 1.0
}
onPressAndHold: {
control.pressAndHold()
}
}
Behavior on scale {
NumberAnimation {
duration: 200
easing.type: Easing.OutSine
}
}
Rectangle {
anchors.fill: parent
radius: FishUI.Theme.bigRadius
opacity: 1
color: {
if (control.checked) {
if (_mouseArea.pressed)
return highlightPressedColor
else if (_mouseArea.containsMouse)
return highlightHoverColor
else
return FishUI.Theme.highlightColor
} else {
if (_mouseArea.pressed)
return pressedColor
else if (_mouseArea.containsMouse)
return hoverColor
else
return backgroundColor
}
}
}
ColumnLayout {
anchors.fill: parent
anchors.leftMargin: FishUI.Theme.smallRadius
anchors.rightMargin: FishUI.Theme.smallRadius
spacing: FishUI.Units.smallSpacing
Item {
Layout.fillHeight: true
}
Image {
id: _image
Layout.preferredWidth: 32
Layout.preferredHeight: 32
sourceSize: Qt.size(32, 32)
asynchronous: true
Layout.alignment: Qt.AlignHCenter
Layout.topMargin: FishUI.Units.largeSpacing
antialiasing: true
smooth: true
// ColorOverlay {
// anchors.fill: _image
// source: _image
// color: control.checked ? FishUI.Theme.highlightedTextColor : FishUI.Theme.disabledTextColor
// }
}
Item {
Layout.fillHeight: true
}
Label {
id: _label
color: control.checked ? FishUI.Theme.highlightedTextColor : FishUI.Theme.textColor
Layout.preferredHeight: control.height * 0.15
Layout.alignment: Qt.AlignHCenter
visible: text
}
Item {
Layout.fillHeight: true
}
}
}

@ -257,7 +257,7 @@ Item {
width: trayView.itemWidth
height: ListView.view.height
animationEnabled: false
animationEnabled: true
onDarkModeChanged: updateTimer.restart()
@ -416,19 +416,32 @@ Item {
visible: battery.showPercentage
}
}
}
}
Image {
id: shutdownIcon
width: rootItem.iconSize
height: width
sourceSize: Qt.size(width, height)
source: "qrc:/images/" + (rootItem.darkMode ? "dark/" : "light/") + "system-shutdown-symbolic.svg"
asynchronous: true
Layout.alignment: Qt.AlignCenter
visible: !batteryIcon.visible
antialiasing: true
smooth: false
}
StandardItem {
id: shutdownItem
animationEnabled: true
Layout.fillHeight: true
Layout.preferredWidth: shutdownIcon.implicitWidth + FishUI.Units.smallSpacing
onClicked: {
shutdownDialog.position = Qt.point(0, 0)
shutdownDialog.position = mapToGlobal(0, 0)
shutdownDialog.open()
}
Image {
id: shutdownIcon
anchors.centerIn: parent
width: rootItem.iconSize
height: width
sourceSize: Qt.size(width, height)
source: "qrc:/images/" + (rootItem.darkMode ? "dark/" : "light/") + "system-shutdown-symbolic.svg"
asynchronous: true
antialiasing: true
smooth: false
}
}
@ -532,6 +545,10 @@ Item {
id: controlCenter
}
ShutdownDialog {
id: shutdownDialog
}
NM.ActiveConnection {
id: activeConnection
}

@ -26,6 +26,7 @@
#include "systemtray/systemtraymodel.h"
#include "appmenu/appmenumodel.h"
#include "appmenu/appmenuapplet.h"
#include "poweractions.h"
#include "appearance.h"
#include "brightness.h"
@ -44,6 +45,7 @@ int main(int argc, char *argv[])
qmlRegisterType<Battery>(uri, 1, 0, "Battery");
qmlRegisterType<AppMenuModel>(uri, 1, 0, "AppMenuModel");
qmlRegisterType<AppMenuApplet>(uri, 1, 0, "AppMenuApplet");
qmlRegisterType<PowerActions>(uri, 1, 0, "PowerActions");
QString qmFilePath = QString("%1/%2.qm").arg("/usr/share/cutefish-statusbar/translations/").arg(QLocale::system().name());
if (QFile::exists(qmFilePath)) {

@ -0,0 +1,72 @@
/*
* Copyright (C) 2021 CutefishOS Team.
*
* Author: revenmartin <revenmartin@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "poweractions.h"
#include <QCommandLineParser>
#include <QDBusInterface>
#include <QApplication>
#include <QProcess>
const static QString s_dbusName = "com.cutefish.Session";
const static QString s_pathName = "/Session";
const static QString s_interfaceName = "com.cutefish.Session";
PowerActions::PowerActions(QObject *parent)
: QObject(parent)
{
}
void PowerActions::shutdown()
{
QDBusInterface iface(s_dbusName, s_pathName, s_interfaceName, QDBusConnection::sessionBus());
if (iface.isValid()) {
iface.call("powerOff");
}
}
void PowerActions::logout()
{
QDBusInterface iface(s_dbusName, s_pathName, s_interfaceName, QDBusConnection::sessionBus());
if (iface.isValid()) {
iface.call("logout");
}
}
void PowerActions::reboot()
{
QDBusInterface iface(s_dbusName, s_pathName, s_interfaceName, QDBusConnection::sessionBus());
if (iface.isValid()) {
iface.call("reboot");
}
}
void PowerActions::lockScreen()
{
QProcess::startDetached("cutefish-screenlocker", QStringList());
}
void PowerActions::suspend()
{
QDBusInterface iface(s_dbusName, s_pathName, s_interfaceName, QDBusConnection::sessionBus());
if (iface.isValid()) {
iface.call("suspend");
}
}

@ -0,0 +1,39 @@
/*
* Copyright (C) 2021 CutefishOS Team.
*
* Author: revenmartin <revenmartin@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ACTIONS_H
#define ACTIONS_H
#include <QObject>
class PowerActions : public QObject
{
Q_OBJECT
public:
explicit PowerActions(QObject *parent = nullptr);
Q_INVOKABLE void shutdown();
Q_INVOKABLE void logout();
Q_INVOKABLE void reboot();
Q_INVOKABLE void lockScreen();
Q_INVOKABLE void suspend();
};
#endif // ACTIONS_H

@ -12,39 +12,67 @@
<context>
<name>ControlCenter</name>
<message>
<location filename="../qml/ControlCenter.qml" line="217"/>
<location filename="../qml/ControlCenter.qml" line="247"/>
<source>Wi-Fi</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/ControlCenter.qml" line="220"/>
<location filename="../qml/ControlCenter.qml" line="236"/>
<location filename="../qml/ControlCenter.qml" line="253"/>
<location filename="../qml/ControlCenter.qml" line="250"/>
<location filename="../qml/ControlCenter.qml" line="266"/>
<location filename="../qml/ControlCenter.qml" line="283"/>
<source>On</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/ControlCenter.qml" line="220"/>
<location filename="../qml/ControlCenter.qml" line="236"/>
<location filename="../qml/ControlCenter.qml" line="253"/>
<location filename="../qml/ControlCenter.qml" line="250"/>
<location filename="../qml/ControlCenter.qml" line="266"/>
<location filename="../qml/ControlCenter.qml" line="283"/>
<source>Off</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/ControlCenter.qml" line="235"/>
<location filename="../qml/ControlCenter.qml" line="265"/>
<source>Bluetooth</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/ControlCenter.qml" line="252"/>
<location filename="../qml/ControlCenter.qml" line="282"/>
<source>Dark Mode</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ShutdownDialog</name>
<message>
<location filename="../qml/ShutdownDialog.qml" line="95"/>
<source>Shutdown</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/ShutdownDialog.qml" line="110"/>
<source>Reboot</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/ShutdownDialog.qml" line="125"/>
<source>Log out</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/ShutdownDialog.qml" line="140"/>
<source>Lock Screen</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/ShutdownDialog.qml" line="155"/>
<source>Suspend</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>main</name>
<message>
<location filename="../qml/main.qml" line="75"/>
<location filename="../qml/main.qml" line="73"/>
<source>Close</source>
<translation type="unfinished"></translation>
</message>

@ -12,39 +12,67 @@
<context>
<name>ControlCenter</name>
<message>
<location filename="../qml/ControlCenter.qml" line="217"/>
<location filename="../qml/ControlCenter.qml" line="247"/>
<source>Wi-Fi</source>
<translation>线</translation>
</message>
<message>
<location filename="../qml/ControlCenter.qml" line="220"/>
<location filename="../qml/ControlCenter.qml" line="236"/>
<location filename="../qml/ControlCenter.qml" line="253"/>
<location filename="../qml/ControlCenter.qml" line="250"/>
<location filename="../qml/ControlCenter.qml" line="266"/>
<location filename="../qml/ControlCenter.qml" line="283"/>
<source>On</source>
<translation></translation>
</message>
<message>
<location filename="../qml/ControlCenter.qml" line="220"/>
<location filename="../qml/ControlCenter.qml" line="236"/>
<location filename="../qml/ControlCenter.qml" line="253"/>
<location filename="../qml/ControlCenter.qml" line="250"/>
<location filename="../qml/ControlCenter.qml" line="266"/>
<location filename="../qml/ControlCenter.qml" line="283"/>
<source>Off</source>
<translation></translation>
</message>
<message>
<location filename="../qml/ControlCenter.qml" line="235"/>
<location filename="../qml/ControlCenter.qml" line="265"/>
<source>Bluetooth</source>
<translation></translation>
</message>
<message>
<location filename="../qml/ControlCenter.qml" line="252"/>
<location filename="../qml/ControlCenter.qml" line="282"/>
<source>Dark Mode</source>
<translation></translation>
</message>
</context>
<context>
<name>ShutdownDialog</name>
<message>
<location filename="../qml/ShutdownDialog.qml" line="95"/>
<source>Shutdown</source>
<translation></translation>
</message>
<message>
<location filename="../qml/ShutdownDialog.qml" line="110"/>
<source>Reboot</source>
<translation></translation>
</message>
<message>
<location filename="../qml/ShutdownDialog.qml" line="125"/>
<source>Log out</source>
<translation></translation>
</message>
<message>
<location filename="../qml/ShutdownDialog.qml" line="140"/>
<source>Lock Screen</source>
<translation></translation>
</message>
<message>
<location filename="../qml/ShutdownDialog.qml" line="155"/>
<source>Suspend</source>
<translation></translation>
</message>
</context>
<context>
<name>main</name>
<message>
<location filename="../qml/main.qml" line="75"/>
<location filename="../qml/main.qml" line="73"/>
<source>Close</source>
<translation></translation>
</message>

Loading…
Cancel
Save