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

Method InstallDialog

launcher/ui/java/InstallJavaDialog.cpp:186–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184}
185
186InstallDialog::InstallDialog(const QString& uid, BaseInstance* instance, QWidget* parent)
187 : QDialog(parent), container(new PageContainer(this, QString(), this)), buttons(new QDialogButtonBox(this))
188{
189 auto layout = new QVBoxLayout(this);
190
191 container->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
192 layout->addWidget(container);
193
194 auto buttonLayout = new QHBoxLayout(this);
195 auto refreshLayout = new QHBoxLayout(this);
196
197 auto refreshButton = new QPushButton(tr("&Refresh"), this);
198 connect(refreshButton, &QPushButton::clicked, this, [this] { pageCast(container->selectedPage())->loadList(); });
199 refreshLayout->addWidget(refreshButton);
200
201 auto recommendedCheckBox = new QCheckBox("Recommended", this);
202 recommendedCheckBox->setCheckState(Qt::CheckState::Checked);
203 connect(recommendedCheckBox, &QCheckBox::stateChanged, this, [this](int state) {
204 for (BasePage* page : container->getPages()) {
205 pageCast(page)->setRecommend(state == Qt::Checked);
206 }
207 });
208
209 refreshLayout->addWidget(recommendedCheckBox);
210 buttonLayout->addLayout(refreshLayout);
211
212 buttons->setOrientation(Qt::Horizontal);
213 buttons->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
214 buttons->button(QDialogButtonBox::Ok)->setText(tr("Download"));
215 buttons->button(QDialogButtonBox::Cancel)->setText(tr("Cancel"));
216 connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept);
217 connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
218 buttonLayout->addWidget(buttons);
219
220 layout->addLayout(buttonLayout);
221
222 setWindowTitle(dialogTitle());
223 setWindowModality(Qt::WindowModal);
224 resize(840, 480);
225
226 QStringList recommendedJavas;
227 if (auto mcInst = dynamic_cast<MinecraftInstance*>(instance); mcInst) {
228 auto mc = mcInst->getPackProfile()->getComponent("net.minecraft");
229 if (mc) {
230 auto file = mc->getVersionFile(); // no need for load as it should already be loaded
231 if (file) {
232 for (auto major : file->compatibleJavaMajors) {
233 recommendedJavas.append(QString("Java %1").arg(major));
234 }
235 }
236 }
237 } else {
238 const auto versions = APPLICATION->metadataIndex()->get("net.minecraft.java");
239 if (versions) {
240 if (versions->isLoaded()) {
241 recommendedJavas = getRecommendedJavaVersionsFromVersionList(versions);
242 } else {
243 auto newTask = versions->getLoadTask();

Callers

nothing calls this directly

Calls 15

QStringClass · 0.85
dialogTitleFunction · 0.85
getComponentMethod · 0.80
getPackProfileMethod · 0.80
getVersionFileMethod · 0.80
appendMethod · 0.80
metadataIndexMethod · 0.80
selectSearchMethod · 0.80
pageCastFunction · 0.70
validateFunction · 0.50
loadListMethod · 0.45

Tested by

no test coverage detected