mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-22 18:52:30 +01:00
Extract steam version init into separate function
This commit is contained in:
parent
0c2d01cdcd
commit
5228ec0d6d
@ -149,18 +149,11 @@ public:
|
||||
Theme theme() const { return m_theme; }
|
||||
bool steamVersion() const { return m_steamVersion; }
|
||||
DesktopEnvironment desktopEnvironment() const { return m_desktopEnvironment; }
|
||||
|
||||
void setupLanguage();
|
||||
|
||||
const QString& buildInfos() const
|
||||
{
|
||||
return m_buildInfos;
|
||||
}
|
||||
const QString& buildInfos() const { return m_buildInfos; }
|
||||
|
||||
signals:
|
||||
void requestRetranslation();
|
||||
void resetInstalledListmodel();
|
||||
|
||||
void autostartChanged(bool autostart);
|
||||
void highPriorityStartChanged(bool highPriorityStart);
|
||||
void hasWorkshopBannerSeenChanged(bool hasWorkshopBannerSeen);
|
||||
@ -176,10 +169,10 @@ signals:
|
||||
void themeChanged(ScreenPlay::Settings::Theme theme);
|
||||
void steamVersionChanged(bool steamVersion);
|
||||
void desktopEnvironmentChanged(DesktopEnvironment desktopEnvironment);
|
||||
|
||||
void buildInfosChanged(const QString& buildInfos);
|
||||
|
||||
public slots:
|
||||
void setupLanguage();
|
||||
void writeJsonFileFromResource(const QString& filename);
|
||||
void setupWidgetAndWindowPaths();
|
||||
bool retranslateUI();
|
||||
@ -407,6 +400,7 @@ public slots:
|
||||
private:
|
||||
void restoreDefault(const QString& appConfigLocation, const QString& settingsFileType);
|
||||
void initInstalledPath();
|
||||
void initSteamInstalledPath();
|
||||
QString fixLanguageCode(const QString& languageCode);
|
||||
|
||||
private:
|
||||
|
@ -203,7 +203,7 @@ void Settings::restoreDefault(const QString& appConfigLocation, const QString& s
|
||||
|
||||
void Settings::initInstalledPath()
|
||||
{
|
||||
const QString contentPath = m_qSettings.value("ScreenPlayContentPath").toString();
|
||||
const QString contentPath = m_qSettings.value("ScreenPlayContentPath", "").toString();
|
||||
|
||||
// Steamless
|
||||
if (!steamVersion() && contentPath.isEmpty()) {
|
||||
@ -216,48 +216,53 @@ void Settings::initInstalledPath()
|
||||
|
||||
// Steam
|
||||
if (contentPath.isEmpty()) {
|
||||
|
||||
/*
|
||||
* ! We must use this (ugly) method, because to stay FOSS we cannot call the steamAPI here !
|
||||
*
|
||||
* We start with the assumption that when we go up 2 folder.
|
||||
* So that there must be at least a common folder:
|
||||
* Windows example:
|
||||
* From -> C:\Program Files (x86)\Steam\steamapps\common\ScreenPlay
|
||||
* To -> C:\Program Files (x86)\Steam\steamapps\
|
||||
* Dest.-> C:\Program Files (x86)\Steam\steamapps\workshop\content\672870
|
||||
*
|
||||
* When we reach the folder it _can_ contain a workshop folder when the user
|
||||
* previously installed any workshop content. If the folder does not exsist we
|
||||
* need to create it by hand. Normally Steam will create this folder but we need to
|
||||
* set it here at this point so that the QFileSystemWatcher in InstalledListModel does
|
||||
* not generate warnings.
|
||||
*/
|
||||
QDir dir;
|
||||
QString appBasePath = QApplication::instance()->applicationDirPath();
|
||||
if (desktopEnvironment() == DesktopEnvironment::OSX) {
|
||||
appBasePath += "/../../..";
|
||||
}
|
||||
QString path = appBasePath + "/../../workshop/content/672870";
|
||||
qInfo() << path;
|
||||
|
||||
if (!dir.mkpath(path)) {
|
||||
qWarning() << "Could not create steam workshop path for path: " << path;
|
||||
}
|
||||
|
||||
if (QDir(path).exists()) {
|
||||
m_globalVariables->setLocalStoragePath(QUrl::fromUserInput(path));
|
||||
m_qSettings.setValue("ScreenPlayContentPath", dir.cleanPath(path));
|
||||
m_qSettings.sync();
|
||||
} else {
|
||||
qWarning() << "The following path could not be resolved to search for workshop content: " << path;
|
||||
}
|
||||
return;
|
||||
return initSteamInstalledPath();
|
||||
}
|
||||
|
||||
m_globalVariables->setLocalStoragePath(QUrl::fromUserInput(contentPath));
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief We must use this (ugly) method, because to stay FOSS we cannot call the steamAPI here !
|
||||
|
||||
We start with the assumption that when we go up 2 folder.
|
||||
So that there must be at least a common folder:
|
||||
Windows example:
|
||||
From -> C:\Program Files (x86)\Steam\steamapps\common\ScreenPlay
|
||||
To -> C:\Program Files (x86)\Steam\steamapps\
|
||||
Dest.-> C:\Program Files (x86)\Steam\steamapps\workshop\content\672870
|
||||
|
||||
When we reach the folder it _can_ contain a workshop folder when the user
|
||||
previously installed any workshop content. If the folder does not exsist we
|
||||
need to create it by hand. Normally Steam will create this folder but we need to
|
||||
set it here at this point so that the QFileSystemWatcher in InstalledListModel does
|
||||
not generate warnings.
|
||||
*/
|
||||
void Settings::initSteamInstalledPath()
|
||||
{
|
||||
QString appBasePath = QApplication::instance()->applicationDirPath();
|
||||
if (desktopEnvironment() == DesktopEnvironment::OSX) {
|
||||
appBasePath += "/../../..";
|
||||
}
|
||||
QString path = appBasePath + "/../../workshop/content/672870";
|
||||
qInfo() << "InitSteamInstalledPath:" << path;
|
||||
|
||||
QDir dir;
|
||||
if (!dir.exists()) {
|
||||
if (!dir.mkpath(path)) {
|
||||
qWarning() << "Could not create steam workshop path for path: " << path;
|
||||
}
|
||||
}
|
||||
|
||||
if (QDir(path).exists()) {
|
||||
m_globalVariables->setLocalStoragePath(QUrl::fromUserInput(path));
|
||||
m_qSettings.setValue("ScreenPlayContentPath", dir.cleanPath(path));
|
||||
m_qSettings.sync();
|
||||
} else {
|
||||
qWarning() << "The following path could not be resolved to search for workshop content: " << path;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Checks if there is already a saved language. If not we try to use the system langauge.
|
||||
If we do not support the system language we use english.
|
||||
|
Loading…
Reference in New Issue
Block a user