static void updateSymlinks() { QDir lists( listDir ); QStringList knownPackages = lists.entryList( "*.list" ); // No tr struct mntent *me; FILE *mntfp = setmntent( "/etc/mtab", "r" ); if ( mntfp ) { while ( (me = getmntent( mntfp )) != 0 ) { QString root = me->mnt_dir; if ( root == "/" ) continue; QString info = root + "/usr/lib/ipkg/info"; QDir infoDir( info ); // odebug << "looking at " << info.ascii() << "" << oendl; if ( infoDir.isReadable() ) { const QFileInfoList *packages = infoDir.entryInfoList( "*.list" ); // No tr QFileInfoListIterator it( *packages ); QFileInfo *fi; while (( fi = *it )) { ++it; if ( knownPackages.contains( fi->fileName() ) ) { // odebug << "found " << fi->fileName() << " and we've seen it before" << oendl; knownPackages.remove( fi->fileName() ); } else { //it's a new one createSymlinks( root, fi->baseName() ); } } } } endmntent( mntfp ); } for ( QStringList::Iterator it = knownPackages.begin(); it != knownPackages.end(); ++it ) { // strip ".info" off the end. removeSymlinks( (*it).left((*it).length()-5) ); } }
status_t AutoConfig::LoadProviderInfo(const BString &provider, provider_info* info) { BPath path; status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path); if (status != B_OK) return status; path.Append(INFO_DIR); BDirectory infoDir(path.Path()); BFile infoFile(&infoDir, provider.String(), B_READ_ONLY); if (infoFile.InitCheck() != B_OK) return B_ENTRY_NOT_FOUND; info->provider = provider; if (ReadProviderInfo(&infoFile, info) == true) return B_OK; return B_ERROR; }
void TimeLapseGenMain::on_actionGenerate_Timelapse_triggered() { imageFileInfo info; QByteArray data; QString outputFilePath; QString destName; bool needEnhancement; QPixmap map; FILE *fp; int rc; enum VideoQuality quality; enum VideoResolution resolution; int framesPerSec ; QString *outPutFileName; if(selectedFileNames.length() == 0 ) { QMessageBox msg; msg.setText("No Images loaded, load images first"); msg.setWindowTitle("Rendering Error !"); msg.setIcon(QMessageBox::Critical); msg.addButton(QMessageBox::Ok); msg.exec(); return; } preferencesDialog = new Preferences(this); if (preferencesDialog->exec() == QDialog::Accepted) { quality = preferencesDialog->getQuality(); resolution = preferencesDialog->getResolution(); framesPerSec = preferencesDialog->getFramesPerSec(); outPutFileName = preferencesDialog->getOutFileName(); outPutFileName->replace(" ", "\\ "); } else return; if ( avconvPresent == false && quality == HighQualityMp4 ) { QMessageBox::critical(this, "Can not render", "Rendering high quality MP4 required avconv utility, please try again with a different quality setting", QMessageBox::Ok); return; } /* First create a sub directory to store the images to render */ QFileInfo infoDir(selectedFileNames[0]); if (!infoDir.dir().exists("resized")) infoDir.dir().mkdir("resized"); /* Setup Progress Bar */ QProgressDialog progress("Resizing Images ....", QString(), 0, selectedFileNames.count(), this); progress.setWindowModality(Qt::WindowModal); progress.show(); outputFilePath = infoDir.path(); if ( brightness == 0 && contrast == 0 && saturation == 0 && eType == None) needEnhancement = false; else needEnhancement = true; /* Now for each image do the following * 1. if brightness or contrast or saturation are specified enhance image accordingly. * 2. If not, directly scale the image to specified size * 3. Save the enhanced/resized image to destination folder i.e resized * 4. Update the progress bar, Since we are enhancing and resizing in the same loop, * change the lable of progress bar to enhancing after 50% */ for(int i=0; i< ImageFileInfoList.size(); i++){ info = ImageFileInfoList.at(i); if (!needEnhancement) { map.load(*info.getFilePath()); //map.scaled(1920,1080, Qt::IgnoreAspectRatio, Qt::SmoothTransformation).save(destName,"JPEG", 95); } else { if ( eType != None) { switch(eType) { case vividImage: data = imageEditor->enhanceImageWithoutScaling(info.getFilePath(), 110, 200, 2000); break; case grayScale: data = imageEditor->enhanceImageWithoutScaling(info.getFilePath(), 100, 0, 100); break; case autoEnhance: data = imageEditor->enhanceImageWithoutScaling(info.getFilePath(), 110, 100, 1400); break; } } else { data = imageEditor->enhanceImageWithoutScaling(info.getFilePath(),(brightness+100), (saturation+100), contrast ); } map.loadFromData(data, "XPM"); } destName.append(outputFilePath.toAscii()); destName.append("/resized/"); destName.append(info.getFileName()); if ( resolution == v720p ) map.scaled(1280,720, Qt::IgnoreAspectRatio, Qt::SmoothTransformation).save(destName,"JPEG", 95); else if (resolution == v1080p ) map.scaled(1920,1080, Qt::IgnoreAspectRatio, Qt::SmoothTransformation).save(destName,"JPEG", 95); else if (resolution == v1440p) map.scaled(2560,1440, Qt::IgnoreAspectRatio, Qt::SmoothTransformation).save(destName,"JPEG", 95); progress.setValue(i); if ( progress.value() == (progress.maximum()/2) ) { if( needEnhancement ) progress.setLabelText("Enhacing Images...."); } destName.clear(); } /* Now start rendering timelapse Video */ /* first list all the files and direct it to a file */ QString cmd; cmd.append("cd "); cmd.append(outputFilePath.replace(" ", "\\ ")); cmd.append("/resized; ls -1rt | grep -v files > files.txt"); qDebug() << "LS Path : " << cmd.toAscii(); fp = popen(cmd.toAscii().constData(), "r"); rc = pclose(fp); if (rc != 0 ){ QMessageBox msg; msg.setWindowTitle("No Idea !"); msg.setText("Someting went wrong while rendering timelapse... !"); msg.setIcon(QMessageBox::Critical); msg.addButton(QMessageBox::Ok); msg.exec(); return; } /* Execute mencoder */ cmd.clear(); cmd.append("cd "); cmd.append(outputFilePath); cmd.append("/resized; "); cmd.append(mencoderCommandPath->toAscii()); cmd.append(" -idx -nosound -noskip -ovc lavc -lavcopts "); if(quality == HighQualityMp4 ) { cmd.append(tr("vcodec=ljpeg -mf fps=%1 'mf://@files.txt' ").arg(framesPerSec)); } else if ( quality == HighQualityAvi) { cmd.append(tr(" vcodec=msmpeg4:vbitrate=10000 -mf type=jpeg -mf fps=%1 'mf://@files.txt' ").arg(framesPerSec)); } else if ( quality == LowQualityMp4) { cmd.append(tr("vcodec=mpeg4 -mf fps=%1 'mf://@files.txt' ").arg(framesPerSec)); } if ( quality == HighQualityMp4 ) { cmd.append(" -o temp.avi; "); cmd.append("avconv -i temp.avi -c:v libx264 -preset slow -crf " ); cmd.append(tr("%1 ").arg(framesPerSec)); cmd.append(*outPutFileName); } else cmd.append(tr(" -o %1").arg(*outPutFileName)); qDebug() << "CMD : " << cmd.toAscii() << endl; /* Now execute mencoder command */ renderVideo(cmd); }