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:
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"));
|
Utility::writeVersion(verFile.fileName(), QStringLiteral("2023.09.15.0000.0000"));
|
||||||
QCOMPARE(Utility::readVersion(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)
|
QTEST_MAIN(UtilityTest)
|
||||||
|
|
|
@ -14,4 +14,5 @@ void createPathIfNeeded(const QDir &dir);
|
||||||
void setSSL(QNetworkRequest &request);
|
void setSSL(QNetworkRequest &request);
|
||||||
QString readVersion(const QString &path);
|
QString readVersion(const QString &path);
|
||||||
void writeVersion(const QString &path, const QString &version);
|
void writeVersion(const QString &path, const QString &version);
|
||||||
|
bool isSteamDeck();
|
||||||
}
|
}
|
|
@ -313,7 +313,7 @@ bool LauncherCore::isSteam() const
|
||||||
|
|
||||||
bool LauncherCore::isSteamDeck() const
|
bool LauncherCore::isSteamDeck() const
|
||||||
{
|
{
|
||||||
return qEnvironmentVariable("SteamDeck") == QStringLiteral("1");
|
return Utility::isSteamDeck();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LauncherCore::isWindows()
|
bool LauncherCore::isWindows()
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#include <KAboutData>
|
#include <KAboutData>
|
||||||
#include <KLocalizedContext>
|
#include <KLocalizedContext>
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
#include <QGuiApplication>
|
|
||||||
#include <QQuickStyle>
|
#include <QQuickStyle>
|
||||||
#include <kdsingleapplication.h>
|
#include <kdsingleapplication.h>
|
||||||
#include <qcoroqml.h>
|
#include <qcoroqml.h>
|
||||||
|
@ -17,6 +16,7 @@
|
||||||
#include "launchercore.h"
|
#include "launchercore.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "physis_logger.h"
|
#include "physis_logger.h"
|
||||||
|
#include "utility.h"
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <BreezeIcons/BreezeIcons>
|
#include <BreezeIcons/BreezeIcons>
|
||||||
|
@ -36,7 +36,7 @@ int main(int argc, char *argv[])
|
||||||
QIcon::setThemeName(QStringLiteral("Breeze"));
|
QIcon::setThemeName(QStringLiteral("Breeze"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (qEnvironmentVariable("SteamDeck") == QStringLiteral("1")) {
|
if (Utility::isSteamDeck()) {
|
||||||
qputenv("QT_SCALE_FACTOR", "1.25");
|
qputenv("QT_SCALE_FACTOR", "1.25");
|
||||||
qputenv("QT_QUICK_CONTROLS_MOBILE", "1");
|
qputenv("QT_QUICK_CONTROLS_MOBILE", "1");
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,6 @@ int main(int argc, char *argv[])
|
||||||
parser.showVersion();
|
parser.showVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isSteamDeck = false;
|
|
||||||
if (parser.isSet(steamOption)) {
|
if (parser.isSet(steamOption)) {
|
||||||
const QStringList args = parser.positionalArguments();
|
const QStringList args = parser.positionalArguments();
|
||||||
// Steam tries to use as a compatibility tool, running installation scripts (like DirectX), so try to ignore it.
|
// 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)
|
#if defined(Q_OS_LINUX)
|
||||||
// Default to org.kde.desktop style unless the user forces another style
|
// Default to org.kde.desktop style unless the user forces another style
|
||||||
if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) {
|
if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) {
|
||||||
if (isSteamDeck) {
|
if (Utility::isSteamDeck()) {
|
||||||
QQuickStyle::setStyle(QStringLiteral("org.kde.breeze"));
|
QQuickStyle::setStyle(QStringLiteral("org.kde.breeze"));
|
||||||
} else {
|
} else {
|
||||||
QQuickStyle::setStyle(QStringLiteral("org.kde.desktop"));
|
QQuickStyle::setStyle(QStringLiteral("org.kde.desktop"));
|
||||||
|
|
|
@ -48,4 +48,9 @@ void Utility::writeVersion(const QString &path, const QString &version)
|
||||||
verFile.open(QIODevice::WriteOnly | QIODevice::Text);
|
verFile.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||||
verFile.write(version.toUtf8());
|
verFile.write(version.toUtf8());
|
||||||
verFile.close();
|
verFile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Utility::isSteamDeck()
|
||||||
|
{
|
||||||
|
return qEnvironmentVariable("SteamDeck") == QStringLiteral("1");
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue