1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-20 11:47:46 +00:00

Add a utility function to check the SteamDeck environment variable

This commit is contained in:
Joshua Goins 2024-08-04 22:48:02 -04:00
parent d3478b6133
commit 36c06eed8b
5 changed files with 23 additions and 10 deletions

View file

@ -52,6 +52,18 @@ private Q_SLOTS:
Utility::writeVersion(verFile.fileName(), QStringLiteral("2023.09.15.0000.0000"));
QCOMPARE(Utility::readVersion(verFile.fileName()), QStringLiteral("2023.09.15.0000.0000"));
}
void testIsSteamDeck()
{
QCOMPARE(Utility::isSteamDeck(), false);
qputenv("SteamDeck", "0");
QCOMPARE(Utility::isSteamDeck(), false);
qputenv("SteamDeck", "1");
QCOMPARE(Utility::isSteamDeck(), true);
}
};
QTEST_MAIN(UtilityTest)

View file

@ -14,4 +14,5 @@ void createPathIfNeeded(const QDir &dir);
void setSSL(QNetworkRequest &request);
QString readVersion(const QString &path);
void writeVersion(const QString &path, const QString &version);
bool isSteamDeck();
}

View file

@ -313,7 +313,7 @@ bool LauncherCore::isSteam() const
bool LauncherCore::isSteamDeck() const
{
return qEnvironmentVariable("SteamDeck") == QStringLiteral("1");
return Utility::isSteamDeck();
}
bool LauncherCore::isWindows()

View file

@ -4,7 +4,6 @@
#include <KAboutData>
#include <KLocalizedContext>
#include <KLocalizedString>
#include <QGuiApplication>
#include <QQuickStyle>
#include <kdsingleapplication.h>
#include <qcoroqml.h>
@ -17,6 +16,7 @@
#include "launchercore.h"
#include "logger.h"
#include "physis_logger.h"
#include "utility.h"
#ifdef Q_OS_WIN
#include <BreezeIcons/BreezeIcons>
@ -36,7 +36,7 @@ int main(int argc, char *argv[])
QIcon::setThemeName(QStringLiteral("Breeze"));
#endif
if (qEnvironmentVariable("SteamDeck") == QStringLiteral("1")) {
if (Utility::isSteamDeck()) {
qputenv("QT_SCALE_FACTOR", "1.25");
qputenv("QT_QUICK_CONTROLS_MOBILE", "1");
}
@ -121,7 +121,6 @@ int main(int argc, char *argv[])
parser.showVersion();
}
bool isSteamDeck = false;
if (parser.isSet(steamOption)) {
const QStringList args = parser.positionalArguments();
// Steam tries to use as a compatibility tool, running installation scripts (like DirectX), so try to ignore it.
@ -130,14 +129,10 @@ int main(int argc, char *argv[])
}
}
if (qEnvironmentVariable("SteamDeck") == QStringLiteral("1")) {
isSteamDeck = true;
}
#if defined(Q_OS_LINUX)
// Default to org.kde.desktop style unless the user forces another style
if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) {
if (isSteamDeck) {
if (Utility::isSteamDeck()) {
QQuickStyle::setStyle(QStringLiteral("org.kde.breeze"));
} else {
QQuickStyle::setStyle(QStringLiteral("org.kde.desktop"));

View file

@ -49,3 +49,8 @@ void Utility::writeVersion(const QString &path, const QString &version)
verFile.write(version.toUtf8());
verFile.close();
}
bool Utility::isSteamDeck()
{
return qEnvironmentVariable("SteamDeck") == QStringLiteral("1");
}