Merge branch 'develop'
This commit is contained in:
commit
f941119fbd
@ -217,6 +217,8 @@ gui/EditNotesDialog.h
|
|||||||
gui/EditNotesDialog.cpp
|
gui/EditNotesDialog.cpp
|
||||||
gui/MCModInfoFrame.h
|
gui/MCModInfoFrame.h
|
||||||
gui/MCModInfoFrame.cpp
|
gui/MCModInfoFrame.cpp
|
||||||
|
gui/CustomMessageBox.h
|
||||||
|
gui/CustomMessageBox.cpp
|
||||||
|
|
||||||
# Base classes and infrastructure
|
# Base classes and infrastructure
|
||||||
logic/BaseVersion.h
|
logic/BaseVersion.h
|
||||||
|
28
MultiMC.cpp
28
MultiMC.cpp
@ -32,8 +32,8 @@ using namespace Util::Commandline;
|
|||||||
|
|
||||||
MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
|
MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
|
||||||
{
|
{
|
||||||
setOrganizationName("MultiMC");
|
setOrganizationName("MultiMC");
|
||||||
setApplicationName("MultiMC5");
|
setApplicationName("MultiMC5");
|
||||||
|
|
||||||
initTranslations();
|
initTranslations();
|
||||||
|
|
||||||
@ -139,13 +139,19 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
initGlobalSettings();
|
initGlobalSettings();
|
||||||
|
|
||||||
// and instances
|
// and instances
|
||||||
m_instances.reset(new InstanceList(m_settings->get("InstanceDir").toString(), this));
|
auto InstDirSetting = m_settings->getSetting("InstanceDir");
|
||||||
|
m_instances.reset(new InstanceList(InstDirSetting->get().toString(), this));
|
||||||
QLOG_INFO() << "Loading Instances...";
|
QLOG_INFO() << "Loading Instances...";
|
||||||
m_instances->loadList();
|
m_instances->loadList();
|
||||||
|
connect(InstDirSetting, SIGNAL(settingChanged(const Setting &, QVariant)),
|
||||||
|
m_instances.get(), SLOT(on_InstFolderChanged(const Setting &, QVariant)));
|
||||||
|
|
||||||
// init the http meta cache
|
// init the http meta cache
|
||||||
initHttpMetaCache();
|
initHttpMetaCache();
|
||||||
|
|
||||||
|
// set up a basic autodetected proxy (system default)
|
||||||
|
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
||||||
|
|
||||||
// create the global network manager
|
// create the global network manager
|
||||||
m_qnam.reset(new QNetworkAccessManager(this));
|
m_qnam.reset(new QNetworkAccessManager(this));
|
||||||
|
|
||||||
@ -348,20 +354,24 @@ std::shared_ptr<JavaVersionList> MultiMC::javalist()
|
|||||||
return m_javalist;
|
return m_javalist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main_gui(MultiMC & app)
|
||||||
|
{
|
||||||
|
// show main window
|
||||||
|
MainWindow mainWin;
|
||||||
|
mainWin.show();
|
||||||
|
mainWin.checkSetDefaultJava();
|
||||||
|
return app.exec();
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// initialize Qt
|
// initialize Qt
|
||||||
MultiMC app(argc, argv);
|
MultiMC app(argc, argv);
|
||||||
|
|
||||||
// show main window
|
|
||||||
MainWindow mainWin;
|
|
||||||
mainWin.show();
|
|
||||||
mainWin.checkSetDefaultJava();
|
|
||||||
|
|
||||||
switch (app.status())
|
switch (app.status())
|
||||||
{
|
{
|
||||||
case MultiMC::Initialized:
|
case MultiMC::Initialized:
|
||||||
return app.exec();
|
return main_gui(app);
|
||||||
case MultiMC::Failed:
|
case MultiMC::Failed:
|
||||||
return 1;
|
return 1;
|
||||||
case MultiMC::Succeeded:
|
case MultiMC::Succeeded:
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#define CMDUTILS_H
|
#define CMDUTILS_H
|
||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
@ -83,16 +84,10 @@ enum Enum
|
|||||||
/**
|
/**
|
||||||
* @brief The ParsingError class
|
* @brief The ParsingError class
|
||||||
*/
|
*/
|
||||||
class LIBUTIL_EXPORT ParsingError : public std::exception
|
class LIBUTIL_EXPORT ParsingError : public std::runtime_error
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ParsingError(const QString &what);
|
ParsingError(const QString &what);
|
||||||
ParsingError(const ParsingError &e);
|
|
||||||
~ParsingError() throw() {}
|
|
||||||
const char *what() const throw();
|
|
||||||
QString qwhat() const;
|
|
||||||
private:
|
|
||||||
QString m_what;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,6 +25,16 @@ LIBUTIL_EXPORT QString PathCombine(QString path1, QString path2, QString path3);
|
|||||||
|
|
||||||
LIBUTIL_EXPORT QString AbsolutePath(QString path);
|
LIBUTIL_EXPORT QString AbsolutePath(QString path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalize path
|
||||||
|
*
|
||||||
|
* Any paths inside the current directory will be normalized to relative paths (to current)
|
||||||
|
* Other paths will be made absolute
|
||||||
|
*
|
||||||
|
* Returns false if the path logic somehow filed (and normalizedPath in invalid)
|
||||||
|
*/
|
||||||
|
QString NormalizePath(QString path);
|
||||||
|
|
||||||
LIBUTIL_EXPORT QString RemoveInvalidFilenameChars(QString string, QChar replaceWith = '-');
|
LIBUTIL_EXPORT QString RemoveInvalidFilenameChars(QString string, QChar replaceWith = '-');
|
||||||
|
|
||||||
LIBUTIL_EXPORT QString DirNameFromString(QString string, QString inDir = ".");
|
LIBUTIL_EXPORT QString DirNameFromString(QString string, QString inDir = ".");
|
||||||
|
@ -463,21 +463,8 @@ void Parser::getPrefix(QString &opt, QString &flag)
|
|||||||
|
|
||||||
// ParsingError
|
// ParsingError
|
||||||
ParsingError::ParsingError(const QString &what)
|
ParsingError::ParsingError(const QString &what)
|
||||||
|
:std::runtime_error(what.toStdString())
|
||||||
{
|
{
|
||||||
m_what = what;
|
|
||||||
}
|
|
||||||
ParsingError::ParsingError(const ParsingError &e)
|
|
||||||
{
|
|
||||||
m_what = e.m_what;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *ParsingError::what() const throw()
|
|
||||||
{
|
|
||||||
return m_what.toLocal8Bit().constData();
|
|
||||||
}
|
|
||||||
QString ParsingError::qwhat() const
|
|
||||||
{
|
|
||||||
return m_what;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,30 @@ QString AbsolutePath(QString path)
|
|||||||
return QFileInfo(path).absolutePath();
|
return QFileInfo(path).absolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalize path
|
||||||
|
*
|
||||||
|
* Any paths inside the current directory will be normalized to relative paths (to current)
|
||||||
|
* Other paths will be made absolute
|
||||||
|
*/
|
||||||
|
QString NormalizePath(QString path)
|
||||||
|
{
|
||||||
|
QDir a = QDir::currentPath();
|
||||||
|
QString currentAbsolute = a.absolutePath();
|
||||||
|
|
||||||
|
QDir b(path);
|
||||||
|
QString newAbsolute = b.absolutePath();
|
||||||
|
|
||||||
|
if (newAbsolute.startsWith(currentAbsolute))
|
||||||
|
{
|
||||||
|
return a.relativeFilePath(newAbsolute);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return newAbsolute;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString badFilenameChars = "\"\\/?<>:*|!";
|
QString badFilenameChars = "\"\\/?<>:*|!";
|
||||||
|
|
||||||
QString RemoveInvalidFilenameChars(QString string, QChar replaceWith)
|
QString RemoveInvalidFilenameChars(QString string, QChar replaceWith)
|
||||||
|
19
gui/CustomMessageBox.cpp
Normal file
19
gui/CustomMessageBox.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include "CustomMessageBox.h"
|
||||||
|
|
||||||
|
namespace CustomMessageBox
|
||||||
|
{
|
||||||
|
QMessageBox *selectable(QWidget *parent, const QString &title, const QString &text,
|
||||||
|
QMessageBox::Icon icon, QMessageBox::StandardButtons buttons,
|
||||||
|
QMessageBox::StandardButton defaultButton)
|
||||||
|
{
|
||||||
|
QMessageBox *messageBox = new QMessageBox(parent);
|
||||||
|
messageBox->setWindowTitle(title);
|
||||||
|
messageBox->setText(text);
|
||||||
|
messageBox->setStandardButtons(buttons);
|
||||||
|
messageBox->setDefaultButton(defaultButton);
|
||||||
|
messageBox->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||||
|
messageBox->setIcon(icon);
|
||||||
|
|
||||||
|
return messageBox;
|
||||||
|
}
|
||||||
|
}
|
11
gui/CustomMessageBox.h
Normal file
11
gui/CustomMessageBox.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
namespace CustomMessageBox
|
||||||
|
{
|
||||||
|
QMessageBox *selectable(QWidget *parent, const QString &title, const QString &text,
|
||||||
|
QMessageBox::Icon icon = QMessageBox::NoIcon,
|
||||||
|
QMessageBox::StandardButtons buttons = QMessageBox::Ok,
|
||||||
|
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
|
||||||
|
}
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include "MCModInfoFrame.h"
|
#include "MCModInfoFrame.h"
|
||||||
#include "ui_MCModInfoFrame.h"
|
#include "ui_MCModInfoFrame.h"
|
||||||
|
#include "CustomMessageBox.h"
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
void MCModInfoFrame::updateWithMod(Mod &m)
|
void MCModInfoFrame::updateWithMod(Mod &m)
|
||||||
@ -104,7 +105,5 @@ void MCModInfoFrame::setModDescription(QString text)
|
|||||||
}
|
}
|
||||||
void MCModInfoFrame::modDescEllipsisHandler(const QString &link)
|
void MCModInfoFrame::modDescEllipsisHandler(const QString &link)
|
||||||
{
|
{
|
||||||
QMessageBox msgbox;
|
CustomMessageBox::selectable(this, tr(""), desc)->show();
|
||||||
msgbox.setText(desc);
|
|
||||||
msgbox.exec();
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "ModEditDialogCommon.h"
|
#include "ModEditDialogCommon.h"
|
||||||
|
#include "CustomMessageBox.h"
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@ -33,8 +34,8 @@ void showWebsiteForMod(QWidget *parentDlg, Mod &m)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QMessageBox::warning(
|
CustomMessageBox::selectable(parentDlg, parentDlg->tr("How sad!"),
|
||||||
parentDlg, parentDlg->tr("How sad!"),
|
parentDlg->tr("The mod author didn't provide a website link for this mod."),
|
||||||
parentDlg->tr("The mod author didn't provide a website link for this mod."));
|
QMessageBox::Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "logic/ForgeInstaller.h"
|
#include "logic/ForgeInstaller.h"
|
||||||
#include "gui/versionselectdialog.h"
|
#include "gui/versionselectdialog.h"
|
||||||
#include "gui/platform.h"
|
#include "gui/platform.h"
|
||||||
|
#include "gui/CustomMessageBox.h"
|
||||||
#include "ProgressDialog.h"
|
#include "ProgressDialog.h"
|
||||||
|
|
||||||
#include <pathutils.h>
|
#include <pathutils.h>
|
||||||
@ -110,11 +111,11 @@ void OneSixModEditDialog::on_customizeBtn_clicked()
|
|||||||
|
|
||||||
void OneSixModEditDialog::on_revertBtn_clicked()
|
void OneSixModEditDialog::on_revertBtn_clicked()
|
||||||
{
|
{
|
||||||
auto reply = QMessageBox::question(
|
auto response = CustomMessageBox::selectable(this, tr("Revert?"),
|
||||||
this, tr("Revert?"), tr("Do you want to revert the "
|
tr("Do you want to revert the "
|
||||||
"version of this instance to its original configuration?"),
|
"version of this instance to its original configuration?"),
|
||||||
QMessageBox::Yes | QMessageBox::No);
|
QMessageBox::Question, QMessageBox::Yes | QMessageBox::No)->exec();
|
||||||
if (reply == QMessageBox::Yes)
|
if (response == QMessageBox::Yes)
|
||||||
{
|
{
|
||||||
if (m_inst->revertCustomVersion())
|
if (m_inst->revertCustomVersion())
|
||||||
{
|
{
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include <gui/platform.h>
|
#include <gui/platform.h>
|
||||||
|
#include <gui/CustomMessageBox.h>
|
||||||
|
|
||||||
ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) :
|
ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
@ -12,8 +13,9 @@ ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) :
|
|||||||
m_mayclose(true),
|
m_mayclose(true),
|
||||||
proc(mcproc)
|
proc(mcproc)
|
||||||
{
|
{
|
||||||
MultiMCPlatform::fixWM_CLASS(this);
|
MultiMCPlatform::fixWM_CLASS(this);
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
this->setWindowFlags(Qt::Window);
|
||||||
connect(mcproc, SIGNAL(ended(BaseInstance*)), this, SLOT(onEnded(BaseInstance*)));
|
connect(mcproc, SIGNAL(ended(BaseInstance*)), this, SLOT(onEnded(BaseInstance*)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,17 +98,13 @@ void ConsoleWindow::closeEvent(QCloseEvent * event)
|
|||||||
void ConsoleWindow::on_btnKillMinecraft_clicked()
|
void ConsoleWindow::on_btnKillMinecraft_clicked()
|
||||||
{
|
{
|
||||||
ui->btnKillMinecraft->setEnabled(false);
|
ui->btnKillMinecraft->setEnabled(false);
|
||||||
QMessageBox r_u_sure;
|
auto response = CustomMessageBox::selectable(this, tr("Kill Minecraft?"),
|
||||||
//: Main question of the kill confirmation dialog
|
tr("This can cause the instance to get corrupted and should only be used if Minecraft is frozen for some reason"),
|
||||||
r_u_sure.setText(tr("Kill Minecraft?"));
|
QMessageBox::Question, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes)->exec();
|
||||||
r_u_sure.setInformativeText(tr("This can cause the instance to get corrupted and should only be used if Minecraft is frozen for some reason"));
|
if (response == QMessageBox::Yes)
|
||||||
r_u_sure.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
|
||||||
r_u_sure.setDefaultButton(QMessageBox::Yes);
|
|
||||||
if (r_u_sure.exec() == QMessageBox::Yes)
|
|
||||||
proc->killMinecraft();
|
proc->killMinecraft();
|
||||||
else
|
else
|
||||||
ui->btnKillMinecraft->setEnabled(true);
|
ui->btnKillMinecraft->setEnabled(true);
|
||||||
r_u_sure.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleWindow::onEnded(BaseInstance *instance)
|
void ConsoleWindow::onEnded(BaseInstance *instance)
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string><span style=" color:#ff0000;">Error</span></string>
|
<string><span style=" color:#ff0000;">Error</span></string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="textInteractionFlags">
|
||||||
|
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -85,19 +88,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="5" rowspan="2">
|
|
||||||
<widget class="QPushButton" name="forgetButton">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Forget</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -128,6 +118,19 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="forgetButton">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Forget</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
#include "gui/consolewindow.h"
|
#include "gui/consolewindow.h"
|
||||||
#include "gui/instancesettings.h"
|
#include "gui/instancesettings.h"
|
||||||
#include "gui/platform.h"
|
#include "gui/platform.h"
|
||||||
|
#include "gui/CustomMessageBox.h"
|
||||||
|
|
||||||
#include "logic/lists/InstanceList.h"
|
#include "logic/lists/InstanceList.h"
|
||||||
#include "logic/lists/MinecraftVersionList.h"
|
#include "logic/lists/MinecraftVersionList.h"
|
||||||
@ -281,20 +282,26 @@ void MainWindow::on_actionAddInstance_triggered()
|
|||||||
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);
|
CustomMessageBox::selectable(this, tr("Error"), errorMsg, QMessageBox::Warning)->show();
|
||||||
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);
|
CustomMessageBox::selectable(this, tr("Error"), errorMsg, QMessageBox::Warning)->show();
|
||||||
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);
|
CustomMessageBox::selectable(this, tr("Error"), errorMsg, QMessageBox::Warning)->show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionChangeInstIcon_triggered()
|
void MainWindow::on_actionChangeInstIcon_triggered()
|
||||||
@ -387,9 +394,10 @@ void MainWindow::on_actionDeleteInstance_triggered()
|
|||||||
{
|
{
|
||||||
if (m_selectedInstance)
|
if (m_selectedInstance)
|
||||||
{
|
{
|
||||||
int response = QMessageBox::question(
|
auto response = CustomMessageBox::selectable(this, tr("CAREFUL"),
|
||||||
this, "CAREFUL", QString("This is permanent! Are you sure?\nAbout to delete: ") +
|
tr("This is permanent! Are you sure?\nAbout to delete: ")
|
||||||
m_selectedInstance->name());
|
+ m_selectedInstance->name(),
|
||||||
|
QMessageBox::Question, QMessageBox::Yes | QMessageBox::No)->exec();
|
||||||
if (response == QMessageBox::Yes)
|
if (response == QMessageBox::Yes)
|
||||||
{
|
{
|
||||||
m_selectedInstance->nuke();
|
m_selectedInstance->nuke();
|
||||||
@ -626,7 +634,7 @@ void MainWindow::onGameUpdateComplete()
|
|||||||
|
|
||||||
void MainWindow::onGameUpdateError(QString error)
|
void MainWindow::onGameUpdateError(QString error)
|
||||||
{
|
{
|
||||||
QMessageBox::warning(this, "Error updating instance", error);
|
CustomMessageBox::selectable(this, tr("Error updating instance"), error, QMessageBox::Warning)->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::launchInstance(BaseInstance *instance, LoginResponse response)
|
void MainWindow::launchInstance(BaseInstance *instance, LoginResponse response)
|
||||||
@ -695,9 +703,9 @@ void MainWindow::on_actionMakeDesktopShortcut_triggered()
|
|||||||
QStringList() << "-dl" << QDir::currentPath() << "test", name,
|
QStringList() << "-dl" << QDir::currentPath() << "test", name,
|
||||||
"application-x-octet-stream");
|
"application-x-octet-stream");
|
||||||
|
|
||||||
QMessageBox::warning(
|
CustomMessageBox::selectable(this, tr("Not useful"),
|
||||||
this, tr("Not useful"),
|
tr("A Dummy Shortcut was created. it will not do anything productive"),
|
||||||
tr("A Dummy Shortcut was created. it will not do anything productive"));
|
QMessageBox::Warning)->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
// BrowserDialog
|
// BrowserDialog
|
||||||
@ -718,11 +726,11 @@ void MainWindow::on_actionChangeInstMCVersion_triggered()
|
|||||||
{
|
{
|
||||||
if (m_selectedInstance->versionIsCustom())
|
if (m_selectedInstance->versionIsCustom())
|
||||||
{
|
{
|
||||||
auto result = QMessageBox::warning(
|
auto result = CustomMessageBox::selectable(this, tr("Are you sure?"),
|
||||||
this, tr("Are you sure?"),
|
tr("This will remove any library/version customization you did previously. "
|
||||||
tr("This will remove any library/version customization you did previously. "
|
"This includes things like Forge install and similar."),
|
||||||
"This includes things like Forge install and similar."),
|
QMessageBox::Warning, QMessageBox::Ok, QMessageBox::Abort)->exec();
|
||||||
QMessageBox::Ok, QMessageBox::Abort);
|
|
||||||
if (result != QMessageBox::Ok)
|
if (result != QMessageBox::Ok)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -853,10 +861,12 @@ void MainWindow::checkSetDefaultJava()
|
|||||||
java = std::dynamic_pointer_cast<JavaVersion>(vselect.selectedVersion());
|
java = std::dynamic_pointer_cast<JavaVersion>(vselect.selectedVersion());
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QMessageBox::warning(this, tr("Invalid version selected"),
|
CustomMessageBox::selectable(this, tr("Invalid version selected"),
|
||||||
tr("You didn't select a valid Java version, so MultiMC will "
|
tr("You didn't select a valid Java version, so MultiMC will "
|
||||||
"select the default. "
|
"select the default. "
|
||||||
"You can change this in the settings dialog."));
|
"You can change this in the settings dialog."),
|
||||||
|
QMessageBox::Warning)->show();
|
||||||
|
|
||||||
JavaUtils ju;
|
JavaUtils ju;
|
||||||
java = ju.GetDefaultJava();
|
java = ju.GetDefaultJava();
|
||||||
}
|
}
|
||||||
|
@ -19,17 +19,18 @@
|
|||||||
#include "logic/JavaUtils.h"
|
#include "logic/JavaUtils.h"
|
||||||
#include "gui/versionselectdialog.h"
|
#include "gui/versionselectdialog.h"
|
||||||
#include "gui/platform.h"
|
#include "gui/platform.h"
|
||||||
|
#include "gui/CustomMessageBox.h"
|
||||||
#include "logic/lists/JavaVersionList.h"
|
#include "logic/lists/JavaVersionList.h"
|
||||||
|
|
||||||
#include <settingsobject.h>
|
#include <settingsobject.h>
|
||||||
|
#include <pathutils.h>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
SettingsDialog::SettingsDialog(QWidget *parent) :
|
SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::SettingsDialog)
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::SettingsDialog)
|
|
||||||
{
|
{
|
||||||
MultiMCPlatform::fixWM_CLASS(this);
|
MultiMCPlatform::fixWM_CLASS(this);
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
loadSettings(MMC->settings().get());
|
loadSettings(MMC->settings().get());
|
||||||
@ -40,7 +41,7 @@ SettingsDialog::~SettingsDialog()
|
|||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
void SettingsDialog::showEvent ( QShowEvent* ev )
|
void SettingsDialog::showEvent(QShowEvent *ev)
|
||||||
{
|
{
|
||||||
QDialog::showEvent(ev);
|
QDialog::showEvent(ev);
|
||||||
adjustSize();
|
adjustSize();
|
||||||
@ -49,31 +50,46 @@ void SettingsDialog::showEvent ( QShowEvent* ev )
|
|||||||
void SettingsDialog::updateCheckboxStuff()
|
void SettingsDialog::updateCheckboxStuff()
|
||||||
{
|
{
|
||||||
ui->windowWidthSpinBox->setEnabled(!ui->maximizedCheckBox->isChecked());
|
ui->windowWidthSpinBox->setEnabled(!ui->maximizedCheckBox->isChecked());
|
||||||
ui->windowHeightSpinBox->setEnabled(! ui->maximizedCheckBox->isChecked());
|
ui->windowHeightSpinBox->setEnabled(!ui->maximizedCheckBox->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::on_instDirBrowseBtn_clicked()
|
void SettingsDialog::on_instDirBrowseBtn_clicked()
|
||||||
{
|
{
|
||||||
QString dir = QFileDialog::getExistingDirectory(this, tr("Instance Directory"),
|
QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Instance Directory"),
|
||||||
ui->instDirTextBox->text());
|
ui->instDirTextBox->text());
|
||||||
if (!dir.isEmpty())
|
QString cooked_dir = NormalizePath(raw_dir);
|
||||||
ui->instDirTextBox->setText(dir);
|
|
||||||
|
// do not allow current dir - it's dirty. Do not allow dirs that don't exist
|
||||||
|
if (!cooked_dir.isEmpty() && QDir(cooked_dir).exists())
|
||||||
|
{
|
||||||
|
ui->instDirTextBox->setText(cooked_dir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::on_modsDirBrowseBtn_clicked()
|
void SettingsDialog::on_modsDirBrowseBtn_clicked()
|
||||||
{
|
{
|
||||||
QString dir = QFileDialog::getExistingDirectory(this, tr("Mods Directory"),
|
QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Mods Directory"),
|
||||||
ui->modsDirTextBox->text());
|
ui->modsDirTextBox->text());
|
||||||
if (!dir.isEmpty())
|
QString cooked_dir = NormalizePath(raw_dir);
|
||||||
ui->modsDirTextBox->setText(dir);
|
|
||||||
|
// do not allow current dir - it's dirty. Do not allow dirs that don't exist
|
||||||
|
if (!cooked_dir.isEmpty() && QDir(cooked_dir).exists())
|
||||||
|
{
|
||||||
|
ui->modsDirTextBox->setText(cooked_dir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::on_lwjglDirBrowseBtn_clicked()
|
void SettingsDialog::on_lwjglDirBrowseBtn_clicked()
|
||||||
{
|
{
|
||||||
QString dir = QFileDialog::getExistingDirectory(this, tr("LWJGL Directory"),
|
QString raw_dir = QFileDialog::getExistingDirectory(this, tr("LWJGL Directory"),
|
||||||
ui->lwjglDirTextBox->text());
|
ui->lwjglDirTextBox->text());
|
||||||
if (!dir.isEmpty())
|
QString cooked_dir = NormalizePath(raw_dir);
|
||||||
ui->lwjglDirTextBox->setText(dir);
|
|
||||||
|
// do not allow current dir - it's dirty. Do not allow dirs that don't exist
|
||||||
|
if (!cooked_dir.isEmpty() && QDir(cooked_dir).exists())
|
||||||
|
{
|
||||||
|
ui->lwjglDirTextBox->setText(cooked_dir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::on_compatModeCheckBox_clicked(bool checked)
|
void SettingsDialog::on_compatModeCheckBox_clicked(bool checked)
|
||||||
@ -104,16 +120,16 @@ void SettingsDialog::applySettings(SettingsObject *s)
|
|||||||
}
|
}
|
||||||
else if (!s->get("UseDevBuilds").toBool())
|
else if (!s->get("UseDevBuilds").toBool())
|
||||||
{
|
{
|
||||||
int response = QMessageBox::question(this, tr("Development builds"),
|
auto response = CustomMessageBox::selectable(this, tr("Development builds"),
|
||||||
tr("Development builds contain experimental features "
|
tr("Development builds contain experimental features "
|
||||||
"and may be unstable. Are you sure you want to enable them?"));
|
"and may be unstable. Are you sure you want to enable them?"),
|
||||||
|
QMessageBox::Question, QMessageBox::Yes | QMessageBox::No)->exec();
|
||||||
if (response == QMessageBox::Yes)
|
if (response == QMessageBox::Yes)
|
||||||
{
|
{
|
||||||
s->set("UseDevBuilds", true);
|
s->set("UseDevBuilds", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updates
|
// Updates
|
||||||
s->set("AutoUpdate", ui->autoUpdateCheckBox->isChecked());
|
s->set("AutoUpdate", ui->autoUpdateCheckBox->isChecked());
|
||||||
|
|
||||||
@ -204,7 +220,7 @@ void SettingsDialog::on_pushButton_clicked()
|
|||||||
void SettingsDialog::on_btnBrowse_clicked()
|
void SettingsDialog::on_btnBrowse_clicked()
|
||||||
{
|
{
|
||||||
QString dir = QFileDialog::getOpenFileName(this, tr("Find Java executable"));
|
QString dir = QFileDialog::getOpenFileName(this, tr("Find Java executable"));
|
||||||
if(!dir.isNull())
|
if (!dir.isNull())
|
||||||
{
|
{
|
||||||
ui->javaPathTextBox->setText(dir);
|
ui->javaPathTextBox->setText(dir);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
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(instDir)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,8 +196,8 @@ void InstanceList::loadGroupList(QMap<QString, QString> &groupMap)
|
|||||||
if (error.error != QJsonParseError::NoError)
|
if (error.error != QJsonParseError::NoError)
|
||||||
{
|
{
|
||||||
QLOG_ERROR() << 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))
|
.arg(error.errorString(), QString::number(error.offset))
|
||||||
.toUtf8();
|
.toUtf8();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,7 +269,8 @@ InstanceList::InstListError InstanceList::loadList()
|
|||||||
|
|
||||||
m_instances.clear();
|
m_instances.clear();
|
||||||
QDir dir(m_instDir);
|
QDir dir(m_instDir);
|
||||||
QDirIterator iter(dir);
|
QDirIterator iter(m_instDir, QDir::Dirs | QDir::NoDot | QDir::NoDotDot | QDir::Readable,
|
||||||
|
QDirIterator::FollowSymlinks);
|
||||||
while (iter.hasNext())
|
while (iter.hasNext())
|
||||||
{
|
{
|
||||||
QString subDir = iter.next();
|
QString subDir = iter.next();
|
||||||
@ -340,7 +341,12 @@ void InstanceList::clear()
|
|||||||
endResetModel();
|
endResetModel();
|
||||||
emit dataIsInvalid();
|
emit dataIsInvalid();
|
||||||
}
|
}
|
||||||
;
|
|
||||||
|
void InstanceList::on_InstFolderChanged(const Setting &setting, QVariant value)
|
||||||
|
{
|
||||||
|
m_instDir = value.toString();
|
||||||
|
loadList();
|
||||||
|
}
|
||||||
|
|
||||||
/// 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)
|
||||||
|
@ -29,7 +29,7 @@ class InstanceList : public QAbstractListModel
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
void loadGroupList(QMap<QString, QString> & groupList);
|
void loadGroupList(QMap<QString, QString> &groupList);
|
||||||
void saveGroupList();
|
void saveGroupList();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -37,10 +37,10 @@ public:
|
|||||||
virtual ~InstanceList();
|
virtual ~InstanceList();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QModelIndex index ( int row, int column = 0, const QModelIndex& parent = QModelIndex() ) const;
|
QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
|
||||||
int rowCount ( const QModelIndex& parent = QModelIndex() ) const;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
QVariant data ( const QModelIndex& index, int role ) const;
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
Qt::ItemFlags flags ( const QModelIndex& index ) const;
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
|
|
||||||
enum AdditionalRoles
|
enum AdditionalRoles
|
||||||
{
|
{
|
||||||
@ -57,7 +57,10 @@ public:
|
|||||||
UnknownError
|
UnknownError
|
||||||
};
|
};
|
||||||
|
|
||||||
QString instDir() const { return m_instDir; }
|
QString instDir() const
|
||||||
|
{
|
||||||
|
return m_instDir;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Loads the instance list. Triggers notifications.
|
* \brief Loads the instance list. Triggers notifications.
|
||||||
@ -70,7 +73,8 @@ public:
|
|||||||
InstancePtr at(int i) const
|
InstancePtr at(int i) const
|
||||||
{
|
{
|
||||||
return m_instances.at(i);
|
return m_instances.at(i);
|
||||||
};
|
}
|
||||||
|
;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Get the count of loaded instances
|
* \brief Get the count of loaded instances
|
||||||
@ -78,7 +82,8 @@ public:
|
|||||||
int count() const
|
int count() const
|
||||||
{
|
{
|
||||||
return m_instances.count();
|
return m_instances.count();
|
||||||
};
|
}
|
||||||
|
;
|
||||||
|
|
||||||
/// Clear all instances. Triggers notifications.
|
/// Clear all instances. Triggers notifications.
|
||||||
void clear();
|
void clear();
|
||||||
@ -87,27 +92,33 @@ public:
|
|||||||
int add(InstancePtr t);
|
int add(InstancePtr t);
|
||||||
|
|
||||||
/// Get an instance by ID
|
/// Get an instance by ID
|
||||||
InstancePtr getInstanceById (QString id);
|
InstancePtr getInstanceById(QString id);
|
||||||
signals:
|
signals:
|
||||||
void dataIsInvalid();
|
void dataIsInvalid();
|
||||||
|
|
||||||
private slots:
|
public
|
||||||
void propertiesChanged(BaseInstance * inst);
|
slots:
|
||||||
void instanceNuked(BaseInstance * inst);
|
void on_InstFolderChanged(const Setting & setting, QVariant value);
|
||||||
|
|
||||||
|
private
|
||||||
|
slots:
|
||||||
|
void propertiesChanged(BaseInstance *inst);
|
||||||
|
void instanceNuked(BaseInstance *inst);
|
||||||
void groupChanged();
|
void groupChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int getInstIndex(BaseInstance * inst);
|
int getInstIndex(BaseInstance *inst);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString m_instDir;
|
QString m_instDir;
|
||||||
QList< InstancePtr > m_instances;
|
QList<InstancePtr> m_instances;
|
||||||
};
|
};
|
||||||
|
|
||||||
class InstanceProxyModel : public KCategorizedSortFilterProxyModel
|
class InstanceProxyModel : public KCategorizedSortFilterProxyModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit InstanceProxyModel ( QObject *parent = 0 );
|
explicit InstanceProxyModel(QObject *parent = 0);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool subSortLessThan ( const QModelIndex& left, const QModelIndex& right ) const;
|
virtual bool subSortLessThan(const QModelIndex &left, const QModelIndex &right) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user