Added file logger
This commit is contained in:
parent
eba9b3d759
commit
f83119ce7e
@ -168,6 +168,14 @@ MultiMC.h
|
|||||||
MultiMC.cpp
|
MultiMC.cpp
|
||||||
MultiMCVersion.h
|
MultiMCVersion.h
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
logger/QsDebugOutput.cpp
|
||||||
|
logger/QsDebugOutput.h
|
||||||
|
logger/QsLog.cpp
|
||||||
|
logger/QsLog.h
|
||||||
|
logger/QsLogDest.cpp
|
||||||
|
logger/QsLogDest.h
|
||||||
|
|
||||||
# GUI
|
# GUI
|
||||||
gui/mainwindow.h
|
gui/mainwindow.h
|
||||||
gui/mainwindow.cpp
|
gui/mainwindow.cpp
|
||||||
|
34
MultiMC.cpp
34
MultiMC.cpp
@ -20,6 +20,8 @@
|
|||||||
#include "cmdutils.h"
|
#include "cmdutils.h"
|
||||||
#include <inisettingsobject.h>
|
#include <inisettingsobject.h>
|
||||||
#include <setting.h>
|
#include <setting.h>
|
||||||
|
#include <logger/QsLog.h>
|
||||||
|
#include <logger/QsLogDest.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
using namespace Util::Commandline;
|
using namespace Util::Commandline;
|
||||||
@ -123,6 +125,9 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
// change directory
|
// change directory
|
||||||
QDir::setCurrent(args["dir"].toString());
|
QDir::setCurrent(args["dir"].toString());
|
||||||
|
|
||||||
|
// init the logger
|
||||||
|
initLogger();
|
||||||
|
|
||||||
// load settings
|
// load settings
|
||||||
initGlobalSettings();
|
initGlobalSettings();
|
||||||
|
|
||||||
@ -156,11 +161,11 @@ MultiMC::~MultiMC()
|
|||||||
{
|
{
|
||||||
if (m_mmc_translator)
|
if (m_mmc_translator)
|
||||||
{
|
{
|
||||||
removeTranslator(m_mmc_translator.data());
|
removeTranslator(m_mmc_translator.get());
|
||||||
}
|
}
|
||||||
if (m_qt_translator)
|
if (m_qt_translator)
|
||||||
{
|
{
|
||||||
removeTranslator(m_qt_translator.data());
|
removeTranslator(m_qt_translator.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +177,7 @@ void MultiMC::initTranslations()
|
|||||||
{
|
{
|
||||||
std::cout << "Loading Qt Language File for "
|
std::cout << "Loading Qt Language File for "
|
||||||
<< QLocale::system().name().toLocal8Bit().constData() << "...";
|
<< QLocale::system().name().toLocal8Bit().constData() << "...";
|
||||||
if (!installTranslator(m_qt_translator.data()))
|
if (!installTranslator(m_qt_translator.get()))
|
||||||
{
|
{
|
||||||
std::cout << " failed.";
|
std::cout << " failed.";
|
||||||
m_qt_translator.reset();
|
m_qt_translator.reset();
|
||||||
@ -190,7 +195,7 @@ void MultiMC::initTranslations()
|
|||||||
{
|
{
|
||||||
std::cout << "Loading MMC Language File for "
|
std::cout << "Loading MMC Language File for "
|
||||||
<< QLocale::system().name().toLocal8Bit().constData() << "...";
|
<< QLocale::system().name().toLocal8Bit().constData() << "...";
|
||||||
if (!installTranslator(m_mmc_translator.data()))
|
if (!installTranslator(m_mmc_translator.get()))
|
||||||
{
|
{
|
||||||
std::cout << " failed.";
|
std::cout << " failed.";
|
||||||
m_mmc_translator.reset();
|
m_mmc_translator.reset();
|
||||||
@ -203,6 +208,19 @@ void MultiMC::initTranslations()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MultiMC::initLogger()
|
||||||
|
{
|
||||||
|
// init the logging mechanism
|
||||||
|
QsLogging::Logger &logger = QsLogging::Logger::instance();
|
||||||
|
logger.setLoggingLevel(QsLogging::TraceLevel);
|
||||||
|
m_fileDestination = QsLogging::DestinationFactory::MakeFileDestination("MultiMC.log");
|
||||||
|
m_debugDestination = QsLogging::DestinationFactory::MakeDebugOutputDestination();
|
||||||
|
logger.addDestination(m_fileDestination.get());
|
||||||
|
logger.addDestination(m_debugDestination.get());
|
||||||
|
// log all the things
|
||||||
|
logger.setLoggingLevel(QsLogging::TraceLevel);
|
||||||
|
}
|
||||||
|
|
||||||
void MultiMC::initGlobalSettings()
|
void MultiMC::initGlobalSettings()
|
||||||
{
|
{
|
||||||
m_settings.reset(new INISettingsObject("multimc.cfg", this));
|
m_settings.reset(new INISettingsObject("multimc.cfg", this));
|
||||||
@ -275,7 +293,7 @@ void MultiMC::initHttpMetaCache()
|
|||||||
m_metacache->Load();
|
m_metacache->Load();
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<IconList> MultiMC::icons()
|
std::shared_ptr<IconList> MultiMC::icons()
|
||||||
{
|
{
|
||||||
if (!m_icons)
|
if (!m_icons)
|
||||||
{
|
{
|
||||||
@ -284,7 +302,7 @@ QSharedPointer<IconList> MultiMC::icons()
|
|||||||
return m_icons;
|
return m_icons;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<LWJGLVersionList> MultiMC::lwjgllist()
|
std::shared_ptr<LWJGLVersionList> MultiMC::lwjgllist()
|
||||||
{
|
{
|
||||||
if (!m_lwjgllist)
|
if (!m_lwjgllist)
|
||||||
{
|
{
|
||||||
@ -293,7 +311,7 @@ QSharedPointer<LWJGLVersionList> MultiMC::lwjgllist()
|
|||||||
return m_lwjgllist;
|
return m_lwjgllist;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<ForgeVersionList> MultiMC::forgelist()
|
std::shared_ptr<ForgeVersionList> MultiMC::forgelist()
|
||||||
{
|
{
|
||||||
if (!m_forgelist)
|
if (!m_forgelist)
|
||||||
{
|
{
|
||||||
@ -302,7 +320,7 @@ QSharedPointer<ForgeVersionList> MultiMC::forgelist()
|
|||||||
return m_forgelist;
|
return m_forgelist;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<MinecraftVersionList> MultiMC::minecraftlist()
|
std::shared_ptr<MinecraftVersionList> MultiMC::minecraftlist()
|
||||||
{
|
{
|
||||||
if (!m_minecraftlist)
|
if (!m_minecraftlist)
|
||||||
{
|
{
|
||||||
|
84
MultiMC.h
84
MultiMC.h
@ -1,9 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QSharedPointer>
|
|
||||||
#include "MultiMCVersion.h"
|
#include "MultiMCVersion.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include <memory>
|
||||||
|
#include "logger/QsLog.h"
|
||||||
|
#include "logger/QsLogDest.h"
|
||||||
|
|
||||||
|
|
||||||
class MinecraftVersionList;
|
class MinecraftVersionList;
|
||||||
class LWJGLVersionList;
|
class LWJGLVersionList;
|
||||||
@ -29,67 +32,72 @@ public:
|
|||||||
Succeeded,
|
Succeeded,
|
||||||
Initialized,
|
Initialized,
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MultiMC ( int& argc, char** argv );
|
MultiMC(int &argc, char **argv);
|
||||||
virtual ~MultiMC();
|
virtual ~MultiMC();
|
||||||
|
|
||||||
QSharedPointer<SettingsObject> settings()
|
std::shared_ptr<SettingsObject> settings()
|
||||||
{
|
{
|
||||||
return m_settings;
|
return m_settings;
|
||||||
};
|
}
|
||||||
|
|
||||||
QSharedPointer<InstanceList> instances()
|
std::shared_ptr<InstanceList> instances()
|
||||||
{
|
{
|
||||||
return m_instances;
|
return m_instances;
|
||||||
};
|
}
|
||||||
|
|
||||||
QSharedPointer<IconList> icons();
|
std::shared_ptr<IconList> icons();
|
||||||
|
|
||||||
Status status()
|
Status status()
|
||||||
{
|
{
|
||||||
return m_status;
|
return m_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiMCVersion version()
|
MultiMCVersion version()
|
||||||
{
|
{
|
||||||
return m_version;
|
return m_version;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<QNetworkAccessManager> qnam()
|
std::shared_ptr<QNetworkAccessManager> qnam()
|
||||||
{
|
{
|
||||||
return m_qnam;
|
return m_qnam;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<HttpMetaCache> metacache()
|
std::shared_ptr<HttpMetaCache> metacache()
|
||||||
{
|
{
|
||||||
return m_metacache;
|
return m_metacache;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<LWJGLVersionList> lwjgllist();
|
std::shared_ptr<LWJGLVersionList> lwjgllist();
|
||||||
|
|
||||||
QSharedPointer<ForgeVersionList> forgelist();
|
std::shared_ptr<ForgeVersionList> forgelist();
|
||||||
|
|
||||||
QSharedPointer<MinecraftVersionList> minecraftlist();
|
std::shared_ptr<MinecraftVersionList> minecraftlist();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void initLogger();
|
||||||
|
|
||||||
void initGlobalSettings();
|
void initGlobalSettings();
|
||||||
|
|
||||||
void initHttpMetaCache();
|
void initHttpMetaCache();
|
||||||
|
|
||||||
void initTranslations();
|
void initTranslations();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedPointer<QTranslator> m_qt_translator;
|
std::shared_ptr<QTranslator> m_qt_translator;
|
||||||
QSharedPointer<QTranslator> m_mmc_translator;
|
std::shared_ptr<QTranslator> m_mmc_translator;
|
||||||
QSharedPointer<SettingsObject> m_settings;
|
std::shared_ptr<SettingsObject> m_settings;
|
||||||
QSharedPointer<InstanceList> m_instances;
|
std::shared_ptr<InstanceList> m_instances;
|
||||||
QSharedPointer<IconList> m_icons;
|
std::shared_ptr<IconList> m_icons;
|
||||||
QSharedPointer<QNetworkAccessManager> m_qnam;
|
std::shared_ptr<QNetworkAccessManager> m_qnam;
|
||||||
QSharedPointer<HttpMetaCache> m_metacache;
|
std::shared_ptr<HttpMetaCache> m_metacache;
|
||||||
QSharedPointer<LWJGLVersionList> m_lwjgllist;
|
std::shared_ptr<LWJGLVersionList> m_lwjgllist;
|
||||||
QSharedPointer<ForgeVersionList> m_forgelist;
|
std::shared_ptr<ForgeVersionList> m_forgelist;
|
||||||
QSharedPointer<MinecraftVersionList> m_minecraftlist;
|
std::shared_ptr<MinecraftVersionList> m_minecraftlist;
|
||||||
|
QsLogging::DestinationPtr m_fileDestination;
|
||||||
|
QsLogging::DestinationPtr m_debugDestination;
|
||||||
|
|
||||||
Status m_status = MultiMC::Failed;
|
Status m_status = MultiMC::Failed;
|
||||||
MultiMCVersion m_version = {VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_BUILD};
|
MultiMCVersion m_version = {VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_BUILD};
|
||||||
};
|
};
|
||||||
|
@ -39,7 +39,7 @@ IconPickerDialog::IconPickerDialog(QWidget *parent) :
|
|||||||
|
|
||||||
contentsWidget->installEventFilter(this);
|
contentsWidget->installEventFilter(this);
|
||||||
|
|
||||||
contentsWidget->setModel(MMC->icons().data());
|
contentsWidget->setModel(MMC->icons().get());
|
||||||
|
|
||||||
auto buttonAdd = ui->buttonBox->addButton(tr("Add Icon"),QDialogButtonBox::ResetRole);
|
auto buttonAdd = ui->buttonBox->addButton(tr("Add Icon"),QDialogButtonBox::ResetRole);
|
||||||
auto buttonRemove = ui->buttonBox->addButton(tr("Remove Icon"),QDialogButtonBox::ResetRole);
|
auto buttonRemove = ui->buttonBox->addButton(tr("Remove Icon"),QDialogButtonBox::ResetRole);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
@ -28,49 +28,47 @@
|
|||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
|
||||||
LegacyModEditDialog::LegacyModEditDialog( LegacyInstance* inst, QWidget* parent ) :
|
LegacyModEditDialog::LegacyModEditDialog(LegacyInstance *inst, QWidget *parent)
|
||||||
m_inst(inst),
|
: m_inst(inst), QDialog(parent), ui(new Ui::LegacyModEditDialog)
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::LegacyModEditDialog)
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
// Jar mods
|
// Jar mods
|
||||||
{
|
{
|
||||||
ensureFolderPathExists(m_inst->jarModsDir());
|
ensureFolderPathExists(m_inst->jarModsDir());
|
||||||
m_jarmods = m_inst->jarModList();
|
m_jarmods = m_inst->jarModList();
|
||||||
ui->jarModsTreeView->setModel(m_jarmods.data());
|
ui->jarModsTreeView->setModel(m_jarmods.get());
|
||||||
#ifndef Q_OS_LINUX
|
#ifndef Q_OS_LINUX
|
||||||
// FIXME: internal DnD causes segfaults later
|
// FIXME: internal DnD causes segfaults later
|
||||||
ui->jarModsTreeView->setDragDropMode(QAbstractItemView::DragDrop);
|
ui->jarModsTreeView->setDragDropMode(QAbstractItemView::DragDrop);
|
||||||
// FIXME: DnD is glitched with contiguous (we move only first item in selection)
|
// FIXME: DnD is glitched with contiguous (we move only first item in selection)
|
||||||
ui->jarModsTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
|
ui->jarModsTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
#endif
|
#endif
|
||||||
ui->jarModsTreeView->installEventFilter( this );
|
ui->jarModsTreeView->installEventFilter(this);
|
||||||
m_jarmods->startWatching();
|
m_jarmods->startWatching();
|
||||||
}
|
}
|
||||||
// Core mods
|
// Core mods
|
||||||
{
|
{
|
||||||
ensureFolderPathExists(m_inst->coreModsDir());
|
ensureFolderPathExists(m_inst->coreModsDir());
|
||||||
m_coremods = m_inst->coreModList();
|
m_coremods = m_inst->coreModList();
|
||||||
ui->coreModsTreeView->setModel(m_coremods.data());
|
ui->coreModsTreeView->setModel(m_coremods.get());
|
||||||
ui->coreModsTreeView->installEventFilter( this );
|
ui->coreModsTreeView->installEventFilter(this);
|
||||||
m_coremods->startWatching();
|
m_coremods->startWatching();
|
||||||
}
|
}
|
||||||
// Loader mods
|
// Loader mods
|
||||||
{
|
{
|
||||||
ensureFolderPathExists(m_inst->loaderModsDir());
|
ensureFolderPathExists(m_inst->loaderModsDir());
|
||||||
m_mods = m_inst->loaderModList();
|
m_mods = m_inst->loaderModList();
|
||||||
ui->loaderModTreeView->setModel(m_mods.data());
|
ui->loaderModTreeView->setModel(m_mods.get());
|
||||||
ui->loaderModTreeView->installEventFilter( this );
|
ui->loaderModTreeView->installEventFilter(this);
|
||||||
m_mods->startWatching();
|
m_mods->startWatching();
|
||||||
}
|
}
|
||||||
// texture packs
|
// texture packs
|
||||||
{
|
{
|
||||||
ensureFolderPathExists(m_inst->texturePacksDir());
|
ensureFolderPathExists(m_inst->texturePacksDir());
|
||||||
m_texturepacks = m_inst->texturePackList();
|
m_texturepacks = m_inst->texturePackList();
|
||||||
ui->texPackTreeView->setModel(m_texturepacks.data());
|
ui->texPackTreeView->setModel(m_texturepacks.get());
|
||||||
ui->texPackTreeView->installEventFilter( this );
|
ui->texPackTreeView->installEventFilter(this);
|
||||||
m_texturepacks->startWatching();
|
m_texturepacks->startWatching();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,113 +82,111 @@ LegacyModEditDialog::~LegacyModEditDialog()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LegacyModEditDialog::coreListFilter ( QKeyEvent* keyEvent )
|
bool LegacyModEditDialog::coreListFilter(QKeyEvent *keyEvent)
|
||||||
{
|
{
|
||||||
switch(keyEvent->key())
|
switch (keyEvent->key())
|
||||||
{
|
{
|
||||||
case Qt::Key_Delete:
|
case Qt::Key_Delete:
|
||||||
on_rmCoreBtn_clicked();
|
on_rmCoreBtn_clicked();
|
||||||
return true;
|
return true;
|
||||||
case Qt::Key_Plus:
|
case Qt::Key_Plus:
|
||||||
on_addCoreBtn_clicked();
|
on_addCoreBtn_clicked();
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return QDialog::eventFilter( ui->coreModsTreeView, keyEvent );
|
return QDialog::eventFilter(ui->coreModsTreeView, keyEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LegacyModEditDialog::jarListFilter ( QKeyEvent* keyEvent )
|
bool LegacyModEditDialog::jarListFilter(QKeyEvent *keyEvent)
|
||||||
{
|
{
|
||||||
switch(keyEvent->key())
|
switch (keyEvent->key())
|
||||||
{
|
{
|
||||||
case Qt::Key_Up:
|
case Qt::Key_Up:
|
||||||
|
{
|
||||||
|
if (keyEvent->modifiers() & Qt::ControlModifier)
|
||||||
{
|
{
|
||||||
if(keyEvent->modifiers() & Qt::ControlModifier)
|
on_moveJarUpBtn_clicked();
|
||||||
{
|
return true;
|
||||||
on_moveJarUpBtn_clicked();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case Qt::Key_Down:
|
break;
|
||||||
|
}
|
||||||
|
case Qt::Key_Down:
|
||||||
|
{
|
||||||
|
if (keyEvent->modifiers() & Qt::ControlModifier)
|
||||||
{
|
{
|
||||||
if(keyEvent->modifiers() & Qt::ControlModifier)
|
on_moveJarDownBtn_clicked();
|
||||||
{
|
return true;
|
||||||
on_moveJarDownBtn_clicked();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case Qt::Key_Delete:
|
break;
|
||||||
on_rmJarBtn_clicked();
|
|
||||||
return true;
|
|
||||||
case Qt::Key_Plus:
|
|
||||||
on_addJarBtn_clicked();
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return QDialog::eventFilter( ui->jarModsTreeView, keyEvent );
|
case Qt::Key_Delete:
|
||||||
|
on_rmJarBtn_clicked();
|
||||||
|
return true;
|
||||||
|
case Qt::Key_Plus:
|
||||||
|
on_addJarBtn_clicked();
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return QDialog::eventFilter(ui->jarModsTreeView, keyEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LegacyModEditDialog::loaderListFilter ( QKeyEvent* keyEvent )
|
bool LegacyModEditDialog::loaderListFilter(QKeyEvent *keyEvent)
|
||||||
{
|
{
|
||||||
switch(keyEvent->key())
|
switch (keyEvent->key())
|
||||||
{
|
{
|
||||||
case Qt::Key_Delete:
|
case Qt::Key_Delete:
|
||||||
on_rmModBtn_clicked();
|
on_rmModBtn_clicked();
|
||||||
return true;
|
return true;
|
||||||
case Qt::Key_Plus:
|
case Qt::Key_Plus:
|
||||||
on_addModBtn_clicked();
|
on_addModBtn_clicked();
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return QDialog::eventFilter( ui->loaderModTreeView, keyEvent );
|
return QDialog::eventFilter(ui->loaderModTreeView, keyEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LegacyModEditDialog::texturePackListFilter ( QKeyEvent* keyEvent )
|
bool LegacyModEditDialog::texturePackListFilter(QKeyEvent *keyEvent)
|
||||||
{
|
{
|
||||||
switch(keyEvent->key())
|
switch (keyEvent->key())
|
||||||
{
|
{
|
||||||
case Qt::Key_Delete:
|
case Qt::Key_Delete:
|
||||||
on_rmTexPackBtn_clicked();
|
on_rmTexPackBtn_clicked();
|
||||||
return true;
|
return true;
|
||||||
case Qt::Key_Plus:
|
case Qt::Key_Plus:
|
||||||
on_addTexPackBtn_clicked();
|
on_addTexPackBtn_clicked();
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return QDialog::eventFilter( ui->texPackTreeView, keyEvent );
|
return QDialog::eventFilter(ui->texPackTreeView, keyEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LegacyModEditDialog::eventFilter(QObject *obj, QEvent *ev)
|
||||||
bool LegacyModEditDialog::eventFilter ( QObject* obj, QEvent* ev )
|
|
||||||
{
|
{
|
||||||
if (ev->type() != QEvent::KeyPress)
|
if (ev->type() != QEvent::KeyPress)
|
||||||
{
|
{
|
||||||
return QDialog::eventFilter( obj, ev );
|
return QDialog::eventFilter(obj, ev);
|
||||||
}
|
}
|
||||||
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(ev);
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(ev);
|
||||||
if(obj == ui->jarModsTreeView)
|
if (obj == ui->jarModsTreeView)
|
||||||
return jarListFilter(keyEvent);
|
return jarListFilter(keyEvent);
|
||||||
if(obj == ui->coreModsTreeView)
|
if (obj == ui->coreModsTreeView)
|
||||||
return coreListFilter(keyEvent);
|
return coreListFilter(keyEvent);
|
||||||
if(obj == ui->loaderModTreeView)
|
if (obj == ui->loaderModTreeView)
|
||||||
return loaderListFilter(keyEvent);
|
return loaderListFilter(keyEvent);
|
||||||
if(obj == ui->texPackTreeView)
|
if (obj == ui->texPackTreeView)
|
||||||
return texturePackListFilter(keyEvent);
|
return texturePackListFilter(keyEvent);
|
||||||
return QDialog::eventFilter( obj, ev );
|
return QDialog::eventFilter(obj, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LegacyModEditDialog::on_addCoreBtn_clicked()
|
void LegacyModEditDialog::on_addCoreBtn_clicked()
|
||||||
{
|
{
|
||||||
//: Title of core mod selection dialog
|
//: Title of core mod selection dialog
|
||||||
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select Core Mods"));
|
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select Core Mods"));
|
||||||
for(auto filename:fileNames)
|
for (auto filename : fileNames)
|
||||||
{
|
{
|
||||||
m_coremods->stopWatching();
|
m_coremods->stopWatching();
|
||||||
m_coremods->installMod(QFileInfo(filename));
|
m_coremods->installMod(QFileInfo(filename));
|
||||||
@ -199,21 +195,22 @@ void LegacyModEditDialog::on_addCoreBtn_clicked()
|
|||||||
}
|
}
|
||||||
void LegacyModEditDialog::on_addForgeBtn_clicked()
|
void LegacyModEditDialog::on_addForgeBtn_clicked()
|
||||||
{
|
{
|
||||||
VersionSelectDialog vselect(MMC->forgelist().data(), this);
|
VersionSelectDialog vselect(MMC->forgelist().get(), this);
|
||||||
vselect.setFilter(1, m_inst->intendedVersionId());
|
vselect.setFilter(1, m_inst->intendedVersionId());
|
||||||
if (vselect.exec() && vselect.selectedVersion())
|
if (vselect.exec() && vselect.selectedVersion())
|
||||||
{
|
{
|
||||||
ForgeVersionPtr forge = vselect.selectedVersion().dynamicCast<ForgeVersion>();
|
ForgeVersionPtr forge =
|
||||||
if(!forge)
|
std::dynamic_pointer_cast<ForgeVersion> (vselect.selectedVersion());
|
||||||
|
if (!forge)
|
||||||
return;
|
return;
|
||||||
auto entry = MMC->metacache()->resolveEntry("minecraftforge", forge->filename);
|
auto entry = MMC->metacache()->resolveEntry("minecraftforge", forge->filename);
|
||||||
if(entry->stale)
|
if (entry->stale)
|
||||||
{
|
{
|
||||||
DownloadJob * fjob = new DownloadJob("Forge download");
|
DownloadJob *fjob = new DownloadJob("Forge download");
|
||||||
fjob->addCacheDownload(forge->universal_url, entry);
|
fjob->addCacheDownload(forge->universal_url, entry);
|
||||||
ProgressDialog dlg(this);
|
ProgressDialog dlg(this);
|
||||||
dlg.exec(fjob);
|
dlg.exec(fjob);
|
||||||
if(dlg.result() == QDialog::Accepted)
|
if (dlg.result() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
m_jarmods->stopWatching();
|
m_jarmods->stopWatching();
|
||||||
m_jarmods->installMod(QFileInfo(entry->getFullPath()));
|
m_jarmods->installMod(QFileInfo(entry->getFullPath()));
|
||||||
@ -236,7 +233,7 @@ void LegacyModEditDialog::on_addJarBtn_clicked()
|
|||||||
{
|
{
|
||||||
//: Title of jar mod selection dialog
|
//: Title of jar mod selection dialog
|
||||||
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select Jar Mods"));
|
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select Jar Mods"));
|
||||||
for(auto filename:fileNames)
|
for (auto filename : fileNames)
|
||||||
{
|
{
|
||||||
m_jarmods->stopWatching();
|
m_jarmods->stopWatching();
|
||||||
m_jarmods->installMod(QFileInfo(filename));
|
m_jarmods->installMod(QFileInfo(filename));
|
||||||
@ -247,7 +244,7 @@ void LegacyModEditDialog::on_addModBtn_clicked()
|
|||||||
{
|
{
|
||||||
//: Title of regular mod selection dialog
|
//: Title of regular mod selection dialog
|
||||||
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select Loader Mods"));
|
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select Loader Mods"));
|
||||||
for(auto filename:fileNames)
|
for (auto filename : fileNames)
|
||||||
{
|
{
|
||||||
m_mods->stopWatching();
|
m_mods->stopWatching();
|
||||||
m_mods->installMod(QFileInfo(filename));
|
m_mods->installMod(QFileInfo(filename));
|
||||||
@ -258,7 +255,7 @@ void LegacyModEditDialog::on_addTexPackBtn_clicked()
|
|||||||
{
|
{
|
||||||
//: Title of texture pack selection dialog
|
//: Title of texture pack selection dialog
|
||||||
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select Texture Packs"));
|
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select Texture Packs"));
|
||||||
for(auto filename:fileNames)
|
for (auto filename : fileNames)
|
||||||
{
|
{
|
||||||
m_texturepacks->stopWatching();
|
m_texturepacks->stopWatching();
|
||||||
m_texturepacks->installMod(QFileInfo(filename));
|
m_texturepacks->installMod(QFileInfo(filename));
|
||||||
@ -270,8 +267,8 @@ void LegacyModEditDialog::on_moveJarDownBtn_clicked()
|
|||||||
{
|
{
|
||||||
int first, last;
|
int first, last;
|
||||||
auto list = ui->jarModsTreeView->selectionModel()->selectedRows();
|
auto list = ui->jarModsTreeView->selectionModel()->selectedRows();
|
||||||
|
|
||||||
if(!lastfirst(list, first, last))
|
if (!lastfirst(list, first, last))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_jarmods->moveModsDown(first, last);
|
m_jarmods->moveModsDown(first, last);
|
||||||
@ -280,8 +277,8 @@ void LegacyModEditDialog::on_moveJarUpBtn_clicked()
|
|||||||
{
|
{
|
||||||
int first, last;
|
int first, last;
|
||||||
auto list = ui->jarModsTreeView->selectionModel()->selectedRows();
|
auto list = ui->jarModsTreeView->selectionModel()->selectedRows();
|
||||||
|
|
||||||
if(!lastfirst(list, first, last))
|
if (!lastfirst(list, first, last))
|
||||||
return;
|
return;
|
||||||
m_jarmods->moveModsUp(first, last);
|
m_jarmods->moveModsUp(first, last);
|
||||||
}
|
}
|
||||||
@ -289,8 +286,8 @@ void LegacyModEditDialog::on_rmCoreBtn_clicked()
|
|||||||
{
|
{
|
||||||
int first, last;
|
int first, last;
|
||||||
auto list = ui->coreModsTreeView->selectionModel()->selectedRows();
|
auto list = ui->coreModsTreeView->selectionModel()->selectedRows();
|
||||||
|
|
||||||
if(!lastfirst(list, first, last))
|
if (!lastfirst(list, first, last))
|
||||||
return;
|
return;
|
||||||
m_coremods->stopWatching();
|
m_coremods->stopWatching();
|
||||||
m_coremods->deleteMods(first, last);
|
m_coremods->deleteMods(first, last);
|
||||||
@ -300,8 +297,8 @@ void LegacyModEditDialog::on_rmJarBtn_clicked()
|
|||||||
{
|
{
|
||||||
int first, last;
|
int first, last;
|
||||||
auto list = ui->jarModsTreeView->selectionModel()->selectedRows();
|
auto list = ui->jarModsTreeView->selectionModel()->selectedRows();
|
||||||
|
|
||||||
if(!lastfirst(list, first, last))
|
if (!lastfirst(list, first, last))
|
||||||
return;
|
return;
|
||||||
m_jarmods->stopWatching();
|
m_jarmods->stopWatching();
|
||||||
m_jarmods->deleteMods(first, last);
|
m_jarmods->deleteMods(first, last);
|
||||||
@ -311,8 +308,8 @@ void LegacyModEditDialog::on_rmModBtn_clicked()
|
|||||||
{
|
{
|
||||||
int first, last;
|
int first, last;
|
||||||
auto list = ui->loaderModTreeView->selectionModel()->selectedRows();
|
auto list = ui->loaderModTreeView->selectionModel()->selectedRows();
|
||||||
|
|
||||||
if(!lastfirst(list, first, last))
|
if (!lastfirst(list, first, last))
|
||||||
return;
|
return;
|
||||||
m_mods->stopWatching();
|
m_mods->stopWatching();
|
||||||
m_mods->deleteMods(first, last);
|
m_mods->deleteMods(first, last);
|
||||||
@ -322,8 +319,8 @@ void LegacyModEditDialog::on_rmTexPackBtn_clicked()
|
|||||||
{
|
{
|
||||||
int first, last;
|
int first, last;
|
||||||
auto list = ui->texPackTreeView->selectionModel()->selectedRows();
|
auto list = ui->texPackTreeView->selectionModel()->selectedRows();
|
||||||
|
|
||||||
if(!lastfirst(list, first, last))
|
if (!lastfirst(list, first, last))
|
||||||
return;
|
return;
|
||||||
m_texturepacks->stopWatching();
|
m_texturepacks->stopWatching();
|
||||||
m_texturepacks->deleteMods(first, last);
|
m_texturepacks->deleteMods(first, last);
|
||||||
@ -342,7 +339,6 @@ void LegacyModEditDialog::on_viewTexPackBtn_clicked()
|
|||||||
openDirInDefaultProgram(m_inst->texturePacksDir(), true);
|
openDirInDefaultProgram(m_inst->texturePacksDir(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LegacyModEditDialog::on_buttonBox_rejected()
|
void LegacyModEditDialog::on_buttonBox_rejected()
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
|
@ -60,10 +60,10 @@ protected:
|
|||||||
bool texturePackListFilter( QKeyEvent* ev );
|
bool texturePackListFilter( QKeyEvent* ev );
|
||||||
private:
|
private:
|
||||||
Ui::LegacyModEditDialog *ui;
|
Ui::LegacyModEditDialog *ui;
|
||||||
QSharedPointer<ModList> m_mods;
|
std::shared_ptr<ModList> m_mods;
|
||||||
QSharedPointer<ModList> m_coremods;
|
std::shared_ptr<ModList> m_coremods;
|
||||||
QSharedPointer<ModList> m_jarmods;
|
std::shared_ptr<ModList> m_jarmods;
|
||||||
QSharedPointer<ModList> m_texturepacks;
|
std::shared_ptr<ModList> m_texturepacks;
|
||||||
LegacyInstance * m_inst;
|
LegacyInstance * m_inst;
|
||||||
DownloadJobPtr forgeJob;
|
DownloadJobPtr forgeJob;
|
||||||
};
|
};
|
||||||
|
@ -42,7 +42,7 @@ OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent)
|
|||||||
{
|
{
|
||||||
main_model = new EnabledItemFilter(this);
|
main_model = new EnabledItemFilter(this);
|
||||||
main_model->setActive(true);
|
main_model->setActive(true);
|
||||||
main_model->setSourceModel(m_version.data());
|
main_model->setSourceModel(m_version.get());
|
||||||
ui->libraryTreeView->setModel(main_model);
|
ui->libraryTreeView->setModel(main_model);
|
||||||
ui->libraryTreeView->installEventFilter(this);
|
ui->libraryTreeView->installEventFilter(this);
|
||||||
ui->mainClassEdit->setText(m_version->mainClass);
|
ui->mainClassEdit->setText(m_version->mainClass);
|
||||||
@ -56,7 +56,7 @@ OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent)
|
|||||||
{
|
{
|
||||||
ensureFolderPathExists(m_inst->loaderModsDir());
|
ensureFolderPathExists(m_inst->loaderModsDir());
|
||||||
m_mods = m_inst->loaderModList();
|
m_mods = m_inst->loaderModList();
|
||||||
ui->loaderModTreeView->setModel(m_mods.data());
|
ui->loaderModTreeView->setModel(m_mods.get());
|
||||||
ui->loaderModTreeView->installEventFilter(this);
|
ui->loaderModTreeView->installEventFilter(this);
|
||||||
m_mods->startWatching();
|
m_mods->startWatching();
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent)
|
|||||||
{
|
{
|
||||||
ensureFolderPathExists(m_inst->resourcePacksDir());
|
ensureFolderPathExists(m_inst->resourcePacksDir());
|
||||||
m_resourcepacks = m_inst->resourcePackList();
|
m_resourcepacks = m_inst->resourcePackList();
|
||||||
ui->resPackTreeView->setModel(m_resourcepacks.data());
|
ui->resPackTreeView->setModel(m_resourcepacks.get());
|
||||||
ui->resPackTreeView->installEventFilter(this);
|
ui->resPackTreeView->installEventFilter(this);
|
||||||
m_resourcepacks->startWatching();
|
m_resourcepacks->startWatching();
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ void OneSixModEditDialog::on_customizeBtn_clicked()
|
|||||||
if (m_inst->customizeVersion())
|
if (m_inst->customizeVersion())
|
||||||
{
|
{
|
||||||
m_version = m_inst->getFullVersion();
|
m_version = m_inst->getFullVersion();
|
||||||
main_model->setSourceModel(m_version.data());
|
main_model->setSourceModel(m_version.get());
|
||||||
updateVersionControls();
|
updateVersionControls();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ void OneSixModEditDialog::on_revertBtn_clicked()
|
|||||||
if (m_inst->revertCustomVersion())
|
if (m_inst->revertCustomVersion())
|
||||||
{
|
{
|
||||||
m_version = m_inst->getFullVersion();
|
m_version = m_inst->getFullVersion();
|
||||||
main_model->setSourceModel(m_version.data());
|
main_model->setSourceModel(m_version.get());
|
||||||
updateVersionControls();
|
updateVersionControls();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ void OneSixModEditDialog::on_revertBtn_clicked()
|
|||||||
|
|
||||||
void OneSixModEditDialog::on_forgeBtn_clicked()
|
void OneSixModEditDialog::on_forgeBtn_clicked()
|
||||||
{
|
{
|
||||||
VersionSelectDialog vselect(MMC->forgelist().data(), this);
|
VersionSelectDialog vselect(MMC->forgelist().get(), this);
|
||||||
vselect.setFilter(1, m_inst->currentVersionId());
|
vselect.setFilter(1, m_inst->currentVersionId());
|
||||||
if (vselect.exec() && vselect.selectedVersion())
|
if (vselect.exec() && vselect.selectedVersion())
|
||||||
{
|
{
|
||||||
@ -139,7 +139,7 @@ void OneSixModEditDialog::on_forgeBtn_clicked()
|
|||||||
m_inst->customizeVersion();
|
m_inst->customizeVersion();
|
||||||
{
|
{
|
||||||
m_version = m_inst->getFullVersion();
|
m_version = m_inst->getFullVersion();
|
||||||
main_model->setSourceModel(m_version.data());
|
main_model->setSourceModel(m_version.get());
|
||||||
updateVersionControls();
|
updateVersionControls();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -150,10 +150,11 @@ void OneSixModEditDialog::on_forgeBtn_clicked()
|
|||||||
{
|
{
|
||||||
m_inst->customizeVersion();
|
m_inst->customizeVersion();
|
||||||
m_version = m_inst->getFullVersion();
|
m_version = m_inst->getFullVersion();
|
||||||
main_model->setSourceModel(m_version.data());
|
main_model->setSourceModel(m_version.get());
|
||||||
updateVersionControls();
|
updateVersionControls();
|
||||||
}
|
}
|
||||||
ForgeVersionPtr forgeVersion = vselect.selectedVersion().dynamicCast<ForgeVersion>();
|
ForgeVersionPtr forgeVersion =
|
||||||
|
std::dynamic_pointer_cast<ForgeVersion>(vselect.selectedVersion());
|
||||||
if (!forgeVersion)
|
if (!forgeVersion)
|
||||||
return;
|
return;
|
||||||
auto entry = MMC->metacache()->resolveEntry("minecraftforge", forgeVersion->filename);
|
auto entry = MMC->metacache()->resolveEntry("minecraftforge", forgeVersion->filename);
|
||||||
|
@ -52,9 +52,9 @@ protected:
|
|||||||
bool resourcePackListFilter( QKeyEvent* ev );
|
bool resourcePackListFilter( QKeyEvent* ev );
|
||||||
private:
|
private:
|
||||||
Ui::OneSixModEditDialog *ui;
|
Ui::OneSixModEditDialog *ui;
|
||||||
QSharedPointer<OneSixVersion> m_version;
|
std::shared_ptr<OneSixVersion> m_version;
|
||||||
QSharedPointer<ModList> m_mods;
|
std::shared_ptr<ModList> m_mods;
|
||||||
QSharedPointer<ModList> m_resourcepacks;
|
std::shared_ptr<ModList> m_resourcepacks;
|
||||||
EnabledItemFilter * main_model;
|
EnabledItemFilter * main_model;
|
||||||
OneSixInstance * m_inst;
|
OneSixInstance * m_inst;
|
||||||
};
|
};
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>450</width>
|
<width>450</width>
|
||||||
<height>400</height>
|
<height>429</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
@ -101,7 +101,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>432</width>
|
<width>432</width>
|
||||||
<height>159</height>
|
<height>179</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
@ -159,8 +159,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>98</width>
|
<width>682</width>
|
||||||
<height>93</height>
|
<height>584</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
@ -176,10 +176,10 @@
|
|||||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||||
p, li { white-space: pre-wrap; }
|
p, li { white-space: pre-wrap; }
|
||||||
</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;">
|
</style></head><body style=" font-family:'Bitstream Vera Sans'; font-size:11pt; font-weight:400; font-style:normal;">
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">Andrew Okin &lt;</span><a href="mailto:forkk@forkk.net"><span style=" font-family:'Ubuntu'; font-size:11pt; text-decoration: underline; color:#0000ff;">forkk@forkk.net</span></a><span style=" font-family:'Ubuntu'; font-size:11pt;">&gt;</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">Andrew Okin &lt;</span><a href="mailto:forkk@forkk.net"><span style=" font-family:'Ubuntu'; text-decoration: underline; color:#0000ff;">forkk@forkk.net</span></a><span style=" font-family:'Ubuntu';">&gt;</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">Petr Mrázek &lt;</span><a href="mailto:peterix@gmail.com"><span style=" font-family:'Ubuntu'; font-size:11pt; text-decoration: underline; color:#0000ff;">peterix@gmail.com</span></a><span style=" font-family:'Ubuntu'; font-size:11pt;">&gt;</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">Petr Mrázek &lt;</span><a href="mailto:peterix@gmail.com"><span style=" font-family:'Ubuntu'; text-decoration: underline; color:#0000ff;">peterix@gmail.com</span></a><span style=" font-family:'Ubuntu';">&gt;</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">Orochimarufan &lt;</span><a href="mailto:orochimarufan.x3@gmail.com"><span style=" font-family:'Ubuntu'; font-size:11pt; text-decoration: underline; color:#0000ff;">orochimarufan.x3@gmail.com</span></a><span style=" font-family:'Ubuntu'; font-size:11pt;">&gt;</span></p></body></html></string>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">Orochimarufan &lt;</span><a href="mailto:orochimarufan.x3@gmail.com"><span style=" font-family:'Ubuntu'; text-decoration: underline; color:#0000ff;">orochimarufan.x3@gmail.com</span></a><span style=" font-family:'Ubuntu';">&gt;</span></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -190,8 +190,8 @@ p, li { white-space: pre-wrap; }
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>98</width>
|
<width>682</width>
|
||||||
<height>93</height>
|
<height>584</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
@ -213,44 +213,45 @@ p, li { white-space: pre-wrap; }
|
|||||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||||
p, li { white-space: pre-wrap; }
|
p, li { white-space: pre-wrap; }
|
||||||
</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;">
|
</style></head><body style=" font-family:'Bitstream Vera Sans'; font-size:11pt; font-weight:400; font-style:normal;">
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">Copyright 2012 MultiMC Contributors</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">Copyright 2012 MultiMC Contributors</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">you may not use this file except in compliance with the License.</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">you may not use this file except in compliance with the License.</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">You may obtain a copy of the License at</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">You may obtain a copy of the License at</span></p>
|
||||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu';"><br /></p>
|
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:10pt;"><br /></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';"> http://www.apache.org/licenses/LICENSE-2.0</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;"> http://www.apache.org/licenses/LICENSE-2.0</span></p>
|
||||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu';"><br /></p>
|
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:10pt;"><br /></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">Unless required by applicable law or agreed to in writing, software</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">Unless required by applicable law or agreed to in writing, software</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">distributed under the License is distributed on an &quot;AS IS&quot; BASIS,</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">distributed under the License is distributed on an &quot;AS IS&quot; BASIS,</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">See the License for the specific language governing permissions and</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">See the License for the specific language governing permissions and</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">limitations under the License.</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">limitations under the License.</span></p>
|
||||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu';"><br /></p>
|
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:10pt;"><br /></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">MultiMC uses bspatch, </span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">MultiMC uses QSLog, </span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">Copyright 2003-2005 Colin Percival</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">Copyright (c) 2010, Razvan Petru</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">All rights reserved</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">All rights reserved.</span></p>
|
||||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu';"><br /></p>
|
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:10pt;"><br /></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">Redistribution and use in source and binary forms, with or without</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">Redistribution and use in source and binary forms, with or without modification,</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">modification, are permitted providing that the following conditions</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">are permitted provided that the following conditions are met:</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">are met: </span></p>
|
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:10pt;"><br /></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">1. Redistributions of source code must retain the above copyright</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">* Redistributions of source code must retain the above copyright notice, this</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';"> notice, this list of conditions and the following disclaimer.</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;"> list of conditions and the following disclaimer.</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">2. Redistributions in binary form must reproduce the above copyright</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">* Redistributions in binary form must reproduce the above copyright notice, this</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';"> notice, this list of conditions and the following disclaimer in the</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;"> list of conditions and the following disclaimer in the documentation and/or other</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';"> documentation and/or other materials provided with the distribution.</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;"> materials provided with the distribution.</span></p>
|
||||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu';"><br /></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">* The name of the contributors may not be used to endorse or promote products</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;"> derived from this software without specific prior written permission.</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED</span></p>
|
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:10pt;"><br /></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS IS&quot; AND</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">POSSIBILITY OF SUCH DAMAGE.</span></p></body></html></string>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED</span></p>
|
||||||
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">OF THE POSSIBILITY OF SUCH DAMAGE.</span></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include "logindialog.h"
|
#include "logindialog.h"
|
||||||
#include "ui_logindialog.h"
|
#include "ui_logindialog.h"
|
||||||
#include "keyring.h"
|
#include "keyring.h"
|
||||||
#include <QDebug>
|
#include <logger/QsLog.h>
|
||||||
|
|
||||||
LoginDialog::LoginDialog(QWidget *parent, const QString& loginErrMsg) :
|
LoginDialog::LoginDialog(QWidget *parent, const QString& loginErrMsg) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
@ -109,7 +109,7 @@ void LoginDialog::passwordToggled ( bool state )
|
|||||||
blockToggles = true;
|
blockToggles = true;
|
||||||
if(!state)
|
if(!state)
|
||||||
{
|
{
|
||||||
qDebug() << "password disabled";
|
QLOG_DEBUG() << "password disabled";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -117,7 +117,7 @@ void LoginDialog::passwordToggled ( bool state )
|
|||||||
{
|
{
|
||||||
ui->rememberUsernameCheckbox->setChecked(true);
|
ui->rememberUsernameCheckbox->setChecked(true);
|
||||||
}
|
}
|
||||||
qDebug() << "password enabled";
|
QLOG_DEBUG() << "password enabled";
|
||||||
}
|
}
|
||||||
blockToggles = false;
|
blockToggles = false;
|
||||||
}
|
}
|
||||||
@ -134,11 +134,11 @@ void LoginDialog::usernameToggled ( bool state )
|
|||||||
{
|
{
|
||||||
ui->rememberPasswordCheckbox->setChecked(false);
|
ui->rememberPasswordCheckbox->setChecked(false);
|
||||||
}
|
}
|
||||||
qDebug() << "username disabled";
|
QLOG_DEBUG() << "username disabled";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug() << "username enabled";
|
QLOG_DEBUG() << "username enabled";
|
||||||
}
|
}
|
||||||
blockToggles = false;
|
blockToggles = false;
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,10 @@ LWJGLSelectDialog::LWJGLSelectDialog(QWidget *parent) :
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->labelStatus->setVisible(false);
|
ui->labelStatus->setVisible(false);
|
||||||
auto lwjgllist = MMC->lwjgllist();
|
auto lwjgllist = MMC->lwjgllist();
|
||||||
ui->lwjglListView->setModel(lwjgllist.data());
|
ui->lwjglListView->setModel(lwjgllist.get());
|
||||||
|
|
||||||
connect(lwjgllist.data(), SIGNAL(loadingStateUpdated(bool)), SLOT(loadingStateUpdated(bool)));
|
connect(lwjgllist.get(), SIGNAL(loadingStateUpdated(bool)), SLOT(loadingStateUpdated(bool)));
|
||||||
connect(lwjgllist.data(), SIGNAL(loadListFailed(QString)), SLOT(loadingFailed(QString)));
|
connect(lwjgllist.get(), SIGNAL(loadListFailed(QString)), SLOT(loadingFailed(QString)));
|
||||||
loadingStateUpdated(lwjgllist->isLoading());
|
loadingStateUpdated(lwjgllist->isLoading());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,20 +68,19 @@
|
|||||||
#include "LabeledToolButton.h"
|
#include "LabeledToolButton.h"
|
||||||
#include "EditNotesDialog.h"
|
#include "EditNotesDialog.h"
|
||||||
|
|
||||||
MainWindow::MainWindow ( QWidget *parent )
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
|
||||||
:QMainWindow ( parent ), ui ( new Ui::MainWindow )
|
|
||||||
{
|
{
|
||||||
ui->setupUi ( this );
|
ui->setupUi(this);
|
||||||
setWindowTitle ( QString ( "MultiMC %1" ).arg ( MMC->version().toString() ) );
|
setWindowTitle(QString("MultiMC %1").arg(MMC->version().toString()));
|
||||||
|
|
||||||
// Set the selected instance to null
|
// Set the selected instance to null
|
||||||
m_selectedInstance = nullptr;
|
m_selectedInstance = nullptr;
|
||||||
// Set active instance to null.
|
// Set active instance to null.
|
||||||
m_activeInst = nullptr;
|
m_activeInst = nullptr;
|
||||||
|
|
||||||
// OSX magic.
|
// OSX magic.
|
||||||
setUnifiedTitleAndToolBarOnMac(true);
|
setUnifiedTitleAndToolBarOnMac(true);
|
||||||
|
|
||||||
// The instance action toolbar customizations
|
// The instance action toolbar customizations
|
||||||
{
|
{
|
||||||
ui->instanceToolBar->setEnabled(false);
|
ui->instanceToolBar->setEnabled(false);
|
||||||
@ -92,44 +91,45 @@ MainWindow::MainWindow ( QWidget *parent )
|
|||||||
connect(renameButton, SIGNAL(clicked(bool)), SLOT(on_actionRenameInstance_triggered()));
|
connect(renameButton, SIGNAL(clicked(bool)), SLOT(on_actionRenameInstance_triggered()));
|
||||||
ui->instanceToolBar->insertWidget(ui->actionLaunchInstance, renameButton);
|
ui->instanceToolBar->insertWidget(ui->actionLaunchInstance, renameButton);
|
||||||
ui->instanceToolBar->insertSeparator(ui->actionLaunchInstance);
|
ui->instanceToolBar->insertSeparator(ui->actionLaunchInstance);
|
||||||
renameButton->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
|
renameButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the instance list widget
|
// Create the instance list widget
|
||||||
{
|
{
|
||||||
view = new KCategorizedView ( ui->centralWidget );
|
view = new KCategorizedView(ui->centralWidget);
|
||||||
drawer = new KCategoryDrawer ( view );
|
drawer = new KCategoryDrawer(view);
|
||||||
|
|
||||||
view->setSelectionMode ( QAbstractItemView::SingleSelection );
|
view->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
view->setCategoryDrawer ( drawer );
|
view->setCategoryDrawer(drawer);
|
||||||
view->setCollapsibleBlocks ( true );
|
view->setCollapsibleBlocks(true);
|
||||||
view->setViewMode ( QListView::IconMode );
|
view->setViewMode(QListView::IconMode);
|
||||||
view->setFlow ( QListView::LeftToRight );
|
view->setFlow(QListView::LeftToRight);
|
||||||
view->setWordWrap(true);
|
view->setWordWrap(true);
|
||||||
view->setMouseTracking ( true );
|
view->setMouseTracking(true);
|
||||||
view->viewport()->setAttribute ( Qt::WA_Hover );
|
view->viewport()->setAttribute(Qt::WA_Hover);
|
||||||
auto delegate = new ListViewDelegate();
|
auto delegate = new ListViewDelegate();
|
||||||
view->setItemDelegate(delegate);
|
view->setItemDelegate(delegate);
|
||||||
view->setSpacing(10);
|
view->setSpacing(10);
|
||||||
view->setUniformItemWidths(true);
|
view->setUniformItemWidths(true);
|
||||||
|
|
||||||
// do not show ugly blue border on the mac
|
// do not show ugly blue border on the mac
|
||||||
view->setAttribute(Qt::WA_MacShowFocusRect, false);
|
view->setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||||
|
|
||||||
view->installEventFilter(this);
|
view->installEventFilter(this);
|
||||||
|
|
||||||
proxymodel = new InstanceProxyModel ( this );
|
proxymodel = new InstanceProxyModel(this);
|
||||||
proxymodel->setSortRole ( KCategorizedSortFilterProxyModel::CategorySortRole );
|
proxymodel->setSortRole(KCategorizedSortFilterProxyModel::CategorySortRole);
|
||||||
proxymodel->setFilterRole ( KCategorizedSortFilterProxyModel::CategorySortRole );
|
proxymodel->setFilterRole(KCategorizedSortFilterProxyModel::CategorySortRole);
|
||||||
//proxymodel->setDynamicSortFilter ( true );
|
// proxymodel->setDynamicSortFilter ( true );
|
||||||
|
|
||||||
// FIXME: instList should be global-ish, or at least not tied to the main window... maybe the application itself?
|
// FIXME: instList should be global-ish, or at least not tied to the main window...
|
||||||
proxymodel->setSourceModel ( MMC->instances().data() );
|
// maybe the application itself?
|
||||||
proxymodel->sort ( 0 );
|
proxymodel->setSourceModel(MMC->instances().get());
|
||||||
view->setFrameShape ( QFrame::NoFrame );
|
proxymodel->sort(0);
|
||||||
view->setModel ( proxymodel );
|
view->setFrameShape(QFrame::NoFrame);
|
||||||
|
view->setModel(proxymodel);
|
||||||
ui->horizontalLayout->addWidget ( view );
|
|
||||||
|
ui->horizontalLayout->addWidget(view);
|
||||||
}
|
}
|
||||||
// The cat background
|
// The cat background
|
||||||
{
|
{
|
||||||
@ -139,18 +139,16 @@ MainWindow::MainWindow ( QWidget *parent )
|
|||||||
setCatBackground(cat_enable);
|
setCatBackground(cat_enable);
|
||||||
}
|
}
|
||||||
// start instance when double-clicked
|
// start instance when double-clicked
|
||||||
connect(view, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(instanceActivated(const QModelIndex &)));
|
connect(view, SIGNAL(doubleClicked(const QModelIndex &)), this,
|
||||||
|
SLOT(instanceActivated(const QModelIndex &)));
|
||||||
// track the selection -- update the instance toolbar
|
// track the selection -- update the instance toolbar
|
||||||
connect(
|
connect(view->selectionModel(),
|
||||||
view->selectionModel(),
|
SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this,
|
||||||
SIGNAL(currentChanged(const QModelIndex &,const QModelIndex &)),
|
SLOT(instanceChanged(const QModelIndex &, const QModelIndex &)));
|
||||||
this,
|
|
||||||
SLOT(instanceChanged(const QModelIndex &,const QModelIndex &))
|
|
||||||
);
|
|
||||||
// model reset -> selection is invalid. All the instance pointers are wrong.
|
// model reset -> selection is invalid. All the instance pointers are wrong.
|
||||||
// FIXME: stop using POINTERS everywhere
|
// FIXME: stop using POINTERS everywhere
|
||||||
connect(MMC->instances().data() ,SIGNAL(dataIsInvalid()),SLOT(selectionBad()));
|
connect(MMC->instances().get(), SIGNAL(dataIsInvalid()), SLOT(selectionBad()));
|
||||||
|
|
||||||
// run the things that load and download other things... FIXME: this is NOT the place
|
// run the things that load and download other things... FIXME: this is NOT the place
|
||||||
// FIXME: invisible actions in the background = NOPE.
|
// FIXME: invisible actions in the background = NOPE.
|
||||||
{
|
{
|
||||||
@ -176,57 +174,55 @@ MainWindow::~MainWindow()
|
|||||||
delete assets_downloader;
|
delete assets_downloader;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::eventFilter ( QObject* obj, QEvent* ev )
|
bool MainWindow::eventFilter(QObject *obj, QEvent *ev)
|
||||||
{
|
{
|
||||||
if(obj == view)
|
if (obj == view)
|
||||||
{
|
{
|
||||||
if (ev->type() == QEvent::KeyPress)
|
if (ev->type() == QEvent::KeyPress)
|
||||||
{
|
{
|
||||||
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(ev);
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(ev);
|
||||||
switch(keyEvent->key())
|
switch (keyEvent->key())
|
||||||
{
|
{
|
||||||
case Qt::Key_Enter:
|
case Qt::Key_Enter:
|
||||||
case Qt::Key_Return:
|
case Qt::Key_Return:
|
||||||
on_actionLaunchInstance_triggered();
|
on_actionLaunchInstance_triggered();
|
||||||
return true;
|
return true;
|
||||||
case Qt::Key_Delete:
|
case Qt::Key_Delete:
|
||||||
on_actionDeleteInstance_triggered();
|
on_actionDeleteInstance_triggered();
|
||||||
return true;
|
return true;
|
||||||
case Qt::Key_F5:
|
case Qt::Key_F5:
|
||||||
on_actionRefresh_triggered();
|
on_actionRefresh_triggered();
|
||||||
return true;
|
return true;
|
||||||
case Qt::Key_F2:
|
case Qt::Key_F2:
|
||||||
on_actionRenameInstance_triggered();
|
on_actionRenameInstance_triggered();
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return QMainWindow::eventFilter ( obj, ev );
|
return QMainWindow::eventFilter(obj, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onCatToggled ( bool state )
|
void MainWindow::onCatToggled(bool state)
|
||||||
{
|
{
|
||||||
setCatBackground(state);
|
setCatBackground(state);
|
||||||
MMC->settings()->set("TheCat", state);
|
MMC->settings()->set("TheCat", state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setCatBackground ( bool enabled )
|
void MainWindow::setCatBackground(bool enabled)
|
||||||
{
|
{
|
||||||
if(enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
view->setStyleSheet(
|
view->setStyleSheet("QListView"
|
||||||
"QListView"
|
"{"
|
||||||
"{"
|
"background-image: url(:/backgrounds/kitteh);"
|
||||||
"background-image: url(:/backgrounds/kitteh);"
|
"background-attachment: fixed;"
|
||||||
"background-attachment: fixed;"
|
"background-clip: padding;"
|
||||||
"background-clip: padding;"
|
"background-position: top right;"
|
||||||
"background-position: top right;"
|
"background-repeat: none;"
|
||||||
"background-repeat: none;"
|
"background-color:palette(base);"
|
||||||
"background-color:palette(base);"
|
"}");
|
||||||
"}"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -234,37 +230,37 @@ void MainWindow::setCatBackground ( bool enabled )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::instanceActivated(QModelIndex index)
|
||||||
void MainWindow::instanceActivated ( QModelIndex index )
|
|
||||||
{
|
{
|
||||||
if(!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
BaseInstance * inst = (BaseInstance *) index.data(InstanceList::InstancePointerRole).value<void *>();
|
BaseInstance *inst =
|
||||||
|
(BaseInstance *)index.data(InstanceList::InstancePointerRole).value<void *>();
|
||||||
doLogin();
|
doLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionAddInstance_triggered()
|
void MainWindow::on_actionAddInstance_triggered()
|
||||||
{
|
{
|
||||||
if (!MMC->minecraftlist()->isLoaded() &&
|
if (!MMC->minecraftlist()->isLoaded() && m_versionLoadTask &&
|
||||||
m_versionLoadTask && m_versionLoadTask->isRunning())
|
m_versionLoadTask->isRunning())
|
||||||
{
|
{
|
||||||
QEventLoop waitLoop;
|
QEventLoop waitLoop;
|
||||||
waitLoop.connect(m_versionLoadTask, SIGNAL(failed(QString)), SLOT(quit()));
|
waitLoop.connect(m_versionLoadTask, SIGNAL(failed(QString)), SLOT(quit()));
|
||||||
waitLoop.connect(m_versionLoadTask, SIGNAL(succeeded()), SLOT(quit()));
|
waitLoop.connect(m_versionLoadTask, SIGNAL(succeeded()), SLOT(quit()));
|
||||||
waitLoop.exec();
|
waitLoop.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
NewInstanceDialog newInstDlg( this );
|
NewInstanceDialog newInstDlg(this);
|
||||||
if (!newInstDlg.exec())
|
if (!newInstDlg.exec())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BaseInstance *newInstance = NULL;
|
BaseInstance *newInstance = NULL;
|
||||||
|
|
||||||
QString instDirName = DirNameFromString(newInstDlg.instName());
|
QString instDirName = DirNameFromString(newInstDlg.instName());
|
||||||
QString instDir = PathCombine(MMC->settings()->get("InstanceDir").toString(), instDirName);
|
QString instDir = PathCombine(MMC->settings()->get("InstanceDir").toString(), instDirName);
|
||||||
|
|
||||||
auto &loader = InstanceFactory::get();
|
auto &loader = InstanceFactory::get();
|
||||||
|
|
||||||
auto error = loader.createInstance(newInstance, newInstDlg.selectedVersion(), instDir);
|
auto error = loader.createInstance(newInstance, newInstDlg.selectedVersion(), instDir);
|
||||||
QString errorMsg = QString("Failed to create instance %1: ").arg(instDirName);
|
QString errorMsg = QString("Failed to create instance %1: ").arg(instDirName);
|
||||||
switch (error)
|
switch (error)
|
||||||
@ -274,17 +270,17 @@ void MainWindow::on_actionAddInstance_triggered()
|
|||||||
newInstance->setIconKey(newInstDlg.iconKey());
|
newInstance->setIconKey(newInstDlg.iconKey());
|
||||||
MMC->instances()->add(InstancePtr(newInstance));
|
MMC->instances()->add(InstancePtr(newInstance));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case InstanceFactory::InstExists:
|
case InstanceFactory::InstExists:
|
||||||
errorMsg += "An instance with the given directory name already exists.";
|
errorMsg += "An instance with the given directory name already exists.";
|
||||||
QMessageBox::warning(this, "Error", errorMsg);
|
QMessageBox::warning(this, "Error", errorMsg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case InstanceFactory::CantCreateDir:
|
case InstanceFactory::CantCreateDir:
|
||||||
errorMsg += "Failed to create the instance directory.";
|
errorMsg += "Failed to create the instance directory.";
|
||||||
QMessageBox::warning(this, "Error", errorMsg);
|
QMessageBox::warning(this, "Error", errorMsg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
errorMsg += QString("Unknown instance loader error %1").arg(error);
|
errorMsg += QString("Unknown instance loader error %1").arg(error);
|
||||||
QMessageBox::warning(this, "Error", errorMsg);
|
QMessageBox::warning(this, "Error", errorMsg);
|
||||||
@ -294,12 +290,12 @@ void MainWindow::on_actionAddInstance_triggered()
|
|||||||
|
|
||||||
void MainWindow::on_actionChangeInstIcon_triggered()
|
void MainWindow::on_actionChangeInstIcon_triggered()
|
||||||
{
|
{
|
||||||
if(!m_selectedInstance)
|
if (!m_selectedInstance)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IconPickerDialog dlg(this);
|
IconPickerDialog dlg(this);
|
||||||
dlg.exec(m_selectedInstance->iconKey());
|
dlg.exec(m_selectedInstance->iconKey());
|
||||||
if(dlg.result() == QDialog::Accepted)
|
if (dlg.result() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
m_selectedInstance->setIconKey(dlg.selectedIconKey);
|
m_selectedInstance->setIconKey(dlg.selectedIconKey);
|
||||||
auto ico = MMC->icons()->getIcon(dlg.selectedIconKey);
|
auto ico = MMC->icons()->getIcon(dlg.selectedIconKey);
|
||||||
@ -307,25 +303,23 @@ void MainWindow::on_actionChangeInstIcon_triggered()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::on_actionChangeInstGroup_triggered()
|
void MainWindow::on_actionChangeInstGroup_triggered()
|
||||||
{
|
{
|
||||||
if(!m_selectedInstance)
|
if (!m_selectedInstance)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
QString name ( m_selectedInstance->group() );
|
QString name(m_selectedInstance->group());
|
||||||
name = QInputDialog::getText ( this, tr ( "Group name" ), tr ( "Enter a new group name." ),
|
name = QInputDialog::getText(this, tr("Group name"), tr("Enter a new group name."),
|
||||||
QLineEdit::Normal, name, &ok );
|
QLineEdit::Normal, name, &ok);
|
||||||
if(ok)
|
if (ok)
|
||||||
m_selectedInstance->setGroupPost(name);
|
m_selectedInstance->setGroupPost(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::on_actionViewInstanceFolder_triggered()
|
void MainWindow::on_actionViewInstanceFolder_triggered()
|
||||||
{
|
{
|
||||||
QString str = MMC->settings()->get ( "InstanceDir" ).toString();
|
QString str = MMC->settings()->get("InstanceDir").toString();
|
||||||
openDirInDefaultProgram ( str );
|
openDirInDefaultProgram(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionRefresh_triggered()
|
void MainWindow::on_actionRefresh_triggered()
|
||||||
@ -335,59 +329,58 @@ void MainWindow::on_actionRefresh_triggered()
|
|||||||
|
|
||||||
void MainWindow::on_actionViewCentralModsFolder_triggered()
|
void MainWindow::on_actionViewCentralModsFolder_triggered()
|
||||||
{
|
{
|
||||||
openDirInDefaultProgram ( MMC->settings()->get ( "CentralModsDir" ).toString() , true);
|
openDirInDefaultProgram(MMC->settings()->get("CentralModsDir").toString(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionConfig_Folder_triggered()
|
void MainWindow::on_actionConfig_Folder_triggered()
|
||||||
{
|
{
|
||||||
if(m_selectedInstance)
|
if (m_selectedInstance)
|
||||||
{
|
{
|
||||||
QString str = m_selectedInstance->instanceConfigFolder();
|
QString str = m_selectedInstance->instanceConfigFolder();
|
||||||
openDirInDefaultProgram ( QDir(str).absolutePath() );
|
openDirInDefaultProgram(QDir(str).absolutePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::on_actionCheckUpdate_triggered()
|
void MainWindow::on_actionCheckUpdate_triggered()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionSettings_triggered()
|
void MainWindow::on_actionSettings_triggered()
|
||||||
{
|
{
|
||||||
SettingsDialog dialog ( this );
|
SettingsDialog dialog(this);
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionReportBug_triggered()
|
void MainWindow::on_actionReportBug_triggered()
|
||||||
{
|
{
|
||||||
openWebPage ( QUrl ( "http://multimc.myjetbrains.com/youtrack/dashboard#newissue=yes" ) );
|
openWebPage(QUrl("http://multimc.myjetbrains.com/youtrack/dashboard#newissue=yes"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionNews_triggered()
|
void MainWindow::on_actionNews_triggered()
|
||||||
{
|
{
|
||||||
openWebPage ( QUrl ( "http://forkk.net/tag/multimc.html" ) );
|
openWebPage(QUrl("http://forkk.net/tag/multimc.html"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionAbout_triggered()
|
void MainWindow::on_actionAbout_triggered()
|
||||||
{
|
{
|
||||||
AboutDialog dialog ( this );
|
AboutDialog dialog(this);
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_mainToolBar_visibilityChanged ( bool )
|
void MainWindow::on_mainToolBar_visibilityChanged(bool)
|
||||||
{
|
{
|
||||||
// Don't allow hiding the main toolbar.
|
// Don't allow hiding the main toolbar.
|
||||||
// This is the only way I could find to prevent it... :/
|
// This is the only way I could find to prevent it... :/
|
||||||
ui->mainToolBar->setVisible ( true );
|
ui->mainToolBar->setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionDeleteInstance_triggered()
|
void MainWindow::on_actionDeleteInstance_triggered()
|
||||||
{
|
{
|
||||||
if (m_selectedInstance)
|
if (m_selectedInstance)
|
||||||
{
|
{
|
||||||
int response = QMessageBox::question(this, "CAREFUL",
|
int response = QMessageBox::question(
|
||||||
QString("This is permanent! Are you sure?\nAbout to delete: ") + m_selectedInstance->name());
|
this, "CAREFUL", QString("This is permanent! Are you sure?\nAbout to delete: ") +
|
||||||
|
m_selectedInstance->name());
|
||||||
if (response == QMessageBox::Yes)
|
if (response == QMessageBox::Yes)
|
||||||
{
|
{
|
||||||
m_selectedInstance->nuke();
|
m_selectedInstance->nuke();
|
||||||
@ -397,31 +390,31 @@ void MainWindow::on_actionDeleteInstance_triggered()
|
|||||||
|
|
||||||
void MainWindow::on_actionRenameInstance_triggered()
|
void MainWindow::on_actionRenameInstance_triggered()
|
||||||
{
|
{
|
||||||
if(m_selectedInstance)
|
if (m_selectedInstance)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
QString name ( m_selectedInstance->name() );
|
QString name(m_selectedInstance->name());
|
||||||
name = QInputDialog::getText ( this, tr ( "Instance name" ), tr ( "Enter a new instance name." ),
|
name =
|
||||||
QLineEdit::Normal, name, &ok );
|
QInputDialog::getText(this, tr("Instance name"), tr("Enter a new instance name."),
|
||||||
|
QLineEdit::Normal, name, &ok);
|
||||||
|
|
||||||
if (name.length() > 0)
|
if (name.length() > 0)
|
||||||
{
|
{
|
||||||
if(ok && name.length())
|
if (ok && name.length())
|
||||||
{
|
{
|
||||||
m_selectedInstance->setName(name);
|
m_selectedInstance->setName(name);
|
||||||
renameButton->setText(name);
|
renameButton->setText(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionViewSelectedInstFolder_triggered()
|
void MainWindow::on_actionViewSelectedInstFolder_triggered()
|
||||||
{
|
{
|
||||||
if(m_selectedInstance)
|
if (m_selectedInstance)
|
||||||
{
|
{
|
||||||
QString str = m_selectedInstance->instanceRoot();
|
QString str = m_selectedInstance->instanceRoot();
|
||||||
openDirInDefaultProgram ( QDir(str).absolutePath() );
|
openDirInDefaultProgram(QDir(str).absolutePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,59 +423,61 @@ void MainWindow::on_actionEditInstMods_triggered()
|
|||||||
if (m_selectedInstance)
|
if (m_selectedInstance)
|
||||||
{
|
{
|
||||||
auto dialog = m_selectedInstance->createModEditDialog(this);
|
auto dialog = m_selectedInstance->createModEditDialog(this);
|
||||||
if(dialog)
|
if (dialog)
|
||||||
dialog->exec();
|
dialog->exec();
|
||||||
dialog->deleteLater();
|
dialog->deleteLater();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::closeEvent ( QCloseEvent *event )
|
void MainWindow::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
// Save the window state and geometry.
|
// Save the window state and geometry.
|
||||||
// TODO: Make this work with the new settings system.
|
// TODO: Make this work with the new settings system.
|
||||||
// settings->getConfig().setValue("MainWindowGeometry", saveGeometry());
|
// settings->getConfig().setValue("MainWindowGeometry", saveGeometry());
|
||||||
// settings->getConfig().setValue("MainWindowState", saveState());
|
// settings->getConfig().setValue("MainWindowState", saveState());
|
||||||
QMainWindow::closeEvent ( event );
|
QMainWindow::closeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_instanceView_customContextMenuRequested ( const QPoint &pos )
|
void MainWindow::on_instanceView_customContextMenuRequested(const QPoint &pos)
|
||||||
{
|
{
|
||||||
QMenu *instContextMenu = new QMenu ( "Instance", this );
|
QMenu *instContextMenu = new QMenu("Instance", this);
|
||||||
|
|
||||||
// Add the actions from the toolbar to the context menu.
|
// Add the actions from the toolbar to the context menu.
|
||||||
instContextMenu->addActions ( ui->instanceToolBar->actions() );
|
instContextMenu->addActions(ui->instanceToolBar->actions());
|
||||||
|
|
||||||
instContextMenu->exec ( view->mapToGlobal ( pos ) );
|
instContextMenu->exec(view->mapToGlobal(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionLaunchInstance_triggered()
|
void MainWindow::on_actionLaunchInstance_triggered()
|
||||||
{
|
{
|
||||||
if(m_selectedInstance)
|
if (m_selectedInstance)
|
||||||
{
|
{
|
||||||
doLogin();
|
doLogin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::doLogin(const QString& errorMsg)
|
void MainWindow::doLogin(const QString &errorMsg)
|
||||||
{
|
{
|
||||||
if (!m_selectedInstance)
|
if (!m_selectedInstance)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LoginDialog* loginDlg = new LoginDialog(this, errorMsg);
|
LoginDialog *loginDlg = new LoginDialog(this, errorMsg);
|
||||||
if (!m_selectedInstance->lastLaunch())
|
if (!m_selectedInstance->lastLaunch())
|
||||||
loginDlg->forceOnline();
|
loginDlg->forceOnline();
|
||||||
|
|
||||||
loginDlg->exec();
|
loginDlg->exec();
|
||||||
if(loginDlg->result() == QDialog::Accepted)
|
if (loginDlg->result() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
if (loginDlg->isOnline())
|
if (loginDlg->isOnline())
|
||||||
{
|
{
|
||||||
UserInfo uInfo{loginDlg->getUsername(), loginDlg->getPassword()};
|
UserInfo uInfo{loginDlg->getUsername(), loginDlg->getPassword()};
|
||||||
|
|
||||||
ProgressDialog* tDialog = new ProgressDialog(this);
|
ProgressDialog *tDialog = new ProgressDialog(this);
|
||||||
LoginTask* loginTask = new LoginTask(uInfo, tDialog);
|
LoginTask *loginTask = new LoginTask(uInfo, tDialog);
|
||||||
connect(loginTask, SIGNAL(succeeded()),SLOT(onLoginComplete()), Qt::QueuedConnection);
|
connect(loginTask, SIGNAL(succeeded()), SLOT(onLoginComplete()),
|
||||||
connect(loginTask, SIGNAL(failed(QString)), SLOT(doLogin(QString)), Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
|
connect(loginTask, SIGNAL(failed(QString)), SLOT(doLogin(QString)),
|
||||||
|
Qt::QueuedConnection);
|
||||||
m_activeInst = m_selectedInstance;
|
m_activeInst = m_selectedInstance;
|
||||||
tDialog->exec(loginTask);
|
tDialog->exec(loginTask);
|
||||||
}
|
}
|
||||||
@ -490,7 +485,7 @@ void MainWindow::doLogin(const QString& errorMsg)
|
|||||||
{
|
{
|
||||||
QString user = loginDlg->getUsername();
|
QString user = loginDlg->getUsername();
|
||||||
if (user.length() == 0)
|
if (user.length() == 0)
|
||||||
user = QString("Offline");
|
user = QString("Offline");
|
||||||
m_activeLogin = {user, QString("Offline"), QString(), QString()};
|
m_activeLogin = {user, QString("Offline"), QString(), QString()};
|
||||||
m_activeInst = m_selectedInstance;
|
m_activeInst = m_selectedInstance;
|
||||||
launchInstance(m_activeInst, m_activeLogin);
|
launchInstance(m_activeInst, m_activeLogin);
|
||||||
@ -500,20 +495,20 @@ void MainWindow::doLogin(const QString& errorMsg)
|
|||||||
|
|
||||||
void MainWindow::onLoginComplete()
|
void MainWindow::onLoginComplete()
|
||||||
{
|
{
|
||||||
if(!m_activeInst)
|
if (!m_activeInst)
|
||||||
return;
|
return;
|
||||||
LoginTask * task = (LoginTask *) QObject::sender();
|
LoginTask *task = (LoginTask *)QObject::sender();
|
||||||
m_activeLogin = task->getResult();
|
m_activeLogin = task->getResult();
|
||||||
|
|
||||||
BaseUpdate *updateTask = m_activeInst->doUpdate();
|
BaseUpdate *updateTask = m_activeInst->doUpdate();
|
||||||
if(!updateTask)
|
if (!updateTask)
|
||||||
{
|
{
|
||||||
launchInstance(m_activeInst, m_activeLogin);
|
launchInstance(m_activeInst, m_activeLogin);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ProgressDialog *tDialog = new ProgressDialog(this);
|
ProgressDialog *tDialog = new ProgressDialog(this);
|
||||||
connect(updateTask, SIGNAL(succeeded()),SLOT(onGameUpdateComplete()));
|
connect(updateTask, SIGNAL(succeeded()), SLOT(onGameUpdateComplete()));
|
||||||
connect(updateTask, SIGNAL(failed(QString)), SLOT(onGameUpdateError(QString)));
|
connect(updateTask, SIGNAL(failed(QString)), SLOT(onGameUpdateError(QString)));
|
||||||
tDialog->exec(updateTask);
|
tDialog->exec(updateTask);
|
||||||
}
|
}
|
||||||
@ -532,11 +527,11 @@ void MainWindow::onGameUpdateError(QString error)
|
|||||||
void MainWindow::launchInstance(BaseInstance *instance, LoginResponse response)
|
void MainWindow::launchInstance(BaseInstance *instance, LoginResponse response)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(instance != NULL, "launchInstance", "instance is NULL");
|
Q_ASSERT_X(instance != NULL, "launchInstance", "instance is NULL");
|
||||||
|
|
||||||
proc = instance->prepareForLaunch(response);
|
proc = instance->prepareForLaunch(response);
|
||||||
if(!proc)
|
if (!proc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Prepare GUI: If it shall stay open disable the required parts
|
// Prepare GUI: If it shall stay open disable the required parts
|
||||||
if (MMC->settings()->get("NoHide").toBool())
|
if (MMC->settings()->get("NoHide").toBool())
|
||||||
{
|
{
|
||||||
@ -546,11 +541,11 @@ void MainWindow::launchInstance(BaseInstance *instance, LoginResponse response)
|
|||||||
{
|
{
|
||||||
this->hide();
|
this->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
console = new ConsoleWindow(proc);
|
console = new ConsoleWindow(proc);
|
||||||
console->show();
|
console->show();
|
||||||
connect(proc, SIGNAL(log(QString, MessageLevel::Enum)),
|
connect(proc, SIGNAL(log(QString, MessageLevel::Enum)), console,
|
||||||
console, SLOT(write(QString, MessageLevel::Enum)));
|
SLOT(write(QString, MessageLevel::Enum)));
|
||||||
connect(proc, SIGNAL(ended()), this, SLOT(instanceEnded()));
|
connect(proc, SIGNAL(ended()), this, SLOT(instanceEnded()));
|
||||||
proc->setLogin(response.username, response.session_id);
|
proc->setLogin(response.username, response.session_id);
|
||||||
proc->launch();
|
proc->launch();
|
||||||
@ -566,7 +561,7 @@ void MainWindow::taskEnd()
|
|||||||
QObject *sender = QObject::sender();
|
QObject *sender = QObject::sender();
|
||||||
if (sender == m_versionLoadTask)
|
if (sender == m_versionLoadTask)
|
||||||
m_versionLoadTask = NULL;
|
m_versionLoadTask = NULL;
|
||||||
|
|
||||||
sender->deleteLater();
|
sender->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,20 +573,24 @@ void MainWindow::startTask(Task *task)
|
|||||||
task->start();
|
task->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Create A Desktop Shortcut
|
// Create A Desktop Shortcut
|
||||||
void MainWindow::on_actionMakeDesktopShortcut_triggered()
|
void MainWindow::on_actionMakeDesktopShortcut_triggered()
|
||||||
{
|
{
|
||||||
QString name ( "Test" );
|
QString name("Test");
|
||||||
name = QInputDialog::getText ( this, tr ( "MultiMC Shortcut" ), tr ( "Enter a Shortcut Name." ), QLineEdit::Normal, name );
|
name = QInputDialog::getText(this, tr("MultiMC Shortcut"), tr("Enter a Shortcut Name."),
|
||||||
|
QLineEdit::Normal, name);
|
||||||
|
|
||||||
Util::createShortCut ( Util::getDesktopDir(), QApplication::instance()->applicationFilePath(), QStringList() << "-dl" << QDir::currentPath() << "test", name, "application-x-octet-stream" );
|
Util::createShortCut(Util::getDesktopDir(), QApplication::instance()->applicationFilePath(),
|
||||||
|
QStringList() << "-dl" << QDir::currentPath() << "test", name,
|
||||||
|
"application-x-octet-stream");
|
||||||
|
|
||||||
QMessageBox::warning ( this, tr("Not useful"), tr("A Dummy Shortcut was created. it will not do anything productive") );
|
QMessageBox::warning(
|
||||||
|
this, tr("Not useful"),
|
||||||
|
tr("A Dummy Shortcut was created. it will not do anything productive"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// BrowserDialog
|
// BrowserDialog
|
||||||
void MainWindow::openWebPage ( QUrl url )
|
void MainWindow::openWebPage(QUrl url)
|
||||||
{
|
{
|
||||||
QDesktopServices::openUrl(url);
|
QDesktopServices::openUrl(url);
|
||||||
}
|
}
|
||||||
@ -600,8 +599,8 @@ void MainWindow::on_actionChangeInstMCVersion_triggered()
|
|||||||
{
|
{
|
||||||
if (view->selectionModel()->selectedIndexes().count() < 1)
|
if (view->selectionModel()->selectedIndexes().count() < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
VersionSelectDialog vselect(m_selectedInstance->versionList().data(), this);
|
VersionSelectDialog vselect(m_selectedInstance->versionList().get(), this);
|
||||||
if (vselect.exec() && vselect.selectedVersion())
|
if (vselect.exec() && vselect.selectedVersion())
|
||||||
{
|
{
|
||||||
m_selectedInstance->setIntendedVersionId(vselect.selectedVersion()->descriptor());
|
m_selectedInstance->setIntendedVersionId(vselect.selectedVersion()->descriptor());
|
||||||
@ -612,12 +611,12 @@ void MainWindow::on_actionChangeInstLWJGLVersion_triggered()
|
|||||||
{
|
{
|
||||||
if (!m_selectedInstance)
|
if (!m_selectedInstance)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LWJGLSelectDialog lselect(this);
|
LWJGLSelectDialog lselect(this);
|
||||||
lselect.exec();
|
lselect.exec();
|
||||||
if (lselect.result() == QDialog::Accepted)
|
if (lselect.result() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
LegacyInstance * linst = (LegacyInstance *) m_selectedInstance;
|
LegacyInstance *linst = (LegacyInstance *)m_selectedInstance;
|
||||||
linst->setLWJGLVersion(lselect.selectedVersion());
|
linst->setLWJGLVersion(lselect.selectedVersion());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -632,18 +631,23 @@ void MainWindow::on_actionInstanceSettings_triggered()
|
|||||||
settings.exec();
|
settings.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::instanceChanged( const QModelIndex& current, const QModelIndex& previous )
|
void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||||
{
|
{
|
||||||
if(current.isValid() && nullptr != (m_selectedInstance = (BaseInstance *) current.data(InstanceList::InstancePointerRole).value<void *>()))
|
if (current.isValid() &&
|
||||||
|
nullptr != (m_selectedInstance =
|
||||||
|
(BaseInstance *)current.data(InstanceList::InstancePointerRole)
|
||||||
|
.value<void *>()))
|
||||||
{
|
{
|
||||||
ui->instanceToolBar->setEnabled(true);
|
ui->instanceToolBar->setEnabled(true);
|
||||||
QString iconKey = m_selectedInstance->iconKey();
|
QString iconKey = m_selectedInstance->iconKey();
|
||||||
renameButton->setText(m_selectedInstance->name());
|
renameButton->setText(m_selectedInstance->name());
|
||||||
ui->actionChangeInstLWJGLVersion->setEnabled(m_selectedInstance->menuActionEnabled("actionChangeInstLWJGLVersion"));
|
ui->actionChangeInstLWJGLVersion->setEnabled(
|
||||||
ui->actionEditInstMods->setEnabled(m_selectedInstance->menuActionEnabled("actionEditInstMods"));
|
m_selectedInstance->menuActionEnabled("actionChangeInstLWJGLVersion"));
|
||||||
|
ui->actionEditInstMods->setEnabled(
|
||||||
|
m_selectedInstance->menuActionEnabled("actionEditInstMods"));
|
||||||
statusBar()->clearMessage();
|
statusBar()->clearMessage();
|
||||||
statusBar()->showMessage(m_selectedInstance->getStatusbarDescription());
|
statusBar()->showMessage(m_selectedInstance->getStatusbarDescription());
|
||||||
auto ico =MMC->icons()->getIcon(iconKey);
|
auto ico = MMC->icons()->getIcon(iconKey);
|
||||||
ui->actionChangeInstIcon->setIcon(ico);
|
ui->actionChangeInstIcon->setIcon(ico);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -663,19 +667,17 @@ void MainWindow::selectionBad()
|
|||||||
ui->actionChangeInstIcon->setIcon(ico);
|
ui->actionChangeInstIcon->setIcon(ico);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::on_actionEditInstNotes_triggered()
|
void MainWindow::on_actionEditInstNotes_triggered()
|
||||||
{
|
{
|
||||||
if (!m_selectedInstance)
|
if (!m_selectedInstance)
|
||||||
return;
|
return;
|
||||||
LegacyInstance * linst = (LegacyInstance *) m_selectedInstance;
|
LegacyInstance *linst = (LegacyInstance *)m_selectedInstance;
|
||||||
|
|
||||||
EditNotesDialog noteedit(linst->notes(), linst->name(), this);
|
EditNotesDialog noteedit(linst->notes(), linst->name(), this);
|
||||||
noteedit.exec();
|
noteedit.exec();
|
||||||
if (noteedit.result() == QDialog::Accepted)
|
if (noteedit.result() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
|
|
||||||
linst->setNotes(noteedit.getText());
|
linst->setNotes(noteedit.getText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ BaseVersionPtr NewInstanceDialog::selectedVersion() const
|
|||||||
|
|
||||||
void NewInstanceDialog::on_btnChangeVersion_clicked()
|
void NewInstanceDialog::on_btnChangeVersion_clicked()
|
||||||
{
|
{
|
||||||
VersionSelectDialog vselect(MMC->minecraftlist().data(), this);
|
VersionSelectDialog vselect(MMC->minecraftlist().get(), this);
|
||||||
vselect.exec();
|
vselect.exec();
|
||||||
if (vselect.result() == QDialog::Accepted)
|
if (vselect.result() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
loadSettings(MMC->settings().data());
|
loadSettings(MMC->settings().get());
|
||||||
updateCheckboxStuff();
|
updateCheckboxStuff();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ void SettingsDialog::on_maximizedCheckBox_clicked(bool checked)
|
|||||||
|
|
||||||
void SettingsDialog::on_buttonBox_accepted()
|
void SettingsDialog::on_buttonBox_accepted()
|
||||||
{
|
{
|
||||||
applySettings(MMC->settings().data());
|
applySettings(MMC->settings().get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::applySettings(SettingsObject *s)
|
void SettingsDialog::applySettings(SettingsObject *s)
|
||||||
|
@ -91,6 +91,6 @@ void VersionSelectDialog::setFilter(int column, QString filter)
|
|||||||
if (filteredTypes.length() > 0)
|
if (filteredTypes.length() > 0)
|
||||||
regexStr = QString("^((?!%1).)*$").arg(filteredTypes.join('|'));
|
regexStr = QString("^((?!%1).)*$").arg(filteredTypes.join('|'));
|
||||||
|
|
||||||
qDebug() << "Filter:" << regexStr;
|
QLOG_DEBUG() << "Filter:" << regexStr;
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
52
logger/QsDebugOutput.cpp
Normal file
52
logger/QsDebugOutput.cpp
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
// Copyright (c) 2010, Razvan Petru
|
||||||
|
// All rights reserved.
|
||||||
|
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
// * Redistributions of source code must retain the above copyright notice, this
|
||||||
|
// list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
// list of conditions and the following disclaimer in the documentation and/or other
|
||||||
|
// materials provided with the distribution.
|
||||||
|
// * The name of the contributors may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||||
|
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||||
|
// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
// OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "QsDebugOutput.h"
|
||||||
|
#include <QString>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#include <Windows.h>
|
||||||
|
void QsDebugOutput::output(const QString &message)
|
||||||
|
{
|
||||||
|
OutputDebugStringW(reinterpret_cast<const WCHAR *>(message.utf16()));
|
||||||
|
OutputDebugStringW(L"\n");
|
||||||
|
}
|
||||||
|
#elif defined(Q_OS_SYMBIAN)
|
||||||
|
#include <e32debug.h>
|
||||||
|
void QsDebugOutput::output(const QString &message)
|
||||||
|
{
|
||||||
|
TPtrC8 symbianMessage(reinterpret_cast<const TUint8 *>(qPrintable(message)));
|
||||||
|
RDebug::RawPrint(symbianMessage);
|
||||||
|
}
|
||||||
|
#elif defined(Q_OS_UNIX)
|
||||||
|
#include <cstdio>
|
||||||
|
void QsDebugOutput::output(const QString &message)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s\n", qPrintable(message));
|
||||||
|
fflush(stderr);
|
||||||
|
}
|
||||||
|
#endif
|
34
logger/QsDebugOutput.h
Normal file
34
logger/QsDebugOutput.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// Copyright (c) 2010, Razvan Petru
|
||||||
|
// All rights reserved.
|
||||||
|
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
// * Redistributions of source code must retain the above copyright notice, this
|
||||||
|
// list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
// list of conditions and the following disclaimer in the documentation and/or other
|
||||||
|
// materials provided with the distribution.
|
||||||
|
// * The name of the contributors may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||||
|
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||||
|
// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
// OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class QString;
|
||||||
|
|
||||||
|
class QsDebugOutput
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void output(const QString &a_message);
|
||||||
|
};
|
141
logger/QsLog.cpp
Normal file
141
logger/QsLog.cpp
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
// Copyright (c) 2010, Razvan Petru
|
||||||
|
// All rights reserved.
|
||||||
|
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
// * Redistributions of source code must retain the above copyright notice, this
|
||||||
|
// list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
// list of conditions and the following disclaimer in the documentation and/or other
|
||||||
|
// materials provided with the distribution.
|
||||||
|
// * The name of the contributors may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||||
|
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||||
|
// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
// OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "QsLog.h"
|
||||||
|
#include "QsLogDest.h"
|
||||||
|
#include <QMutex>
|
||||||
|
#include <QList>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QtGlobal>
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
namespace QsLogging
|
||||||
|
{
|
||||||
|
typedef QList<Destination *> DestinationList;
|
||||||
|
|
||||||
|
static const char *LevelStrings[] = {"TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL"
|
||||||
|
"UNKNOWN"};
|
||||||
|
|
||||||
|
// not using Qt::ISODate because we need the milliseconds too
|
||||||
|
static const QString fmtDateTime("hhhh:mm:ss.zzz");
|
||||||
|
|
||||||
|
static const char *LevelToText(Level theLevel)
|
||||||
|
{
|
||||||
|
if (theLevel > FatalLevel)
|
||||||
|
{
|
||||||
|
assert(!"bad log level");
|
||||||
|
return LevelStrings[UnknownLevel];
|
||||||
|
}
|
||||||
|
return LevelStrings[theLevel];
|
||||||
|
}
|
||||||
|
|
||||||
|
class LoggerImpl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LoggerImpl() : level(InfoLevel), start_time(QDateTime::currentDateTime())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
QMutex logMutex;
|
||||||
|
Level level;
|
||||||
|
DestinationList destList;
|
||||||
|
QDateTime start_time;
|
||||||
|
};
|
||||||
|
|
||||||
|
Logger::Logger() : d(new LoggerImpl)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger::~Logger()
|
||||||
|
{
|
||||||
|
delete d;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Logger::addDestination(Destination *destination)
|
||||||
|
{
|
||||||
|
assert(destination);
|
||||||
|
d->destList.push_back(destination);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Logger::setLoggingLevel(Level newLevel)
|
||||||
|
{
|
||||||
|
d->level = newLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
Level Logger::loggingLevel() const
|
||||||
|
{
|
||||||
|
return d->level;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! creates the complete log message and passes it to the logger
|
||||||
|
void Logger::Helper::writeToLog()
|
||||||
|
{
|
||||||
|
const char *const levelName = LevelToText(level);
|
||||||
|
const QString completeMessage(QString("%1\t%2\t%3")
|
||||||
|
.arg(QDateTime::currentDateTime().toString(fmtDateTime))
|
||||||
|
.arg(levelName, 5)
|
||||||
|
.arg(buffer));
|
||||||
|
|
||||||
|
Logger &logger = Logger::instance();
|
||||||
|
QMutexLocker lock(&logger.d->logMutex);
|
||||||
|
logger.write(completeMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger::Helper::Helper(Level logLevel) : level(logLevel), qtDebug(&buffer)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger::Helper::~Helper()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
writeToLog();
|
||||||
|
}
|
||||||
|
catch (std::exception &e)
|
||||||
|
{
|
||||||
|
// you shouldn't throw exceptions from a sink
|
||||||
|
Q_UNUSED(e);
|
||||||
|
assert(!"exception in logger helper destructor");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//! sends the message to all the destinations
|
||||||
|
void Logger::write(const QString &message)
|
||||||
|
{
|
||||||
|
for (DestinationList::iterator it = d->destList.begin(), endIt = d->destList.end();
|
||||||
|
it != endIt; ++it)
|
||||||
|
{
|
||||||
|
if (!(*it))
|
||||||
|
{
|
||||||
|
assert(!"null log destination");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
(*it)->write(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end namespace
|
130
logger/QsLog.h
Normal file
130
logger/QsLog.h
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
// Copyright (c) 2010, Razvan Petru
|
||||||
|
// All rights reserved.
|
||||||
|
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
// * Redistributions of source code must retain the above copyright notice, this
|
||||||
|
// list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
// list of conditions and the following disclaimer in the documentation and/or other
|
||||||
|
// materials provided with the distribution.
|
||||||
|
// * The name of the contributors may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||||
|
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||||
|
// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
// OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
namespace QsLogging
|
||||||
|
{
|
||||||
|
class Destination;
|
||||||
|
enum Level
|
||||||
|
{
|
||||||
|
TraceLevel = 0,
|
||||||
|
DebugLevel,
|
||||||
|
InfoLevel,
|
||||||
|
WarnLevel,
|
||||||
|
ErrorLevel,
|
||||||
|
FatalLevel,
|
||||||
|
UnknownLevel
|
||||||
|
};
|
||||||
|
|
||||||
|
class LoggerImpl; // d pointer
|
||||||
|
class Logger
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Logger &instance()
|
||||||
|
{
|
||||||
|
static Logger staticLog;
|
||||||
|
return staticLog;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Adds a log message destination. Don't add null destinations.
|
||||||
|
void addDestination(Destination *destination);
|
||||||
|
//! Logging at a level < 'newLevel' will be ignored
|
||||||
|
void setLoggingLevel(Level newLevel);
|
||||||
|
//! The default level is INFO
|
||||||
|
Level loggingLevel() const;
|
||||||
|
|
||||||
|
//! The helper forwards the streaming to QDebug and builds the final
|
||||||
|
//! log message.
|
||||||
|
class Helper
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit Helper(Level logLevel);
|
||||||
|
~Helper();
|
||||||
|
QDebug &stream()
|
||||||
|
{
|
||||||
|
return qtDebug;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void writeToLog();
|
||||||
|
|
||||||
|
Level level;
|
||||||
|
QString buffer;
|
||||||
|
QDebug qtDebug;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
Logger();
|
||||||
|
Logger(const Logger &);
|
||||||
|
Logger &operator=(const Logger &);
|
||||||
|
~Logger();
|
||||||
|
|
||||||
|
void write(const QString &message);
|
||||||
|
|
||||||
|
LoggerImpl *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // end namespace
|
||||||
|
|
||||||
|
#define QLOG_TRACE() \
|
||||||
|
if (QsLogging::Logger::instance().loggingLevel() <= QsLogging::TraceLevel) \
|
||||||
|
QsLogging::Logger::Helper(QsLogging::TraceLevel).stream()
|
||||||
|
#define QLOG_DEBUG() \
|
||||||
|
if (QsLogging::Logger::instance().loggingLevel() <= QsLogging::DebugLevel) \
|
||||||
|
QsLogging::Logger::Helper(QsLogging::DebugLevel).stream()
|
||||||
|
#define QLOG_INFO() \
|
||||||
|
if (QsLogging::Logger::instance().loggingLevel() <= QsLogging::InfoLevel) \
|
||||||
|
QsLogging::Logger::Helper(QsLogging::InfoLevel).stream()
|
||||||
|
#define QLOG_WARN() \
|
||||||
|
if (QsLogging::Logger::instance().loggingLevel() <= QsLogging::WarnLevel) \
|
||||||
|
QsLogging::Logger::Helper(QsLogging::WarnLevel).stream()
|
||||||
|
#define QLOG_ERROR() \
|
||||||
|
if (QsLogging::Logger::instance().loggingLevel() <= QsLogging::ErrorLevel) \
|
||||||
|
QsLogging::Logger::Helper(QsLogging::ErrorLevel).stream()
|
||||||
|
#define QLOG_FATAL() QsLogging::Logger::Helper(QsLogging::FatalLevel).stream()
|
||||||
|
|
||||||
|
/*
|
||||||
|
#define QLOG_TRACE() \
|
||||||
|
if (QsLogging::Logger::instance().loggingLevel() <= QsLogging::TraceLevel) \
|
||||||
|
QsLogging::Logger::Helper(QsLogging::TraceLevel).stream() << __FILE__ << '@' << __LINE__
|
||||||
|
#define QLOG_DEBUG() \
|
||||||
|
if (QsLogging::Logger::instance().loggingLevel() <= QsLogging::DebugLevel) \
|
||||||
|
QsLogging::Logger::Helper(QsLogging::DebugLevel).stream() << __FILE__ << '@' << __LINE__
|
||||||
|
#define QLOG_INFO() \
|
||||||
|
if (QsLogging::Logger::instance().loggingLevel() <= QsLogging::InfoLevel) \
|
||||||
|
QsLogging::Logger::Helper(QsLogging::InfoLevel).stream() << __FILE__ << '@' << __LINE__
|
||||||
|
#define QLOG_WARN() \
|
||||||
|
if (QsLogging::Logger::instance().loggingLevel() <= QsLogging::WarnLevel) \
|
||||||
|
QsLogging::Logger::Helper(QsLogging::WarnLevel).stream() << __FILE__ << '@' << __LINE__
|
||||||
|
#define QLOG_ERROR() \
|
||||||
|
if (QsLogging::Logger::instance().loggingLevel() <= QsLogging::ErrorLevel) \
|
||||||
|
QsLogging::Logger::Helper(QsLogging::ErrorLevel).stream() << __FILE__ << '@' << __LINE__
|
||||||
|
#define QLOG_FATAL() \
|
||||||
|
QsLogging::Logger::Helper(QsLogging::FatalLevel).stream() << __FILE__ << '@' << __LINE__
|
||||||
|
*/
|
83
logger/QsLogDest.cpp
Normal file
83
logger/QsLogDest.cpp
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
// Copyright (c) 2010, Razvan Petru
|
||||||
|
// All rights reserved.
|
||||||
|
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
// * Redistributions of source code must retain the above copyright notice, this
|
||||||
|
// list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
// list of conditions and the following disclaimer in the documentation and/or other
|
||||||
|
// materials provided with the distribution.
|
||||||
|
// * The name of the contributors may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||||
|
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||||
|
// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
// OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "QsLogDest.h"
|
||||||
|
#include "QsDebugOutput.h"
|
||||||
|
#include <QFile>
|
||||||
|
#include <QTextStream>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
namespace QsLogging
|
||||||
|
{
|
||||||
|
|
||||||
|
//! file message sink
|
||||||
|
class FileDestination : public Destination
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FileDestination(const QString &filePath);
|
||||||
|
virtual void write(const QString &message);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QFile mFile;
|
||||||
|
QTextStream mOutputStream;
|
||||||
|
};
|
||||||
|
|
||||||
|
FileDestination::FileDestination(const QString &filePath)
|
||||||
|
{
|
||||||
|
mFile.setFileName(filePath);
|
||||||
|
mFile.open(QFile::WriteOnly | QFile::Text |
|
||||||
|
QFile::Truncate); // fixme: should throw on failure
|
||||||
|
mOutputStream.setDevice(&mFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileDestination::write(const QString &message)
|
||||||
|
{
|
||||||
|
mOutputStream << message << endl;
|
||||||
|
mOutputStream.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
//! debugger sink
|
||||||
|
class DebugOutputDestination : public Destination
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void write(const QString &message);
|
||||||
|
};
|
||||||
|
|
||||||
|
void DebugOutputDestination::write(const QString &message)
|
||||||
|
{
|
||||||
|
QsDebugOutput::output(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
DestinationPtr DestinationFactory::MakeFileDestination(const QString &filePath)
|
||||||
|
{
|
||||||
|
return DestinationPtr(new FileDestination(filePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
DestinationPtr DestinationFactory::MakeDebugOutputDestination()
|
||||||
|
{
|
||||||
|
return DestinationPtr(new DebugOutputDestination);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end namespace
|
53
logger/QsLogDest.h
Normal file
53
logger/QsLogDest.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
// Copyright (c) 2010, Razvan Petru
|
||||||
|
// All rights reserved.
|
||||||
|
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
// * Redistributions of source code must retain the above copyright notice, this
|
||||||
|
// list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
// list of conditions and the following disclaimer in the documentation and/or other
|
||||||
|
// materials provided with the distribution.
|
||||||
|
// * The name of the contributors may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||||
|
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||||
|
// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
// OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
class QString;
|
||||||
|
|
||||||
|
namespace QsLogging
|
||||||
|
{
|
||||||
|
|
||||||
|
class Destination
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~Destination()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual void write(const QString &message) = 0;
|
||||||
|
};
|
||||||
|
typedef std::shared_ptr<Destination> DestinationPtr;
|
||||||
|
|
||||||
|
//! Creates logging destinations/sinks. The caller will have ownership of
|
||||||
|
//! the newly created destinations.
|
||||||
|
class DestinationFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static DestinationPtr MakeFileDestination(const QString &filePath);
|
||||||
|
static DestinationPtr MakeDebugOutputDestination();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // end namespace
|
@ -132,7 +132,7 @@ InstanceList *BaseInstance::instList() const
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<BaseVersionList> BaseInstance::versionList() const
|
std::shared_ptr<BaseVersionList> BaseInstance::versionList() const
|
||||||
{
|
{
|
||||||
return MMC->minecraftlist();
|
return MMC->minecraftlist();
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ public:
|
|||||||
* \brief Gets a pointer to this instance's version list.
|
* \brief Gets a pointer to this instance's version list.
|
||||||
* \return A pointer to the available version list for this instance.
|
* \return A pointer to the available version list for this instance.
|
||||||
*/
|
*/
|
||||||
virtual QSharedPointer<BaseVersionList> versionList() const;
|
virtual std::shared_ptr<BaseVersionList> versionList() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Gets this instance's settings object.
|
* \brief Gets this instance's settings object.
|
||||||
@ -179,9 +179,9 @@ signals:
|
|||||||
void nuked(BaseInstance * inst);
|
void nuked(BaseInstance * inst);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QSharedPointer<BaseInstancePrivate> inst_d;
|
std::shared_ptr<BaseInstancePrivate> inst_d;
|
||||||
};
|
};
|
||||||
|
|
||||||
// pointer for lazy people
|
// pointer for lazy people
|
||||||
typedef QSharedPointer<BaseInstance> InstancePtr;
|
typedef std::shared_ptr<BaseInstance> InstancePtr;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
class BaseInstance;
|
class BaseInstance;
|
||||||
|
|
||||||
#define I_D(Class) Class##Private * const d = (Class##Private * const) inst_d.data()
|
#define I_D(Class) Class##Private * const d = (Class##Private * const) inst_d.get()
|
||||||
|
|
||||||
struct BaseInstancePrivate
|
struct BaseInstancePrivate
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <QSharedPointer>
|
#include <memory>
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* An abstract base class for versions.
|
* An abstract base class for versions.
|
||||||
@ -40,6 +40,6 @@ struct BaseVersion
|
|||||||
virtual QString typeString() const = 0;
|
virtual QString typeString() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QSharedPointer<BaseVersion> BaseVersionPtr;
|
typedef std::shared_ptr<BaseVersion> BaseVersionPtr;
|
||||||
|
|
||||||
Q_DECLARE_METATYPE( BaseVersionPtr )
|
Q_DECLARE_METATYPE( BaseVersionPtr )
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
ForgeInstaller::ForgeInstaller(QString filename, QString universal_url)
|
ForgeInstaller::ForgeInstaller(QString filename, QString universal_url)
|
||||||
{
|
{
|
||||||
QSharedPointer<OneSixVersion> newVersion;
|
std::shared_ptr<OneSixVersion> newVersion;
|
||||||
m_universal_url = universal_url;
|
m_universal_url = universal_url;
|
||||||
|
|
||||||
QuaZip zip(filename);
|
QuaZip zip(filename);
|
||||||
@ -88,7 +88,7 @@ ForgeInstaller::ForgeInstaller(QString filename, QString universal_url)
|
|||||||
realVersionId = m_forge_version->id = installObj.value("minecraft").toString();
|
realVersionId = m_forge_version->id = installObj.value("minecraft").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ForgeInstaller::apply(QSharedPointer<OneSixVersion> to)
|
bool ForgeInstaller::apply(std::shared_ptr<OneSixVersion> to)
|
||||||
{
|
{
|
||||||
if (!m_forge_version)
|
if (!m_forge_version)
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QSharedPointer>
|
#include <memory>
|
||||||
|
|
||||||
class OneSixVersion;
|
class OneSixVersion;
|
||||||
|
|
||||||
@ -9,11 +9,11 @@ class ForgeInstaller
|
|||||||
public:
|
public:
|
||||||
ForgeInstaller(QString filename, QString universal_url);
|
ForgeInstaller(QString filename, QString universal_url);
|
||||||
|
|
||||||
bool apply(QSharedPointer<OneSixVersion> to);
|
bool apply(std::shared_ptr<OneSixVersion> to);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// the version, read from the installer
|
// the version, read from the installer
|
||||||
QSharedPointer<OneSixVersion> m_forge_version;
|
std::shared_ptr<OneSixVersion> m_forge_version;
|
||||||
QString internalPath;
|
QString internalPath;
|
||||||
QString finalPath;
|
QString finalPath;
|
||||||
QString realVersionId;
|
QString realVersionId;
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <setting.h>
|
#include <setting.h>
|
||||||
|
|
||||||
#include "pathutils.h"
|
#include "pathutils.h"
|
||||||
|
#include <logger/QsLog.h>
|
||||||
|
|
||||||
InstanceFactory InstanceFactory::loader;
|
InstanceFactory InstanceFactory::loader;
|
||||||
|
|
||||||
@ -72,12 +73,12 @@ InstanceFactory::InstCreateError InstanceFactory::createInstance( BaseInstance*&
|
|||||||
{
|
{
|
||||||
QDir rootDir(instDir);
|
QDir rootDir(instDir);
|
||||||
|
|
||||||
qDebug(instDir.toUtf8());
|
QLOG_DEBUG() << instDir.toUtf8();
|
||||||
if (!rootDir.exists() && !rootDir.mkpath("."))
|
if (!rootDir.exists() && !rootDir.mkpath("."))
|
||||||
{
|
{
|
||||||
return InstanceFactory::CantCreateDir;
|
return InstanceFactory::CantCreateDir;
|
||||||
}
|
}
|
||||||
auto mcVer = version.dynamicCast<MinecraftVersion>();
|
auto mcVer = std::dynamic_pointer_cast<MinecraftVersion>(version);
|
||||||
if(!mcVer)
|
if(!mcVer)
|
||||||
return InstanceFactory::NoSuchVersion;
|
return InstanceFactory::NoSuchVersion;
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ int InstanceLauncher::launch()
|
|||||||
{
|
{
|
||||||
std::cout << "Launching Instance '" << qPrintable ( instId ) << "'" << std::endl;
|
std::cout << "Launching Instance '" << qPrintable ( instId ) << "'" << std::endl;
|
||||||
auto instance = MMC->instances()->getInstanceById(instId);
|
auto instance = MMC->instances()->getInstanceById(instId);
|
||||||
if ( instance.isNull() )
|
if ( !instance )
|
||||||
{
|
{
|
||||||
std::cout << "Could not find instance requested. note that you have to specify the ID, not the NAME" << std::endl;
|
std::cout << "Could not find instance requested. note that you have to specify the ID, not the NAME" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -92,7 +92,7 @@ void LegacyInstance::cleanupAfterRun()
|
|||||||
//FIXME: delete the launcher and icons and whatnot.
|
//FIXME: delete the launcher and icons and whatnot.
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer< ModList > LegacyInstance::coreModList()
|
std::shared_ptr< ModList > LegacyInstance::coreModList()
|
||||||
{
|
{
|
||||||
I_D(LegacyInstance);
|
I_D(LegacyInstance);
|
||||||
if(!d->core_mod_list)
|
if(!d->core_mod_list)
|
||||||
@ -104,7 +104,7 @@ QSharedPointer< ModList > LegacyInstance::coreModList()
|
|||||||
return d->core_mod_list;
|
return d->core_mod_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer< ModList > LegacyInstance::jarModList()
|
std::shared_ptr< ModList > LegacyInstance::jarModList()
|
||||||
{
|
{
|
||||||
I_D(LegacyInstance);
|
I_D(LegacyInstance);
|
||||||
if(!d->jar_mod_list)
|
if(!d->jar_mod_list)
|
||||||
@ -124,7 +124,7 @@ void LegacyInstance::jarModsChanged()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QSharedPointer< ModList > LegacyInstance::loaderModList()
|
std::shared_ptr< ModList > LegacyInstance::loaderModList()
|
||||||
{
|
{
|
||||||
I_D(LegacyInstance);
|
I_D(LegacyInstance);
|
||||||
if(!d->loader_mod_list)
|
if(!d->loader_mod_list)
|
||||||
@ -136,7 +136,7 @@ QSharedPointer< ModList > LegacyInstance::loaderModList()
|
|||||||
return d->loader_mod_list;
|
return d->loader_mod_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer< ModList > LegacyInstance::texturePackList()
|
std::shared_ptr< ModList > LegacyInstance::texturePackList()
|
||||||
{
|
{
|
||||||
I_D(LegacyInstance);
|
I_D(LegacyInstance);
|
||||||
if(!d->texture_pack_list)
|
if(!d->texture_pack_list)
|
||||||
|
@ -19,10 +19,10 @@ public:
|
|||||||
QString modListFile() const;
|
QString modListFile() const;
|
||||||
|
|
||||||
////// Mod Lists //////
|
////// Mod Lists //////
|
||||||
QSharedPointer<ModList> jarModList();
|
std::shared_ptr<ModList> jarModList();
|
||||||
QSharedPointer<ModList> coreModList();
|
std::shared_ptr<ModList> coreModList();
|
||||||
QSharedPointer<ModList> loaderModList();
|
std::shared_ptr<ModList> loaderModList();
|
||||||
QSharedPointer<ModList> texturePackList();
|
std::shared_ptr<ModList> texturePackList();
|
||||||
|
|
||||||
////// Directories //////
|
////// Directories //////
|
||||||
QString savesDir() const;
|
QString savesDir() const;
|
||||||
|
@ -9,8 +9,8 @@ class ModList;
|
|||||||
|
|
||||||
struct LegacyInstancePrivate: public BaseInstancePrivate
|
struct LegacyInstancePrivate: public BaseInstancePrivate
|
||||||
{
|
{
|
||||||
QSharedPointer<ModList> jar_mod_list;
|
std::shared_ptr<ModList> jar_mod_list;
|
||||||
QSharedPointer<ModList> core_mod_list;
|
std::shared_ptr<ModList> core_mod_list;
|
||||||
QSharedPointer<ModList> loader_mod_list;
|
std::shared_ptr<ModList> loader_mod_list;
|
||||||
QSharedPointer<ModList> texture_pack_list;
|
std::shared_ptr<ModList> texture_pack_list;
|
||||||
};
|
};
|
@ -9,9 +9,11 @@
|
|||||||
#include <quazip.h>
|
#include <quazip.h>
|
||||||
#include <quazipfile.h>
|
#include <quazipfile.h>
|
||||||
#include <JlCompress.h>
|
#include <JlCompress.h>
|
||||||
|
#include <logger/QsLog.h>
|
||||||
|
|
||||||
|
LegacyUpdate::LegacyUpdate(BaseInstance *inst, QObject *parent) : BaseUpdate(inst, parent)
|
||||||
LegacyUpdate::LegacyUpdate ( BaseInstance* inst, QObject* parent ) : BaseUpdate ( inst, parent ) {}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void LegacyUpdate::executeTask()
|
void LegacyUpdate::executeTask()
|
||||||
{
|
{
|
||||||
@ -20,35 +22,35 @@ void LegacyUpdate::executeTask()
|
|||||||
|
|
||||||
void LegacyUpdate::lwjglStart()
|
void LegacyUpdate::lwjglStart()
|
||||||
{
|
{
|
||||||
LegacyInstance * inst = (LegacyInstance *) m_inst;
|
LegacyInstance *inst = (LegacyInstance *)m_inst;
|
||||||
|
|
||||||
|
lwjglVersion = inst->lwjglVersion();
|
||||||
|
lwjglTargetPath = PathCombine("lwjgl", lwjglVersion);
|
||||||
|
lwjglNativesPath = PathCombine(lwjglTargetPath, "natives");
|
||||||
|
|
||||||
lwjglVersion = inst->lwjglVersion();
|
|
||||||
lwjglTargetPath = PathCombine("lwjgl", lwjglVersion );
|
|
||||||
lwjglNativesPath = PathCombine( lwjglTargetPath, "natives");
|
|
||||||
|
|
||||||
// if the 'done' file exists, we don't have to download this again
|
// if the 'done' file exists, we don't have to download this again
|
||||||
QFileInfo doneFile(PathCombine(lwjglTargetPath, "done"));
|
QFileInfo doneFile(PathCombine(lwjglTargetPath, "done"));
|
||||||
if(doneFile.exists())
|
if (doneFile.exists())
|
||||||
{
|
{
|
||||||
jarStart();
|
jarStart();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto list = MMC->lwjgllist();
|
auto list = MMC->lwjgllist();
|
||||||
if(!list->isLoaded())
|
if (!list->isLoaded())
|
||||||
{
|
{
|
||||||
emitFailed("Too soon! Let the LWJGL list load :)");
|
emitFailed("Too soon! Let the LWJGL list load :)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setStatus("Downloading new LWJGL.");
|
setStatus("Downloading new LWJGL.");
|
||||||
auto version = list->getVersion(lwjglVersion);
|
auto version = list->getVersion(lwjglVersion);
|
||||||
if(!version)
|
if (!version)
|
||||||
{
|
{
|
||||||
emitFailed("Game update failed: the selected LWJGL version is invalid.");
|
emitFailed("Game update failed: the selected LWJGL version is invalid.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString url = version->url();
|
QString url = version->url();
|
||||||
QUrl realUrl(url);
|
QUrl realUrl(url);
|
||||||
QString hostname = realUrl.host();
|
QString hostname = realUrl.host();
|
||||||
@ -56,39 +58,42 @@ void LegacyUpdate::lwjglStart()
|
|||||||
QNetworkRequest req(realUrl);
|
QNetworkRequest req(realUrl);
|
||||||
req.setRawHeader("Host", hostname.toLatin1());
|
req.setRawHeader("Host", hostname.toLatin1());
|
||||||
req.setHeader(QNetworkRequest::UserAgentHeader, "Wget/1.14 (linux-gnu)");
|
req.setHeader(QNetworkRequest::UserAgentHeader, "Wget/1.14 (linux-gnu)");
|
||||||
QNetworkReply * rep = worker->get ( req );
|
QNetworkReply *rep = worker->get(req);
|
||||||
|
|
||||||
m_reply = QSharedPointer<QNetworkReply> (rep, &QObject::deleteLater);
|
m_reply = std::shared_ptr<QNetworkReply>(rep);
|
||||||
connect(rep, SIGNAL(downloadProgress(qint64,qint64)), SIGNAL(progress(qint64,qint64)));
|
connect(rep, SIGNAL(downloadProgress(qint64, qint64)), SIGNAL(progress(qint64, qint64)));
|
||||||
connect(worker.data(), SIGNAL(finished(QNetworkReply*)), SLOT(lwjglFinished(QNetworkReply*)));
|
connect(worker.get(), SIGNAL(finished(QNetworkReply *)),
|
||||||
//connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(downloadError(QNetworkReply::NetworkError)));
|
SLOT(lwjglFinished(QNetworkReply *)));
|
||||||
|
// connect(rep, SIGNAL(error(QNetworkReply::NetworkError)),
|
||||||
|
// SLOT(downloadError(QNetworkReply::NetworkError)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LegacyUpdate::lwjglFinished(QNetworkReply* reply)
|
void LegacyUpdate::lwjglFinished(QNetworkReply *reply)
|
||||||
{
|
{
|
||||||
if(m_reply != reply)
|
if (m_reply.get() != reply)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(reply->error() != QNetworkReply::NoError)
|
if (reply->error() != QNetworkReply::NoError)
|
||||||
{
|
{
|
||||||
emitFailed( "Failed to download: "+
|
emitFailed("Failed to download: " + reply->errorString() +
|
||||||
reply->errorString()+
|
"\nSometimes you have to wait a bit if you download many LWJGL versions in "
|
||||||
"\nSometimes you have to wait a bit if you download many LWJGL versions in a row. YMMV");
|
"a row. YMMV");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto worker = MMC->qnam();
|
auto worker = MMC->qnam();
|
||||||
//Here i check if there is a cookie for me in the reply and extract it
|
// Here i check if there is a cookie for me in the reply and extract it
|
||||||
QList<QNetworkCookie> cookies = qvariant_cast<QList<QNetworkCookie>>(reply->header(QNetworkRequest::SetCookieHeader));
|
QList<QNetworkCookie> cookies =
|
||||||
if(cookies.count() != 0)
|
qvariant_cast<QList<QNetworkCookie>>(reply->header(QNetworkRequest::SetCookieHeader));
|
||||||
|
if (cookies.count() != 0)
|
||||||
{
|
{
|
||||||
//you must tell which cookie goes with which url
|
// you must tell which cookie goes with which url
|
||||||
worker->cookieJar()->setCookiesFromUrl(cookies, QUrl("sourceforge.net"));
|
worker->cookieJar()->setCookiesFromUrl(cookies, QUrl("sourceforge.net"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//here you can check for the 302 or whatever other header i need
|
// here you can check for the 302 or whatever other header i need
|
||||||
QVariant newLoc = reply->header(QNetworkRequest::LocationHeader);
|
QVariant newLoc = reply->header(QNetworkRequest::LocationHeader);
|
||||||
if(newLoc.isValid())
|
if (newLoc.isValid())
|
||||||
{
|
{
|
||||||
QString redirectedTo = reply->header(QNetworkRequest::LocationHeader).toString();
|
QString redirectedTo = reply->header(QNetworkRequest::LocationHeader).toString();
|
||||||
QUrl realUrl(redirectedTo);
|
QUrl realUrl(redirectedTo);
|
||||||
@ -96,9 +101,10 @@ void LegacyUpdate::lwjglFinished(QNetworkReply* reply)
|
|||||||
QNetworkRequest req(redirectedTo);
|
QNetworkRequest req(redirectedTo);
|
||||||
req.setRawHeader("Host", hostname.toLatin1());
|
req.setRawHeader("Host", hostname.toLatin1());
|
||||||
req.setHeader(QNetworkRequest::UserAgentHeader, "Wget/1.14 (linux-gnu)");
|
req.setHeader(QNetworkRequest::UserAgentHeader, "Wget/1.14 (linux-gnu)");
|
||||||
QNetworkReply * rep = worker->get(req);
|
QNetworkReply *rep = worker->get(req);
|
||||||
connect(rep, SIGNAL(downloadProgress(qint64,qint64)), SIGNAL(progress(qint64,qint64)));
|
connect(rep, SIGNAL(downloadProgress(qint64, qint64)),
|
||||||
m_reply = QSharedPointer<QNetworkReply> (rep, &QObject::deleteLater);
|
SIGNAL(progress(qint64, qint64)));
|
||||||
|
m_reply = std::shared_ptr<QNetworkReply>(rep);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QFile saveMe("lwjgl.zip");
|
QFile saveMe("lwjgl.zip");
|
||||||
@ -114,26 +120,26 @@ void LegacyUpdate::extractLwjgl()
|
|||||||
// make sure the directories are there
|
// make sure the directories are there
|
||||||
|
|
||||||
bool success = ensureFolderPathExists(lwjglNativesPath);
|
bool success = ensureFolderPathExists(lwjglNativesPath);
|
||||||
|
|
||||||
if(!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
emitFailed("Failed to extract the lwjgl libs - error when creating required folders.");
|
emitFailed("Failed to extract the lwjgl libs - error when creating required folders.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QuaZip zip("lwjgl.zip");
|
QuaZip zip("lwjgl.zip");
|
||||||
if(!zip.open(QuaZip::mdUnzip))
|
if (!zip.open(QuaZip::mdUnzip))
|
||||||
{
|
{
|
||||||
emitFailed("Failed to extract the lwjgl libs - not a valid archive.");
|
emitFailed("Failed to extract the lwjgl libs - not a valid archive.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// and now we are going to access files inside it
|
// and now we are going to access files inside it
|
||||||
QuaZipFile file(&zip);
|
QuaZipFile file(&zip);
|
||||||
const QString jarNames[] = { "jinput.jar", "lwjgl_util.jar", "lwjgl.jar" };
|
const QString jarNames[] = {"jinput.jar", "lwjgl_util.jar", "lwjgl.jar"};
|
||||||
for(bool more=zip.goToFirstFile(); more; more=zip.goToNextFile())
|
for (bool more = zip.goToFirstFile(); more; more = zip.goToNextFile())
|
||||||
{
|
{
|
||||||
if(!file.open(QIODevice::ReadOnly))
|
if (!file.open(QIODevice::ReadOnly))
|
||||||
{
|
{
|
||||||
zip.close();
|
zip.close();
|
||||||
emitFailed("Failed to extract the lwjgl libs - error while reading archive.");
|
emitFailed("Failed to extract the lwjgl libs - error while reading archive.");
|
||||||
@ -141,7 +147,7 @@ void LegacyUpdate::extractLwjgl()
|
|||||||
}
|
}
|
||||||
QuaZipFileInfo info;
|
QuaZipFileInfo info;
|
||||||
QString name = file.getActualFileName();
|
QString name = file.getActualFileName();
|
||||||
if(name.endsWith('/'))
|
if (name.endsWith('/'))
|
||||||
{
|
{
|
||||||
file.close();
|
file.close();
|
||||||
continue;
|
continue;
|
||||||
@ -156,25 +162,25 @@ void LegacyUpdate::extractLwjgl()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Not found? look for the natives
|
// Not found? look for the natives
|
||||||
if(destFileName.isEmpty())
|
if (destFileName.isEmpty())
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
QString nativesDir = "windows";
|
QString nativesDir = "windows";
|
||||||
#else
|
#else
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
QString nativesDir = "macosx";
|
QString nativesDir = "macosx";
|
||||||
#else
|
#else
|
||||||
QString nativesDir = "linux";
|
QString nativesDir = "linux";
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
if (name.contains(nativesDir))
|
if (name.contains(nativesDir))
|
||||||
{
|
{
|
||||||
int lastSlash = name.lastIndexOf('/');
|
int lastSlash = name.lastIndexOf('/');
|
||||||
int lastBackSlash = name.lastIndexOf('\\');
|
int lastBackSlash = name.lastIndexOf('\\');
|
||||||
if(lastSlash != -1)
|
if (lastSlash != -1)
|
||||||
name = name.mid(lastSlash+1);
|
name = name.mid(lastSlash + 1);
|
||||||
else if(lastBackSlash != -1)
|
else if (lastBackSlash != -1)
|
||||||
name = name.mid(lastBackSlash+1);
|
name = name.mid(lastBackSlash + 1);
|
||||||
destFileName = PathCombine(lwjglNativesPath, name);
|
destFileName = PathCombine(lwjglNativesPath, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -190,7 +196,7 @@ void LegacyUpdate::extractLwjgl()
|
|||||||
file.close(); // do not forget to close!
|
file.close(); // do not forget to close!
|
||||||
}
|
}
|
||||||
zip.close();
|
zip.close();
|
||||||
m_reply.clear();
|
m_reply.reset();
|
||||||
QFile doneFile(PathCombine(lwjglTargetPath, "done"));
|
QFile doneFile(PathCombine(lwjglTargetPath, "done"));
|
||||||
doneFile.open(QIODevice::WriteOnly);
|
doneFile.open(QIODevice::WriteOnly);
|
||||||
doneFile.write("done.");
|
doneFile.write("done.");
|
||||||
@ -204,13 +210,13 @@ void LegacyUpdate::lwjglFailed()
|
|||||||
|
|
||||||
void LegacyUpdate::jarStart()
|
void LegacyUpdate::jarStart()
|
||||||
{
|
{
|
||||||
LegacyInstance * inst = (LegacyInstance *) m_inst;
|
LegacyInstance *inst = (LegacyInstance *)m_inst;
|
||||||
if(!inst->shouldUpdate() || inst->shouldUseCustomBaseJar())
|
if (!inst->shouldUpdate() || inst->shouldUseCustomBaseJar())
|
||||||
{
|
{
|
||||||
ModTheJar();
|
ModTheJar();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setStatus("Checking for jar updates...");
|
setStatus("Checking for jar updates...");
|
||||||
// Make directories
|
// Make directories
|
||||||
QDir binDir(inst->binDir());
|
QDir binDir(inst->binDir());
|
||||||
@ -226,13 +232,13 @@ void LegacyUpdate::jarStart()
|
|||||||
QString urlstr("http://s3.amazonaws.com/Minecraft.Download/versions/");
|
QString urlstr("http://s3.amazonaws.com/Minecraft.Download/versions/");
|
||||||
QString intended_version_id = inst->intendedVersionId();
|
QString intended_version_id = inst->intendedVersionId();
|
||||||
urlstr += intended_version_id + "/" + intended_version_id + ".jar";
|
urlstr += intended_version_id + "/" + intended_version_id + ".jar";
|
||||||
|
|
||||||
auto dljob = new DownloadJob("Minecraft.jar for version " + intended_version_id);
|
auto dljob = new DownloadJob("Minecraft.jar for version " + intended_version_id);
|
||||||
dljob->addFileDownload(QUrl(urlstr), inst->defaultBaseJar());
|
dljob->addFileDownload(QUrl(urlstr), inst->defaultBaseJar());
|
||||||
legacyDownloadJob.reset(dljob);
|
legacyDownloadJob.reset(dljob);
|
||||||
connect(dljob, SIGNAL(succeeded()), SLOT(jarFinished()));
|
connect(dljob, SIGNAL(succeeded()), SLOT(jarFinished()));
|
||||||
connect(dljob, SIGNAL(failed()), SLOT(jarFailed()));
|
connect(dljob, SIGNAL(failed()), SLOT(jarFailed()));
|
||||||
connect(dljob, SIGNAL(progress(qint64,qint64)), SIGNAL(progress(qint64,qint64)));
|
connect(dljob, SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64)));
|
||||||
legacyDownloadJob->start();
|
legacyDownloadJob->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,34 +254,36 @@ void LegacyUpdate::jarFailed()
|
|||||||
emitFailed("Failed to download the minecraft jar. Try again later.");
|
emitFailed("Failed to download the minecraft jar. Try again later.");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LegacyUpdate::MergeZipFiles( QuaZip* into, QFileInfo from, QSet< QString >& contained, MetainfAction metainf )
|
bool LegacyUpdate::MergeZipFiles(QuaZip *into, QFileInfo from, QSet<QString> &contained,
|
||||||
|
MetainfAction metainf)
|
||||||
{
|
{
|
||||||
setStatus("Installing mods - Adding " + from.fileName());
|
setStatus("Installing mods - Adding " + from.fileName());
|
||||||
|
|
||||||
QuaZip modZip(from.filePath());
|
QuaZip modZip(from.filePath());
|
||||||
modZip.open(QuaZip::mdUnzip);
|
modZip.open(QuaZip::mdUnzip);
|
||||||
|
|
||||||
QuaZipFile fileInsideMod(&modZip);
|
QuaZipFile fileInsideMod(&modZip);
|
||||||
QuaZipFile zipOutFile( into );
|
QuaZipFile zipOutFile(into);
|
||||||
for(bool more=modZip.goToFirstFile(); more; more=modZip.goToNextFile())
|
for (bool more = modZip.goToFirstFile(); more; more = modZip.goToNextFile())
|
||||||
{
|
{
|
||||||
QString filename = modZip.getCurrentFileName();
|
QString filename = modZip.getCurrentFileName();
|
||||||
if(filename.contains("META-INF") && metainf == LegacyUpdate::IgnoreMetainf)
|
if (filename.contains("META-INF") && metainf == LegacyUpdate::IgnoreMetainf)
|
||||||
{
|
{
|
||||||
qDebug() << "Skipping META-INF " << filename << " from " << from.fileName();
|
QLOG_INFO() << "Skipping META-INF " << filename << " from " << from.fileName();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(contained.contains(filename))
|
if (contained.contains(filename))
|
||||||
{
|
{
|
||||||
qDebug() << "Skipping already contained file " << filename << " from " << from.fileName();
|
QLOG_INFO() << "Skipping already contained file " << filename << " from "
|
||||||
|
<< from.fileName();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
contained.insert(filename);
|
contained.insert(filename);
|
||||||
qDebug() << "Adding file " << filename << " from " << from.fileName();
|
QLOG_INFO() << "Adding file " << filename << " from " << from.fileName();
|
||||||
|
|
||||||
if(!fileInsideMod.open(QIODevice::ReadOnly))
|
if (!fileInsideMod.open(QIODevice::ReadOnly))
|
||||||
{
|
{
|
||||||
qDebug() << "Failed to open " << filename << " from " << from.fileName();
|
QLOG_ERROR() << "Failed to open " << filename << " from " << from.fileName();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -286,17 +294,17 @@ bool LegacyUpdate::MergeZipFiles( QuaZip* into, QFileInfo from, QSet< QString >&
|
|||||||
/*
|
/*
|
||||||
info_out.externalAttr = old_info.externalAttr;
|
info_out.externalAttr = old_info.externalAttr;
|
||||||
*/
|
*/
|
||||||
if(!zipOutFile.open(QIODevice::WriteOnly, info_out))
|
if (!zipOutFile.open(QIODevice::WriteOnly, info_out))
|
||||||
{
|
{
|
||||||
qDebug() << "Failed to open " << filename << " in the jar";
|
QLOG_ERROR() << "Failed to open " << filename << " in the jar";
|
||||||
fileInsideMod.close();
|
fileInsideMod.close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!JlCompress::copyData(fileInsideMod, zipOutFile))
|
if (!JlCompress::copyData(fileInsideMod, zipOutFile))
|
||||||
{
|
{
|
||||||
zipOutFile.close();
|
zipOutFile.close();
|
||||||
fileInsideMod.close();
|
fileInsideMod.close();
|
||||||
qDebug() << "Failed to copy data of " << filename << " into the jar";
|
QLOG_ERROR() << "Failed to copy data of " << filename << " into the jar";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
zipOutFile.close();
|
zipOutFile.close();
|
||||||
@ -307,34 +315,34 @@ bool LegacyUpdate::MergeZipFiles( QuaZip* into, QFileInfo from, QSet< QString >&
|
|||||||
|
|
||||||
void LegacyUpdate::ModTheJar()
|
void LegacyUpdate::ModTheJar()
|
||||||
{
|
{
|
||||||
LegacyInstance * inst = (LegacyInstance *) m_inst;
|
LegacyInstance *inst = (LegacyInstance *)m_inst;
|
||||||
|
|
||||||
if(!inst->shouldRebuild())
|
if (!inst->shouldRebuild())
|
||||||
{
|
{
|
||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the mod list
|
// Get the mod list
|
||||||
auto modList = inst->jarModList();
|
auto modList = inst->jarModList();
|
||||||
|
|
||||||
QFileInfo runnableJar (inst->runnableJar());
|
QFileInfo runnableJar(inst->runnableJar());
|
||||||
QFileInfo baseJar (inst->baseJar());
|
QFileInfo baseJar(inst->baseJar());
|
||||||
bool base_is_custom = inst->shouldUseCustomBaseJar();
|
bool base_is_custom = inst->shouldUseCustomBaseJar();
|
||||||
|
|
||||||
// Nothing to do if there are no jar mods to install, no backup and just the mc jar
|
// Nothing to do if there are no jar mods to install, no backup and just the mc jar
|
||||||
if(base_is_custom)
|
if (base_is_custom)
|
||||||
{
|
{
|
||||||
// yes, this can happen if the instance only has the runnable jar and not the base jar
|
// yes, this can happen if the instance only has the runnable jar and not the base jar
|
||||||
// it *could* be assumed that such an instance is vanilla, but that wouldn't be safe
|
// it *could* be assumed that such an instance is vanilla, but that wouldn't be safe
|
||||||
// because that's not something mmc4 guarantees
|
// because that's not something mmc4 guarantees
|
||||||
if(runnableJar.isFile() && !baseJar.exists() && modList->empty())
|
if (runnableJar.isFile() && !baseJar.exists() && modList->empty())
|
||||||
{
|
{
|
||||||
inst->setShouldRebuild(false);
|
inst->setShouldRebuild(false);
|
||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setStatus("Installing mods - backing up minecraft.jar...");
|
setStatus("Installing mods - backing up minecraft.jar...");
|
||||||
if (!baseJar.exists() && !QFile::copy(runnableJar.filePath(), baseJar.filePath()))
|
if (!baseJar.exists() && !QFile::copy(runnableJar.filePath(), baseJar.filePath()))
|
||||||
{
|
{
|
||||||
@ -342,24 +350,24 @@ void LegacyUpdate::ModTheJar()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!baseJar.exists())
|
if (!baseJar.exists())
|
||||||
{
|
{
|
||||||
emitFailed("The base jar " + baseJar.filePath() + " does not exist");
|
emitFailed("The base jar " + baseJar.filePath() + " does not exist");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (runnableJar.exists() && !QFile::remove(runnableJar.filePath()))
|
if (runnableJar.exists() && !QFile::remove(runnableJar.filePath()))
|
||||||
{
|
{
|
||||||
emitFailed("Failed to delete old minecraft.jar");
|
emitFailed("Failed to delete old minecraft.jar");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TaskStep(); // STEP 1
|
// TaskStep(); // STEP 1
|
||||||
setStatus("Installing mods - Opening minecraft.jar");
|
setStatus("Installing mods - Opening minecraft.jar");
|
||||||
|
|
||||||
QuaZip zipOut(runnableJar.filePath());
|
QuaZip zipOut(runnableJar.filePath());
|
||||||
if(!zipOut.open(QuaZip::mdCreate))
|
if (!zipOut.open(QuaZip::mdCreate))
|
||||||
{
|
{
|
||||||
QFile::remove(runnableJar.filePath());
|
QFile::remove(runnableJar.filePath());
|
||||||
emitFailed("Failed to open the minecraft.jar for modding");
|
emitFailed("Failed to open the minecraft.jar for modding");
|
||||||
@ -376,7 +384,7 @@ void LegacyUpdate::ModTheJar()
|
|||||||
auto &mod = modList->operator[](i);
|
auto &mod = modList->operator[](i);
|
||||||
if (mod.type() == Mod::MOD_ZIPFILE)
|
if (mod.type() == Mod::MOD_ZIPFILE)
|
||||||
{
|
{
|
||||||
if(!MergeZipFiles(&zipOut, mod.filename(), addedFiles, LegacyUpdate::KeepMetainf))
|
if (!MergeZipFiles(&zipOut, mod.filename(), addedFiles, LegacyUpdate::KeepMetainf))
|
||||||
{
|
{
|
||||||
zipOut.close();
|
zipOut.close();
|
||||||
QFile::remove(runnableJar.filePath());
|
QFile::remove(runnableJar.filePath());
|
||||||
@ -387,7 +395,8 @@ void LegacyUpdate::ModTheJar()
|
|||||||
else if (mod.type() == Mod::MOD_SINGLEFILE)
|
else if (mod.type() == Mod::MOD_SINGLEFILE)
|
||||||
{
|
{
|
||||||
auto filename = mod.filename();
|
auto filename = mod.filename();
|
||||||
if(!JlCompress::compressFile(&zipOut, filename.absoluteFilePath(), filename.fileName()))
|
if (!JlCompress::compressFile(&zipOut, filename.absoluteFilePath(),
|
||||||
|
filename.fileName()))
|
||||||
{
|
{
|
||||||
zipOut.close();
|
zipOut.close();
|
||||||
QFile::remove(runnableJar.filePath());
|
QFile::remove(runnableJar.filePath());
|
||||||
@ -395,7 +404,8 @@ void LegacyUpdate::ModTheJar()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
addedFiles.insert(filename.fileName());
|
addedFiles.insert(filename.fileName());
|
||||||
qDebug() << "Adding file " << filename.fileName() << " from " << filename.absoluteFilePath();
|
QLOG_INFO() << "Adding file " << filename.fileName() << " from "
|
||||||
|
<< filename.absoluteFilePath();
|
||||||
}
|
}
|
||||||
else if (mod.type() == Mod::MOD_FOLDER)
|
else if (mod.type() == Mod::MOD_FOLDER)
|
||||||
{
|
{
|
||||||
@ -404,35 +414,36 @@ void LegacyUpdate::ModTheJar()
|
|||||||
QDir dir(what_to_zip);
|
QDir dir(what_to_zip);
|
||||||
dir.cdUp();
|
dir.cdUp();
|
||||||
QString parent_dir = dir.absolutePath();
|
QString parent_dir = dir.absolutePath();
|
||||||
if(!JlCompress::compressSubDir(&zipOut, what_to_zip, parent_dir, true, addedFiles))
|
if (!JlCompress::compressSubDir(&zipOut, what_to_zip, parent_dir, true, addedFiles))
|
||||||
{
|
{
|
||||||
zipOut.close();
|
zipOut.close();
|
||||||
QFile::remove(runnableJar.filePath());
|
QFile::remove(runnableJar.filePath());
|
||||||
emitFailed("Failed to add " + filename.fileName() + " to the jar");
|
emitFailed("Failed to add " + filename.fileName() + " to the jar");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qDebug() << "Adding folder " << filename.fileName() << " from " << filename.absoluteFilePath();
|
QLOG_INFO() << "Adding folder " << filename.fileName() << " from "
|
||||||
|
<< filename.absoluteFilePath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!MergeZipFiles(&zipOut, baseJar, addedFiles, LegacyUpdate::IgnoreMetainf))
|
if (!MergeZipFiles(&zipOut, baseJar, addedFiles, LegacyUpdate::IgnoreMetainf))
|
||||||
{
|
{
|
||||||
zipOut.close();
|
zipOut.close();
|
||||||
QFile::remove(runnableJar.filePath());
|
QFile::remove(runnableJar.filePath());
|
||||||
emitFailed("Failed to insert minecraft.jar contents.");
|
emitFailed("Failed to insert minecraft.jar contents.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recompress the jar
|
// Recompress the jar
|
||||||
zipOut.close();
|
zipOut.close();
|
||||||
if(zipOut.getZipError()!=0)
|
if (zipOut.getZipError() != 0)
|
||||||
{
|
{
|
||||||
QFile::remove(runnableJar.filePath());
|
QFile::remove(runnableJar.filePath());
|
||||||
emitFailed("Failed to finalize minecraft.jar!");
|
emitFailed("Failed to finalize minecraft.jar!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
inst->setShouldRebuild(false);
|
inst->setShouldRebuild(false);
|
||||||
//inst->UpdateVersion(true);
|
// inst->UpdateVersion(true);
|
||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
@ -56,7 +56,7 @@ private:
|
|||||||
bool MergeZipFiles(QuaZip *into, QFileInfo from, QSet<QString>& contained, MetainfAction metainf);
|
bool MergeZipFiles(QuaZip *into, QFileInfo from, QSet<QString>& contained, MetainfAction metainf);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QSharedPointer<QNetworkReply> m_reply;
|
std::shared_ptr<QNetworkReply> m_reply;
|
||||||
|
|
||||||
// target version, determined during this task
|
// target version, determined during this task
|
||||||
// MinecraftVersion *targetVersion;
|
// MinecraftVersion *targetVersion;
|
||||||
|
@ -20,14 +20,13 @@
|
|||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
#include <QDebug>
|
|
||||||
#include <quazip.h>
|
#include <quazip.h>
|
||||||
#include <quazipfile.h>
|
#include <quazipfile.h>
|
||||||
|
|
||||||
#include "Mod.h"
|
#include "Mod.h"
|
||||||
#include <pathutils.h>
|
#include <pathutils.h>
|
||||||
#include <inifile.h>
|
#include <inifile.h>
|
||||||
|
#include <logger/QsLog.h>
|
||||||
|
|
||||||
Mod::Mod( const QFileInfo& file )
|
Mod::Mod( const QFileInfo& file )
|
||||||
{
|
{
|
||||||
@ -134,8 +133,8 @@ void Mod::ReadMCModInfo(QByteArray contents)
|
|||||||
int version = val.toDouble();
|
int version = val.toDouble();
|
||||||
if(version != 2)
|
if(version != 2)
|
||||||
{
|
{
|
||||||
qDebug() << "BAD stuff happened to mod json:";
|
QLOG_ERROR() << "BAD stuff happened to mod json:";
|
||||||
qDebug() << contents;
|
QLOG_ERROR() << contents;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto arrVal = jsonDoc.object().value("modlist");
|
auto arrVal = jsonDoc.object().value("modlist");
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
#include <pathutils.h>
|
#include <pathutils.h>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QDebug>
|
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
#include <QFileSystemWatcher>
|
#include <QFileSystemWatcher>
|
||||||
|
#include <logger/QsLog.h>
|
||||||
|
|
||||||
ModList::ModList ( const QString& dir, const QString& list_file )
|
ModList::ModList ( const QString& dir, const QString& list_file )
|
||||||
: QAbstractListModel(), m_dir(dir), m_list_file(list_file)
|
: QAbstractListModel(), m_dir(dir), m_list_file(list_file)
|
||||||
@ -39,18 +39,18 @@ void ModList::startWatching()
|
|||||||
{
|
{
|
||||||
is_watching = m_watcher->addPath(m_dir.absolutePath());
|
is_watching = m_watcher->addPath(m_dir.absolutePath());
|
||||||
if(is_watching)
|
if(is_watching)
|
||||||
qDebug() << "Started watching " << m_dir.absolutePath();
|
QLOG_INFO() << "Started watching " << m_dir.absolutePath();
|
||||||
else
|
else
|
||||||
qDebug() << "Failed to start watching " << m_dir.absolutePath();
|
QLOG_INFO() << "Failed to start watching " << m_dir.absolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModList::stopWatching()
|
void ModList::stopWatching()
|
||||||
{
|
{
|
||||||
is_watching = !m_watcher->removePath(m_dir.absolutePath());
|
is_watching = !m_watcher->removePath(m_dir.absolutePath());
|
||||||
if(!is_watching)
|
if(!is_watching)
|
||||||
qDebug() << "Stopped watching " << m_dir.absolutePath();
|
QLOG_INFO() << "Stopped watching " << m_dir.absolutePath();
|
||||||
else
|
else
|
||||||
qDebug() << "Failed to stop watching " << m_dir.absolutePath();
|
QLOG_INFO() << "Failed to stop watching " << m_dir.absolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -436,7 +436,7 @@ bool ModList::dropMimeData ( const QMimeData* data, Qt::DropAction action, int r
|
|||||||
row = rowCount();
|
row = rowCount();
|
||||||
if (column == -1)
|
if (column == -1)
|
||||||
column = 0;
|
column = 0;
|
||||||
qDebug() << "Drop row: " << row << " column: " << column;
|
QLOG_INFO() << "Drop row: " << row << " column: " << column;
|
||||||
|
|
||||||
// files dropped from outside?
|
// files dropped from outside?
|
||||||
if(data->hasUrls())
|
if(data->hasUrls())
|
||||||
@ -452,7 +452,7 @@ bool ModList::dropMimeData ( const QMimeData* data, Qt::DropAction action, int r
|
|||||||
continue;
|
continue;
|
||||||
QString filename = url.toLocalFile();
|
QString filename = url.toLocalFile();
|
||||||
installMod(filename, row);
|
installMod(filename, row);
|
||||||
qDebug() << "installing: " << filename;
|
QLOG_INFO() << "installing: " << filename;
|
||||||
}
|
}
|
||||||
if(was_watching)
|
if(was_watching)
|
||||||
startWatching();
|
startWatching();
|
||||||
@ -466,7 +466,7 @@ bool ModList::dropMimeData ( const QMimeData* data, Qt::DropAction action, int r
|
|||||||
return false;
|
return false;
|
||||||
QString remoteId = list[0];
|
QString remoteId = list[0];
|
||||||
int remoteIndex = list[1].toInt();
|
int remoteIndex = list[1].toInt();
|
||||||
qDebug() << "move: " << sourcestr;
|
QLOG_INFO() << "move: " << sourcestr;
|
||||||
// no moving of things between two lists
|
// no moving of things between two lists
|
||||||
if(remoteId != m_list_id)
|
if(remoteId != m_list_id)
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QDebug>
|
#include <logger/QsLog.h>
|
||||||
#include <QtXml/QtXml>
|
#include <QtXml/QtXml>
|
||||||
#include "OneSixAssets.h"
|
#include "OneSixAssets.h"
|
||||||
#include "net/DownloadJob.h"
|
#include "net/DownloadJob.h"
|
||||||
@ -21,6 +21,7 @@ class ThreadedDeleter : public QThread
|
|||||||
public:
|
public:
|
||||||
void run()
|
void run()
|
||||||
{
|
{
|
||||||
|
QLOG_INFO() << "Cleaning up assets folder...";
|
||||||
QDirIterator iter ( m_base, QDirIterator::Subdirectories );
|
QDirIterator iter ( m_base, QDirIterator::Subdirectories );
|
||||||
int base_length = m_base.length();
|
int base_length = m_base.length();
|
||||||
while ( iter.hasNext() )
|
while ( iter.hasNext() )
|
||||||
@ -34,12 +35,12 @@ public:
|
|||||||
trimmedf.remove ( 0, base_length + 1 );
|
trimmedf.remove ( 0, base_length + 1 );
|
||||||
if ( m_whitelist.contains ( trimmedf ) )
|
if ( m_whitelist.contains ( trimmedf ) )
|
||||||
{
|
{
|
||||||
// qDebug() << trimmedf << " gets to live";
|
QLOG_TRACE() << trimmedf << " gets to live";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// DO NOT TOLERATE JUNK
|
// DO NOT TOLERATE JUNK
|
||||||
// qDebug() << trimmedf << " dies";
|
QLOG_TRACE() << trimmedf << " dies";
|
||||||
QFile f ( filename );
|
QFile f ( filename );
|
||||||
f.remove();
|
f.remove();
|
||||||
}
|
}
|
||||||
@ -67,13 +68,15 @@ void OneSixAssets::fetchXMLFinished()
|
|||||||
nuke_whitelist.clear();
|
nuke_whitelist.clear();
|
||||||
|
|
||||||
auto firstJob = index_job->first();
|
auto firstJob = index_job->first();
|
||||||
QByteArray ba = firstJob.dynamicCast<ByteArrayDownload>()->m_data;
|
QByteArray ba = std::dynamic_pointer_cast<ByteArrayDownload>(firstJob)->m_data;
|
||||||
|
|
||||||
QString xmlErrorMsg;
|
QString xmlErrorMsg;
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
if ( !doc.setContent ( ba, false, &xmlErrorMsg ) )
|
if ( !doc.setContent ( ba, false, &xmlErrorMsg ) )
|
||||||
{
|
{
|
||||||
qDebug() << "Failed to process s3.amazonaws.com/Minecraft.Resources. XML error:" << xmlErrorMsg << ba;
|
QLOG_ERROR() << "Failed to process s3.amazonaws.com/Minecraft.Resources. XML error:" << xmlErrorMsg << ba;
|
||||||
|
emit failed();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
//QRegExp etag_match(".*([a-f0-9]{32}).*");
|
//QRegExp etag_match(".*([a-f0-9]{32}).*");
|
||||||
QDomNodeList contents = doc.elementsByTagName ( "Contents" );
|
QDomNodeList contents = doc.elementsByTagName ( "Contents" );
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <cmdutils.h>
|
#include <cmdutils.h>
|
||||||
#include <JlCompress.h>
|
#include <JlCompress.h>
|
||||||
#include <gui/OneSixModEditDialog.h>
|
#include <gui/OneSixModEditDialog.h>
|
||||||
|
#include <logger/QsLog.h>
|
||||||
|
|
||||||
OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *setting_obj,
|
OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *setting_obj,
|
||||||
QObject *parent)
|
QObject *parent)
|
||||||
@ -102,7 +103,7 @@ MinecraftProcess *OneSixInstance::prepareForLaunch(LoginResponse response)
|
|||||||
for (auto lib : libs_to_extract)
|
for (auto lib : libs_to_extract)
|
||||||
{
|
{
|
||||||
QString path = "libraries/" + lib->storagePath();
|
QString path = "libraries/" + lib->storagePath();
|
||||||
qDebug() << "Will extract " << path.toLocal8Bit();
|
QLOG_INFO() << "Will extract " << path.toLocal8Bit();
|
||||||
if (JlCompress::extractWithExceptions(path, natives_dir_raw, lib->extract_excludes)
|
if (JlCompress::extractWithExceptions(path, natives_dir_raw, lib->extract_excludes)
|
||||||
.isEmpty())
|
.isEmpty())
|
||||||
{
|
{
|
||||||
@ -156,7 +157,7 @@ void OneSixInstance::cleanupAfterRun()
|
|||||||
dir.removeRecursively();
|
dir.removeRecursively();
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<ModList> OneSixInstance::loaderModList()
|
std::shared_ptr<ModList> OneSixInstance::loaderModList()
|
||||||
{
|
{
|
||||||
I_D(OneSixInstance);
|
I_D(OneSixInstance);
|
||||||
if (!d->loader_mod_list)
|
if (!d->loader_mod_list)
|
||||||
@ -168,7 +169,7 @@ QSharedPointer<ModList> OneSixInstance::loaderModList()
|
|||||||
return d->loader_mod_list;
|
return d->loader_mod_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<ModList> OneSixInstance::resourcePackList()
|
std::shared_ptr<ModList> OneSixInstance::resourcePackList()
|
||||||
{
|
{
|
||||||
I_D(OneSixInstance);
|
I_D(OneSixInstance);
|
||||||
if (!d->resource_pack_list)
|
if (!d->resource_pack_list)
|
||||||
@ -271,7 +272,7 @@ bool OneSixInstance::reloadFullVersion()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<OneSixVersion> OneSixInstance::getFullVersion()
|
std::shared_ptr<OneSixVersion> OneSixInstance::getFullVersion()
|
||||||
{
|
{
|
||||||
I_D(OneSixInstance);
|
I_D(OneSixInstance);
|
||||||
return d->version;
|
return d->version;
|
||||||
|
@ -14,8 +14,8 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
////// Mod Lists //////
|
////// Mod Lists //////
|
||||||
QSharedPointer<ModList> loaderModList();
|
std::shared_ptr<ModList> loaderModList();
|
||||||
QSharedPointer<ModList> resourcePackList();
|
std::shared_ptr<ModList> resourcePackList();
|
||||||
|
|
||||||
////// Directories //////
|
////// Directories //////
|
||||||
QString resourcePacksDir() const;
|
QString resourcePacksDir() const;
|
||||||
@ -40,7 +40,7 @@ public:
|
|||||||
/// reload the full version json file. return true on success!
|
/// reload the full version json file. return true on success!
|
||||||
bool reloadFullVersion();
|
bool reloadFullVersion();
|
||||||
/// get the current full version info
|
/// get the current full version info
|
||||||
QSharedPointer<OneSixVersion> getFullVersion();
|
std::shared_ptr<OneSixVersion> getFullVersion();
|
||||||
/// revert the current custom version back to base
|
/// revert the current custom version back to base
|
||||||
bool revertCustomVersion();
|
bool revertCustomVersion();
|
||||||
/// customize the current base version
|
/// customize the current base version
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
struct OneSixInstancePrivate: public BaseInstancePrivate
|
struct OneSixInstancePrivate: public BaseInstancePrivate
|
||||||
{
|
{
|
||||||
QSharedPointer<OneSixVersion> version;
|
std::shared_ptr<OneSixVersion> version;
|
||||||
QSharedPointer<ModList> loader_mod_list;
|
std::shared_ptr<ModList> loader_mod_list;
|
||||||
QSharedPointer<ModList> resource_pack_list;
|
std::shared_ptr<ModList> resource_pack_list;
|
||||||
};
|
};
|
@ -72,7 +72,7 @@ void OneSixLibrary::addNative(OpSys os, QString suffix)
|
|||||||
m_is_native = true;
|
m_is_native = true;
|
||||||
m_native_suffixes[os] = suffix;
|
m_native_suffixes[os] = suffix;
|
||||||
}
|
}
|
||||||
void OneSixLibrary::setRules(QList<QSharedPointer<Rule>> rules)
|
void OneSixLibrary::setRules(QList<std::shared_ptr<Rule>> rules)
|
||||||
{
|
{
|
||||||
m_rules = rules;
|
m_rules = rules;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QSharedPointer>
|
#include <memory>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include "OpSys.h"
|
#include "OpSys.h"
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ private:
|
|||||||
// basic values used internally (so far)
|
// basic values used internally (so far)
|
||||||
QString m_name;
|
QString m_name;
|
||||||
QString m_base_url = "https://s3.amazonaws.com/Minecraft.Download/libraries/";
|
QString m_base_url = "https://s3.amazonaws.com/Minecraft.Download/libraries/";
|
||||||
QList<QSharedPointer<Rule> > m_rules;
|
QList<std::shared_ptr<Rule> > m_rules;
|
||||||
|
|
||||||
// custom values
|
// custom values
|
||||||
/// absolute URL. takes precedence over m_download_path, if defined
|
/// absolute URL. takes precedence over m_download_path, if defined
|
||||||
@ -83,7 +83,7 @@ public:
|
|||||||
/// Attach a name suffix to the specified OS native
|
/// Attach a name suffix to the specified OS native
|
||||||
void addNative(OpSys os, QString suffix);
|
void addNative(OpSys os, QString suffix);
|
||||||
/// Set the load rules
|
/// Set the load rules
|
||||||
void setRules(QList<QSharedPointer<Rule> > rules);
|
void setRules(QList<std::shared_ptr<Rule> > rules);
|
||||||
|
|
||||||
/// Returns true if the library should be loaded (or extracted, in case of natives)
|
/// Returns true if the library should be loaded (or extracted, in case of natives)
|
||||||
bool isActive();
|
bool isActive();
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
|
||||||
QList<QSharedPointer<Rule>> rulesFromJsonV4(QJsonObject &objectWithRules)
|
QList<std::shared_ptr<Rule>> rulesFromJsonV4(QJsonObject &objectWithRules)
|
||||||
{
|
{
|
||||||
QList<QSharedPointer<Rule>> rules;
|
QList<std::shared_ptr<Rule>> rules;
|
||||||
auto rulesVal = objectWithRules.value("rules");
|
auto rulesVal = objectWithRules.value("rules");
|
||||||
if (!rulesVal.isArray())
|
if (!rulesVal.isArray())
|
||||||
return rules;
|
return rules;
|
||||||
@ -12,7 +12,7 @@ QList<QSharedPointer<Rule>> rulesFromJsonV4(QJsonObject &objectWithRules)
|
|||||||
QJsonArray ruleList = rulesVal.toArray();
|
QJsonArray ruleList = rulesVal.toArray();
|
||||||
for (auto ruleVal : ruleList)
|
for (auto ruleVal : ruleList)
|
||||||
{
|
{
|
||||||
QSharedPointer<Rule> rule;
|
std::shared_ptr<Rule> rule;
|
||||||
if (!ruleVal.isObject())
|
if (!ruleVal.isObject())
|
||||||
continue;
|
continue;
|
||||||
auto ruleObj = ruleVal.toObject();
|
auto ruleObj = ruleVal.toObject();
|
||||||
|
@ -11,7 +11,7 @@ enum RuleAction
|
|||||||
};
|
};
|
||||||
|
|
||||||
RuleAction RuleAction_fromString(QString);
|
RuleAction RuleAction_fromString(QString);
|
||||||
QList<QSharedPointer<Rule>> rulesFromJsonV4(QJsonObject &objectWithRules);
|
QList<std::shared_ptr<Rule>> rulesFromJsonV4(QJsonObject &objectWithRules);
|
||||||
|
|
||||||
class Rule
|
class Rule
|
||||||
{
|
{
|
||||||
@ -48,9 +48,9 @@ protected:
|
|||||||
: Rule(result), m_system(system), m_version_regexp(version_regexp) {}
|
: Rule(result), m_system(system), m_version_regexp(version_regexp) {}
|
||||||
public:
|
public:
|
||||||
virtual QJsonObject toJson();
|
virtual QJsonObject toJson();
|
||||||
static QSharedPointer<OsRule> create(RuleAction result, OpSys system, QString version_regexp)
|
static std::shared_ptr<OsRule> create(RuleAction result, OpSys system, QString version_regexp)
|
||||||
{
|
{
|
||||||
return QSharedPointer<OsRule> (new OsRule(result, system, version_regexp));
|
return std::shared_ptr<OsRule> (new OsRule(result, system, version_regexp));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -65,8 +65,8 @@ protected:
|
|||||||
: Rule(result) {}
|
: Rule(result) {}
|
||||||
public:
|
public:
|
||||||
virtual QJsonObject toJson();
|
virtual QJsonObject toJson();
|
||||||
static QSharedPointer<ImplicitRule> create(RuleAction result)
|
static std::shared_ptr<ImplicitRule> create(RuleAction result)
|
||||||
{
|
{
|
||||||
return QSharedPointer<ImplicitRule> (new ImplicitRule(result));
|
return std::shared_ptr<ImplicitRule> (new ImplicitRule(result));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -22,8 +22,6 @@
|
|||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#include "BaseInstance.h"
|
#include "BaseInstance.h"
|
||||||
#include "lists/MinecraftVersionList.h"
|
#include "lists/MinecraftVersionList.h"
|
||||||
#include "OneSixVersion.h"
|
#include "OneSixVersion.h"
|
||||||
@ -49,8 +47,8 @@ void OneSixUpdate::executeTask()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get a pointer to the version object that corresponds to the instance's version.
|
// Get a pointer to the version object that corresponds to the instance's version.
|
||||||
targetVersion =
|
targetVersion = std::dynamic_pointer_cast<MinecraftVersion>(
|
||||||
MMC->minecraftlist()->findVersion(intendedVersion).dynamicCast<MinecraftVersion>();
|
MMC->minecraftlist()->findVersion(intendedVersion));
|
||||||
if (targetVersion == nullptr)
|
if (targetVersion == nullptr)
|
||||||
{
|
{
|
||||||
// don't do anything if it was invalid
|
// don't do anything if it was invalid
|
||||||
@ -77,10 +75,9 @@ void OneSixUpdate::versionFileStart()
|
|||||||
auto job = new DownloadJob("Version index");
|
auto job = new DownloadJob("Version index");
|
||||||
job->addByteArrayDownload(QUrl(urlstr));
|
job->addByteArrayDownload(QUrl(urlstr));
|
||||||
specificVersionDownloadJob.reset(job);
|
specificVersionDownloadJob.reset(job);
|
||||||
connect(specificVersionDownloadJob.data(), SIGNAL(succeeded()),
|
connect(specificVersionDownloadJob.get(), SIGNAL(succeeded()), SLOT(versionFileFinished()));
|
||||||
SLOT(versionFileFinished()));
|
connect(specificVersionDownloadJob.get(), SIGNAL(failed()), SLOT(versionFileFailed()));
|
||||||
connect(specificVersionDownloadJob.data(), SIGNAL(failed()), SLOT(versionFileFailed()));
|
connect(specificVersionDownloadJob.get(), SIGNAL(progress(qint64, qint64)),
|
||||||
connect(specificVersionDownloadJob.data(), SIGNAL(progress(qint64, qint64)),
|
|
||||||
SIGNAL(progress(qint64, qint64)));
|
SIGNAL(progress(qint64, qint64)));
|
||||||
specificVersionDownloadJob->start();
|
specificVersionDownloadJob->start();
|
||||||
}
|
}
|
||||||
@ -103,7 +100,7 @@ void OneSixUpdate::versionFileFinished()
|
|||||||
emitFailed("Can't open " + version1 + " for writing.");
|
emitFailed("Can't open " + version1 + " for writing.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto data = DlJob.dynamicCast<ByteArrayDownload>()->m_data;
|
auto data = std::dynamic_pointer_cast<ByteArrayDownload>(DlJob)->m_data;
|
||||||
qint64 actual = 0;
|
qint64 actual = 0;
|
||||||
if ((actual = vfile1.write(data)) != data.size())
|
if ((actual = vfile1.write(data)) != data.size())
|
||||||
{
|
{
|
||||||
@ -149,7 +146,7 @@ void OneSixUpdate::jarlibStart()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<OneSixVersion> version = inst->getFullVersion();
|
std::shared_ptr<OneSixVersion> version = inst->getFullVersion();
|
||||||
|
|
||||||
// download the right jar, save it in versions/$version/$version.jar
|
// download the right jar, save it in versions/$version/$version.jar
|
||||||
QString urlstr("http://s3.amazonaws.com/Minecraft.Download/versions/");
|
QString urlstr("http://s3.amazonaws.com/Minecraft.Download/versions/");
|
||||||
@ -171,15 +168,15 @@ void OneSixUpdate::jarlibStart()
|
|||||||
auto entry = metacache->resolveEntry("libraries", lib->storagePath());
|
auto entry = metacache->resolveEntry("libraries", lib->storagePath());
|
||||||
if (entry->stale)
|
if (entry->stale)
|
||||||
{
|
{
|
||||||
if(lib->hint() == "forge-pack-xz")
|
if (lib->hint() == "forge-pack-xz")
|
||||||
jarlibDownloadJob->addForgeXzDownload(download_path, entry);
|
jarlibDownloadJob->addForgeXzDownload(download_path, entry);
|
||||||
else
|
else
|
||||||
jarlibDownloadJob->addCacheDownload(download_path, entry);
|
jarlibDownloadJob->addCacheDownload(download_path, entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
connect(jarlibDownloadJob.data(), SIGNAL(succeeded()), SLOT(jarlibFinished()));
|
connect(jarlibDownloadJob.get(), SIGNAL(succeeded()), SLOT(jarlibFinished()));
|
||||||
connect(jarlibDownloadJob.data(), SIGNAL(failed()), SLOT(jarlibFailed()));
|
connect(jarlibDownloadJob.get(), SIGNAL(failed()), SLOT(jarlibFailed()));
|
||||||
connect(jarlibDownloadJob.data(), SIGNAL(progress(qint64, qint64)),
|
connect(jarlibDownloadJob.get(), SIGNAL(progress(qint64, qint64)),
|
||||||
SIGNAL(progress(qint64, qint64)));
|
SIGNAL(progress(qint64, qint64)));
|
||||||
|
|
||||||
jarlibDownloadJob->start();
|
jarlibDownloadJob->start();
|
||||||
|
@ -47,7 +47,7 @@ private:
|
|||||||
DownloadJobPtr jarlibDownloadJob;
|
DownloadJobPtr jarlibDownloadJob;
|
||||||
|
|
||||||
// target version, determined during this task
|
// target version, determined during this task
|
||||||
QSharedPointer<MinecraftVersion> targetVersion;
|
std::shared_ptr<MinecraftVersion> targetVersion;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
#include "OneSixLibrary.h"
|
#include "OneSixLibrary.h"
|
||||||
#include "OneSixRule.h"
|
#include "OneSixRule.h"
|
||||||
|
|
||||||
QSharedPointer<OneSixVersion> fromJsonV4(QJsonObject root,
|
std::shared_ptr<OneSixVersion> fromJsonV4(QJsonObject root,
|
||||||
QSharedPointer<OneSixVersion> fullVersion)
|
std::shared_ptr<OneSixVersion> fullVersion)
|
||||||
{
|
{
|
||||||
fullVersion->id = root.value("id").toString();
|
fullVersion->id = root.value("id").toString();
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ QSharedPointer<OneSixVersion> fromJsonV4(QJsonObject root,
|
|||||||
auto nameVal = libObj.value("name");
|
auto nameVal = libObj.value("name");
|
||||||
if (!nameVal.isString())
|
if (!nameVal.isString())
|
||||||
continue;
|
continue;
|
||||||
QSharedPointer<OneSixLibrary> library(new OneSixLibrary(nameVal.toString()));
|
std::shared_ptr<OneSixLibrary> library(new OneSixLibrary(nameVal.toString()));
|
||||||
|
|
||||||
auto urlVal = libObj.value("url");
|
auto urlVal = libObj.value("url");
|
||||||
if (urlVal.isString())
|
if (urlVal.isString())
|
||||||
@ -129,9 +129,9 @@ QSharedPointer<OneSixVersion> fromJsonV4(QJsonObject root,
|
|||||||
return fullVersion;
|
return fullVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<OneSixVersion> OneSixVersion::fromJson(QJsonObject root)
|
std::shared_ptr<OneSixVersion> OneSixVersion::fromJson(QJsonObject root)
|
||||||
{
|
{
|
||||||
QSharedPointer<OneSixVersion> readVersion(new OneSixVersion());
|
std::shared_ptr<OneSixVersion> readVersion(new OneSixVersion());
|
||||||
int launcher_ver = readVersion->minimumLauncherVersion =
|
int launcher_ver = readVersion->minimumLauncherVersion =
|
||||||
root.value("minimumLauncherVersion").toDouble();
|
root.value("minimumLauncherVersion").toDouble();
|
||||||
|
|
||||||
@ -140,16 +140,16 @@ QSharedPointer<OneSixVersion> OneSixVersion::fromJson(QJsonObject root)
|
|||||||
return fromJsonV4(root, readVersion);
|
return fromJsonV4(root, readVersion);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return QSharedPointer<OneSixVersion>();
|
return std::shared_ptr<OneSixVersion>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<OneSixVersion> OneSixVersion::fromFile(QString filepath)
|
std::shared_ptr<OneSixVersion> OneSixVersion::fromFile(QString filepath)
|
||||||
{
|
{
|
||||||
QFile file(filepath);
|
QFile file(filepath);
|
||||||
if (!file.open(QIODevice::ReadOnly))
|
if (!file.open(QIODevice::ReadOnly))
|
||||||
{
|
{
|
||||||
return QSharedPointer<OneSixVersion>();
|
return std::shared_ptr<OneSixVersion>();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto data = file.readAll();
|
auto data = file.readAll();
|
||||||
@ -158,12 +158,12 @@ QSharedPointer<OneSixVersion> OneSixVersion::fromFile(QString filepath)
|
|||||||
|
|
||||||
if (jsonError.error != QJsonParseError::NoError)
|
if (jsonError.error != QJsonParseError::NoError)
|
||||||
{
|
{
|
||||||
return QSharedPointer<OneSixVersion>();
|
return std::shared_ptr<OneSixVersion>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!jsonDoc.isObject())
|
if (!jsonDoc.isObject())
|
||||||
{
|
{
|
||||||
return QSharedPointer<OneSixVersion>();
|
return std::shared_ptr<OneSixVersion>();
|
||||||
}
|
}
|
||||||
QJsonObject root = jsonDoc.object();
|
QJsonObject root = jsonDoc.object();
|
||||||
auto version = fromJson(root);
|
auto version = fromJson(root);
|
||||||
@ -202,9 +202,9 @@ bool OneSixVersion::toOriginalFile()
|
|||||||
return file.commit();
|
return file.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QSharedPointer<OneSixLibrary>> OneSixVersion::getActiveNormalLibs()
|
QList<std::shared_ptr<OneSixLibrary>> OneSixVersion::getActiveNormalLibs()
|
||||||
{
|
{
|
||||||
QList<QSharedPointer<OneSixLibrary>> output;
|
QList<std::shared_ptr<OneSixLibrary>> output;
|
||||||
for (auto lib : libraries)
|
for (auto lib : libraries)
|
||||||
{
|
{
|
||||||
if (lib->isActive() && !lib->isNative())
|
if (lib->isActive() && !lib->isNative())
|
||||||
@ -215,9 +215,9 @@ QList<QSharedPointer<OneSixLibrary>> OneSixVersion::getActiveNormalLibs()
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QSharedPointer<OneSixLibrary>> OneSixVersion::getActiveNativeLibs()
|
QList<std::shared_ptr<OneSixLibrary>> OneSixVersion::getActiveNativeLibs()
|
||||||
{
|
{
|
||||||
QList<QSharedPointer<OneSixLibrary>> output;
|
QList<std::shared_ptr<OneSixLibrary>> output;
|
||||||
for (auto lib : libraries)
|
for (auto lib : libraries)
|
||||||
{
|
{
|
||||||
if (lib->isActive() && lib->isNative())
|
if (lib->isActive() && lib->isNative())
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class OneSixLibrary;
|
class OneSixLibrary;
|
||||||
|
|
||||||
class OneSixVersion : public QAbstractListModel
|
class OneSixVersion : public QAbstractListModel
|
||||||
@ -16,12 +18,12 @@ public:
|
|||||||
// serialization/deserialization
|
// serialization/deserialization
|
||||||
public:
|
public:
|
||||||
bool toOriginalFile();
|
bool toOriginalFile();
|
||||||
static QSharedPointer<OneSixVersion> fromJson(QJsonObject root);
|
static std::shared_ptr<OneSixVersion> fromJson(QJsonObject root);
|
||||||
static QSharedPointer<OneSixVersion> fromFile(QString filepath);
|
static std::shared_ptr<OneSixVersion> fromFile(QString filepath);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QList<QSharedPointer<OneSixLibrary>> getActiveNormalLibs();
|
QList<std::shared_ptr<OneSixLibrary>> getActiveNormalLibs();
|
||||||
QList<QSharedPointer<OneSixLibrary>> getActiveNativeLibs();
|
QList<std::shared_ptr<OneSixLibrary>> getActiveNativeLibs();
|
||||||
// called when something starts/stops messing with the object
|
// called when something starts/stops messing with the object
|
||||||
// FIXME: these are ugly in every possible way.
|
// FIXME: these are ugly in every possible way.
|
||||||
void externalUpdateStart();
|
void externalUpdateStart();
|
||||||
@ -62,7 +64,7 @@ public:
|
|||||||
QString mainClass;
|
QString mainClass;
|
||||||
|
|
||||||
/// the list of libs - both active and inactive, native and java
|
/// the list of libs - both active and inactive, native and java
|
||||||
QList<QSharedPointer<OneSixLibrary>> libraries;
|
QList<std::shared_ptr<OneSixLibrary>> libraries;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
FIXME: add support for those rules here? Looks like a pile of quick hacks to me though.
|
FIXME: add support for those rules here? Looks like a pile of quick hacks to me though.
|
||||||
|
@ -18,11 +18,11 @@
|
|||||||
#include "MultiMC.h"
|
#include "MultiMC.h"
|
||||||
|
|
||||||
#include <QtNetwork>
|
#include <QtNetwork>
|
||||||
|
|
||||||
#include <QtXml>
|
#include <QtXml>
|
||||||
|
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
|
|
||||||
|
#include <logger/QsLog.h>
|
||||||
|
|
||||||
#define JSON_URL "http://files.minecraftforge.net/minecraftforge/json"
|
#define JSON_URL "http://files.minecraftforge.net/minecraftforge/json"
|
||||||
|
|
||||||
ForgeVersionList::ForgeVersionList(QObject *parent) : BaseVersionList(parent)
|
ForgeVersionList::ForgeVersionList(QObject *parent) : BaseVersionList(parent)
|
||||||
@ -62,7 +62,7 @@ QVariant ForgeVersionList::data(const QModelIndex &index, int role) const
|
|||||||
if (index.row() > count())
|
if (index.row() > count())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
auto version = m_vlist[index.row()].dynamicCast<ForgeVersion>();
|
auto version = std::dynamic_pointer_cast<ForgeVersion>(m_vlist[index.row()]);
|
||||||
switch (role)
|
switch (role)
|
||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
@ -164,9 +164,9 @@ void ForgeListLoadTask::executeTask()
|
|||||||
auto forgeListEntry = MMC->metacache()->resolveEntry("minecraftforge", "list.json");
|
auto forgeListEntry = MMC->metacache()->resolveEntry("minecraftforge", "list.json");
|
||||||
job->addCacheDownload(QUrl(JSON_URL), forgeListEntry);
|
job->addCacheDownload(QUrl(JSON_URL), forgeListEntry);
|
||||||
listJob.reset(job);
|
listJob.reset(job);
|
||||||
connect(listJob.data(), SIGNAL(succeeded()), SLOT(list_downloaded()));
|
connect(listJob.get(), SIGNAL(succeeded()), SLOT(list_downloaded()));
|
||||||
connect(listJob.data(), SIGNAL(failed()), SLOT(list_failed()));
|
connect(listJob.get(), SIGNAL(failed()), SLOT(list_failed()));
|
||||||
connect(listJob.data(), SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64)));
|
connect(listJob.get(), SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64)));
|
||||||
listJob->start();
|
listJob->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,10 +176,10 @@ void ForgeListLoadTask::list_failed()
|
|||||||
auto reply = DlJob->m_reply;
|
auto reply = DlJob->m_reply;
|
||||||
if(reply)
|
if(reply)
|
||||||
{
|
{
|
||||||
qDebug() << "Getting forge version list failed: " << reply->errorString();
|
QLOG_ERROR() << "Getting forge version list failed: " << reply->errorString();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
qDebug() << "Getting forge version list failed for reasons unknown.";
|
QLOG_ERROR() << "Getting forge version list failed for reasons unknown.";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForgeListLoadTask::list_downloaded()
|
void ForgeListLoadTask::list_downloaded()
|
||||||
@ -187,7 +187,7 @@ void ForgeListLoadTask::list_downloaded()
|
|||||||
QByteArray data;
|
QByteArray data;
|
||||||
{
|
{
|
||||||
auto DlJob = listJob->first();
|
auto DlJob = listJob->first();
|
||||||
auto filename = DlJob.dynamicCast<CacheDownload>()->m_target_path;
|
auto filename = std::dynamic_pointer_cast<CacheDownload>(DlJob)->m_target_path;
|
||||||
QFile listFile(filename);
|
QFile listFile(filename);
|
||||||
if(!listFile.open(QIODevice::ReadOnly))
|
if(!listFile.open(QIODevice::ReadOnly))
|
||||||
return;
|
return;
|
||||||
@ -272,7 +272,7 @@ void ForgeListLoadTask::list_downloaded()
|
|||||||
if (valid)
|
if (valid)
|
||||||
{
|
{
|
||||||
// Now, we construct the version object and add it to the list.
|
// Now, we construct the version object and add it to the list.
|
||||||
QSharedPointer<ForgeVersion> fVersion(new ForgeVersion());
|
std::shared_ptr<ForgeVersion> fVersion(new ForgeVersion());
|
||||||
fVersion->universal_url = url;
|
fVersion->universal_url = url;
|
||||||
fVersion->changelog_url = changelog_url;
|
fVersion->changelog_url = changelog_url;
|
||||||
fVersion->installer_url = installer_url;
|
fVersion->installer_url = installer_url;
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include "logic/net/DownloadJob.h"
|
#include "logic/net/DownloadJob.h"
|
||||||
|
|
||||||
class ForgeVersion;
|
class ForgeVersion;
|
||||||
typedef QSharedPointer<ForgeVersion> ForgeVersionPtr;
|
typedef std::shared_ptr<ForgeVersion> ForgeVersionPtr;
|
||||||
|
|
||||||
struct ForgeVersion : public BaseVersion
|
struct ForgeVersion : public BaseVersion
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
@ -29,13 +29,13 @@
|
|||||||
#include "logic/lists/IconList.h"
|
#include "logic/lists/IconList.h"
|
||||||
#include "logic/BaseInstance.h"
|
#include "logic/BaseInstance.h"
|
||||||
#include "logic/InstanceFactory.h"
|
#include "logic/InstanceFactory.h"
|
||||||
|
#include <logger/QsLog.h>
|
||||||
|
|
||||||
const static int GROUP_FILE_FORMAT_VERSION = 1;
|
const static int GROUP_FILE_FORMAT_VERSION = 1;
|
||||||
|
|
||||||
InstanceList::InstanceList(const QString &instDir, QObject *parent) :
|
InstanceList::InstanceList(const QString &instDir, QObject *parent)
|
||||||
QAbstractListModel ( parent ), m_instDir("instances")
|
: QAbstractListModel(parent), m_instDir("instances")
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InstanceList::~InstanceList()
|
InstanceList::~InstanceList()
|
||||||
@ -43,32 +43,32 @@ InstanceList::~InstanceList()
|
|||||||
saveGroupList();
|
saveGroupList();
|
||||||
}
|
}
|
||||||
|
|
||||||
int InstanceList::rowCount ( const QModelIndex& parent ) const
|
int InstanceList::rowCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
Q_UNUSED ( parent );
|
Q_UNUSED(parent);
|
||||||
return m_instances.count();
|
return m_instances.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex InstanceList::index ( int row, int column, const QModelIndex& parent ) const
|
QModelIndex InstanceList::index(int row, int column, const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
Q_UNUSED ( parent );
|
Q_UNUSED(parent);
|
||||||
if ( row < 0 || row >= m_instances.size() )
|
if (row < 0 || row >= m_instances.size())
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
return createIndex ( row, column, ( void* ) m_instances.at ( row ).data() );
|
return createIndex(row, column, (void *)m_instances.at(row).get());
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant InstanceList::data ( const QModelIndex& index, int role ) const
|
QVariant InstanceList::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if ( !index.isValid() )
|
if (!index.isValid())
|
||||||
{
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
BaseInstance *pdata = static_cast<BaseInstance*> ( index.internalPointer() );
|
BaseInstance *pdata = static_cast<BaseInstance *>(index.internalPointer());
|
||||||
switch ( role )
|
switch (role)
|
||||||
{
|
{
|
||||||
case InstancePointerRole:
|
case InstancePointerRole:
|
||||||
{
|
{
|
||||||
QVariant v = qVariantFromValue((void *) pdata);
|
QVariant v = qVariantFromValue((void *)pdata);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
@ -96,12 +96,12 @@ QVariant InstanceList::data ( const QModelIndex& index, int role ) const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags InstanceList::flags ( const QModelIndex& index ) const
|
Qt::ItemFlags InstanceList::flags(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
Qt::ItemFlags f;
|
Qt::ItemFlags f;
|
||||||
if ( index.isValid() )
|
if (index.isValid())
|
||||||
{
|
{
|
||||||
f |= ( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
|
f |= (Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||||
}
|
}
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
@ -116,23 +116,23 @@ void InstanceList::saveGroupList()
|
|||||||
{
|
{
|
||||||
QString groupFileName = m_instDir + "/instgroups.json";
|
QString groupFileName = m_instDir + "/instgroups.json";
|
||||||
QFile groupFile(groupFileName);
|
QFile groupFile(groupFileName);
|
||||||
|
|
||||||
// if you can't open the file, fail
|
// if you can't open the file, fail
|
||||||
if (!groupFile.open(QIODevice::WriteOnly| QIODevice::Truncate))
|
if (!groupFile.open(QIODevice::WriteOnly | QIODevice::Truncate))
|
||||||
{
|
{
|
||||||
// An error occurred. Ignore it.
|
// An error occurred. Ignore it.
|
||||||
qDebug("Failed to read instance group file.");
|
QLOG_ERROR() << "Failed to read instance group file.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QTextStream out(&groupFile);
|
QTextStream out(&groupFile);
|
||||||
QMap<QString, QSet<QString> > groupMap;
|
QMap<QString, QSet<QString>> groupMap;
|
||||||
for(auto instance: m_instances)
|
for (auto instance : m_instances)
|
||||||
{
|
{
|
||||||
QString id = instance->id();
|
QString id = instance->id();
|
||||||
QString group = instance->group();
|
QString group = instance->group();
|
||||||
if(group.isEmpty())
|
if (group.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
if(!groupMap.count(group))
|
if (!groupMap.count(group))
|
||||||
{
|
{
|
||||||
QSet<QString> set;
|
QSet<QString> set;
|
||||||
set.insert(id);
|
set.insert(id);
|
||||||
@ -145,109 +145,114 @@ void InstanceList::saveGroupList()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
QJsonObject toplevel;
|
QJsonObject toplevel;
|
||||||
toplevel.insert("formatVersion",QJsonValue(QString("1")));
|
toplevel.insert("formatVersion", QJsonValue(QString("1")));
|
||||||
QJsonObject groupsArr;
|
QJsonObject groupsArr;
|
||||||
for(auto iter = groupMap.begin(); iter != groupMap.end(); iter++)
|
for (auto iter = groupMap.begin(); iter != groupMap.end(); iter++)
|
||||||
{
|
{
|
||||||
auto list = iter.value();
|
auto list = iter.value();
|
||||||
auto name = iter.key();
|
auto name = iter.key();
|
||||||
QJsonObject groupObj;
|
QJsonObject groupObj;
|
||||||
QJsonArray instanceArr;
|
QJsonArray instanceArr;
|
||||||
groupObj.insert("hidden",QJsonValue(QString("false")));
|
groupObj.insert("hidden", QJsonValue(QString("false")));
|
||||||
for(auto item: list)
|
for (auto item : list)
|
||||||
{
|
{
|
||||||
instanceArr.append(QJsonValue(item));
|
instanceArr.append(QJsonValue(item));
|
||||||
}
|
}
|
||||||
groupObj.insert("instances",instanceArr);
|
groupObj.insert("instances", instanceArr);
|
||||||
groupsArr.insert(name,groupObj);
|
groupsArr.insert(name, groupObj);
|
||||||
}
|
}
|
||||||
toplevel.insert("groups",groupsArr);
|
toplevel.insert("groups", groupsArr);
|
||||||
QJsonDocument doc(toplevel);
|
QJsonDocument doc(toplevel);
|
||||||
groupFile.write(doc.toJson());
|
groupFile.write(doc.toJson());
|
||||||
groupFile.close();
|
groupFile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceList::loadGroupList(QMap<QString, QString> & groupMap)
|
void InstanceList::loadGroupList(QMap<QString, QString> &groupMap)
|
||||||
{
|
{
|
||||||
QString groupFileName = m_instDir + "/instgroups.json";
|
QString groupFileName = m_instDir + "/instgroups.json";
|
||||||
|
|
||||||
// if there's no group file, fail
|
// if there's no group file, fail
|
||||||
if(!QFileInfo(groupFileName).exists())
|
if (!QFileInfo(groupFileName).exists())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QFile groupFile(groupFileName);
|
QFile groupFile(groupFileName);
|
||||||
|
|
||||||
// if you can't open the file, fail
|
// if you can't open the file, fail
|
||||||
if (!groupFile.open(QIODevice::ReadOnly))
|
if (!groupFile.open(QIODevice::ReadOnly))
|
||||||
{
|
{
|
||||||
// An error occurred. Ignore it.
|
// An error occurred. Ignore it.
|
||||||
qDebug("Failed to read instance group file.");
|
QLOG_ERROR() << "Failed to read instance group file.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextStream in(&groupFile);
|
QTextStream in(&groupFile);
|
||||||
QString jsonStr = in.readAll();
|
QString jsonStr = in.readAll();
|
||||||
groupFile.close();
|
groupFile.close();
|
||||||
|
|
||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonStr.toUtf8(), &error);
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonStr.toUtf8(), &error);
|
||||||
|
|
||||||
// if the json was bad, fail
|
// if the json was bad, fail
|
||||||
if (error.error != QJsonParseError::NoError)
|
if (error.error != QJsonParseError::NoError)
|
||||||
{
|
{
|
||||||
qWarning(QString("Failed to parse instance group file: %1 at offset %2").
|
QLOG_ERROR() << QString("Failed to parse instance group file: %1 at offset %2")
|
||||||
arg(error.errorString(), QString::number(error.offset)).toUtf8());
|
.arg(error.errorString(), QString::number(error.offset))
|
||||||
|
.toUtf8();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the root of the json wasn't an object, fail
|
// if the root of the json wasn't an object, fail
|
||||||
if (!jsonDoc.isObject())
|
if (!jsonDoc.isObject())
|
||||||
{
|
{
|
||||||
qWarning("Invalid group file. Root entry should be an object.");
|
qWarning("Invalid group file. Root entry should be an object.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject rootObj = jsonDoc.object();
|
QJsonObject rootObj = jsonDoc.object();
|
||||||
|
|
||||||
// Make sure the format version matches, otherwise fail.
|
// Make sure the format version matches, otherwise fail.
|
||||||
if (rootObj.value("formatVersion").toVariant().toInt() != GROUP_FILE_FORMAT_VERSION)
|
if (rootObj.value("formatVersion").toVariant().toInt() != GROUP_FILE_FORMAT_VERSION)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Get the groups. if it's not an object, fail
|
// Get the groups. if it's not an object, fail
|
||||||
if (!rootObj.value("groups").isObject())
|
if (!rootObj.value("groups").isObject())
|
||||||
{
|
{
|
||||||
qWarning("Invalid group list JSON: 'groups' should be an object.");
|
qWarning("Invalid group list JSON: 'groups' should be an object.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate through all the groups.
|
// Iterate through all the groups.
|
||||||
QJsonObject groupMapping = rootObj.value("groups").toObject();
|
QJsonObject groupMapping = rootObj.value("groups").toObject();
|
||||||
for (QJsonObject::iterator iter = groupMapping.begin(); iter != groupMapping.end(); iter++)
|
for (QJsonObject::iterator iter = groupMapping.begin(); iter != groupMapping.end(); iter++)
|
||||||
{
|
{
|
||||||
QString groupName = iter.key();
|
QString groupName = iter.key();
|
||||||
|
|
||||||
// If not an object, complain and skip to the next one.
|
// If not an object, complain and skip to the next one.
|
||||||
if (!iter.value().isObject())
|
if (!iter.value().isObject())
|
||||||
{
|
{
|
||||||
qWarning(QString("Group '%1' in the group list should "
|
qWarning(QString("Group '%1' in the group list should "
|
||||||
"be an object.").arg(groupName).toUtf8());
|
"be an object.")
|
||||||
|
.arg(groupName)
|
||||||
|
.toUtf8());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject groupObj = iter.value().toObject();
|
QJsonObject groupObj = iter.value().toObject();
|
||||||
if (!groupObj.value("instances").isArray())
|
if (!groupObj.value("instances").isArray())
|
||||||
{
|
{
|
||||||
qWarning(QString("Group '%1' in the group list is invalid. "
|
qWarning(QString("Group '%1' in the group list is invalid. "
|
||||||
"It should contain an array "
|
"It should contain an array "
|
||||||
"called 'instances'.").arg(groupName).toUtf8());
|
"called 'instances'.")
|
||||||
|
.arg(groupName)
|
||||||
|
.toUtf8());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate through the list of instances in the group.
|
// Iterate through the list of instances in the group.
|
||||||
QJsonArray instancesArray = groupObj.value("instances").toArray();
|
QJsonArray instancesArray = groupObj.value("instances").toArray();
|
||||||
|
|
||||||
for (QJsonArray::iterator iter2 = instancesArray.begin();
|
for (QJsonArray::iterator iter2 = instancesArray.begin(); iter2 != instancesArray.end();
|
||||||
iter2 != instancesArray.end(); iter2++)
|
iter2++)
|
||||||
{
|
{
|
||||||
groupMap[(*iter2).toString()] = groupName;
|
groupMap[(*iter2).toString()] = groupName;
|
||||||
}
|
}
|
||||||
@ -259,9 +264,9 @@ InstanceList::InstListError InstanceList::loadList()
|
|||||||
// load the instance groups
|
// load the instance groups
|
||||||
QMap<QString, QString> groupMap;
|
QMap<QString, QString> groupMap;
|
||||||
loadGroupList(groupMap);
|
loadGroupList(groupMap);
|
||||||
|
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
|
|
||||||
m_instances.clear();
|
m_instances.clear();
|
||||||
QDir dir(m_instDir);
|
QDir dir(m_instDir);
|
||||||
QDirIterator iter(dir);
|
QDirIterator iter(dir);
|
||||||
@ -270,53 +275,55 @@ InstanceList::InstListError InstanceList::loadList()
|
|||||||
QString subDir = iter.next();
|
QString subDir = iter.next();
|
||||||
if (!QFileInfo(PathCombine(subDir, "instance.cfg")).exists())
|
if (!QFileInfo(PathCombine(subDir, "instance.cfg")).exists())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BaseInstance *instPtr = NULL;
|
BaseInstance *instPtr = NULL;
|
||||||
auto &loader = InstanceFactory::get();
|
auto &loader = InstanceFactory::get();
|
||||||
auto error = loader.loadInstance(instPtr, subDir);
|
auto error = loader.loadInstance(instPtr, subDir);
|
||||||
|
|
||||||
switch(error)
|
switch (error)
|
||||||
{
|
{
|
||||||
case InstanceFactory::NoLoadError:
|
case InstanceFactory::NoLoadError:
|
||||||
break;
|
break;
|
||||||
case InstanceFactory::NotAnInstance:
|
case InstanceFactory::NotAnInstance:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error != InstanceFactory::NoLoadError &&
|
if (error != InstanceFactory::NoLoadError && error != InstanceFactory::NotAnInstance)
|
||||||
error != InstanceFactory::NotAnInstance)
|
|
||||||
{
|
{
|
||||||
QString errorMsg = QString("Failed to load instance %1: ").
|
QString errorMsg = QString("Failed to load instance %1: ")
|
||||||
arg(QFileInfo(subDir).baseName()).toUtf8();
|
.arg(QFileInfo(subDir).baseName())
|
||||||
|
.toUtf8();
|
||||||
|
|
||||||
switch (error)
|
switch (error)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
errorMsg += QString("Unknown instance loader error %1").
|
errorMsg += QString("Unknown instance loader error %1").arg(error);
|
||||||
arg(error);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
qDebug(errorMsg.toUtf8());
|
QLOG_ERROR() << errorMsg.toUtf8();
|
||||||
}
|
}
|
||||||
else if (!instPtr)
|
else if (!instPtr)
|
||||||
{
|
{
|
||||||
qDebug(QString("Error loading instance %1. Instance loader returned null.").
|
QLOG_ERROR() << QString("Error loading instance %1. Instance loader returned null.")
|
||||||
arg(QFileInfo(subDir).baseName()).toUtf8());
|
.arg(QFileInfo(subDir).baseName())
|
||||||
|
.toUtf8();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QSharedPointer<BaseInstance> inst(instPtr);
|
std::shared_ptr<BaseInstance> inst(instPtr);
|
||||||
auto iter = groupMap.find(inst->id());
|
auto iter = groupMap.find(inst->id());
|
||||||
if(iter != groupMap.end())
|
if (iter != groupMap.end())
|
||||||
{
|
{
|
||||||
inst->setGroupInitial((*iter));
|
inst->setGroupInitial((*iter));
|
||||||
}
|
}
|
||||||
qDebug(QString("Loaded instance %1").arg(inst->name()).toUtf8());
|
QLOG_INFO() << QString("Loaded instance %1").arg(inst->name()).toUtf8();
|
||||||
inst->setParent(this);
|
inst->setParent(this);
|
||||||
m_instances.append(inst);
|
m_instances.append(inst);
|
||||||
connect(instPtr, SIGNAL(propertiesChanged(BaseInstance*)),this, SLOT(propertiesChanged(BaseInstance*)));
|
connect(instPtr, SIGNAL(propertiesChanged(BaseInstance *)), this,
|
||||||
connect(instPtr, SIGNAL(groupChanged()),this, SLOT(groupChanged()));
|
SLOT(propertiesChanged(BaseInstance *)));
|
||||||
connect(instPtr, SIGNAL(nuked(BaseInstance*)), this, SLOT(instanceNuked(BaseInstance*)));
|
connect(instPtr, SIGNAL(groupChanged()), this, SLOT(groupChanged()));
|
||||||
|
connect(instPtr, SIGNAL(nuked(BaseInstance *)), this,
|
||||||
|
SLOT(instanceNuked(BaseInstance *)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
endResetModel();
|
endResetModel();
|
||||||
@ -332,7 +339,8 @@ void InstanceList::clear()
|
|||||||
m_instances.clear();
|
m_instances.clear();
|
||||||
endResetModel();
|
endResetModel();
|
||||||
emit dataIsInvalid();
|
emit dataIsInvalid();
|
||||||
};
|
}
|
||||||
|
;
|
||||||
|
|
||||||
/// Add an instance. Triggers notifications, returns the new index
|
/// Add an instance. Triggers notifications, returns the new index
|
||||||
int InstanceList::add(InstancePtr t)
|
int InstanceList::add(InstancePtr t)
|
||||||
@ -340,9 +348,10 @@ int InstanceList::add(InstancePtr t)
|
|||||||
beginInsertRows(QModelIndex(), m_instances.size(), m_instances.size());
|
beginInsertRows(QModelIndex(), m_instances.size(), m_instances.size());
|
||||||
m_instances.append(t);
|
m_instances.append(t);
|
||||||
t->setParent(this);
|
t->setParent(this);
|
||||||
connect(t.data(), SIGNAL(propertiesChanged(BaseInstance*)),this, SLOT(propertiesChanged(BaseInstance*)));
|
connect(t.get(), SIGNAL(propertiesChanged(BaseInstance *)), this,
|
||||||
connect(t.data(), SIGNAL(groupChanged()),this, SLOT(groupChanged()));
|
SLOT(propertiesChanged(BaseInstance *)));
|
||||||
connect(t.data(), SIGNAL(nuked(BaseInstance*)), this, SLOT(instanceNuked(BaseInstance*)));
|
connect(t.get(), SIGNAL(groupChanged()), this, SLOT(groupChanged()));
|
||||||
|
connect(t.get(), SIGNAL(nuked(BaseInstance *)), this, SLOT(instanceNuked(BaseInstance *)));
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
return count() - 1;
|
return count() - 1;
|
||||||
}
|
}
|
||||||
@ -351,7 +360,7 @@ InstancePtr InstanceList::getInstanceById(QString instId)
|
|||||||
{
|
{
|
||||||
QListIterator<InstancePtr> iter(m_instances);
|
QListIterator<InstancePtr> iter(m_instances);
|
||||||
InstancePtr inst;
|
InstancePtr inst;
|
||||||
while(iter.hasNext())
|
while (iter.hasNext())
|
||||||
{
|
{
|
||||||
inst = iter.next();
|
inst = iter.next();
|
||||||
if (inst->id() == instId)
|
if (inst->id() == instId)
|
||||||
@ -363,11 +372,11 @@ InstancePtr InstanceList::getInstanceById(QString instId)
|
|||||||
return iter.peekPrevious();
|
return iter.peekPrevious();
|
||||||
}
|
}
|
||||||
|
|
||||||
int InstanceList::getInstIndex ( BaseInstance* inst )
|
int InstanceList::getInstIndex(BaseInstance *inst)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < m_instances.count(); i++)
|
for (int i = 0; i < m_instances.count(); i++)
|
||||||
{
|
{
|
||||||
if(inst == m_instances[i].data())
|
if (inst == m_instances[i].get())
|
||||||
{
|
{
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@ -375,40 +384,39 @@ int InstanceList::getInstIndex ( BaseInstance* inst )
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InstanceList::instanceNuked(BaseInstance *inst)
|
||||||
void InstanceList::instanceNuked ( BaseInstance* inst )
|
|
||||||
{
|
{
|
||||||
int i = getInstIndex(inst);
|
int i = getInstIndex(inst);
|
||||||
if(i != -1)
|
if (i != -1)
|
||||||
{
|
{
|
||||||
beginRemoveRows(QModelIndex(),i,i);
|
beginRemoveRows(QModelIndex(), i, i);
|
||||||
m_instances.removeAt(i);
|
m_instances.removeAt(i);
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InstanceList::propertiesChanged(BaseInstance *inst)
|
||||||
void InstanceList::propertiesChanged(BaseInstance * inst)
|
|
||||||
{
|
{
|
||||||
int i = getInstIndex(inst);
|
int i = getInstIndex(inst);
|
||||||
if(i != -1)
|
if (i != -1)
|
||||||
{
|
{
|
||||||
emit dataChanged(index(i), index(i));
|
emit dataChanged(index(i), index(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InstanceProxyModel::InstanceProxyModel ( QObject *parent )
|
InstanceProxyModel::InstanceProxyModel(QObject *parent)
|
||||||
: KCategorizedSortFilterProxyModel ( parent )
|
: KCategorizedSortFilterProxyModel(parent)
|
||||||
{
|
{
|
||||||
// disable since by default we are globally sorting by date:
|
// disable since by default we are globally sorting by date:
|
||||||
setCategorizedModel(true);
|
setCategorizedModel(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InstanceProxyModel::subSortLessThan (const QModelIndex& left, const QModelIndex& right ) const
|
bool InstanceProxyModel::subSortLessThan(const QModelIndex &left,
|
||||||
|
const QModelIndex &right) const
|
||||||
{
|
{
|
||||||
BaseInstance *pdataLeft = static_cast<BaseInstance*> ( left.internalPointer() );
|
BaseInstance *pdataLeft = static_cast<BaseInstance *>(left.internalPointer());
|
||||||
BaseInstance *pdataRight = static_cast<BaseInstance*> ( right.internalPointer() );
|
BaseInstance *pdataRight = static_cast<BaseInstance *>(right.internalPointer());
|
||||||
//kDebug() << *pdataLeft << *pdataRight;
|
// kDebug() << *pdataLeft << *pdataRight;
|
||||||
return QString::localeAwareCompare(pdataLeft->name(), pdataRight->name()) < 0;
|
return QString::localeAwareCompare(pdataLeft->name(), pdataRight->name()) < 0;
|
||||||
//return pdataLeft->name() < pdataRight->name();
|
// return pdataLeft->name() < pdataRight->name();
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
@ -17,15 +17,14 @@
|
|||||||
#include "MultiMC.h"
|
#include "MultiMC.h"
|
||||||
|
|
||||||
#include <QtNetwork>
|
#include <QtNetwork>
|
||||||
|
|
||||||
#include <QtXml>
|
#include <QtXml>
|
||||||
|
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
|
|
||||||
|
#include <logger/QsLog.h>
|
||||||
|
|
||||||
#define RSS_URL "http://sourceforge.net/api/file/index/project-id/58488/mtime/desc/rss"
|
#define RSS_URL "http://sourceforge.net/api/file/index/project-id/58488/mtime/desc/rss"
|
||||||
|
|
||||||
LWJGLVersionList::LWJGLVersionList(QObject *parent) :
|
LWJGLVersionList::LWJGLVersionList(QObject *parent) : QAbstractListModel(parent)
|
||||||
QAbstractListModel(parent)
|
|
||||||
{
|
{
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@ -34,20 +33,20 @@ QVariant LWJGLVersionList::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
if (index.row() > count())
|
if (index.row() > count())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
const PtrLWJGLVersion version = at(index.row());
|
const PtrLWJGLVersion version = at(index.row());
|
||||||
|
|
||||||
switch (role)
|
switch (role)
|
||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
return version->name();
|
return version->name();
|
||||||
|
|
||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
return version->url();
|
return version->url();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -59,10 +58,10 @@ QVariant LWJGLVersionList::headerData(int section, Qt::Orientation orientation,
|
|||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
return "Version";
|
return "Version";
|
||||||
|
|
||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
return "LWJGL version name.";
|
return "LWJGL version name.";
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -81,7 +80,7 @@ bool LWJGLVersionList::isLoading() const
|
|||||||
void LWJGLVersionList::loadList()
|
void LWJGLVersionList::loadList()
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(!m_loading, "loadList", "list is already loading (m_loading is true)");
|
Q_ASSERT_X(!m_loading, "loadList", "list is already loading (m_loading is true)");
|
||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
auto worker = MMC->qnam();
|
auto worker = MMC->qnam();
|
||||||
reply = worker->get(QNetworkRequest(QUrl(RSS_URL)));
|
reply = worker->get(QNetworkRequest(QUrl(RSS_URL)));
|
||||||
@ -102,68 +101,68 @@ void LWJGLVersionList::netRequestComplete()
|
|||||||
if (reply->error() == QNetworkReply::NoError)
|
if (reply->error() == QNetworkReply::NoError)
|
||||||
{
|
{
|
||||||
QRegExp lwjglRegex("lwjgl-(([0-9]\\.?)+)\\.zip");
|
QRegExp lwjglRegex("lwjgl-(([0-9]\\.?)+)\\.zip");
|
||||||
Q_ASSERT_X(lwjglRegex.isValid(), "load LWJGL list",
|
Q_ASSERT_X(lwjglRegex.isValid(), "load LWJGL list", "LWJGL regex is invalid");
|
||||||
"LWJGL regex is invalid");
|
|
||||||
|
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
|
|
||||||
QString xmlErrorMsg;
|
QString xmlErrorMsg;
|
||||||
int errorLine;
|
int errorLine;
|
||||||
if (!doc.setContent(reply->readAll(), false, &xmlErrorMsg, &errorLine))
|
if (!doc.setContent(reply->readAll(), false, &xmlErrorMsg, &errorLine))
|
||||||
{
|
{
|
||||||
failed("Failed to load LWJGL list. XML error: " + xmlErrorMsg + " at line " + QString::number(errorLine));
|
failed("Failed to load LWJGL list. XML error: " + xmlErrorMsg + " at line " +
|
||||||
|
QString::number(errorLine));
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomNodeList items = doc.elementsByTagName("item");
|
QDomNodeList items = doc.elementsByTagName("item");
|
||||||
|
|
||||||
QList<PtrLWJGLVersion> tempList;
|
QList<PtrLWJGLVersion> tempList;
|
||||||
|
|
||||||
for (int i = 0; i < items.length(); i++)
|
for (int i = 0; i < items.length(); i++)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(items.at(i).isElement(), "load LWJGL list",
|
Q_ASSERT_X(items.at(i).isElement(), "load LWJGL list",
|
||||||
"XML element isn't an element... wat?");
|
"XML element isn't an element... wat?");
|
||||||
|
|
||||||
QDomElement linkElement = getDomElementByTagName(items.at(i).toElement(), "link");
|
QDomElement linkElement = getDomElementByTagName(items.at(i).toElement(), "link");
|
||||||
if (linkElement.isNull())
|
if (linkElement.isNull())
|
||||||
{
|
{
|
||||||
qWarning() << "Link element" << i << "in RSS feed doesn't exist! Skipping.";
|
qWarning() << "Link element" << i << "in RSS feed doesn't exist! Skipping.";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString link = linkElement.text();
|
QString link = linkElement.text();
|
||||||
|
|
||||||
// Make sure it's a download link.
|
// Make sure it's a download link.
|
||||||
if (link.endsWith("/download") && link.contains(lwjglRegex))
|
if (link.endsWith("/download") && link.contains(lwjglRegex))
|
||||||
{
|
{
|
||||||
QString name = link.mid(lwjglRegex.indexIn(link) + 6);
|
QString name = link.mid(lwjglRegex.indexIn(link) + 6);
|
||||||
// Subtract 4 here to remove the .zip file extension.
|
// Subtract 4 here to remove the .zip file extension.
|
||||||
name = name.left(lwjglRegex.matchedLength() - 10);
|
name = name.left(lwjglRegex.matchedLength() - 10);
|
||||||
|
|
||||||
QUrl url(link);
|
QUrl url(link);
|
||||||
if (!url.isValid())
|
if (!url.isValid())
|
||||||
{
|
{
|
||||||
qWarning() << "LWJGL version URL isn't valid:" << link << "Skipping.";
|
qWarning() << "LWJGL version URL isn't valid:" << link << "Skipping.";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
tempList.append(LWJGLVersion::Create(name, link));
|
tempList.append(LWJGLVersion::Create(name, link));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
m_vlist.swap(tempList);
|
m_vlist.swap(tempList);
|
||||||
endResetModel();
|
endResetModel();
|
||||||
|
|
||||||
qDebug("Loaded LWJGL list.");
|
QLOG_INFO() << "Loaded LWJGL list.";
|
||||||
finished();
|
finished();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
failed("Failed to load LWJGL list. Network error: " + reply->errorString());
|
failed("Failed to load LWJGL list. Network error: " + reply->errorString());
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
}
|
}
|
||||||
@ -173,13 +172,12 @@ const PtrLWJGLVersion LWJGLVersionList::getVersion(const QString &versionName)
|
|||||||
for (int i = 0; i < count(); i++)
|
for (int i = 0; i < count(); i++)
|
||||||
{
|
{
|
||||||
QString name = at(i)->name();
|
QString name = at(i)->name();
|
||||||
if ( name == versionName)
|
if (name == versionName)
|
||||||
return at(i);
|
return at(i);
|
||||||
}
|
}
|
||||||
return PtrLWJGLVersion();
|
return PtrLWJGLVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LWJGLVersionList::failed(QString msg)
|
void LWJGLVersionList::failed(QString msg)
|
||||||
{
|
{
|
||||||
qWarning() << msg;
|
qWarning() << msg;
|
||||||
|
@ -17,13 +17,13 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QSharedPointer>
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class LWJGLVersion;
|
class LWJGLVersion;
|
||||||
typedef QSharedPointer<LWJGLVersion> PtrLWJGLVersion;
|
typedef std::shared_ptr<LWJGLVersion> PtrLWJGLVersion;
|
||||||
|
|
||||||
class LWJGLVersion : public QObject
|
class LWJGLVersion : public QObject
|
||||||
{
|
{
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
#include "MinecraftVersionList.h"
|
#include "MinecraftVersionList.h"
|
||||||
#include <MultiMC.h>
|
#include <MultiMC.h>
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#include <QtXml>
|
#include <QtXml>
|
||||||
|
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
@ -62,8 +60,8 @@ int MinecraftVersionList::count() const
|
|||||||
|
|
||||||
bool cmpVersions(BaseVersionPtr first, BaseVersionPtr second)
|
bool cmpVersions(BaseVersionPtr first, BaseVersionPtr second)
|
||||||
{
|
{
|
||||||
auto left = first.dynamicCast<MinecraftVersion>();
|
auto left = std::dynamic_pointer_cast<MinecraftVersion>(first);
|
||||||
auto right = second.dynamicCast<MinecraftVersion>();
|
auto right = std::dynamic_pointer_cast<MinecraftVersion>(second);
|
||||||
return left->timestamp > right->timestamp;
|
return left->timestamp > right->timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +76,7 @@ BaseVersionPtr MinecraftVersionList::getLatestStable() const
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < m_vlist.length(); i++)
|
for (int i = 0; i < m_vlist.length(); i++)
|
||||||
{
|
{
|
||||||
auto ver = m_vlist.at(i).dynamicCast<MinecraftVersion>();
|
auto ver =std::dynamic_pointer_cast<MinecraftVersion>(m_vlist.at(i));
|
||||||
if (ver->is_latest && !ver->is_snapshot)
|
if (ver->is_latest && !ver->is_snapshot)
|
||||||
{
|
{
|
||||||
return m_vlist.at(i);
|
return m_vlist.at(i);
|
||||||
@ -272,7 +270,7 @@ void MCVListLoadTask::list_downloaded()
|
|||||||
QString dlUrl = QString(MCVLIST_URLBASE) + versionID + "/";
|
QString dlUrl = QString(MCVLIST_URLBASE) + versionID + "/";
|
||||||
|
|
||||||
// Now, we construct the version object and add it to the list.
|
// Now, we construct the version object and add it to the list.
|
||||||
QSharedPointer<MinecraftVersion> mcVersion(new MinecraftVersion());
|
std::shared_ptr<MinecraftVersion> mcVersion(new MinecraftVersion());
|
||||||
mcVersion->m_name = mcVersion->m_descriptor = versionID;
|
mcVersion->m_name = mcVersion->m_descriptor = versionID;
|
||||||
mcVersion->timestamp = versionTime.toMSecsSinceEpoch();
|
mcVersion->timestamp = versionTime.toMSecsSinceEpoch();
|
||||||
mcVersion->download_url = dlUrl;
|
mcVersion->download_url = dlUrl;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "ByteArrayDownload.h"
|
#include "ByteArrayDownload.h"
|
||||||
#include "MultiMC.h"
|
#include "MultiMC.h"
|
||||||
#include <QDebug>
|
#include <logger/QsLog.h>
|
||||||
|
|
||||||
ByteArrayDownload::ByteArrayDownload(QUrl url) : Download()
|
ByteArrayDownload::ByteArrayDownload(QUrl url) : Download()
|
||||||
{
|
{
|
||||||
@ -10,13 +10,13 @@ ByteArrayDownload::ByteArrayDownload(QUrl url) : Download()
|
|||||||
|
|
||||||
void ByteArrayDownload::start()
|
void ByteArrayDownload::start()
|
||||||
{
|
{
|
||||||
qDebug() << "Downloading " << m_url.toString();
|
QLOG_INFO() << "Downloading " << m_url.toString();
|
||||||
QNetworkRequest request(m_url);
|
QNetworkRequest request(m_url);
|
||||||
request.setHeader(QNetworkRequest::UserAgentHeader, "MultiMC/5.0 (Uncached)");
|
request.setHeader(QNetworkRequest::UserAgentHeader, "MultiMC/5.0 (Uncached)");
|
||||||
auto worker = MMC->qnam();
|
auto worker = MMC->qnam();
|
||||||
QNetworkReply *rep = worker->get(request);
|
QNetworkReply *rep = worker->get(request);
|
||||||
|
|
||||||
m_reply = QSharedPointer<QNetworkReply>(rep, &QObject::deleteLater);
|
m_reply = std::shared_ptr<QNetworkReply>(rep);
|
||||||
connect(rep, SIGNAL(downloadProgress(qint64, qint64)),
|
connect(rep, SIGNAL(downloadProgress(qint64, qint64)),
|
||||||
SLOT(downloadProgress(qint64, qint64)));
|
SLOT(downloadProgress(qint64, qint64)));
|
||||||
connect(rep, SIGNAL(finished()), SLOT(downloadFinished()));
|
connect(rep, SIGNAL(finished()), SLOT(downloadFinished()));
|
||||||
@ -33,7 +33,8 @@ void ByteArrayDownload::downloadProgress(qint64 bytesReceived, qint64 bytesTotal
|
|||||||
void ByteArrayDownload::downloadError(QNetworkReply::NetworkError error)
|
void ByteArrayDownload::downloadError(QNetworkReply::NetworkError error)
|
||||||
{
|
{
|
||||||
// error happened during download.
|
// error happened during download.
|
||||||
qDebug() << "URL:" << m_url.toString().toLocal8Bit() << "Network error: " << error;
|
QLOG_ERROR() << "Error getting URL:" << m_url.toString().toLocal8Bit()
|
||||||
|
<< "Network error: " << error;
|
||||||
m_status = Job_Failed;
|
m_status = Job_Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,14 +46,14 @@ void ByteArrayDownload::downloadFinished()
|
|||||||
// nothing went wrong...
|
// nothing went wrong...
|
||||||
m_status = Job_Finished;
|
m_status = Job_Finished;
|
||||||
m_data = m_reply->readAll();
|
m_data = m_reply->readAll();
|
||||||
m_reply.clear();
|
m_reply.reset();
|
||||||
emit succeeded(index_within_job);
|
emit succeeded(index_within_job);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// else the download failed
|
// else the download failed
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_reply.clear();
|
m_reply.reset();
|
||||||
emit failed(index_within_job);
|
emit failed(index_within_job);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -21,4 +21,4 @@ protected slots:
|
|||||||
void downloadReadyRead();
|
void downloadReadyRead();
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QSharedPointer<ByteArrayDownload> ByteArrayDownloadPtr;
|
typedef std::shared_ptr<ByteArrayDownload> ByteArrayDownloadPtr;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDebug>
|
#include <logger/QsLog.h>
|
||||||
|
|
||||||
CacheDownload::CacheDownload(QUrl url, MetaEntryPtr entry)
|
CacheDownload::CacheDownload(QUrl url, MetaEntryPtr entry)
|
||||||
: Download(), md5sum(QCryptographicHash::Md5)
|
: Download(), md5sum(QCryptographicHash::Md5)
|
||||||
@ -31,7 +31,7 @@ void CacheDownload::start()
|
|||||||
emit failed(index_within_job);
|
emit failed(index_within_job);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qDebug() << "Downloading " << m_url.toString();
|
QLOG_INFO() << "Downloading " << m_url.toString();
|
||||||
QNetworkRequest request(m_url);
|
QNetworkRequest request(m_url);
|
||||||
request.setRawHeader(QString("If-None-Match").toLatin1(), m_entry->etag.toLatin1());
|
request.setRawHeader(QString("If-None-Match").toLatin1(), m_entry->etag.toLatin1());
|
||||||
request.setHeader(QNetworkRequest::UserAgentHeader,"MultiMC/5.0 (Cached)");
|
request.setHeader(QNetworkRequest::UserAgentHeader,"MultiMC/5.0 (Cached)");
|
||||||
@ -39,7 +39,7 @@ void CacheDownload::start()
|
|||||||
auto worker = MMC->qnam();
|
auto worker = MMC->qnam();
|
||||||
QNetworkReply *rep = worker->get(request);
|
QNetworkReply *rep = worker->get(request);
|
||||||
|
|
||||||
m_reply = QSharedPointer<QNetworkReply>(rep, &QObject::deleteLater);
|
m_reply = std::shared_ptr<QNetworkReply>(rep);
|
||||||
connect(rep, SIGNAL(downloadProgress(qint64, qint64)),
|
connect(rep, SIGNAL(downloadProgress(qint64, qint64)),
|
||||||
SLOT(downloadProgress(qint64, qint64)));
|
SLOT(downloadProgress(qint64, qint64)));
|
||||||
connect(rep, SIGNAL(finished()), SLOT(downloadFinished()));
|
connect(rep, SIGNAL(finished()), SLOT(downloadFinished()));
|
||||||
@ -92,7 +92,7 @@ void CacheDownload::downloadFinished()
|
|||||||
m_entry->stale = false;
|
m_entry->stale = false;
|
||||||
MMC->metacache()->updateEntry(m_entry);
|
MMC->metacache()->updateEntry(m_entry);
|
||||||
|
|
||||||
m_reply.clear();
|
m_reply.reset();
|
||||||
emit succeeded(index_within_job);
|
emit succeeded(index_within_job);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ void CacheDownload::downloadFinished()
|
|||||||
{
|
{
|
||||||
m_output_file.close();
|
m_output_file.close();
|
||||||
m_output_file.remove();
|
m_output_file.remove();
|
||||||
m_reply.clear();
|
m_reply.reset();
|
||||||
emit failed(index_within_job);
|
emit failed(index_within_job);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -31,4 +31,4 @@ public slots:
|
|||||||
virtual void start();
|
virtual void start();
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QSharedPointer<CacheDownload> CacheDownloadPtr;
|
typedef std::shared_ptr<CacheDownload> CacheDownloadPtr;
|
||||||
|
@ -2,10 +2,9 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QSharedPointer>
|
#include <memory>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
|
||||||
|
|
||||||
enum JobStatus
|
enum JobStatus
|
||||||
{
|
{
|
||||||
Job_NotStarted,
|
Job_NotStarted,
|
||||||
@ -18,20 +17,21 @@ class Download : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
protected:
|
protected:
|
||||||
explicit Download(): QObject(0){};
|
explicit Download() : QObject(0) {};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~Download() {};
|
virtual ~Download() {};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// the network reply
|
/// the network reply
|
||||||
QSharedPointer<QNetworkReply> m_reply;
|
std::shared_ptr<QNetworkReply> m_reply;
|
||||||
|
|
||||||
/// source URL
|
/// source URL
|
||||||
QUrl m_url;
|
QUrl m_url;
|
||||||
|
|
||||||
/// The file's status
|
/// The file's status
|
||||||
JobStatus m_status;
|
JobStatus m_status;
|
||||||
|
|
||||||
/// index within the parent job
|
/// index within the parent job
|
||||||
int index_within_job = 0;
|
int index_within_job = 0;
|
||||||
|
|
||||||
@ -46,9 +46,9 @@ protected slots:
|
|||||||
virtual void downloadError(QNetworkReply::NetworkError error) = 0;
|
virtual void downloadError(QNetworkReply::NetworkError error) = 0;
|
||||||
virtual void downloadFinished() = 0;
|
virtual void downloadFinished() = 0;
|
||||||
virtual void downloadReadyRead() = 0;
|
virtual void downloadReadyRead() = 0;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void start() = 0;
|
virtual void start() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QSharedPointer<Download> DownloadPtr;
|
typedef std::shared_ptr<Download> DownloadPtr;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "ByteArrayDownload.h"
|
#include "ByteArrayDownload.h"
|
||||||
#include "CacheDownload.h"
|
#include "CacheDownload.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <logger/QsLog.h>
|
||||||
|
|
||||||
ByteArrayDownloadPtr DownloadJob::addByteArrayDownload(QUrl url)
|
ByteArrayDownloadPtr DownloadJob::addByteArrayDownload(QUrl url)
|
||||||
{
|
{
|
||||||
@ -54,18 +54,18 @@ void DownloadJob::partSucceeded(int index)
|
|||||||
partProgress(index, slot.total_progress, slot.total_progress);
|
partProgress(index, slot.total_progress, slot.total_progress);
|
||||||
|
|
||||||
num_succeeded++;
|
num_succeeded++;
|
||||||
qDebug() << m_job_name.toLocal8Bit() << " progress: " << num_succeeded << "/"
|
QLOG_INFO() << m_job_name.toLocal8Bit() << " progress: " << num_succeeded << "/"
|
||||||
<< downloads.size();
|
<< downloads.size();
|
||||||
if (num_failed + num_succeeded == downloads.size())
|
if (num_failed + num_succeeded == downloads.size())
|
||||||
{
|
{
|
||||||
if (num_failed)
|
if (num_failed)
|
||||||
{
|
{
|
||||||
qDebug() << m_job_name.toLocal8Bit() << " failed.";
|
QLOG_ERROR() << m_job_name.toLocal8Bit() << " failed.";
|
||||||
emit failed();
|
emit failed();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug() << m_job_name.toLocal8Bit() << " succeeded.";
|
QLOG_INFO() << m_job_name.toLocal8Bit() << " succeeded.";
|
||||||
emit succeeded();
|
emit succeeded();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,17 +76,17 @@ void DownloadJob::partFailed(int index)
|
|||||||
auto &slot = parts_progress[index];
|
auto &slot = parts_progress[index];
|
||||||
if (slot.failures == 3)
|
if (slot.failures == 3)
|
||||||
{
|
{
|
||||||
qDebug() << "Part " << index << " failed 3 times (" << downloads[index]->m_url << ")";
|
QLOG_ERROR() << "Part " << index << " failed 3 times (" << downloads[index]->m_url << ")";
|
||||||
num_failed++;
|
num_failed++;
|
||||||
if (num_failed + num_succeeded == downloads.size())
|
if (num_failed + num_succeeded == downloads.size())
|
||||||
{
|
{
|
||||||
qDebug() << m_job_name.toLocal8Bit() << " failed.";
|
QLOG_ERROR() << m_job_name.toLocal8Bit() << " failed.";
|
||||||
emit failed();
|
emit failed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug() << "Part " << index << " failed, restarting (" << downloads[index]->m_url
|
QLOG_ERROR() << "Part " << index << " failed, restarting (" << downloads[index]->m_url
|
||||||
<< ")";
|
<< ")";
|
||||||
// restart the job
|
// restart the job
|
||||||
slot.failures++;
|
slot.failures++;
|
||||||
@ -110,12 +110,12 @@ void DownloadJob::partProgress(int index, qint64 bytesReceived, qint64 bytesTota
|
|||||||
|
|
||||||
void DownloadJob::start()
|
void DownloadJob::start()
|
||||||
{
|
{
|
||||||
qDebug() << m_job_name.toLocal8Bit() << " started.";
|
QLOG_INFO() << m_job_name.toLocal8Bit() << " started.";
|
||||||
for (auto iter : downloads)
|
for (auto iter : downloads)
|
||||||
{
|
{
|
||||||
connect(iter.data(), SIGNAL(succeeded(int)), SLOT(partSucceeded(int)));
|
connect(iter.get(), SIGNAL(succeeded(int)), SLOT(partSucceeded(int)));
|
||||||
connect(iter.data(), SIGNAL(failed(int)), SLOT(partFailed(int)));
|
connect(iter.get(), SIGNAL(failed(int)), SLOT(partFailed(int)));
|
||||||
connect(iter.data(), SIGNAL(progress(int, qint64, qint64)),
|
connect(iter.get(), SIGNAL(progress(int, qint64, qint64)),
|
||||||
SLOT(partProgress(int, qint64, qint64)));
|
SLOT(partProgress(int, qint64, qint64)));
|
||||||
iter->start();
|
iter->start();
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include "logic/tasks/ProgressProvider.h"
|
#include "logic/tasks/ProgressProvider.h"
|
||||||
|
|
||||||
class DownloadJob;
|
class DownloadJob;
|
||||||
typedef QSharedPointer<DownloadJob> DownloadJobPtr;
|
typedef std::shared_ptr<DownloadJob> DownloadJobPtr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A single file for the downloader/cache to process.
|
* A single file for the downloader/cache to process.
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "FileDownload.h"
|
#include "FileDownload.h"
|
||||||
#include <pathutils.h>
|
#include <pathutils.h>
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
#include <QDebug>
|
#include <logger/QsLog.h>
|
||||||
|
|
||||||
|
|
||||||
FileDownload::FileDownload ( QUrl url, QString target_path )
|
FileDownload::FileDownload ( QUrl url, QString target_path )
|
||||||
@ -28,7 +28,7 @@ void FileDownload::start()
|
|||||||
// skip this file if they match
|
// skip this file if they match
|
||||||
if ( m_check_md5 && hash == m_expected_md5 )
|
if ( m_check_md5 && hash == m_expected_md5 )
|
||||||
{
|
{
|
||||||
qDebug() << "Skipping " << m_url.toString() << ": md5 match.";
|
QLOG_INFO() << "Skipping " << m_url.toString() << ": md5 match.";
|
||||||
emit succeeded(index_within_job);
|
emit succeeded(index_within_job);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ void FileDownload::start()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "Downloading " << m_url.toString();
|
QLOG_INFO() << "Downloading " << m_url.toString();
|
||||||
QNetworkRequest request ( m_url );
|
QNetworkRequest request ( m_url );
|
||||||
request.setRawHeader(QString("If-None-Match").toLatin1(), m_expected_md5.toLatin1());
|
request.setRawHeader(QString("If-None-Match").toLatin1(), m_expected_md5.toLatin1());
|
||||||
request.setHeader(QNetworkRequest::UserAgentHeader,"MultiMC/5.0 (Uncached)");
|
request.setHeader(QNetworkRequest::UserAgentHeader,"MultiMC/5.0 (Uncached)");
|
||||||
@ -51,7 +51,7 @@ void FileDownload::start()
|
|||||||
auto worker = MMC->qnam();
|
auto worker = MMC->qnam();
|
||||||
QNetworkReply * rep = worker->get ( request );
|
QNetworkReply * rep = worker->get ( request );
|
||||||
|
|
||||||
m_reply = QSharedPointer<QNetworkReply> ( rep, &QObject::deleteLater );
|
m_reply = std::shared_ptr<QNetworkReply> ( rep );
|
||||||
connect ( rep, SIGNAL ( downloadProgress ( qint64,qint64 ) ), SLOT ( downloadProgress ( qint64,qint64 ) ) );
|
connect ( rep, SIGNAL ( downloadProgress ( qint64,qint64 ) ), SLOT ( downloadProgress ( qint64,qint64 ) ) );
|
||||||
connect ( rep, SIGNAL ( finished() ), SLOT ( downloadFinished() ) );
|
connect ( rep, SIGNAL ( finished() ), SLOT ( downloadFinished() ) );
|
||||||
connect ( rep, SIGNAL ( error ( QNetworkReply::NetworkError ) ), SLOT ( downloadError ( QNetworkReply::NetworkError ) ) );
|
connect ( rep, SIGNAL ( error ( QNetworkReply::NetworkError ) ), SLOT ( downloadError ( QNetworkReply::NetworkError ) ) );
|
||||||
@ -79,7 +79,7 @@ void FileDownload::downloadFinished()
|
|||||||
m_status = Job_Finished;
|
m_status = Job_Finished;
|
||||||
m_output_file.close();
|
m_output_file.close();
|
||||||
|
|
||||||
m_reply.clear();
|
m_reply.reset();
|
||||||
emit succeeded(index_within_job);
|
emit succeeded(index_within_job);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ void FileDownload::downloadFinished()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_output_file.close();
|
m_output_file.close();
|
||||||
m_reply.clear();
|
m_reply.reset();
|
||||||
emit failed(index_within_job);
|
emit failed(index_within_job);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -32,4 +32,4 @@ public slots:
|
|||||||
virtual void start();
|
virtual void start();
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QSharedPointer<FileDownload> FileDownloadPtr;
|
typedef std::shared_ptr<FileDownload> FileDownloadPtr;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDebug>
|
#include <logger/QsLog.h>
|
||||||
|
|
||||||
ForgeXzDownload::ForgeXzDownload(QUrl url, MetaEntryPtr entry)
|
ForgeXzDownload::ForgeXzDownload(QUrl url, MetaEntryPtr entry)
|
||||||
: Download()
|
: Download()
|
||||||
@ -32,7 +32,7 @@ void ForgeXzDownload::start()
|
|||||||
emit failed(index_within_job);
|
emit failed(index_within_job);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qDebug() << "Downloading " << m_url.toString();
|
QLOG_INFO() << "Downloading " << m_url.toString();
|
||||||
QNetworkRequest request(m_url);
|
QNetworkRequest request(m_url);
|
||||||
request.setRawHeader(QString("If-None-Match").toLatin1(), m_entry->etag.toLatin1());
|
request.setRawHeader(QString("If-None-Match").toLatin1(), m_entry->etag.toLatin1());
|
||||||
request.setHeader(QNetworkRequest::UserAgentHeader,"MultiMC/5.0 (Cached)");
|
request.setHeader(QNetworkRequest::UserAgentHeader,"MultiMC/5.0 (Cached)");
|
||||||
@ -40,7 +40,7 @@ void ForgeXzDownload::start()
|
|||||||
auto worker = MMC->qnam();
|
auto worker = MMC->qnam();
|
||||||
QNetworkReply *rep = worker->get(request);
|
QNetworkReply *rep = worker->get(request);
|
||||||
|
|
||||||
m_reply = QSharedPointer<QNetworkReply>(rep, &QObject::deleteLater);
|
m_reply = std::shared_ptr<QNetworkReply>(rep);
|
||||||
connect(rep, SIGNAL(downloadProgress(qint64, qint64)),
|
connect(rep, SIGNAL(downloadProgress(qint64, qint64)),
|
||||||
SLOT(downloadProgress(qint64, qint64)));
|
SLOT(downloadProgress(qint64, qint64)));
|
||||||
connect(rep, SIGNAL(finished()), SLOT(downloadFinished()));
|
connect(rep, SIGNAL(finished()), SLOT(downloadFinished()));
|
||||||
@ -78,7 +78,7 @@ void ForgeXzDownload::downloadFinished()
|
|||||||
{
|
{
|
||||||
// something bad happened
|
// something bad happened
|
||||||
m_pack200_xz_file.remove();
|
m_pack200_xz_file.remove();
|
||||||
m_reply.clear();
|
m_reply.reset();
|
||||||
emit failed(index_within_job);
|
emit failed(index_within_job);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ void ForgeXzDownload::downloadFinished()
|
|||||||
{
|
{
|
||||||
m_pack200_xz_file.close();
|
m_pack200_xz_file.close();
|
||||||
m_pack200_xz_file.remove();
|
m_pack200_xz_file.remove();
|
||||||
m_reply.clear();
|
m_reply.reset();
|
||||||
emit failed(index_within_job);
|
emit failed(index_within_job);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -198,38 +198,38 @@ void ForgeXzDownload::decompressAndInstall()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case XZ_MEM_ERROR:
|
case XZ_MEM_ERROR:
|
||||||
qDebug() << "Memory allocation failed\n";
|
QLOG_ERROR() << "Memory allocation failed\n";
|
||||||
xz_dec_end(s);
|
xz_dec_end(s);
|
||||||
emit failed(index_within_job);
|
emit failed(index_within_job);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case XZ_MEMLIMIT_ERROR:
|
case XZ_MEMLIMIT_ERROR:
|
||||||
qDebug() << "Memory usage limit reached\n";
|
QLOG_ERROR() << "Memory usage limit reached\n";
|
||||||
xz_dec_end(s);
|
xz_dec_end(s);
|
||||||
emit failed(index_within_job);
|
emit failed(index_within_job);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case XZ_FORMAT_ERROR:
|
case XZ_FORMAT_ERROR:
|
||||||
qDebug() << "Not a .xz file\n";
|
QLOG_ERROR() << "Not a .xz file\n";
|
||||||
xz_dec_end(s);
|
xz_dec_end(s);
|
||||||
emit failed(index_within_job);
|
emit failed(index_within_job);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case XZ_OPTIONS_ERROR:
|
case XZ_OPTIONS_ERROR:
|
||||||
qDebug() << "Unsupported options in the .xz headers\n";
|
QLOG_ERROR() << "Unsupported options in the .xz headers\n";
|
||||||
xz_dec_end(s);
|
xz_dec_end(s);
|
||||||
emit failed(index_within_job);
|
emit failed(index_within_job);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case XZ_DATA_ERROR:
|
case XZ_DATA_ERROR:
|
||||||
case XZ_BUF_ERROR:
|
case XZ_BUF_ERROR:
|
||||||
qDebug() << "File is corrupt\n";
|
QLOG_ERROR() << "File is corrupt\n";
|
||||||
xz_dec_end(s);
|
xz_dec_end(s);
|
||||||
emit failed(index_within_job);
|
emit failed(index_within_job);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
qDebug() << "Bug!\n";
|
QLOG_ERROR() << "Bug!\n";
|
||||||
xz_dec_end(s);
|
xz_dec_end(s);
|
||||||
emit failed(index_within_job);
|
emit failed(index_within_job);
|
||||||
return;
|
return;
|
||||||
@ -246,7 +246,7 @@ void ForgeXzDownload::decompressAndInstall()
|
|||||||
}
|
}
|
||||||
catch(std::runtime_error & err)
|
catch(std::runtime_error & err)
|
||||||
{
|
{
|
||||||
qDebug() << "Error unpacking " << pack_name.toUtf8() << " : " << err.what();
|
QLOG_ERROR() << "Error unpacking " << pack_name.toUtf8() << " : " << err.what();
|
||||||
QFile f(m_target_path);
|
QFile f(m_target_path);
|
||||||
if(f.exists())
|
if(f.exists())
|
||||||
f.remove();
|
f.remove();
|
||||||
@ -274,6 +274,6 @@ void ForgeXzDownload::decompressAndInstall()
|
|||||||
m_entry->stale = false;
|
m_entry->stale = false;
|
||||||
MMC->metacache()->updateEntry(m_entry);
|
MMC->metacache()->updateEntry(m_entry);
|
||||||
|
|
||||||
m_reply.clear();
|
m_reply.reset();
|
||||||
emit succeeded(index_within_job);
|
emit succeeded(index_within_job);
|
||||||
}
|
}
|
||||||
|
@ -32,4 +32,4 @@ private:
|
|||||||
void decompressAndInstall();
|
void decompressAndInstall();
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QSharedPointer<ForgeXzDownload> ForgeXzDownloadPtr;
|
typedef std::shared_ptr<ForgeXzDownload> ForgeXzDownloadPtr;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <logger/QsLog.h>
|
||||||
|
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
@ -105,12 +105,12 @@ bool HttpMetaCache::updateEntry ( MetaEntryPtr stale_entry )
|
|||||||
{
|
{
|
||||||
if(!m_entries.contains(stale_entry->base))
|
if(!m_entries.contains(stale_entry->base))
|
||||||
{
|
{
|
||||||
qDebug() << "Cannot add entry with unknown base: " << stale_entry->base.toLocal8Bit();
|
QLOG_ERROR() << "Cannot add entry with unknown base: " << stale_entry->base.toLocal8Bit();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(stale_entry->stale)
|
if(stale_entry->stale)
|
||||||
{
|
{
|
||||||
qDebug() << "Cannot add stale entry: " << stale_entry->getFullPath().toLocal8Bit();
|
QLOG_ERROR() << "Cannot add stale entry: " << stale_entry->getFullPath().toLocal8Bit();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
m_entries[stale_entry->base].entry_list[stale_entry->path] = stale_entry;
|
m_entries[stale_entry->base].entry_list[stale_entry->path] = stale_entry;
|
||||||
|
@ -15,7 +15,7 @@ struct MetaEntry
|
|||||||
QString getFullPath();
|
QString getFullPath();
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QSharedPointer<MetaEntry> MetaEntryPtr;
|
typedef std::shared_ptr<MetaEntry> MetaEntryPtr;
|
||||||
|
|
||||||
class HttpMetaCache : public QObject
|
class HttpMetaCache : public QObject
|
||||||
{
|
{
|
||||||
|
@ -40,7 +40,7 @@ void LoginTask::legacyLogin()
|
|||||||
{
|
{
|
||||||
setStatus(tr("Logging in..."));
|
setStatus(tr("Logging in..."));
|
||||||
auto worker = MMC->qnam();
|
auto worker = MMC->qnam();
|
||||||
connect(worker.data(), SIGNAL(finished(QNetworkReply *)), this,
|
connect(worker.get(), SIGNAL(finished(QNetworkReply *)), this,
|
||||||
SLOT(processLegacyReply(QNetworkReply *)));
|
SLOT(processLegacyReply(QNetworkReply *)));
|
||||||
|
|
||||||
QUrl loginURL("https://login.minecraft.net/");
|
QUrl loginURL("https://login.minecraft.net/");
|
||||||
@ -134,7 +134,7 @@ void LoginTask::yggdrasilLogin()
|
|||||||
{
|
{
|
||||||
setStatus(tr("Logging in..."));
|
setStatus(tr("Logging in..."));
|
||||||
auto worker = MMC->qnam();
|
auto worker = MMC->qnam();
|
||||||
connect(worker.data(), SIGNAL(finished(QNetworkReply *)), this,
|
connect(worker.get(), SIGNAL(finished(QNetworkReply *)), this,
|
||||||
SLOT(processYggdrasilReply(QNetworkReply *)));
|
SLOT(processYggdrasilReply(QNetworkReply *)));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Task.h"
|
#include "Task.h"
|
||||||
|
#include <logger/QsLog.h>
|
||||||
|
|
||||||
Task::Task(QObject *parent) :
|
Task::Task(QObject *parent) :
|
||||||
ProgressProvider(parent)
|
ProgressProvider(parent)
|
||||||
@ -55,6 +56,7 @@ void Task::start()
|
|||||||
void Task::emitFailed(QString reason)
|
void Task::emitFailed(QString reason)
|
||||||
{
|
{
|
||||||
m_running = false;
|
m_running = false;
|
||||||
|
QLOG_ERROR() << "Task failed: " << reason;
|
||||||
emit failed(reason);
|
emit failed(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user