MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / confirmProjectKit

Method confirmProjectKit

src/plugins/project/projectcore.cpp:308–401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306}
307
308void ProjectCore::confirmProjectKit(const QString &path)
309{
310 DDialog dialog;
311 dialog.setWindowTitle(tr("Config"));
312 dialog.setIcon(QIcon::fromTheme("ide"));
313 auto widget = new QWidget;
314 auto layout = new QHBoxLayout(widget);
315 layout->setAlignment(Qt::AlignLeft);
316
317 QLabel *label = new QLabel(tr("Project Type:"), widget);
318 label->setFixedWidth(100);
319 QComboBox *cbBox = new QComboBox(widget);
320 layout->addWidget(label);
321 layout->addWidget(cbBox);
322 dialog.addContent(widget);
323 dialog.addButton(tr("Cancel"));
324 dialog.addButton(tr("Confirm"), true, DDialog::ButtonRecommend);
325 auto originalSize = dialog.size();
326
327 auto projectService = dpfGetService(ProjectService);
328 auto allKits = projectService->supportGeneratorName<ProjectGenerator>();
329 cbBox->addItems(allKits);
330 DStackedWidget *configureWidget = new DStackedWidget;
331 dialog.addContent(configureWidget);
332
333 // check defualt kit by supportNames
334 bool hasDefault = false;
335 for (auto kit : allKits) {
336 if (hasDefault)
337 break;
338 auto generator = projectService->createGenerator<ProjectGenerator>(kit);
339 QStringList fileNames = generator->supportFileNames();
340 if (fileNames.isEmpty())
341 continue;
342 for (auto filename : fileNames) {
343 if (QDir(path).exists(filename)) {
344 cbBox->setCurrentText(kit);
345 auto widget = generator->configureWidget(generator->supportLanguages().first(), path);
346 if (widget)
347 configureWidget->addWidget(widget);
348 hasDefault = true;
349 break;
350 }
351 }
352 }
353
354 if (!hasDefault) {
355 // Apply language-specific processing by suffix
356 QString kit = DirectoryGenerator::toolKitName();
357 for (auto fileInfo : QDir(path).entryInfoList()) {
358 if (fileInfo.suffix() == "py")
359 kit = "python";
360 else if (fileInfo.suffix() == "js")
361 kit = "javascript";
362 else
363 continue;
364
365 break;

Callers

nothing calls this directly

Calls 15

toolKitNameFunction · 0.85
connectFunction · 0.85
addContentMethod · 0.80
currentWidgetMethod · 0.80
removeWidgetMethod · 0.80
canOpenProjectMethod · 0.80
setIconMethod · 0.45
addWidgetMethod · 0.45
sizeMethod · 0.45
addItemsMethod · 0.45
supportFileNamesMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected