mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-12 16:23:07 -07:00
FEATURE: Added Auto-Shutdown on downloads completion feature (Linux Only for now)
This commit is contained in:
parent
0af44eadb6
commit
df677789d2
10 changed files with 74 additions and 1 deletions
14
src/misc.cpp
14
src/misc.cpp
|
@ -67,6 +67,11 @@ const int UNLEN = 256;
|
|||
#include <winbase.h>
|
||||
#endif
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusMessage>
|
||||
#endif
|
||||
|
||||
QString misc::QDesktopServicesDataLocation() {
|
||||
#ifdef Q_WS_WIN
|
||||
LPWSTR path=new WCHAR[256];
|
||||
|
@ -184,6 +189,15 @@ long long misc::freeDiskSpaceOnPath(QString path) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void misc::shutdownComputer() {
|
||||
#ifdef Q_WS_X11
|
||||
// Use dbus to power off the system
|
||||
// dbus-send --print-reply --system --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown
|
||||
QDBusInterface computer("org.freedesktop.Hal", "/org/freedesktop/Hal/devices/computer", "org.freedesktop.Hal.Device.SystemPowerManagement", QDBusConnection::systemBus());
|
||||
computer.call("Shutdown");
|
||||
#endif
|
||||
}
|
||||
|
||||
QString misc::truncateRootFolder(boost::intrusive_ptr<torrent_info> t) {
|
||||
if(t->num_files() == 1) {
|
||||
// Single file torrent
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue