NOISSUE Translations model and initial setup wizard work
This commit is contained in:
parent
46c5368a78
commit
722896d41f
@ -412,9 +412,8 @@ add_unit_test(JavaVersion
|
||||
)
|
||||
|
||||
set(TRANSLATIONS_SOURCES
|
||||
# Translations
|
||||
trans/TranslationDownloader.h
|
||||
trans/TranslationDownloader.cpp
|
||||
translations/TranslationsModel.h
|
||||
translations/TranslationsModel.cpp
|
||||
)
|
||||
|
||||
set(TOOLS_SOURCES
|
||||
|
@ -1,51 +0,0 @@
|
||||
#include "TranslationDownloader.h"
|
||||
#include "net/NetJob.h"
|
||||
#include "net/Download.h"
|
||||
#include "net/URLConstants.h"
|
||||
#include "Env.h"
|
||||
#include <QDebug>
|
||||
|
||||
TranslationDownloader::TranslationDownloader()
|
||||
{
|
||||
}
|
||||
void TranslationDownloader::downloadTranslations()
|
||||
{
|
||||
qDebug() << "Downloading Translations Index...";
|
||||
m_index_job.reset(new NetJob("Translations Index"));
|
||||
m_index_task = Net::Download::makeByteArray(QUrl("http://files.multimc.org/translations/index"), &m_data);
|
||||
m_index_job->addNetAction(m_index_task);
|
||||
connect(m_index_job.get(), &NetJob::failed, this, &TranslationDownloader::indexFailed);
|
||||
connect(m_index_job.get(), &NetJob::succeeded, this, &TranslationDownloader::indexRecieved);
|
||||
m_index_job->start();
|
||||
}
|
||||
void TranslationDownloader::indexRecieved()
|
||||
{
|
||||
qDebug() << "Got translations index!";
|
||||
m_dl_job.reset(new NetJob("Translations"));
|
||||
QList<QByteArray> lines = m_data.split('\n');
|
||||
m_data.clear();
|
||||
for (const auto line : lines)
|
||||
{
|
||||
if (!line.isEmpty())
|
||||
{
|
||||
MetaEntryPtr entry = ENV.metacache()->resolveEntry("translations", "mmc_" + line);
|
||||
entry->setStale(true);
|
||||
m_dl_job->addNetAction(Net::Download::makeCached(QUrl(URLConstants::TRANSLATIONS_BASE_URL + line), entry));
|
||||
}
|
||||
}
|
||||
connect(m_dl_job.get(), &NetJob::succeeded, this, &TranslationDownloader::dlGood);
|
||||
connect(m_dl_job.get(), &NetJob::failed, this, &TranslationDownloader::dlFailed);
|
||||
m_dl_job->start();
|
||||
}
|
||||
void TranslationDownloader::dlFailed(QString reason)
|
||||
{
|
||||
qCritical() << "Translations Download Failed:" << reason;
|
||||
}
|
||||
void TranslationDownloader::dlGood()
|
||||
{
|
||||
qDebug() << "Got translations!";
|
||||
}
|
||||
void TranslationDownloader::indexFailed(QString reason)
|
||||
{
|
||||
qCritical() << "Translations Index Download Failed:" << reason;
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <QList>
|
||||
#include <QUrl>
|
||||
#include <memory>
|
||||
#include <QObject>
|
||||
#include <net/NetJob.h>
|
||||
#include "multimc_logic_export.h"
|
||||
namespace Net{
|
||||
class Download;
|
||||
}
|
||||
class NetJob;
|
||||
|
||||
class MULTIMC_LOGIC_EXPORT TranslationDownloader : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TranslationDownloader();
|
||||
|
||||
void downloadTranslations();
|
||||
|
||||
private slots:
|
||||
void indexRecieved();
|
||||
void indexFailed(QString reason);
|
||||
void dlFailed(QString reason);
|
||||
void dlGood();
|
||||
|
||||
private:
|
||||
std::shared_ptr<Net::Download> m_index_task;
|
||||
NetJobPtr m_dl_job;
|
||||
NetJobPtr m_index_job;
|
||||
QByteArray m_data;
|
||||
};
|
315
api/logic/translations/TranslationsModel.cpp
Normal file
315
api/logic/translations/TranslationsModel.cpp
Normal file
@ -0,0 +1,315 @@
|
||||
#include "TranslationsModel.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QTranslator>
|
||||
#include <QLocale>
|
||||
#include <QDir>
|
||||
#include <QLibraryInfo>
|
||||
#include <QDebug>
|
||||
#include <FileSystem.h>
|
||||
#include <net/NetJob.h>
|
||||
#include <Env.h>
|
||||
#include <net/URLConstants.h>
|
||||
|
||||
const static QLatin1Literal defaultLangCode("en");
|
||||
|
||||
struct Language
|
||||
{
|
||||
QString key;
|
||||
QLocale locale;
|
||||
bool updated;
|
||||
};
|
||||
|
||||
struct TranslationsModel::Private
|
||||
{
|
||||
QDir m_dir;
|
||||
|
||||
// initial state is just english
|
||||
QVector<Language> m_languages = {{defaultLangCode, QLocale(defaultLangCode), false}};
|
||||
QString m_selectedLanguage = defaultLangCode;
|
||||
std::unique_ptr<QTranslator> m_qt_translator;
|
||||
std::unique_ptr<QTranslator> m_app_translator;
|
||||
|
||||
std::shared_ptr<Net::Download> m_index_task;
|
||||
QString m_downloadingTranslation;
|
||||
NetJobPtr m_dl_job;
|
||||
NetJobPtr m_index_job;
|
||||
QString m_nextDownload;
|
||||
};
|
||||
|
||||
TranslationsModel::TranslationsModel(QString path, QObject* parent): QAbstractListModel(parent)
|
||||
{
|
||||
d.reset(new Private);
|
||||
d->m_dir.setPath(path);
|
||||
loadLocalIndex();
|
||||
}
|
||||
|
||||
TranslationsModel::~TranslationsModel()
|
||||
{
|
||||
}
|
||||
|
||||
QVariant TranslationsModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
int row = index.row();
|
||||
|
||||
if (row < 0 || row >= d->m_languages.size())
|
||||
return QVariant();
|
||||
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
return d->m_languages[row].locale.nativeLanguageName();
|
||||
case Qt::UserRole:
|
||||
return d->m_languages[row].key;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
int TranslationsModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
return d->m_languages.size();
|
||||
}
|
||||
|
||||
Language * TranslationsModel::findLanguage(const QString& key)
|
||||
{
|
||||
auto found = std::find_if(d->m_languages.begin(), d->m_languages.end(), [&](Language & lang)
|
||||
{
|
||||
return lang.key == key;
|
||||
});
|
||||
if(found == d->m_languages.end())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
return found;
|
||||
}
|
||||
}
|
||||
|
||||
bool TranslationsModel::selectLanguage(QString key)
|
||||
{
|
||||
QString &langCode = key;
|
||||
auto langPtr = findLanguage(key);
|
||||
if(!langPtr)
|
||||
{
|
||||
qWarning() << "Selected invalid language" << key << ", defaulting to" << defaultLangCode;
|
||||
langCode = defaultLangCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
langCode = langPtr->key;
|
||||
}
|
||||
|
||||
// uninstall existing translators if there are any
|
||||
if (d->m_app_translator)
|
||||
{
|
||||
QCoreApplication::removeTranslator(d->m_app_translator.get());
|
||||
d->m_app_translator.reset();
|
||||
}
|
||||
if (d->m_qt_translator)
|
||||
{
|
||||
QCoreApplication::removeTranslator(d->m_qt_translator.get());
|
||||
d->m_qt_translator.reset();
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: potential source of crashes:
|
||||
* In a multithreaded application, the default locale should be set at application startup, before any non-GUI threads are created.
|
||||
* This function is not reentrant.
|
||||
*/
|
||||
QLocale locale(langCode);
|
||||
QLocale::setDefault(locale);
|
||||
|
||||
// if it's the default UI language, finish
|
||||
if(langCode == defaultLangCode)
|
||||
{
|
||||
d->m_selectedLanguage = langCode;
|
||||
return true;
|
||||
}
|
||||
|
||||
// otherwise install new translations
|
||||
bool successful = false;
|
||||
// FIXME: this is likely never present. FIX IT.
|
||||
d->m_qt_translator.reset(new QTranslator());
|
||||
if (d->m_qt_translator->load("qt_" + langCode, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
|
||||
{
|
||||
qDebug() << "Loading Qt Language File for" << langCode.toLocal8Bit().constData() << "...";
|
||||
if (!QCoreApplication::installTranslator(d->m_qt_translator.get()))
|
||||
{
|
||||
qCritical() << "Loading Qt Language File failed.";
|
||||
d->m_qt_translator.reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
successful = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
d->m_qt_translator.reset();
|
||||
}
|
||||
|
||||
d->m_app_translator.reset(new QTranslator());
|
||||
if (d->m_app_translator->load("mmc_" + langCode, d->m_dir.path()))
|
||||
{
|
||||
qDebug() << "Loading Application Language File for" << langCode.toLocal8Bit().constData() << "...";
|
||||
if (!QCoreApplication::installTranslator(d->m_app_translator.get()))
|
||||
{
|
||||
qCritical() << "Loading Application Language File failed.";
|
||||
d->m_app_translator.reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
successful = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
d->m_app_translator.reset();
|
||||
}
|
||||
d->m_selectedLanguage = langCode;
|
||||
return successful;
|
||||
}
|
||||
|
||||
QModelIndex TranslationsModel::selectedIndex()
|
||||
{
|
||||
auto found = findLanguage(d->m_selectedLanguage);
|
||||
if(found)
|
||||
{
|
||||
// QVector iterator freely converts to pointer to contained type
|
||||
return index(found - d->m_languages.begin(), 0, QModelIndex());
|
||||
}
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
QString TranslationsModel::selectedLanguage()
|
||||
{
|
||||
return d->m_selectedLanguage;
|
||||
}
|
||||
|
||||
void TranslationsModel::downloadIndex()
|
||||
{
|
||||
qDebug() << "Downloading Translations Index...";
|
||||
d->m_index_job.reset(new NetJob("Translations Index"));
|
||||
MetaEntryPtr entry = ENV.metacache()->resolveEntry("translations", "index");
|
||||
d->m_index_task = Net::Download::makeCached(QUrl("http://files.multimc.org/translations/index"), entry);
|
||||
d->m_index_job->addNetAction(d->m_index_task);
|
||||
connect(d->m_index_job.get(), &NetJob::failed, this, &TranslationsModel::indexFailed);
|
||||
connect(d->m_index_job.get(), &NetJob::succeeded, this, &TranslationsModel::indexRecieved);
|
||||
d->m_index_job->start();
|
||||
}
|
||||
|
||||
void TranslationsModel::indexRecieved()
|
||||
{
|
||||
qDebug() << "Got translations index!";
|
||||
d->m_index_job.reset();
|
||||
loadLocalIndex();
|
||||
if(d->m_selectedLanguage != defaultLangCode)
|
||||
{
|
||||
downloadTranslation(d->m_selectedLanguage);
|
||||
}
|
||||
}
|
||||
|
||||
void TranslationsModel::loadLocalIndex()
|
||||
{
|
||||
QByteArray data;
|
||||
try
|
||||
{
|
||||
data = FS::read(d->m_dir.absoluteFilePath("index"));
|
||||
}
|
||||
catch (Exception &e)
|
||||
{
|
||||
qCritical() << "Translations Download Failed: index file not readable";
|
||||
return;
|
||||
}
|
||||
QVector<Language> languages;
|
||||
QList<QByteArray> lines = data.split('\n');
|
||||
// add the default english.
|
||||
languages.append({defaultLangCode, QLocale(defaultLangCode), true});
|
||||
for (const auto line : lines)
|
||||
{
|
||||
if(!line.isEmpty())
|
||||
{
|
||||
auto str = QString::fromLatin1(line);
|
||||
str.remove(".qm");
|
||||
languages.append({str, QLocale(str), false});
|
||||
}
|
||||
}
|
||||
beginResetModel();
|
||||
d->m_languages.swap(languages);
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void TranslationsModel::updateLanguage(QString key)
|
||||
{
|
||||
if(key == defaultLangCode)
|
||||
{
|
||||
qWarning() << "Cannot update builtin language" << key;
|
||||
return;
|
||||
}
|
||||
auto found = findLanguage(key);
|
||||
if(!found)
|
||||
{
|
||||
qWarning() << "Cannot update invalid language" << key;
|
||||
return;
|
||||
}
|
||||
if(!found->updated)
|
||||
{
|
||||
downloadTranslation(key);
|
||||
}
|
||||
}
|
||||
|
||||
void TranslationsModel::downloadTranslation(QString key)
|
||||
{
|
||||
if(d->m_dl_job)
|
||||
{
|
||||
d->m_nextDownload = key;
|
||||
return;
|
||||
}
|
||||
d->m_downloadingTranslation = key;
|
||||
MetaEntryPtr entry = ENV.metacache()->resolveEntry("translations", "mmc_" + key + ".qm");
|
||||
entry->setStale(true);
|
||||
d->m_dl_job.reset(new NetJob("Translation for " + key));
|
||||
d->m_dl_job->addNetAction(Net::Download::makeCached(QUrl(URLConstants::TRANSLATIONS_BASE_URL + key + ".qm"), entry));
|
||||
connect(d->m_dl_job.get(), &NetJob::succeeded, this, &TranslationsModel::dlGood);
|
||||
connect(d->m_dl_job.get(), &NetJob::failed, this, &TranslationsModel::dlFailed);
|
||||
d->m_dl_job->start();
|
||||
}
|
||||
|
||||
void TranslationsModel::downloadNext()
|
||||
{
|
||||
if(!d->m_nextDownload.isEmpty())
|
||||
{
|
||||
downloadTranslation(d->m_nextDownload);
|
||||
d->m_nextDownload.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void TranslationsModel::dlFailed(QString reason)
|
||||
{
|
||||
qCritical() << "Translations Download Failed:" << reason;
|
||||
d->m_dl_job.reset();
|
||||
downloadNext();
|
||||
}
|
||||
|
||||
void TranslationsModel::dlGood()
|
||||
{
|
||||
qDebug() << "Got translation:" << d->m_downloadingTranslation;
|
||||
|
||||
if(d->m_downloadingTranslation == d->m_selectedLanguage)
|
||||
{
|
||||
selectLanguage(d->m_selectedLanguage);
|
||||
}
|
||||
d->m_dl_job.reset();
|
||||
downloadNext();
|
||||
}
|
||||
|
||||
void TranslationsModel::indexFailed(QString reason)
|
||||
{
|
||||
qCritical() << "Translations Index Download Failed:" << reason;
|
||||
d->m_index_job.reset();
|
||||
}
|
61
api/logic/translations/TranslationsModel.h
Normal file
61
api/logic/translations/TranslationsModel.h
Normal file
@ -0,0 +1,61 @@
|
||||
/* Copyright 2013-2016 MultiMC Contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <memory>
|
||||
#include "multimc_logic_export.h"
|
||||
|
||||
struct Language;
|
||||
|
||||
class MULTIMC_LOGIC_EXPORT TranslationsModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TranslationsModel(QString path, QObject *parent = 0);
|
||||
virtual ~TranslationsModel();
|
||||
|
||||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
bool selectLanguage(QString key);
|
||||
void updateLanguage(QString key);
|
||||
QModelIndex selectedIndex();
|
||||
QString selectedLanguage();
|
||||
|
||||
void downloadIndex();
|
||||
|
||||
private:
|
||||
Language *findLanguage(const QString & key);
|
||||
void loadLocalIndex();
|
||||
void downloadTranslation(QString key);
|
||||
void downloadNext();
|
||||
|
||||
// hide copy constructor
|
||||
TranslationsModel(const TranslationsModel &) = delete;
|
||||
// hide assign op
|
||||
TranslationsModel &operator=(const TranslationsModel &) = delete;
|
||||
|
||||
private slots:
|
||||
void indexRecieved();
|
||||
void indexFailed(QString reason);
|
||||
void dlFailed(QString reason);
|
||||
void dlGood();
|
||||
|
||||
private: /* data */
|
||||
struct Private;
|
||||
std::unique_ptr<Private> d;
|
||||
};
|
@ -302,9 +302,6 @@ SET(MULTIMC_UIS
|
||||
|
||||
# Widgets/other
|
||||
widgets/MCModInfoFrame.ui
|
||||
|
||||
# The Setup Wizard
|
||||
setupwizard/SetupWizard.ui
|
||||
)
|
||||
|
||||
set(MULTIMC_QRCS
|
||||
|
@ -1429,6 +1429,15 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
QApplication::exit();
|
||||
}
|
||||
|
||||
void MainWindow::changeEvent(QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::LanguageChange)
|
||||
{
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
QMainWindow::changeEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::instanceActivated(QModelIndex index)
|
||||
{
|
||||
if (!index.isValid())
|
||||
@ -1552,76 +1561,6 @@ void MainWindow::selectionBad()
|
||||
setSelectedInstanceById(MMC->settings()->get("SelectedInstance").toString());
|
||||
}
|
||||
|
||||
void MainWindow::checkSetDefaultJava()
|
||||
{
|
||||
const QString javaHack = "IntelHack";
|
||||
bool askForJava = false;
|
||||
do
|
||||
{
|
||||
QString currentHostName = QHostInfo::localHostName();
|
||||
QString oldHostName = MMC->settings()->get("LastHostname").toString();
|
||||
if (currentHostName != oldHostName)
|
||||
{
|
||||
MMC->settings()->set("LastHostname", currentHostName);
|
||||
askForJava = true;
|
||||
break;
|
||||
}
|
||||
QString currentJavaPath = MMC->settings()->get("JavaPath").toString();
|
||||
QString actualPath = FS::ResolveExecutable(currentJavaPath);
|
||||
if (currentJavaPath.isNull())
|
||||
{
|
||||
askForJava = true;
|
||||
break;
|
||||
}
|
||||
#if defined Q_OS_WIN32
|
||||
QString currentHack = MMC->settings()->get("JavaDetectionHack").toString();
|
||||
if (currentHack != javaHack)
|
||||
{
|
||||
CustomMessageBox::selectable(this, tr("Java detection forced"), tr("Because of graphics performance issues caused by Intel drivers on Windows, "
|
||||
"MultiMC java detection was forced. Please select a Java "
|
||||
"version.<br/><br/>If you have custom java versions set for your instances, "
|
||||
"make sure you use the 'javaw.exe' executable."),
|
||||
QMessageBox::Warning)
|
||||
->exec();
|
||||
askForJava = true;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
} while (0);
|
||||
|
||||
if (askForJava)
|
||||
{
|
||||
qDebug() << "Java path needs resetting, showing Java selection dialog...";
|
||||
|
||||
JavaInstallPtr java;
|
||||
|
||||
VersionSelectDialog vselect(MMC->javalist().get(), tr("Select a Java version"), this, false);
|
||||
vselect.setResizeOn(2);
|
||||
vselect.exec();
|
||||
|
||||
if (vselect.selectedVersion())
|
||||
java = std::dynamic_pointer_cast<JavaInstall>(vselect.selectedVersion());
|
||||
else
|
||||
{
|
||||
CustomMessageBox::selectable(this, tr("Invalid version selected"), tr("You didn't select a valid Java version, so MultiMC will "
|
||||
"select the default. "
|
||||
"You can change this in the settings dialog."),
|
||||
QMessageBox::Warning)
|
||||
->show();
|
||||
|
||||
JavaUtils ju;
|
||||
java = ju.GetDefaultJava();
|
||||
}
|
||||
if (java)
|
||||
{
|
||||
MMC->settings()->set("JavaPath", java->path);
|
||||
MMC->settings()->set("JavaDetectionHack", javaHack);
|
||||
}
|
||||
else
|
||||
MMC->settings()->set("JavaPath", QString("java"));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::checkInstancePathForProblems()
|
||||
{
|
||||
QString instanceFolder = MMC->settings()->get("InstanceDir").toString();
|
||||
|
@ -48,10 +48,10 @@ public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
virtual bool eventFilter(QObject *obj, QEvent *ev) override;
|
||||
virtual void closeEvent(QCloseEvent *event) override;
|
||||
bool eventFilter(QObject *obj, QEvent *ev) override;
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
void changeEvent(QEvent * event) override;
|
||||
|
||||
void checkSetDefaultJava();
|
||||
void checkInstancePathForProblems();
|
||||
|
||||
private slots:
|
||||
|
@ -58,7 +58,7 @@
|
||||
#include "settings/INISettingsObject.h"
|
||||
#include "settings/Setting.h"
|
||||
|
||||
#include "trans/TranslationDownloader.h"
|
||||
#include "translations/TranslationsModel.h"
|
||||
|
||||
#include "minecraft/ftb/FTBPlugin.h"
|
||||
|
||||
@ -289,8 +289,6 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
|
||||
m_updateChecker.reset(new UpdateChecker(BuildConfig.CHANLIST_URL, BuildConfig.VERSION_CHANNEL, BuildConfig.VERSION_BUILD));
|
||||
}
|
||||
|
||||
m_translationChecker.reset(new TranslationDownloader());
|
||||
|
||||
initIcons();
|
||||
initThemes();
|
||||
// make sure we have at least some minecraft versions before we init instances
|
||||
@ -299,7 +297,8 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
|
||||
initAccounts();
|
||||
initNetwork();
|
||||
|
||||
m_translationChecker->downloadTranslations();
|
||||
// now we have network, download translation updates
|
||||
m_translations->downloadIndex();
|
||||
|
||||
//FIXME: what to do with these?
|
||||
m_profilers.insert("jprofiler", std::shared_ptr<BaseProfilerFactory>(new JProfilerFactory()));
|
||||
@ -347,14 +346,6 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
|
||||
|
||||
MultiMC::~MultiMC()
|
||||
{
|
||||
if (m_mmc_translator)
|
||||
{
|
||||
removeTranslator(m_mmc_translator.get());
|
||||
}
|
||||
if (m_qt_translator)
|
||||
{
|
||||
removeTranslator(m_qt_translator.get());
|
||||
}
|
||||
#if defined Q_OS_WIN32
|
||||
if(consoleAttached)
|
||||
{
|
||||
@ -415,43 +406,10 @@ void MultiMC::initNetwork()
|
||||
|
||||
void MultiMC::initTranslations()
|
||||
{
|
||||
m_translations.reset(new TranslationsModel("translations"));
|
||||
auto bcp47Name = m_settings->get("Language").toString();
|
||||
QLocale locale(bcp47Name);
|
||||
QLocale::setDefault(locale);
|
||||
m_translations->selectLanguage(bcp47Name);
|
||||
qDebug() << "Your language is" << bcp47Name;
|
||||
// FIXME: this is likely never present.
|
||||
m_qt_translator.reset(new QTranslator());
|
||||
if (m_qt_translator->load("qt_" + bcp47Name,
|
||||
QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
|
||||
{
|
||||
qDebug() << "Loading Qt Language File for"
|
||||
<< bcp47Name.toLocal8Bit().constData() << "...";
|
||||
if (!installTranslator(m_qt_translator.get()))
|
||||
{
|
||||
qCritical() << "Loading Qt Language File failed.";
|
||||
m_qt_translator.reset();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_qt_translator.reset();
|
||||
}
|
||||
|
||||
m_mmc_translator.reset(new QTranslator());
|
||||
if (m_mmc_translator->load("mmc_" + bcp47Name, FS::PathCombine(QDir::currentPath(), "translations")))
|
||||
{
|
||||
qDebug() << "Loading MMC Language File for"
|
||||
<< bcp47Name.toLocal8Bit().constData() << "...";
|
||||
if (!installTranslator(m_mmc_translator.get()))
|
||||
{
|
||||
qCritical() << "Loading MMC Language File failed.";
|
||||
m_mmc_translator.reset();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_mmc_translator.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void MultiMC::initIcons()
|
||||
@ -520,6 +478,7 @@ void MultiMC::shutdownLogger()
|
||||
|
||||
void MultiMC::initAnalytics()
|
||||
{
|
||||
const int analyticsVersion = 1;
|
||||
if(BuildConfig.ANALYTICS_ID.isEmpty())
|
||||
{
|
||||
return;
|
||||
@ -535,11 +494,16 @@ void MultiMC::initAnalytics()
|
||||
clientID.remove(QLatin1Char('}'));
|
||||
m_settings->set("AnalyticsClientID", clientID);
|
||||
}
|
||||
m_analytics = new GAnalytics(BuildConfig.ANALYTICS_ID, clientID, this);
|
||||
m_analytics = new GAnalytics(BuildConfig.ANALYTICS_ID, clientID, analyticsVersion, this);
|
||||
m_analytics->setLogLevel(GAnalytics::Debug);
|
||||
m_analytics->setAnonymizeIPs(true);
|
||||
m_analytics->setNetworkAccessManager(&ENV.qnam());
|
||||
|
||||
if(m_settings->get("AnalyticsSeen").toInt() < m_analytics->version())
|
||||
{
|
||||
qDebug() << "Analytics info not seen by user yet (or old version).";
|
||||
return;
|
||||
}
|
||||
if(!m_settings->get("Analytics").toBool())
|
||||
{
|
||||
qDebug() << "Analytics disabled by user.";
|
||||
@ -659,7 +623,7 @@ void MultiMC::initGlobalSettings()
|
||||
m_settings->registerSetting("JsonEditor", QString());
|
||||
|
||||
// Language
|
||||
m_settings->registerSetting("Language", QLocale(QLocale::system().language()).bcp47Name());
|
||||
m_settings->registerSetting("Language", QString());
|
||||
|
||||
// Console
|
||||
m_settings->registerSetting("ShowConsole", false);
|
||||
@ -695,7 +659,6 @@ void MultiMC::initGlobalSettings()
|
||||
m_settings->registerSetting("JavaArchitecture", "");
|
||||
m_settings->registerSetting("JavaVersion", "");
|
||||
m_settings->registerSetting("LastHostname", "");
|
||||
m_settings->registerSetting("JavaDetectionHack", "");
|
||||
m_settings->registerSetting("JvmArgs", "");
|
||||
|
||||
// Minecraft launch method
|
||||
@ -735,6 +698,7 @@ void MultiMC::initGlobalSettings()
|
||||
{
|
||||
// Analytics
|
||||
m_settings->registerSetting("Analytics", true);
|
||||
m_settings->registerSetting("AnalyticsSeen", 0);
|
||||
m_settings->registerSetting("AnalyticsClientID", QString());
|
||||
}
|
||||
|
||||
@ -756,6 +720,11 @@ void MultiMC::initMCEdit()
|
||||
m_mcedit.reset(new MCEditTool(m_settings));
|
||||
}
|
||||
|
||||
std::shared_ptr<TranslationsModel> MultiMC::translations()
|
||||
{
|
||||
return m_translations;
|
||||
}
|
||||
|
||||
std::shared_ptr<LWJGLVersionList> MultiMC::lwjgllist()
|
||||
{
|
||||
if (!m_lwjgllist)
|
||||
@ -1013,7 +982,6 @@ MainWindow* MultiMC::showMainWindow(bool minimized)
|
||||
m_mainWindow->show();
|
||||
}
|
||||
|
||||
m_mainWindow->checkSetDefaultJava();
|
||||
m_mainWindow->checkInstancePathForProblems();
|
||||
m_openWindows++;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class JavaInstallList;
|
||||
class UpdateChecker;
|
||||
class BaseProfilerFactory;
|
||||
class BaseDetachedToolFactory;
|
||||
class TranslationDownloader;
|
||||
class TranslationsModel;
|
||||
class ITheme;
|
||||
class MCEditTool;
|
||||
class GAnalytics;
|
||||
@ -58,6 +58,11 @@ public:
|
||||
MultiMC(int &argc, char **argv);
|
||||
virtual ~MultiMC();
|
||||
|
||||
GAnalytics *analytics() const
|
||||
{
|
||||
return m_analytics;
|
||||
}
|
||||
|
||||
std::shared_ptr<SettingsObject> settings() const
|
||||
{
|
||||
return m_settings;
|
||||
@ -87,6 +92,7 @@ public:
|
||||
return m_updateChecker;
|
||||
}
|
||||
|
||||
std::shared_ptr<TranslationsModel> translations();
|
||||
std::shared_ptr<MinecraftVersionList> minecraftlist();
|
||||
std::shared_ptr<LWJGLVersionList> lwjgllist();
|
||||
std::shared_ptr<ForgeVersionList> forgelist();
|
||||
@ -183,8 +189,6 @@ private:
|
||||
private:
|
||||
QDateTime startTime;
|
||||
|
||||
std::shared_ptr<QTranslator> m_qt_translator;
|
||||
std::shared_ptr<QTranslator> m_mmc_translator;
|
||||
std::shared_ptr<SettingsObject> m_settings;
|
||||
std::shared_ptr<InstanceList> m_instances;
|
||||
FolderInstanceProvider * m_instanceFolder = nullptr;
|
||||
@ -196,7 +200,7 @@ private:
|
||||
std::shared_ptr<LiteLoaderVersionList> m_liteloaderlist;
|
||||
std::shared_ptr<MinecraftVersionList> m_minecraftlist;
|
||||
std::shared_ptr<JavaInstallList> m_javalist;
|
||||
std::shared_ptr<TranslationDownloader> m_translationChecker;
|
||||
std::shared_ptr<TranslationsModel> m_translations;
|
||||
std::shared_ptr<GenericPageProvider> m_globalSettingsProvider;
|
||||
std::map<QString, std::unique_ptr<ITheme>> m_themes;
|
||||
std::unique_ptr<MCEditTool> m_mcedit;
|
||||
|
@ -1,26 +1,273 @@
|
||||
#include "SetupWizard.h"
|
||||
#include "translations/TranslationsModel.h"
|
||||
#include <MultiMC.h>
|
||||
#include <FileSystem.h>
|
||||
#include <ganalytics.h>
|
||||
|
||||
enum Page
|
||||
{
|
||||
Language,
|
||||
Java,
|
||||
Analytics,
|
||||
Themes,
|
||||
Accounts
|
||||
// Themes,
|
||||
// Accounts
|
||||
};
|
||||
#include "ui_SetupWizard.h"
|
||||
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtWidgets/QAction>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtWidgets/QButtonGroup>
|
||||
#include <QtWidgets/QCheckBox>
|
||||
#include <QtWidgets/QHeaderView>
|
||||
#include <QtWidgets/QListView>
|
||||
#include <QtWidgets/QTextBrowser>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
#include <QtWidgets/QWizard>
|
||||
#include <QtWidgets/QWizardPage>
|
||||
|
||||
SetupWizard::SetupWizard(QWidget *parent):QWizard(parent), ui(new Ui::SetupWizard)
|
||||
class BaseWizardPage : public QWizardPage
|
||||
{
|
||||
ui->setupUi(this);
|
||||
public:
|
||||
explicit BaseWizardPage(QWidget *parent = Q_NULLPTR)
|
||||
: QWizardPage(parent)
|
||||
{
|
||||
}
|
||||
virtual ~BaseWizardPage() {};
|
||||
|
||||
protected:
|
||||
virtual void retranslate() = 0;
|
||||
void changeEvent(QEvent * event) override
|
||||
{
|
||||
if (event->type() == QEvent::LanguageChange)
|
||||
{
|
||||
retranslate();
|
||||
}
|
||||
QWizardPage::changeEvent(event);
|
||||
}
|
||||
};
|
||||
|
||||
class LanguageWizardPage : public BaseWizardPage
|
||||
{
|
||||
Q_OBJECT;
|
||||
public:
|
||||
explicit LanguageWizardPage(QWidget *parent = Q_NULLPTR)
|
||||
: BaseWizardPage(parent)
|
||||
{
|
||||
setObjectName(QStringLiteral("languagePage"));
|
||||
verticalLayout = new QVBoxLayout(this);
|
||||
verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
|
||||
languageView = new QListView(this);
|
||||
languageView->setObjectName(QStringLiteral("languageView"));
|
||||
verticalLayout->addWidget(languageView);
|
||||
retranslate();
|
||||
|
||||
auto translations = MMC->translations();
|
||||
auto index = translations->selectedIndex();
|
||||
languageView->setModel(translations.get());
|
||||
languageView->setCurrentIndex(index);
|
||||
connect(languageView->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &LanguageWizardPage::languageRowChanged);
|
||||
}
|
||||
virtual ~LanguageWizardPage() {};
|
||||
|
||||
protected:
|
||||
void retranslate() override
|
||||
{
|
||||
setTitle(QApplication::translate("LanguageWizardPage", "Language", Q_NULLPTR));
|
||||
setSubTitle(QApplication::translate("LanguageWizardPage", "Select the language to use in MultiMC", Q_NULLPTR));
|
||||
}
|
||||
|
||||
protected slots:
|
||||
void languageRowChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||
{
|
||||
if (current == previous)
|
||||
{
|
||||
return;
|
||||
}
|
||||
auto translations = MMC->translations();
|
||||
QString key = translations->data(current, Qt::UserRole).toString();
|
||||
translations->selectLanguage(key);
|
||||
translations->updateLanguage(key);
|
||||
}
|
||||
|
||||
private:
|
||||
QVBoxLayout *verticalLayout = nullptr;
|
||||
QListView *languageView = nullptr;
|
||||
};
|
||||
|
||||
class AnalyticsWizardPage : public BaseWizardPage
|
||||
{
|
||||
Q_OBJECT;
|
||||
public:
|
||||
explicit AnalyticsWizardPage(QWidget *parent = Q_NULLPTR)
|
||||
: BaseWizardPage(parent)
|
||||
{
|
||||
setObjectName(QStringLiteral("analyticsPage"));
|
||||
verticalLayout_3 = new QVBoxLayout(this);
|
||||
verticalLayout_3->setObjectName(QStringLiteral("verticalLayout_3"));
|
||||
textBrowser = new QTextBrowser(this);
|
||||
textBrowser->setObjectName(QStringLiteral("textBrowser"));
|
||||
textBrowser->setAcceptRichText(false);
|
||||
textBrowser->setOpenExternalLinks(true);
|
||||
verticalLayout_3->addWidget(textBrowser);
|
||||
|
||||
checkBox = new QCheckBox(this);
|
||||
checkBox->setObjectName(QStringLiteral("checkBox"));
|
||||
checkBox->setChecked(true);
|
||||
verticalLayout_3->addWidget(checkBox);
|
||||
retranslate();
|
||||
}
|
||||
virtual ~AnalyticsWizardPage() {};
|
||||
|
||||
protected:
|
||||
void retranslate() override
|
||||
{
|
||||
setTitle(QApplication::translate("AnalyticsWizardPage", "Analytics", Q_NULLPTR));
|
||||
setSubTitle(QApplication::translate("AnalyticsWizardPage", "We track some anonymous statistics about users.", Q_NULLPTR));
|
||||
textBrowser->setHtml(QApplication::translate("AnalyticsWizardPage",
|
||||
"<html><body>"
|
||||
"<p>MultiMC sends anonymous usage statistics on every start of the application. This helps us decide what platforms and issues to focus on.</p>"
|
||||
"<p>The data is processed by Google Analytics, see their <a href=\"https://support.google.com/analytics/answer/6004245?hl=en\">article on the matter</a>.</p>"
|
||||
"<p>The following data is collected:</p>"
|
||||
"<ul><li>A random unique ID of the MultiMC installation.<br />It is stored in the application settings (multimc.cfg).</li>"
|
||||
"<li>Anonymized IP address.<br />Last octet is set to 0 by Google and not stored.</li>"
|
||||
"<li>MultiMC version.</li>"
|
||||
"<li>Operating system name, version and architecture.</li>"
|
||||
"<li>CPU architecture (kernel architecture on linux).</li>"
|
||||
"<li>Size of system memory.</li>"
|
||||
"<li>Java version, architecture and memory settings.</li></ul>"
|
||||
"<p>The analytics will activate on next start, unless you disable them in the settings.</p>"
|
||||
"<p>If we change the tracked information, analytics won't be active for the first run and you will see this page again.</p></body></html>", Q_NULLPTR));
|
||||
checkBox->setText(QApplication::translate("AnalyticsWizardPage", "Enable Analytics", Q_NULLPTR));
|
||||
}
|
||||
private:
|
||||
QVBoxLayout *verticalLayout_3 = nullptr;
|
||||
QTextBrowser *textBrowser = nullptr;
|
||||
QCheckBox *checkBox = nullptr;
|
||||
};
|
||||
|
||||
SetupWizard::SetupWizard(QWidget *parent) : QWizard(parent)
|
||||
{
|
||||
setObjectName(QStringLiteral("SetupWizard"));
|
||||
resize(615, 659);
|
||||
setOptions(QWizard::NoCancelButton);
|
||||
if (languageIsRequired())
|
||||
{
|
||||
setPage(Page::Language, new LanguageWizardPage(this));
|
||||
}
|
||||
if(javaIsRequired())
|
||||
{
|
||||
// set up java selection
|
||||
}
|
||||
else
|
||||
{
|
||||
removePage(Page::Java);
|
||||
}
|
||||
if(analyticsIsRequired())
|
||||
{
|
||||
setPage(Page::Analytics, new AnalyticsWizardPage(this));
|
||||
}
|
||||
}
|
||||
|
||||
void SetupWizard::retranslate()
|
||||
{
|
||||
setButtonText(QWizard::NextButton, tr("Next >"));
|
||||
setButtonText(QWizard::BackButton, tr("< Back"));
|
||||
setButtonText(QWizard::FinishButton, tr("Finish"));
|
||||
setWindowTitle(QApplication::translate("SetupWizard", "MultiMC Quick Setup", Q_NULLPTR));
|
||||
}
|
||||
|
||||
void SetupWizard::changeEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::LanguageChange)
|
||||
{
|
||||
retranslate();
|
||||
}
|
||||
QWizard::changeEvent(event);
|
||||
}
|
||||
|
||||
SetupWizard::~SetupWizard()
|
||||
{
|
||||
}
|
||||
|
||||
bool SetupWizard::languageIsRequired()
|
||||
{
|
||||
auto settings = MMC->settings();
|
||||
if (settings->get("Language").toString().isEmpty())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SetupWizard::javaIsRequired()
|
||||
{
|
||||
QString currentHostName = QHostInfo::localHostName();
|
||||
QString oldHostName = MMC->settings()->get("LastHostname").toString();
|
||||
if (currentHostName != oldHostName)
|
||||
{
|
||||
MMC->settings()->set("LastHostname", currentHostName);
|
||||
return true;
|
||||
}
|
||||
QString currentJavaPath = MMC->settings()->get("JavaPath").toString();
|
||||
QString actualPath = FS::ResolveExecutable(currentJavaPath);
|
||||
if (actualPath.isNull())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SetupWizard::analyticsIsRequired()
|
||||
{
|
||||
auto settings = MMC->settings();
|
||||
auto analytics = MMC->analytics();
|
||||
if(settings->get("AnalyticsSeen").toInt() < analytics->version())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SetupWizard::isRequired()
|
||||
{
|
||||
if (languageIsRequired())
|
||||
return true;
|
||||
if (javaIsRequired())
|
||||
return true;
|
||||
if (analyticsIsRequired())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
void MainWindow::checkSetDefaultJava()
|
||||
{
|
||||
qDebug() << "Java path needs resetting, showing Java selection dialog...";
|
||||
|
||||
JavaInstallPtr java;
|
||||
|
||||
VersionSelectDialog vselect(MMC->javalist().get(), tr("Select a Java version"), this, false);
|
||||
vselect.setResizeOn(2);
|
||||
vselect.exec();
|
||||
|
||||
if (vselect.selectedVersion())
|
||||
java = std::dynamic_pointer_cast<JavaInstall>(vselect.selectedVersion());
|
||||
else
|
||||
{
|
||||
CustomMessageBox::selectable(this, tr("Invalid version selected"), tr("You didn't select a valid Java version, so MultiMC will "
|
||||
"select the default. "
|
||||
"You can change this in the settings dialog."),
|
||||
QMessageBox::Warning)
|
||||
->show();
|
||||
|
||||
JavaUtils ju;
|
||||
java = ju.GetDefaultJava();
|
||||
}
|
||||
if (java)
|
||||
{
|
||||
MMC->settings()->set("JavaPath", java->path);
|
||||
}
|
||||
else
|
||||
MMC->settings()->set("JavaPath", QString("java"));
|
||||
}
|
||||
*/
|
||||
|
||||
#include "SetupWizard.moc"
|
||||
|
@ -30,10 +30,15 @@ public: /* con/destructors */
|
||||
explicit SetupWizard(QWidget *parent = 0);
|
||||
virtual ~SetupWizard();
|
||||
|
||||
public: /* methods */
|
||||
static bool isRequired();
|
||||
void changeEvent(QEvent * event) override;
|
||||
|
||||
private: /* data */
|
||||
Ui::SetupWizard *ui = nullptr;
|
||||
public: /* methods */
|
||||
static bool isRequired();
|
||||
static bool javaIsRequired();
|
||||
static bool languageIsRequired();
|
||||
static bool analyticsIsRequired();
|
||||
|
||||
private: /* methods */
|
||||
void retranslate();
|
||||
};
|
||||
|
||||
|
@ -1,289 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SetupWizard</class>
|
||||
<widget class="QWizard" name="SetupWizard">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>628</width>
|
||||
<height>637</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MultiMC Quick Setup</string>
|
||||
</property>
|
||||
<property name="options">
|
||||
<set>QWizard::NoCancelButton</set>
|
||||
</property>
|
||||
<widget class="QWizardPage" name="welcomePage">
|
||||
<property name="title">
|
||||
<string>Welcome</string>
|
||||
</property>
|
||||
<property name="subTitle">
|
||||
<string>Hello and welcome the quick setup wizard!</string>
|
||||
</property>
|
||||
<attribute name="pageId">
|
||||
<string notr="true">Page::Language</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>Choose your <s>adventure</s> language:</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListView" name="languageView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWizardPage" name="javaPage">
|
||||
<property name="title">
|
||||
<string>Java</string>
|
||||
</property>
|
||||
<property name="subTitle">
|
||||
<string>Your java settings need attention!</string>
|
||||
</property>
|
||||
<attribute name="pageId">
|
||||
<string notr="true">Page::Java</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="javaSettingsGroupBox">
|
||||
<property name="title">
|
||||
<string>Java Runtime</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="4" column="1">
|
||||
<widget class="QTreeView" name="javaView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="memoryGroupBox">
|
||||
<property name="title">
|
||||
<string>Memory</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="maxMemSpinBox">
|
||||
<property name="toolTip">
|
||||
<string>The maximum amount of memory Minecraft is allowed to use.</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string notr="true"> MB</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>512</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>65536</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>128</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1024</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelMinMem">
|
||||
<property name="text">
|
||||
<string>Minimum memory allocation:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelMaxMem">
|
||||
<property name="text">
|
||||
<string>Maximum memory allocation:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelPermGen">
|
||||
<property name="text">
|
||||
<string notr="true">PermGen:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="permGenSpinBox">
|
||||
<property name="toolTip">
|
||||
<string>The amount of memory available to store loaded Java classes.</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string notr="true"> MB</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>64</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999999999</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>64</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="minMemSpinBox">
|
||||
<property name="toolTip">
|
||||
<string>The amount of memory Minecraft is started with.</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string notr="true"> MB</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>256</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>65536</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>128</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>256</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWizardPage" name="analyticsPage">
|
||||
<property name="title">
|
||||
<string>Analytics</string>
|
||||
</property>
|
||||
<property name="subTitle">
|
||||
<string>We track some anonymous statistics about users.</string>
|
||||
</property>
|
||||
<attribute name="pageId">
|
||||
<string notr="true">Page::Analytics</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustToContentsOnFirstShow</enum>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>592</width>
|
||||
<height>477</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string><html><head/><body>
|
||||
<p>MultiMC sends anonymous usage statistics on every start of the application. This helps us decide what platforms and issues to focus on.</p>
|
||||
<p>The data is processed by Google Analytics, see their <a href="https://support.google.com/analytics/answer/6004245?hl=en">article on the matter</a>.</p>
|
||||
<p>The following data is collected:</p>
|
||||
<ul>
|
||||
<li>A random unique ID of the MultiMC installation.<br />It is stored in the application settings (multimc.cfg).</li>
|
||||
<li>Anonymized IP address.<br />Last octet is set to 0 by Google and not stored.</li>
|
||||
<li>MultiMC version.</li>
|
||||
<li>Operating system name, version and architecture.</li>
|
||||
<li>CPU architecture (kernel architecture on linux).</li>
|
||||
<li>Size of system memory.</li>
|
||||
<li>Java version, architecture and memory settings.</li>
|
||||
</ul>
|
||||
<p>The analytics will activate on next start, unless you disable them in the settings.</p>
|
||||
<p>If we change the tracked information, analytics won't be active for the first run and you will see this page again.</p>
|
||||
</body></html></string>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWizardPage" name="themePage">
|
||||
<property name="title">
|
||||
<string>Themes and icons</string>
|
||||
</property>
|
||||
<property name="subTitle">
|
||||
<string>Change how things look.</string>
|
||||
</property>
|
||||
<attribute name="pageId">
|
||||
<string notr="true">Page::Themes</string>
|
||||
</attribute>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>230</x>
|
||||
<y>70</y>
|
||||
<width>151</width>
|
||||
<height>71</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Put stuff here.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWizardPage" name="accountsPage">
|
||||
<property name="title">
|
||||
<string>Minecraft accounts</string>
|
||||
</property>
|
||||
<property name="subTitle">
|
||||
<string>Add your account - or accounts.</string>
|
||||
</property>
|
||||
<attribute name="pageId">
|
||||
<string notr="true">Page::Accounts</string>
|
||||
</attribute>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>60</y>
|
||||
<width>311</width>
|
||||
<height>131</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Put existing accounts page here.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -12,7 +12,7 @@ class GAnalytics : public QObject
|
||||
Q_ENUMS(LogLevel)
|
||||
|
||||
public:
|
||||
explicit GAnalytics(const QString &trackingID, const QString &clientID, QObject *parent = 0);
|
||||
explicit GAnalytics(const QString &trackingID, const QString &clientID, const int version, QObject *parent = 0);
|
||||
~GAnalytics();
|
||||
|
||||
public:
|
||||
@ -23,6 +23,8 @@ public:
|
||||
Error
|
||||
};
|
||||
|
||||
int version();
|
||||
|
||||
void setLogLevel(LogLevel logLevel);
|
||||
LogLevel logLevel() const;
|
||||
|
||||
|
@ -14,11 +14,12 @@
|
||||
#include <QUrlQuery>
|
||||
#include <QUuid>
|
||||
|
||||
GAnalytics::GAnalytics(const QString &trackingID, const QString &clientID, QObject *parent) : QObject(parent)
|
||||
GAnalytics::GAnalytics(const QString &trackingID, const QString &clientID, const int version, QObject *parent) : QObject(parent)
|
||||
{
|
||||
d = new GAnalyticsWorker(this);
|
||||
d->m_trackingID = trackingID;
|
||||
d->m_clientID = clientID;
|
||||
d->m_version = version;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,6 +91,11 @@ void GAnalytics::enable(bool state)
|
||||
d->enable(state);
|
||||
}
|
||||
|
||||
int GAnalytics::version()
|
||||
{
|
||||
return d->m_version;
|
||||
}
|
||||
|
||||
void GAnalytics::setNetworkAccessManager(QNetworkAccessManager *networkAccessManager)
|
||||
{
|
||||
if (d->networkManager != networkAccessManager)
|
||||
|
@ -40,6 +40,7 @@ public:
|
||||
bool m_anonymizeIPs = false;
|
||||
bool m_isEnabled = false;
|
||||
int m_timerInterval = 30000;
|
||||
int m_version = 0;
|
||||
|
||||
const static int fourHours = 4 * 60 * 60 * 1000;
|
||||
const static QLatin1String dateTimeFormat;
|
||||
|
@ -70,7 +70,6 @@ void WonkoClient::initGlobalSettings()
|
||||
m_settings->registerSetting("JavaArchitecture", "");
|
||||
m_settings->registerSetting("JavaVersion", "");
|
||||
m_settings->registerSetting("LastHostname", "");
|
||||
m_settings->registerSetting("JavaDetectionHack", "");
|
||||
m_settings->registerSetting("JvmArgs", "");
|
||||
|
||||
// Wrapper command for launch
|
||||
|
Loading…
Reference in New Issue
Block a user