About::About(QWidget *parent): QDialog(parent){
setupUi(this);
textBrowser->setOpenExternalLinks(true);
textBrowser_2->setHtml(tr("Special thanks to:
"
"Fabian Deuchler for helping here and "
"there.
And Brian Nelson for "
"sponsoring the uploads to Debian.
"
"As well as to Miquel Banchs i Piqué for the idea of "
"implementing a routine allowing custom settings for "
"each day of the week.
"));
textBrowser->setText(tr("qshutdown, a time and countdown based shutdown tool
"
"Author: Christian Metscher <hakaishi@web.de>
"
"Copyright © 2010-2019, by Christian Metscher
"
""
"https://launchpad.net/~hakaishi
"
"Please use https://bugs.launchpad.net/qt-shutdown-p"
" or "
"http://www.debian.org/Bugs/Reporting"
" to report bugs.
"));
//Versioning
QFile versionFile(":version");
versionFile.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream in(&versionFile);
QString string = in.readLine();
version->setText(tr("Version ") + string);
versionFile.close();
icon = QIcon(":red_glasses_image");
QPixmap pixmap = icon.pixmap(QSize(60,60), QIcon::Normal, QIcon::On);
label->setPixmap(pixmap);
}
About::~About(){ }
shutdown-qapps-1.7.4/qshutdown/src/gui.h 0000664 0001750 0001750 00000007020 13477727547 017332 0 ustar chris chris /* qshutdown, a program to shutdown/reboot/suspend/hibernate the system
* Copyright (C) 2010-2019 Christian Metscher
* 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
* (at your option) 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 .
*/
#ifndef GUI_H
#define GUI_H
#include "ui_gui.h"
#include
#include
#include
#include
#include
#ifndef Q_OS_WIN32
#include
#endif
#define SERVICE_NAME "org.qshutdown"
#define OBJECT_NAME "/org/qshutdown"
class Preferences;
class Info;
class Calendar;
class PassWord;
class Editor;
class About;
class Gui : public QMainWindow, public Ui::Gui {
Q_OBJECT // important for creating own singals and slots
public:
Gui();
~Gui();
void loadSettings();
void center();
QString information;
private:
bool timeRunning;
bool aWeeklyTimeWasSet;
QPushButton *minim;
QTimer *timer, *ti;
QDateTime localDatetime, futureDateTime;
QTime elapsedTime, oldTime;
QIcon icon;
QSystemTrayIcon *TIcon;
QMenu *menu;
QActionGroup *power_actions;
QAction *shutdown_action, *reboot_action,
*suspend_action, *hibernate_action;
QAction *minimize_restore_action, *quit_action,
*reset_action, *info_action, *log_action, *pref_action;
int i; //number of seconds left
int oldComboBoxIndex;
double bigI; //for more precise display
const static int n = 10; //to check if i==0 was skipped
QFont *font1, *font2, *font3;
double logFileSize;
Preferences *pref;
Info *infoBox;
Calendar *cal;
PassWord *checkPassword;
Editor *editor;
About *about;
//QLabel *parentalLockL, *customL;
// defining signals and slots
private slots:
void tray_actions();
void warnings_on();
void iconActivated(QSystemTrayIcon::ActivationReason reason);
void showW();
void updateT();
bool Time();
void power_action(int action);
void power(QAction *action);
void reset();
void finished_();
void beforeQuit();
void setInfoText();
void getFonts();
void showCalendarBox();
void saveOldTime(QTime time);
void saveOldComboBoxIndex(int i);
void setDate();
void lockEverything(bool actual);
void updateLock();
void showEditor();
void staticProportions(bool var);
void saveLog();
void hideTrayIcon(bool dontShowTray);
public slots:
Q_SCRIPTABLE void showRunningProgram();
Q_SCRIPTABLE void set();
protected:
void keyPressEvent(QKeyEvent* kEvent);
virtual void closeEvent(QCloseEvent* window_close);
virtual void showEvent(QShowEvent* window_show);
virtual void hideEvent(QHideEvent* window_hide);
};
#endif //GUI_H
shutdown-qapps-1.7.4/qshutdown/src/weekday.h 0000664 0001750 0001750 00000002255 13477727620 020174 0 ustar chris chris /* qshutdown, a program to shutdown/reboot/suspend/hibernate the system
* Copyright (C) 2010-2019 Christian Metscher
* 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
* (at your option) 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 .
*/
#ifndef WEEKDAY_H
#define WEEKDAY_H
#include
#include
#include
#include
#include
#include
class WeekDay : public QFrame{
Q_OBJECT
public:
WeekDay(QWidget *parent = 0);
~WeekDay();
QSpinBox *spin;
QLabel *label;
private:
//QFrame *frame;
QHBoxLayout *dayL;
QSpacerItem *h;
};
#endif //WEEKDAY_H
shutdown-qapps-1.7.4/qshutdown/src/ch_passwd.h 0000664 0001750 0001750 00000002554 13477727525 020524 0 ustar chris chris /* qshutdown, a program to shutdown/reboot/suspend/hibernate the system
* Copyright (C) 2010-2019 Christian Metscher
* 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
* (at your option) 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 .
*/
#ifndef CH_PASSWD_H
#define CH_PASSWD_H
#include "ui_ch_passwd.h"
#include
#include
class ChangePassword : public QDialog, public Ui::ChangePassword {
Q_OBJECT
public:
ChangePassword(QWidget *parent = 0);
~ChangePassword();
signals:
void updatePasswordGui();
private:
QSettings *settings;
QString file;
QMessageBox *msgBox1, *msgBox2;
private slots:
void checkOldPW();
void checkNewPW();
void savePW();
protected:
virtual void closeEvent(QCloseEvent* close_ch_pw);
};
#endif //CH_PASSWD_H
shutdown-qapps-1.7.4/qshutdown/src/info.cpp 0000664 0001750 0001750 00000002430 13477727553 020031 0 ustar chris chris /* qshutdown, a program to shutdown/reboot/suspend/hibernate the system
* Copyright (C) 2010-2019 Christian Metscher
* 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
* (at your option) 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 .
*/
#include "info.h"
Info::Info(QWidget *parent): QTextEdit(parent){
isClosed = true;
setWindowFlags(Qt::Window);
setReadOnly(true);
resize(500,450);
setWindowTitle(tr("Info"));
}
Info::~Info(){ }
void Info::showEvent(QShowEvent* show_Info){
isClosed = false;
starting();
QWidget::showEvent(show_Info);
}
void Info::closeEvent(QCloseEvent* close_Info){
isClosed = true;
finishing();
QWidget::closeEvent(close_Info);
}
bool Info::getClosed(){ return isClosed; }
shutdown-qapps-1.7.4/qshutdown/src/weekdayitem.cpp 0000664 0001750 0001750 00000003560 13477727624 021412 0 ustar chris chris /* qshutdown, a program to shutdown/reboot/suspend/hibernate the system
* Copyright (C) 2010-2019 Christian Metscher
* 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
* (at your option) 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 .
*/
#include "weekdayitem.h"
#include
WeekDayItem::WeekDayItem(QWidget *parent) : QWidget(parent){
itemL = new QHBoxLayout(this);
itemL->setContentsMargins(0,0,0,0);
h2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
timeEdit = new QTimeEdit(this);
QString timeEditFormat = timeEdit->displayFormat();
if(timeEditFormat.contains(":ss"))
timeEditFormat.replace(QString(":ss"), QString(""));
if(timeEditFormat.contains(":s"))
timeEditFormat.replace(QString(":s"), QString(""));
timeEdit->setDisplayFormat(timeEditFormat);
timeEdit->setTime(QTime(22,0,0));
comboBox = new QComboBox(this);
comboBox->insertItems(0, QStringList()
<< QCoreApplication::translate("Gui", "Shutdown", 0)
<< QCoreApplication::translate("Gui", "Reboot", 0)
<< QCoreApplication::translate("Gui", "Suspend", 0)
<< QCoreApplication::translate("Gui", "Hibernate", 0)
);
itemL->addItem(h2);
itemL->addWidget(timeEdit);
itemL->addWidget(comboBox);
}
WeekDayItem::~WeekDayItem(){;}
shutdown-qapps-1.7.4/qshutdown/src/power.h 0000664 0001750 0001750 00000056172 13477727600 017704 0 ustar chris chris /* qshutdown, a program to shutdown the shutdown/reboot/suspend/hibernate
* Copyright (C) 2010-2019 Christian Metscher
* 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
* (at your option) 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 .
*/
/* INFO: For Windows hibernate has to be activated:
Please note that this only works if the hardware supports it and
enough RAM is available.
- powercfg -a #prints aviable sleep states
- powercfg -hibernate on
- powercfg -hibernate off
*/
#ifndef POWER_H
#define POWER_H
#ifndef Q_OS_WIN32
#include
#endif
#include
#include
extern bool verbose;
extern QString shell;
namespace Power{
QTextStream oput(stdout);
bool lockMyScreen;
bool automatic = false;
bool login1 = false;
bool gnome = false;
bool kde = false;
bool hal_ = false;
bool consolekit = false;
bool sudo = false;
bool upower_ = false;
bool devicekit = false;
bool user = false;
QString myShutdown, myReboot, mySuspend, myHibernate;
void shutdown(){
#ifndef Q_OS_WIN32
QDBusMessage response;
//variables for automatic mode
bool g_pwr1 = false;
bool g_pwr2 = false;
QStringList args;
args << "-c" << myShutdown;
QDBusInterface freedesktopLogin1("org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager", QDBusConnection::systemBus());
QDBusInterface gnomeSessionManager("org.gnome.SessionManager",
"/org/gnome/SessionManager", "org.gnome.SessionManager",
QDBusConnection::sessionBus());
QDBusInterface kdeSessionManager("org.kde.ksmserver", "/KSMServer",
"org.kde.KSMServerInterface", QDBusConnection::sessionBus());
QDBusInterface freedesktopHal("org.freedesktop.Hal",
"/org/freedesktop/Hal/devices/computer",
"org.freedesktop.Hal.Device.SystemPowerManagement",
QDBusConnection::systemBus());
QDBusInterface freedesktopConsoleKit("org.freedesktop.ConsoleKit",
"/org/freedesktop/ConsoleKit/Manager", "org.freedesktop.ConsoleKit.Manager",
QDBusConnection::systemBus());
#endif
if(automatic){
#ifdef Q_OS_WIN32
QProcess::startDetached("shutdown -s -f -t 00"); // Windows command to shutdown immediately
}
#else
if(QProcess::startDetached("/usr/bin/systemctl poweroff"))
return;
g_pwr1 = QProcess::startDetached("gnome-power-cmd.sh shutdown");
g_pwr2 = QProcess::startDetached("gnome-power-cmd shutdown");
if(verbose && !g_pwr1 && !g_pwr2)
oput << "W: gnome-power-cmd, gnome-power-cmd.sh and gnome-session-quit didn't work"
<< endl;
else if(g_pwr1 || g_pwr2)
return;
response = freedesktopLogin1.call("PowerOff", true);
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
else return;
response = gnomeSessionManager.call("RequestShutdown");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
else return;
response = gnomeSessionManager.call("Shutdown");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
else return;
response = kdeSessionManager.call("logout", 0, 2, 2);
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
else return;
response = freedesktopHal.call("Shutdown");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
else return;
response = freedesktopConsoleKit.call("Stop");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
else return;
if(QProcess::startDetached("sudo shutdown -P now"))
return;
QProcess::startDetached("sudo shutdown -h -P now");
} //end of automatic
else if(login1){
response = freedesktopLogin1.call("PowerOff", true);
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
}
else if(gnome){
g_pwr1 = QProcess::startDetached("gnome-power-cmd.sh shutdown");
g_pwr2 = QProcess::startDetached("gnome-power-cmd shutdown");
if(verbose && !g_pwr1 && !g_pwr2)
oput << "W: gnome-power-cmd, gnome-power-cmd.sh and gnome-session-quit didn't work"
<< endl;
if(g_pwr1 || g_pwr2)
return;
response = gnomeSessionManager.call("RequestShutdown");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
else return;
response = gnomeSessionManager.call("Shutdown");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
}
else if(kde){
response = kdeSessionManager.call("logout", 0, 2, 2);
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
}
else if(hal_){
response = freedesktopHal.call("Shutdown");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
}
else if(consolekit){
response = freedesktopConsoleKit.call("Stop");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
}
else if(sudo){
if(QProcess::startDetached("sudo /usr/bin/systemctl poweroff"))
return;
if(QProcess::startDetached("sudo shutdown -P now"))
return;
QProcess::startDetached("sudo shutdown -h -P now");
}
else if(user)
if(!shell.isEmpty())
QProcess::startDetached(shell, args);
//resetting variables
automatic = false;
login1 = false;
gnome = false;
kde = false;
hal_ = false;
consolekit = false;
sudo = false;
user = false;
#endif
}
void reboot(){
#ifndef Q_OS_WIN32
QDBusMessage response;
bool g_pwr1 = false;
bool g_pwr2 = false;
QStringList args;
args << "-c" << myReboot;
QDBusInterface freedesktopLogin1("org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager", QDBusConnection::systemBus());
QDBusInterface gnomeSessionManager("org.gnome.SessionManager",
"/org/gnome/SessionManager", "org.gnome.SessionManager",
QDBusConnection::sessionBus());
QDBusInterface kdeSessionManager("org.kde.ksmserver", "/KSMServer",
"org.kde.KSMServerInterface", QDBusConnection::sessionBus());
QDBusInterface freedesktopHal("org.freedesktop.Hal",
"/org/freedesktop/Hal/devices/computer",
"org.freedesktop.Hal.Device.SystemPowerManagement",
QDBusConnection::systemBus());
QDBusInterface freedesktopConsoleKit("org.freedesktop.ConsoleKit",
"/org/freedesktop/ConsoleKit/Manager", "org.freedesktop.ConsoleKit.Manager",
QDBusConnection::systemBus());
#endif
if(automatic){
#ifdef Q_OS_WIN32
QProcess::startDetached("shutdown -r -f -t 00"); // Windows command to reboot immediately
}
#else
if(QProcess::startDetached("/usr/bin/systemctl reboot"))
return;
g_pwr1 = QProcess::startDetached("gnome-power-cmd.sh reboot");
g_pwr2 = QProcess::startDetached("gnome-power-cmd reboot");
if(verbose && !g_pwr1 && !g_pwr2)
oput << "W: gnome-power-cmd and gnome-power-cmd.sh didn't work"
<< endl;
else if(g_pwr1 || g_pwr2)
return;
response = freedesktopLogin1.call("Reboot", true);
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
else return;
response = gnomeSessionManager.call("RequestReboot");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
else return;
QDBusInterface kdeSessionManager("org.kde.ksmserver", "/KSMServer",
"org.kde.KSMServerInterface", QDBusConnection::sessionBus());
response = kdeSessionManager.call("logout", 0, 2, 1);
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
else return;
response = freedesktopHal.call("Reboot");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
else return;
response = freedesktopConsoleKit.call("Restart");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
else return;
QProcess::startDetached("sudo shutdown -r now");
} //end of automatic
else if(login1){
response = freedesktopLogin1.call("Reboot", true);
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
}
else if(gnome){
g_pwr1 = QProcess::startDetached("gnome-power-cmd.sh reboot");
g_pwr2 = QProcess::startDetached("gnome-power-cmd reboot");
if(verbose && !g_pwr1 && !g_pwr2)
oput << "W: gnome-power-cmd and gnome-power-cmd.sh didn't work"
<< endl;
if(g_pwr1 || g_pwr2)
return;
response = gnomeSessionManager.call("RequestReboot");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
}
else if(kde){
response = kdeSessionManager.call("logout", 0, 2, 1);
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
}
else if(hal_){
response = freedesktopHal.call("Reboot");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
}
else if(consolekit){
response = freedesktopConsoleKit.call("Restart");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
}
else if(sudo){
if(QProcess::startDetached("sudo /usr/bin/systemctl reboot"))
return;
QProcess::startDetached("sudo shutdown -r now");
}
else if(user)
if(!shell.isEmpty())
QProcess::startDetached(shell, args);
//resetting variables
automatic = false;
login1 = false;
gnome = false;
kde = false;
hal_ = false;
consolekit = false;
sudo = false;
user = false;
#endif
}
void suspend(){
#ifndef Q_OS_WIN32
QDBusMessage response;
bool g_pwr1 = false;
bool g_pwr2 = false;
QStringList args;
args << "-c" << mySuspend;
QDBusInterface freedesktopLogin1("org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager", QDBusConnection::systemBus());
QDBusInterface freedesktopHal("org.freedesktop.Hal",
"/org/freedesktop/Hal/devices/computer",
"org.freedesktop.Hal.Device.SystemPowerManagement",
QDBusConnection::systemBus());
QDBusInterface freedesktopUPower("org.freedesktop.UPower",
"/org/freedesktop/UPower",
"org.freedesktop.UPower", QDBusConnection::systemBus());
QDBusInterface freedesktopDeviceKit("org.freedesktop.DeviceKit.Power",
"/org/freedesktop/DeviceKit/Power",
"org.freedesktop.DeviceKit.Power", QDBusConnection::systemBus());
if(lockMyScreen){
bool lock_works = false;
QDBusInterface screenlock("org.gnome.ScreenSaver",
"/org/gnome/ScreenSaver", "org.gnome.ScreenSaver",
QDBusConnection::systemBus());
response = screenlock.call("Lock");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
else
lock_works = true;
if(!lock_works){
if(!QProcess::startDetached("gnome-screensaver-command -l")){
if(verbose) oput << "W: gnome-screensaver-command -l didn't work"
<< endl;
}
else lock_works = true;
}
if(!lock_works){
if(!QProcess::startDetached("qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock")){
if(verbose) oput << "W: qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock didn't work"
<< endl;
}
else lock_works = true;
}
if(!lock_works){
if(!QProcess::startDetached("dcop kdesktop KScreensaverIface lock")){
if(verbose) oput << "W: dcop kdesktop KScreensaverIface lock didn't work"
<< endl;
}
else lock_works = true;
}
if(!lock_works){
if(!QProcess::startDetached("xscreensaver-command -lock")){
if(verbose) oput << "W: xscreensaver-command -lock didn't work"
<< endl;
}
else lock_works = true;
}
}
#endif
if(automatic){
#ifdef Q_OS_WIN32
QProcess::startDetached("powercfg -hibernate off"); // enable suspend
QProcess::startDetached("rundll32 powrprof.dll,SetSuspendState");
}
#else
if(QProcess::startDetached("/usr/bin/systemctl suspend"))
return;
g_pwr1 = QProcess::startDetached("gnome-power-cmd.sh suspend");
g_pwr2 = QProcess::startDetached("gnome-power-cmd suspend");
if(!g_pwr1 && !g_pwr2 && verbose)
oput << "W: gnome-power-cmd and gnome-power-cmd.sh didn't work"
<< endl;
else if(g_pwr1 || g_pwr2)
return;
response = freedesktopLogin1.call("Suspend", true);
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
else return;
response = freedesktopHal.call("Suspend",0);
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
else return;
response = freedesktopUPower.call("Suspend");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
else return;
response = freedesktopDeviceKit.call("Suspend");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
} //end of automatic
else if(login1){
response = freedesktopLogin1.call("Suspend", true);
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
}
else if(gnome){
g_pwr1 = QProcess::startDetached("gnome-power-cmd.sh suspend");
g_pwr2 = QProcess::startDetached("gnome-power-cmd suspend");
if(!g_pwr1 && !g_pwr2 && verbose)
oput << "W: gnome-power-cmd and gnome-power-cmd.sh didn't work"
<< endl;
}
else if(hal_){
response = freedesktopHal.call("Suspend",0);
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
}
else if(upower_){
response = freedesktopUPower.call("Suspend");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
}
else if(devicekit){
response = freedesktopDeviceKit.call("Suspend");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
}
else if(user)
if(!shell.isEmpty())
QProcess::startDetached(shell, args);
//resetting variables
automatic = false;
login1 = false;
gnome = false;
hal_ = false;
upower_ = false;
devicekit = false;
user = false;
#endif
}
void hibernate(){
#ifndef Q_OS_WIN32
QDBusMessage response;
bool g_pwr1 = false;
bool g_pwr2 = false;
QStringList args;
args << "-c" << myHibernate;
QDBusInterface freedesktopLogin1("org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager", QDBusConnection::systemBus());
QDBusInterface freedesktopHal("org.freedesktop.Hal",
"/org/freedesktop/Hal/devices/computer",
"org.freedesktop.Hal.Device.SystemPowerManagement",
QDBusConnection::systemBus());
QDBusInterface freedesktopUPower("org.freedesktop.UPower",
"/org/freedesktop/UPower",
"org.freedesktop.UPower", QDBusConnection::systemBus());
QDBusInterface freedesktopDeviceKit("org.freedesktop.DeviceKit.Power",
"/org/freedesktop/DeviceKit/Power",
"org.freedesktop.DeviceKit.Power", QDBusConnection::systemBus());
if(lockMyScreen){
bool lock_works = false;
QDBusInterface screenlock("org.gnome.ScreenSaver",
"/org/gnome/ScreenSaver", "org.gnome.ScreenSaver",
QDBusConnection::systemBus());
response = screenlock.call("Lock");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
else
lock_works = true;
if(!lock_works){
if(!QProcess::startDetached("gnome-screensaver-command -l")){
if(verbose) oput << "W: gnome-screensaver-command -l didn't work"
<< endl;
}
else lock_works = true;
}
if(!lock_works){
if(!QProcess::startDetached("qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock")){
if(verbose) oput << "W: qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock didn't work"
<< endl;
}
else lock_works = true;
}
if(!lock_works){
if(!QProcess::startDetached("dcop kdesktop KScreensaverIface lock")){
if(verbose) oput << "W: dcop kdesktop KScreensaverIface lock didn't work"
<< endl;
}
else lock_works = true;
}
if(!lock_works){
if(!QProcess::startDetached("xscreensaver-command -lock")){
if(verbose) oput << "W: xscreensaver-command -lock didn't work"
<< endl;
}
else lock_works = true;
}
}
#endif
if(automatic){
#ifdef Q_OS_WIN32
QProcess::startDetached("powercfg -hibernate on"); // enable hibernate
QProcess::startDetached("rundll32 powrprof.dll,SetSuspendState");
}
#else
if(QProcess::startDetached("/usr/bin/systemctl hibernate"))
return;
g_pwr1 = QProcess::startDetached("gnome-power-cmd.sh hibernate");
g_pwr2 = QProcess::startDetached("gnome-power-cmd hibernate");
if(!g_pwr1 && !g_pwr2 && verbose)
oput << "W: gnome-power-cmd and gnome-power-cmd.sh didn't work"
<< endl;
else if (g_pwr1 || g_pwr2)
return;
response = freedesktopLogin1.call("Hibernate", true);
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
else return;
response = freedesktopHal.call("Hibernate");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
else return;
response = freedesktopUPower.call("Hibernate");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
else return;
response = freedesktopDeviceKit.call("Hibernate");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
} // end of automatic
else if(login1){
response = freedesktopLogin1.call("Hibernate", true);
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
}
else if(gnome){
g_pwr1 = QProcess::startDetached("gnome-power-cmd.sh hibernate");
g_pwr2 = QProcess::startDetached("gnome-power-cmd hibernate");
if(!g_pwr1 && !g_pwr2 && verbose)
oput << "W: gnome-power-cmd and gnome-power-cmd.sh didn't work"
<< endl;
}
else if(hal_){
response = freedesktopHal.call("Hibernate");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
}
else if(upower_){
response = freedesktopUPower.call("Hibernate");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
}
else if(devicekit){
response = freedesktopDeviceKit.call("Hibernate");
if(response.type() == QDBusMessage::ErrorMessage){
if(verbose)
oput << "W: " << response.errorName() << ": "
<< response.errorMessage() << endl;
}
}
else if(user)
if(!shell.isEmpty())
QProcess::startDetached(shell, args);
//resetting variables
automatic = false;
login1 = false;
gnome = false;
hal_ = false;
upower_ = false;
devicekit = false;
user = false;
#endif
}
}
#endif //POWER_H
shutdown-qapps-1.7.4/qshutdown/src/about.h 0000664 0001750 0001750 00000002007 13477727501 017646 0 ustar chris chris /* qshutdown, a program to shutdown/reboot/suspend/hibernate the system
* Copyright (C) 2010-2019 Christian Metscher
* 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
* (at your option) 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 .
*/
#ifndef ABOUT_H
#define ABOUT_H
#include "ui_about.h"
#include
class About : public QDialog, public Ui::About {
Q_OBJECT
public:
About(QWidget *parent = 0);
~About();
private:
QIcon icon;
};
#endif //ABOUT_H
shutdown-qapps-1.7.4/qshutdown/src/calendar.h 0000664 0001750 0001750 00000005507 13477727513 020320 0 ustar chris chris /* qshutdown, a program to shutdown/reboot/suspend/hibernate the system
* Copyright (C) 2010-2019 Christian Metscher
* 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
* (at your option) 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 .
*/
#ifndef CALENDAR_H
#define CALENDAR_H
#include "ui_calendar.h"
#include
#include
#include "weekday.h"
#include "weekdayitem.h"
class Calendar : public QDialog, public Ui::Calendar {
Q_OBJECT
public:
Calendar(QWidget *parent = 0);
~Calendar();
bool timeRunning;
QDateTime setCalendarDate, calendarDate, setWeeklyDate;
bool getClosed();
WeekDay *mon, *tue, *wed, *thu, *fri,
*sat, *sun;
WeekDayItem *mon1, *mon2, *mon3, *mon4, *mon5,
*tue1, *tue2, *tue3, *tue4, *tue5,
*wed1, *wed2, *wed3, *wed4, *wed5,
*thu1, *thu2, *thu3, *thu4, *thu5,
*fri1, *fri2, *fri3, *fri4, *fri5,
*sat1, *sat2, *sat3, *sat4, *sat5,
*sun1, *sun2, *sun3, *sun4, *sun5;
private:
QVBoxLayout *scrollArea_layout;
bool isClosed;
QList *mondayItems;
QList *tuesdayItems;
QList *wednesdayItems;
QList *thursdayItems;
QList *fridayItems;
QList *saturdayItems;
QList *sundayItems;
QSettings *settings;
QString file;
private slots:
void getDate(QDate date);
void getSortedAndActivatedDays();
void getNearestTime(QList calculatedDay);
QList getSortedTimes();
void loadSettings();
void saveToConfFile();
void monday_addTimeEditAndActionBox(int i);
void tuesday_addTimeEditAndActionBox(int i);
void wednesday_addTimeEditAndActionBox(int i);
void thursday_addTimeEditAndActionBox(int i);
void friday_addTimeEditAndActionBox(int i);
void saturday_addTimeEditAndActionBox(int i);
void sunday_addTimeEditAndActionBox(int i);
public slots:
void setDate();
signals:
void aDateWasSet();
void starting();
void finishing();
protected:
virtual void showEvent(QShowEvent* show_calendar);
virtual void closeEvent(QCloseEvent* close_calendar);
};
#endif //CALENDAR_H
shutdown-qapps-1.7.4/qshutdown/src/preferences.h 0000664 0001750 0001750 00000004163 13477727611 021044 0 ustar chris chris /* qshutdown, a program to shutdown/reboot/suspend/hibernate the system
* Copyright (C) 2010-2019 Christian Metscher
* 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
* (at your option) 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 .
*/
#ifndef PREFERENCES_H
#define PREFERENCES_H
#include "ui_preferences.h"
#include
#include
class Preferences : public QDialog, public Ui::Preferences {
Q_OBJECT
public:
Preferences(QWidget *parent = 0);
~Preferences();
QString fonts;
QString myShutdown, myReboot, mySuspend, myHibernate;
QString userDef1S, userDef2S, userDef3S, userDef4S;
int fontS1, fontS2, fontS3;
bool getClosed();
bool lockMyScreen;
private:
bool isClosed;
QString file;
QSettings *settings;
QMessageBox *msgBox, *infoBox;
private slots:
void loadSettings();
void saveToConfFile();
void resetSettings();
void fontChanged(QString font);
void resetFont();
void fontSize1Changed(int f1);
void fontSize2Changed(int f2);
void fontSize3Changed(int f3);
void lockScreen();
void enableUserDef1();
void enableUserDef2();
void enableUserDef3();
void enableUserDef4();
void setFocusToUserDef();
public slots:
void autostartFile();
signals:
void starting();
void finishing();
void changeFont();
void editConf();
void removeTrayIcon(bool);
protected:
virtual void showEvent(QShowEvent* show_pref);
virtual void closeEvent(QCloseEvent* close_pref);
};
#endif //PREFERENCES_H
shutdown-qapps-1.7.4/qshutdown/src/pixmap/ 0000775 0001750 0001750 00000000000 13513631003 017640 5 ustar chris chris shutdown-qapps-1.7.4/qshutdown/src/pixmap/red_glasses.png 0000666 0001750 0001750 00000034617 13401523311 022654 0 ustar chris chris PNG
IHDR >a sRGB bKGD pHYs tIME +2 IDATxy$Uy{\yVVV]%j1H0ZՈ`Њ1a,Ʋb!@VH[h%U]WfVVޙ?==̬nIa}n/->=Rz QkX{5':}L}1 ,6Ԧg8ZOcg[@Q==8U\uEV.2ߊhE1n%_/oMl{+ԃ1IR0>@I6I@S9еR5,/^vvKy[o>