mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-20 14:41:34 +00: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
4 changed files with 48 additions and 18 deletions
|
@ -1001,7 +1001,11 @@ bool Launcher::DataFilesPage::showDeleteMessageBox(const QString& text)
|
|||
|
||||
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)
|
||||
{
|
||||
const std::lock_guard lock(mReloadCellsMutex);
|
||||
|
@ -1013,6 +1017,7 @@ void Launcher::DataFilesPage::slotAddonDataChanged()
|
|||
|
||||
void Launcher::DataFilesPage::reloadCells()
|
||||
{
|
||||
QStringList selectedFiles;
|
||||
std::unique_lock lock(mReloadCellsMutex);
|
||||
|
||||
while (true)
|
||||
|
@ -1025,16 +1030,26 @@ void Launcher::DataFilesPage::reloadCells()
|
|||
if (!std::exchange(mReloadCells, false))
|
||||
continue;
|
||||
|
||||
QStringList selectedFiles = mSelectedFiles;
|
||||
const QStringList newSelectedFiles = mSelectedFiles;
|
||||
|
||||
lock.unlock();
|
||||
|
||||
QStringList filteredFiles;
|
||||
for (const QString& v : newSelectedFiles)
|
||||
if (QFile::exists(v))
|
||||
filteredFiles.append(v);
|
||||
|
||||
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();
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <QDirIterator>
|
||||
#include <QFont>
|
||||
#include <QIODevice>
|
||||
#include <QProgressDialog>
|
||||
|
||||
#include <components/esm/format.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)
|
||||
{
|
||||
QProgressDialog progressDialog("Setting content list", {}, 0, static_cast<int>(fileList.size()));
|
||||
progressDialog.setWindowModality(Qt::WindowModal);
|
||||
progressDialog.setValue(0);
|
||||
|
||||
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))
|
||||
{
|
||||
// setCheckState already gracefully handles builtIn and fromAnotherConfigFile
|
||||
|
@ -714,7 +719,10 @@ void ContentSelectorModel::ContentModel::setContentList(const QStringList& fileL
|
|||
previousPosition = filePosition;
|
||||
}
|
||||
}
|
||||
|
||||
progressDialog.setValue(static_cast<int>(i + 1));
|
||||
}
|
||||
|
||||
refreshModel();
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <QClipboard>
|
||||
#include <QMenu>
|
||||
#include <QModelIndex>
|
||||
#include <QProgressDialog>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
ContentSelectorView::ContentSelector::ContentSelector(QWidget* parent, bool showOMWScripts)
|
||||
|
@ -292,27 +293,33 @@ void ContentSelectorView::ContentSelector::slotShowContextMenu(const QPoint& pos
|
|||
mContextMenu->exec(globalPos);
|
||||
}
|
||||
|
||||
void ContentSelectorView::ContentSelector::setCheckStateForMultiSelectedItems(bool checked)
|
||||
void ContentSelectorView::ContentSelector::setCheckStateForMultiSelectedItems(Qt::CheckState checkState)
|
||||
{
|
||||
Qt::CheckState checkState = checked ? Qt::Checked : Qt::Unchecked;
|
||||
for (const QModelIndex& index : ui->addonView->selectionModel()->selectedIndexes())
|
||||
const QModelIndexList selectedIndexes = 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)
|
||||
{
|
||||
mContentModel->setData(sourceIndex, checkState, Qt::CheckStateRole);
|
||||
}
|
||||
|
||||
progressDialog.setValue(static_cast<int>(i + 1));
|
||||
}
|
||||
}
|
||||
|
||||
void ContentSelectorView::ContentSelector::slotUncheckMultiSelectedItems()
|
||||
{
|
||||
setCheckStateForMultiSelectedItems(false);
|
||||
setCheckStateForMultiSelectedItems(Qt::Unchecked);
|
||||
}
|
||||
|
||||
void ContentSelectorView::ContentSelector::slotCheckMultiSelectedItems()
|
||||
{
|
||||
setCheckStateForMultiSelectedItems(true);
|
||||
setCheckStateForMultiSelectedItems(Qt::Checked);
|
||||
}
|
||||
|
||||
void ContentSelectorView::ContentSelector::slotCopySelectedItemsPaths()
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace ContentSelectorView
|
|||
void buildAddonView();
|
||||
void buildContextMenu();
|
||||
void setGameFileSelected(int index, bool selected);
|
||||
void setCheckStateForMultiSelectedItems(bool checked);
|
||||
void setCheckStateForMultiSelectedItems(Qt::CheckState checkState);
|
||||
|
||||
signals:
|
||||
void signalCurrentGamefileIndexChanged(int);
|
||||
|
|
Loading…
Reference in a new issue