ShutdownUI: Support lock screen

pull/9/head
reionwong 4 years ago
parent fd3b1f01ee
commit 052e477392

@ -21,6 +21,7 @@
#include <QCommandLineParser> #include <QCommandLineParser>
#include <QDBusInterface> #include <QDBusInterface>
#include <QApplication> #include <QApplication>
#include <QProcess>
const static QString s_dbusName = "org.cutefish.Session"; const static QString s_dbusName = "org.cutefish.Session";
const static QString s_pathName = "/Session"; const static QString s_pathName = "/Session";
@ -56,6 +57,12 @@ void Actions::reboot()
} }
} }
void Actions::lockScreen()
{
QProcess::startDetached("cutefish-screenlocker", QStringList());
qApp->exit(0);
}
void Actions::suspend() void Actions::suspend()
{ {
QDBusInterface iface(s_dbusName, s_pathName, s_interfaceName, QDBusConnection::sessionBus()); QDBusInterface iface(s_dbusName, s_pathName, s_interfaceName, QDBusConnection::sessionBus());

@ -32,6 +32,7 @@ public:
Q_INVOKABLE void shutdown(); Q_INVOKABLE void shutdown();
Q_INVOKABLE void logout(); Q_INVOKABLE void logout();
Q_INVOKABLE void reboot(); Q_INVOKABLE void reboot();
Q_INVOKABLE void lockScreen();
Q_INVOKABLE void suspend(); Q_INVOKABLE void suspend();
}; };

@ -0,0 +1,8 @@
<svg version="1.1" viewBox="0 0 32 32" 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="m16 4c-6.6274 0-12 5.3726-12 12s5.3726 12 12 12 12-5.3726 12-12-5.3726-12-12-12zm0 1c6.0751 0 11 4.9249 11 11s-4.9249 11-11 11-11-4.9249-11-11 4.9249-11 11-11zm-0.039062 2c-2.216 0-4 1.784-4 4v4h-1.0938c-1.0341 0-1.8672 0.892-1.8672 2v4c0 1.108 0.83305 2 1.8672 2h10.266c1.0341 0 1.8672-0.892 1.8672-2v-4c0-1.108-0.83305-2-1.8672-2h-1.1719v-4c0-2.216-1.784-4-4-4zm0 1c1.662 0 3 1.561 3 3.5v3.5h-6v-3.5c0-1.939 1.338-3.5 3-3.5zm-4.9609 8h10c0.554 0 1 0.446 1 1v4c0 0.554-0.446 1-1 1h-10c-0.554 0-1-0.446-1-1v-4c0-0.554 0.446-1 1-1z" fill="#fff"/>
</svg>

After

Width:  |  Height:  |  Size: 790 B

@ -1,17 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"> <svg version="1.1" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
<defs <defs>
id="defs3051"> <style id="current-color-scheme" type="text/css">.ColorScheme-Text {
<style
type="text/css"
id="current-color-scheme">
.ColorScheme-Text {
color:#dedede; color:#dedede;
} }</style>
</style> </defs>
</defs> <path class="ColorScheme-Text" d="m16 4a12 12 0 0 0-12 12 12 12 0 0 0 12 12 12 12 0 0 0 12-12 12 12 0 0 0-12-12zm0 1a11 11 0 0 1 11 11 11 11 0 0 1-11 11 11 11 0 0 1-11-11 11 11 0 0 1 11-11zm3.2695 3-8.2695 8 8.2695 8 0.73047-0.70703-7.5391-7.293 7.5391-7.293-0.73047-0.70703z" fill="#fff"/>
<path
style="fill:currentColor;fill-opacity:1;stroke:none"
d="M 16,3.9999997 A 12,12 0 0 0 4,16 12,12 0 0 0 16,28 12,12 0 0 0 28,16 12,12 0 0 0 16,3.9999997 Z m 0,1 A 11,11 0 0 1 27,16 11,11 0 0 1 16,27 11,11 0 0 1 5,16 11,11 0 0 1 16,4.9999997 Z m 3.269531,3 L 11,16 19.269531,24 20,23.292969 12.460938,16 20,8.7070309 19.269531,7.9999997 Z"
class="ColorScheme-Text"
/>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 640 B

After

Width:  |  Height:  |  Size: 501 B

@ -1,13 +1,8 @@
<svg version="1.1" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"> <svg version="1.1" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
<defs> <defs>
<style type="text/css" id="current-color-scheme"> <style id="current-color-scheme" type="text/css">.ColorScheme-Text {
.ColorScheme-Text {
color:#dedede; color:#dedede;
} }</style>
</style> </defs>
</defs> <path class="ColorScheme-Text" d="m4 16a12 12 0 0 1 1.6719-6.084l5.3789 5.377-0.71094 0.70703-4.4043-4.4043a11 11 0 0 0-0.93555 4.4043 11 11 0 0 0 11 11 11 11 0 0 0 5.3516-1.4043l0.72852 0.73242a12 12 0 0 1-6.0801 1.6719 12 12 0 0 1-12-12zm5.916-10.328a12 12 0 0 1 6.084-1.6719 12 12 0 0 1 12 12 12 12 0 0 1-1.6719 6.084l-5.3789-5.377 0.70703-0.70703 4.4043 4.4062a11 11 0 0 0 0.93945-4.4062 11 11 0 0 0-11-11 11 11 0 0 0-5.3516 1.4043z" fill="#fff"/>
<path style="fill:currentColor;fill-opacity:1;stroke:none"
class="ColorScheme-Text"
d="M 4,16 A 12,12 0 0 1 5.671875,9.916016 L 11.050781,15.292969 10.339844,16 5.935547,11.595703 A 11,11 0 0 0 5,16 11,11 0 0 0 16,27 11,11 0 0 0 21.351562,25.595703 l 0.728516,0.732422 A 12,12 0 0 1 16,28 12,12 0 0 1 4,16 Z M 9.916016,5.671875 A 12,12 0 0 1 16,4 12,12 0 0 1 28,16 12,12 0 0 1 26.328125,22.083984 L 20.949219,16.707031 21.65625,16 26.060547,20.40625 A 11,11 0 0 0 27,16 11,11 0 0 0 16,5 11,11 0 0 0 10.648438,6.404297 Z"
/>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 809 B

After

Width:  |  Height:  |  Size: 676 B

@ -1,17 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"> <svg version="1.1" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
<defs <defs>
id="defs3051"> <style id="current-color-scheme" type="text/css">.ColorScheme-Text {
<style
type="text/css"
id="current-color-scheme">
.ColorScheme-Text {
color:#dedede; color:#dedede;
} }</style>
</style> </defs>
</defs> <path class="ColorScheme-Text" d="m15 4v0.05078 1.0039 7.9453h2v-7.9492-1.0039-0.046875h-1-1zm3 0.16992v1.0215a11 11 0 0 1 9 10.809 11 11 0 0 1-11 11 11 11 0 0 1-11-11 11 11 0 0 1 9-10.811v-1.0078a12 12 0 0 0-10 11.818 12 12 0 0 0 12 12 12 12 0 0 0 12-12 12 12 0 0 0-10-11.83z" fill="#fff"/>
<path
style="fill:currentColor;fill-opacity:1;stroke:none"
d="M 15,4 15,4.05078 15,5.054686 15,13 17,13 17,5.050781 17,4.046875 17,4 16,4 15,4 Z m 3,0.169922 0,1.021484 A 11,11 0 0 1 27,16 11,11 0 0 1 16,27 11,11 0 0 1 5,16 11,11 0 0 1 14,5.189453 L 14,4.181641 A 12,12 0 0 0 4,16 12,12 0 0 0 16,28 12,12 0 0 0 28,16 12,12 0 0 0 18,4.169922 Z"
class="ColorScheme-Text"
/>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 641 B

After

Width:  |  Height:  |  Size: 502 B

@ -1,13 +1,9 @@
<svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"> <svg version="1.1" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
<style <style id="current-color-scheme" type="text/css">.ColorScheme-Text {
type="text/css"
id="current-color-scheme">
.ColorScheme-Text {
color:#dedede; color:#dedede;
} }</style>
</style> <g class="ColorScheme-Text" fill="#fff">
<g class="ColorScheme-Text" fill="currentColor"> <path d="M9.762 5.762a12 12 0 0 0-.004.008A12 12 0 0 0 4 16a12 12 0 0 0 12 12 12 12 0 0 0 10.238-5.762l-.732-.732A11 11 0 0 1 20 23 11 11 0 0 1 9 12a11 11 0 0 1 1.486-5.502 11 11 0 0 1 .008-.004zM8.8 7.702A12 12 0 0 0 8 12a12 12 0 0 0 12 12 12 12 0 0 0 4.326-.82A11 11 0 0 1 16 27 11 11 0 0 1 5 16a11 11 0 0 1 3.8-8.299zM22 6v1h2.293l-2 2-.293.293V10h4V9h-2.293l2-2L26 6.707V6h-.707z"/>
<path d="M9.762 5.762a12 12 0 0 0-.004.008A12 12 0 0 0 4 16a12 12 0 0 0 12 12 12 12 0 0 0 10.238-5.762l-.732-.732A11 11 0 0 1 20 23 11 11 0 0 1 9 12a11 11 0 0 1 1.486-5.502 11 11 0 0 1 .008-.004zM8.8 7.702A12 12 0 0 0 8 12a12 12 0 0 0 12 12 12 12 0 0 0 4.326-.82A11 11 0 0 1 16 27 11 11 0 0 1 5 16a11 11 0 0 1 3.8-8.299zM22 6v1h2.293l-2 2-.293.293V10h4V9h-2.293l2-2L26 6.707V6h-.707z"/> <path d="M20 13v1h2.293l-2 2-.293.293V17h4v-1h-2.293l2-2 .293-.293V13h-.707zm-6-5v1h2.293l-2 2-.293.293V12h4v-1h-2.293l2-2L18 8.707V8h-.707z"/>
<path d="M20 13v1h2.293l-2 2-.293.293V17h4v-1h-2.293l2-2 .293-.293V13h-.707zm-6-5v1h2.293l-2 2-.293.293V12h4v-1h-2.293l2-2L18 8.707V8h-.707z"/> </g>
</g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 825 B

After

Width:  |  Height:  |  Size: 780 B

@ -92,6 +92,14 @@ ApplicationWindow {
onClicked: actions.logout() onClicked: actions.logout()
} }
IconButton {
id: lockscreenButton
Layout.alignment: Qt.AlignVCenter
text: qsTr("Lock screen")
icon: "qrc:/icons/system-lock-screen.svg"
onClicked: actions.lockScreen()
}
IconButton { IconButton {
id: suspendButton id: suspendButton
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter

@ -6,5 +6,6 @@
<file>icons/system-shutdown.svg</file> <file>icons/system-shutdown.svg</file>
<file>icons/system-suspend.svg</file> <file>icons/system-suspend.svg</file>
<file>IconButton.qml</file> <file>IconButton.qml</file>
<file>icons/system-lock-screen.svg</file>
</qresource> </qresource>
</RCC> </RCC>

Loading…
Cancel
Save