diff options
Diffstat (limited to 'launcher/Application.cpp')
-rw-r--r-- | launcher/Application.cpp | 160 |
1 files changed, 12 insertions, 148 deletions
diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 958c5e3d..cbfdcbe2 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -26,7 +26,6 @@ #include "ui/setupwizard/SetupWizard.h" #include "ui/setupwizard/LanguageWizardPage.h" #include "ui/setupwizard/JavaWizardPage.h" -#include "ui/setupwizard/AnalyticsWizardPage.h" #include "ui/dialogs/CustomMessageBox.h" @@ -73,11 +72,8 @@ #include <DesktopServices.h> #include <LocalPeer.h> -#include <ganalytics.h> #include <sys.h> -#include <Secrets.h> - #if defined Q_OS_WIN32 #ifndef WIN32_LEAN_AND_MEAN @@ -308,7 +304,13 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) } else { -#if defined(Q_OS_MAC) +#ifdef LAUNCHER_LINUX_DATADIR + QString xdgDataHome = QFile::decodeName(qgetenv("XDG_DATA_HOME")); + if (xdgDataHome.isEmpty()) + xdgDataHome = QDir::homePath() + QLatin1String("/.local/share"); + dataPath = xdgDataHome + "/polymc"; + adjustedBy += "XDG standard " + dataPath; +#elif defined(Q_OS_MAC) QDir foo(FS::PathCombine(applicationDirPath(), "../../Data")); dataPath = foo.absolutePath(); adjustedBy += "Fallback to special Mac location " + dataPath; @@ -533,6 +535,10 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) FS::updateTimestamp(m_rootPath); #endif +#ifdef MULTIMC_JARS_LOCATION + m_jarsPath = TOSTRING(MULTIMC_JARS_LOCATION); +#endif + qDebug() << BuildConfig.LAUNCHER_DISPLAYNAME << ", (c) 2013-2021 " << BuildConfig.LAUNCHER_COPYRIGHT; qDebug() << "Version : " << BuildConfig.printableVersionString(); qDebug() << "Git commit : " << BuildConfig.GIT_COMMIT; @@ -711,14 +717,6 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) // paste.ee API key m_settings->registerSetting("PasteEEAPIKey", "multimc"); - if(!BuildConfig.ANALYTICS_ID.isEmpty()) - { - // Analytics - m_settings->registerSetting("Analytics", true); - m_settings->registerSetting("AnalyticsSeen", 0); - m_settings->registerSetting("AnalyticsClientID", QString()); - } - // Init page provider { m_globalSettingsProvider = std::make_shared<GenericPageProvider>(tr("Settings")); @@ -900,46 +898,6 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) qDebug() << "<> Application theme set."; } - // Initialize analytics - [this]() - { - const int analyticsVersion = 2; - if(BuildConfig.ANALYTICS_ID.isEmpty()) - { - return; - } - - auto analyticsSetting = m_settings->getSetting("Analytics"); - connect(analyticsSetting.get(), &Setting::SettingChanged, this, &Application::analyticsSettingChanged); - QString clientID = m_settings->get("AnalyticsClientID").toString(); - if(clientID.isEmpty()) - { - clientID = QUuid::createUuid().toString(); - clientID.remove(QLatin1Char('{')); - clientID.remove(QLatin1Char('}')); - m_settings->set("AnalyticsClientID", clientID); - } - m_analytics = new GAnalytics(BuildConfig.ANALYTICS_ID, clientID, analyticsVersion, this); - m_analytics->setLogLevel(GAnalytics::Debug); - m_analytics->setAnonymizeIPs(true); - // FIXME: the ganalytics library has no idea about our fancy shared pointers... - m_analytics->setNetworkAccessManager(network().get()); - - 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."; - return; - } - - m_analytics->enable(); - qDebug() << "<> Initialized analytics with tid" << BuildConfig.ANALYTICS_ID; - }(); - if(createSetupWizard()) { return; @@ -966,29 +924,13 @@ bool Application::createSetupWizard() } return false; }(); - bool analyticsRequired = [&]() - { - if(BuildConfig.ANALYTICS_ID.isEmpty()) - { - return false; - } - if (!settings()->get("Analytics").toBool()) - { - return false; - } - if (settings()->get("AnalyticsSeen").toInt() < analytics()->version()) - { - return true; - } - return false; - }(); bool languageRequired = [&]() { if (settings()->get("Language").toString().isEmpty()) return true; return false; }(); - bool wizardRequired = javaRequired || analyticsRequired || languageRequired; + bool wizardRequired = javaRequired || languageRequired; if(wizardRequired) { @@ -1001,10 +943,6 @@ bool Application::createSetupWizard() { m_setupWizard->addPage(new JavaWizardPage(m_setupWizard)); } - if(analyticsRequired) - { - m_setupWizard->addPage(new AnalyticsWizardPage(m_setupWizard)); - } connect(m_setupWizard, &QDialog::finished, this, &Application::setupWizardFinished); m_setupWizard->show(); return true; @@ -1161,22 +1099,6 @@ void Application::messageReceived(const QByteArray& message) } } -void Application::analyticsSettingChanged(const Setting&, QVariant value) -{ - if(!m_analytics) - return; - bool enabled = value.toBool(); - if(enabled) - { - qDebug() << "Analytics enabled by user."; - } - else - { - qDebug() << "Analytics disabled by user."; - } - m_analytics->enable(enabled); -} - std::shared_ptr<TranslationsModel> Application::translations() { return m_translations; @@ -1446,60 +1368,6 @@ MainWindow* Application::showMainWindow(bool minimized) connect(m_mainWindow, &MainWindow::isClosing, this, &Application::on_windowClose); m_openWindows++; } - // FIXME: move this somewhere else... - if(m_analytics) - { - auto windowSize = m_mainWindow->size(); - auto sizeString = QString("%1x%2").arg(windowSize.width()).arg(windowSize.height()); - qDebug() << "Viewport size" << sizeString; - m_analytics->setViewportSize(sizeString); - /* - * cm1 = java min heap [MB] - * cm2 = java max heap [MB] - * cm3 = system RAM [MB] - * - * cd1 = java version - * cd2 = java architecture - * cd3 = system architecture - * cd4 = CPU architecture - */ - QVariantMap customValues; - int min = m_settings->get("MinMemAlloc").toInt(); - int max = m_settings->get("MaxMemAlloc").toInt(); - if(min < max) - { - customValues["cm1"] = min; - customValues["cm2"] = max; - } - else - { - customValues["cm1"] = max; - customValues["cm2"] = min; - } - - constexpr uint64_t Mega = 1024ull * 1024ull; - int ramSize = int(Sys::getSystemRam() / Mega); - qDebug() << "RAM size is" << ramSize << "MB"; - customValues["cm3"] = ramSize; - - customValues["cd1"] = m_settings->get("JavaVersion"); - customValues["cd2"] = m_settings->get("JavaArchitecture"); - customValues["cd3"] = Sys::isSystem64bit() ? "64":"32"; - customValues["cd4"] = Sys::isCPU64bit() ? "64":"32"; - auto kernelInfo = Sys::getKernelInfo(); - customValues["cd5"] = kernelInfo.kernelName; - customValues["cd6"] = kernelInfo.kernelVersion; - auto distInfo = Sys::getDistributionInfo(); - if(!distInfo.distributionName.isEmpty()) - { - customValues["cd7"] = distInfo.distributionName; - } - if(!distInfo.distributionVersion.isEmpty()) - { - customValues["cd8"] = distInfo.distributionVersion; - } - m_analytics->sendScreenView("Main Window", customValues); - } return m_mainWindow; } @@ -1558,10 +1426,6 @@ void Application::on_windowClose() } } -QString Application::msaClientId() const { - return Secrets::getMSAClientID('-'); -} - void Application::updateProxySettings(QString proxyTypeStr, QString addr, int port, QString user, QString password) { // Set the application proxy settings. |