GH-2050 fix cancel button in file browse dialogs filling text fields
This commit is contained in:
parent
95e6f37d39
commit
4bae6fe491
@ -388,7 +388,7 @@ bool ExportInstanceDialog::doExport()
|
|||||||
const QString output = QFileDialog::getSaveFileName(
|
const QString output = QFileDialog::getSaveFileName(
|
||||||
this, tr("Export %1").arg(m_instance->name()),
|
this, tr("Export %1").arg(m_instance->name()),
|
||||||
FS::PathCombine(QDir::homePath(), name + ".zip"), "Zip (*.zip)", nullptr, QFileDialog::DontConfirmOverwrite);
|
FS::PathCombine(QDir::homePath(), name + ".zip"), "Zip (*.zip)", nullptr, QFileDialog::DontConfirmOverwrite);
|
||||||
if (output.isNull())
|
if (output.isEmpty())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -54,11 +54,11 @@ void SkinUploadDialog::on_buttonBox_accepted()
|
|||||||
void SkinUploadDialog::on_skinBrowseBtn_clicked()
|
void SkinUploadDialog::on_skinBrowseBtn_clicked()
|
||||||
{
|
{
|
||||||
QString raw_path = QFileDialog::getOpenFileName(this, tr("Select Skin Texture"), QString(), "*.png");
|
QString raw_path = QFileDialog::getOpenFileName(this, tr("Select Skin Texture"), QString(), "*.png");
|
||||||
QString cooked_path = FS::NormalizePath(raw_path);
|
if (raw_path.isEmpty() || !QFileInfo::exists(raw_path))
|
||||||
if (cooked_path.isEmpty() || !QFileInfo::exists(cooked_path))
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
QString cooked_path = FS::NormalizePath(raw_path);
|
||||||
ui->skinPathTextBox->setText(cooked_path);
|
ui->skinPathTextBox->setText(cooked_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,13 +212,13 @@ void InstanceSettingsPage::on_javaDetectBtn_clicked()
|
|||||||
void InstanceSettingsPage::on_javaBrowseBtn_clicked()
|
void InstanceSettingsPage::on_javaBrowseBtn_clicked()
|
||||||
{
|
{
|
||||||
QString raw_path = QFileDialog::getOpenFileName(this, tr("Find Java executable"));
|
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
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
|
QString cooked_path = FS::NormalizePath(raw_path);
|
||||||
|
|
||||||
QFileInfo javaInfo(cooked_path);;
|
QFileInfo javaInfo(cooked_path);;
|
||||||
if(!javaInfo.exists() || !javaInfo.isExecutable())
|
if(!javaInfo.exists() || !javaInfo.isExecutable())
|
||||||
|
@ -206,12 +206,12 @@ void ExternalToolsPage::on_jsonEditorBrowseBtn_clicked()
|
|||||||
? QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation).first()
|
? QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation).first()
|
||||||
#endif
|
#endif
|
||||||
: ui->jsonEditorTextBox->text());
|
: ui->jsonEditorTextBox->text());
|
||||||
QString cooked_file = FS::NormalizePath(raw_file);
|
|
||||||
|
|
||||||
if (cooked_file.isEmpty())
|
if (raw_file.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
QString cooked_file = FS::NormalizePath(raw_file);
|
||||||
|
|
||||||
// it has to exist and be an executable
|
// 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())
|
||||||
|
@ -131,14 +131,14 @@ void JavaPage::on_javaDetectBtn_clicked()
|
|||||||
void JavaPage::on_javaBrowseBtn_clicked()
|
void JavaPage::on_javaBrowseBtn_clicked()
|
||||||
{
|
{
|
||||||
QString raw_path = QFileDialog::getOpenFileName(this, tr("Find Java executable"));
|
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
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString cooked_path = FS::NormalizePath(raw_path);
|
||||||
QFileInfo javaInfo(cooked_path);;
|
QFileInfo javaInfo(cooked_path);;
|
||||||
if(!javaInfo.exists() || !javaInfo.isExecutable())
|
if(!javaInfo.exists() || !javaInfo.isExecutable())
|
||||||
{
|
{
|
||||||
|
@ -94,13 +94,12 @@ bool MultiMCPage::apply()
|
|||||||
|
|
||||||
void MultiMCPage::on_instDirBrowseBtn_clicked()
|
void MultiMCPage::on_instDirBrowseBtn_clicked()
|
||||||
{
|
{
|
||||||
QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Instance Folder"),
|
QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Instance Folder"), ui->instDirTextBox->text());
|
||||||
ui->instDirTextBox->text());
|
|
||||||
QString cooked_dir = FS::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
|
||||||
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)))
|
if (FS::checkProblemticPathJava(QDir(cooked_dir)))
|
||||||
{
|
{
|
||||||
QMessageBox warning;
|
QMessageBox warning;
|
||||||
@ -127,25 +126,23 @@ void MultiMCPage::on_instDirBrowseBtn_clicked()
|
|||||||
|
|
||||||
void MultiMCPage::on_iconsDirBrowseBtn_clicked()
|
void MultiMCPage::on_iconsDirBrowseBtn_clicked()
|
||||||
{
|
{
|
||||||
QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Icons Folder"),
|
QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Icons Folder"), ui->iconsDirTextBox->text());
|
||||||
ui->iconsDirTextBox->text());
|
|
||||||
QString cooked_dir = FS::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
|
||||||
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);
|
ui->iconsDirTextBox->setText(cooked_dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void MultiMCPage::on_modsDirBrowseBtn_clicked()
|
void MultiMCPage::on_modsDirBrowseBtn_clicked()
|
||||||
{
|
{
|
||||||
QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Mods Folder"),
|
QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Mods Folder"), ui->modsDirTextBox->text());
|
||||||
ui->modsDirTextBox->text());
|
|
||||||
QString cooked_dir = FS::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
|
||||||
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);
|
ui->modsDirTextBox->setText(cooked_dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,7 +263,7 @@ void JavaWizardPage::on_javaBrowseBtn_clicked()
|
|||||||
filter = "Java (java)";
|
filter = "Java (java)";
|
||||||
#endif
|
#endif
|
||||||
QString raw_path = QFileDialog::getOpenFileName(this, tr("Find Java executable"), QString(), filter);
|
QString raw_path = QFileDialog::getOpenFileName(this, tr("Find Java executable"), QString(), filter);
|
||||||
if(raw_path.isNull())
|
if(raw_path.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user