Files
modorganizer-bsapacker/src/ArchiveAutoService.cpp
T

35 lines
994 B
C++
Raw Normal View History

2019-11-13 21:19:08 +00:00
#include <bsapacker/ArchiveAutoService.h>
2023-10-11 01:16:49 -05:00
#include <QProgressDialog>
#include <QtConcurrent>
#include <QLabel>
2019-11-13 21:19:08 +00:00
namespace BsaPacker
{
2025-05-29 11:03:38 +02:00
bool ArchiveAutoService::CreateBSA(libbsarch::bs_archive_auto* archive, const QString& archiveName, const bsa_archive_type_e) const
2019-11-13 21:19:08 +00:00
{
2023-10-11 20:35:28 -05:00
QProgressDialog savingDialog;
savingDialog.setWindowFlags(savingDialog.windowFlags() & ~Qt::WindowCloseButtonHint);
savingDialog.setWindowTitle(QObject::tr("Writing Archive"));
savingDialog.setCancelButton(0);
QLabel text;
text.setText(QObject::tr("Writing %1").arg(archiveName));
savingDialog.setLabel(&text);
savingDialog.setRange(0, 0);
savingDialog.show();
auto future = QtConcurrent::run([=]() -> bool {
try {
2023-10-11 01:16:49 -05:00
archive->save_to_disk(archiveName.toStdString());
2023-10-11 20:35:28 -05:00
} catch (std::exception e) {
return false;
2023-10-11 01:16:49 -05:00
}
2023-10-11 20:35:28 -05:00
return true;
});
while (!future.isFinished())
{
QCoreApplication::processEvents();
2023-10-08 03:02:20 -05:00
}
2023-10-11 20:35:28 -05:00
savingDialog.hide();
return future.result();
2019-11-13 21:19:08 +00:00
}
} // namespace BsaPacker