void QrcEditor::resolveLocationIssues(QStringList &files) { const QDir dir = QFileInfo(m_treeview->fileName()).absoluteDir(); const QString dotdotSlash = QLatin1String("../"); int i = 0; const int count = files.count(); const int initialCount = files.count(); // Find first troublesome file for (; i < count; i++) { QString const &file = files.at(i); const QString relativePath = dir.relativeFilePath(file); if (relativePath.startsWith(dotdotSlash)) break; } // All paths fine -> no interaction needed if (i == count) { return; } // Interact with user from now on ResolveLocationContext context; bool abort = false; for (QStringList::iterator it = files.begin(); it != files.end(); ) { // Path fine -> skip file QString const &file = *it; QString const relativePath = dir.relativeFilePath(file); if (!relativePath.startsWith(dotdotSlash)) { continue; } // Path troublesome and aborted -> remove file bool ok = false; if (!abort) { // Path troublesome -> query user "Do you want copy/abort/skip". QAbstractButton *clickedButton = context.execLocationMessageBox(this, file, initialCount > 1); if (clickedButton == context.copyButton) { const QFileInfo fi(file); QFileInfo suggestion; QDir tmpTarget(dir.path() + QString(QDir::separator()) + QString("Resources"));; if (tmpTarget.exists()) suggestion.setFile(tmpTarget, fi.fileName()); else suggestion.setFile(dir, fi.fileName()); // Prompt for copy location, copy and replace name. const QString copyName = context.execCopyFileDialog(this, dir, suggestion.absoluteFilePath()); ok = !copyName.isEmpty() && copyFile(file, copyName, this); if (ok) *it = copyName; } else if (clickedButton == context.abortButton) { abort = true; } } // !abort if (ok) { // Remove files where user canceled or failures occurred. ++it; } else { it = files.erase(it); } } // for files }
QVariantMap S60EmulatorRunConfiguration::toMap() const { QVariantMap map(ProjectExplorer::RunConfiguration::toMap()); const QDir projectDir = QDir(target()->project()->projectDirectory()); map.insert(QLatin1String(PRO_FILE_KEY), projectDir.relativeFilePath(m_proFilePath)); return map; }
/******************************************************************************* .pls playlist save *******************************************************************************/ void savePlsPlaylist(QIODevice* device, const QDir& playlist_dir, QList<MEDIA::TrackPtr> list) { QTextStream stream(device); stream << "[playlist]" << endl; stream << "Version=2" << endl; stream << "NumberOfEntries=" << list.size() << endl; int n = 1; foreach (MEDIA::TrackPtr media, list) { if (!media) continue; if (media->type() != TYPE_TRACK && media->type() != TYPE_STREAM) continue; // write metadata if (media->type() == TYPE_TRACK ) { QString media_path = media->url; media_path = playlist_dir.relativeFilePath(media_path).toUtf8(); stream << "File" << n << "=" << media_path << endl; stream << "Title" << n << "=" << media->title << endl; stream << "Length" << n << "=" << media->duration << endl; ++n; } else { // TYPE_STREAM stream << "File" << n << "=" << QString(media->url).toUtf8() << endl; stream << "Title" << n << "=" << QString(media->name).toUtf8() << endl; stream << "Length" << n << "=" << endl; ++n; } } // fin Foreach }
/******************************************************************************* m3u playlist save *******************************************************************************/ void saveM3uPlaylist(QIODevice* device, const QDir& playlist_dir, QList<MEDIA::TrackPtr> list) { device->write("#EXTM3U\n"); foreach (MEDIA::TrackPtr media, list) { if (!media) continue; if (media->type() != TYPE_TRACK && media->type() != TYPE_STREAM) continue; QString info; QString media_path; if (media->type() == TYPE_TRACK ) { info = QString("#EXTINF:%1,%2 - %3\n").arg(QString::number(media->duration)) .arg(media->artist) .arg(media->album); device->write(info.toUtf8()); //! Get the path to MediaItem relative to the Playlist File directory media_path = playlist_dir.relativeFilePath(media->url); } else { info = QString("#EXTINF:\n"); info = QString("#EXTINF:%1,%2 - %3\n").arg(0) .arg("") .arg(media->name); device->write(info.toUtf8()); media_path = media->url; } device->write(media_path.toUtf8()); device->write("\n"); } }
static void migrateDataDir() { #ifdef Q_OS_MAC QString olddir = QDir::homePath() + QLatin1String("/Library/Preferences/Mumble"); QString newdir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); QString linksTo = QFile::readLink(olddir); if (!QFile::exists(newdir) && QFile::exists(olddir) && linksTo.isEmpty()) { QDir d; d.mkpath(newdir + QLatin1String("/..")); if (d.rename(olddir, newdir)) { if (d.cd(QDir::homePath() + QLatin1String("/Library/Preferences"))) { if (QFile::link(d.relativeFilePath(newdir), olddir)) { qWarning("Migrated application data directory from '%s' to '%s'", qPrintable(olddir), qPrintable(newdir)); return; } } } } else { /* Data dir has already been migrated. */ return; } qWarning("Application data migration failed."); #endif }
QList<QString> scanDir(QDir dir) { QList<QString> files; QStack<QString> stack; stack.push(dir.absolutePath()); while (!stack.isEmpty()) { QString sSubdir = stack.pop(); QDir subdir(sSubdir); // Check for the files. QList<QString> sublist = subdir.entryList(QDir::Files); for (QString& file : sublist) file = dir.relativeFilePath(sSubdir + '/' + file); files += sublist; QFileInfoList infoEntries = subdir.entryInfoList(QStringList(), QDir::AllDirs | QDir::NoSymLinks | QDir::NoDotAndDotDot); for (int i = 0; i < infoEntries.size(); i++) { QFileInfo& item = infoEntries[i]; stack.push(item.absoluteFilePath()); } } return files; }
static void updateTsFiles( const MetaTranslator& fetchedTor, const QStringList& tsFileNames, const QString& codecForTr, bool noObsolete, bool verbose ) { QStringList::ConstIterator t = tsFileNames.begin(); QDir dir; while ( t != tsFileNames.end() ) { QString fn = dir.relativeFilePath(*t); MetaTranslator tor; MetaTranslator out; tor.load( *t ); if ( !codecForTr.isEmpty() ) tor.setCodec( codecForTr.toLatin1() ); if ( verbose ) fprintf( stderr, "Updating '%s'...\n", fn.toLatin1().constData() ); merge( &tor, &fetchedTor, &out, verbose, noObsolete ); if ( noObsolete ) out.stripObsoleteMessages(); out.stripEmptyContexts(); if ( !out.save(*t) ) { #if defined(_MSC_VER) && _MSC_VER >= 1400 char buf[100]; strerror_s(buf, sizeof(buf), errno); fprintf( stderr, "pylupdate4 error: Cannot save '%s': %s\n", fn.toLatin1().constData(), buf ); #else fprintf( stderr, "pylupdate4 error: Cannot save '%s': %s\n", fn.toLatin1().constData(), strerror(errno) ); #endif } ++t; } }
void CPropBrowserWidget::on_treeView_clicked(const QModelIndex &index) { QDir d; QString filePath; std::string stdFilePath; if(!m_model->isDir(index)) { filePath = m_model->filePath(index); filePath = d.relativeFilePath(filePath); stdFilePath = filePath.toStdString(); utils::changeExt(stdFilePath, "jpg"); if(utils::fileExists(stdFilePath)) { m_default = false; m_image.load(stdFilePath.c_str()); ui->label->setPixmap(m_image); } else if(!m_default) { m_default = true; m_image.load(DEFAULT_PROPBROWSER_IMAGE_PATH); ui->label->setPixmap(m_image); } } }
QString txEmissionsBase::saveCalcOptions() const { QDir calcConfDir; const QString fullPath = calcConfDir.relativeFilePath(m_fullReportsPath) + QDir::separator() + m_currTime + ".conf"; QFile confFile(fullPath); if ( !confFile.open(QFile::WriteOnly) ) { throw txError("Can not open file " + fullPath + "!"); } QTextStream fout(&confFile); fout << "task" << "=" << m_calculationOptions->val_task() << "\n" << "Vh" << "=" << m_calculationOptions->val_Vh() << "\n" << "standard" << "=" << m_calculationOptions->val_standard() << "\n" << "chargingType" << "=" << m_calculationOptions->val_chargingType() << "\n" << "fuelType" << "=" << m_calculationOptions->val_fuelType() << "\n" << "NOxSample" << "=" << m_calculationOptions->val_NOxSample() << "\n" << "PTcalc" << "=" << m_calculationOptions->val_PTcalc() << "\n" << "PTmass" << "=" << m_calculationOptions->val_PTmass() << "\n" << "addPointsCalc" << "=" << m_calculationOptions->val_addPointsCalc() << "\n" << "testDate" << "=" << m_calculationOptions->val_testDate() << "\n" << "calcConfigFile" << "=" << m_calculationOptions->val_calcConfigFile() << "\n"; confFile.close(); return "libtoxic: Calculation config file \"" + fullPath + "\" created.\n"; }
/*! \brief \param e \return QString */ QString PlayList::playListEntry(const M3uEntry& e) const { //obtain the filename to be used in the m3u playlist //not nescessary the same name as the original file //could be pointing to the location the original file is copied, if copied //could be relative or absolute //will also be different from originalFile if keepFolderStructure const QDir outPutPath(guiSettings->value("outPutPath") .toString()); const QFileInfo file = e.originalFile(); QString playListEntryName = file.absoluteFilePath(); bool useCopyFilesToPath = guiSettings->value("useCopyFilesToPath").toBool(); if (copyFiles_ && useCopyFilesToPath) { playListEntryName = copyFilesToDir_.absolutePath() + "/" + file.fileName(); bool keepFolderStructure = guiSettings->value("keepFolderStructure").toBool(); if (keepFolderStructure) { QStringList dirs = file.absolutePath().replace("\\", "/").split("/"); QString root = dirs[0]; playListEntryName = file.absoluteFilePath().replace(root, copyFilesToDir_.absolutePath()); } } if (relativePath_) { playListEntryName = outPutPath.relativeFilePath(playListEntryName); } return playListEntryName; }
DeploymentData CMakeBuildConfiguration::deploymentData() const { DeploymentData result; QDir sourceDir = target()->project()->projectDirectory().toString(); QDir buildDir = buildDirectory().toString(); QString deploymentPrefix; QString deploymentFilePath = sourceDir.filePath("QtCreatorDeployment.txt"); bool hasDeploymentFile = QFileInfo::exists(deploymentFilePath); if (!hasDeploymentFile) { deploymentFilePath = buildDir.filePath("QtCreatorDeployment.txt"); hasDeploymentFile = QFileInfo::exists(deploymentFilePath); } if (hasDeploymentFile) { deploymentPrefix = result.addFilesFromDeploymentFile(deploymentFilePath, sourceDir.absolutePath()); } for (const CMakeBuildTarget &ct : m_buildTargets) { if (ct.targetType == ExecutableType || ct.targetType == DynamicLibraryType) { if (!ct.executable.isEmpty() && !result.deployableForLocalFile(ct.executable.toString()).isValid()) { result.addFile(ct.executable.toString(), deploymentPrefix + buildDir.relativeFilePath(ct.executable.toFileInfo().dir().path()), DeployableFile::TypeExecutable); } } } return result; }
QStringList KateProjectWorker::filesFromDarcs(const QDir &dir, bool recursive) { QStringList files; const QString cmd = QStringLiteral("darcs"); QString root; { QProcess darcs; darcs.setWorkingDirectory(dir.absolutePath()); QStringList args; args << QStringLiteral("list") << QStringLiteral("repo"); darcs.start(cmd, args); if (!darcs.waitForStarted() || !darcs.waitForFinished()) return files; auto str = QString::fromLocal8Bit(darcs.readAllStandardOutput()); QRegularExpression exp(QStringLiteral("Root: ([^\\n\\r]*)")); auto match = exp.match(str); if(!match.hasMatch()) return files; root = match.captured(1); } QStringList relFiles; { QProcess darcs; QStringList args; darcs.setWorkingDirectory(dir.absolutePath()); args << QStringLiteral("list") << QStringLiteral("files") << QStringLiteral("--no-directories") << QStringLiteral("--pending"); darcs.start(cmd, args); if(!darcs.waitForStarted() || !darcs.waitForFinished()) return files; relFiles = QString::fromLocal8Bit(darcs.readAllStandardOutput()) .split(QRegularExpression(QStringLiteral("[\n\r]")), QString::SkipEmptyParts); } for (const QString &relFile: relFiles) { const QString path = dir.relativeFilePath(root + QStringLiteral("/") + relFile); if ((!recursive && (relFile.indexOf(QStringLiteral("/")) != -1)) || (recursive && (relFile.indexOf(QStringLiteral("..")) == 0)) ) { continue; } files.append(dir.absoluteFilePath(path)); } return files; }
QVariantMap BareMetalRunConfiguration::toMap() const { QVariantMap map(RunConfiguration::toMap()); const QDir dir = QDir(target()->project()->projectDirectory().toString()); map.insert(QLatin1String(ProFileKey), dir.relativeFilePath(m_projectFilePath)); map.insert(QLatin1String(WorkingDirectoryKey), m_workingDirectory); return map; }
static QString relativeFilePath(const QDir &dir, const QString &fileName) { // Likely a reference to a resource file if (fileName.startsWith(QLatin1Char(':'))) return fileName; return dir.relativeFilePath(fileName); }
QString txEmissionsBase::saveSourceData() const { QDir reportDir; const QString fullPath = reportDir.relativeFilePath(m_fullReportsPath) + QDir::separator() + "SourceData_" + m_calculationOptions->defStandardName( m_calculationOptions->val_standard() ) + "_" + m_currTime + ".dat"; QFile srcData(fullPath); if ( !srcData.open(QFile::WriteOnly) ) { throw txError("Can not open file " + fullPath + "!"); } QTextStream fout(&srcData); fout << right << qSetFieldWidth(COLUMNWIDTH); for ( ptrdiff_t i=0; i<SRCDATACAPTIONS_EMISSIONS.size(); i++ ) { fout << SRCDATACAPTIONS_EMISSIONS[i]; } fout << qSetFieldWidth(0) << "\n" << fixed << qSetFieldWidth(COLUMNWIDTH) << qSetRealNumberPrecision(PRECISION+1); for ( ptrdiff_t i=0; i<m_numberOfPoints; i++ ) { fout << qSetFieldWidth(COLUMNWIDTH); fout << i + 1; fout << ma_n[i] << ma_Me_brutto[i] << ma_Ne_brutto[i] << ma_N_fan[i] << ma_w[i] << ma_t0[i] << ma_B0[i] << ma_Ra[i] << ma_dPn[i] << ma_Gair[i] << ma_Gfuel[i] << ma_CNOx[i] << ma_gNOx[i] << ma_CCO[i] << ma_CCH[i] << ma_CCO2in[i] << ma_CCO2out[i] << ma_CO2[i] << ma_Ka1m[i] << ma_KaPerc[i] << ma_FSN[i] << ma_Pr[i] << ma_ts[i] << ma_tauf[i] << ma_qmdw[i] << ma_qmdew[i] << ma_rd[i]; fout << qSetFieldWidth(0) << "\n"; } srcData.close(); return "libtoxic: Source data file \"" + fullPath + "\" created.\n"; }
Utils::FileName QmlProject::targetFile(const Utils::FileName &sourceFile, const Target *target) const { const QDir sourceDir(m_projectItem ? m_projectItem->sourceDirectory() : canonicalProjectDir().toString()); const QDir targetDir(targetDirectory(target).toString()); const QString relative = sourceDir.relativeFilePath(sourceFile.toString()); return Utils::FileName::fromString(QDir::cleanPath(targetDir.absoluteFilePath(relative))); }
QVariantMap DesktopQmakeRunConfiguration::toMap() const { const QDir projectDir = QDir(target()->project()->projectDirectory().toString()); QVariantMap map(RunConfiguration::toMap()); map.insert(QLatin1String(PRO_FILE_KEY), projectDir.relativeFilePath(m_proFilePath.toString())); map.insert(QLatin1String(USE_DYLD_IMAGE_SUFFIX_KEY), m_isUsingDyldImageSuffix); map.insert(QLatin1String(USE_LIBRARY_SEARCH_PATH), m_isUsingLibrarySearchPath); return map; }
///////////////////// // Helper Function ///////////////////// static QString projectDirRelativeToBuildDir(BuildConfiguration *bc) { const QDir buildDir(bc->buildDirectory().toString()); QString projDirToBuildDir = buildDir.relativeFilePath( bc->target()->project()->projectDirectory().toString()); if (projDirToBuildDir.isEmpty()) return QLatin1String("./"); if (!projDirToBuildDir.endsWith(QLatin1Char('/'))) projDirToBuildDir.append(QLatin1Char('/')); return projDirToBuildDir; }
void Qt4RunConfiguration::save(PersistentSettingsWriter &writer) const { const QDir projectDir = QFileInfo(project()->file()->fileName()).absoluteDir(); writer.saveValue("CommandLineArguments", m_commandLineArguments); writer.saveValue("ProFile", projectDir.relativeFilePath(m_proFilePath)); writer.saveValue("UserSetName", m_userSetName); writer.saveValue("UseTerminal", m_runMode == Console); writer.saveValue("UseDyldImageSuffix", m_isUsingDyldImageSuffix); ApplicationRunConfiguration::save(writer); }
QVariantMap S60DeviceRunConfiguration::toMap() const { QVariantMap map = ProjectExplorer::RunConfiguration::toMap(); const QDir projectDir = QDir(target()->project()->projectDirectory()); map.insert(QLatin1String(PRO_FILE_KEY), projectDir.relativeFilePath(m_proFilePath)); map.insert(QLatin1String(COMMAND_LINE_ARGUMENTS_KEY), m_commandLineArguments); return map; }
QVariantMap RemoteLinuxRunConfiguration::toMap() const { QVariantMap map(RunConfiguration::toMap()); map.insert(QLatin1String(ArgumentsKey), d->arguments); const QDir dir = QDir(target()->project()->projectDirectory()); map.insert(QLatin1String(ProFileKey), dir.relativeFilePath(d->projectFilePath)); map.insert(QLatin1String(UseAlternateExeKey), d->useAlternateRemoteExecutable); map.insert(QLatin1String(AlternateExeKey), d->alternateRemoteExecutable); map.insert(QLatin1String(WorkingDirectoryKey), d->workingDirectory); return map; }
void DataPrimitive::Private::saveFilename(const QString& fn, QXmlStreamWriter& s) { if (!fn.isEmpty()) { // QDir::current is set to *.kst's file path in mainwindow.cpp QDir current = QDir::current(); QString relFn = current.relativeFilePath(fn); s.writeAttribute("file", current.absoluteFilePath(fn)); if (QDir::isRelativePath(relFn)) { // is absolute if on a differnt disk/network s.writeAttribute("fileRelative", relFn); } } }
QStringList Kleo::makeRelativeTo(const QDir &baseDir, const QStringList &fileNames) { QStringList rv; rv.reserve(fileNames.size()); std::transform(fileNames.cbegin(), fileNames.cend(), std::back_inserter(rv), [&baseDir](const QString &file) { return baseDir.relativeFilePath(file); }); return rv; }
QVariantMap DesktopQmakeRunConfiguration::toMap() const { const QDir projectDir = QDir(target()->project()->projectDirectory()); QVariantMap map(LocalApplicationRunConfiguration::toMap()); map.insert(QLatin1String(COMMAND_LINE_ARGUMENTS_KEY), m_commandLineArguments); map.insert(QLatin1String(PRO_FILE_KEY), projectDir.relativeFilePath(m_proFilePath)); map.insert(QLatin1String(USE_TERMINAL_KEY), m_runMode == Console); map.insert(QLatin1String(USE_DYLD_IMAGE_SUFFIX_KEY), m_isUsingDyldImageSuffix); map.insert(QLatin1String(USER_WORKING_DIRECTORY_KEY), m_userWorkingDirectory); return map; }
QVariantMap RemoteLinuxRunConfiguration::toMap() const { QVariantMap map(RunConfiguration::toMap()); map.insert(ArgumentsKey, m_d->arguments); const QDir dir = QDir(target()->project()->projectDirectory()); map.insert(ProFileKey, dir.relativeFilePath(m_d->proFilePath)); map.insert(BaseEnvironmentBaseKey, m_d->baseEnvironmentType); map.insert(UserEnvironmentChangesKey, Utils::EnvironmentItem::toStringList(m_d->userEnvironmentChanges)); map.unite(m_d->remoteMounts->toMap()); return map; }
void CPropBrowserWidget::on_treeView_doubleClicked(const QModelIndex &index) { QDir d; QString filePath; if(!m_model->isDir(index)) { filePath = m_model->filePath(index); filePath = d.relativeFilePath(filePath); emit propFilePathSelected(filePath.toStdString()); } }
QString SyncProcess::updateEntry(const QString & path, const QDir & source, const QDir & destination) { QFileInfo sourceInfo(path); QString relativePath = source.relativeFilePath(path); QString destinationPath = destination.absoluteFilePath(relativePath); QFileInfo destinationInfo(destinationPath); if (sourceInfo.isDir()) { if (!destinationInfo.exists()) { progress->addText(tr("Create directory %1\n").arg(destinationPath)); if (!destination.mkdir(relativePath)) { return QObject::tr("Create '%1' failed").arg(destinationPath); } } } else { if (!destinationInfo.exists()) { // qDebug() << "Copy" << path << "to" << destinationPath; progress->addText(tr("Copy %1 to %2").arg(path).arg(destinationPath) + "\n"); if (!QFile::copy(path, destinationPath)) { return QObject::tr("Copy '%1' to '%2' failed").arg(path).arg(destinationPath); } } else if (sourceInfo.lastModified() > destinationInfo.lastModified()) { // retrieve source contents QFile sourceFile(path); if (!sourceFile.open(QFile::ReadOnly)) { return QObject::tr("Open '%1' failed").arg(path); } QByteArray sourceContents = sourceFile.readAll(); sourceFile.close(); // retrieve destination contents QFile destinationFile(destinationPath); if (!destinationFile.open(QFile::ReadOnly)) { return QObject::tr("Open '%1' failed").arg(destinationPath); } QByteArray destinationContents = destinationFile.readAll(); destinationFile.close(); if (contentsDifferent(sourceContents, destinationContents)) { // copy contents if (!destinationFile.open(QFile::WriteOnly | QIODevice::Truncate)) { return QObject::tr("Write '%1' failed").arg(destinationPath); } progress->addText(tr("Write %1").arg(destinationPath) + "\n"); // qDebug() << "Write" << destinationPath; destinationFile.write(sourceContents); destinationFile.close(); } } } return QString(); }
static void migrateDataDir() { #ifdef Q_OS_MAC QString olddir = QDir::homePath() + QLatin1String("/Library/Preferences/Mumble"); #if QT_VERSION >= 0x050000 QString newdir = QStandardPaths::writableLocation(QStandardPaths::DataLocation); #else QString newdir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); #endif QString linksTo = QFile::readLink(olddir); if (!QFile::exists(newdir) && QFile::exists(olddir) && linksTo.isEmpty()) { QDir d; d.mkpath(newdir + QLatin1String("/..")); if (d.rename(olddir, newdir)) { if (d.cd(QDir::homePath() + QLatin1String("/Library/Preferences"))) { if (QFile::link(d.relativeFilePath(newdir), olddir)) { qWarning("Migrated application data directory from '%s' to '%s'", qPrintable(olddir), qPrintable(newdir)); return; } } } } else { /* Data dir has already been migrated. */ return; } qWarning("Application data migration failed."); #endif // Qt4 used another data directory on Unix-like systems, to ensure a seamless // transition we must first move the users data to the new directory. #if defined(Q_OS_UNIX) && ! defined(Q_OS_MAC) #if QT_VERSION >= 0x050000 QString olddir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/data/Mumble"); QString newdir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/Mumble"); if (!QFile::exists(newdir) && QFile::exists(olddir)) { QDir d; d.mkpath(newdir + QLatin1String("/..")); if (d.rename(olddir, newdir)) { qWarning("Migrated application data directory from '%s' to '%s'", qPrintable(olddir), qPrintable(newdir)); return; } } else { /* Data dir has already been migrated. */ return; } qWarning("Application data migration failed."); #endif #endif }
QmakeBuildInfo *QmakeBuildConfigurationFactory::createBuildInfo(const Kit *k, const QString &projectPath, BuildConfiguration::BuildType type) const { QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k); QmakeBuildInfo *info = new QmakeBuildInfo(this); QString suffix; if (type == BuildConfiguration::Release) { //: The name of the release build configuration created by default for a qmake project. info->displayName = tr("Release"); //: Non-ASCII characters in directory suffix may cause build issues. suffix = tr("Release", "Shadow build directory suffix"); if (version && version->isQtQuickCompilerSupported()) info->config.useQtQuickCompiler = true; } else { if (type == BuildConfiguration::Debug) { //: The name of the debug build configuration created by default for a qmake project. info->displayName = tr("Debug"); //: Non-ASCII characters in directory suffix may cause build issues. suffix = tr("Debug", "Shadow build directory suffix"); } else if (type == BuildConfiguration::Profile) { //: The name of the profile build configuration created by default for a qmake project. info->displayName = tr("Profile"); //: Non-ASCII characters in directory suffix may cause build issues. suffix = tr("Profile", "Shadow build directory suffix"); info->config.separateDebugInfo = true; if (version && version->isQtQuickCompilerSupported()) info->config.useQtQuickCompiler = true; } if (version && version->isQmlDebuggingSupported()) info->config.linkQmlDebuggingQQ2 = true; } info->typeName = info->displayName; // Leave info->buildDirectory unset; info->kitId = k->id(); // check if this project is in the source directory: Utils::FileName projectFilePath = Utils::FileName::fromString(projectPath); if (version && version->isInSourceDirectory(projectFilePath)) { // assemble build directory QString projectDirectory = projectFilePath.toFileInfo().absolutePath(); QDir qtSourceDir = QDir(version->sourcePath().toString()); QString relativeProjectPath = qtSourceDir.relativeFilePath(projectDirectory); QString qtBuildDir = version->versionInfo().value(QStringLiteral("QT_INSTALL_PREFIX")); QString absoluteBuildPath = QDir::cleanPath(qtBuildDir + QLatin1Char('/') + relativeProjectPath); info->buildDirectory = Utils::FileName::fromString(absoluteBuildPath); } else { info->buildDirectory = defaultBuildDirectory(projectPath, k, suffix, type); } info->buildType = type; return info; }
void Controls::on_actionSave_QML_triggered() { QString modelFileName = m_model->fullPath(); QFileInfo fi(modelFileName); QString qmlName = fi.baseName(); qmlName = qmlName.mid(1).prepend(qmlName[0].toUpper()) + ".qml"; QString path = fi.absoluteDir().absoluteFilePath(qmlName); QFileDialog::Options options = 0; #ifdef Q_OS_LINUX // work around data loss bug with KDE: https://bugs.kde.org/show_bug.cgi?id=210904 options = QFileDialog::DontUseNativeDialog; #endif QString file = QFileDialog::getSaveFileName(this, tr("Save QML file"), path, tr("QML files (*.qml)"), 0, options); if (!file.isEmpty()) { QFileInfo fi2(file); QDir d = fi2.absoluteDir(); QString relName = d.relativeFilePath(modelFileName); QString n2 = fi2.baseName(); n2 = n2.mid(1).prepend((n2[0].toUpper())) + ".qml"; file = fi2.absolutePath() + "/" + n2; QmlGenerator gen(file); gen.setProperty("modelFileName", relName); saveSettings(modelFileName); QString options = m_model->getOptions(); if (!options.isEmpty()) gen.setProperty("options", options); QVector3D p = m_view->position(); if (!qFuzzyIsNull(p.x())) gen.setProperty("x_translation", QString::number(p.x())); if (!qFuzzyIsNull(p.y())) gen.setProperty("y_translation", QString::number(p.y())); if (!qFuzzyIsNull(p.z())) gen.setProperty("z_translation", QString::number(p.z())); QVector3D o = m_view->orientation(); if (!qFuzzyIsNull(o.x())) gen.setProperty("x_rotation", QString::number(o.x())); if (!qFuzzyIsNull(o.y())) gen.setProperty("y_rotation", QString::number(o.y())); if (!qFuzzyIsNull(o.z())) gen.setProperty("z_rotation", QString::number(o.z())); QVector3D s = m_view->scale(); if (!qFuzzyIsNull(s.x())) gen.setProperty("x_scale", ((s.x() < 0.0f) ? QString::number(1.0f / qAbs(s.x())) : QString::number(s.x()))); if (!qFuzzyIsNull(s.y())) gen.setProperty("y_scale", ((s.y() < 0.0f) ? QString::number(1.0f / qAbs(s.y())) : QString::number(s.y()))); if (!qFuzzyIsNull(s.z())) gen.setProperty("z_scale", ((s.z() < 0.0f) ? QString::number(1.0f / qAbs(s.z())) : QString::number(s.z()))); gen.save(); } }