本文整理汇总了C++中QFileInfo函数的典型用法代码示例。如果您正苦于以下问题:C++ QFileInfo函数的具体用法?C++ QFileInfo怎么用?C++ QFileInfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QFileInfo函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: QFileInfo
bool QlFiles::isDir(const QString &path){ return QFileInfo(path).isDir(); }
开发者ID:ArpegiusWhooves,项目名称:qserterm,代码行数:1,代码来源:ql-files.cpp
示例2: QString
bool QtDesignerFormClassCodeGenerator::generateCpp(const FormClassWizardParameters ¶meters,
QString *header, QString *source, int indentation)
{
Internal::FormClassWizardGenerationParameters generationParameters;
generationParameters.fromSettings(Core::ICore::settings());
const QString indent = QString(indentation, QLatin1Char(' '));
QString formBaseClass;
QString uiClassName;
if (!Internal::FormTemplateWizardPage::getUIXmlData(parameters.uiTemplate, &formBaseClass, &uiClassName)) {
qWarning("Unable to determine the form base class from %s.", qPrintable(parameters.uiTemplate));
return false;
}
// Build the ui class (Ui::Foo) name relative to the namespace (which is the same):
const QString colonColon = QLatin1String("::");
const int lastSeparator = uiClassName.lastIndexOf(colonColon);
if (lastSeparator != -1)
uiClassName.remove(0, lastSeparator + colonColon.size());
uiClassName.insert(0, QLatin1String(uiNamespaceC) + colonColon);
// Do we have namespaces?
QStringList namespaceList = parameters.className.split(colonColon);
if (namespaceList.empty()) // Paranoia!
return false;
const QString unqualifiedClassName = namespaceList.takeLast();
const QString headerLicense =
CppTools::AbstractEditorSupport::licenseTemplate(parameters.headerFile, parameters.className);
const QString sourceLicense =
CppTools::AbstractEditorSupport::licenseTemplate(parameters.sourceFile, parameters.className);
// Include guards
const QString guard = Utils::headerGuard(parameters.headerFile, namespaceList);
QString uiInclude = QLatin1String("ui_");
uiInclude += QFileInfo(parameters.uiFile).completeBaseName();
uiInclude += QLatin1String(".h");
// 1) Header file
QTextStream headerStr(header);
headerStr << headerLicense << "#ifndef " << guard
<< "\n#define " << guard << '\n' << '\n';
// Include 'ui_'
if (generationParameters.embedding != Internal::PointerAggregatedUiClass) {
Utils::writeIncludeFileDirective(uiInclude, false, headerStr);
} else {
// Todo: Can we obtain the header from the code model for custom widgets?
// Alternatively, from Designer.
if (formBaseClass.startsWith(QLatin1Char('Q'))) {
if (generationParameters.includeQtModule) {
if (generationParameters.addQtVersionCheck) {
Utils::writeBeginQtVersionCheck(headerStr);
Utils::writeIncludeFileDirective(QLatin1String("QtWidgets/") + formBaseClass, true, headerStr);
headerStr << "#else\n";
Utils::writeIncludeFileDirective(QLatin1String("QtGui/") + formBaseClass, true, headerStr);
headerStr << "#endif\n";
} else {
Utils::writeIncludeFileDirective(QLatin1String("QtGui/") + formBaseClass, true, headerStr);
}
} else {
Utils::writeIncludeFileDirective(formBaseClass, true, headerStr);
}
}
}
const QString namespaceIndent = Utils::writeOpeningNameSpaces(namespaceList,
generationParameters.indentNamespace ? indent : QString(),
headerStr);
// Forward-declare the UI class
if (generationParameters.embedding == Internal::PointerAggregatedUiClass) {
headerStr << '\n'
<< namespaceIndent << "namespace " << uiNamespaceC << " {\n"
<< namespaceIndent << indent << "class " << Internal::FormTemplateWizardPage::stripNamespaces(uiClassName) << ";\n"
<< namespaceIndent << "}\n";
}
// Class declaration
headerStr << '\n' << namespaceIndent << "class " << unqualifiedClassName
<< " : public " << formBaseClass;
if (generationParameters.embedding == Internal::InheritedUiClass)
headerStr << ", private " << uiClassName;
headerStr << "\n{\n" << namespaceIndent << indent << "Q_OBJECT\n\n"
<< namespaceIndent << "public:\n"
<< namespaceIndent << indent << "explicit " << unqualifiedClassName << "(QWidget *parent = 0);\n";
if (generationParameters.embedding == Internal::PointerAggregatedUiClass)
headerStr << namespaceIndent << indent << "~" << unqualifiedClassName << "();\n";
// retranslation
if (generationParameters.retranslationSupport)
headerStr << '\n' << namespaceIndent << "protected:\n"
<< namespaceIndent << indent << "void changeEvent(QEvent *e);\n";
// Member variable
if (generationParameters.embedding != Internal::InheritedUiClass) {
headerStr << '\n' << namespaceIndent << "private:\n"
<< namespaceIndent << indent << uiClassName << ' ';
if (generationParameters.embedding == Internal::PointerAggregatedUiClass)
headerStr << '*';
//.........这里部分代码省略.........
开发者ID:FlavioFalcao,项目名称:qt-creator,代码行数:101,代码来源:qtdesignerformclasscodegenerator.cpp
示例3: QFileInfo
QString ImageDisplay::strippedName(const QString &fullFileName)
{
return QFileInfo(fullFileName).fileName();
}
开发者ID:bpoje,项目名称:dct,代码行数:4,代码来源:ImageDisplay.cpp
示例4: QString
//MTL PARSER INSPIRED FROM KIXOR.NET "objloader" (http://www.kixor.net/dev/objloader/)
bool ccMaterialSet::ParseMTL(QString path, const QString& filename, ccMaterialSet &materials, QStringList& errors)
{
//open mtl file
QString fullPathFilename = path + QString('/') + filename;
QFile file(fullPathFilename);
if (!file.open(QFile::ReadOnly))
{
errors << QString("Error reading file: %1").arg(filename);
return false;
}
//update path (if the input filename has already a relative path)
path = QFileInfo(fullPathFilename).absolutePath();
QTextStream stream(&file);
QString currentLine = stream.readLine();
unsigned currentLineIndex = 0;
ccMaterial::Shared currentMaterial(0);
while( !currentLine.isNull() )
{
++currentLineIndex;
QStringList tokens = currentLine.split(QRegExp("\\s+"),QString::SkipEmptyParts);
//skip comments & empty lines
if( tokens.empty() || tokens.front().startsWith('/',Qt::CaseInsensitive) || tokens.front().startsWith('#',Qt::CaseInsensitive) )
{
currentLine = stream.readLine();
continue;
}
//start material
if (tokens.front() == "newmtl")
{
//push the previous material (if any)
if (currentMaterial)
{
materials.addMaterial(currentMaterial);
currentMaterial = ccMaterial::Shared(0);
}
// get the name
QString materialName = currentLine.mid(7).trimmed(); //we must take the whole line! (see OBJ filter)
if (materialName.isEmpty())
materialName = "undefined";
currentMaterial = ccMaterial::Shared(new ccMaterial(materialName));
}
else if (currentMaterial) //we already have a "current" material
{
//ambient
if (tokens.front() == "Ka")
{
if (tokens.size() > 3)
{
ccColor::Rgbaf ambient( tokens[1].toFloat(),
tokens[2].toFloat(),
tokens[3].toFloat(),
1.0f);
currentMaterial->setAmbient(ambient);
}
}
//diff
else if (tokens.front() == "Kd")
{
if (tokens.size() > 3)
{
ccColor::Rgbaf diffuse( tokens[1].toFloat(),
tokens[2].toFloat(),
tokens[3].toFloat(),
1.0f);
currentMaterial->setDiffuse(diffuse);
}
}
//specular
else if (tokens.front() == "Ks")
{
if (tokens.size() > 3)
{
ccColor::Rgbaf specular(tokens[1].toFloat(),
tokens[2].toFloat(),
tokens[3].toFloat(),
1.0f);
currentMaterial->setSpecular(specular);
}
}
//shiny
else if (tokens.front() == "Ns")
{
if (tokens.size() > 1)
currentMaterial->setShininess(tokens[1].toFloat());
}
//transparent
else if (tokens.front() == "d" || tokens.front() == "Tr")
{
if (tokens.size() > 1)
//.........这里部分代码省略.........
开发者ID:rotorliu,项目名称:trunk,代码行数:101,代码来源:ccMaterialSet.cpp
示例5: assert
void qSRA::loadProfile()
{
assert(m_app);
if (!m_app)
return;
//persistent settings (default import path)
QSettings settings;
settings.beginGroup("qSRA");
QString path = settings.value("importPath",QApplication::applicationDirPath()).toString();
ProfileImportDlg piDlg(m_app->getMainWindow());
piDlg.setDefaultFilename(path);
if (!piDlg.exec())
return;
QString filename = piDlg.getFilename();
if (filename.isEmpty())
return;
//save current import path to persistent settings
settings.setValue("importPath",QFileInfo(filename).absolutePath());
//get the user defined global axis
int axisDim = piDlg.getAxisDimension();
//get whether heights are expressed relatively to 0 or to the input center
bool ignoreAxisShift = piDlg.ignoreAxisShift();
//load profile as a (2D) polyline
ccPolyline* polyline = ProfileLoader::Load(filename,ignoreAxisShift,axisDim,m_app);
if (polyline)
{
//apply a visual transformation to see the polyline in the right place!
ccPointCloud* vertices = dynamic_cast<ccPointCloud*>(polyline->getAssociatedCloud());
if (vertices)
{
const CCVector3d& O = vertices->getGlobalShift();
ccGLMatrix trans;
trans.setTranslation(CCVector3::fromArray(O.u));
float* mat = trans.data();
switch(axisDim)
{
case 0: //X
//invert X and Y
mat[0] = 0; mat[1] = 1;
mat[4] = 1; mat[5] = 0;
break;
//case 1: //Y
case 2: //Z
//invert Z and Y
mat[5] = 0; mat[6] = 1;
mat[9] = 1; mat[10] = 0;
break;
default:
//nothing to do
break;
}
polyline->set2DMode(false);
polyline->setGLTransformation(trans);
}
//add revolution axis as meta-data
DistanceMapGenerationTool::SetPoylineAxis(polyline,axisDim);
//default destination container
ccHObject* defaultContainer = GetDefaultContainer(m_app);
if (defaultContainer)
defaultContainer->addChild(polyline);
m_app->addToDB(polyline,false);
m_app->dispToConsole(QString("[qSRA] File '%1' succesfully loaded").arg(filename),ccMainAppInterface::STD_CONSOLE_MESSAGE);
}
else
{
m_app->dispToConsole(QString("Failed to load file '%1'!").arg(filename),ccMainAppInterface::ERR_CONSOLE_MESSAGE);
}
}
开发者ID:imight,项目名称:trunk,代码行数:81,代码来源:qSRA.cpp
示例6: QFileInfo
bool RazorPluginInfo::load(const QString& fileName)
{
XdgDesktopFile::load(fileName);
mId = QFileInfo(fileName).completeBaseName();
return isValid();
}
开发者ID:grimtraveller,项目名称:netbas,代码行数:6,代码来源:razorplugininfo.cpp
示例7: QFileInfo
QString ModelFileImpl::workPath() const
{
return QFileInfo(m_fileName).absolutePath();
}
开发者ID:AChinaProgrammer,项目名称:liteide,代码行数:4,代码来源:modelfileimpl.cpp
示例8: ModPlusCtrls
Optimization::Optimization(QDomElement domProblem,Project* project,bool &ok)
:Problem((ProjectBase*)project)
{
// initialization
_omProject = project;
_algos = OptimAlgoUtils::getNewAlgos(this);
// look for modmodelplus
ok = !domProblem.isNull();
ok = ok && (domProblem.tagName()==Optimization::className());
if(ok)
{
QDomElement domInfos = domProblem.firstChildElement("Infos");
this->setName(domInfos.attribute("name", "" ));
// compatibility with older saving format (one model, saved in Infos node)
if(!domInfos.attribute("model").isEmpty())
{
QString modelName = domInfos.attribute("model");
ModModelPlus* model = project->modModelPlus(modelName);
// read corresponding controlers
QDomElement domCtrls = domProblem.firstChildElement(ModPlusCtrls::className());
ModPlusCtrls* ctrls = new ModPlusCtrls(project,model,domCtrls);
// add model
this->addModel(domInfos.attribute("model"));
}
// new format
QDomElement domModels = domProblem.firstChildElement("Models");
QDomElement domModel = domModels.firstChildElement("Model");
while(!domModel.isNull())
{
QString modelName = domModel.attribute("name");
ModModelPlus* model = project->modModelPlus(modelName);
// read corresponding controlers
QDomElement domCtrls = domModel.firstChildElement(ModPlusCtrls::className());
ModPlusCtrls* ctrls = new ModPlusCtrls(project,model,domCtrls);
// add model and controlers
this->addModel(modelName,ctrls);
domModel = domModel.nextSiblingElement("Model");
}
}
//initialize default(otherwise seg fault in destructor)
_optimizedVariables = new OptVariables(true);
_scannedVariables = new ScannedVariables(true);
_overwritedVariables = new Variables(true);
_objectives = new OptObjectives(true);
// Optimized Variables
QDomElement domOptVars = domProblem.firstChildElement("OptimizedVariables");
this->optimizedVariables()->setItems(domOptVars);
// Objectives
QDomElement domObj = domProblem.firstChildElement("Objectives");
this->objectives()->setItems(domObj);
// Scanned Variables
QDomElement domScann = domProblem.firstChildElement("ScannedVariables");
this->scannedVariables()->setItems(domScann);
// Overvars Variables
QDomElement domOverVars = domProblem.firstChildElement("OverwritedVariables");
this->overwritedVariables()->setItems(domOverVars);
for(int i=0;i<overwritedVariables()->size();i++)
overwritedVariables()->at(i)->setIsEditableField(Variable::VALUE,true);
// Files to copy
QDomElement cFilesToCopy = domProblem.firstChildElement("FilesToCopy");
QString text = cFilesToCopy.text();
QStringList strList = text.split("\n",QString::SkipEmptyParts);
for(int i=0;i<strList.size();i++)
this->_filesToCopy.push_back(QFileInfo(strList.at(i)));
// BlockSubstitutions
QDomElement domBlockSubs = domProblem.firstChildElement("BlockSubstitutions");
_blockSubstitutions = new BlockSubstitutions(project,domBlockSubs);
// EA
QDomElement domEA = domProblem.firstChildElement("EA");
QDomElement domEAInfos = domEA.firstChildElement("Infos");
if(!domEAInfos.isNull())
{
this->setiCurAlgo(domEAInfos.attribute("num", "" ).toInt());
}
QDomElement domEAParameters = domEA.firstChildElement("Parameters");
if(!domEAParameters.isNull())
{
this->getCurAlgo()->_parameters->update(domEAParameters);
}
}
开发者ID:SemiSQ,项目名称:OpenModelica,代码行数:100,代码来源:Optimization.cpp
示例9: QFileInfo
QString SoulNote::strippedName(const QString &fullFileName)
{
return QFileInfo(fullFileName).fileName();
}
开发者ID:thesoulless,项目名称:SoulNote,代码行数:4,代码来源:soulnote.cpp
示例10: main
//.........这里部分代码省略.........
KstEquationPtr eq = new KstEquation(KST::suggestEQName(eqS), eqS, min, max, n);
KstVCurvePtr vc = new KstVCurve(KST::suggestCurveName(eq->tag(), true),
eq->vX(), eq->vY(), 0L, 0L, 0L, 0L,
KstColorSequence::next(vcurves,plot->backgroundColor()));
KST::dataObjectList.lock().writeLock();
KST::dataObjectList.append(eq.data());
KST::dataObjectList.append(vc.data());
KST::dataObjectList.lock().unlock();
plot->addCurve(vc.data());
if (in.sep_plots) {
i_plot++;
if (i_plot < in.n_plots) {
plot = *plist.at(i_plot);
}
}
}
handled++;
kst->slotUpdateProgress( count, handled, creatingEquations );
}
}
}
}
// make the requested curves for each data file
count = args->count();
handled = 0;
kst->slotUpdateProgress( count, handled, creatingCurves );
for (i_curve = i_v = 0, i_file = 0; i_file < args->count(); i_file++) {
// make the file
if (QFile::exists(args->arg(i_file))) {
fullPath = QFileInfo(args->arg(i_file)).absFilePath();
} else {
fullPath = args->arg(i_file);
}
KstDataSourcePtr file = KstDataSource::loadSource(fullPath);
if (file) {
if (!file->isValid() || file->isEmpty()) {
kstdError() << i18n("No data in file %1. Trying to continue...").arg(args->arg(i_file)) << endl;
// The file might get data later!
}
KST::dataObjectList.lock().writeLock();
KST::dataSourceList.append(file);
KST::dataObjectList.lock().unlock();
KstRVectorPtr yvector;
KstRVectorPtr evector;
KstVCurvePtr curve;
KstPSDPtr psd;
KstHistogramPtr hs;
KstRVectorPtr xvector;
if (!ycolList.isEmpty()) { // if there are some xy plots
// make the x axis vector
xvector = GetOrCreateVector(args->getOption("x"), file, in);
if (xvector) {
// make the y axis vectors
for (i_ycol = 0; i_ycol < ycolList.count(); ++i_ycol ) {
yvector = GetOrCreateVector(*(ycolList.at(i_ycol)), file, in);
if (yvector) {
// make the curves
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:67,代码来源:main.cpp
示例11: assert
CC_FILE_ERROR PovFilter::saveToFile(ccHObject* entity, const char* filename)
{
if (!entity || !filename)
return CC_FERR_BAD_ARGUMENT;
ccHObject::Container hClouds;
entity->filterChildren(hClouds,false,CC_POINT_CLOUD);
if (hClouds.empty())
return CC_FERR_NO_SAVE;
unsigned i;
std::vector<ccGBLSensor*> sensors;
std::vector<ccGenericPointCloud*> clouds;
for (i=0;hClouds.size();++i)
{
ccHObject::Container cloudSensors;
hClouds[i]->filterChildren(cloudSensors,false,CC_GBL_SENSOR);
if (!cloudSensors.empty())
{
clouds.push_back(ccHObjectCaster::ToGenericPointCloud(hClouds[i]));
if (cloudSensors.size()>1)
ccLog::Warning(QString("Found more than one ground-based LIDAR sensor associated to entity '%1'. Only the first will be saved!").arg(hClouds[i]->getName()));
sensors.push_back(static_cast<ccGBLSensor*>(cloudSensors[0]));
}
}
assert(sensors.size() == clouds.size());
if (sensors.empty())
return CC_FERR_NO_SAVE;
//FIXME
//the first GLS sensor will be used as reference! (ugly)
ccGBLSensor* firstGls = sensors.front();
if (sensors.size()>1)
ccLog::Warning("Assuming all sensors are equivalent...");
//we extract the body of the filename (without extension)
QString fullBaseName = QFileInfo(filename).completeBaseName();
//main file (.POV)
FILE* mainFile = fopen(filename,"wt");
if (!mainFile)
return CC_FERR_WRITING;
if (fprintf(mainFile,"#CC_POVS_FILE\n")<0)
{
fclose(mainFile);
return CC_FERR_WRITING;
};
if (fprintf(mainFile,"SENSOR_TYPE = %s\n",CC_SENSOR_ROTATION_ORDER_NAMES[firstGls->getRotationOrder()])<0)
{
fclose(mainFile);
return CC_FERR_WRITING;
};
if (fprintf(mainFile,"SENSOR_BASE = %f\n",firstGls->getSensorBase())<0)
{
fclose(mainFile);
return CC_FERR_WRITING;
};
if (fprintf(mainFile,"UNITS = IGNORED\n")<0)
{
fclose(mainFile);
return CC_FERR_WRITING;
};
if (fprintf(mainFile,"#END_HEADER\n")<0)
{
fclose(mainFile);
return CC_FERR_WRITING;
};
for (i=0;i<clouds.size();++i)
{
QString thisFilename = fullBaseName + QString("_%1.bin").arg(i);
CC_FILE_ERROR error = FileIOFilter::SaveToFile(clouds[i],qPrintable(thisFilename),BIN);
if (error != CC_FERR_NO_ERROR)
{
fclose(mainFile);
return error;
}
ccGBLSensor* gls = sensors[i];
//il faut ecrire le nom du fichier relatif et non absolu !
int result = fprintf(mainFile,"\n#POV %i\nF %s\nT ASC\n",i,qPrintable(QFileInfo(thisFilename).fileName()));
if (result>0)
{
CCVector3 C = gls->getSensorCenter();
result = fprintf(mainFile,"C %f %f %f\n",C[0],C[1],C[2]);
if (result>0)
{
const float* mat = gls->getOrientationMatrix().data();
result = fprintf(mainFile,"X %f %f %f\n",mat[0],mat[4],mat[8]);
result = fprintf(mainFile,"Y %f %f %f\n",mat[1],mat[5],mat[9]);
result = fprintf(mainFile,"Z %f %f %f\n",mat[2],mat[6],mat[10]);
//.........这里部分代码省略.........
开发者ID:kod3r,项目名称:trunk,代码行数:101,代码来源:PovFilter.cpp
示例12: QFileInfo
void QrcEditor::resolveLocationIssues(QStringList &files)
{
const QDir dir = QFileInfo(m_treeview->fileName()).absoluteDir();
const QString dotdotSlash = QLatin1String("../");
int i = 0;
int count = 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
bool abort = false;
for (; i < count; i++) {
// Path fine -> skip file
QString const &file = files.at(i);
QString const relativePath = dir.relativeFilePath(file);
if (!relativePath.startsWith(dotdotSlash)) {
continue;
}
// Path troublesome and aborted -> remove file
if (abort) {
files.removeAt(i);
count--;
i--;
continue;
} else {
// Path troublesome -> query user
QMessageBox message(this);
message.setWindowTitle(tr("Invalid file"));
message.setIcon(QMessageBox::Warning);
QPushButton * const continueButton = message.addButton(tr("Add anyway"), QMessageBox::AcceptRole);
QPushButton * const copyButton = message.addButton(tr("Copy"), QMessageBox::ActionRole);
QPushButton * const skipButton = message.addButton(tr("Don't add"), QMessageBox::DestructiveRole);
QPushButton * const abortButton = message.addButton(tr("Abort"), QMessageBox::RejectRole);
message.setDefaultButton(copyButton);
message.setEscapeButton(skipButton);
message.setText(tr("The file %1 is not in a subdirectory of the resource file. Continuing will result in an invalid resource file.")
.arg(QDir::toNativeSeparators(file)));
message.exec();
if (message.clickedButton() == continueButton) {
continue;
} else if (message.clickedButton() == skipButton) {
files.removeAt(i);
count--;
i--; // Compensate i++
} else if (message.clickedButton() == copyButton) {
const QFileInfo fi(file);
const QFileInfo suggestion(dir, fi.fileName());
const QString copyName = QFileDialog::getSaveFileName(this, tr("Choose copy location"),
suggestion.absoluteFilePath());
if (!copyName.isEmpty()) {
if (QFile::exists(copyName)) {
if (!QFile::remove(copyName)) {
QMessageBox::critical(this, tr("Overwrite failed"),
tr("Could not overwrite file %1.")
.arg(QDir::toNativeSeparators(copyName)));
// Remove file
files.removeAt(i);
count--;
i--; // Compensate i++
continue;
}
}
if (!QFile::copy(file, copyName)) {
QMessageBox::critical(this, tr("Copying failed"),
tr("Could not copy the file to %1.")
.arg(QDir::toNativeSeparators(copyName)));
// Remove file
files.removeAt(i);
count--;
i--; // Compensate i++
continue;
}
files[i] = copyName;
} else {
// Remove file
files.removeAt(i);
count--;
i--; // Compensate i++
}
} else if (message.clickedButton() == abortButton) {
abort = true;
files.removeAt(i);
count--;
i--; // Compensate i++
}
}
}
//.........这里部分代码省略.........
开发者ID:ramons03,项目名称:qt-creator,代码行数:101,代码来源:qrceditor.cpp
示例13: lock
bool RemotePlugin::init( const QString &pluginExecutable,
bool waitForInitDoneMsg )
{
lock();
if( m_failed )
{
#ifdef SYNC_WITH_SHM_FIFO
reset( new shmFifo(), new shmFifo() );
#endif
m_failed = false;
}
QString exec = QFileInfo(QDir("plugins:"), pluginExecutable).absoluteFilePath();
#ifdef LMMS_BUILD_APPLE
// search current directory first
QString curDir = QCoreApplication::applicationDirPath() + "/" + pluginExecutable;
if( QFile( curDir ).exists() )
{
exec = curDir;
}
#endif
#ifdef LMMS_BUILD_WIN32
if( ! exec.endsWith( ".exe", Qt::CaseInsensitive ) )
{
exec += ".exe";
}
#endif
if( ! QFile( exec ).exists() )
{
qWarning( "Remote plugin '%s' not found.",
exec.toUtf8().constData() );
m_failed = true;
invalidate();
unlock();
return failed();
}
QStringList args;
#ifdef SYNC_WITH_SHM_FIFO
// swap in and out for bidirectional communication
args << QString::number( out()->shmKey() );
args << QString::number( in()->shmKey() );
#else
args << m_socketFile;
#endif
#ifndef DEBUG_REMOTE_PLUGIN
m_process.setProcessChannelMode( QProcess::ForwardedChannels );
m_process.setWorkingDirectory( QCoreApplication::applicationDirPath() );
m_process.start( exec, args );
m_watcher.start( QThread::LowestPriority );
#else
qDebug() << exec << args;
#endif
connect( &m_process, SIGNAL( finished( int, QProcess::ExitStatus ) ),
this, SLOT( processFinished( int, QProcess::ExitStatus ) ) );
#ifndef SYNC_WITH_SHM_FIFO
struct pollfd pollin;
pollin.fd = m_server;
pollin.events = POLLIN;
switch ( poll( &pollin, 1, 30000 ) )
{
case -1:
qWarning( "Unexpected poll error." );
break;
case 0:
qWarning( "Remote plugin did not connect." );
break;
default:
m_socket = accept( m_server, NULL, NULL );
if ( m_socket == -1 )
{
qWarning( "Unexpected socket error." );
}
}
#endif
resizeSharedProcessingMemory();
if( waitForInitDoneMsg )
{
waitForInitDone();
}
unlock();
return failed();
}
开发者ID:RebeccaDeField,项目名称:lmms,代码行数:91,代码来源:RemotePlugin.cpp
示例14: arg
void ScribusQApp::parseCommandLine()
{
showSplash=!neverSplashExists();
QString arg("");
bool usage=false;
bool header=false;
bool availlangs=false;
bool version=false;
bool runUpgradeCheck=false;
showFontInfo=false;
showProfileInfo=false;
swapDialogButtonOrder=false;
//Parse for command line information options, and lang
for(int i = 1; i < argc(); i++)
{
arg = argv()[i];
if ((arg == ARG_LANG || arg == ARG_LANG_SHORT) && (++i < argc())) {
lang = argv()[i];
}
else if (arg == ARG_VERSION || arg == ARG_VERSION_SHORT) {
header=true;
version=true;
} else if (arg == ARG_HELP || arg == ARG_HELP_SHORT) {
header=true;
usage=true;
} else if (arg == ARG_AVAILLANG || arg == ARG_AVAILLANG_SHORT) {
header=true;
availlangs=true;
} else if (arg == ARG_UPGRADECHECK || arg == ARG_UPGRADECHECK_SHORT) {
header=true;
runUpgradeCheck=true;
}
}
//Init translations
initLang();
//Show command line help
if (header)
showHeader();
if (version)
showVersion();
if (availlangs)
showAvailLangs();
if (usage)
showUsage();
if (runUpgradeCheck)
{
UpgradeChecker uc;
uc.fetch();
}
//Dont run the GUI init process called from main.cpp, and return
if (!header)
useGUI=true;
else
return;
//We are going to run something other than command line help
for(int i = 1; i < argc(); i++) {
arg = argv()[i];
if ((arg == ARG_LANG || arg == ARG_LANG_SHORT) && (++i < argc())) {
continue;
} else if ( arg == ARG_CONSOLE || arg == ARG_CONSOLE_SHORT ) {
continue;
} else if (arg == ARG_NOSPLASH || arg == ARG_NOSPLASH_SHORT) {
showSplash = false;
}
else if (arg == ARG_NEVERSPLASH || arg == ARG_NEVERSPLASH_SHORT) {
showSplash = false;
neverSplash(true);
} else if (arg == ARG_NOGUI || arg == ARG_NOGUI_SHORT) {
useGUI=false;
} else if (arg == ARG_FONTINFO || arg == ARG_FONTINFO_SHORT) {
showFontInfo=true;
} else if (arg == ARG_PROFILEINFO || arg == ARG_PROFILEINFO_SHORT) {
showProfileInfo=true;
} else if (arg == ARG_SWAPDIABUTTONS || arg == ARG_SWAPDIABUTTONS_SHORT) {
swapDialogButtonOrder=true;
} else if ((arg == ARG_DISPLAY || arg==ARG_DISPLAY_SHORT || arg==ARG_DISPLAY_QT) && ++i < argc()) {
// allow setting of display, QT expect the option -display <display_name> so we discard the
// last argument. FIXME: Qt only understands -display not --display and -d , we need to work
// around this.
} else if (arg == ARG_PREFS || arg == ARG_PREFS_SHORT) {
prefsUserFile = QFile::decodeName(argv()[i + 1]);
if (!QFileInfo(prefsUserFile).exists()) {
showHeader();
if (fileName.left(1) == "-" || fileName.left(2) == "--") {
std::cout << tr("Invalid argument: ").toLocal8Bit().data() << fileName.toLocal8Bit().data() << std::endl;
} else {
std::cout << tr("File %1 does not exist, aborting.").arg(fileName).toLocal8Bit().data() << std::endl;
}
showUsage();
useGUI=false;
return;
} else {
++i;
}
} else if (strncmp(arg.toLocal8Bit().data(),"-psn_",4) == 0)
{
// Andreas Vox: Qt/Mac has -psn_blah flags that must be accepted.
//.........这里部分代码省略.........
开发者ID:pvanek,项目名称:scribus-cuba-1.5.0,代码行数:101,代码来源:scribusapp.cpp
示例15: main
//.........这里部分代码省略.........
type = PrinterType;
highres = true;
} else if (option == "printdialog") {
type = PrinterType;
printdlg = true;
}
else if (option == "grab")
type = GrabType;
else if (option == "i")
interactive = true;
else if (option == "v")
verboseMode = true;
else if (option == "commands") {
displayCommands();
return 0;
} else if (option == "w") {
Q_ASSERT_X(i + 1 < argc, "main", "-w must be followed by a value");
width = atoi(argv[++i]);
} else if (option == "h") {
Q_ASSERT_X(i + 1 < argc, "main", "-h must be followed by a value");
height = atoi(argv[++i]);
} else if (option == "scalefactor") {
Q_ASSERT_X(i + 1 < argc, "main", "-scalefactor must be followed by a value");
scalefactor = atof(argv[++i]);
} else if (option == "cmp") {
show_cmp = true;
} else if (option == "bg-white") {
checkers_background = false;
}
} else {
#if defined (Q_WS_WIN)
QString input = QString::fromLocal8Bit(argv[i]);
if (input.indexOf('*') >= 0) {
QFileInfo info(input);
QDir dir = info.dir();
QFileInfoList infos = dir.entryInfoList(QStringList(info.fileName()));
for (int ii=0; ii<infos.size(); ++ii)
files.append(infos.at(ii).absoluteFilePath());
} else {
files.append(input);
}
#else
files.append(QString(argv[i]));
#endif
}
}
scaledWidth = width * scalefactor;
scaledHeight = height * scalefactor;
PaintCommands pcmd(QStringList(), 800, 800);
pcmd.setVerboseMode(verboseMode);
pcmd.setType(type);
pcmd.setCheckersBackground(checkers_background);
QWidget *activeWidget = 0;
if (interactive) {
runInteractive();
if (!files.isEmpty())
interactive_widget->load(files.at(0));
} else if (files.isEmpty()) {
printHelp();
return 0;
} else {
for (int j=0; j<files.size(); ++j) {
const QString &fileName = files.at(j);
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:67,代码来源:main.cpp
示例16: QFileInfo
QStringList ScribusQApp::getLang(QString lang)
{
QStringList langs;
// read the locales
if (!lang.isEmpty())
langs.push_back(lang);
//add in user preferences lang, only overridden by lang command line option
QString Pff = QDir::toNativeSeparators(ScPaths::getApplicationDataDir());
QFileInfo Pffi = QFileInfo(Pff);
if (Pffi.exists())
{
QString PrefsPfad;
if (Pffi.isDir())
PrefsPfad = Pff;
else
PrefsPfad = QDir::homePath();
QString prefsXMLFile=QDir::toNativeSeparators(PrefsPfad + "/prefs140.xml");
QFileInfo infoPrefsFile(prefsXMLFile);
if (infoPrefsFile.exists())
{
PrefsFile* prefsFile = new PrefsFile(prefsXMLFile);
if (prefsFile) {
PrefsContext* userprefsContext = prefsFile->getContext("user_preferences");
if (userprefsContext) {
QString prefslang = userprefsContext->get("gui_language","");
if (!prefslang.isEmpty())
langs.push_back(prefslang);
}
}
delete prefsFile;
}
}
if (!(lang = ::getenv("LC_ALL")).isEmpty())
langs.push_back(lang);
if (!(lang = ::getenv("LC_MESSAGES")).isEmpty())
langs.push_back(lang);
if (!(lang = ::getenv("LANG")).isEmpty())
langs.push_back(lang);
#if defined(_WIN32)
wchar_t out[256];
QString language, sublanguage;
LCID lcIdo = GetUserDefaultLCID();
WORD sortId = SORTIDFROMLCID(lcIdo);
LANGID langId = GetUserDefaultUILanguage();
LCID lcIdn = MAKELCID(langId, sortId);
if ( GetLocaleInfoW(lcIdn, LOCALE_SISO639LANGNAME , out, 255) )
{
language = QString::fromUtf16( (ushort*)out );
if ( GetLocaleInfoW(lcIdn, LOCALE_SISO3166CTRYNAME, out, 255) )
{
sublanguage = QString::fromUtf16( (ushort*)out ).toLower();
lang = language;
if ( sublanguage != language && !sublanguage.isEmpty() )
lang += "_" + sublanguage.toUpper();
langs.push_back(lang);
}
}
#endif
langs.push_back(QString(QLocale::system().name()));
// remove duplicate entries...
QStringList::Iterator it = langs.end();
while (it != langs.begin())
{
--it;
if (langs.count(*it) > 1)
it = langs.erase(it);
}
return langs;
}
开发者ID:pvanek,项目名称:scribus-cuba-1.5.0,代码行数:76,代码来源:scribusapp.cpp
示例17: lcGetProfileInt
//.........这里部分代码省略.........
{
if (SaveImage || SaveWavefront || Save3DS)
{
fprintf(stderr, "ERROR: Cannot load pieces library.");
return false;
}
if (mLibrary->LoadBuiltinPieces())
QMessageBox::information(gMainWindow, tr("LeoCAD"), tr("LeoCAD could not find a compatible Parts Library so only a small number of parts will be available.\n\n"
"Please visit http://www.leocad.org for information on how to download and install a library."));
else
QMessageBox::information(gMainWindow, tr("LeoCAD"), tr("LeoCAD could not load Parts Library.\n\n"
"Please visit http://www.leocad.org for information on how to download and install a library."));
}
gMainWindow->CreateWidgets();
// Create a new project.
Project* NewProject = new Project();
SetProject(NewProject);
// Load project.
if (ProjectName && gMainWindow->OpenProject(ProjectName))
{
if (SaveImage)
{
QString FileName;
if (ImageName)
FileName = ImageName;
else
FileName = ProjectName;
QString Extension = QFileInfo(FileName).suffix().toLower();
if (Extension.isEmpty())
{
FileName += lcGetProfileString(LC_PROFILE_IMAGE_EXTENSION);
}
else if (Extension != "bmp" && Extension != "jpg" && Extension != "jpeg" && Extension != "png")
{
FileName = FileName.left(FileName.length() - Extension.length() - 1);
FileName += lcGetProfileString(LC_PROFILE_IMAGE_EXTENSION);
}
if (ImageEnd < ImageStart)
ImageEnd = ImageStart;
else if (ImageStart > ImageEnd)
ImageStart = ImageEnd;
if ((ImageStart == 0) && (ImageEnd == 0))
{
ImageStart = ImageEnd = mProject->GetActiveModel()->GetCurrentStep();
}
else if ((ImageStart == 0) && (ImageEnd != 0))
{
ImageStart = ImageEnd;
}
else if ((ImageStart != 0) && (ImageEnd == 0))
{
ImageEnd = ImageStart;
}
if (ImageStart > 255)
ImageStart = 255;
开发者ID:ldraw-linux,项目名称:leocad,代码行数:66,代码来源:lc_application.cpp
示例18: fileLoading
void sf2Instrument::openFile( const QString & _sf2File, bool updateTrackName )
{
emit fileLoading();
// Used for loading file
char * sf2Ascii = qstrdup( qPrintable( SampleBuffer::tryToMakeAbsolute( _sf2File ) ) );
QString relativePath = SampleBuffer::tryToMakeRelative( _sf2File );
// free reference to soundfont if one is selected
freeFont();
m_synthMutex.lock();
|
请发表评论