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

Method confirm

launcher/ui/dialogs/ResourceDownloadDialog.cpp:142–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140}
141
142void ResourceDownloadDialog::confirm()
143{
144 auto confirm_dialog = ReviewMessageBox::create(this, tr("Confirm %1 to download").arg(resourcesString()));
145 confirm_dialog->retranslateUi(resourcesString());
146
147 QHash<QString, GetModDependenciesTask::PackDependencyExtraInfo> dependencyExtraInfo;
148 QStringList depNames;
149 if (auto task = getModDependenciesTask(); task) {
150 connect(task.get(), &Task::failed, this,
151 [&](QString reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->exec(); });
152
153 connect(task.get(), &Task::succeeded, this, [&]() {
154 QStringList warnings = task->warnings();
155 if (warnings.count()) {
156 CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->exec();
157 }
158 });
159
160 // Check for updates
161 ProgressDialog progress_dialog(this);
162 progress_dialog.setSkipButton(true, tr("Abort"));
163 progress_dialog.setWindowTitle(tr("Checking for dependencies..."));
164 auto ret = progress_dialog.execWithTask(task.get());
165
166 // If the dialog was skipped / some download error happened
167 if (ret == QDialog::DialogCode::Rejected) {
168 QMetaObject::invokeMethod(this, "reject", Qt::QueuedConnection);
169 return;
170 } else {
171 for (auto dep : task->getDependecies()) {
172 addResource(dep->pack, dep->version);
173 depNames << dep->pack->name;
174 }
175 dependencyExtraInfo = task->getExtraInfo();
176 }
177 }
178
179 auto selected = getTasks();
180 std::sort(selected.begin(), selected.end(), [](const DownloadTaskPtr& a, const DownloadTaskPtr& b) {
181 return QString::compare(a->getName(), b->getName(), Qt::CaseInsensitive) < 0;
182 });
183 for (auto& task : selected) {
184 auto extraInfo = dependencyExtraInfo.value(task->getPack()->addonId.toString());
185 confirm_dialog->appendResource({ task->getName(), task->getFilename(), task->getCustomPath(),
186 ModPlatform::ProviderCapabilities::name(task->getProvider()), extraInfo.required_by,
187 task->getVersion().version_type.toString(), !extraInfo.maybe_installed });
188 }
189
190 if (confirm_dialog->exec()) {
191 auto deselected = confirm_dialog->deselectedResources();
192 for (auto page : m_container->getPages()) {
193 auto res = static_cast<ResourcePage*>(page);
194 for (auto name : deselected)
195 res->removeResourceFromPage(name);
196 }
197
198 this->accept();
199 } else {

Callers

nothing calls this directly

Calls 15

acceptMethod · 0.95
selectableFunction · 0.85
setSkipButtonMethod · 0.80
execWithTaskMethod · 0.80
getDependeciesMethod · 0.80
getExtraInfoMethod · 0.80
getNameMethod · 0.80
valueMethod · 0.80
getPackMethod · 0.80
appendResourceMethod · 0.80
getFilenameMethod · 0.80
deselectedResourcesMethod · 0.80

Tested by

no test coverage detected