| 306 | } |
| 307 | |
| 308 | void 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; |
nothing calls this directly
no test coverage detected