ShutdownUI: add single instance

pull/9/head
reionwong 4 years ago
parent 0616f89957
commit 5e16a0b416

@ -24,6 +24,7 @@
#include <QFile> #include <QFile>
#include <QLocale> #include <QLocale>
#include <QTranslator> #include <QTranslator>
#include <QDBusConnection>
#include "actions.h" #include "actions.h"
@ -33,6 +34,14 @@ int main(int argc, char *argv[])
QGuiApplication app(argc, argv); QGuiApplication app(argc, argv);
if (!QDBusConnection::sessionBus().registerService("org.cutefish.ShutdownUI")) {
return -1;
}
if (!QDBusConnection::sessionBus().registerObject("/ShutdownUI", &app)) {
return -1;
}
// Translations // Translations
QLocale locale; QLocale locale;
QString qmFilePath = QString("%1/%2.qm").arg("/usr/share/cutefish-shutdown/translations/").arg(locale.name()); QString qmFilePath = QString("%1/%2.qm").arg("/usr/share/cutefish-shutdown/translations/").arg(locale.name());

@ -28,7 +28,7 @@ ApplicationWindow {
height: Screen.height height: Screen.height
visible: true visible: true
visibility: Window.FullScreen visibility: Window.FullScreen
flags: Qt.FramelessWindowHint | Qt.Popup flags: Qt.FramelessWindowHint | Qt.X11BypassWindowManagerHint
id: root id: root
color: "transparent" color: "transparent"
@ -59,57 +59,68 @@ ApplicationWindow {
onClicked: exit() onClicked: exit()
} }
RowLayout { Item {
id: layout id: rootItem
anchors.fill: parent anchors.fill: parent
spacing: root.width * 0.05 focus: true
Item { Keys.enabled: true
Layout.fillWidth: true Keys.onEscapePressed: {
Qt.quit()
} }
IconButton { RowLayout {
id: shutdownButton id: layout
Layout.alignment: Qt.AlignVCenter anchors.fill: parent
text: qsTr("Shutdown") spacing: root.width * 0.05
icon: "qrc:///icons/system-shutdown.svg"
onClicked: actions.shutdown() Item {
} Layout.fillWidth: true
}
IconButton {
id: rebootButton IconButton {
Layout.alignment: Qt.AlignVCenter id: shutdownButton
text: qsTr("Reboot") Layout.alignment: Qt.AlignVCenter
icon: "qrc:///icons/system-reboot.svg" text: qsTr("Shutdown")
onClicked: actions.reboot() icon: "qrc:///icons/system-shutdown.svg"
} onClicked: actions.shutdown()
}
IconButton {
id: logoutButton IconButton {
Layout.alignment: Qt.AlignVCenter id: rebootButton
text: qsTr("Logout") Layout.alignment: Qt.AlignVCenter
icon: "qrc:///icons/system-log-out.svg" text: qsTr("Reboot")
onClicked: actions.logout() icon: "qrc:///icons/system-reboot.svg"
} onClicked: actions.reboot()
}
IconButton {
id: lockscreenButton IconButton {
Layout.alignment: Qt.AlignVCenter id: logoutButton
text: qsTr("Lock screen") Layout.alignment: Qt.AlignVCenter
icon: "qrc:/icons/system-lock-screen.svg" text: qsTr("Logout")
onClicked: actions.lockScreen() icon: "qrc:///icons/system-log-out.svg"
} onClicked: actions.logout()
}
IconButton {
id: suspendButton IconButton {
Layout.alignment: Qt.AlignVCenter id: lockscreenButton
text: qsTr("Suspend") Layout.alignment: Qt.AlignVCenter
icon: "qrc:///icons/system-suspend.svg" text: qsTr("Lock screen")
onClicked: actions.suspend() icon: "qrc:/icons/system-lock-screen.svg"
} onClicked: actions.lockScreen()
}
Item {
Layout.fillWidth: true IconButton {
id: suspendButton
Layout.alignment: Qt.AlignVCenter
text: qsTr("Suspend")
icon: "qrc:///icons/system-suspend.svg"
onClicked: actions.suspend()
}
Item {
Layout.fillWidth: true
}
} }
} }
} }

Loading…
Cancel
Save