shutdown-qapps-1.7.3/ 0000775 0001750 0001750 00000000000 13036326541 013526 5 ustar chris chris shutdown-qapps-1.7.3/qshutdown/ 0000775 0001750 0001750 00000000000 13036324107 015556 5 ustar chris chris shutdown-qapps-1.7.3/qshutdown/qshutdown.qc 0000664 0001750 0001750 00000000113 12771720552 020143 0 ustar chris chris
qshutdown
qshutdown.pro
shutdown-qapps-1.7.3/qshutdown/NEWS 0000664 0001750 0001750 00000021337 13036324107 016263 0 ustar chris chris Changes in Release 1.7.3
=========================
- fixed bug for shutdown/reboot/suspend/hibernate settings caused by
previous update.
Changes in Release 1.7.2
=========================
- code optimations
- fixed small bugs in calendar and "weekly"
- added DBus Interface method for starting qshutdown from scripts or other
programs. (Looking for a way to restart countdown after sleep...)
Changes in Release 1.7.1
=========================
- fixed: "Weekly" not disabled eventhough the countdown is running.
- fixed: From time to time strage behaviour causing countdown to
abbort (issue with two different time types).
Changes in Release 1.7.0
=========================
- time is now displayed immediately when OK is pressed
- added new shutdown/reboot/suspend/hibernate command (possibly
working on most debian based systems, if supported/activated)
- code cleanup
- added weekly to the calendar
- fixed resizing problems in config menu
- fixed issues after manual/automatic standby mode (not caused by
qshutdown)
- added option to hide the system tray icon
- updated Galician, Ukrainian, Asturian, Malay
- added Russian
Changes in Release 1.6.8
=========================
- added systemctl command in "automatic" and "sudo"
- complete Turkish translation
- added Indonesian
- added Czech
Changes in Release 1.6.7
=========================
- updated Japanese translations
- fixed sudo shutdown command
- fixed bug relating to environment (#716194)
Changes in Release 1.6.6
=========================
- revisited power.h
- added welcome dialog with informations
Changes in Release 1.6.5
=========================
- minor fix for the preferences, the password and the about dialog
- reviewed shutdown commands
- new translations for: English (Australian), Galician, Croatian, Burmese,
Romanian
Changes in Release 1.6.4
=========================
- new (and bigger) qshutdown symbol
- many new translations
- fix for intern reset: now independent from QTimer
- fix for not keeping proportions at startup
- fix for discarding changes and passwords when escaping
preferences and password dialogs
- removed version text label from the main window
- added version text message to the statusbar
- simplified the creation of the config file
Changes in Release 1.6.3
=========================
- added advanced settings for specifying or choosing a shutdown/reboot/
suspend/hibernate command.
- added checkBox for qshutdown to quit after countdown ended
- added gnome-session-quit command
- changed config file format
- fix for enabling "hide qshudown at startup"
- save and ok of the editor now updates the preferences window's settings
Changes in Release 1.6.2
=========================
- replaced all qDebug(), qWarning() and qCritical()
- added "About Qt"
- reworked QSettings
- added hideEvent and showEvent because of minimize/restore Action of
the System Tray Icon
Changes in Release 1.6.1
=========================
- for first start fonts weren't correctly initialized -> fixed.
Changes in Release 1.6.0
=========================
- tool tips updated and new ones
- new design with more features
- added: "About"
- new warning method: System tray icon message.
- removed spacers and LCD from the source code
since it's more convenient to leave this to the ui.
- more precise display of the time displayed with the LCD
- removed most global variables and thus restructured many
functions and classes
- removed qApp-quit() from Gui::finished_() -> shutdown works again under
Ubuntu Natty and so on. Added Gui::saveLog() instead to resolve the
problem from version 1.5.2 (instead of the solution from version 1.5.3)
Changes in Release 1.5.6
=========================
- bugfix: minimize and restore button didn't work correctly on all systems.
- added: more information about hotkeys (removed old ones)
Changes in Release 1.5.5
=========================
- bugfix: autostart entry is written or deleted when confirming with OK.
(the function was called at the wrong place)
Changes in Release 1.5.4
=========================
- added: restore and minimize Button to the system tray icon
(also because the left click will not work with Unity on
Ubuntu).
Changes in Release 1.5.3
=========================
- fixed: No log entry for shutdown events (gui.cpp -> before_quit())
- fixed: When pressing Enter in the password prompt line Edit
the message box reappeared twice (passwd.cpp)
Changes in Release 1.5.2
=========================
- fixed timer problem (minor).
Changes in Release 1.5.1
=========================
- saving the edited configuration file will now
also update the preferences window.
- the editor got an additional button and won't quit
after saving, if Ok hasn't been clicked.
- the main window won't rise into the foreground if
the calendar, the password promt or the editor is
open.
- removed line for minimizing Window after OK has
been clicked.
Changes in Release 1.5.0
=========================
- added a password gui and editor to access
qshutdown.conf, removing a possible
security vulnerability (in "admin mode" only).
- added a button in preferences to
edit qshutdown.conf
- revised the way of how the autostart works and
added an option to the preferences.
Changes in Release 1.4.9
=========================
- fixed translation (de) for info box:
qshutdown_script.sh -> qshutdown_script
Changes in Release 1.4.8
=========================
Changes in Release 1.4.7
=========================
- fixed: missing line in power.cpp at hibernate()
- integrated dbus command for locking screen
Changes in Release 1.4.6
=========================
- simplified some calculations (gui.cpp)
- removed redundant funktion starter()
- added lock screen for suspend and hibernate
- added option to hide qshutdown at startup if
"Start countdown" is enabled.
Changes in Release 1.4.5
=========================
- new path for .qm translation files
- implemented UPower (for suspend and
hibernate)
- implemented shortcut Shift + E
to edit ~/.qshutdown/qshutdown.conf
with gksu(do)/kdesu(do)
- revised "admin mode" (Lock_all)
- made some code cleanups
Changes in Release 1.4.4
=========================
- fixed: if no date was set and
the clock turned 12:00 AM
qshutdown stopped working because
the date was intern set to the current
day.
- .ui files had wrong .qrc path (fixed)
Changes in Release 1.4.3
=========================
- new version control
- and some minor changes
Changes in Release 1.3.6
=========================
- fix for timeEdit
Changes in Release 1.3.4
=========================
- fix for toolButton
- bugfix for spinBox
Changes in Release 1.3.3
=========================
- new layout for preferences
Changes in Release 1.3.2
=========================
- fixed and modified many things
Changes in Release 1.3.1
=========================
- adjusted some things in the calendar widget
- corrected quite a lot things
- made some code cleanups
Changes in Release 1.3.0
=========================
- new features: added a calendar and
the changes of the font settings
take immediantly effect in the main window
Changes in Release 1.2.5
=========================
- bugfix: Programwindow didn't reappear
when starting twice
Changes in Release 1.2.4
=========================
- new feature: start countdown at startup
- scrollable area for preferences
Changes in Release 1.2.3
=========================
- bugfix for "Lock_all": timeEdit was
not disabled at startup.
- other minor changes related to Lock_all
- the size of the log file is now adjustable
Changes in Release 1.2.2
=========================
- "Reset settings" won't save changes
directly anymore. The settings will
be loaded by each showEvent.
Changes in Release 1.2.1
=========================
- bug fixed: window shifted down by
each show and hide event
Changes in Release 1.2.0
=========================
- improved tray-icon-contextmenu
- fixed shutdown/reboot/suspend/hibernate
functions
- replaced info message box
with a QPlainTextEdit Object
- added a combo box and shortcuts
- qshutdown now accepts arguments
- added a preferences dialog
Changes in Release 1.1.0
=========================
- added tray-icon-contextmenus for
shutdown/reboot/standby/hibernate
- pixmap now in .xpm format
- added DeviceKit in the shutdown
option
Changes in Release 1.0.2
=========================
- bugfix: if local time is not
continual and skips certain
seconds, qshutdown might have
not shutdown the system or
shown it self 3 times even if
there were less than 70
seconds left. *now fixed*
Changes in Release 1.0.1
=========================
- Initial Release
shutdown-qapps-1.7.3/qshutdown/README 0000664 0001750 0001750 00000005023 12771720552 016447 0 ustar chris chris qshutdown
INSTALL:
========
Dependencies: qtbase5-dev, qttools5-dev-tools, build-essential
If you want to install from source, open a terminal and change into this folder.
To install type:
qmake
sudo make install distclean
For admins:
You can enable "parental lock" for every user if you do the following:
sudo cp /usr/share/qshutdown/autostart/99qshutdown /etc/X11/Xsession.d/
now add the following line to the sudoers (for example with "EDITOR=nano sudo -E visudo"):
* ALL = NOPASSWD:/usr/bin/qshutdown
the * replaces the username or %groupname (Don't forget the % if it's a group).
And one more thing:
Edit the /root/.qshutdown/qshutdown.conf (after starting qshutdown once as root) and set
the option Lock_all to true.
If you should ever forget your set password, just remove the whole line
starting with "Password" manually from the qshutdown.conf.
UNINSTALL:
==========
To uninstall type:
qmake (if the Makefile has been removed)
sudo make deinstall
(note that ~/.qshutdown/qshutdown.conf and
~/.qshutdown/log.txt won't be removed)
KNOWN ISSUES:
=============
There is no system tray icon for qshutdown in Ubuntu 11.04.
SOLUTION: Type the following line in a terminal:
gsettings set com.canonical.Unity.Panel systray-whitelist "['all']"
In case you want to use the sudo shutdown command and you have set
the rights in the sudoers, but it still doesn't work, please specify
your own command in the preferences and try if "sudo shutdown -hP" now works.
For most systems using the Gnome Shell a certain DBus method has been removed,
thus a shutdown dialog will be likely to appear if qshutdown's methods have
been set to automatic or to Gnome session. If you do not want this
shutdown dialog to appear, please use ConsoleKit or something else.
HINTS ON USAGE:
===============
One can not close qshutdown, but only quit it using the sytem tray icon (indicator) or
the key combination Ctrl+Q (see shortcuts). If you want qshutdown to stop bugging you,
just remove the hook from warnings on?
HOTKEYS:
==========
Ctrl+I information window
Ctrl+Q Quit
Ctrl+P Prefereces
Ctrl+L write the run time once into the logfile (works only if qshutdown quits. To make it permanent set it in the preferences.)
Ctrl+S set to shutdown
Ctrl+R set to restart
Ctrl+U set to suspend to RAM
Ctrl+H set to hibernate
Ctrl+E stop timer (only if the countdown has started and the admin didn't restrict the access)
Shift+E to edit the config file (for this a password is necessary. If you are a user, you can set an "empty password" (leave the password field empty)).
shutdown-qapps-1.7.3/qshutdown/src/ 0000775 0001750 0001750 00000000000 13036323077 016352 5 ustar chris chris shutdown-qapps-1.7.3/qshutdown/src/weekdayitem.h 0000664 0001750 0001750 00000002257 13036323077 021041 0 ustar chris chris /* qshutdown, a program to shutdown/reboot/suspend/hibernate the system
* Copyright (C) 2010-2017 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 WEEKDAYITEM_H
#define WEEKDAYITEM_H
#include
#include
#include
#include
#include
class WeekDayItem : public QWidget{
Q_OBJECT
public:
WeekDayItem(QWidget *parent = 0);
~WeekDayItem();
QTimeEdit *timeEdit;
QComboBox *comboBox;
private:
QSpacerItem *h2;
QHBoxLayout *itemL;
};
#endif //WEEKDAYITEM_H
shutdown-qapps-1.7.3/qshutdown/src/preferences.cpp 0000664 0001750 0001750 00000036607 13036323060 021363 0 ustar chris chris /* qshutdown, a program to shutdown/reboot/suspend/hibernate the system
* Copyright (C) 2010-2017 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 "preferences.h"
#include
#include
#include
#include
#include
Preferences::Preferences(QWidget *parent): QDialog(parent){
setupUi(this);
isClosed = true;
setWindowFlags(Qt::Window);
//Seconds won't be recognized, thus removing them (just in case).
QString timeEditFormat;
timeEditFormat = timeEdit->displayFormat();
if(timeEditFormat.contains(":ss"))
timeEditFormat.replace(QString(":ss"), QString(""));
if(timeEditFormat.contains(":s"))
timeEditFormat.replace(QString(":s"), QString(""));
timeEdit->setDisplayFormat(timeEditFormat);
/***************** load settings from the conf file *****************/
#ifdef Q_OS_WIN32
lockS->setDisabled(true); //if there is a command for locking the display in Windows, remove this line
//and add the command to power.h
file = QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/qshutdown/qshutdown.conf";
#else //!Q_OS_WIN32
file = QDir::homePath() + "/.qshutdown/qshutdown.conf";
#endif //Q_OS_WIN32
settings = new QSettings(file, QSettings::IniFormat);
#ifdef Q_OS_WIN32
fonts = "Times New Roman";
fontS1 = 13;
fontS2 = 18;
fontS3 = 11;
#else
fonts = "DejaVu Sans";
fontS1 = 11;
fontS2 = 15;
fontS3 = 9;
#endif
userDef1S = tr("Please input an user specified command for shutdown here");
userDef2S = tr("Please input an user specified command for reboot here");
userDef3S = tr("Please input an user specified command for suspend here");
userDef4S = tr("Please input an user specified command for hibernate here");
msgBox = new QMessageBox(this);
msgBox->setWindowTitle(tr("Error"));
msgBox->setIcon(QMessageBox::Warning);
msgBox->setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Window);
msgBox->setInformativeText(tr("The File \"%1\" is not writable!\n"
"Maybe you just don't have the permissions to do so.").arg(file));
if(QSettings().value("first_start", true).toBool())
{
infoBox = new QMessageBox(this);
infoBox->setWindowTitle(tr("Please read this carefully!"));
infoBox->setIcon(QMessageBox::Information);
infoBox->setInformativeText(tr("Welcome to qshutdown!\n"
"If you want qshutdown e.g. to shutdown the system "
"and you are using the Gnome Shell, then you are likely to get a "
"shutdown dialog from there. If you want a direct shutdown, then "
"please consider going into the preferences and setting the shutdown "
"method to ConsoleKit or something else.\n\nPlease feel free to visit "
"https://launchpad.net/~hakaishi to report bugs or for anyting "
"concerning translations."));
infoBox->setStandardButtons(QMessageBox::Ok);
infoBox->show();
QSettings().setValue("first_start", false);
}
connect(this, SIGNAL(accepted()), this, SLOT(saveToConfFile()));
connect(reset, SIGNAL(clicked(bool)), this, SLOT(resetSettings()));
connect(font1Spin, SIGNAL(valueChanged(int)), this, SLOT(fontSize1Changed(int)));
connect(font2Spin, SIGNAL(valueChanged(int)), this, SLOT(fontSize2Changed(int)));
connect(font3Spin, SIGNAL(valueChanged(int)), this, SLOT(fontSize3Changed(int)));
connect(fontComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(fontChanged(QString)));
connect(confEditButton, SIGNAL(clicked(bool)), this, SIGNAL(editConf()));
connect(shutdownM, SIGNAL(currentIndexChanged(int)), this, SLOT(enableUserDef1()));
connect(rebootM, SIGNAL(currentIndexChanged(int)), this, SLOT(enableUserDef2()));
connect(suspendM, SIGNAL(currentIndexChanged(int)), this, SLOT(enableUserDef3()));
connect(hibernateM, SIGNAL(currentIndexChanged(int)), this, SLOT(enableUserDef4()));
connect(disableTray, SIGNAL(toggled(bool)), this, SIGNAL(removeTrayIcon(bool)));
loadSettings();
if(!QFile::exists(file))
saveToConfFile();
if(userDef1->isEnabled())
myShutdown = userDef1->toPlainText();
if(userDef2->isEnabled())
myReboot = userDef2->toPlainText();
if(userDef3->isEnabled())
mySuspend = userDef3->toPlainText();
if(userDef4->isEnabled())
myHibernate = userDef4->toPlainText();
}
Preferences::~Preferences(){ delete settings; }
void Preferences::showEvent(QShowEvent* show_pref){
isClosed = false;
starting(); //sends SIGNAL starting()
if(!settings->isWritable()){
QTimer::singleShot(15000, msgBox, SLOT(close()));
msgBox->show();
}
loadSettings();
QDialog::showEvent(show_pref);
}
void Preferences::setFocusToUserDef(){
if(userDef4->isEnabled())
userDef4->setFocus();
if(userDef3->isEnabled())
userDef3->setFocus();
if(userDef2->isEnabled())
userDef2->setFocus();
if(userDef1->isEnabled())
userDef1->setFocus();
}
void Preferences::enableUserDef1(){
if(shutdownM->currentIndex() == (shutdownM->count()-1)){
userDef1->setEnabled(true);
userDef1->setFocus();
if(userDef1->toPlainText() == userDef1S)
userDef1->clear();
}
else{
userDef1->setEnabled(false);
if(userDef1->toPlainText() == "")
userDef1->setPlainText(userDef1S);
setFocusToUserDef();
}
}
void Preferences::enableUserDef2(){
if(rebootM->currentIndex() == (rebootM->count()-1)){
userDef2->setEnabled(true);
userDef2->setFocus();
if(userDef2->toPlainText() == userDef2S)
userDef2->clear();
}
else{
userDef2->setEnabled(false);
if(userDef2->toPlainText() == "")
userDef2->setPlainText(userDef2S);
setFocusToUserDef();
}
}
void Preferences::enableUserDef3(){
if(suspendM->currentIndex() == (suspendM->count()-1)){
userDef3->setEnabled(true);
userDef3->setFocus();
if(userDef3->toPlainText() == userDef3S)
userDef3->clear();
}
else{
userDef3->setEnabled(false);
if(userDef3->toPlainText() == "")
userDef3->setPlainText(userDef3S);
setFocusToUserDef();
}
}
void Preferences::enableUserDef4(){
if(hibernateM->currentIndex() == (hibernateM->count()-1)){
userDef4->setEnabled(true);
userDef4->setFocus();
if(userDef4->toPlainText() == userDef4S)
userDef4->clear();
}
else{
userDef4->setEnabled(false);
if(userDef4->toPlainText() == "")
userDef4->setPlainText(userDef4S);
setFocusToUserDef();
}
}
void Preferences::loadSettings(){
if(settings->contains("PrefWindowSize/size"))
resize(settings->value("PrefWindowSize/size").toSize());
comboBox->setCurrentIndex(settings->value("Power/comboBox",0).toInt());
timeEdit->setTime(QTime(settings->value("Time/time_hour",22).toInt(),settings->value("Time/time_minute",00).toInt()));
spin->setValue(settings->value("Time/countdown_minutes",60).toInt());
quitOnCloseMain->setChecked(settings->value("Quit_on_close",false).toBool());
countdown->setChecked(settings->value("Time/countdown_at_startup",false).toBool());
hideMe->setChecked(settings->value("Hide_at_startup",false).toBool());
fontComboBox->setCurrentFont(settings->value("Fonts/font_type",fonts).toString());
font1Spin->setValue(settings->value("Fonts/font1",fontS1).toInt());
font2Spin->setValue(settings->value("Fonts/font2",fontS2).toInt());
font3Spin->setValue(settings->value("Fonts/font3",fontS3).toInt());
spinBox->setValue(settings->value("Logfile/size",1.5).toDouble());
disableTray->setChecked(settings->value("CheckBoxes/Disable_tray_icon", false).toBool());
radio1->setChecked(settings->value("CheckBoxes/target_time",false).toBool());
radio2->setChecked(settings->value("CheckBoxes/countdown",true).toBool());
lock->setChecked(settings->value("CheckBoxes/lock",true).toBool());
warn->setChecked(settings->value("CheckBoxes/warnings",true).toBool());
log->setChecked(settings->value("Logfile/logging",false).toBool());
lockS->setChecked(settings->value("Lock_screen",true).toBool());
autostart->setChecked(settings->value("Autostart").toBool());
shutdownM->setCurrentIndex(settings->value("Methods/shutdown",0).toInt());
userDef1->setPlainText(settings->value("Methods/myShutdown",userDef1S).toString());
rebootM->setCurrentIndex(settings->value("Methods/reboot",0).toInt());
userDef2->setPlainText(settings->value("Methods/myReboot",userDef2S).toString());
suspendM->setCurrentIndex(settings->value("Methods/suspend",0).toInt());
userDef3->setPlainText(settings->value("Methods/mySuspend",userDef3S).toString());
hibernateM->setCurrentIndex(settings->value("Methods/hibernate",0).toInt());
userDef4->setPlainText(settings->value("Methods/myHibernate",userDef4S).toString());
lockMyScreen = settings->value("Lock_screen").toBool();
quitAfterCountdown->setChecked(settings->value("Quit_after_countdown_ended",false).toBool());
}
void Preferences::saveToConfFile(){
if(settings->isWritable()){
settings->setValue("Power/comboBox",comboBox->currentIndex());
settings->setValue("Time/time_hour",timeEdit->time().hour());
settings->setValue("Time/time_minute",timeEdit->time().minute());
settings->setValue("Quit_on_close",quitOnCloseMain->isChecked());
settings->setValue("Time/countdown_at_startup",countdown->isChecked());
settings->setValue("Hide_at_startup",hideMe->isChecked());
settings->setValue("Time/countdown_minutes",spin->value());
settings->setValue("Fonts/font_type",fontComboBox->currentText());
settings->setValue("Fonts/font1",font1Spin->value());
settings->setValue("Fonts/font2",font2Spin->value());
settings->setValue("Fonts/font3",font3Spin->value());
settings->setValue("Logfile/size",spinBox->value());
settings->setValue("CheckBoxes/Disable_tray_icon",disableTray->isChecked());
settings->setValue("CheckBoxes/target_time",radio1->isChecked());
settings->setValue("CheckBoxes/countdown",radio2->isChecked());
settings->setValue("CheckBoxes/lock",lock->isChecked());
settings->setValue("CheckBoxes/warnings",warn->isChecked());
settings->setValue("Logfile/logging",log->isChecked());
settings->setValue("Lock_screen",lockS->isChecked());
settings->setValue("Autostart",autostart->isChecked());
settings->setValue("Methods/shutdown",shutdownM->currentIndex());
settings->setValue("Methods/myShutdown",userDef1->toPlainText());
settings->setValue("Methods/reboot",rebootM->currentIndex());
settings->setValue("Methods/myReboot",userDef2->toPlainText());
settings->setValue("Methods/suspend",suspendM->currentIndex());
settings->setValue("Methods/mySuspend",userDef3->toPlainText());
settings->setValue("Methods/hibernate",hibernateM->currentIndex());
settings->setValue("Methods/myHibernate",userDef4->toPlainText());
settings->setValue("Quit_after_countdown_ended",quitAfterCountdown->isChecked());
}
autostartFile(); //to create or to delete the autostart file
lockScreen(); //set lockMyScreen to true or false according to lockS
if(userDef1->isEnabled())
myShutdown = userDef1->toPlainText();
else myShutdown = "";
if(userDef2->isEnabled())
myReboot = userDef2->toPlainText();
else myReboot = "";
if(userDef3->isEnabled())
mySuspend = userDef3->toPlainText();
else mySuspend = "";
if(userDef4->isEnabled())
myHibernate = userDef4->toPlainText();
else mySuspend = "";
this->close();
}
void Preferences::resetSettings(){
if(settings->isWritable()){
comboBox->setCurrentIndex(0);
timeEdit->setTime(QTime(22,00));
countdown->setChecked(false);
disableTray->setChecked(false);
quitOnCloseMain->setChecked(false);
hideMe->setChecked(false);
spin->setValue(60);
fontComboBox->setCurrentFont(QFont(fonts));
font1Spin->setValue(fontS1);
font2Spin->setValue(fontS2);
font3Spin->setValue(fontS3);
spinBox->setValue(1.5);
radio1->setChecked(false);
radio2->setChecked(true);
lock->setChecked(true);
warn->setChecked(true);
log->setChecked(false);
lockS->setChecked(true);
shutdownM->setCurrentIndex(0);
rebootM->setCurrentIndex(0);
suspendM->setCurrentIndex(0);
hibernateM->setCurrentIndex(0);
userDef1->setPlainText(userDef1S);
userDef2->setPlainText(userDef2S);
userDef3->setPlainText(userDef3S);
userDef4->setPlainText(userDef4S);
quitAfterCountdown->setChecked(false);
}
}
void Preferences::closeEvent(QCloseEvent* close_pref){
isClosed = true;
finishing(); //sends SIGNAL finishing()
if(settings->isWritable())
settings->setValue("PrefWindowSize/size",size());
resetFont();
QDialog::closeEvent(close_pref);
}
bool Preferences::getClosed(){ return isClosed; }
void Preferences::fontChanged(QString font){ fonts = font; changeFont(); }
void Preferences::fontSize1Changed(int f1){ fontS1 = f1; changeFont(); }
void Preferences::fontSize2Changed(int f2){ fontS2 = f2; changeFont(); }
void Preferences::fontSize3Changed(int f3){ fontS3 = f3; changeFont(); }
void Preferences::resetFont(){
fonts = settings->value("Fonts/font_type","Times New Roman").toString();
fontS1 = settings->value("Fonts/font1",13).toInt();
fontS2 = settings->value("Fonts/font2",18).toInt();
fontS3 = settings->value("Fonts/font3",11).toInt();
changeFont();
}
void Preferences::autostartFile(){
#ifndef Q_OS_WIN32
QFile autostartFile(QDir::homePath() + "/.config/autostart/qshutdown.desktop");
if(settings->value("Autostart").toBool() && !autostartFile.exists()){
if(!QDir(QDir::homePath() + "/.config/autostart").exists()){
QDir dir(QDir::homePath() + "/.config/autostart");
dir.mkdir(QDir::homePath() + "/.config/autostart");
}
if(!autostartFile.open(QIODevice::ReadWrite | QIODevice::Text)){
QTextStream myOutput(stdout);
myOutput << "E: Can not open qshutdown.conf!" << endl;
return;
}
QString autostartContent("[Desktop Entry]\nName=qshutdown\n"
"Name[de_DE]=qshutdown\nExec=qshutdown\nTerminal=false\n"
"Type=Application\nIcon=red_glasses\nCategories=Utility");
QTextStream out(&autostartFile);
out << autostartContent;
autostartFile.close();
}
if(autostartFile.exists() && !settings->value("Autostart").toBool())
autostartFile.remove();
#endif
}
void Preferences::lockScreen(){ lockMyScreen = lockS->isChecked(); }
shutdown-qapps-1.7.3/qshutdown/src/weekday.cpp 0000664 0001750 0001750 00000002415 13036323065 020506 0 ustar chris chris /* qshutdown, a program to shutdown/reboot/suspend/hibernate the system
* Copyright (C) 2010-2017 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 "weekday.h"
WeekDay::WeekDay(QWidget *parent) : QFrame(parent){
this->setFrameShape(QFrame::Panel);
this->setFrameShadow(QFrame::Raised);
dayL = new QHBoxLayout(this);
dayL->setContentsMargins(0,0,0,0);
label = new QLabel(this);
h = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
spin = new QSpinBox(this);
spin->setRange(0,5);
dayL->addWidget(label);
dayL->addItem(h);
dayL->addWidget(spin);
}
WeekDay::~WeekDay(){;}
shutdown-qapps-1.7.3/qshutdown/src/power.h 0000664 0001750 0001750 00000056172 13036323055 017666 0 ustar chris chris /* qshutdown, a program to shutdown the shutdown/reboot/suspend/hibernate
* Copyright (C) 2010-2017 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.3/qshutdown/src/editor.h 0000664 0001750 0001750 00000002712 13036323020 017777 0 ustar chris chris /* qshutdown, a program to shutdown/reboot/suspend/hibernate the system
* Copyright (C) 2010-2017 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 EDITOR_H
#define EDITOR_H
#include "ui_editor.h"
#include
#include
class Editor : public QDialog, public Ui::Editor {
Q_OBJECT
public:
Editor(QWidget *parent = 0);
~Editor();
bool getClosed();
signals:
void saved();
void starting();
void finishing();
private:
QFile *confFile;
QSettings *settings;
bool isClosed;
private slots:
void saveChanges();
public slots:
bool getLockAll();
protected:
virtual void showEvent(QShowEvent* show_editor);
virtual void closeEvent(QCloseEvent* close_editor);
void keyPressEvent(QKeyEvent* kEvent);
};
#endif //EDITOR_H
shutdown-qapps-1.7.3/qshutdown/src/ch_passwd.cpp 0000664 0001750 0001750 00000006132 13036322767 021040 0 ustar chris chris /* qshutdown, a program to shutdown/reboot/suspend/hibernate the system
* Copyright (C) 2010-2017 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 "ch_passwd.h"
#include
#include
#include
ChangePassword::ChangePassword(QWidget *parent): QDialog(parent){
setupUi(this);
setWindowFlags(Qt::Window); //always in front
#ifdef Q_OS_WIN32
file = QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/qshutdown/qshutdown.conf";
#else //!Q_OS_WIN32
file = QDir::homePath() + "/.qshutdown/qshutdown.conf";
#endif //Q_OS_WIN32
settings = new QSettings(file, QSettings::IniFormat);
if(settings->contains("Password")){
oldPasswd->setEnabled(true);
oldL->setEnabled(true);
}
msgBox1 = new QMessageBox(this);
msgBox1->setWindowTitle("Error");
msgBox1->setIcon(QMessageBox::Warning);
msgBox1->setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Window);
msgBox1->setInformativeText(tr("The current password is not correct!"));
msgBox2 = new QMessageBox(this);
msgBox2->setWindowTitle("Error");
msgBox2->setIcon(QMessageBox::Warning);
msgBox2->setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Window);
msgBox2->setInformativeText(tr("The retyped password doesn't match!"));
connect(buttonBox, SIGNAL(accepted()), this, SLOT(checkOldPW()));
}
ChangePassword::~ChangePassword(){ delete settings; }
void ChangePassword::checkOldPW(){
if(settings->contains("Password")){
if(settings->value("Password").toByteArray() ==
QCryptographicHash::hash(oldPasswd->text().toUtf8(), QCryptographicHash::Sha1))
checkNewPW();
else
msgBox1->exec();
}
else
checkNewPW();
}
void ChangePassword::checkNewPW(){
if(newPasswd->text() == retypedNewPasswd->text()){
savePW();
accept();
}
else
msgBox2->exec();
}
void ChangePassword::savePW(){
settings->setValue("Password", QCryptographicHash::hash(retypedNewPasswd->text().toUtf8(),
QCryptographicHash::Sha1));
updatePasswordGui();
if(settings->contains("Password")){
oldPasswd->setEnabled(true);
oldL->setEnabled(true);
}
oldPasswd->clear();
newPasswd->clear();
retypedNewPasswd->clear();
}
void ChangePassword::closeEvent(QCloseEvent* close_ch_pw){
oldPasswd->clear();
newPasswd->clear();
retypedNewPasswd->clear();
QDialog::closeEvent(close_ch_pw);
}
shutdown-qapps-1.7.3/qshutdown/src/weekdayitem.cpp 0000664 0001750 0001750 00000003560 13036323072 021365 0 ustar chris chris /* qshutdown, a program to shutdown/reboot/suspend/hibernate the system
* Copyright (C) 2010-2017 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.3/qshutdown/src/preferences.h 0000664 0001750 0001750 00000004163 13036323062 021022 0 ustar chris chris /* qshutdown, a program to shutdown/reboot/suspend/hibernate the system
* Copyright (C) 2010-2017 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.3/qshutdown/src/pixmap/ 0000775 0001750 0001750 00000000000 12771720552 017654 5 ustar chris chris shutdown-qapps-1.7.3/qshutdown/src/pixmap/red_glasses.png 0000664 0001750 0001750 00000034617 12771720552 022670 0 ustar chris chris ‰PNG
IHDR € € Ã>aË sRGB ®Îé bKGD ÿ ÿ ÿ ½§“ pHYs šœ tIMEÜ +Øã2 IDATxÚí½y$ùUçùy¿Ÿ{\yVVVÖÑ÷]¾»%j1HÍ0³ºZ¢Õˆ…µÉ`Њ1ÃÄaÀÎƒÍØ,³Æ²b€!@¢Õ¬VHˆ[Òh…º%µÔÝÕU]WfVVÞ™áî¿ßÛ?Ü=Â=®Ì¬ÊnIÐaæ‘þ}ïûÎßûÁ·n/ÜþáÞäïëûþ-ß>=ÎÿRãz ï»óQúØköX{Ûô5‰ƒí'––ùíúþìø:½}òÿàŸÎLò}µ1® ,6°Ô¦g8Z¨Ocgì¸Ô[À@’¾Q=à»÷éÿ=š8UÑ\—åu‚ÅEV–.2ߊhE1n³ÅÉÅ%Þý¶_ã£/À×àöÄoM½úðlû{ÇÆã+Ôƒññ«˜¨Í1˜Iƒ©Rã0>Ðö@I6 Iø¢@àS9Ñ´—е¸¤©¾ÙRã—ýÅ5õ‹‹,/^àôv›æv›ÓKyÏ[ÿo>ü‚