mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-20 19:57:45 +00:00
Add a utility function to check the SteamDeck environment variable
This commit is contained in:
parent
d3478b6133
commit
36c06eed8b
5 changed files with 23 additions and 10 deletions
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -313,7 +313,7 @@ bool LauncherCore::isSteam() const
|
|||
|
||||
bool LauncherCore::isSteamDeck() const
|
||||
{
|
||||
return qEnvironmentVariable("SteamDeck") == QStringLiteral("1");
|
||||
return Utility::isSteamDeck();
|
||||
}
|
||||
|
||||
bool LauncherCore::isWindows()
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue