improve file dialog experience

This commit is contained in:
Syping 2023-05-13 01:17:46 +02:00
parent 09d79228a0
commit 40675f605d
4 changed files with 14 additions and 13 deletions

View file

@ -55,10 +55,10 @@ QString AppEnv::getGameFolder(bool *ok)
{
QDir dir;
QString GTAV_FOLDER = QString::fromUtf8(qgetenv("GTAV_FOLDER"));
if (GTAV_FOLDER != "") {
if (!GTAV_FOLDER.isEmpty()) {
dir.setPath(GTAV_FOLDER);
if (dir.exists()) {
if (ok != NULL)
if (ok)
*ok = true;
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return dir.absolutePath();
@ -77,7 +77,7 @@ QString AppEnv::getGameFolder(bool *ok)
if (forceDir) {
dir.setPath(GTAV_returnFolder);
if (dir.exists()) {
if (ok != 0)
if (ok)
*ok = true;
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return dir.absolutePath();
@ -86,7 +86,7 @@ QString AppEnv::getGameFolder(bool *ok)
dir.setPath(GTAV_defaultFolder);
if (dir.exists()) {
if (ok != 0)
if (ok)
*ok = true;
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return dir.absolutePath();
@ -95,14 +95,14 @@ QString AppEnv::getGameFolder(bool *ok)
if (!forceDir) {
dir.setPath(GTAV_returnFolder);
if (dir.exists()) {
if (ok != 0)
if (ok)
*ok = true;
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return dir.absolutePath();
}
}
if (ok != 0)
if (ok)
*ok = false;
return QString();
}

View file

@ -694,7 +694,7 @@ void OptionsDialog::setupSnapmaticPictureViewer()
void OptionsDialog::on_cmdExploreFolder_clicked()
{
const QString GTAV_Folder = QFileDialog::getExistingDirectory(this, UserInterface::tr("Select GTA V Folder..."), StandardPaths::documentsLocation(), QFileDialog::ShowDirsOnly);
if (QDir(GTAV_Folder).exists()) {
if (!GTAV_Folder.isEmpty() && QDir(GTAV_Folder).exists()) {
ui->txtFolder->setText(GTAV_Folder);
}
}

View file

@ -1302,8 +1302,8 @@ void ProfileInterface::exportSelected()
settings.beginGroup("FileDialogs");
//bool dontUseNativeDialog = settings.value("DontUseNativeDialog", false).toBool();
settings.beginGroup("ExportDirectory");
QString exportDirectory = QFileDialog::getExistingDirectory(this, tr("Export selected..."), settings.value(profileName, profileFolder).toString());
if (exportDirectory != "") {
const QString exportDirectory = QFileDialog::getExistingDirectory(this, tr("Export selected..."), settings.value(profileName, profileFolder).toString());
if (!exportDirectory.isEmpty()) {
settings.setValue(profileName, exportDirectory);
for (const QString &widgetStr : qAsConst(widgets)) {
ProfileWidget *widget = widgets.key(widgetStr, nullptr);

View file

@ -321,8 +321,9 @@ void UserInterface::setupDirEnv(bool showFolderDialog)
QDir::setCurrent(GTAV_Folder);
}
else if (showFolderDialog) {
GTAV_Folder = QFileDialog::getExistingDirectory(this, tr("Select GTA V Folder..."), StandardPaths::documentsLocation(), QFileDialog::ShowDirsOnly);
if (QDir(GTAV_Folder).exists()) {
const QString GTAV_Folder_Temp = QFileDialog::getExistingDirectory(this, tr("Select GTA V Folder..."), StandardPaths::documentsLocation(), QFileDialog::ShowDirsOnly);
if (!GTAV_Folder_Temp.isEmpty() && QDir(GTAV_Folder_Temp).exists()) {
GTAV_Folder = GTAV_Folder_Temp;
folderExists = true;
QDir::setCurrent(GTAV_Folder);
AppEnv::setGameFolder(GTAV_Folder);
@ -809,8 +810,8 @@ void UserInterface::updateCacheId(uint cacheId)
void UserInterface::on_actionSelect_GTA_Folder_triggered()
{
QString GTAV_Folder_Temp = QFileDialog::getExistingDirectory(this, tr("Select GTA V Folder..."), StandardPaths::documentsLocation(), QFileDialog::ShowDirsOnly);
if (QDir(GTAV_Folder_Temp).exists()) {
const QString GTAV_Folder_Temp = QFileDialog::getExistingDirectory(this, tr("Select GTA V Folder..."), StandardPaths::documentsLocation(), QFileDialog::ShowDirsOnly);
if (!GTAV_Folder_Temp.isEmpty() && QDir(GTAV_Folder_Temp).exists()) {
if (profileOpen) {
closeProfile_p();
}