Skip to content

Commit

Permalink
Added EnhancedDisplaySwitch for screen management
Browse files Browse the repository at this point in the history
  • Loading branch information
Odizinne committed Aug 18, 2024
1 parent a48c7b1 commit 9d765f5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 44 deletions.
5 changes: 5 additions & 0 deletions BigPictureTV.pro
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ RC_FILE = src/Resources/appicon.rc

LIBS += -lole32 -luser32 -ladvapi32 -lshell32

DEPENDENCIES_DIR = $$PWD/dependencies
DEST_DIR = $$OUT_PWD/release/dependencies

QMAKE_POST_LINK += powershell -Command "New-Item -ItemType Directory -Path '$$DEST_DIR' -Force; Copy-Item -Path '$$DEPENDENCIES_DIR\*' -Destination '$$DEST_DIR' -Recurse -Force"

# Default rules for deployment
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
Expand Down
Binary file added dependencies/EnhancedDisplaySwitch.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion src/BigPictureTV/bigpicturetv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ void BigPictureTV::handleMonitorChanges(bool isDesktopMode, bool disableVideo)
}

if (command) {
runDisplayswitch(command);
runEnhancedDisplayswitch(command);
}
}

Expand Down
46 changes: 4 additions & 42 deletions src/Utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,21 @@
#include <QSettings>
#include <QStandardPaths>
#include <QTextStream>

#include <QCoreApplication>
#include <QFileInfo>

const QString DISCORD_EXECUTABLE_NAME = "Update.exe";
const QString DISCORD_PROCESS_NAME = "Discord.exe";
const QString DISPLAYSWITCH_HISTORY_PATH = QStandardPaths::writableLocation(
QStandardPaths::AppDataLocation)
+ "/displayswitch_history";
const QString SUNSHINE_STATUS_FILE = QStandardPaths::writableLocation(
QStandardPaths::AppDataLocation)
+ "/sunshine-status/status.txt";

void runDisplayswitch(const QString &command)
void runEnhancedDisplayswitch(const QString &command)
{
QProcess process;
process.start("displayswitch.exe", QStringList() << command);
process.waitForFinished(); // Wait for the process to finish

QString commandToStore = command.startsWith('/') ? command.mid(1) : command;

QDir dir(DISPLAYSWITCH_HISTORY_PATH);
if (!dir.exists()) {
dir.mkpath(".");
}

QFile file(DISPLAYSWITCH_HISTORY_PATH + "/displayswitch.txt");
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
return;
}

QTextStream out(&file);
out << commandToStore;
file.close();
QString executablePath = "dependencies/EnhancedDisplaySwitch.exe";
process.start(executablePath, QStringList() << command);
process.waitForFinished();
}

QString getTheme()
Expand Down Expand Up @@ -74,25 +55,6 @@ QString getActivePowerPlan()

void setPowerPlan(QString planGuid)
{
//QString planGuid;

//switch (planIndex) {
//case 1:
// // Performance
// planGuid = "8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c";
// break;
//case 2:
// // Balanced
// planGuid = "381b4222-f694-41f0-9685-ff5bb260df2e";
// break;
//case 3:
// // Energy Saving
// planGuid = "a1841308-3541-4fab-bc81-f71556f20b4a";
// break;
//default:
// return;
//}

QString command = "powercfg";
QStringList arguments;
arguments << "/s" << planGuid;
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <QIcon>
#include <QString>

void runDisplayswitch(const QString &command);
void runEnhancedDisplayswitch(const QString &command);
QString getTheme();
QIcon getIconForTheme();
QString getActivePowerPlan();
Expand Down

0 comments on commit 9d765f5

Please sign in to comment.