Skip to content

Commit

Permalink
use HDR.h instead of HDRCmd executable
Browse files Browse the repository at this point in the history
  • Loading branch information
Odizinne committed Nov 13, 2024
1 parent f7707d1 commit 9ac236b
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 37 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "Dependencies/HDRtray"]
path = Dependencies/HDRtray
url = https://github.com/res2k/HDRTray.git
21 changes: 10 additions & 11 deletions BigPictureTV.pro
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++17 silent lrelease embed_translations

QM_FILES_RESOURCE_PREFIX = /translations
DEPS_DIR = $$PWD/Dependencies
BUILD_DIR = $$OUT_PWD

INCLUDEPATH += \
AudioManager \
BigPictureTV \
Configurator \
NightLightSwitcher \
ShortcutManager \
SteamWindowManager \
Utils \
AudioManager/ \
BigPictureTV/ \
Configurator/ \
NightLightSwitcher/ \
ShortcutManager/ \
SteamWindowManager/ \
Utils/ \
Dependencies/HDRtray/common/ \

SOURCES += \
AudioManager/AudioManager.cpp \
Expand All @@ -26,6 +25,7 @@ SOURCES += \
SteamWindowManager/SteamwindowManager.cpp \
Utils/Utils.cpp \
main.cpp \
Dependencies/HDRtray/common/hdr.cpp \

HEADERS += \
AudioManager/AudioManager.h \
Expand All @@ -36,6 +36,7 @@ HEADERS += \
ShortcutManager/ShortcutManager.h \
SteamWindowManager/SteamwindowManager.h \
Utils/Utils.h \
Dependencies/HDRtray/common/hdr.h \

FORMS += \
Configurator/Configurator.ui \
Expand All @@ -50,5 +51,3 @@ RESOURCES += \
RC_FILE = Resources/appicon.rc

LIBS += -lole32 -luser32 -ladvapi32 -lshell32

QMAKE_POST_LINK = powershell -Command "Copy-Item -Path '$$DEPS_DIR' -Recurse -Destination '$$BUILD_DIR/release'"
4 changes: 2 additions & 2 deletions BigPictureTV/BigPictureTV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ void BigPictureTV::checkAndSetHDR(bool isDesktopMode)
return;
}

QString command = isDesktopMode ? "off" : "on";
bool enable = isDesktopMode ? false : true;
if (Utils::getHDRStatus() != 2) {
Utils::setHDR(command);
Utils::setHDR(enable);
}
}

Expand Down
Binary file removed Dependencies/HDRCmd.exe
Binary file not shown.
1 change: 1 addition & 0 deletions Dependencies/HDRtray
Submodule HDRtray added at c9b477
35 changes: 12 additions & 23 deletions Utils/Utils.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "Utils.h"
#include "HDR.h"
#include <QTranslator>
#include <QApplication>
#include <QScreen>
Expand Down Expand Up @@ -212,31 +213,19 @@ bool Utils::isWindows10()

int Utils::getHDRStatus()
{
QString program = QCoreApplication::applicationDirPath() + "/Dependencies/HDRCmd.exe";
QStringList arguments;
arguments << "status" << "-m" << "exitcode";
QProcess process;
process.start(program, arguments);

if (!process.waitForFinished()) {
qDebug() << "Process failed to finish";
return -1;
hdr::Status hdrStatus = hdr::GetWindowsHDRStatus();
if (hdrStatus == hdr::Status::On) {
return 0; // Enabled
} else if (hdrStatus == hdr::Status::Off) {
return 1; // Disabled
} else if (hdrStatus == hdr::Status::Unsupported) {
return 2; // Unsuported
} else {
return 2; // Error, so unsupported
}

int exitCode = process.exitCode();
return exitCode;
}

void Utils::setHDR(QString mode)
void Utils::setHDR(bool enable)
{
QString program = QCoreApplication::applicationDirPath() + "/Dependencies/HDRCmd.exe";
QStringList arguments;
arguments << mode;
QProcess process;
process.start(program, arguments);

if (!process.waitForFinished()) {
qDebug() << "Process failed to finish";
return;
}
hdr::SetWindowsHDRStatus(enable);
}
2 changes: 1 addition & 1 deletion Utils/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Utils {
void skipBigPictureIntro();
bool isWindows10();
int getHDRStatus();
void setHDR(QString mode);
void setHDR(bool enable);
}

#endif // UTILS_H

0 comments on commit 9ac236b

Please sign in to comment.