add executable to handle leave actions
authorLudger Krämer <dbluelle@blau-weissoedingen.de>
Fri, 14 Nov 2014 20:56:52 +0000 (21:56 +0100)
committerJerome Leclanche <jerome@leclan.ch>
Mon, 12 Jan 2015 00:41:47 +0000 (01:41 +0100)
17 files changed:
CMakeLists.txt
lxqtleave/CMakeLists.txt [new file with mode: 0644]
lxqtleave/main.cpp [new file with mode: 0644]
lxqtleave/resources/lxqt-hibernate.desktop.in [new file with mode: 0644]
lxqtleave/resources/lxqt-lockscreen.desktop.in [new file with mode: 0644]
lxqtleave/resources/lxqt-logout.desktop.in [new file with mode: 0644]
lxqtleave/resources/lxqt-reboot.desktop.in [new file with mode: 0644]
lxqtleave/resources/lxqt-shutdown.desktop.in [new file with mode: 0644]
lxqtleave/resources/lxqt-suspend.desktop.in [new file with mode: 0644]
lxqtleave/translations/lxqt-hibernate_de.desktop [new file with mode: 0644]
lxqtleave/translations/lxqt-lockscreen_de.desktop [new file with mode: 0644]
lxqtleave/translations/lxqt-logout_de.desktop [new file with mode: 0644]
lxqtleave/translations/lxqt-reboot_de.desktop [new file with mode: 0644]
lxqtleave/translations/lxqt-shutdown_de.desktop [new file with mode: 0644]
lxqtleave/translations/lxqt-suspend_de.desktop [new file with mode: 0644]
lxqtscreensaver.cpp
lxqtscreensaver.h

index e5f78fa..6b60ba8 100644 (file)
@@ -347,3 +347,6 @@ set(CPACK_GENERATOR TBZ2)
 set(CPACK_SOURCE_GENERATOR TBZ2)
 set(CPACK_SOURCE_IGNORE_FILES /build/;.gitignore;.*~;.git;.kdev4;temp)
 include(CPack)
+
+# lxqt-leave executable
+add_subdirectory(lxqtleave)
diff --git a/lxqtleave/CMakeLists.txt b/lxqtleave/CMakeLists.txt
new file mode 100644 (file)
index 0000000..6932b57
--- /dev/null
@@ -0,0 +1,35 @@
+cmake_minimum_required(VERSION 2.8.11)
+project(lxqt-leave)
+
+set(CPP_FILES
+    main.cpp
+)
+
+
+# Translations **********************************
+include(LXQtTranslate)
+lxqt_translate_desktop(DESKTOP_FILES
+    SOURCES
+    resources/lxqt-hibernate.desktop.in
+    resources/lxqt-lockscreen.desktop.in
+    resources/lxqt-logout.desktop.in
+    resources/lxqt-reboot.desktop.in
+    resources/lxqt-shutdown.desktop.in
+    resources/lxqt-suspend.desktop.in
+)
+#************************************************
+
+
+add_executable(lxqt-leave
+    ${CPP_FILES}
+    ${DESKTOP_FILES}
+)
+
+target_link_libraries(lxqt-leave
+    ${LXQT_LIBRARIES}
+    ${LXQT_LIBRARY_NAME}
+)
+
+install(TARGETS lxqt-leave RUNTIME DESTINATION bin)
+install(FILES ${DESKTOP_FILES} DESTINATION share/applications)
+
diff --git a/lxqtleave/main.cpp b/lxqtleave/main.cpp
new file mode 100644 (file)
index 0000000..539fedd
--- /dev/null
@@ -0,0 +1,77 @@
+/* BEGIN_COMMON_COPYRIGHT_HEADER
+ * (c)LGPL2+
+ *
+ * LXDE-Qt - a lightweight, Qt based, desktop toolset
+ * http://razor-qt.org
+ *
+ * Copyright: 2010-2011 Razor team
+ * Authors:
+ *   Petr Vanek <petr@scribus.info>
+ *
+ * This program or library is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * END_COMMON_COPYRIGHT_HEADER */
+
+#include "../lxqtapplication.h"
+#include "../lxqtpowermanager.h"
+#include "../lxqtscreensaver.h"
+#include "../lxqttranslator.h"
+
+int main(int argc, char *argv[])
+{
+    LxQt::Application a(argc,argv);
+    LxQt::Translator::translateApplication();
+
+    LxQt::PowerManager powermanager(&a);
+    LxQt::ScreenSaver screensaver(&a);
+    for (int i=1; i < argc; ++i)
+    {
+        QString arg = QString::fromLocal8Bit(argv[i]);
+
+        if (arg == "--logout")
+        {
+            powermanager.logout();
+            return 0;
+        }
+        if (arg == "--suspend")
+        {
+            powermanager.suspend();
+            return 0;
+        }
+        if (arg == "--hibernate")
+        {
+            powermanager.hibernate();
+            return 0;
+        }
+        if (arg == "--shutdown")
+        {
+            powermanager.shutdown();
+            return 0;
+        }
+        if (arg == "--reboot")
+        {
+            powermanager.reboot();
+            return 0;
+        }
+        if (arg == "--lockscreen")
+        {
+            a.connect(&screensaver,SIGNAL(done()),&a,SLOT(quit()));
+            screensaver.lockScreen();
+            a.exec();
+            return 0;
+        }
+    }
+}
diff --git a/lxqtleave/resources/lxqt-hibernate.desktop.in b/lxqtleave/resources/lxqt-hibernate.desktop.in
new file mode 100644 (file)
index 0000000..140db64
--- /dev/null
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Type=Application
+Name=Hibernate
+GenericName=Hibernate
+Comment=hibernate the machine
+Exec=lxqt-leave --hibernate
+Icon=system-suspend-hibernate
+Categories=LXQt;X-Leave
+OnlyShowIn=LXQt
+
+#TRANSLATIONS_DIR=../translations
diff --git a/lxqtleave/resources/lxqt-lockscreen.desktop.in b/lxqtleave/resources/lxqt-lockscreen.desktop.in
new file mode 100644 (file)
index 0000000..b94f67f
--- /dev/null
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Type=Application
+Name=Lock Screen
+GenericName=Lock Screen
+Comment=Lock the current session
+Exec=lxqt-leave --lockscreen
+Icon=system-lock-screen
+Categories=LXQt;Screensaver
+OnlyShowIn=LXQt;
+
+#TRANSLATIONS_DIR=../translations
diff --git a/lxqtleave/resources/lxqt-logout.desktop.in b/lxqtleave/resources/lxqt-logout.desktop.in
new file mode 100644 (file)
index 0000000..fda3a95
--- /dev/null
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Type=Application
+Name=Logout
+GenericName=Logout
+Comment=Logout from the current session
+Exec=lxqt-leave --logout
+Icon=system-log-out
+Categories=LXQt;X-Leave
+OnlyShowIn=LXQt;
+
+#TRANSLATIONS_DIR=../translations
diff --git a/lxqtleave/resources/lxqt-reboot.desktop.in b/lxqtleave/resources/lxqt-reboot.desktop.in
new file mode 100644 (file)
index 0000000..5b0e160
--- /dev/null
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Type=Application
+Name=Reboot
+GenericName=Reboot
+Comment=reboot the machine
+Exec=lxqt-leave --reboot
+Icon=system-reboot
+Categories=LXQt;X-Leave
+OnlyShowIn=LXQt;
+
+#TRANSLATIONS_DIR=../translations
diff --git a/lxqtleave/resources/lxqt-shutdown.desktop.in b/lxqtleave/resources/lxqt-shutdown.desktop.in
new file mode 100644 (file)
index 0000000..57eb60b
--- /dev/null
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Type=Application
+Name=Shutdown
+GenericName=Shutdown
+Comment=shutdown the machine
+Exec=lxqt-leave --shutdown
+Icon=system-shutdown
+Categories=LXQt;X-Leave
+OnlyShowIn=LXQt;
+
+#TRANSLATIONS_DIR=../translations
diff --git a/lxqtleave/resources/lxqt-suspend.desktop.in b/lxqtleave/resources/lxqt-suspend.desktop.in
new file mode 100644 (file)
index 0000000..ac0d2f3
--- /dev/null
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Type=Application
+Name=Suspend
+GenericName=Suspend
+Comment=suspend the machine
+Exec=lxqt-leave --suspend
+Icon=system-suspend
+Categories=LXQt;X-Leave
+OnlyShowIn=LXQt
+
+#TRANSLATIONS_DIR=../translations
diff --git a/lxqtleave/translations/lxqt-hibernate_de.desktop b/lxqtleave/translations/lxqt-hibernate_de.desktop
new file mode 100644 (file)
index 0000000..74e3dbf
--- /dev/null
@@ -0,0 +1,15 @@
+[Desktop Entry]
+Type=Application
+Name=Hibernate
+GenericName=Hibernate
+Comment=hibernate the machine
+Exec=lxqt-leave --hibernate
+Icon=system-suspend-hibernate
+Categories=LXQt;X-Leave
+OnlyShowIn=LXQt
+
+#TRANSLATIONS_DIR=../translations
+
+# Translations
+Comment[de]=Rechner in Tiefschlaf versetzen
+Name[de]=Tiefschlaf
diff --git a/lxqtleave/translations/lxqt-lockscreen_de.desktop b/lxqtleave/translations/lxqt-lockscreen_de.desktop
new file mode 100644 (file)
index 0000000..448d934
--- /dev/null
@@ -0,0 +1,16 @@
+[Desktop Entry]
+Type=Application
+Name=Lock Screen
+GenericName=Lock Screen
+Comment=Lock the current session
+Exec=lxqt-leave --lockscreen
+Icon=system-lock-screen
+Categories=LXQt;Screensaver
+OnlyShowIn=LXQt;
+
+#TRANSLATIONS_DIR=../translations
+
+
+# Translations
+Comment[de]=aktuelle Sitzung sperren
+Name[de]=Bildschirm sperren
diff --git a/lxqtleave/translations/lxqt-logout_de.desktop b/lxqtleave/translations/lxqt-logout_de.desktop
new file mode 100644 (file)
index 0000000..65e57f6
--- /dev/null
@@ -0,0 +1,15 @@
+[Desktop Entry]
+Type=Application
+Name=Logout
+GenericName=Logout
+Comment=Logout from the current session
+Exec=lxqt-leave --logout
+Icon=system-log-out
+Categories=LXQt;X-Leave
+OnlyShowIn=LXQt;
+
+#TRANSLATIONS_DIR=../translations
+
+# Translations
+Comment[de]=Sitzung beenden
+Name[de]=Abmelden
diff --git a/lxqtleave/translations/lxqt-reboot_de.desktop b/lxqtleave/translations/lxqt-reboot_de.desktop
new file mode 100644 (file)
index 0000000..4c0d386
--- /dev/null
@@ -0,0 +1,15 @@
+[Desktop Entry]
+Type=Application
+Name=Reboot
+GenericName=Reboot
+Comment=reboot the machine
+Exec=lxqt-leave --reboot
+Icon=system-reboot
+Categories=LXQt;X-Leave
+OnlyShowIn=LXQt;
+
+#TRANSLATIONS_DIR=../translations
+
+# Translations
+Comment[de]=Rechner neustarten
+Name[de]=Neustart
diff --git a/lxqtleave/translations/lxqt-shutdown_de.desktop b/lxqtleave/translations/lxqt-shutdown_de.desktop
new file mode 100644 (file)
index 0000000..d656d3d
--- /dev/null
@@ -0,0 +1,15 @@
+[Desktop Entry]
+Type=Application
+Name=Shutdown
+GenericName=Shutdown
+Comment=shutdown the machine
+Exec=lxqt-leave --shutdown
+Icon=system-shutdown
+Categories=LXQt;X-Leave
+OnlyShowIn=LXQt;
+
+#TRANSLATIONS_DIR=../translations
+
+# Translations
+Comment[de]=Rechner herunterfahren
+Name[de]=Herunterfahren
diff --git a/lxqtleave/translations/lxqt-suspend_de.desktop b/lxqtleave/translations/lxqt-suspend_de.desktop
new file mode 100644 (file)
index 0000000..21906e2
--- /dev/null
@@ -0,0 +1,15 @@
+[Desktop Entry]
+Type=Application
+Name=Suspend
+GenericName=Suspend
+Comment=suspend the machine
+Exec=lxqt-leave --suspend
+Icon=system-suspend
+Categories=LXQt;X-Leave
+OnlyShowIn=LXQt
+
+#TRANSLATIONS_DIR=../translations
+
+# Translations
+Comment[de]=Rechner in Bereitschaftsmodus versetzen
+Name[de]=Bereitschaft
index 665fd2a..fe26779 100644 (file)
@@ -125,5 +125,6 @@ void ScreenSaver::xdgProcess_finished(int err, QProcess::ExitStatus status)
                                 "Unknown error - undocumented return value from xdg-screensaver=%1.").arg(err)
                             );
     }
+    emit done();
 }
 
index 0713f74..6290a5e 100644 (file)
@@ -49,7 +49,7 @@ public:
 
 signals:
     void activated();
-
+    void done();
 public slots:
     void lockScreen();