summaryrefslogtreecommitdiffstats
path: root/gui/dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'gui/dialogs')
-rw-r--r--gui/dialogs/OneSixModEditDialog.cpp206
-rw-r--r--gui/dialogs/OneSixModEditDialog.h6
-rw-r--r--gui/dialogs/OneSixModEditDialog.ui50
-rw-r--r--gui/dialogs/SettingsDialog.cpp230
-rw-r--r--gui/dialogs/SettingsDialog.h7
-rw-r--r--gui/dialogs/SettingsDialog.ui133
-rw-r--r--gui/dialogs/VersionSelectDialog.cpp1
7 files changed, 435 insertions, 198 deletions
diff --git a/gui/dialogs/OneSixModEditDialog.cpp b/gui/dialogs/OneSixModEditDialog.cpp
index 9e585de5..78585a05 100644
--- a/gui/dialogs/OneSixModEditDialog.cpp
+++ b/gui/dialogs/OneSixModEditDialog.cpp
@@ -34,15 +34,15 @@
#include "gui/dialogs/ProgressDialog.h"
#include "logic/ModList.h"
-#include "logic/OneSixVersion.h"
+#include "logic/VersionFinal.h"
#include "logic/EnabledItemFilter.h"
#include "logic/lists/ForgeVersionList.h"
+#include "logic/lists/LiteLoaderVersionList.h"
#include "logic/ForgeInstaller.h"
#include "logic/LiteLoaderInstaller.h"
#include "logic/OneSixVersionBuilder.h"
-template<typename A, typename B>
-QMap<A, B> invert(const QMap<B, A> &in)
+template <typename A, typename B> QMap<A, B> invert(const QMap<B, A> &in)
{
QMap<A, B> out;
for (auto it = in.begin(); it != in.end(); ++it)
@@ -95,7 +95,8 @@ OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent)
m_resourcepacks->startWatching();
}
- connect(m_inst, &OneSixInstance::versionReloaded, this, &OneSixModEditDialog::updateVersionControls);
+ connect(m_inst, &OneSixInstance::versionReloaded, this,
+ &OneSixModEditDialog::updateVersionControls);
}
OneSixModEditDialog::~OneSixModEditDialog()
@@ -108,8 +109,7 @@ OneSixModEditDialog::~OneSixModEditDialog()
void OneSixModEditDialog::updateVersionControls()
{
ui->forgeBtn->setEnabled(true);
- ui->liteloaderBtn->setEnabled(LiteLoaderInstaller().canApply(m_inst));
- ui->mainClassEdit->setText(m_version->mainClass);
+ ui->liteloaderBtn->setEnabled(true);
}
void OneSixModEditDialog::disableVersionControls()
@@ -118,125 +118,86 @@ void OneSixModEditDialog::disableVersionControls()
ui->liteloaderBtn->setEnabled(false);
ui->reloadLibrariesBtn->setEnabled(false);
ui->removeLibraryBtn->setEnabled(false);
- ui->mainClassEdit->setText("");
+}
+
+bool OneSixModEditDialog::reloadInstanceVersion()
+{
+ try
+ {
+ m_inst->reloadVersion();
+ return true;
+ }
+ catch (MMCError &e)
+ {
+ QMessageBox::critical(this, tr("Error"), e.cause());
+ return false;
+ }
+ catch (...)
+ {
+ QMessageBox::critical(
+ this, tr("Error"),
+ tr("Failed to load the version description file for reasons unknown."));
+ return false;
+ }
}
void OneSixModEditDialog::on_reloadLibrariesBtn_clicked()
{
- m_inst->reloadVersion(this);
+ reloadInstanceVersion();
}
void OneSixModEditDialog::on_removeLibraryBtn_clicked()
{
if (ui->libraryTreeView->currentIndex().isValid())
{
+ // FIXME: use actual model, not reloading.
if (!m_version->remove(ui->libraryTreeView->currentIndex().row()))
{
QMessageBox::critical(this, tr("Error"), tr("Couldn't remove file"));
}
else
{
- m_inst->reloadVersion(this);
+ reloadInstanceVersion();
}
}
}
void OneSixModEditDialog::on_resetLibraryOrderBtn_clicked()
{
- QDir(m_inst->instanceRoot()).remove("order.json");
- m_inst->reloadVersion(this);
+ // FIXME: IMPLEMENT LOGIC IN MODEL. SEE LEGACY DIALOG FOR EXAMPLE(S).
}
+
void OneSixModEditDialog::on_moveLibraryUpBtn_clicked()
{
-
- QMap<QString, int> order = getExistingOrder();
- if (order.size() < 2 || ui->libraryTreeView->selectionModel()->selectedIndexes().isEmpty())
- {
- return;
- }
- const int ourRow = ui->libraryTreeView->selectionModel()->selectedIndexes().first().row();
- const QString ourId = m_version->versionFileId(ourRow);
- const int ourOrder = order[ourId];
- if (ourId.isNull() || ourId.startsWith("org.multimc."))
- {
- return;
- }
-
- QMap<int, QString> sortedOrder = invert(order);
-
- QList<int> sortedOrders = sortedOrder.keys();
- const int ourIndex = sortedOrders.indexOf(ourOrder);
- if (ourIndex <= 0)
- {
- return;
- }
- const int ourNewOrder = sortedOrders.at(ourIndex - 1);
- order[ourId] = ourNewOrder;
- order[sortedOrder[sortedOrders[ourIndex - 1]]] = ourOrder;
-
- if (!OneSixVersionBuilder::writeOverrideOrders(order, m_inst))
- {
- QMessageBox::critical(this, tr("Error"), tr("Couldn't save the new order"));
- }
- else
- {
- m_inst->reloadVersion(this);
- ui->libraryTreeView->selectionModel()->select(m_version->index(ourRow - 1), QItemSelectionModel::SelectCurrent);
- }
+ // FIXME: IMPLEMENT LOGIC IN MODEL. SEE LEGACY DIALOG FOR EXAMPLE(S).
}
+
void OneSixModEditDialog::on_moveLibraryDownBtn_clicked()
{
- QMap<QString, int> order = getExistingOrder();
- if (order.size() < 2 || ui->libraryTreeView->selectionModel()->selectedIndexes().isEmpty())
- {
- return;
- }
- const int ourRow = ui->libraryTreeView->selectionModel()->selectedIndexes().first().row();
- const QString ourId = m_version->versionFileId(ourRow);
- const int ourOrder = order[ourId];
- if (ourId.isNull() || ourId.startsWith("org.multimc."))
- {
- return;
- }
-
- QMap<int, QString> sortedOrder = invert(order);
-
- QList<int> sortedOrders = sortedOrder.keys();
- const int ourIndex = sortedOrders.indexOf(ourOrder);
- if ((ourIndex + 1) >= sortedOrders.size())
- {
- return;
- }
- const int ourNewOrder = sortedOrders.at(ourIndex + 1);
- order[ourId] = ourNewOrder;
- order[sortedOrder[sortedOrders[ourIndex + 1]]] = ourOrder;
-
- if (!OneSixVersionBuilder::writeOverrideOrders(order, m_inst))
- {
- QMessageBox::critical(this, tr("Error"), tr("Couldn't save the new order"));
- }
- else
- {
- m_inst->reloadVersion(this);
- ui->libraryTreeView->selectionModel()->select(m_version->index(ourRow + 1), QItemSelectionModel::SelectCurrent);
- }
+ // FIXME: IMPLEMENT LOGIC IN MODEL. SEE LEGACY DIALOG FOR EXAMPLE(S).
}
void OneSixModEditDialog::on_forgeBtn_clicked()
{
+ // FIXME: use actual model, not reloading. Move logic to model.
+
+ // FIXME: model::isCustom();
if (QDir(m_inst->instanceRoot()).exists("custom.json"))
{
- if (QMessageBox::question(this, tr("Revert?"), tr("This action will remove your custom.json. Continue?")) != QMessageBox::Yes)
+ if (QMessageBox::question(this, tr("Revert?"),
+ tr("This action will remove your custom.json. Continue?")) !=
+ QMessageBox::Yes)
{
return;
}
+ // FIXME: model::revertToBase();
QDir(m_inst->instanceRoot()).remove("custom.json");
- m_inst->reloadVersion(this);
+ reloadInstanceVersion();
}
VersionSelectDialog vselect(MMC->forgelist().get(), tr("Select Forge version"), this);
vselect.setFilter(1, m_inst->currentVersionId());
vselect.setEmptyString(tr("No Forge versions are currently available for Minecraft ") +
- m_inst->currentVersionId());
+ m_inst->currentVersionId());
if (vselect.exec() && vselect.selectedVersion())
{
ForgeVersionPtr forgeVersion =
@@ -276,38 +237,45 @@ void OneSixModEditDialog::on_forgeBtn_clicked()
}
}
}
- m_inst->reloadVersion(this);
+ reloadInstanceVersion();
}
void OneSixModEditDialog::on_liteloaderBtn_clicked()
{
+ // FIXME: model...
if (QDir(m_inst->instanceRoot()).exists("custom.json"))
{
- if (QMessageBox::question(this, tr("Revert?"), tr("This action will remove your custom.json. Continue?")) != QMessageBox::Yes)
+ if (QMessageBox::question(this, tr("Revert?"),
+ tr("This action will remove your custom.json. Continue?")) !=
+ QMessageBox::Yes)
{
return;
}
QDir(m_inst->instanceRoot()).remove("custom.json");
- m_inst->reloadVersion(this);
- }
- LiteLoaderInstaller liteloader;
- if (!liteloader.canApply(m_inst))
- {
- QMessageBox::critical(
- this, tr("LiteLoader"),
- tr("There is no information available on how to install LiteLoader "
- "into this version of Minecraft"));
- return;
- }
- if (!liteloader.add(m_inst))
- {
- QMessageBox::critical(this, tr("LiteLoader"),
- tr("For reasons unknown, the LiteLoader installation failed. "
- "Check your MultiMC log files for details."));
+ reloadInstanceVersion();
}
- else
+ VersionSelectDialog vselect(MMC->liteloaderlist().get(), tr("Select LiteLoader version"),
+ this);
+ vselect.setFilter(1, m_inst->currentVersionId());
+ vselect.setEmptyString(tr("No LiteLoader versions are currently available for Minecraft ") +
+ m_inst->currentVersionId());
+ if (vselect.exec() && vselect.selectedVersion())
{
- m_inst->reloadVersion(this);
+ LiteLoaderVersionPtr liteloaderVersion =
+ std::dynamic_pointer_cast<LiteLoaderVersion>(vselect.selectedVersion());
+ if (!liteloaderVersion)
+ return;
+ LiteLoaderInstaller liteloader(liteloaderVersion);
+ if (!liteloader.add(m_inst))
+ {
+ QMessageBox::critical(this, tr("LiteLoader"),
+ tr("For reasons unknown, the LiteLoader installation failed. "
+ "Check your MultiMC log files for details."));
+ }
+ else
+ {
+ reloadInstanceVersion();
+ }
}
}
@@ -343,35 +311,6 @@ bool OneSixModEditDialog::resourcePackListFilter(QKeyEvent *keyEvent)
return QDialog::eventFilter(ui->resPackTreeView, keyEvent);
}
-QMap<QString, int> OneSixModEditDialog::getExistingOrder() const
-{
-
- QMap<QString, int> order;
- // default
- {
- for (OneSixVersion::VersionFile file : m_version->versionFiles)
- {
- if (file.id.startsWith("org.multimc."))
- {
- continue;
- }
- order.insert(file.id, file.order);
- }
- }
- // overriden
- {
- QMap<QString, int> overridenOrder = OneSixVersionBuilder::readOverrideOrders(m_inst);
- for (auto id : order.keys())
- {
- if (overridenOrder.contains(id))
- {
- order[id] = overridenOrder[id];
- }
- }
- }
- return order;
-}
-
bool OneSixModEditDialog::eventFilter(QObject *obj, QEvent *ev)
{
if (ev->type() != QEvent::KeyPress)
@@ -457,7 +396,8 @@ void OneSixModEditDialog::loaderCurrent(QModelIndex current, QModelIndex previou
ui->frame->updateWithMod(m);
}
-void OneSixModEditDialog::versionCurrent(const QModelIndex &current, const QModelIndex &previous)
+void OneSixModEditDialog::versionCurrent(const QModelIndex &current,
+ const QModelIndex &previous)
{
if (!current.isValid())
{
diff --git a/gui/dialogs/OneSixModEditDialog.h b/gui/dialogs/OneSixModEditDialog.h
index f44b336b..e106c6fe 100644
--- a/gui/dialogs/OneSixModEditDialog.h
+++ b/gui/dialogs/OneSixModEditDialog.h
@@ -57,17 +57,17 @@ protected:
bool eventFilter(QObject *obj, QEvent *ev);
bool loaderListFilter(QKeyEvent *ev);
bool resourcePackListFilter(QKeyEvent *ev);
+ /// FIXME: this shouldn't be necessary!
+ bool reloadInstanceVersion();
private:
Ui::OneSixModEditDialog *ui;
- std::shared_ptr<OneSixVersion> m_version;
+ std::shared_ptr<VersionFinal> m_version;
std::shared_ptr<ModList> m_mods;
std::shared_ptr<ModList> m_resourcepacks;
EnabledItemFilter *main_model;
OneSixInstance *m_inst;
- QMap<QString, int> getExistingOrder() const;
-
public
slots:
void loaderCurrent(QModelIndex current, QModelIndex previous);
diff --git a/gui/dialogs/OneSixModEditDialog.ui b/gui/dialogs/OneSixModEditDialog.ui
index eaf8f7fd..b606dcd2 100644
--- a/gui/dialogs/OneSixModEditDialog.ui
+++ b/gui/dialogs/OneSixModEditDialog.ui
@@ -48,24 +48,6 @@
</attribute>
</widget>
</item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_7">
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Main Class:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="mainClassEdit">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
</layout>
</item>
<item>
@@ -109,13 +91,6 @@
</widget>
</item>
<item>
- <widget class="QPushButton" name="resetLibraryOrderBtn">
- <property name="text">
- <string>Reset order</string>
- </property>
- </widget>
- </item>
- <item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -124,6 +99,12 @@
</item>
<item>
<widget class="QPushButton" name="moveLibraryUpBtn">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string>This isn't implemented yet.</string>
+ </property>
<property name="text">
<string>Move up</string>
</property>
@@ -131,12 +112,31 @@
</item>
<item>
<widget class="QPushButton" name="moveLibraryDownBtn">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string>This isn't implemented yet.</string>
+ </property>
<property name="text">
<string>Move down</string>
</property>
</widget>
</item>
<item>
+ <widget class="QPushButton" name="resetLibraryOrderBtn">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string>This isn't implemented yet.</string>
+ </property>
+ <property name="text">
+ <string>Reset order</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
diff --git a/gui/dialogs/SettingsDialog.cpp b/gui/dialogs/SettingsDialog.cpp
index ef363f02..d79bb558 100644
--- a/gui/dialogs/SettingsDialog.cpp
+++ b/gui/dialogs/SettingsDialog.cpp
@@ -29,6 +29,8 @@
#include "logic/updater/UpdateChecker.h"
+#include "logic/tools/BaseProfiler.h"
+
#include <settingsobject.h>
#include <pathutils.h>
#include <QFileDialog>
@@ -46,12 +48,14 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::Se
ui->jsonEditorTextBox->setClearButtonEnabled(true);
#endif
- restoreGeometry(QByteArray::fromBase64(MMC->settings()->get("SettingsGeometry").toByteArray()));
+ restoreGeometry(
+ QByteArray::fromBase64(MMC->settings()->get("SettingsGeometry").toByteArray()));
loadSettings(MMC->settings().get());
updateCheckboxStuff();
- QObject::connect(MMC->updateChecker().get(), &UpdateChecker::channelListLoaded, this, &SettingsDialog::refreshUpdateChannelList);
+ QObject::connect(MMC->updateChecker().get(), &UpdateChecker::channelListLoaded, this,
+ &SettingsDialog::refreshUpdateChannelList);
if (MMC->updateChecker()->hasChannels())
{
@@ -62,6 +66,9 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::Se
MMC->updateChecker()->updateChanList();
}
connect(ui->proxyGroup, SIGNAL(buttonClicked(int)), SLOT(proxyChanged(int)));
+ ui->mceditLink->setOpenExternalLinks(true);
+ ui->jvisualvmLink->setOpenExternalLinks(true);
+ ui->jprofilerLink->setOpenExternalLinks(true);
}
SettingsDialog::~SettingsDialog()
@@ -84,8 +91,10 @@ void SettingsDialog::updateCheckboxStuff()
{
ui->windowWidthSpinBox->setEnabled(!ui->maximizedCheckBox->isChecked());
ui->windowHeightSpinBox->setEnabled(!ui->maximizedCheckBox->isChecked());
- ui->proxyAddrBox->setEnabled(!ui->proxyNoneBtn->isChecked() && !ui->proxyDefaultBtn->isChecked());
- ui->proxyAuthBox->setEnabled(!ui->proxyNoneBtn->isChecked() && !ui->proxyDefaultBtn->isChecked());
+ ui->proxyAddrBox->setEnabled(!ui->proxyNoneBtn->isChecked() &&
+ !ui->proxyDefaultBtn->isChecked());
+ ui->proxyAuthBox->setEnabled(!ui->proxyNoneBtn->isChecked() &&
+ !ui->proxyDefaultBtn->isChecked());
}
void SettingsDialog::on_ftbLauncherBrowseBtn_clicked()
@@ -103,8 +112,8 @@ void SettingsDialog::on_ftbLauncherBrowseBtn_clicked()
void SettingsDialog::on_ftbBrowseBtn_clicked()
{
- QString raw_dir = QFileDialog::getExistingDirectory(this, tr("FTB Directory"),
- ui->ftbBox->text());
+ QString raw_dir =
+ QFileDialog::getExistingDirectory(this, tr("FTB Directory"), ui->ftbBox->text());
QString cooked_dir = NormalizePath(raw_dir);
// do not allow current dir - it's dirty. Do not allow dirs that don't exist
@@ -170,11 +179,11 @@ void SettingsDialog::on_jsonEditorBrowseBtn_clicked()
QString raw_file = QFileDialog::getOpenFileName(
this, tr("JSON Editor"),
ui->jsonEditorTextBox->text().isEmpty()
- #if defined(Q_OS_LINUX)
+#if defined(Q_OS_LINUX)
? QString("/usr/bin")
- #else
+#else
? QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation).first()
- #endif
+#endif
: ui->jsonEditorTextBox->text());
QString cooked_file = NormalizePath(raw_file);
@@ -184,14 +193,14 @@ void SettingsDialog::on_jsonEditorBrowseBtn_clicked()
}
// it has to exist and be an executable
- if (QFileInfo(cooked_file).exists() &&
- QFileInfo(cooked_file).isExecutable())
+ if (QFileInfo(cooked_file).exists() && QFileInfo(cooked_file).isExecutable())
{
ui->jsonEditorTextBox->setText(cooked_file);
}
else
{
- QMessageBox::warning(this, tr("Invalid"), tr("The file chosen does not seem to be an executable"));
+ QMessageBox::warning(this, tr("Invalid"),
+ tr("The file chosen does not seem to be an executable"));
}
}
@@ -223,9 +232,11 @@ void SettingsDialog::proxyChanged(int)
void SettingsDialog::refreshUpdateChannelList()
{
- // Stop listening for selection changes. It's going to change a lot while we update it and we don't need to update the
+ // Stop listening for selection changes. It's going to change a lot while we update it and
+ // we don't need to update the
// description label constantly.
- QObject::disconnect(ui->updateChannelComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateChannelSelectionChanged(int)));
+ QObject::disconnect(ui->updateChannelComboBox, SIGNAL(currentIndexChanged(int)), this,
+ SLOT(updateChannelSelectionChanged(int)));
QList<UpdateChecker::ChannelListEntry> channelList = MMC->updateChecker()->getChannelList();
ui->updateChannelComboBox->clear();
@@ -233,29 +244,34 @@ void SettingsDialog::refreshUpdateChannelList()
for (int i = 0; i < channelList.count(); i++)
{
UpdateChecker::ChannelListEntry entry = channelList.at(i);
-
- // When it comes to selection, we'll rely on the indexes of a channel entry being the same in the
+
+ // When it comes to selection, we'll rely on the indexes of a channel entry being the
+ // same in the
// combo box as it is in the update checker's channel list.
- // This probably isn't very safe, but the channel list doesn't change often enough (or at all) for
+ // This probably isn't very safe, but the channel list doesn't change often enough (or
+ // at all) for
// this to be a big deal. Hope it doesn't break...
ui->updateChannelComboBox->addItem(entry.name);
- // If the update channel we just added was the selected one, set the current index in the combo box to it.
+ // If the update channel we just added was the selected one, set the current index in
+ // the combo box to it.
if (entry.id == m_currentUpdateChannel)
{
QLOG_DEBUG() << "Selected index" << i << "channel id" << m_currentUpdateChannel;
selection = i;
}
}
-
+
ui->updateChannelComboBox->setCurrentIndex(selection);
// Start listening for selection changes again and update the description label.
- QObject::connect(ui->updateChannelComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateChannelSelectionChanged(int)));
+ QObject::connect(ui->updateChannelComboBox, SIGNAL(currentIndexChanged(int)), this,
+ SLOT(updateChannelSelectionChanged(int)));
refreshUpdateChannelDesc();
// Now that we've updated the channel list, we can enable the combo box.
- // It starts off disabled so that if the channel list hasn't been loaded, it will be disabled.
+ // It starts off disabled so that if the channel list hasn't been loaded, it will be
+ // disabled.
ui->updateChannelComboBox->setEnabled(true);
}
@@ -269,7 +285,7 @@ void SettingsDialog::refreshUpdateChannelDesc()
// Get the channel list.
QList<UpdateChecker::ChannelListEntry> channelList = MMC->updateChecker()->getChannelList();
int selectedIndex = ui->updateChannelComboBox->currentIndex();
- if(selectedIndex < 0)
+ if (selectedIndex < 0)
{
return;
}
@@ -289,7 +305,8 @@ void SettingsDialog::refreshUpdateChannelDesc()
void SettingsDialog::applySettings(SettingsObject *s)
{
// Language
- s->set("Language", ui->languageBox->itemData(ui->languageBox->currentIndex()).toLocale().bcp47Name());
+ s->set("Language",
+ ui->languageBox->itemData(ui->languageBox->currentIndex()).toLocale().bcp47Name());
// Updates
s->set("AutoUpdate", ui->autoUpdateCheckBox->isChecked());
@@ -309,7 +326,8 @@ void SettingsDialog::applySettings(SettingsObject *s)
// Editors
QString jsonEditor = ui->jsonEditorTextBox->text();
- if (!jsonEditor.isEmpty() && (!QFileInfo(jsonEditor).exists() || !QFileInfo(jsonEditor).isExecutable()))
+ if (!jsonEditor.isEmpty() &&
+ (!QFileInfo(jsonEditor).exists() || !QFileInfo(jsonEditor).isExecutable()))
{
QString found = QStandardPaths::findExecutable(jsonEditor);
if (!found.isEmpty())
@@ -330,10 +348,14 @@ void SettingsDialog::applySettings(SettingsObject *s)
// Proxy
QString proxyType = "None";
- if (ui->proxyDefaultBtn->isChecked()) proxyType = "Default";
- else if (ui->proxyNoneBtn->isChecked()) proxyType = "None";
- else if (ui->proxySOCKS5Btn->isChecked()) proxyType = "SOCKS5";
- else if (ui->proxyHTTPBtn->isChecked()) proxyType = "HTTP";
+ if (ui->proxyDefaultBtn->isChecked())
+ proxyType = "Default";
+ else if (ui->proxyNoneBtn->isChecked())
+ proxyType = "None";
+ else if (ui->proxySOCKS5Btn->isChecked())
+ proxyType = "SOCKS5";
+ else if (ui->proxyHTTPBtn->isChecked())
+ proxyType = "HTTP";
s->set("ProxyType", proxyType);
s->set("ProxyAddr", ui->proxyAddrEdit->text());
@@ -368,6 +390,11 @@ void SettingsDialog::applySettings(SettingsObject *s)
}
s->set("PostExitCommand", ui->postExitCmdTextBox->text());
+
+ // Profilers
+ s->set("JProfilerPath", ui->jprofilerPathEdit->text());
+ s->set("JVisualVMPath", ui->jvisualvmPathEdit->text());
+ s->set("MCEditPath", ui->mceditPathEdit->text());
}
void SettingsDialog::loadSettings(SettingsObject *s)
@@ -379,11 +406,10 @@ void SettingsDialog::loadSettings(SettingsObject *s)
QDir(MMC->root() + "/translations").entryList(QStringList() << "*.qm", QDir::Files))
{
QLocale locale(lang.section(QRegExp("[_\.]"), 1));
- ui->languageBox->addItem(
- QLocale::languageToString(locale.language()),
- locale);
+ ui->languageBox->addItem(QLocale::languageToString(locale.language()), locale);
}
- ui->languageBox->setCurrentIndex(ui->languageBox->findData(QLocale(s->get("Language").toString())));
+ ui->languageBox->setCurrentIndex(
+ ui->languageBox->findData(QLocale(s->get("Language").toString())));
// Updates
ui->autoUpdateCheckBox->setChecked(s->get("AutoUpdate").toBool());
@@ -430,10 +456,14 @@ void SettingsDialog::loadSettings(SettingsObject *s)
// Proxy
QString proxyType = s->get("ProxyType").toString();
- if (proxyType == "Default") ui->proxyDefaultBtn->setChecked(true);
- else if (proxyType == "None") ui->proxyNoneBtn->setChecked(true);
- else if (proxyType == "SOCKS5") ui->proxySOCKS5Btn->setChecked(true);
- else if (proxyType == "HTTP") ui->proxyHTTPBtn->setChecked(true);
+ if (proxyType == "Default")
+ ui->proxyDefaultBtn->setChecked(true);
+ else if (proxyType == "None")
+ ui->proxyNoneBtn->setChecked(true);
+ else if (proxyType == "SOCKS5")
+ ui->proxySOCKS5Btn->setChecked(true);
+ else if (proxyType == "HTTP")
+ ui->proxyHTTPBtn->setChecked(true);
ui->proxyAddrEdit->setText(s->get("ProxyAddr").toString());
ui->proxyPortEdit->setValue(s->get("ProxyPort").value<qint16>());
@@ -447,6 +477,11 @@ void SettingsDialog::loadSettings(SettingsObject *s)
// Custom Commands
ui->preLaunchCmdTextBox->setText(s->get("PreLaunchCommand").toString());
ui->postExitCmdTextBox->setText(s->get("PostExitCommand").toString());
+
+ // Profilers
+ ui->jprofilerPathEdit->setText(s->get("JProfilerPath").toString());
+ ui->jvisualvmPathEdit->setText(s->get("JVisualVMPath").toString());
+ ui->mceditPathEdit->setText(s->get("MCEditPath").toString());
}
void SettingsDialog::on_javaDetectBtn_clicked()
@@ -503,3 +538,126 @@ void SettingsDialog::checkFinished(JavaCheckResult result)
"or set the path to the java executable."));
}
}
+
+void SettingsDialog::on_jprofilerPathBtn_clicked()
+{
+ QString raw_dir = ui->jprofilerPathEdit->text();
+ QString error;
+ do
+ {
+ raw_dir = QFileDialog::getExistingDirectory(this, tr("JProfiler Directory"), raw_dir);
+ if (raw_dir.isEmpty())
+ {
+ break;
+ }
+ QString cooked_dir = NormalizePath(raw_dir);
+ if (!MMC->profilers()["jprofiler"]->check(cooked_dir, &error))
+ {
+ QMessageBox::critical(this, tr("Error"),
+ tr("Error while checking JProfiler install:\n%1").arg(error));
+ continue;
+ }
+ else
+ {
+ ui->jprofilerPathEdit->setText(cooked_dir);
+ break;
+ }
+ } while (1);
+}
+void SettingsDialog::on_jprofilerCheckBtn_clicked()
+{
+ QString error;
+ if (!MMC->profilers()["jprofiler"]->check(ui->jprofilerPathEdit->text(), &error))
+ {
+ QMessageBox::critical(this, tr("Error"),
+ tr("Error while checking JProfiler install:\n%1").arg(error));
+ }
+ else
+ {
+ QMessageBox::information(this, tr("OK"), tr("JProfiler setup seems to be OK"));
+ }
+}
+
+void SettingsDialog::on_jvisualvmPathBtn_clicked()
+{
+ QString raw_dir = ui->jvisualvmPathEdit->text();
+ QString error;
+ do
+ {
+ raw_dir = QFileDialog::getOpenFileName(this, tr("JVisualVM Executable"), raw_dir);
+ if (raw_dir.isEmpty())
+ {
+ break;
+ }
+ QString cooked_dir = NormalizePath(raw_dir);
+ if (!MMC->profilers()["jvisualvm"]->check(cooked_dir, &error))
+ {
+ QMessageBox::critical(this, tr("Error"),
+ tr("Error while checking JVisualVM install:\n%1").arg(error));
+ continue;
+ }
+ else
+ {
+ ui->jvisualvmPathEdit->setText(cooked_dir);
+ break;
+ }
+ } while (1);
+}
+void SettingsDialog::on_jvisualvmCheckBtn_clicked()
+{
+ QString error;
+ if (!MMC->profilers()["jvisualvm"]->check(ui->jvisualvmPathEdit->text(), &error))
+ {
+ QMessageBox::critical(this, tr("Error"),
+ tr("Error while checking JVisualVM install:\n%1").arg(error));
+ }
+ else
+ {
+ QMessageBox::information(this, tr("OK"), tr("JVisualVM setup seems to be OK"));
+ }
+}
+
+void SettingsDialog::on_mceditPathBtn_clicked()
+{
+ QString raw_dir = ui->mceditPathEdit->text();
+ QString error;
+ do
+ {
+#ifdef Q_OS_OSX
+#warning stuff
+ raw_dir = QFileDialog::getOpenFileName(this, tr("MCEdit Application"), raw_dir);
+#else
+ raw_dir = QFileDialog::getExistingDirectory(this, tr("MCEdit Directory"), raw_dir);
+#endif
+ if (raw_dir.isEmpty())
+ {
+ break;
+ }
+ QString cooked_dir = NormalizePath(raw_dir);
+ if (!MMC->tools()["mcedit"]->check(cooked_dir, &error))
+ {
+ QMessageBox::critical(this, tr("Error"),
+ tr("Error while checking MCEdit install:\n%1").arg(error));
+ continue;
+ }
+ else
+ {
+ ui->mceditPathEdit->setText(cooked_dir);
+ break;
+ }
+ } while (1);
+}
+
+void SettingsDialog::on_mceditCheckBtn_clicked()
+{
+ QString error;
+ if (!MMC->tools()["mcedit"]->check(ui->mceditPathEdit->text(), &error))
+ {
+ QMessageBox::critical(this, tr("Error"),
+ tr("Error while checking MCEdit install:\n%1").arg(error));
+ }
+ else
+ {
+ QMessageBox::information(this, tr("OK"), tr("MCEdit setup seems to be OK"));
+ }
+}
diff --git a/gui/dialogs/SettingsDialog.h b/gui/dialogs/SettingsDialog.h
index d7bbbeb3..d8495fdd 100644
--- a/gui/dialogs/SettingsDialog.h
+++ b/gui/dialogs/SettingsDialog.h
@@ -75,6 +75,13 @@ slots:
void checkFinished(JavaCheckResult result);
+ void on_jprofilerPathBtn_clicked();
+ void on_jprofilerCheckBtn_clicked();
+ void on_jvisualvmPathBtn_clicked();
+ void on_jvisualvmCheckBtn_clicked();
+ void on_mceditPathBtn_clicked();
+ void on_mceditCheckBtn_clicked();
+
/*!
* Updates the list of update channels in the combo box.
*/
diff --git a/gui/dialogs/SettingsDialog.ui b/gui/dialogs/SettingsDialog.ui
index 54e7db7a..e8da8582 100644
--- a/gui/dialogs/SettingsDialog.ui
+++ b/gui/dialogs/SettingsDialog.ui
@@ -863,6 +863,137 @@
</item>
</layout>
</widget>
+ <widget class="QWidget" name="externalToolsTab">
+ <attribute name="title">
+ <string>External Tools</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_13">
+ <item>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="title">
+ <string>JProfiler</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_10">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="QLineEdit" name="jprofilerPathEdit"/>
+ </item>
+ <item>
+ <widget class="QPushButton" name="jprofilerPathBtn">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QPushButton" name="jprofilerCheckBtn">
+ <property name="text">
+ <string>Check</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="jprofilerLink">
+ <property name="text">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;http://www.ej-technologies.com/products/jprofiler/overview.html&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;http://www.ej-technologies.com/products/jprofiler/overview.html&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_3">
+ <property name="title">
+ <string>JVisualVM</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_11">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <item>
+ <widget class="QLineEdit" name="jvisualvmPathEdit"/>
+ </item>
+ <item>
+ <widget class="QPushButton" name="jvisualvmPathBtn">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QPushButton" name="jvisualvmCheckBtn">
+ <property name="text">
+ <string>Check</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="jvisualvmLink">
+ <property name="text">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;http://visualvm.java.net/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;http://visualvm.java.net/&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_4">
+ <property name="title">
+ <string>MCEdit</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_12">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_6">
+ <item>
+ <widget class="QLineEdit" name="mceditPathEdit"/>
+ </item>
+ <item>
+ <widget class="QPushButton" name="mceditPathBtn">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QPushButton" name="mceditCheckBtn">
+ <property name="text">
+ <string>Check</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="mceditLink">
+ <property name="text">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;http://www.mcedit.net/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;http://www.mcedit.net/&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
</widget>
</item>
<item>
@@ -938,7 +1069,7 @@
</connection>
</connections>
<buttongroups>
- <buttongroup name="proxyGroup"/>
<buttongroup name="sortingModeGroup"/>
+ <buttongroup name="proxyGroup"/>
</buttongroups>
</ui>
diff --git a/gui/dialogs/VersionSelectDialog.cpp b/gui/dialogs/VersionSelectDialog.cpp
index 0f379f56..3277fd2f 100644
--- a/gui/dialogs/VersionSelectDialog.cpp
+++ b/gui/dialogs/VersionSelectDialog.cpp
@@ -82,6 +82,7 @@ void VersionSelectDialog::loadList()
Task *loadTask = m_vlist->getLoadTask();
loadTask->setParent(taskDlg);
taskDlg->exec(loadTask);
+ delete taskDlg;
}
BaseVersionPtr VersionSelectDialog::selectedVersion() const