change: change code style to Linux style except indent.

This commit is contained in:
Mike Solar
2025-08-03 03:09:40 +08:00
parent 65ab76edc8
commit 74f73ab3be
789 changed files with 77113 additions and 68888 deletions
+48 -41
View File
@@ -10,7 +10,8 @@
#include <QtDBus/QtDBus>
#endif
namespace olive {
namespace olive
{
#if defined(Q_OS_MAC)
IOPMAssertionID assertionID = 0;
@@ -21,53 +22,59 @@ IOPMAssertionID assertionID = 0;
void PreventSleep(bool on)
{
#if defined(Q_OS_WINDOWS)
SetThreadExecutionState(on ? ES_DISPLAY_REQUIRED | ES_CONTINUOUS : ES_CONTINUOUS);
SetThreadExecutionState(on ? ES_DISPLAY_REQUIRED | ES_CONTINUOUS :
ES_CONTINUOUS);
#elif defined(Q_OS_MAC)
if (on) {
static const CFStringRef reasonForActivity = CFSTR("Video Playback");
if (on) {
static const CFStringRef reasonForActivity = CFSTR("Video Playback");
IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep,
kIOPMAssertionLevelOn, reasonForActivity, &assertionID);
} else if (assertionID) {
IOPMAssertionRelease(assertionID);
assertionID = 0;
}
IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep,
kIOPMAssertionLevelOn, reasonForActivity,
&assertionID);
} else if (assertionID) {
IOPMAssertionRelease(assertionID);
assertionID = 0;
}
#elif defined(Q_OS_LINUX)
QDBusConnection bus = QDBusConnection::sessionBus();
if(bus.isConnected()) {
static const QStringList sleep_services = {
QStringLiteral("org.freedesktop.ScreenSaver"),
//QStringLiteral("org.gnome.SessionManager")
};
static const QStringList sleep_paths = {
QStringLiteral("/org/freedesktop/ScreenSaver"),
//QStringLiteral("/org/gnome/SessionManager")
};
static QVector<uint> sleep_cookies;
QDBusConnection bus = QDBusConnection::sessionBus();
if (bus.isConnected()) {
static const QStringList sleep_services = {
QStringLiteral("org.freedesktop.ScreenSaver"),
//QStringLiteral("org.gnome.SessionManager")
};
static const QStringList sleep_paths = {
QStringLiteral("/org/freedesktop/ScreenSaver"),
//QStringLiteral("/org/gnome/SessionManager")
};
static QVector<uint> sleep_cookies;
// Initialize vector to 0
if (sleep_cookies.isEmpty()) {
sleep_cookies.resize(sleep_services.size());
sleep_cookies.fill(0);
}
// Initialize vector to 0
if (sleep_cookies.isEmpty()) {
sleep_cookies.resize(sleep_services.size());
sleep_cookies.fill(0);
}
for (int i=0; i<sleep_cookies.size(); i++) {
QDBusInterface interface(sleep_services.at(i), sleep_paths.at(i), sleep_services.at(i), bus);
if (interface.isValid()) {
QDBusReply<uint> reply;
for (int i = 0; i < sleep_cookies.size(); i++) {
QDBusInterface interface(sleep_services.at(i), sleep_paths.at(i),
sleep_services.at(i), bus);
if (interface.isValid()) {
QDBusReply<uint> reply;
if (on) {
reply = interface.call(QStringLiteral("Inhibit"), QStringLiteral("Olive Video Editor"), QStringLiteral("Video Playback"));
} else {
reply = interface.call(QStringLiteral("UnInhibit"), sleep_cookies.at(i));
}
if (on) {
reply = interface.call(QStringLiteral("Inhibit"),
QStringLiteral("Olive Video Editor"),
QStringLiteral("Video Playback"));
} else {
reply = interface.call(QStringLiteral("UnInhibit"),
sleep_cookies.at(i));
}
if (reply.isValid()) {
sleep_cookies[i] = reply.value();
}
}
}
}
if (reply.isValid()) {
sleep_cookies[i] = reply.value();
}
}
}
}
#endif
}