mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-09-12 14:01:15 -04:00
Merge branch 'fix_launcher_ui_freeze' into 'master'
Make launcher UI on content files selection more responsive (#8478) See merge request OpenMW/openmw!4682
This commit is contained in:
commit
2342dbe0f5
@ -1001,7 +1001,11 @@ bool Launcher::DataFilesPage::showDeleteMessageBox(const QString& text)
|
|||||||
|
|
||||||
void Launcher::DataFilesPage::slotAddonDataChanged()
|
void Launcher::DataFilesPage::slotAddonDataChanged()
|
||||||
{
|
{
|
||||||
QStringList selectedFiles = selectedFilePaths();
|
const ContentSelectorModel::ContentFileList items = mSelector->selectedFiles();
|
||||||
|
QStringList selectedFiles;
|
||||||
|
for (const ContentSelectorModel::EsmFile* item : items)
|
||||||
|
selectedFiles.append(item->filePath());
|
||||||
|
|
||||||
if (mSelectedFiles != selectedFiles)
|
if (mSelectedFiles != selectedFiles)
|
||||||
{
|
{
|
||||||
const std::lock_guard lock(mReloadCellsMutex);
|
const std::lock_guard lock(mReloadCellsMutex);
|
||||||
@ -1013,6 +1017,7 @@ void Launcher::DataFilesPage::slotAddonDataChanged()
|
|||||||
|
|
||||||
void Launcher::DataFilesPage::reloadCells()
|
void Launcher::DataFilesPage::reloadCells()
|
||||||
{
|
{
|
||||||
|
QStringList selectedFiles;
|
||||||
std::unique_lock lock(mReloadCellsMutex);
|
std::unique_lock lock(mReloadCellsMutex);
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
@ -1025,16 +1030,26 @@ void Launcher::DataFilesPage::reloadCells()
|
|||||||
if (!std::exchange(mReloadCells, false))
|
if (!std::exchange(mReloadCells, false))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QStringList selectedFiles = mSelectedFiles;
|
const QStringList newSelectedFiles = mSelectedFiles;
|
||||||
|
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
||||||
CellNameLoader cellNameLoader;
|
QStringList filteredFiles;
|
||||||
QSet<QString> set = cellNameLoader.getCellNames(selectedFiles);
|
for (const QString& v : newSelectedFiles)
|
||||||
QStringList cellNamesList(set.begin(), set.end());
|
if (QFile::exists(v))
|
||||||
std::sort(cellNamesList.begin(), cellNamesList.end());
|
filteredFiles.append(v);
|
||||||
|
|
||||||
emit signalLoadedCellsChanged(std::move(cellNamesList));
|
if (selectedFiles != filteredFiles)
|
||||||
|
{
|
||||||
|
selectedFiles = std::move(filteredFiles);
|
||||||
|
|
||||||
|
CellNameLoader cellNameLoader;
|
||||||
|
QSet<QString> set = cellNameLoader.getCellNames(selectedFiles);
|
||||||
|
QStringList cellNamesList(set.begin(), set.end());
|
||||||
|
std::sort(cellNamesList.begin(), cellNamesList.end());
|
||||||
|
|
||||||
|
emit signalLoadedCellsChanged(std::move(cellNamesList));
|
||||||
|
}
|
||||||
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <QDirIterator>
|
#include <QDirIterator>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
|
#include <QProgressDialog>
|
||||||
|
|
||||||
#include <components/esm/format.hpp>
|
#include <components/esm/format.hpp>
|
||||||
#include <components/esm3/esmreader.hpp>
|
#include <components/esm3/esmreader.hpp>
|
||||||
@ -696,10 +697,14 @@ bool ContentSelectorModel::ContentModel::isLoadOrderError(const EsmFile* file) c
|
|||||||
|
|
||||||
void ContentSelectorModel::ContentModel::setContentList(const QStringList& fileList)
|
void ContentSelectorModel::ContentModel::setContentList(const QStringList& fileList)
|
||||||
{
|
{
|
||||||
|
QProgressDialog progressDialog("Setting content list", {}, 0, static_cast<int>(fileList.size()));
|
||||||
|
progressDialog.setWindowModality(Qt::WindowModal);
|
||||||
|
progressDialog.setValue(0);
|
||||||
|
|
||||||
int previousPosition = -1;
|
int previousPosition = -1;
|
||||||
for (const QString& filepath : fileList)
|
for (qsizetype i = 0, n = fileList.size(); i < n; ++i)
|
||||||
{
|
{
|
||||||
const EsmFile* file = item(filepath);
|
const EsmFile* file = item(fileList[i]);
|
||||||
if (setCheckState(file, true))
|
if (setCheckState(file, true))
|
||||||
{
|
{
|
||||||
// setCheckState already gracefully handles builtIn and fromAnotherConfigFile
|
// setCheckState already gracefully handles builtIn and fromAnotherConfigFile
|
||||||
@ -714,7 +719,10 @@ void ContentSelectorModel::ContentModel::setContentList(const QStringList& fileL
|
|||||||
previousPosition = filePosition;
|
previousPosition = filePosition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
progressDialog.setValue(static_cast<int>(i + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshModel();
|
refreshModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
|
#include <QProgressDialog>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
ContentSelectorView::ContentSelector::ContentSelector(QWidget* parent, bool showOMWScripts)
|
ContentSelectorView::ContentSelector::ContentSelector(QWidget* parent, bool showOMWScripts)
|
||||||
@ -292,27 +293,33 @@ void ContentSelectorView::ContentSelector::slotShowContextMenu(const QPoint& pos
|
|||||||
mContextMenu->exec(globalPos);
|
mContextMenu->exec(globalPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::setCheckStateForMultiSelectedItems(bool checked)
|
void ContentSelectorView::ContentSelector::setCheckStateForMultiSelectedItems(Qt::CheckState checkState)
|
||||||
{
|
{
|
||||||
Qt::CheckState checkState = checked ? Qt::Checked : Qt::Unchecked;
|
const QModelIndexList selectedIndexes = ui->addonView->selectionModel()->selectedIndexes();
|
||||||
for (const QModelIndex& index : ui->addonView->selectionModel()->selectedIndexes())
|
|
||||||
|
QProgressDialog progressDialog("Updating content selection", {}, 0, static_cast<int>(selectedIndexes.size()));
|
||||||
|
progressDialog.setWindowModality(Qt::WindowModal);
|
||||||
|
progressDialog.setValue(0);
|
||||||
|
|
||||||
|
for (qsizetype i = 0, n = selectedIndexes.size(); i < n; ++i)
|
||||||
{
|
{
|
||||||
QModelIndex sourceIndex = mAddonProxyModel->mapToSource(index);
|
const QModelIndex sourceIndex = mAddonProxyModel->mapToSource(selectedIndexes[i]);
|
||||||
|
|
||||||
if (mContentModel->data(sourceIndex, Qt::CheckStateRole).toInt() != checkState)
|
if (mContentModel->data(sourceIndex, Qt::CheckStateRole).toInt() != checkState)
|
||||||
{
|
|
||||||
mContentModel->setData(sourceIndex, checkState, Qt::CheckStateRole);
|
mContentModel->setData(sourceIndex, checkState, Qt::CheckStateRole);
|
||||||
}
|
|
||||||
|
progressDialog.setValue(static_cast<int>(i + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::slotUncheckMultiSelectedItems()
|
void ContentSelectorView::ContentSelector::slotUncheckMultiSelectedItems()
|
||||||
{
|
{
|
||||||
setCheckStateForMultiSelectedItems(false);
|
setCheckStateForMultiSelectedItems(Qt::Unchecked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::slotCheckMultiSelectedItems()
|
void ContentSelectorView::ContentSelector::slotCheckMultiSelectedItems()
|
||||||
{
|
{
|
||||||
setCheckStateForMultiSelectedItems(true);
|
setCheckStateForMultiSelectedItems(Qt::Checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::slotCopySelectedItemsPaths()
|
void ContentSelectorView::ContentSelector::slotCopySelectedItemsPaths()
|
||||||
|
@ -69,7 +69,7 @@ namespace ContentSelectorView
|
|||||||
void buildAddonView();
|
void buildAddonView();
|
||||||
void buildContextMenu();
|
void buildContextMenu();
|
||||||
void setGameFileSelected(int index, bool selected);
|
void setGameFileSelected(int index, bool selected);
|
||||||
void setCheckStateForMultiSelectedItems(bool checked);
|
void setCheckStateForMultiSelectedItems(Qt::CheckState checkState);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void signalCurrentGamefileIndexChanged(int);
|
void signalCurrentGamefileIndexChanged(int);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user