1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-06 20:15:34 +00:00

Launcher: Improve directory appending UX and heuristics (bug #7502)

- Recognize more asset directories and omwgame files
- Always let the user append the selected directory
- Automatically pick the user-selected directory if it's the only valid directory
- Add a caption to directory selection dialog, properly handle cancellation
This commit is contained in:
Alexei Kotov 2023-10-12 01:12:50 +03:00
parent a08ca11c34
commit f68bd3ba97
3 changed files with 50 additions and 27 deletions

View file

@ -70,6 +70,7 @@
Bug #7450: Evading obstacles does not work for actors missing certain animations Bug #7450: Evading obstacles does not work for actors missing certain animations
Bug #7459: Icons get stacked on the cursor when picking up multiple items simultaneously Bug #7459: Icons get stacked on the cursor when picking up multiple items simultaneously
Bug #7472: Crash when enchanting last projectiles Bug #7472: Crash when enchanting last projectiles
Bug #7502: Data directories dialog (0.48.0) forces adding subdirectory instead of intended directory
Bug #7505: Distant terrain does not support sample size greater than cell size Bug #7505: Distant terrain does not support sample size greater than cell size
Bug #7553: Faction reaction loading is incorrect Bug #7553: Faction reaction loading is incorrect
Bug #7557: Terrain::ChunkManager::createChunk is called twice for the same position, lod on initial loading Bug #7557: Terrain::ChunkManager::createChunk is called twice for the same position, lod on initial loading

View file

@ -40,8 +40,35 @@ namespace
{ {
void contentSubdirs(const QString& path, QStringList& dirs) void contentSubdirs(const QString& path, QStringList& dirs)
{ {
QStringList fileFilter{ "*.esm", "*.esp", "*.omwaddon", "*.bsa", "*.ba2", "*.omwscripts" }; static const QStringList fileFilter{
QStringList dirFilter{ "bookart", "icons", "meshes", "music", "sound", "textures" }; "*.esm",
"*.esp",
"*.bsa",
"*.ba2",
"*.omwgame",
"*.omwaddon",
"*.omwscripts",
};
static const QStringList dirFilter{
"animations",
"bookart",
"fonts",
"icons",
"interface",
"l10n",
"meshes",
"music",
"mygui",
"scripts",
"shaders",
"sound",
"splash",
"strings",
"textures",
"trees",
"video",
};
QDir currentDir(path); QDir currentDir(path);
if (!currentDir.entryInfoList(fileFilter, QDir::Files).empty() if (!currentDir.entryInfoList(fileFilter, QDir::Files).empty()
@ -587,18 +614,6 @@ void Launcher::DataFilesPage::updateCloneProfileOkButton(const QString& text)
mCloneProfileDialog->setOkButtonEnabled(!text.isEmpty() && ui.profilesComboBox->findText(text) == -1); mCloneProfileDialog->setOkButtonEnabled(!text.isEmpty() && ui.profilesComboBox->findText(text) == -1);
} }
QString Launcher::DataFilesPage::selectDirectory()
{
QFileDialog fileDialog(this);
fileDialog.setFileMode(QFileDialog::Directory);
fileDialog.setOptions(QFileDialog::Option::ShowDirsOnly | QFileDialog::Option::ReadOnly);
if (fileDialog.exec() == QDialog::Rejected)
return {};
return QDir(fileDialog.selectedFiles()[0]).canonicalPath();
}
void Launcher::DataFilesPage::addSubdirectories(bool append) void Launcher::DataFilesPage::addSubdirectories(bool append)
{ {
int selectedRow = append ? ui.directoryListWidget->count() : ui.directoryListWidget->currentRow(); int selectedRow = append ? ui.directoryListWidget->count() : ui.directoryListWidget->currentRow();
@ -606,22 +621,30 @@ void Launcher::DataFilesPage::addSubdirectories(bool append)
if (selectedRow == -1) if (selectedRow == -1)
return; return;
const auto rootDir = selectDirectory(); QString rootPath = QFileDialog::getExistingDirectory(
if (rootDir.isEmpty()) this, tr("Select Directory"), QDir::homePath(), QFileDialog::ShowDirsOnly | QFileDialog::Option::ReadOnly);
if (rootPath.isEmpty())
return; return;
QStringList subdirs; const QDir rootDir(rootPath);
contentSubdirs(rootDir, subdirs); rootPath = rootDir.canonicalPath();
if (subdirs.empty()) QStringList subdirs;
contentSubdirs(rootPath, subdirs);
// Always offer to append the root directory just in case
if (subdirs.isEmpty() || subdirs[0] != rootPath)
subdirs.prepend(rootPath);
else if (subdirs.size() == 1)
{ {
// we didn't find anything that looks like a content directory, add directory selected by user // We didn't find anything else that looks like a content directory
if (ui.directoryListWidget->findItems(rootDir, Qt::MatchFixedString).isEmpty()) // Automatically add the directory selected by user
{ if (!ui.directoryListWidget->findItems(rootPath, Qt::MatchFixedString).isEmpty())
ui.directoryListWidget->addItem(rootDir); return;
mNewDataDirs.push_back(rootDir); ui.directoryListWidget->addItem(rootPath);
refreshDataFilesView(); mNewDataDirs.push_back(rootPath);
} refreshDataFilesView();
return; return;
} }

View file

@ -131,7 +131,6 @@ namespace Launcher
void reloadCells(QStringList selectedFiles); void reloadCells(QStringList selectedFiles);
void refreshDataFilesView(); void refreshDataFilesView();
void updateNavMeshProgress(int minDataSize); void updateNavMeshProgress(int minDataSize);
QString selectDirectory();
/** /**
* Returns the file paths of all selected content files * Returns the file paths of all selected content files