MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / doExport

Method doExport

launcher/ui/dialogs/ExportInstanceDialog.cpp:132–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132void ExportInstanceDialog::doExport()
133{
134 auto name = FS::RemoveInvalidFilenameChars(m_instance->name());
135
136 const QString output = QFileDialog::getSaveFileName(this, tr("Export %1").arg(m_instance->name()),
137 FS::PathCombine(QDir::homePath(), name + ".zip"), "Zip (*.zip)", nullptr);
138 if (output.isEmpty()) {
139 QDialog::done(QDialog::Rejected);
140 return;
141 }
142
143 SaveIcon(m_instance);
144
145 auto files = QFileInfoList();
146 if (!MMCZip::collectFileListRecursively(m_instance->instanceRoot(), nullptr, &files,
147 std::bind(&FileIgnoreProxy::filterFile, proxyModel, std::placeholders::_1))) {
148 QMessageBox::warning(this, tr("Error"), tr("Unable to export instance"));
149 QDialog::done(QDialog::Rejected);
150 return;
151 }
152
153 auto task = makeShared<MMCZip::ExportToZipTask>(output, m_instance->instanceRoot(), files, "", true, true);
154
155 connect(task.get(), &Task::failed, this,
156 [this, output](QString reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show(); });
157 connect(task.get(), &Task::finished, this, [task] { task->deleteLater(); });
158
159 ProgressDialog progress(this);
160 progress.setSkipButton(true, tr("Abort"));
161 auto result = progress.execWithTask(task.get());
162 QDialog::done(result);
163}
164
165void ExportInstanceDialog::done(int result)
166{

Callers

nothing calls this directly

Calls 12

PathCombineFunction · 0.85
SaveIconFunction · 0.85
selectableFunction · 0.85
instanceRootMethod · 0.80
showMethod · 0.80
setSkipButtonMethod · 0.80
execWithTaskMethod · 0.80
nameMethod · 0.45
isEmptyMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected