QString BaseCheckoutWizard::openProject(const QString &path, QString *errorMessage) { ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance(); if (!pe) { *errorMessage = tr("The Project Explorer is not available."); return QString(); } // Search the directory for project files const QDir dir(path); if (!dir.exists()) { *errorMessage = tr("'%1' does not exist."). arg(QDir::toNativeSeparators(path)); // Should not happen return QString(); } QFileInfoList projectFiles = findProjectFiles(dir, errorMessage); if (projectFiles.empty()) return QString(); // Open. Do not use a busy cursor here as additional wizards might pop up const QString projectFile = projectFiles.front().absoluteFilePath(); if (!pe->openProject(projectFile, errorMessage)) return QString(); return projectFile; }
QString BaseCheckoutWizardFactory::openProject(const Utils::FileName &path, QString *errorMessage) { // Search the directory for project files const QDir dir(path.toString()); if (!dir.exists()) { *errorMessage = tr("\"%1\" does not exist."). arg(path.toUserOutput()); // Should not happen return QString(); } QFileInfoList projectFiles = findProjectFiles(dir, errorMessage); if (projectFiles.empty()) return QString(); // Open. Do not use a busy cursor here as additional wizards might pop up const QString projectFile = projectFiles.front().absoluteFilePath(); if (!ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(projectFile, errorMessage)) return QString(); return projectFile; }
QString findD3dCompiler(Platform platform, const QString &qtBinDir, unsigned wordSize) { const QString prefix = QStringLiteral("D3Dcompiler_"); const QString suffix = QLatin1String(windowsSharedLibrarySuffix); // Get the DLL from Kit 8.0 onwards const QString kitDir = QString::fromLocal8Bit(qgetenv("WindowsSdkDir")); if (!kitDir.isEmpty()) { QString redistDirPath = QDir::cleanPath(kitDir) + QStringLiteral("/Redist/D3D/"); if (platform & ArmBased) { redistDirPath += QStringLiteral("arm"); } else { redistDirPath += wordSize == 32 ? QStringLiteral("x86") : QStringLiteral("x64"); } QDir redistDir(redistDirPath); if (redistDir.exists()) { const QFileInfoList files = redistDir.entryInfoList(QStringList(prefix + QLatin1Char('*') + suffix), QDir::Files); if (!files.isEmpty()) return files.front().absoluteFilePath(); } } QStringList candidateVersions; for (int i = 47 ; i >= 40 ; --i) candidateVersions.append(prefix + QString::number(i) + suffix); // Check the bin directory of the Qt SDK (in case it is shadowed by the // Windows system directory in PATH). foreach (const QString &candidate, candidateVersions) { const QFileInfo fi(qtBinDir + QLatin1Char('/') + candidate); if (fi.isFile()) return fi.absoluteFilePath(); } // Find the latest D3D compiler DLL in path (Windows 8.1 has d3dcompiler_47). if (platform & IntelBased) { QString errorMessage; unsigned detectedWordSize; foreach (const QString &candidate, candidateVersions) { const QString dll = findInPath(candidate); if (!dll.isEmpty() && readPeExecutable(dll, &errorMessage, 0, &detectedWordSize, 0) && detectedWordSize == wordSize) { return dll; } } }
// Try to find the project files in a project directory with some smartness static QFileInfoList findProjectFiles(const QDir &projectDir, QString *errorMessage) { const QStringList projectFilePatterns = ProjectExplorer::ProjectExplorerPlugin::projectFilePatterns(); // Project directory QFileInfoList projectFiles = projectDir.entryInfoList(projectFilePatterns, QDir::Files|QDir::NoDotAndDotDot|QDir::Readable); if (!projectFiles.empty()) return projectFiles; // Try a 'src' directory QFileInfoList srcDirs = projectDir.entryInfoList(QStringList(QLatin1String("src")), QDir::Dirs|QDir::NoDotAndDotDot|QDir::Readable); if (srcDirs.empty()) { *errorMessage = msgNoProjectFiles(projectDir, projectFilePatterns); return QFileInfoList(); } const QDir srcDir = QDir(srcDirs.front().absoluteFilePath()); projectFiles = srcDir.entryInfoList(projectFilePatterns, QDir::Files|QDir::NoDotAndDotDot|QDir::Readable); if (projectFiles.empty()) { *errorMessage = msgNoProjectFiles(srcDir, projectFilePatterns); return QFileInfoList(); } return projectFiles; }