GH-2050 fix cancel button in file browse dialogs filling text fields
This commit is contained in:
@ -212,13 +212,13 @@ void InstanceSettingsPage::on_javaDetectBtn_clicked()
|
||||
void InstanceSettingsPage::on_javaBrowseBtn_clicked()
|
||||
{
|
||||
QString raw_path = QFileDialog::getOpenFileName(this, tr("Find Java executable"));
|
||||
QString cooked_path = FS::NormalizePath(raw_path);
|
||||
|
||||
// do not allow current dir - it's dirty. Do not allow dirs that don't exist
|
||||
if(cooked_path.isEmpty())
|
||||
if(raw_path.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
QString cooked_path = FS::NormalizePath(raw_path);
|
||||
|
||||
QFileInfo javaInfo(cooked_path);;
|
||||
if(!javaInfo.exists() || !javaInfo.isExecutable())
|
||||
|
@ -206,12 +206,12 @@ void ExternalToolsPage::on_jsonEditorBrowseBtn_clicked()
|
||||
? QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation).first()
|
||||
#endif
|
||||
: ui->jsonEditorTextBox->text());
|
||||
QString cooked_file = FS::NormalizePath(raw_file);
|
||||
|
||||
if (cooked_file.isEmpty())
|
||||
if (raw_file.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
QString cooked_file = FS::NormalizePath(raw_file);
|
||||
|
||||
// it has to exist and be an executable
|
||||
if (QFileInfo(cooked_file).exists() && QFileInfo(cooked_file).isExecutable())
|
||||
|
@ -131,14 +131,14 @@ void JavaPage::on_javaDetectBtn_clicked()
|
||||
void JavaPage::on_javaBrowseBtn_clicked()
|
||||
{
|
||||
QString raw_path = QFileDialog::getOpenFileName(this, tr("Find Java executable"));
|
||||
QString cooked_path = FS::NormalizePath(raw_path);
|
||||
|
||||
// do not allow current dir - it's dirty. Do not allow dirs that don't exist
|
||||
if(cooked_path.isEmpty())
|
||||
if(raw_path.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QString cooked_path = FS::NormalizePath(raw_path);
|
||||
QFileInfo javaInfo(cooked_path);;
|
||||
if(!javaInfo.exists() || !javaInfo.isExecutable())
|
||||
{
|
||||
|
@ -94,13 +94,12 @@ bool MultiMCPage::apply()
|
||||
|
||||
void MultiMCPage::on_instDirBrowseBtn_clicked()
|
||||
{
|
||||
QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Instance Folder"),
|
||||
ui->instDirTextBox->text());
|
||||
QString cooked_dir = FS::NormalizePath(raw_dir);
|
||||
QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Instance Folder"), ui->instDirTextBox->text());
|
||||
|
||||
// do not allow current dir - it's dirty. Do not allow dirs that don't exist
|
||||
if (!cooked_dir.isEmpty() && QDir(cooked_dir).exists())
|
||||
if (!raw_dir.isEmpty() && QDir(raw_dir).exists())
|
||||
{
|
||||
QString cooked_dir = FS::NormalizePath(raw_dir);
|
||||
if (FS::checkProblemticPathJava(QDir(cooked_dir)))
|
||||
{
|
||||
QMessageBox warning;
|
||||
@ -127,25 +126,23 @@ void MultiMCPage::on_instDirBrowseBtn_clicked()
|
||||
|
||||
void MultiMCPage::on_iconsDirBrowseBtn_clicked()
|
||||
{
|
||||
QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Icons Folder"),
|
||||
ui->iconsDirTextBox->text());
|
||||
QString cooked_dir = FS::NormalizePath(raw_dir);
|
||||
QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Icons Folder"), ui->iconsDirTextBox->text());
|
||||
|
||||
// do not allow current dir - it's dirty. Do not allow dirs that don't exist
|
||||
if (!cooked_dir.isEmpty() && QDir(cooked_dir).exists())
|
||||
if (!raw_dir.isEmpty() && QDir(raw_dir).exists())
|
||||
{
|
||||
QString cooked_dir = FS::NormalizePath(raw_dir);
|
||||
ui->iconsDirTextBox->setText(cooked_dir);
|
||||
}
|
||||
}
|
||||
void MultiMCPage::on_modsDirBrowseBtn_clicked()
|
||||
{
|
||||
QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Mods Folder"),
|
||||
ui->modsDirTextBox->text());
|
||||
QString cooked_dir = FS::NormalizePath(raw_dir);
|
||||
QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Mods Folder"), ui->modsDirTextBox->text());
|
||||
|
||||
// do not allow current dir - it's dirty. Do not allow dirs that don't exist
|
||||
if (!cooked_dir.isEmpty() && QDir(cooked_dir).exists())
|
||||
if (!raw_dir.isEmpty() && QDir(raw_dir).exists())
|
||||
{
|
||||
QString cooked_dir = FS::NormalizePath(raw_dir);
|
||||
ui->modsDirTextBox->setText(cooked_dir);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user