| 623 | } |
| 624 | |
| 625 | InstallationResult InstallationManager::install(const QString& fileName, |
| 626 | GuessedValue<QString>& modName, |
| 627 | int modID) |
| 628 | { |
| 629 | m_IsRunning = true; |
| 630 | ON_BLOCK_EXIT([this]() { |
| 631 | m_IsRunning = false; |
| 632 | }); |
| 633 | |
| 634 | QFileInfo fileInfo(fileName); |
| 635 | if (!getSupportedExtensions().contains(fileInfo.suffix(), Qt::CaseInsensitive)) { |
| 636 | reportError(tr("File format \"%1\" not supported").arg(fileInfo.suffix())); |
| 637 | return InstallationResult(IPluginInstaller::RESULT_FAILED); |
| 638 | } |
| 639 | |
| 640 | modName.setFilter(&fixDirectoryName); |
| 641 | |
| 642 | modName.update(QFileInfo(fileName).completeBaseName(), GUESS_FALLBACK); |
| 643 | |
| 644 | // read out meta information from the download if available |
| 645 | QString gameName = ""; |
| 646 | QString version = ""; |
| 647 | QString newestVersion = ""; |
| 648 | int category = 0; |
| 649 | int categoryID = 0; |
| 650 | int fileCategoryID = 1; |
| 651 | QString repository = "Nexus"; |
| 652 | |
| 653 | QString metaName = fileName + ".meta"; |
| 654 | if (QFile(metaName).exists()) { |
| 655 | QSettings metaFile(metaName, QSettings::IniFormat); |
| 656 | gameName = metaFile.value("gameName", "").toString(); |
| 657 | modID = metaFile.value("modID", 0).toInt(); |
| 658 | QTextDocument doc; |
| 659 | doc.setHtml(metaFile.value("name", "").toString()); |
| 660 | modName.update(doc.toPlainText(), GUESS_FALLBACK); |
| 661 | modName.update(metaFile.value("modName", "").toString(), GUESS_META); |
| 662 | |
| 663 | version = metaFile.value("version", "").toString(); |
| 664 | newestVersion = metaFile.value("newestVersion", "").toString(); |
| 665 | category = metaFile.value("category", 0).toInt(); |
| 666 | unsigned int categoryIndex = CategoryFactory::instance().resolveNexusID(category); |
| 667 | if (category != 0 && categoryIndex == 0U && |
| 668 | Settings::instance().nexus().categoryMappings()) { |
| 669 | QMessageBox nexusQuery; |
| 670 | nexusQuery.setWindowTitle(tr("No category found")); |
| 671 | nexusQuery.setText(tr( |
| 672 | "This Nexus category has not yet been mapped. Do you wish to proceed without " |
| 673 | "setting a category, proceed and disable automatic Nexus mappings, or stop " |
| 674 | "and configure your category mappings?")); |
| 675 | QPushButton* proceedButton = |
| 676 | nexusQuery.addButton(tr("&Proceed"), QMessageBox::YesRole); |
| 677 | QPushButton* disableButton = |
| 678 | nexusQuery.addButton(tr("&Disable"), QMessageBox::AcceptRole); |
| 679 | QPushButton* stopButton = |
| 680 | nexusQuery.addButton(tr("&Stop && Configure"), QMessageBox::DestructiveRole); |
| 681 | nexusQuery.exec(); |
| 682 | if (nexusQuery.clickedButton() == disableButton) { |
no test coverage detected