mirror of
https://github.com/tnodir/fort
synced 2024-11-15 09:59:38 +00:00
UI: Refactor portable mode detection.
This commit is contained in:
parent
dd8fef9958
commit
9f40ac34a2
@ -14,10 +14,15 @@
|
||||
|
||||
namespace {
|
||||
|
||||
QString pathSlash(const QString &path)
|
||||
{
|
||||
return FileUtil::pathSlash(FileUtil::absolutePath(path));
|
||||
}
|
||||
|
||||
QString expandPath(const QString &path, EnvManager *envManager = nullptr)
|
||||
{
|
||||
const auto expPath = envManager ? envManager->expandString(path) : path;
|
||||
return FileUtil::pathSlash(FileUtil::absolutePath(expPath));
|
||||
return pathSlash(expPath);
|
||||
}
|
||||
|
||||
}
|
||||
@ -25,7 +30,6 @@ QString expandPath(const QString &path, EnvManager *envManager = nullptr)
|
||||
FortSettings::FortSettings(QObject *parent) :
|
||||
QObject(parent),
|
||||
m_iniExists(false),
|
||||
m_isPortable(false),
|
||||
m_noCache(false),
|
||||
m_bulkUpdating(false),
|
||||
m_bulkIniChanged(false)
|
||||
@ -124,9 +128,6 @@ void FortSettings::processArguments(const QStringList &args, EnvManager *envMana
|
||||
|
||||
parser.process(args);
|
||||
|
||||
// Portable Mode
|
||||
m_isPortable = FileUtil::fileExists(FileUtil::appBinLocation() + "/README.portable");
|
||||
|
||||
// No Cache
|
||||
if (parser.isSet(noCacheOption)) {
|
||||
m_noCache = true;
|
||||
@ -142,10 +143,14 @@ void FortSettings::processArguments(const QStringList &args, EnvManager *envMana
|
||||
m_profilePath = parser.value(profileOption);
|
||||
}
|
||||
if (m_profilePath.isEmpty()) {
|
||||
const auto appBinLocation = FileUtil::appBinLocation();
|
||||
const bool isPortable = FileUtil::fileExists(appBinLocation + "/README.portable");
|
||||
|
||||
m_profilePath =
|
||||
m_isPortable ? FileUtil::appBinLocation() + "/Data" : FileUtil::appConfigLocation();
|
||||
pathSlash(isPortable ? appBinLocation + "/Data" : FileUtil::appConfigLocation());
|
||||
} else {
|
||||
m_profilePath = expandPath(m_profilePath, envManager);
|
||||
}
|
||||
m_profilePath = expandPath(m_profilePath, envManager);
|
||||
|
||||
// Statistics Path
|
||||
if (parser.isSet(statOption)) {
|
||||
|
@ -66,7 +66,6 @@ class FortSettings : public QObject
|
||||
public:
|
||||
explicit FortSettings(QObject *parent = nullptr);
|
||||
|
||||
bool isPortable() const { return m_isPortable; }
|
||||
bool noCache() const { return m_noCache; }
|
||||
|
||||
bool debug() const { return iniBool("base/debug"); }
|
||||
@ -326,7 +325,6 @@ private:
|
||||
|
||||
private:
|
||||
bool m_iniExists : 1;
|
||||
bool m_isPortable : 1;
|
||||
bool m_noCache : 1;
|
||||
|
||||
bool m_bulkUpdating : 1;
|
||||
|
@ -27,9 +27,8 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
FortSettings fortSettings;
|
||||
|
||||
// Process global settings required before QApplication costruction
|
||||
FortSettings fortSettings;
|
||||
fortSettings.setupGlobal();
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
@ -45,7 +44,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
EnvManager envManager;
|
||||
|
||||
// Initialize with command line arguments
|
||||
// Initialize settings from command line arguments
|
||||
fortSettings.initialize(QCoreApplication::arguments(), &envManager);
|
||||
|
||||
#ifdef USE_CONTROL_COMMANDS
|
||||
|
Loading…
Reference in New Issue
Block a user