@ -92,16 +92,16 @@ static struct { const char *source; const char *comment; } units[] = {
} ;
} ;
# ifndef DISABLE_GUI
# ifndef DISABLE_GUI
void Utils : : Misc : : shutdownComputer ( ShutdownAction action )
void Utils : : Misc : : shutdownComputer ( const ShutdownDialog Action & action )
{
{
# if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB)
# if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB)
// Use dbus to power off / suspend the system
// Use dbus to power off / suspend the system
if ( action ! = ShutdownAction : : Shutdown ) {
if ( action ! = ShutdownDialog Action : : Shutdown ) {
// Some recent systems use systemd's logind
// Some recent systems use systemd's logind
QDBusInterface login1Iface ( " org.freedesktop.login1 " , " /org/freedesktop/login1 " ,
QDBusInterface login1Iface ( " org.freedesktop.login1 " , " /org/freedesktop/login1 " ,
" org.freedesktop.login1.Manager " , QDBusConnection : : systemBus ( ) ) ;
" org.freedesktop.login1.Manager " , QDBusConnection : : systemBus ( ) ) ;
if ( login1Iface . isValid ( ) ) {
if ( login1Iface . isValid ( ) ) {
if ( action = = ShutdownAction : : Suspend )
if ( action = = ShutdownDialog Action : : Suspend )
login1Iface . call ( " Suspend " , false ) ;
login1Iface . call ( " Suspend " , false ) ;
else
else
login1Iface . call ( " Hibernate " , false ) ;
login1Iface . call ( " Hibernate " , false ) ;
@ -111,7 +111,7 @@ void Utils::Misc::shutdownComputer(ShutdownAction action)
QDBusInterface upowerIface ( " org.freedesktop.UPower " , " /org/freedesktop/UPower " ,
QDBusInterface upowerIface ( " org.freedesktop.UPower " , " /org/freedesktop/UPower " ,
" org.freedesktop.UPower " , QDBusConnection : : systemBus ( ) ) ;
" org.freedesktop.UPower " , QDBusConnection : : systemBus ( ) ) ;
if ( upowerIface . isValid ( ) ) {
if ( upowerIface . isValid ( ) ) {
if ( action = = ShutdownAction : : Suspend )
if ( action = = ShutdownDialog Action : : Suspend )
upowerIface . call ( " Suspend " ) ;
upowerIface . call ( " Suspend " ) ;
else
else
upowerIface . call ( " Hibernate " ) ;
upowerIface . call ( " Hibernate " ) ;
@ -121,7 +121,7 @@ void Utils::Misc::shutdownComputer(ShutdownAction action)
QDBusInterface halIface ( " org.freedesktop.Hal " , " /org/freedesktop/Hal/devices/computer " ,
QDBusInterface halIface ( " org.freedesktop.Hal " , " /org/freedesktop/Hal/devices/computer " ,
" org.freedesktop.Hal.Device.SystemPowerManagement " ,
" org.freedesktop.Hal.Device.SystemPowerManagement " ,
QDBusConnection : : systemBus ( ) ) ;
QDBusConnection : : systemBus ( ) ) ;
if ( action = = ShutdownAction : : Suspend )
if ( action = = ShutdownDialog Action : : Suspend )
halIface . call ( " Suspend " , 5 ) ;
halIface . call ( " Suspend " , 5 ) ;
else
else
halIface . call ( " Hibernate " ) ;
halIface . call ( " Hibernate " ) ;
@ -150,7 +150,7 @@ void Utils::Misc::shutdownComputer(ShutdownAction action)
# endif
# endif
# ifdef Q_OS_MAC
# ifdef Q_OS_MAC
AEEventID EventToSend ;
AEEventID EventToSend ;
if ( action ! = ShutdownAction : : Shutdown )
if ( action ! = ShutdownDialog Action : : Shutdown )
EventToSend = kAESleep ;
EventToSend = kAESleep ;
else
else
EventToSend = kAEShutDown ;
EventToSend = kAEShutDown ;
@ -203,9 +203,9 @@ void Utils::Misc::shutdownComputer(ShutdownAction action)
if ( GetLastError ( ) ! = ERROR_SUCCESS )
if ( GetLastError ( ) ! = ERROR_SUCCESS )
return ;
return ;
if ( action = = ShutdownAction : : Suspend )
if ( action = = ShutdownDialog Action : : Suspend )
SetSuspendState ( false , false , false ) ;
SetSuspendState ( false , false , false ) ;
else if ( action = = ShutdownAction : : Hibernate )
else if ( action = = ShutdownDialog Action : : Hibernate )
SetSuspendState ( true , false , false ) ;
SetSuspendState ( true , false , false ) ;
else
else
InitiateSystemShutdownA ( 0 , QCoreApplication : : translate ( " misc " , " qBittorrent will shutdown the computer now because all downloads are complete. " ) . toLocal8Bit ( ) . data ( ) , 10 , true , false ) ;
InitiateSystemShutdownA ( 0 , QCoreApplication : : translate ( " misc " , " qBittorrent will shutdown the computer now because all downloads are complete. " ) . toLocal8Bit ( ) . data ( ) , 10 , true , false ) ;