コード例 #1
0
ファイル: chatlogger.cpp プロジェクト: aeickho/yappari
void ChatLogger::deleteAllMessages()
{
    db.close();
    QSqlDatabase::removeDatabase(jid);

    QDir home = QDir::home();
    QFile file(home.path() + LOGS_DIR + jid.left(jid.indexOf("@")) + LOG_EXTENSION);

    file.remove();

    init(jid);
}
コード例 #2
0
bool TrainingSet::addFace(const QString &person, const QImage &image)
{
  if(getAvailableFaces().contains(person) == false)
    return false;
  else{
    QString photoName;
    QDir faceDirectory;
    faceDirectory.setPath(mainDirectory.path() + "/" + person);
    photoName.sprintf("%06d", faceDirectory.entryList(QDir::Files).size() +1);
    image.save(faceDirectory.path() + "/" + photoName + ".jpg","jpg", 100);
  }
}
コード例 #3
0
ファイル: filebrowser.cpp プロジェクト: DFRobot/liteide
void FileBrowser::viewGodoc()
{
    QDir dir = contextDir();
    LiteApi::IGolangDoc *doc = LiteApi::findExtensionObject<LiteApi::IGolangDoc*>(m_liteApp,"LiteApi.IGolangDoc");
    if (doc) {
        QUrl url;
        url.setScheme("pdoc");
        url.setPath(dir.path());
        doc->openUrl(url);
        doc->activeBrowser();
    }
}
コード例 #4
0
ファイル: MainWindow.cpp プロジェクト: petevieira/reviz-g
void MainWindow::loadPluginDirWithDialog()
{
    if (true) {
        // Set file extension filters
        QStringList filters;
        filters << "Shared library (*.so)";

        QFileDialog dialog(this);
        dialog.setNameFilters(filters);
        dialog.setAcceptMode(QFileDialog::AcceptOpen);
        dialog.setFileMode(QFileDialog::Directory);
        if (dialog.exec()) {
            QDir pluginsDir = QDir(dialog.selectedFiles().at(0));
            std::cerr << "pluginDir: " << pluginsDir.path().toStdString() << std::endl;
            slotSetStatusBarMessage(tr(qPrintable("plugin Dir: " + pluginsDir.path())));
            loadPluginDirectory(pluginsDir);
        } else {
            slotSetStatusBarMessage(tr("Didn't find plugin directory"));
        }
    }
}
コード例 #5
0
bool EmptyDirsFix2::isEmpty(QDir dir)
{
	QStringList files = dir.entryList(QDir::Files);
	if (!files.isEmpty())
	{ return false; }

	QStringList dirs = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
	bool empty = true;
	for (int i = 0; i < dirs.size(); i++)
	{ empty = empty && isEmpty(QDir(dir.path()+"/"+dirs.at(i))); }
	return empty;
}
コード例 #6
0
void ResourceManager::addDataPath(QDir path) {
    // make sure the default paths are checked first
    if(!mDataPathsSearched)
        _findDataPaths();

    if(path.exists()) {
        Logger::get().debug("Added data path: <" + path.absolutePath() + ">.");
        QDir::addSearchPath("data", path.absolutePath());
    } else {
        Logger::get().warning("Cannot add data path <" + path.path() + ">: not a directory.");
    }
}
コード例 #7
0
ファイル: rgbscript_test.cpp プロジェクト: Cingulingu/qlcplus
void RGBScript_Test::directories()
{
    QDir dir = RGBScriptsCache::systemScriptsDirectory();
    QCOMPARE(dir.filter(), QDir::Files);
    QCOMPARE(dir.nameFilters(), QStringList() << QString("*.js"));
#if defined( __APPLE__) || defined(Q_OS_MAC)
    QString path("%1/../%2");
    QCOMPARE(dir.path(), path.arg(QCoreApplication::applicationDirPath())
                             .arg("Resources/RGBScripts"));
#elif defined(WIN32) || defined(Q_OS_WIN)
    QVERIFY(dir.path().endsWith("RGBScripts"));
#else
    QVERIFY(dir.path().endsWith("qlcplus/rgbscripts"));
#endif

    dir = RGBScriptsCache::userScriptsDirectory();
    QCOMPARE(dir.filter(), QDir::Files);
    QCOMPARE(dir.nameFilters(), QStringList() << QString("*.js"));
#if defined( __APPLE__) || defined(Q_OS_MAC)
    QVERIFY(dir.path().endsWith("Library/Application Support/QLC+/RGBScripts"));
#elif defined(WIN32) || defined(Q_OS_WIN)
    QVERIFY(dir.path().endsWith("RGBScripts"));
#else
    QVERIFY(dir.path().endsWith(".qlcplus/rgbscripts"));
#endif
}
コード例 #8
0
ファイル: Project.cpp プロジェクト: rcari/libNigel
Project* Project::CreateNewProject(const QString& projectFilePath)
{
	QString file = projectFilePath;
	if(!projectFilePath.endsWith(N_PROJECT_FILE_EXTENSION))
	{
		file.append(N_PROJECT_FILE_EXTENSION);
	}

	Project* result = DocumentInstance::CreateDocumentInstance<Project>(file);

	K_ASSERT( result )

	// Project layout is created here.
	QDir projectRoot = result->fileInfo().dir();

	if(!QFileInfo(projectRoot.path()).isWritable())
	{
		Kore::KoreEngine::Error(
				tr("Could not create project !"),
				tr("Project folder %s is not writable !").arg(projectRoot.path())
			);

		result->destroy();
		return K_NULL;
	}

	// Create the resources folder.
	projectRoot.mkdir(N_PROJECT_RESOURCES_FOLDER);

	// Create the scenes folder.
	projectRoot.mkdir(N_PROJECT_SCENES_FOLDER);

	// Create the models folder.
	projectRoot.mkdir(N_PROJECT_MODELS_FOLDER);

	// TODO: Add default Project stuff (default scene, default model, default everything...)

	return result;
}
コード例 #9
0
ファイル: tscontroller.cpp プロジェクト: AmurSU/TSProject
void TSController::openPrivateDB(QSqlRecord record)
{
    examinationsConnection = QSqlDatabase::addDatabase("QSQLITE","ExamConnection");
    QDir d;
    if(!d.cd("pravatedb"))
    {
        d.mkpath("privatedb");
    }
    d.setPath(d.path()+"\\privatedb");
    examinationsConnection.setDatabaseName(d.path()+"\\"+record.value("id").toString()+"_"+
                                           record.value("code").toString()+".db");
    if(!examinationsConnection.open())
    {
        qDebug()<<examinationsConnection.lastError().text();
        QMessageBox msgBox(this);
        msgBox.setWindowTitle(tr("Ошибка"));
        msgBox.setText(tr("Произошла ошибка. Обратитесь к разработчикам. Код: 00002"));
        msgBox.exec();
        ui->mainBox->setCurrentIndex(0);
        return;
    }
}
コード例 #10
0
void CardiacMeshReaderUI::dirChooserMesh() {
  QString dir;
  // use the DICOM set location for the mesh, since they might be close together
  QDir lastDirUp = QDir(m_lastDir);
  lastDirUp.cdUp();
  dir = QFileDialog::getExistingDirectory(this, "Select Mesh Directory", lastDirUp.path(), QFileDialog::ShowDirsOnly);

  if (dir != "") {
    // The user did select a directory.
    directoryEditMesh->setText(dir);
    newDirectoryMesh();
  }
}
コード例 #11
0
ファイル: fileNavigator.cpp プロジェクト: donSchoe/cgsee
void FileNavigator::on_activatedDir(const QString & path)
{
    m_model->setRootPath(path);
    QDir * dir = new QDir(m_model->rootDirectory());

    while (dir->cdUp())
    {
        this->expand(m_model->index(m_model->rootPath()));
        m_model->setRootPath(dir->path());
    }

    delete dir;
}
コード例 #12
0
void ScreenWidget::initializeGL(){
    glClearColor(1,1,1,1);
    glClear(GL_COLOR_BUFFER_BIT);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0,1280,0,720,-1,1);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glDisable(GL_DEPTH_TEST);
    //static GLfloat lightPosition[4] = { 0, 0, 10, 1.0 };
    //glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
    //QDir::setCurrent(QCoreApplication::applicationDirPath());

    QDir absoluteDirectory = QDir::currentPath();
    //qDebug() << absoluteDirectory.cdUp();
    qDebug() << absoluteDirectory.cd("Shader");
    QString vertexShader = absoluteDirectory.path() + "/vertexShader.vsh";
    QString fragmentShader = absoluteDirectory.path() + "/fragmentShader.fsh";
    qDebug() << vertexShader << " AND " << fragmentShader;

    QFileInfo checkFile(vertexShader);
    QFileInfo checkFile2(fragmentShader);
    if(!checkFile.exists()){
        qDebug() << "Can't find the file...";
    }else{
        qDebug() << "The file exists!";
    }

    if(!checkFile2.exists()){
        qDebug() << "Can't find the file...";
    }else{
        qDebug() << "The file2 exists!";
    }

    if (!prepareShaderProgram(vertexShader, fragmentShader)){
        return;
    }

}
コード例 #13
0
ファイル: tsystem.cpp プロジェクト: SaierMe/opentoonz
void TSystem::readDirectory(TFilePathSet &dst, const QDir &dir,
                            bool groupFrames) {
  if (!(dir.exists() && QFileInfo(dir.path()).isDir()))
    throw TSystemException(TFilePath(dir.path().toStdWString()),
                           " is not a directory");

  QStringList entries(dir.entryList(dir.filter() | QDir::NoDotAndDotDot));
  TFilePath dirPath(dir.path().toStdWString());

  std::set<TFilePath, CaselessFilepathLess> fpSet;

  int e, eCount = entries.size();
  for (e = 0; e != eCount; ++e) {
    TFilePath path(dirPath + TFilePath(entries.at(e).toStdWString()));

    if (groupFrames && path.getDots() == "..") path = path.withFrame();

    fpSet.insert(path);
  }

  dst.insert(dst.end(), fpSet.begin(), fpSet.end());
}
コード例 #14
0
ファイル: Application.cpp プロジェクト: odelande/QGameTrainer
QDir createSettingDir() {
	static QDir res;
	static bool created = false;
	if (!created) {
		QSettings dummySettings(QSettings::IniFormat, QSettings::UserScope, organization, QString::fromWCharArray(L"a"));
		QDir organizationDir(QFileInfo(dummySettings.fileName()).path());
		res = QDir(QFileInfo(organizationDir, name).filePath());
		if (!res.exists()) {
			QDir().mkpath(res.path());
		}
	}
	return res;
}
コード例 #15
0
ファイル: browse.cpp プロジェクト: hutchgrant/beagleplayer
/*
 *  Initialize/update/re-read from cache.
 */
void browse::Sync(int type){
    if(type == 2 || type == 3){    /// import new entries into local db for each folder and file
        QDir usrDir = QString(getenv("HOME"));
        QFileDialog iDirect;

        usrDir = iDirect.getExistingDirectory(this, tr("Import a directory"), usrDir.absolutePath());
        if(usrDir.dirName() != NULL || usrDir.dirName() != ""){
            if(type == 2){   /// import audio
               if(lclSync.Sync(usrDir, 0)){
                   MenuMode = 0;
                }
            }
            else if(type == 3){  /// import video
                if(lclSync.Sync(usrDir, 1)){
                    MenuMode = 1;
                }
            }
        }
    }else if(type == 4){
        radStat = new radiostat();
        radStat->init(dbCon);
        radStat->show();
        if(radStat->exec() == QDialog::Accepted){
            dbCon->readDB(Radio, "radios");
            dbCon->readDB(RadioCat, "categories");

            MenuMode = 2;  /// set Mode to radio
            updateMenu();
            updateTitle(0);
        }
    }else if(type == 0){
        QDir usrDir;
         usrDir = QFileDialog::getOpenFileName(this, tr("Open a Audio/Video file"), QDir::currentPath(), tr("Video/Audio (*.avi *.mp4 *.mp3 *.flac *.wav)"));
         if(usrDir.dirName() != NULL || usrDir.dirName() != ""){
            emit startTempTrack(usrDir.dirName().toStdString(), usrDir.path().toStdString(), MenuMode);
         }
    }else if(type == -1){
        web = new QWebUrl();
        web->show();
        if(web->exec() == QDialog::Accepted){
            if(web->url_input != "http://" || web->url_input != ""){
                emit startTempTrack("", web->url_input, MenuMode);
            }
        }
    }

    if(type ==1 || type == 2 || type == 3){   /// don't sync if we're playing a temp file
        syncCache();
        updateMenu();
    }
}
コード例 #16
0
ファイル: CheckAndSync.cpp プロジェクト: s-quark95/yadiskQt
void CheckAndSync::Syncronize(){
    QStack <QFileInfo> File_Stack;
    QFileInfo backdir("..");
    QDir *tempDir = new QDir();
    tempDir->setCurrent("/home/quark/YaDiskDir");
    tempDir->setFilter(QDir::Files| QDir::Dirs | QDir::Hidden | QDir::NoDotAndDotDot);
    tempDir->setSorting(QDir::DirsLast);
    QVector <QString> VizitedDirs;

    qDebug() << QDateTime::currentDateTime().toString("ddd MMM dd hh:mm:ss yyyy")+" | "+"Begin to global syncronizing";
    do {
        if (!VizitedDirs.contains(tempDir->path())) {
            File_Stack.push(backdir);
            for(int i=tempDir->entryInfoList().count();i>0;i--){
                File_Stack.push(tempDir->entryInfoList().at(i-1));

                if (File_Stack.top().isFile()) {
                    if(tempDir->path() == "."){
                        emit NeedFilePropeties("/",File_Stack.pop().fileName());
                        qDebug() << QDateTime::currentDateTime().toString("ddd MMM dd hh:mm:ss yyyy")+" | "+"NeedFileProperties signal emmited";
                    }
                    else {
                        emit NeedFilePropeties('/'+tempDir->path()+'/',File_Stack.pop().fileName());
                        qDebug() << QDateTime::currentDateTime().toString("ddd MMM dd hh:mm:ss yyyy")+" | "+"NeedFileProperties signal emmited";
                    }
                }
            }
        }

        qDebug() << "CD to "+File_Stack.top().fileName();
        VizitedDirs.append(tempDir->path());
        tempDir->cd(File_Stack.pop().fileName());

    }
    while(!File_Stack.empty());
    qDebug() << QDateTime::currentDateTime().toString("ddd MMM dd hh:mm:ss yyyy")+" | "+"Global syncronizing complete.Waiting.";

}
コード例 #17
0
ファイル: mainwindow.cpp プロジェクト: nonameHDT/QHashCatGui
void MainWindow::startCracking()
{
    QString curstate = ui->btnAction->property("state").toString();
    if(curstate == "cracking")
    {
        createActionText("idle");
        crackingProcess->terminate();
    }
    else
    {
        QFileInfo file(ui->txtProg->text());
        if(!file.exists())
        {
            QMessageBox msgBox(this);
            msgBox.setText("Hashcat not found! Please download it");
            msgBox.setIcon(QMessageBox::Warning);
            msgBox.exec();
            QDesktopServices::openUrl(QUrl("http://hashcat.net/hashcat/"));
            return;
        }

        QDir dir = file.absoluteDir();
        if(dir.entryList(QStringList() << "eula.accepted").count() == 0)
        {
            QFile file(dir.path() + QDir::separator() + "eula.accepted");
            file.open(QIODevice::ReadWrite | QIODevice::Text);
            QTextStream out(&file);
            out << "1\0";
            file.close();
        }

        QStringList args = createCommand();
        ui->txtLog->append("COMMAND: " + ui->txtProg->text() + " " + args.join(" "));
        createActionText("cracking");
        ui->tabWidget->setCurrentWidget(ui->tab_3);

		QString completeCmd = ui->txtProg->text();
		foreach (QString arg, args)
		{
			completeCmd += " " + arg;
		}
        crackingProcess->start(completeCmd);

        if(!crackingProcess->waitForStarted(60000))
        {
            createActionText("idle");
            ui->txtLog->append("Start failed");
            return;
        }
    }
コード例 #18
0
void DockPixelStreamer::addRootDirToFlow()
{
    QDir rootDir = currentDir_;
    const bool hasRootDir = rootDir.cdUp();

    if( hasRootDir)
    {
        FolderThumbnailGeneratorPtr folderGenerator = ThumbnailGeneratorFactory::getFolderGenerator(flow_->slideSize());

        QImage img = folderGenerator->generateUpFolderImage(rootDir);
        flow_->addSlide( img, "UP: " + rootDir.path() );
        slideImagesLoaded_.append(qMakePair(true, QString()));
    }
}
コード例 #19
0
ファイル: mainwindow.cpp プロジェクト: sokolukanton/overture
QString MainWindow::createIni()
{
    QSettings settings("settings.ini",QSettings::IniFormat);
    QString dirpath = QFileDialog::getExistingDirectory(this, tr("Выберите папку в которой создастся хранилище"),"/home",
                                                    QFileDialog::ShowDirsOnly| QFileDialog::DontResolveSymlinks);
    QDir dir;
    dir.cd(dirpath);
    dir.mkdir("OvertureStorage");
    dir.cd("OvertureStorage");
    dirpath=dir.path();
    settings.setValue("DataStorage/Path",dirpath);
    _xmlwriter->createFile(dirpath+"/data.xml");
    return dirpath;
}
コード例 #20
0
ファイル: ioplugincache.cpp プロジェクト: ChrisLaurie/qlcplus
void IOPluginCache::load(const QDir& dir)
{
    qDebug() << Q_FUNC_INFO << dir.path();

    /* Check that we can access the directory */
    if (dir.exists() == false || dir.isReadable() == false)
        return;

    /* Loop thru all files in the directory */
    QStringListIterator it(dir.entryList());
    while (it.hasNext() == true)
    {
        /* Attempt to load a plugin from the path */
        QString fileName(it.next());
        QString path = dir.absoluteFilePath(fileName);
        QPluginLoader loader(path, this);
        QLCIOPlugin* ptr = qobject_cast<QLCIOPlugin*> (loader.instance());
        if (ptr != NULL)
        {
            /* Check for duplicates */
            if (plugin(ptr->name()) == NULL)
            {
                /* New plugin. Append and init. */
                qDebug() << "Loaded I/O plugin" << ptr->name() << "from" << fileName;
                emit pluginLoaded(ptr->name());
                ptr->init();
                m_plugins << ptr;
                connect(ptr, SIGNAL(configurationChanged()),
                        this, SLOT(slotConfigurationChanged()));
#if !defined(Q_OS_ANDROID)
                HotPlugMonitor::connectListener(ptr);
#endif
                // QLCi18n::loadTranslation(p->name().replace(" ", "_"));
            }
            else
            {
                /* Duplicate plugin. Unload it. */
                qWarning() << Q_FUNC_INFO << "Discarded duplicate I/O plugin"
                           << ptr->name() << "in" << path;
                loader.unload();
            }
        }
        else
        {
            qWarning() << Q_FUNC_INFO << fileName << "doesn't contain an I/O plugin:"
                       << loader.errorString();
            loader.unload();
        }
    }
}
コード例 #21
0
void SessionManager::renameSession( const QString & oldName, const QString & newName )
{
    if (mCurrentSession && mCurrentSession->name() == oldName) {
        saveSessionAs(newName);
        removeSession(oldName);
    } else {
        QDir dir = sessionsDir();
        if (dir.path().isEmpty())
            return;

        if (!dir.rename(oldName + ".yaml", newName + ".yaml"))
            qWarning("Could not rename session file!");
    }
}
コード例 #22
0
void FileSystemWidget::openShell()
{
    QDir dir = contextDir();
    QProcessEnvironment env = LiteApi::getCurrentEnvironment(m_liteApp);
    QString cmd = env.value("LITEIDE_TERM");
    QStringList args = env.value("LITEIDE_TERMARGS").split(" ");
    QString path = dir.path();
#ifdef Q_OS_WIN
    if (path.length() == 2 && path.right(1) == ":") {
        path += "/";
    }
#endif
    QProcess::startDetached(cmd,args,path);
}
コード例 #23
0
QString UBFileSystemUtils::createTempDir(const QString& templateString, bool autoDeleteOnExit)
{
    QString appTempDir =  QDesktopServices::storageLocation(QDesktopServices::TempLocation)
                                  + "/" + templateString;

    int index = 0;
    QDir dir;

    do
    {
        index++;
        QString dirName = appTempDir + QString("%1").arg(index);
        dir = QDir(dirName);
    }
    while(dir.exists() && index < 10000);

    dir.mkpath(dir.path());

    if (autoDeleteOnExit)
        UBFileSystemUtils::sTempDirToCleanUp << dir.path();

    return dir.path();
}
コード例 #24
0
ファイル: main.cpp プロジェクト: serghei/kde3-kdevelop
void parseDirectory( Driver& driver, QDir& dir, bool rec, bool parseAllFiles )
{
	
	QStringList fileList;
	if ( parseAllFiles )
		fileList = dir.entryList( QDir::Files );
	else
		fileList = dir.entryList( "*.h;*.H;*.hh;*.hxx;*.hpp;*.tlh" );
	
	QStringList::Iterator it = fileList.begin();
	while ( it != fileList.end() )
	{
		QString fn = dir.path() + "/" + ( *it );
		++it;
		
		driver.parseFile( fn );
	}
	
	if ( rec )
	{
		QStringList fileList = dir.entryList( QDir::Dirs );
		QStringList::Iterator it = fileList.begin();
		while ( it != fileList.end() )
		{
			if ( ( *it ).startsWith( "." ) )
			{
				++it;
				continue;
			}
			
			QDir subdir( dir.path() + "/" + ( *it ) );
			++it;
			
			parseDirectory( driver, subdir, rec, parseAllFiles );
		}
	}
}
コード例 #25
0
/*
  Create a new project.
  - a new directory for the project
  - an XML project file for the project, from template
  - a stubbed out source file, from template
  Make sure the path name doesn't have any spaces in it, so make can work happily.
  Return the new project's name, or an empty string on failure.
*/
QString ProjectManager::createNewProject(QString newProjectPath)
{
  confirmValidProjectName(&newProjectPath);
  if(newProjectPath.contains(" ")) // if there are still spaces in the path, we have problems
    return "";
  QDir newProjectDir;
  newProjectDir.mkpath(newProjectPath);
  newProjectDir.setPath(newProjectPath);
  QString newProjName = newProjectDir.dirName();
  
  // grab the templates for a new project
  QDir templatesDir = QDir::current().filePath("resources/templates");
    
  // create the project file from our template
  QFile templateFile(templatesDir.filePath("project_template.xml"));
  templateFile.copy(newProjectDir.filePath(newProjName + ".xml"));
  templateFile.close();
  
  templateFile.setFileName(templatesDir.filePath("source_template.txt"));
  if( templateFile.open(QIODevice::ReadOnly | QFile::Text) )
  {
    // and create the main file
    QFile mainFile(newProjectDir.filePath(newProjName + ".c"));
    if( mainFile.open(QIODevice::WriteOnly | QFile::Text) )
    {
      QTextStream out(&mainFile);
      out << QString("// %1.c").arg(newProjName) << endl;
      out << QString("// created %1").arg(QDate::currentDate().toString("MMM d, yyyy") ) << endl;
      out << templateFile.readAll();
      mainFile.close();
    }
    QFileInfo fi(mainFile);
    addToProjectFile(newProjectDir.path(), fi.filePath(), "thumb");
    templateFile.close();
  }
  return newProjectDir.path();
}
コード例 #26
0
ファイル: ModelPackager.cpp プロジェクト: Nex-Pro/hifi
bool ModelPackager::copyTextures(const QString& oldDir, const QDir& newDir) {
    QString errors;
    for (auto texture : _textures) {
        QString oldPath = oldDir + "/" + texture;
        QString newPath = newDir.path() + "/" + texture;

        // Make sure path exists
        if (texture.contains("/")) {
            QString dirPath = newDir.relativeFilePath(QFileInfo(newPath).path());
            newDir.mkpath(dirPath);
        }
        
        QFile texFile(oldPath);
        if (texFile.exists() && texFile.open(QIODevice::ReadOnly)) {
            // Check if texture needs to be recoded
            QFileInfo fileInfo(oldPath);
            QString extension = fileInfo.suffix().toLower();
            bool isJpeg = (extension == "jpg");
            bool mustRecode = !(isJpeg || extension == "png");
            QImage image = QImage::fromData(texFile.readAll());

            // Recode texture if too big
            if (image.width() > MAX_TEXTURE_SIZE || image.height() > MAX_TEXTURE_SIZE) {
                image = image.scaled(MAX_TEXTURE_SIZE, MAX_TEXTURE_SIZE, Qt::KeepAspectRatio);
                mustRecode = true;
            }
            
            // Copy texture
            if (mustRecode) {
                QFile newTexFile(newPath);
                newTexFile.open(QIODevice::WriteOnly);
                image.save(&newTexFile, isJpeg ? "JPG" : "PNG");
            } else {
                texFile.copy(newPath);
            }
        } else {
            errors += QString("\n%1").arg(oldPath);
        }
    }
    
    if (!errors.isEmpty()) {
        OffscreenUi::asyncWarning(nullptr, "ModelPackager::copyTextures()",
                             "Missing textures:" + errors);
        qCDebug(interfaceapp) << "ModelPackager::copyTextures():" << errors;
        return false;
    }
    
    return true;
}
コード例 #27
0
//Returns true filepath for a  update entry
QString CROSS_OS_GetDirectoryFromLocationTag(QString locationtag)
{
    //Make sure the paths exist.
    #ifdef Q_OS_WIN
        QDir().mkpath(QDesktopServices::storageLocation(QDesktopServices::DataLocation));
        QDir().mkpath(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation) + "/B9Creator");
        QDir().mkpath(QDesktopServices::storageLocation(QDesktopServices::TempLocation) + "/B9Creator");
    #endif
    #ifdef Q_OS_MAC
        QDir().mkpath(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation) + "/B9Creator");
        QDir().mkpath(QDesktopServices::storageLocation(QDesktopServices::TempLocation) + "/B9Creator");
    #endif
    #ifdef Q_OS_LINUX
         QDir().mkpath(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation) + "/B9Creator");
        QDir().mkpath(QDesktopServices::storageLocation(QDesktopServices::TempLocation) + "/B9Creator");
    #endif


    QString dir;
    if(locationtag == "APPLICATION_DIR")
    {
        #ifdef Q_OS_WIN // User/AppData/Local/B9Creatoions LLC/B9Creator
            dir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
        #endif
        #ifdef Q_OS_MAC//AppBundle/content/resources
            QDir recources = QDir(QCoreApplication::applicationDirPath());
            recources.cdUp();
            recources.cd("Resources");
            dir = recources.path();
        #endif
        #ifdef Q_OS_LINUX
            dir = QCoreApplication::applicationDirPath();
        #endif
    }
    if(locationtag == "EXECUTABLE_DIR")
    {
        dir = QCoreApplication::applicationDirPath();
    }
    if(locationtag == "TEMP_DIR")
    {
        dir = QDesktopServices::storageLocation(QDesktopServices::TempLocation) + "/B9Creator";
    }
    if(locationtag == "DOCUMENTS_DIR")
    {
        dir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation) + "/B9Creator";
    }

    return QDir(dir).absolutePath();
}
コード例 #28
0
void MainWindow::on_pushButton_convert_clicked()
{
    //コンバート

    if (( ui->listWidget->count() > 0 ) && (convert_exec == false))
    {
        convert_error = false;
        convert_exec = false;  //コンバート中か
        convet_index = 0;
        QString st = QString("Exec %1/%2").arg(convet_index+1).arg(ui->listWidget->count());
        ui->textBrowser_status->setText(st);     //ステータス
        ui->textBrowser_err->setText(tr(""));           //エラー
        cnvOutputStr = "";

        {
            QString fileName = ui->listWidget->item(convet_index)->text();
            //コンバータの起動
            if (fileName.isEmpty())
            {
                //ファイル名なし
            }
            else
            {
                QString str;
                QString execstr;

        #ifdef Q_OS_WIN32
                // Windows
                execstr = "Ss5Converter.exe";
        #else
                // Mac
                QDir dir = QDir(execPathStr);
                dir.cd("..");
                dir.cd("..");
                dir.cd("..");
                dir.cd("..");
                QString str_current_path = dir.path();
                execstr = str_current_path + "/Ss5Converter";
        #endif
                str = execstr + " \"" + fileName + "\"";
                cnvProcess->start(str); //パスと引数

                button_enable(false);
                convert_exec = true;  //コンバート中か
                convet_index++;
            }
        }
    }
}
コード例 #29
0
bool NewWindowSchemaPage::loadSchemas(Fix8SharedLib::LibType libType)
{
    QDir schemaDir;
    QString errorStr;
    if (libType == Fix8SharedLib::SystemLib)
        schemaDir = QDir(systemDirName);
    else
        schemaDir = QDir(userDirName);
    if (!schemaDir.exists()) {
        errorStr = "Schema Dir" + schemaDir.path() + " does not exists";
        qWarning() << errorStr << __FILE__ << __LINE__;
        schemaErrorStrList.append(errorStr);
        return false;
    }
    QFileInfoList fileInfoList = schemaDir.entryInfoList(QDir::Files |QDir::NoDotAndDotDot| QDir::NoSymLinks);
    QFileInfo fi;
    QStandardItem *si;
    QListIterator<QFileInfo> iter(fileInfoList);
    int i=0;
    QString nameList;
    while(iter.hasNext()) {
        QString baseName;
        fi = iter.next();
        baseName = fi.baseName();
        QString name;

#ifdef Q_OS_WIN
        name = baseName;
        if (libType == Fix8SharedLib::SystemLib)
            name.append("*");
#else
        QString libStr = baseName.left(3);
        if (libStr == "lib")
            name = baseName.right(baseName.length()-3);
        if (libType == Fix8SharedLib::SystemLib)
            name.append("\u002a");
#endif
        if (!nameList.contains(name)) {
            si = new QStandardItem(name);
            QVariant var;
            QString fileName = fi.absoluteFilePath();
            var.setValue(fileName);
            si->setData(var);
            schemaModel->insertRow(i++,si);
            nameList.append(name);
        }
    }
    return true;
}
コード例 #30
0
/*
  Save a copy of a project.
  Any files in the project with the name of the project should be changed,
  others are simply copied over.
*/
QString ProjectManager::saveCurrentProjectAs(const QString & currentProjectPath, const QString & newProjectPath)
{
  QDir currentProjectDir(currentProjectPath);
  QString currentProjectName = currentProjectDir.dirName();
  QString newProjPath = confirmValidProjectName(newProjectPath);

  QDir newProjectDir;
  newProjectDir.mkpath(newProjPath);
  newProjectDir.setPath(newProjPath);
  QString newProjectName = newProjectDir.dirName();

  QFileInfoList fileList = currentProjectDir.entryInfoList();
  foreach (QFileInfo fi, fileList) {
    // give any project-specific files the new project's name
    if (fi.baseName() == currentProjectName) {
      if (fi.suffix() != "o") { // don't need to copy obj files
        QFile tocopy(fi.filePath());
        tocopy.copy(newProjectDir.filePath(newProjectName + "." + fi.suffix()));
      }
    }
    else { // just copy the file over
      QFile tocopy(fi.filePath());
      tocopy.copy(newProjectDir.filePath(fi.fileName()));
    }
  }

  // update the contents of the project file
  QDomDocument projectDoc;
  QFile projFile(newProjectDir.filePath(newProjectName + ".xml"));
  if (projectDoc.setContent(&projFile)) {
    projFile.close();
    QDomNodeList allFiles = projectDoc.elementsByTagName("files").at(0).childNodes();
    for (int i = 0; i < allFiles.count(); i++) {
      if (!allFiles.at(i).toElement().text().startsWith("resources/cores")) {
        QFileInfo fi(allFiles.at(i).toElement().text());
        if (fi.baseName() == currentProjectName) {
          fi.setFile(fi.path() + "/" + newProjectName + "." + fi.suffix());
          allFiles.at(i).firstChild().setNodeValue(QDir::cleanPath(fi.filePath()));
        }
      }
    }
    // reopen with WriteOnly
    if (projFile.open(QIODevice::WriteOnly|QFile::Text)) {
      projFile.write(projectDoc.toByteArray(2));
      projFile.close();
    }
  }
  return newProjectDir.path();
}