summaryrefslogtreecommitdiffstats
path: root/gui/LegacyModEditDialog.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-10-06 01:13:40 +0200
committerPetr Mrázek <peterix@gmail.com>2013-10-06 01:13:40 +0200
commitf83119ce7ec3d11a903901b8eff762d2b0a9f635 (patch)
tree5c30d7b9fff0f9417e7f2cd79d8ad9ea56d7f056 /gui/LegacyModEditDialog.cpp
parenteba9b3d759dbf6e402e91ab897059f1d274aef90 (diff)
downloadMultiMC-f83119ce7ec3d11a903901b8eff762d2b0a9f635.tar
MultiMC-f83119ce7ec3d11a903901b8eff762d2b0a9f635.tar.gz
MultiMC-f83119ce7ec3d11a903901b8eff762d2b0a9f635.tar.lz
MultiMC-f83119ce7ec3d11a903901b8eff762d2b0a9f635.tar.xz
MultiMC-f83119ce7ec3d11a903901b8eff762d2b0a9f635.zip
Added file logger
Diffstat (limited to 'gui/LegacyModEditDialog.cpp')
-rw-r--r--gui/LegacyModEditDialog.cpp206
1 files changed, 101 insertions, 105 deletions
diff --git a/gui/LegacyModEditDialog.cpp b/gui/LegacyModEditDialog.cpp
index 053aef6b..c240daff 100644
--- a/gui/LegacyModEditDialog.cpp
+++ b/gui/LegacyModEditDialog.cpp
@@ -3,7 +3,7 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@@ -28,49 +28,47 @@
#include <QEvent>
#include <QKeyEvent>
-LegacyModEditDialog::LegacyModEditDialog( LegacyInstance* inst, QWidget* parent ) :
- m_inst(inst),
- QDialog(parent),
- ui(new Ui::LegacyModEditDialog)
+LegacyModEditDialog::LegacyModEditDialog(LegacyInstance *inst, QWidget *parent)
+ : m_inst(inst), QDialog(parent), ui(new Ui::LegacyModEditDialog)
{
ui->setupUi(this);
-
+
// Jar mods
{
ensureFolderPathExists(m_inst->jarModsDir());
m_jarmods = m_inst->jarModList();
- ui->jarModsTreeView->setModel(m_jarmods.data());
+ ui->jarModsTreeView->setModel(m_jarmods.get());
#ifndef Q_OS_LINUX
// FIXME: internal DnD causes segfaults later
ui->jarModsTreeView->setDragDropMode(QAbstractItemView::DragDrop);
// FIXME: DnD is glitched with contiguous (we move only first item in selection)
ui->jarModsTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
#endif
- ui->jarModsTreeView->installEventFilter( this );
+ ui->jarModsTreeView->installEventFilter(this);
m_jarmods->startWatching();
}
// Core mods
{
ensureFolderPathExists(m_inst->coreModsDir());
m_coremods = m_inst->coreModList();
- ui->coreModsTreeView->setModel(m_coremods.data());
- ui->coreModsTreeView->installEventFilter( this );
+ ui->coreModsTreeView->setModel(m_coremods.get());
+ ui->coreModsTreeView->installEventFilter(this);
m_coremods->startWatching();
}
// Loader mods
{
ensureFolderPathExists(m_inst->loaderModsDir());
m_mods = m_inst->loaderModList();
- ui->loaderModTreeView->setModel(m_mods.data());
- ui->loaderModTreeView->installEventFilter( this );
+ ui->loaderModTreeView->setModel(m_mods.get());
+ ui->loaderModTreeView->installEventFilter(this);
m_mods->startWatching();
}
// texture packs
{
ensureFolderPathExists(m_inst->texturePacksDir());
m_texturepacks = m_inst->texturePackList();
- ui->texPackTreeView->setModel(m_texturepacks.data());
- ui->texPackTreeView->installEventFilter( this );
+ ui->texPackTreeView->setModel(m_texturepacks.get());
+ ui->texPackTreeView->installEventFilter(this);
m_texturepacks->startWatching();
}
}
@@ -84,113 +82,111 @@ LegacyModEditDialog::~LegacyModEditDialog()
delete ui;
}
-bool LegacyModEditDialog::coreListFilter ( QKeyEvent* keyEvent )
+bool LegacyModEditDialog::coreListFilter(QKeyEvent *keyEvent)
{
- switch(keyEvent->key())
+ switch (keyEvent->key())
{
- case Qt::Key_Delete:
- on_rmCoreBtn_clicked();
- return true;
- case Qt::Key_Plus:
- on_addCoreBtn_clicked();
- return true;
- default:
- break;
+ case Qt::Key_Delete:
+ on_rmCoreBtn_clicked();
+ return true;
+ case Qt::Key_Plus:
+ on_addCoreBtn_clicked();
+ return true;
+ default:
+ 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;
- }
- break;
+ on_moveJarUpBtn_clicked();
+ return true;
}
- case Qt::Key_Down:
+ break;
+ }
+ case Qt::Key_Down:
+ {
+ if (keyEvent->modifiers() & Qt::ControlModifier)
{
- if(keyEvent->modifiers() & Qt::ControlModifier)
- {
- on_moveJarDownBtn_clicked();
- return true;
- }
- break;
- }
- case Qt::Key_Delete:
- on_rmJarBtn_clicked();
- return true;
- case Qt::Key_Plus:
- on_addJarBtn_clicked();
+ on_moveJarDownBtn_clicked();
return true;
- default:
- break;
+ }
+ 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:
- on_rmModBtn_clicked();
- return true;
- case Qt::Key_Plus:
- on_addModBtn_clicked();
- return true;
- default:
- break;
+ case Qt::Key_Delete:
+ on_rmModBtn_clicked();
+ return true;
+ case Qt::Key_Plus:
+ on_addModBtn_clicked();
+ return true;
+ default:
+ 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:
- on_rmTexPackBtn_clicked();
- return true;
- case Qt::Key_Plus:
- on_addTexPackBtn_clicked();
- return true;
- default:
- break;
+ case Qt::Key_Delete:
+ on_rmTexPackBtn_clicked();
+ return true;
+ case Qt::Key_Plus:
+ on_addTexPackBtn_clicked();
+ return true;
+ default:
+ 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)
{
- return QDialog::eventFilter( obj, ev );
+ return QDialog::eventFilter(obj, ev);
}
- QKeyEvent *keyEvent = static_cast<QKeyEvent*>(ev);
- if(obj == ui->jarModsTreeView)
+ QKeyEvent *keyEvent = static_cast<QKeyEvent *>(ev);
+ if (obj == ui->jarModsTreeView)
return jarListFilter(keyEvent);
- if(obj == ui->coreModsTreeView)
+ if (obj == ui->coreModsTreeView)
return coreListFilter(keyEvent);
- if(obj == ui->loaderModTreeView)
+ if (obj == ui->loaderModTreeView)
return loaderListFilter(keyEvent);
- if(obj == ui->texPackTreeView)
+ if (obj == ui->texPackTreeView)
return texturePackListFilter(keyEvent);
- return QDialog::eventFilter( obj, ev );
+ return QDialog::eventFilter(obj, ev);
}
-
void LegacyModEditDialog::on_addCoreBtn_clicked()
{
//: Title of core mod selection dialog
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select Core Mods"));
- for(auto filename:fileNames)
+ for (auto filename : fileNames)
{
m_coremods->stopWatching();
m_coremods->installMod(QFileInfo(filename));
@@ -199,21 +195,22 @@ void LegacyModEditDialog::on_addCoreBtn_clicked()
}
void LegacyModEditDialog::on_addForgeBtn_clicked()
{
- VersionSelectDialog vselect(MMC->forgelist().data(), this);
+ VersionSelectDialog vselect(MMC->forgelist().get(), this);
vselect.setFilter(1, m_inst->intendedVersionId());
if (vselect.exec() && vselect.selectedVersion())
{
- ForgeVersionPtr forge = vselect.selectedVersion().dynamicCast<ForgeVersion>();
- if(!forge)
+ ForgeVersionPtr forge =
+ std::dynamic_pointer_cast<ForgeVersion> (vselect.selectedVersion());
+ if (!forge)
return;
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);
ProgressDialog dlg(this);
dlg.exec(fjob);
- if(dlg.result() == QDialog::Accepted)
+ if (dlg.result() == QDialog::Accepted)
{
m_jarmods->stopWatching();
m_jarmods->installMod(QFileInfo(entry->getFullPath()));
@@ -236,7 +233,7 @@ void LegacyModEditDialog::on_addJarBtn_clicked()
{
//: Title of jar mod selection dialog
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select Jar Mods"));
- for(auto filename:fileNames)
+ for (auto filename : fileNames)
{
m_jarmods->stopWatching();
m_jarmods->installMod(QFileInfo(filename));
@@ -247,7 +244,7 @@ void LegacyModEditDialog::on_addModBtn_clicked()
{
//: Title of regular mod selection dialog
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select Loader Mods"));
- for(auto filename:fileNames)
+ for (auto filename : fileNames)
{
m_mods->stopWatching();
m_mods->installMod(QFileInfo(filename));
@@ -258,7 +255,7 @@ void LegacyModEditDialog::on_addTexPackBtn_clicked()
{
//: Title of texture pack selection dialog
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select Texture Packs"));
- for(auto filename:fileNames)
+ for (auto filename : fileNames)
{
m_texturepacks->stopWatching();
m_texturepacks->installMod(QFileInfo(filename));
@@ -270,8 +267,8 @@ void LegacyModEditDialog::on_moveJarDownBtn_clicked()
{
int first, last;
auto list = ui->jarModsTreeView->selectionModel()->selectedRows();
-
- if(!lastfirst(list, first, last))
+
+ if (!lastfirst(list, first, last))
return;
m_jarmods->moveModsDown(first, last);
@@ -280,8 +277,8 @@ void LegacyModEditDialog::on_moveJarUpBtn_clicked()
{
int first, last;
auto list = ui->jarModsTreeView->selectionModel()->selectedRows();
-
- if(!lastfirst(list, first, last))
+
+ if (!lastfirst(list, first, last))
return;
m_jarmods->moveModsUp(first, last);
}
@@ -289,8 +286,8 @@ void LegacyModEditDialog::on_rmCoreBtn_clicked()
{
int first, last;
auto list = ui->coreModsTreeView->selectionModel()->selectedRows();
-
- if(!lastfirst(list, first, last))
+
+ if (!lastfirst(list, first, last))
return;
m_coremods->stopWatching();
m_coremods->deleteMods(first, last);
@@ -300,8 +297,8 @@ void LegacyModEditDialog::on_rmJarBtn_clicked()
{
int first, last;
auto list = ui->jarModsTreeView->selectionModel()->selectedRows();
-
- if(!lastfirst(list, first, last))
+
+ if (!lastfirst(list, first, last))
return;
m_jarmods->stopWatching();
m_jarmods->deleteMods(first, last);
@@ -311,8 +308,8 @@ void LegacyModEditDialog::on_rmModBtn_clicked()
{
int first, last;
auto list = ui->loaderModTreeView->selectionModel()->selectedRows();
-
- if(!lastfirst(list, first, last))
+
+ if (!lastfirst(list, first, last))
return;
m_mods->stopWatching();
m_mods->deleteMods(first, last);
@@ -322,8 +319,8 @@ void LegacyModEditDialog::on_rmTexPackBtn_clicked()
{
int first, last;
auto list = ui->texPackTreeView->selectionModel()->selectedRows();
-
- if(!lastfirst(list, first, last))
+
+ if (!lastfirst(list, first, last))
return;
m_texturepacks->stopWatching();
m_texturepacks->deleteMods(first, last);
@@ -342,7 +339,6 @@ void LegacyModEditDialog::on_viewTexPackBtn_clicked()
openDirInDefaultProgram(m_inst->texturePacksDir(), true);
}
-
void LegacyModEditDialog::on_buttonBox_rejected()
{
close();