コード例 #1
0
QString LoadSaveManager::configFilePath()
{
    QDir dir {QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)};
    if (!dir.exists()) {
        if (!QDir::root().mkpath(dir.absolutePath())) {
            qCWarning(QLoggingCategory("load-save-manager")) << "Failed to create root config dir"
                                                             << dir.absolutePath();
            return QString();
        }
    }
    const QString &appName {QCoreApplication::instance()->applicationName()};
    if (!dir.exists(appName)) {
        if (!dir.mkdir(appName)) {
            qCWarning(QLoggingCategory("load-save-manager")) << "Failed to create config dir"
                                                             << dir.absoluteFilePath(appName);
            return QString();
        }
    }
    if(!dir.cd(appName)) {
        qCWarning(QLoggingCategory("load-save-manager")) << "Failed to enter in config dir"
                                                         << dir.absoluteFilePath(appName);
        return QString();
    }
    return dir.absoluteFilePath(QLatin1String("config.json"));
}
コード例 #2
0
ファイル: bodyfetch.cpp プロジェクト: aboduo/leechcraft
	void Plugin::hookItemLoad (IHookProxy_ptr, Item *item)
	{
		if (!FetchedItems_.contains (item->ItemID_))
			return;

		const quint64 id = item->ItemID_;
		if (!ContentsCache_.contains (id))
		{
			QDir dir = StorageDir_;

			dir.cd (QString::number (id % 10));
			QFile file (dir.filePath (QString ("%1.html").arg (id)));
			if (!file.open (QIODevice::ReadOnly))
			{
				qWarning () << Q_FUNC_INFO
						<< "unable to open file:"
						<< file.fileName ()
						<< file.errorString ();
				return;
			}

			ContentsCache_ [id] = QString::fromUtf8 (file.readAll ());
		}

		const QString& contents = ContentsCache_ [id];
		if (!contents.isEmpty ())
			item->Description_ = contents;
	}
コード例 #3
0
ファイル: LuminaThemes.cpp プロジェクト: LeFroid/lumina
QStringList LTHEME::availableSystemIcons(){ 	//returns: [name] for each item
  QStringList paths;
  paths << QDir::homePath()+"/.icons";
  QStringList xdd = QString(getenv("XDG_DATA_HOME")).split(":");
  xdd << QString(getenv("XDG_DATA_DIRS")).split(":");
  for(int i=0; i<xdd.length(); i++){
    if(QFile::exists(xdd[i]+"/icons")){
      paths << xdd[i]+"/icons";	    
    }
  }
  //Now get all the icon themes in these directories
  QStringList themes, tmpthemes;
  QDir dir;
  for(int i=0; i<paths.length(); i++){
    if(dir.cd(paths[i])){
       tmpthemes = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
       for(int j=0; j<tmpthemes.length(); j++){
	 if(tmpthemes[j].startsWith("default")){ continue; }
         if(QFile::exists(dir.absoluteFilePath(tmpthemes[j]+"/index.theme")) ){ themes << tmpthemes[j]; }
       }
    }
  }
  themes.removeDuplicates();
  themes.sort();
  return themes;
}
コード例 #4
0
ファイル: iBioformatIO.cpp プロジェクト: Vaa3D/vaa3d_tools
QString getAppPath()
{
	QString v3dAppPath("~/Work/v3d_external/v3d");
	QDir testPluginsDir = QDir(qApp->applicationDirPath());

#if defined(Q_OS_WIN)
	if (testPluginsDir.dirName().toLower() == "debug" || testPluginsDir.dirName().toLower() == "release")
		testPluginsDir.cdUp();
#elif defined(Q_OS_MAC)
	// In a Mac app bundle, plugins directory could be either
	//  a - below the actual executable i.e. v3d.app/Contents/MacOS/plugins/
	//  b - parallel to v3d.app i.e. foo/v3d.app and foo/plugins/
	if (testPluginsDir.dirName() == "MacOS") {
		QDir testUpperPluginsDir = testPluginsDir;
		testUpperPluginsDir.cdUp();
		testUpperPluginsDir.cdUp();
		testUpperPluginsDir.cdUp(); // like foo/plugins next to foo/v3d.app
		if (testUpperPluginsDir.cd("plugins")) testPluginsDir = testUpperPluginsDir;
		testPluginsDir.cdUp();
	}
#endif

	v3dAppPath = testPluginsDir.absolutePath();
	return v3dAppPath;
}
コード例 #5
0
ファイル: simulator.cpp プロジェクト: cody82/opentx
int main(int argc, char *argv[])
{
  Q_INIT_RESOURCE(companion);
  QApplication app(argc, argv);
  app.setApplicationName("OpenTX Simulator");
  app.setOrganizationName("OpenTX");
  app.setOrganizationDomain("open-tx.org");

#ifdef __APPLE__
  app.setStyle(new MyProxyStyle);
#endif

  QString dir;
  if (argc) dir = QFileInfo(argv[0]).canonicalPath() + "/lang";

  /* QTranslator companionTranslator;
  companionTranslator.load(":/companion_" + locale);
  QTranslator qtTranslator;
  qtTranslator.load((QString)"qt_" + locale.left(2), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
  app.installTranslator(&companionTranslator);
  app.installTranslator(&qtTranslator);
*/

  QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));

#if defined(JOYSTICKS) || defined(SIMU_AUDIO)
  uint32_t sdlFlags = 0;
  #ifdef JOYSTICKS
    sdlFlags |= SDL_INIT_JOYSTICK;
  #endif
  #ifdef SIMU_AUDIO
    sdlFlags |= SDL_INIT_AUDIO;
  #endif
  if (SDL_Init(sdlFlags) < 0) {
    fprintf(stderr, "ERROR: couldn't initialize SDL: %s\n", SDL_GetError());
  }
#endif

  SimulatorDialog *dialog;
  QString eepromFileName;
  QDir eedir;
  QFile file;

  registerSimulators();
  registerOpenTxFirmwares();

  eedir = QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation));
  if (!eedir.exists("OpenTX")) {
    eedir.mkdir("OpenTX");
  }
  eedir.cd("OpenTX");

  QStringList firmwareIds;
  int currentIdx = 0;
  foreach(SimulatorFactory *factory, registered_simulators) {
    firmwareIds << factory->name();
    if (factory->name() == g.lastSimulator()) {
      currentIdx = firmwareIds.size() - 1;
    }
  }
コード例 #6
0
ファイル: qtservice_unix.cpp プロジェクト: tangb4c/qtservice
static QString absPath(const QString &path)
{
    QString ret;
    if (path[0] != QChar('/')) { // Not an absolute path
        int slashpos;
        if ((slashpos = path.lastIndexOf('/')) != -1) { // Relative path
            QDir dir = QDir::current();
            dir.cd(path.left(slashpos));
            ret = dir.absolutePath();
        } else { // Need to search $PATH
            char *envPath = ::getenv("PATH");
            if (envPath) {
                QStringList envPaths = QString::fromLocal8Bit(envPath).split(':');
                for (int i = 0; i < envPaths.size(); ++i) {
                    if (QFile::exists(envPaths.at(i) + QLatin1String("/") + QString(path))) {
                        QDir dir(envPaths.at(i));
                        ret = dir.absolutePath();
                        break;
                    }
                }
            }
        }
    } else {
        QFileInfo fi(path);
        ret = fi.absolutePath();
    }
    return ret;
}
コード例 #7
0
void PluginSurprise::OnCron(Bunny * b, QVariant)
{
	if(b->IsIdle())
	{
		QByteArray file;
		// Fetch available files
		QDir * dir = GetLocalHTTPFolder();
		if(dir)
		{
			QString surprise = b->GetPluginSetting(GetName(), "folder", QString()).toString();

			if(!surprise.isNull() && dir->cd(surprise))
			{
				QStringList list = dir->entryList(QDir::Files|QDir::NoDotAndDotDot);
				if(list.count())
				{
					file = GetBroadcastHTTPPath(QString("%1/%3").arg(surprise, list.at(qrand()%list.count())));
					QByteArray message = "MU "+file+"\nPL 3\nMW\n";
					b->SendPacket(MessagePacket(message));
				}
			}
			else
				LogError("Invalid surprise config");

			delete dir;
		}
		else
			LogError("Invalid GetLocalHTTPFolder()");
	}
	// Restart Timer
	createCron(b);
}
コード例 #8
0
ProfileCreationWizard::ProfileCreationWizard(ModuleManager *parent,
											 const QString &id, const QString &password,
											 bool singleProfile)
{
	m_manager = parent;
	m_singleProfile = singleProfile;

	QDir tmpDir = QDir::temp();
	QString path;
	do {
		path = "qutim-" + randomString(6) + "-profile";
	} while (tmpDir.exists(path));
	if (!tmpDir.mkpath(path) || !tmpDir.cd(path)) {
		qFatal("Can't access or create directory: \"%s\"", qPrintable(tmpDir.absoluteFilePath(path)));
	}
	QVector<QDir> &systemDirs = *system_info_dirs();
	systemDirs[SystemInfo::ConfigDir] = tmpDir.absoluteFilePath("config");
	systemDirs[SystemInfo::HistoryDir] = tmpDir.absoluteFilePath("history");
	systemDirs[SystemInfo::ShareDir] = tmpDir.absoluteFilePath("share");
	for (int i = SystemInfo::ConfigDir; i <= SystemInfo::ShareDir; i++)
		tmpDir.mkdir(systemDirs[i].dirName());
	qDebug() << Q_FUNC_INFO << SystemInfo::getPath(SystemInfo::ConfigDir);

	setProperty("singleProfile",singleProfile);
	setProperty("password",password);

	addPage(new ProfileCreationPage(this));
	QString realId;
	QString realName;
	if (id.isEmpty()) {
#if defined(Q_OS_UNIX)
		QT_TRY {
			struct passwd *userInfo = getpwuid(getuid());
			QTextCodec *codec = QTextCodec::codecForLocale();
			realId = codec->toUnicode(userInfo->pw_name);
			realName = codec->toUnicode(userInfo->pw_gecos).section(',', 0, 0);
		} QT_CATCH(...) {
		}
#elif defined(Q_OS_WIN32)
//		TCHAR wTId[UNLEN + 1];
//		DWORD wSId = sizeof(wTId);
//		if (GetUserName(wTId, &wSId))
//			#if defined(UNICODE)
//			realid= QString::fromUtf16((ushort*)wTId);
//			#else
//			realId = QString::fromLocal8Bit(wTId);
//			#endif

//		TCHAR wTName[1024];
//		DWORD wSName = 1024;
//		if (GetUserNameEx(NameDisplay, wTName, &wSName))
//			#if defined( UNICODE )
//			realName = QString::fromUtf16((ushort*)wTName);
//			#else
//			realName = QString::fromLocal8Bit(wTName);
//			#endif
#endif
		if (realName.isEmpty())
			realName = realId;
	} else {
コード例 #9
0
ファイル: rmap.cpp プロジェクト: 87maxi/oom
void RouteMapDock::populateTable(int /*flag*/)/*{{{*/
{
	_listModel->clear();
	QDir routes;
	routes.setFilter(QDir::Files | QDir::NoSymLinks);
	if(!routes.cd(routePath))
		return;
	QFileInfoList files = routes.entryInfoList();
	for(int it = 0; it < files.size(); ++it)
	{
		QFileInfo f = files.at(it);
		QString note = oom->noteForRouteMapping(f.filePath());
		QList<QStandardItem*> rowData;
		QStandardItem *chk = new QStandardItem(f.filePath());
		QStandardItem *tname = new QStandardItem(f.baseName());
		tname->setToolTip(note);
		chk->setToolTip(note);
		rowData.append(chk);
		rowData.append(tname);
		_listModel->blockSignals(true);
		_listModel->insertRow(_listModel->rowCount(), rowData);
		_listModel->blockSignals(false);
		routeList->setRowHeight(_listModel->rowCount(), 25);
	}
	updateTableHeader();
	//routeList->resizeRowsToContents();
}/*}}}*/
コード例 #10
0
ファイル: AtticaManager.cpp プロジェクト: eartle/tomahawk
void
AtticaManager::loadPixmapsFromCache()
{
    QDir cacheDir = TomahawkUtils::appDataDir();
    if ( !cacheDir.cd( "atticacache" ) ) // doesn't exist, no cache
        return;

    qDebug() << "Loading resolvers from cache dir:" << cacheDir.absolutePath();
    qDebug() << "Currently we know about these resolvers:" << m_resolverStates.keys();
    foreach ( const QString& file, cacheDir.entryList( QStringList() << "*.png", QDir::Files | QDir::NoSymLinks ) )
    {
        // load all the pixmaps
        QFileInfo info( file );
        if ( !m_resolverStates.contains( info.baseName() ) )
        {
            tLog() << "Found resolver icon cached for resolver we no longer see in synchrotron repo:" << info.baseName();
            continue;
        }

        QPixmap* icon = new QPixmap( cacheDir.absoluteFilePath( file ) );
        if ( !icon->isNull() )
        {
            m_resolverStates[ info.baseName() ].pixmap = icon;
        }
    }
}
コード例 #11
0
ファイル: myimgtool.cpp プロジェクト: ClansChen/MyIMGTool
void MYIMGTOOL::dropEvent(QDropEvent *event)
{
	QStringList paths;
	QString path;
	QDir testIfDirectory;
	QList<QUrl> urls = event->mimeData()->urls();

	if (urls.isEmpty())
		return;

	for (auto &url : urls)
	{
		path = url.toLocalFile();

		if (testIfDirectory.cd(path))
			paths += GetFilePathListOfFolder(testIfDirectory);
		else
			paths.push_back(path);
	}

	if (paths.isEmpty())
	{
		RaiseErrorMessage({ "没有文件可以导入" });
		return;
	}

	ImportFiles(paths);
}
コード例 #12
0
ファイル: dialog.cpp プロジェクト: GuoXinxiao/meshlab
void Dialog::browseTexturePath(int i) {
  QFileDialog fd(0,"Choose new texture");

  QDir shadersDir = QDir(qApp->applicationDirPath());
#if defined(Q_OS_WIN)
  if (shadersDir.dirName() == "debug" || shadersDir.dirName() == "release")
	shadersDir.cdUp();
#elif defined(Q_OS_MAC)
  if (shadersDir.dirName() == "MacOS") {
	shadersDir.cdUp();
	shadersDir.cdUp();
	shadersDir.cdUp();
  }
#endif
  shadersDir.cd("textures");
	
  fd.setDirectory(shadersDir);
  fd.move(500, 100);

  QStringList newPath;
  if (fd.exec())
	{
	  newPath = fd.selectedFiles();
	  textLineEdits[i]->setText(newPath.at(0));
	  shaderInfo->textureInfo[i].path = newPath.at(0);
	  reloadTexture(i);
	} 
	
}
コード例 #13
0
ファイル: languagesPage.cpp プロジェクト: aaly/MPF
int languagesPage::initLanguages()
{
	setStatus(tr("Loading languages"), BUSY);

    QDir languagesDir;
    QString languagesDirDirPath = getApplicationFile("/Translations/");
    languagesDir.cd(languagesDirDirPath);

    if (!languagesDir.exists())
    {
		setStatus(tr("Ooops , Couldn't find the languages directory : ")+languagesDirDirPath, ERROR);
		setStatus(tr("Assuming english language"), INFORMATION);
        return 1;
    }

    for ( unsigned int lang =0; lang < languagesDir.count(); lang++)
    {
        QString translation = languagesDir.entryList().at(lang);

        if (translation == "." || translation == "..")
        {
            continue;
        }

        if (translation.contains(".qm"))
        {
            languagesListWidget->addItem(new QListWidgetItem(translation.mid(0, translation.indexOf(".qm"))));
        }


    }
    return 0;
}
コード例 #14
0
ファイル: Global.cpp プロジェクト: Samangan/mumble
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
}
コード例 #15
0
ファイル: Config.cpp プロジェクト: polybox3d/polybox
void Config::init()
{
    QSettings().setValue("LOG/nbrExec", QSettings().value("LOG/nbrExec").toInt() + 1 );
    QSettings().setValue("ABOUT/version", QCoreApplication::applicationVersion() );
    // no settings found
    if ( QSettings().value(QString(SETTINGS_GROUP)+"/runtimePath").toString().isEmpty() )
    {
        // We must find the runtime path (means we want the top level of the git repository
        QDir dir;
        for ( u_int8_t i = 0 ; i < 6 ; ++i )
        {

            if ( dir.cd("src") )
            {
                dir.cdUp();
                Config::get(SETTINGS_GROUP,"runtimePath", dir.path()+"/").toString();
                return;
            }
            else
            {
                dir.cdUp();
            }
        }
        Config::get(ERRORS_GROUP,"runtimePath", "CRITICAL : Can't find src directory... The software will not work.").toString();
    }
}
コード例 #16
0
bool MercurialPlugin::isValidDirectory(const QUrl &directory)
{
    // Mercurial uses the same test, so we don't lose any functionality
    static const QString hgDir(".hg");

    if (m_lastRepoRoot.isParentOf(directory))
        return true;

    const QString initialPath(directory.adjusted(QUrl::StripTrailingSlash).toLocalFile());
    const QFileInfo finfo(initialPath);
    QDir dir;
    if (finfo.isFile()) {
        dir = finfo.absoluteDir();
    } else {
        dir = QDir(initialPath);
        dir.makeAbsolute();
    }

    while (!dir.cd(hgDir) && dir.cdUp())
    {} // cdUp, until there is a sub-directory called .hg

    if (hgDir != dir.dirName())
        return false;

    dir.cdUp(); // Leave .hg
    // TODO: Check whether this is the right port, original code was: m_lastRepoRoot.setDirectory(dir.absolutePath());
    m_lastRepoRoot.setPath(dir.absolutePath());
    return true;
}
コード例 #17
0
void ApplicationUI::onGetResponse(QString& response)
{
	m_pCardHolder->setProperty("visible", false);
	m_pResponseHolder->setProperty("visible", true);
	m_pResponseHolder->setProperty("text", response);

	QDir vcfPath;
	vcfPath.mkdir(QDir::tempPath()+"/data/");
	vcfPath.cd(QDir::tempPath()+"/data/");
	QFile vcfCard(QDir::tempPath()+"/data/readContact.vcf");
	if(!vcfCard.open(QIODevice::WriteOnly | QIODevice::Text))
	{
		showToast("Error Creating new file");
		return;
	}
	QTextStream out(&vcfCard);
	out << response;
	vcfCard.close();

	InvokeManager manager;
	InvokeRequest request;
	request.setTarget("sys.pim.contacts.card.viewer");
	request.setAction("bb.action.VIEW");
	request.setUri("file://" + QDir::tempPath()+"/data/readContact.vcf");
	manager.invoke(request);
}
コード例 #18
0
ファイル: iconoptions.cpp プロジェクト: laneslexicon/lexicon
void IconOptions::setIconFromField(const QLineEdit * edit, const QString & sid) {
  QDir themeDirectory = getLexicon()->themeDirectory();
  QDir imagedirectory;


  /// if the image directory is absolute then just use it
  /// otherwise it is a subdirectory of the theme root
  QFileInfo im(m_directory->text());
  if (im.isRelative()) {
    if (themeDirectory.cd(m_directory->text())) {
      /// good to go
      imagedirectory = themeDirectory;
    }
    else {
    }
  }
  else {
    imagedirectory = im.dir();
  }
  QString name = edit->text();
  QFileInfo f(name);
  if (f.isRelative()) {
    QFileInfo fi(imagedirectory,name);
    name = fi.absoluteFilePath();
  }
  onSetIcon(sid,name);
}
コード例 #19
0
void QGeoMappingManagerEngineCm::cleanCacheToSize(int sizeLimit)
{
    DBG_CM(TILES_M, INFO_L, "cleanCacheToSize():  start cleaning cache, sizeLimit = " << sizeLimit);

    QDir dir;
    dir.cd(m_cacheDir);

    QStringList filters;
    filters << "*.png";
    dir.setNameFilters(filters);
    dir.setSorting(QDir::Time);

    qint64 totalSize = 0;   // SUM of all tiles size (not precize cache size, because of cluster size)
    QFileInfoList list = dir.entryInfoList();
    for (int i = 0; i < list.size(); ++i) {
        totalSize += list.at(i).size();
        //QFileInfo fileInfo = list.at(i);
        //qDebug() << fileInfo.lastModified() << "    " << fileInfo.fileName() << "    " << fileInfo.size();
    }
    DBG_CM(TILES_M, INFO_L, "Current cache size in bytes = " << totalSize);

    // start cleaning:
    int listSize = list.size();
    while ((listSize > 0) && (totalSize > sizeLimit)) {
        totalSize -= list.at(listSize-1).size();
        if (!dir.remove(list.at(listSize-1).fileName())) {
            DBG_CM(TILES_M, ERR_L, "Failed to delete file: " << list.at(listSize-1).fileName());
            totalSize += list.at(listSize-1).size();
        }
        listSize--;
    }
    DBG_CM(TILES_M, INFO_L, "Cache cleaning finished, current cache size = " << totalSize);
}
コード例 #20
0
void MainWindow::updateFileList()
{
    QFileInfoList tmp_list;
    QDir dir;

    if (this->directoryPath == "")
        this->directoryPath = dir.absolutePath();

    this->fileList.clear();
    dir.cd(this->directoryPath);
    tmp_list = dir.entryInfoList();
    for (int i = 0; i < tmp_list.size(); ++i)
    {
        QString tmp_name = tmp_list.at(i).fileName();
        if (tmp_name.endsWith(".jpg", Qt::CaseInsensitive) == 1 ||
            tmp_name.endsWith(".bmp", Qt::CaseInsensitive) == 1 ||
            tmp_name.endsWith(".png", Qt::CaseInsensitive) == 1)
        {
            MyFile new_file;
            new_file.name = tmp_list.at(i).fileName();
            new_file.sent = false;
            new_file.path = this->directoryPath;
            new_file.plate = "";
            this->fileList.push_back(new_file);
        }
    }
}
コード例 #21
0
ファイル: QxFileBrowser.cpp プロジェクト: corelon/paco
void QxFileBrowser::delete_()
{
	QModelIndex currentIndex = dirView_->currentIndex();
	if (currentIndex.isValid()) {
		QItemSelectionModel* sm = dirView_->selectionModel();
		if (sm->hasSelection()) {
			QModelIndexList l = sm->selectedRows();
			currentIndex = QModelIndex(); // visual HACK, cwdModel_->index(currentIndex.row() + l.count(), 0, currentIndex.parent());
			for (int i = 0; i < l.count(); ++i) {
				QModelIndex mi = l[i];
				QDir dest = QDir::home();
				dest.mkdir(".Trash");
				dest.cd(".Trash");
				QString destBasePath = dest.filePath(cwdModel_->fileName(mi));
				QString destPath = destBasePath;
				int i = 1;
				while (QFileInfo(destPath).exists()) {
					destPath = QString("%1_%2").arg(destBasePath).arg(i);
					++i;
				}
				QFile(cwdModel_->filePath(mi)).rename(destPath);
			}
			dirView_->setCurrentIndex(currentIndex);
		}
	}
}
コード例 #22
0
ファイル: utils.cpp プロジェクト: lipq525/moonplayer
//get ffmpeg's file name
QString getFFmpegFile()
{
    static QString filename;
    if (filename.isNull())
    {
#if defined(Q_OS_WIN)
        QDir dir(Settings::path);
        if (dir.exists("ffmpeg.exe"))
            dir.filePath("ffmpeg.exe");
        else
            filename = "";

#elif defined(Q_OS_LINUX)
        QDir dir = QDir::home();
        dir.cd(".moonplayer");
        if (dir.exists("ffmpeg"))
            filename = dir.filePath("ffmpeg");
        else if (QDir("/usr/share/moonplayer").exists("ffmpeg"))
            filename = "/usr/share/moonplayer/ffmpeg";
        else
            filename = "";
#else
#error ERROR: Unsupport system!
#endif
    }
    return filename;
}
コード例 #23
0
ファイル: Queue.cpp プロジェクト: ActionLuzifer/fatrat
void Queue::loadQueues()
{
	QDomDocument doc;
	QFile file;
	QDir dir = QDir::home();
	
	dir.mkpath(".local/share/fatrat");
	if(!dir.cd(".local/share/fatrat"))
		return;
	file.setFileName(dir.absoluteFilePath("queues.xml"));
	
	QString errmsg;
	if(!file.open(QIODevice::ReadOnly) || !doc.setContent(&file, false, &errmsg))
	{
		qDebug() << "Failed to open " << file.fileName();
		if(!errmsg.isEmpty())
			qDebug() << "PARSE ERROR!" << errmsg;
		
		// default queue for new users
		Queue* q = new Queue;
		q->setName(QObject::tr("Main queue"));
		g_queues << q;
	}
	else
	{
		g_queuesLock.lockForWrite();
		qDeleteAll(g_queues);
		
		qDebug() << "Loading queues";
		
		QDomElement n = doc.documentElement().firstChildElement("queue");
		while(!n.isNull())
		{
			if(!n.hasAttribute("name"))
				continue;
			else
			{
				Queue* pQueue = new Queue;
				
				pQueue->m_strName = n.attribute("name");
				pQueue->m_nDownLimit = n.attribute("downlimit").toInt();
				pQueue->m_nUpLimit = n.attribute("uplimit").toInt();
				pQueue->m_nDownTransferLimit = n.attribute("dtranslimit").toInt();
				pQueue->m_nUpTransferLimit = n.attribute("utranslimit").toInt();
				pQueue->m_bUpAsDown = n.attribute("upasdown").toInt() != 0;
				pQueue->m_uuid = QUuid( n.attribute("uuid", pQueue->m_uuid.toString()) );
				pQueue->m_strDefaultDirectory = n.attribute("defaultdir", pQueue->m_strDefaultDirectory);
				pQueue->m_strMoveDirectory = n.attribute("movedir");
				
				pQueue->loadQueue(n);
				g_queues << pQueue;
			}
			n = n.nextSiblingElement("queue");
		}
		
		g_queuesLock.unlock();
	}

	m_bLoaded = true;
}
コード例 #24
0
ファイル: imagescanner.cpp プロジェクト: DaveDaCoda/mythtv
void ImageScanThread<DBFS>::CountFiles(const QStringList &paths)
{
    // Get exclusions as comma-seperated list using glob chars * and ?
    QString excPattern = gCoreContext->GetSetting("GalleryIgnoreFilter", "");

    // Combine into a single regexp
    excPattern.replace(".", "\\."); // Preserve "."
    excPattern.replace("*", ".*");  // Convert glob wildcard "*"
    excPattern.replace("?", ".");   // Convert glob wildcard "?"
    excPattern.replace(",", "|");   // Convert list to OR's

    QString pattern = QString("^(%1)$").arg(excPattern);
    m_exclusions = REGEXP(pattern);

    LOG(VB_FILE, LOG_DEBUG, QString("Exclude regexp is \"%1\"").arg(pattern));

    // Lock counts until counting complete
    QMutexLocker locker(&m_mutexProgress);
    m_progressCount       = 0;
    m_progressTotalCount  = 0;

    // Use global image filters
    QDir dir = m_dir;
    foreach(const QString &sgDir, paths)
    {
        // Ignore missing dirs
        if (dir.cd(sgDir))
            CountTree(dir);
    }
    // 0 signifies a scan start
    Broadcast(0);
}
コード例 #25
0
ファイル: window.cpp プロジェクト: jitka/tfm
Window::Window(){

	resize(W_WIDTH, W_HEIGHT);
	setWindowTitle("Timer for massage");
	setWindowIcon(QIcon("icon.jpg"));

	QVBoxLayout *vbox = new QVBoxLayout(this);
	vbox->setContentsMargins(0,0,0,0);

	tabs = new QTabWidget(this);
	tabs->setTabsClosable(true);
	tabs->setMovable(true);
	connect(tabs, SIGNAL(tabCloseRequested(int)), this, SLOT(onCloseTab(int)));
	vbox->addWidget(tabs);

	QDir dir = QDir::home();
	if (!dir.cd(".tfm")){
		QMessageBox::critical (this,"Error", "Setting not found");
		show();

	} else {

		QFileInfoList list = dir.entryInfoList();

		for (int i = 0; i < list.size(); ++i) {
			if (list[i].isFile()){
				Tab *tab = new Tab(this,list[i].fileName(),list[i].canonicalFilePath());
				tabs->addTab (tab,list[i].fileName());
			}
		} 
		show();

	}
}
コード例 #26
0
SevenZip::SevenZip(const QString &image, const QString &target, QObject *parent)
    : QObject(parent)
{
#ifdef Q_OS_WIN32
    QString sevnz = XSys::FS::InsertTmpFile(":/blob/sevnz/sevnz.exe");
    QString sevnzdll = XSys::FS::InsertTmpFile(":/blob/sevnz/sevnz.dll", "7z.dll");
    qDebug() << sevnz << sevnzdll;
#endif

#ifdef Q_OS_MAC
    QDir resourceDir = QDir(QCoreApplication::applicationDirPath());
    resourceDir.cdUp();
    resourceDir.cd("Resources");
    QString sevnz = resourceDir.absoluteFilePath("7z-mac");
    qDebug() << sevnz;
#endif

#ifdef Q_OS_LINUX
    QString sevnz = "7z";
#endif

    m_szpp = new SevenZipProcessParser("", &m_sevenz);
    m_sevenZip = sevnz;
    m_archiveFile = image;
    m_outputDir = "-o" + target;
    //    connect(&m_szpp, &SevenZipProcessParser::progressChanged, this, &SevenZip::progressChanged);
    //    connect(&m_sevenz, static_cast<void(QProcess::*)(int exitCode)>(&QProcess::finished),
    //            this, &SevenZip::handleFinished);
}
コード例 #27
0
ファイル: mplayer.cpp プロジェクト: lipq525/moonplayer
// Save unfinished time
MPlayer::~MPlayer()
{
#ifdef Q_OS_LINUX
    if (!unfinished_time.isEmpty() && Settings::rememberUnfinished)
    {
        QByteArray data;
        QHash<QString, int>::const_iterator i = unfinished_time.constBegin();
        while (i != unfinished_time.constEnd())
        {
            QString name = i.key();
            if (!name.startsWith("http://"))
                data += name.toUtf8() + '\n' + QByteArray::number(i.value()) + '\n';
            i++;
        }
        data.chop(1); // Remove last '\n'
        if (data.isEmpty())
            return;
        QString filename = QDir::homePath() + "/.moonplayer/unfinished.txt";
        QFile file(filename);
        if (!file.open(QFile::WriteOnly))
            return;
        file.write(data);
        file.close();
    }
    else
    {
        QDir dir = QDir::home();
        dir.cd(".moonplayer");
        if (dir.exists("unfinished.txt"))
            dir.remove("unfinished.txt");
    }
#endif
}
コード例 #28
0
ThemeLoader::ThemeLoader(QObject* parent) : QObject(parent)
{
    ThemeInfo info;
    if (!info.load(":/themes/cute/cute.theme"))
        qWarning() << "Failed to load cute.theme";
    d.themes.append(info.name());
    d.infos.insert(info.name(), info);

    QDir inst(COMMUNI_INSTALL_THEMES);
    if (inst.exists())
        load(inst);

#if defined(Q_OS_MAC)
    QDir dir(QApplication::applicationDirPath());
    if (dir.dirName() == "MacOS" && dir.cd("../Resources/themes"))
        load(dir);
#elif defined(Q_OS_WIN)
    QDir dir(QApplication::applicationDirPath());
    if (dir.cd("themes") || (dir.cdUp() && dir.cd("themes")))
        load(dir);
#elif defined(Q_OS_UNIX)
    QDir sys("/usr/share/themes/communi");
    if (sys != inst && sys.exists())
        load(sys);
    QDir home = QDir::home();
    if (home.cd(".local/share/themes/communi"))
        load(home);
    QDir dev(QApplication::applicationDirPath());
    if (dev.cdUp() && dev.cd("themes"))
        load(dev);
#endif
}
コード例 #29
0
void QQuickControlSettings::findStyle(QQmlEngine *engine, const QString &styleName)
{
    QString path = styleImportPath(engine, styleName);
    QDir dir;
    dir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
    dir.setPath(path);
    dir.cd(styleName);

    StyleData styleData;

    foreach (const QString &fileName, dir.entryList()) {
        // This assumes that there is only one library in the style directory,
        // which should be a safe assumption. If at some point it's determined
        // not to be safe, we'll have to resolve the init and path functions
        // here, to be sure that it is the correct library.
        if (QLibrary::isLibrary(fileName)) {
            styleData.m_stylePluginPath = dir.absoluteFilePath(fileName);
            break;
        }
    }

    // If there's no plugin for the style, then the style's files are
    // contained in this directory (which contains a qmldir file instead).
    styleData.m_styleDirPath = dir.absolutePath();

    m_styleMap[styleName] = styleData;
}
コード例 #30
0
void 
DeviceScrobbler::checkCachedIPodScrobbles()
{
    QStringList files;

    // check if there are any iPod scrobbles in its folder
    QDir scrobblesDir = lastfm::dir::runtimeData();

    if ( scrobblesDir.cd( "devices" ) )
    {
        QDirIterator iterator( scrobblesDir, QDirIterator::Subdirectories );

        while ( iterator.hasNext() )
        {
            iterator.next();

            if ( iterator.fileInfo().isFile() )
            {
                QString filename = iterator.fileName();

                if ( filename.endsWith(".xml") )
                    files << iterator.fileInfo().absoluteFilePath();
            }
        }
    }

    scrobbleIpodFiles( files );
}