-
-
Notifications
You must be signed in to change notification settings - Fork 343
Expand file tree
/
Copy pathPostCompressionActions.cpp
More file actions
68 lines (59 loc) · 1.6 KB
/
PostCompressionActions.cpp
File metadata and controls
68 lines (59 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "PostCompressionActions.h"
#include <QProcess>
void PostCompressionActions::runAction(PostCompressionAction action)
{
switch (action) {
case PostCompressionAction::CLOSE_APPLICATION:
closeApplication();
break;
case PostCompressionAction::SHUTDOWN:
shutdownMachine();
break;
case PostCompressionAction::SLEEP:
putMachineToSleep();
break;
default:
case PostCompressionAction::OPEN_FOLDER:
case PostCompressionAction::NO_ACTION:
break;
}
}
void PostCompressionActions::runAction(PostCompressionAction action, const QString& folder)
{
switch (action) {
case PostCompressionAction::OPEN_FOLDER:
openOutputFolder(folder);
break;
default:
return runAction(action);
}
}
void PostCompressionActions::closeApplication()
{
QCoreApplication::quit();
}
void PostCompressionActions::shutdownMachine()
{
#ifdef Q_OS_WIN
QProcess::startDetached("shutdown", QStringList() << "/s");
#endif
#if defined(Q_OS_MAC) || defined(Q_OS_LINUX)
QProcess::startDetached("shutdown", QStringList() << "-h" << "now");
#endif
}
void PostCompressionActions::putMachineToSleep()
{
#ifdef Q_OS_WIN
QProcess::startDetached("rundll32.exe", QStringList() << "powrprof.dll,SetSuspendState" << "0,1,0");
#endif
#ifdef Q_OS_MAC
QProcess::startDetached("pmset", QStringList() << "sleepnow");
#endif
#ifdef Q_OS_LINUX
QProcess::startDetached("systemctl", QStringList() << "suspend");
#endif
}
void PostCompressionActions::openOutputFolder(const QString& folder)
{
showDirectoryInNativeFileManager(folder);
}