Nicer way of selecting tool folders and executables
This commit is contained in:
parent
e4ecc31e07
commit
dd2d8f48fa
@ -48,12 +48,14 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::Se
|
|||||||
ui->jsonEditorTextBox->setClearButtonEnabled(true);
|
ui->jsonEditorTextBox->setClearButtonEnabled(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
restoreGeometry(QByteArray::fromBase64(MMC->settings()->get("SettingsGeometry").toByteArray()));
|
restoreGeometry(
|
||||||
|
QByteArray::fromBase64(MMC->settings()->get("SettingsGeometry").toByteArray()));
|
||||||
|
|
||||||
loadSettings(MMC->settings().get());
|
loadSettings(MMC->settings().get());
|
||||||
updateCheckboxStuff();
|
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())
|
if (MMC->updateChecker()->hasChannels())
|
||||||
{
|
{
|
||||||
@ -64,6 +66,9 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::Se
|
|||||||
MMC->updateChecker()->updateChanList();
|
MMC->updateChecker()->updateChanList();
|
||||||
}
|
}
|
||||||
connect(ui->proxyGroup, SIGNAL(buttonClicked(int)), SLOT(proxyChanged(int)));
|
connect(ui->proxyGroup, SIGNAL(buttonClicked(int)), SLOT(proxyChanged(int)));
|
||||||
|
ui->mceditLink->setOpenExternalLinks(true);
|
||||||
|
ui->jvisualvmLink->setOpenExternalLinks(true);
|
||||||
|
ui->jprofilerLink->setOpenExternalLinks(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsDialog::~SettingsDialog()
|
SettingsDialog::~SettingsDialog()
|
||||||
@ -86,8 +91,10 @@ 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());
|
||||||
ui->proxyAddrBox->setEnabled(!ui->proxyNoneBtn->isChecked() && !ui->proxyDefaultBtn->isChecked());
|
ui->proxyAddrBox->setEnabled(!ui->proxyNoneBtn->isChecked() &&
|
||||||
ui->proxyAuthBox->setEnabled(!ui->proxyNoneBtn->isChecked() && !ui->proxyDefaultBtn->isChecked());
|
!ui->proxyDefaultBtn->isChecked());
|
||||||
|
ui->proxyAuthBox->setEnabled(!ui->proxyNoneBtn->isChecked() &&
|
||||||
|
!ui->proxyDefaultBtn->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::on_ftbLauncherBrowseBtn_clicked()
|
void SettingsDialog::on_ftbLauncherBrowseBtn_clicked()
|
||||||
@ -105,8 +112,8 @@ void SettingsDialog::on_ftbLauncherBrowseBtn_clicked()
|
|||||||
|
|
||||||
void SettingsDialog::on_ftbBrowseBtn_clicked()
|
void SettingsDialog::on_ftbBrowseBtn_clicked()
|
||||||
{
|
{
|
||||||
QString raw_dir = QFileDialog::getExistingDirectory(this, tr("FTB Directory"),
|
QString raw_dir =
|
||||||
ui->ftbBox->text());
|
QFileDialog::getExistingDirectory(this, tr("FTB Directory"), ui->ftbBox->text());
|
||||||
QString cooked_dir = NormalizePath(raw_dir);
|
QString cooked_dir = NormalizePath(raw_dir);
|
||||||
|
|
||||||
// do not allow current dir - it's dirty. Do not allow dirs that don't exist
|
// do not allow current dir - it's dirty. Do not allow dirs that don't exist
|
||||||
@ -186,14 +193,14 @@ void SettingsDialog::on_jsonEditorBrowseBtn_clicked()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// it has to exist and be an executable
|
// it has to exist and be an executable
|
||||||
if (QFileInfo(cooked_file).exists() &&
|
if (QFileInfo(cooked_file).exists() && QFileInfo(cooked_file).isExecutable())
|
||||||
QFileInfo(cooked_file).isExecutable())
|
|
||||||
{
|
{
|
||||||
ui->jsonEditorTextBox->setText(cooked_file);
|
ui->jsonEditorTextBox->setText(cooked_file);
|
||||||
}
|
}
|
||||||
else
|
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"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,9 +232,11 @@ void SettingsDialog::proxyChanged(int)
|
|||||||
|
|
||||||
void SettingsDialog::refreshUpdateChannelList()
|
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.
|
// 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();
|
QList<UpdateChecker::ChannelListEntry> channelList = MMC->updateChecker()->getChannelList();
|
||||||
ui->updateChannelComboBox->clear();
|
ui->updateChannelComboBox->clear();
|
||||||
@ -236,13 +245,16 @@ void SettingsDialog::refreshUpdateChannelList()
|
|||||||
{
|
{
|
||||||
UpdateChecker::ChannelListEntry entry = channelList.at(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.
|
// 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...
|
// this to be a big deal. Hope it doesn't break...
|
||||||
ui->updateChannelComboBox->addItem(entry.name);
|
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)
|
if (entry.id == m_currentUpdateChannel)
|
||||||
{
|
{
|
||||||
QLOG_DEBUG() << "Selected index" << i << "channel id" << m_currentUpdateChannel;
|
QLOG_DEBUG() << "Selected index" << i << "channel id" << m_currentUpdateChannel;
|
||||||
@ -253,11 +265,13 @@ void SettingsDialog::refreshUpdateChannelList()
|
|||||||
ui->updateChannelComboBox->setCurrentIndex(selection);
|
ui->updateChannelComboBox->setCurrentIndex(selection);
|
||||||
|
|
||||||
// Start listening for selection changes again and update the description label.
|
// 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();
|
refreshUpdateChannelDesc();
|
||||||
|
|
||||||
// Now that we've updated the channel list, we can enable the combo box.
|
// 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);
|
ui->updateChannelComboBox->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,7 +305,8 @@ void SettingsDialog::refreshUpdateChannelDesc()
|
|||||||
void SettingsDialog::applySettings(SettingsObject *s)
|
void SettingsDialog::applySettings(SettingsObject *s)
|
||||||
{
|
{
|
||||||
// Language
|
// Language
|
||||||
s->set("Language", ui->languageBox->itemData(ui->languageBox->currentIndex()).toLocale().bcp47Name());
|
s->set("Language",
|
||||||
|
ui->languageBox->itemData(ui->languageBox->currentIndex()).toLocale().bcp47Name());
|
||||||
|
|
||||||
// Updates
|
// Updates
|
||||||
s->set("AutoUpdate", ui->autoUpdateCheckBox->isChecked());
|
s->set("AutoUpdate", ui->autoUpdateCheckBox->isChecked());
|
||||||
@ -311,7 +326,8 @@ void SettingsDialog::applySettings(SettingsObject *s)
|
|||||||
|
|
||||||
// Editors
|
// Editors
|
||||||
QString jsonEditor = ui->jsonEditorTextBox->text();
|
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);
|
QString found = QStandardPaths::findExecutable(jsonEditor);
|
||||||
if (!found.isEmpty())
|
if (!found.isEmpty())
|
||||||
@ -332,10 +348,14 @@ void SettingsDialog::applySettings(SettingsObject *s)
|
|||||||
|
|
||||||
// Proxy
|
// Proxy
|
||||||
QString proxyType = "None";
|
QString proxyType = "None";
|
||||||
if (ui->proxyDefaultBtn->isChecked()) proxyType = "Default";
|
if (ui->proxyDefaultBtn->isChecked())
|
||||||
else if (ui->proxyNoneBtn->isChecked()) proxyType = "None";
|
proxyType = "Default";
|
||||||
else if (ui->proxySOCKS5Btn->isChecked()) proxyType = "SOCKS5";
|
else if (ui->proxyNoneBtn->isChecked())
|
||||||
else if (ui->proxyHTTPBtn->isChecked()) proxyType = "HTTP";
|
proxyType = "None";
|
||||||
|
else if (ui->proxySOCKS5Btn->isChecked())
|
||||||
|
proxyType = "SOCKS5";
|
||||||
|
else if (ui->proxyHTTPBtn->isChecked())
|
||||||
|
proxyType = "HTTP";
|
||||||
|
|
||||||
s->set("ProxyType", proxyType);
|
s->set("ProxyType", proxyType);
|
||||||
s->set("ProxyAddr", ui->proxyAddrEdit->text());
|
s->set("ProxyAddr", ui->proxyAddrEdit->text());
|
||||||
@ -386,11 +406,10 @@ void SettingsDialog::loadSettings(SettingsObject *s)
|
|||||||
QDir(MMC->root() + "/translations").entryList(QStringList() << "*.qm", QDir::Files))
|
QDir(MMC->root() + "/translations").entryList(QStringList() << "*.qm", QDir::Files))
|
||||||
{
|
{
|
||||||
QLocale locale(lang.section(QRegExp("[_\.]"), 1));
|
QLocale locale(lang.section(QRegExp("[_\.]"), 1));
|
||||||
ui->languageBox->addItem(
|
ui->languageBox->addItem(QLocale::languageToString(locale.language()), locale);
|
||||||
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
|
// Updates
|
||||||
ui->autoUpdateCheckBox->setChecked(s->get("AutoUpdate").toBool());
|
ui->autoUpdateCheckBox->setChecked(s->get("AutoUpdate").toBool());
|
||||||
@ -437,10 +456,14 @@ void SettingsDialog::loadSettings(SettingsObject *s)
|
|||||||
|
|
||||||
// Proxy
|
// Proxy
|
||||||
QString proxyType = s->get("ProxyType").toString();
|
QString proxyType = s->get("ProxyType").toString();
|
||||||
if (proxyType == "Default") ui->proxyDefaultBtn->setChecked(true);
|
if (proxyType == "Default")
|
||||||
else if (proxyType == "None") ui->proxyNoneBtn->setChecked(true);
|
ui->proxyDefaultBtn->setChecked(true);
|
||||||
else if (proxyType == "SOCKS5") ui->proxySOCKS5Btn->setChecked(true);
|
else if (proxyType == "None")
|
||||||
else if (proxyType == "HTTP") ui->proxyHTTPBtn->setChecked(true);
|
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->proxyAddrEdit->setText(s->get("ProxyAddr").toString());
|
||||||
ui->proxyPortEdit->setValue(s->get("ProxyPort").value<qint16>());
|
ui->proxyPortEdit->setValue(s->get("ProxyPort").value<qint16>());
|
||||||
@ -518,19 +541,28 @@ void SettingsDialog::checkFinished(JavaCheckResult result)
|
|||||||
|
|
||||||
void SettingsDialog::on_jprofilerPathBtn_clicked()
|
void SettingsDialog::on_jprofilerPathBtn_clicked()
|
||||||
{
|
{
|
||||||
QString raw_dir = QFileDialog::getExistingDirectory(this, tr("JProfiler Directory"),
|
QString raw_dir = ui->jprofilerPathEdit->text();
|
||||||
ui->jprofilerPathEdit->text());
|
QString error;
|
||||||
QString cooked_dir = NormalizePath(raw_dir);
|
do
|
||||||
|
|
||||||
// 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->jprofilerPathEdit->setText(cooked_dir);
|
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
|
else
|
||||||
{
|
{
|
||||||
// FIXME: see below...
|
ui->jprofilerPathEdit->setText(cooked_dir);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
} while (1);
|
||||||
}
|
}
|
||||||
void SettingsDialog::on_jprofilerCheckBtn_clicked()
|
void SettingsDialog::on_jprofilerCheckBtn_clicked()
|
||||||
{
|
{
|
||||||
@ -548,21 +580,28 @@ void SettingsDialog::on_jprofilerCheckBtn_clicked()
|
|||||||
|
|
||||||
void SettingsDialog::on_jvisualvmPathBtn_clicked()
|
void SettingsDialog::on_jvisualvmPathBtn_clicked()
|
||||||
{
|
{
|
||||||
QString raw_dir = QFileDialog::getOpenFileName(this, tr("JVisualVM Executable"),
|
QString raw_dir = ui->jvisualvmPathEdit->text();
|
||||||
ui->jvisualvmPathEdit->text());
|
QString error;
|
||||||
QString cooked_path = NormalizePath(raw_dir);
|
do
|
||||||
QFileInfo finfo(cooked_path);
|
|
||||||
|
|
||||||
// do not allow current dir - it's dirty. Do not allow dirs that don't exist
|
|
||||||
if (!cooked_path.isEmpty() && finfo.isExecutable() && finfo.isFile())
|
|
||||||
{
|
{
|
||||||
ui->jvisualvmPathEdit->setText(cooked_path);
|
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 MCEdit install:\n%1").arg(error));
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// FIXME: report error here, or run the checker instead of that condition above.
|
ui->jvisualvmPathEdit->setText(cooked_dir);
|
||||||
// ideally unify all the sanity checks and put them into the relevant classes
|
break;
|
||||||
}
|
}
|
||||||
|
} while (1);
|
||||||
}
|
}
|
||||||
void SettingsDialog::on_jvisualvmCheckBtn_clicked()
|
void SettingsDialog::on_jvisualvmCheckBtn_clicked()
|
||||||
{
|
{
|
||||||
@ -580,19 +619,30 @@ void SettingsDialog::on_jvisualvmCheckBtn_clicked()
|
|||||||
|
|
||||||
void SettingsDialog::on_mceditPathBtn_clicked()
|
void SettingsDialog::on_mceditPathBtn_clicked()
|
||||||
{
|
{
|
||||||
QString raw_dir = QFileDialog::getExistingDirectory(this, tr("MCEdit Path"),
|
QString raw_dir = ui->mceditPathEdit->text();
|
||||||
ui->mceditPathEdit->text());
|
QString error;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
raw_dir = QFileDialog::getExistingDirectory(this, tr("MCEdit Path"), raw_dir);
|
||||||
|
if (raw_dir.isEmpty())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
QString cooked_dir = NormalizePath(raw_dir);
|
QString cooked_dir = NormalizePath(raw_dir);
|
||||||
|
if (!MMC->tools()["mcedit"]->check(cooked_dir, &error))
|
||||||
// do not allow current dir - it's dirty. Do not allow dirs that don't exist
|
{
|
||||||
if (!cooked_dir.isEmpty() && QDir(cooked_dir).exists())
|
QMessageBox::critical(this, tr("Error"),
|
||||||
|
tr("Error while checking MCEdit install:\n%1").arg(error));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
ui->mceditPathEdit->setText(cooked_dir);
|
ui->mceditPathEdit->setText(cooked_dir);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
{
|
} while (1);
|
||||||
// FIXME: as above.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::on_mceditCheckBtn_clicked()
|
void SettingsDialog::on_mceditCheckBtn_clicked()
|
||||||
{
|
{
|
||||||
QString error;
|
QString error;
|
||||||
|
@ -896,7 +896,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_6">
|
<widget class="QLabel" name="jprofilerLink">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><html><head/><body><p><a href="http://www.ej-technologies.com/products/jprofiler/overview.html"><span style=" text-decoration: underline; color:#0000ff;">http://www.ej-technologies.com/products/jprofiler/overview.html</span></a></p></body></html></string>
|
<string><html><head/><body><p><a href="http://www.ej-technologies.com/products/jprofiler/overview.html"><span style=" text-decoration: underline; color:#0000ff;">http://www.ej-technologies.com/products/jprofiler/overview.html</span></a></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
@ -933,7 +933,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_5">
|
<widget class="QLabel" name="jvisualvmLink">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><html><head/><body><p><a href="http://visualvm.java.net/"><span style=" text-decoration: underline; color:#0000ff;">http://visualvm.java.net/</span></a></p></body></html></string>
|
<string><html><head/><body><p><a href="http://visualvm.java.net/"><span style=" text-decoration: underline; color:#0000ff;">http://visualvm.java.net/</span></a></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
@ -970,7 +970,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="mceditLink">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><html><head/><body><p><a href="http://www.mcedit.net/"><span style=" text-decoration: underline; color:#0000ff;">http://www.mcedit.net/</span></a></p></body></html></string>
|
<string><html><head/><body><p><a href="http://www.mcedit.net/"><span style=" text-decoration: underline; color:#0000ff;">http://www.mcedit.net/</span></a></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
|
Loading…
Reference in New Issue
Block a user