GH-1308 remove use of static data (translations) and root (notifications.json) paths.
This commit is contained in:
parent
7670d72bd9
commit
e8063d193d
@ -126,6 +126,7 @@ MultiMC::MultiMC(int &argc, char **argv, bool test_mode) : QApplication(argc, ar
|
|||||||
QString origcwdPath = QDir::currentPath();
|
QString origcwdPath = QDir::currentPath();
|
||||||
QString binPath = applicationDirPath();
|
QString binPath = applicationDirPath();
|
||||||
QString adjustedBy;
|
QString adjustedBy;
|
||||||
|
QString dataPath;
|
||||||
// change directory
|
// change directory
|
||||||
QString dirParam = args["dir"].toString();
|
QString dirParam = args["dir"].toString();
|
||||||
if (!dirParam.isEmpty())
|
if (!dirParam.isEmpty())
|
||||||
@ -170,17 +171,6 @@ MultiMC::MultiMC(int &argc, char **argv, bool test_mode) : QApplication(argc, ar
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// static data paths... mostly just for translations
|
|
||||||
#ifdef Q_OS_LINUX
|
|
||||||
QDir foo(FS::PathCombine(binPath, ".."));
|
|
||||||
staticDataPath = foo.absolutePath();
|
|
||||||
#elif defined(Q_OS_WIN32)
|
|
||||||
staticDataPath = binPath;
|
|
||||||
#elif defined(Q_OS_MAC)
|
|
||||||
QDir foo(FS::PathCombine(rootPath, "Contents/Resources"));
|
|
||||||
staticDataPath = foo.absolutePath();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// init the logger
|
// init the logger
|
||||||
initLogger();
|
initLogger();
|
||||||
|
|
||||||
@ -199,7 +189,6 @@ MultiMC::MultiMC(int &argc, char **argv, bool test_mode) : QApplication(argc, ar
|
|||||||
}
|
}
|
||||||
qDebug() << "Binary path : " << binPath;
|
qDebug() << "Binary path : " << binPath;
|
||||||
qDebug() << "Application root path : " << rootPath;
|
qDebug() << "Application root path : " << rootPath;
|
||||||
qDebug() << "Static data path : " << staticDataPath;
|
|
||||||
|
|
||||||
// load settings
|
// load settings
|
||||||
initGlobalSettings(test_mode);
|
initGlobalSettings(test_mode);
|
||||||
@ -239,7 +228,7 @@ MultiMC::MultiMC(int &argc, char **argv, bool test_mode) : QApplication(argc, ar
|
|||||||
m_accounts->loadList();
|
m_accounts->loadList();
|
||||||
|
|
||||||
// init the http meta cache
|
// init the http meta cache
|
||||||
ENV.initHttpMetaCache(rootPath, staticDataPath);
|
ENV.initHttpMetaCache();
|
||||||
|
|
||||||
// create the global network manager
|
// create the global network manager
|
||||||
ENV.m_qnam.reset(new QNetworkAccessManager(this));
|
ENV.m_qnam.reset(new QNetworkAccessManager(this));
|
||||||
@ -330,7 +319,7 @@ void MultiMC::initTranslations()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_mmc_translator.reset(new QTranslator());
|
m_mmc_translator.reset(new QTranslator());
|
||||||
if (m_mmc_translator->load("mmc_" + locale.bcp47Name(), staticDataPath + "/translations"))
|
if (m_mmc_translator->load("mmc_" + locale.bcp47Name(), FS::PathCombine(QDir::currentPath(), "translations")))
|
||||||
{
|
{
|
||||||
qDebug() << "Loading MMC Language File for"
|
qDebug() << "Loading MMC Language File for"
|
||||||
<< locale.bcp47Name().toLocal8Bit().constData() << "...";
|
<< locale.bcp47Name().toLocal8Bit().constData() << "...";
|
||||||
|
@ -124,13 +124,6 @@ public:
|
|||||||
bool openJsonEditor(const QString &filename);
|
bool openJsonEditor(const QString &filename);
|
||||||
|
|
||||||
protected: /* to be removed! */
|
protected: /* to be removed! */
|
||||||
// FIXME: remove. used by MultiMCPage to enumerate translations.
|
|
||||||
/// this is the static data. it stores things that don't move.
|
|
||||||
const QString &staticData()
|
|
||||||
{
|
|
||||||
return staticDataPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: remove. used by MainWindow to create application update tasks
|
// FIXME: remove. used by MainWindow to create application update tasks
|
||||||
/// this is the root of the 'installation'. Used for automatic updates
|
/// this is the root of the 'installation'. Used for automatic updates
|
||||||
const QString &root()
|
const QString &root()
|
||||||
@ -175,8 +168,6 @@ private:
|
|||||||
QMap<QString, std::shared_ptr<BaseDetachedToolFactory>> m_tools;
|
QMap<QString, std::shared_ptr<BaseDetachedToolFactory>> m_tools;
|
||||||
|
|
||||||
QString rootPath;
|
QString rootPath;
|
||||||
QString staticDataPath;
|
|
||||||
QString dataPath;
|
|
||||||
|
|
||||||
Status m_status = MultiMC::Failed;
|
Status m_status = MultiMC::Failed;
|
||||||
public:
|
public:
|
||||||
|
@ -336,8 +336,7 @@ void MultiMCPage::loadSettings()
|
|||||||
// Language
|
// Language
|
||||||
ui->languageBox->clear();
|
ui->languageBox->clear();
|
||||||
ui->languageBox->addItem(tr("English"), QLocale(QLocale::English));
|
ui->languageBox->addItem(tr("English"), QLocale(QLocale::English));
|
||||||
foreach(const QString & lang, QDir(MMC->staticData() + "/translations")
|
for(const QString & lang: QDir("translations").entryList(QStringList() << "*.qm", QDir::Files))
|
||||||
.entryList(QStringList() << "*.qm", QDir::Files))
|
|
||||||
{
|
{
|
||||||
QLocale locale(lang.section(QRegExp("[_\\.]"), 1));
|
QLocale locale(lang.section(QRegExp("[_\\.]"), 1));
|
||||||
ui->languageBox->addItem(QLocale::languageToString(locale.language()), locale);
|
ui->languageBox->addItem(QLocale::languageToString(locale.language()), locale);
|
||||||
|
@ -134,7 +134,7 @@ void Env::registerVersionList(QString name, std::shared_ptr< BaseVersionList > v
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Env::initHttpMetaCache(QString rootPath, QString staticDataPath)
|
void Env::initHttpMetaCache()
|
||||||
{
|
{
|
||||||
m_metacache.reset(new HttpMetaCache("metacache"));
|
m_metacache.reset(new HttpMetaCache("metacache"));
|
||||||
m_metacache->addBase("asset_indexes", QDir("assets/indexes").absolutePath());
|
m_metacache->addBase("asset_indexes", QDir("assets/indexes").absolutePath());
|
||||||
@ -146,8 +146,8 @@ void Env::initHttpMetaCache(QString rootPath, QString staticDataPath)
|
|||||||
m_metacache->addBase("liteloader", QDir("mods/liteloader").absolutePath());
|
m_metacache->addBase("liteloader", QDir("mods/liteloader").absolutePath());
|
||||||
m_metacache->addBase("general", QDir("cache").absolutePath());
|
m_metacache->addBase("general", QDir("cache").absolutePath());
|
||||||
m_metacache->addBase("skins", QDir("accounts/skins").absolutePath());
|
m_metacache->addBase("skins", QDir("accounts/skins").absolutePath());
|
||||||
m_metacache->addBase("root", QDir(rootPath).absolutePath());
|
m_metacache->addBase("root", QDir::currentPath());
|
||||||
m_metacache->addBase("translations", QDir(staticDataPath + "/translations").absolutePath());
|
m_metacache->addBase("translations", QDir("translations").absolutePath());
|
||||||
m_metacache->addBase("icons", QDir("cache/icons").absolutePath());
|
m_metacache->addBase("icons", QDir("cache/icons").absolutePath());
|
||||||
m_metacache->Load();
|
m_metacache->Load();
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public:
|
|||||||
std::shared_ptr<IconList> icons();
|
std::shared_ptr<IconList> icons();
|
||||||
|
|
||||||
/// init the cache. FIXME: possible future hook point
|
/// init the cache. FIXME: possible future hook point
|
||||||
void initHttpMetaCache(QString rootPath, QString staticDataPath);
|
void initHttpMetaCache();
|
||||||
|
|
||||||
/// Updates the application proxy settings from the settings object.
|
/// Updates the application proxy settings from the settings object.
|
||||||
void updateProxySettings(QString proxyTypeStr, QString addr, int port, QString user, QString password);
|
void updateProxySettings(QString proxyTypeStr, QString addr, int port, QString user, QString password);
|
||||||
|
Loading…
Reference in New Issue
Block a user