void WizUpdaterDialog::doUpdateApp()
{
    // read metadata
    QList<QStringList> files;

    setGuiNotify("Prepare upgrade");

    QString strConfig = ::WizGetUpgradePath() + "config.txt";
    WizSettings* config = new WizSettings(strConfig);

    int i = 0;
    QString strFileEntry = config->getString("Files", QString::number(i));
    while (!strFileEntry.isEmpty()) {
        QStringList strFileMeta = strFileEntry.split("*");

        QStringList strFile;
        strFile << strFileMeta.at(0) << strFileMeta.at(1);
        files.append(strFile);

        i++;
        strFileEntry = config->getString("Files", QString::number(i));
    }

    QList<QStringList>::const_iterator it;
    for(it = files.constBegin(); it!= files.constEnd(); it++) {
        QString strLocal = ::WizGetAppPath() + (*it).at(0);
        QString strLocalPath = ::WizExtractFilePath(strLocal);
        QString strUpdate = ::WizGetUpgradePath() + (*it).at(0);
        QString strUpdatePath = ::WizExtractFilePath(strUpdate);

        QFile fileUpdate(strUpdate);
        if (fileUpdate.exists()) {
            // compare MD5
            QString md5Remote = (*it).at(1);
            QString md5Download = ::WizMd5FileString(strUpdate);

            if (md5Remote == md5Download) {
                ::WizEnsurePathExists(strLocalPath);
                fileUpdate.copy(strLocal);
                fileUpdate.remove();
                setGuiNotify(QString("Copying %1").arg(strLocal));
            }
        }

        ::WizDeleteFolder(strUpdatePath);
    }

    // remove config file
    QFile fileConfig(strConfig);
    fileConfig.remove();
    QFile fileZip(::WizGetUpgradePath() + "update.zip");
    fileZip.remove();

    // remove stub
    QFile fileStub(::WizGetUpgradePath() + "WIZNOTE_READY_FOR_UPGRADE");
    fileStub.remove();

    setGuiNotify("Upgrade done");
    ui->progressUpdate->setValue(ui->progressUpdate->maximum());
}
예제 #2
0
//============================================================================================================
// _readConfigFile
//------------------------------------------------------------------------------------------------------------
// Read target config file
//============================================================================================================
void dlgConfigEditor::_readConfigFile()
{
    cTracer tracer("_readConfigFile");

    m_qsFileName = QString( "%1/%2" ).arg(m_qsDirConf).arg(ui->ledFileName->text());
    ui->ledFileName->setToolTip( m_qsFileName );

    QFile   fileConfig( m_qsFileName );

    m_vTestCases.clear();

    if( !fileConfig.open(QIODevice::ReadOnly | QIODevice::Text) )
        return;

    QTextStream in(&fileConfig);
    QStringList qslTestCase;

    QString line = in.readLine();

    if( line.contains("<atp_config") )
    {
        m_bConfigXML = true;
        fileConfig.close();
        _readConfigXml( m_qsFileName );
    }
    else
    {
        m_bConfigXML = false;
        while( !in.atEnd() )
        {
            if( line.contains( "<testproc>" ) )
            {
                if( qslTestCase.count() > 0 )
                {
                    m_vTestCases.append( qslTestCase );
                    qslTestCase.clear();
                }
                qslTestCase << _addTestProcedure( line );
            }
            else if( line.contains( "<testcase>" ) )
            {
                qslTestCase << _addTestProcedure( line );
            }

            line = in.readLine();
        }

        if( qslTestCase.count() > 0 )
        {
            m_vTestCases.append( qslTestCase );
        }

        fileConfig.close();
    }
}
예제 #3
0
void WXCConfig::ReadConfig ()
{
    wxFileInputStream   is(WXC_CONFIG);
    wxFileConfig        fileConfig(is);
    long                lVal;

    // maximum log-file size
    if ( fileConfig.Read("log-size", &lVal) )
        lMaxSize_ = lVal;

    // crontab check intervall
    if ( fileConfig.Read("crontab-check", &lVal) )
        lCheckCrontab_ = lVal;
}
예제 #4
0
/**
 * This function creates a datasource object based on either a descriptor
 * or a file.
 * @param aFile - If 'ETrue', datasource if file based, else it's descriptor based.
 * @param aFilename - If filebased, this is the file name passed to the DataSource
 *					  If descriptor based, the data is read from the file.
 * @param aOffset - The offset from the start of the file to read (for Descriptor
 *				     based DataSources only)
 */
void CTestStep_MMF_AFMT::CreateDataSource(const TBool& aFile, const TDesC& aFilename,
        const TUint& aOffset)
{
    if (aFile)
    {   // File based DataSource (making a CMMFFile object)
        TMMFFileParams fileParams ;
        fileParams.iPath = TFileName(aFilename) ;
        TMMFFileConfig fileConfig( fileParams ) ;

        // Create the iDataSource object.
        iDataSource = STATIC_CAST(CMMFFile*, MDataSource::NewSourceL( KUidMmfFileSource,
                                  *STATIC_CAST(TDesC8*,&fileConfig)));
    }
    else
    {   // Descriptor based DataSource
예제 #5
0
bool WXCConfig::SaveConfig ()
{
    wxFileInputStream   is(WXC_CONFIG);
    wxFileConfig        fileConfig(is);

    // maximum log-file size
    fileConfig.Write("log-size", lMaxSize_);

    // crontab check intervall
    fileConfig.Write("crontab-check", lCheckCrontab_);

    // save
    wxFileOutputStream os(WXC_CONFIG);

    if ( !(fileConfig.Save(os)) )
    {
        WXCLog::Do(wxString::Format("Error while saving the config file %s.", WXC_CONFIG));
        return false;
    }

    return true;
}
예제 #6
0
//============================================================================================================
// _saveConfigSettings
//------------------------------------------------------------------------------------------------------------
// Overwrite the target config file based on the selections in the test item listbox
//============================================================================================================
void dlgConfigEditor::_saveConfigSettings()
{
    cTracer tracer("_saveConfigSettings");

    tgPrefs::instance().setTestReportRevision( ui->ledTestReportRevision->text() );
    tgPrefs::instance().setTesterName( ui->ledTesterName->text() );
    tgPrefs::instance().setTestEnvironment( ui->ledEnvironmentName->text() );

    QFile   fileConfig( m_qsFileName );

    fileConfig.copy( QString( "%1/ATP_backup_%2.config" ).arg(m_qsDirConf).arg(QDateTime::currentDateTime().toString("yyyyMMdd_hhmmss")) );

    fileConfig.open( QIODevice::WriteOnly );

    if( m_bConfigXML )
    {
        fileConfig.write( "<atp_config version=\"2.0\">\n\n    <header>\n" );
        fileConfig.write( QString("        <setting fail_silent=\"%1\" />\n").arg((ui->chkSilent->isChecked()?"1":"0")).toStdString().c_str() );
        if( m_tcSystemType == tgPrefs::instance().TC_AIF )
        {
            fileConfig.write( QString("        <setting only_tp=\"%1\" />\n").arg((ui->chkOnlyTP->isChecked()?"1":"0")).toStdString().c_str() );
        }
        fileConfig.write( QString("        <setting system_release=\"%1\" />\n").arg(ui->ledReleaseVersion->text()).toStdString().c_str() );
        fileConfig.write( QString("        <setting testreport_revision=\"%1\" />\n").arg(ui->ledTestReportRevision->text()).toStdString().c_str() );
        fileConfig.write( QString("        <setting tester_name=\"%1\" />\n").arg(ui->ledTesterName->text()).toStdString().c_str() );
        fileConfig.write( QString("        <setting test_environment=\"%1\" />\n").arg(ui->ledEnvironmentName->text()).toStdString().c_str() );
        fileConfig.write( QString("        <setting itu_address=\"%1\" />\n").arg(ui->ledITUAddress->text()).toStdString().c_str() );
        fileConfig.write( "    </header>\n\n    <testcases>\n" );

        for( int i=0; i<ui->treeTestElements->topLevelItemCount(); i++ )
        {
            QString          qsLine;
            QTreeWidgetItem *itemTestCase = ui->treeTestElements->topLevelItem(i);

            qsLine = "";
            qsLine.append( "\n        <testitem name=\"" );
            qsLine.append( itemTestCase->text(2) );
            qsLine.append( "\" filename=\"" );
            qsLine.append( itemTestCase->text(1) );
            qsLine.append( "\" execute=\"" );
            qsLine.append( (itemTestCase->checkState(0)==Qt::Checked?"1":"0") );
            qsLine.append( "\" flags=\"" );
            qsLine.append( itemTestCase->text(3) );
            qsLine.append( "\">\n" );

            fileConfig.write( qsLine.toStdString().c_str() );

            for( int j=0; j<itemTestCase->childCount(); j++ )
            {
                QTreeWidgetItem *itemTestProcedure = itemTestCase->child( j );

                qsLine = "";
                qsLine.append( "            <testproc name=\"" );
                qsLine.append( itemTestProcedure->text(2) );
                qsLine.append( "\" execute=\"" );
                qsLine.append( (itemTestProcedure->checkState(0)==Qt::Checked?"1":"0") );
                qsLine.append( "\" flags=\"" );
                qsLine.append( itemTestProcedure->text(3) );
                qsLine.append( "\" />\n" );

                fileConfig.write( qsLine.toStdString().c_str() );
            }

            fileConfig.write( "        </testitem>\n" );
        }

        /*
        bool    bTestItemStarted = false;

        for( int i=0; i<ui->listTestElements->count(); i++ )
        {
            QString qsLine      = ui->listTestElements->item(i)->text();
            //QStringList qslItem = ui->listTestElements->item(i)->text().split( QChar(' ') );
            QString qsEnabled   = ( ui->listTestElements->selectedItems().contains(ui->listTestElements->item(i)) ? "1" : "0" );

            QString qsName      = qsLine.left( qsLine.indexOf(QChar(' ')) ); //qslItem.at(0);
            QString qsTitle     = ( !qsName.contains("\t") ? qsLine.mid( qsLine.indexOf(QChar('('))+1, (qsLine.indexOf(QChar(')'))-qsLine.indexOf(QChar('('))-1) ) : "" );
            QString qsComment   = ( qsLine.contains(QChar('#')) ? qsLine.right( qsLine.length()-qsLine.indexOf(QChar('#')) ) : "" ); //QString( ( qslItem.count()>1 ? qslItem.at(1) : "" ) ).remove("#");

            if( qsName.contains("\t") )
            {
                qsLine = QString( "            <testproc name=\"%1\" execute=\"%2\" flags=\"%3\" />" ).arg(qsName.remove("\t")).arg(qsEnabled).arg(qsComment.remove("#"));
            }
            else
            {
                if( bTestItemStarted )
                {
                    fileConfig.write( "\n        </testitem>\n" );
                }
                qsLine = QString( "\n        <testitem name=\"%1\" filename=\"%2\" execute=\"%3\" flags=\"%4\">\n" ).arg(qsTitle).arg(qsName).arg(qsEnabled).arg(qsComment.remove("#"));
                bTestItemStarted = true;
            }

            fileConfig.write( QString("%1\n").arg(qsLine).toStdString().c_str() );
        }
        if( bTestItemStarted )
        {
            fileConfig.write( "\n        </testitem>\n" );
        }*/
        fileConfig.write( "\n    </testcases>\n\n</atp_config>\n" );
        fileConfig.write( QString("\n").toStdString().c_str() );
    }
    // No need for supporting old version config file
    /*else
    {
        fileConfig.write( QString("<fail-silent> %1\n").arg((ui->chkSilent->isChecked()?"1":"0")).toStdString().c_str() );
        if( m_tcSystemType == tgPrefs::instance().TC_AIF )
        {
            fileConfig.write( QString("<onlyTP> %1\n").arg((ui->chkOnlyTP->isChecked()?"1":"0")).toStdString().c_str() );
        }

        for( int i=0; i<ui->listTestElements->count(); i++ )
        {
            QString qsLine;
            QStringList qslItem = ui->listTestElements->item(i)->text().split( QChar(' ') );

            if( qslItem.at(0).contains("\t") )
            {
                qsLine += QString("    <testcase> %1").arg( qslItem.at(0) ).remove("\t");
            }
            else
            {
                qsLine += QString("\n<testproc> %1").arg( qslItem.at(0) );
            }

            if( ui->listTestElements->selectedItems().contains( ui->listTestElements->item(i) ) )
            {
                qsLine += QString(" 1 ");
            }
            else
            {
                qsLine += QString(" 0 ");
            }

            if( qslItem.count() > 1 )
            {
                qsLine += QString("      %1").arg(qslItem.at(1));
            }

            fileConfig.write( QString("%1\n").arg(qsLine).toStdString().c_str() );
        }
        fileConfig.write( QString("\n").toStdString().c_str() );
    }*/

    fileConfig.close();
}
예제 #7
0
파일: ddz.cpp 프로젝트: chindit/dadaword
QStringList DDZ::ouvre(QString nom){
    //Variables globales
    QString contenu;
    QStringList retour;
    ErrorManager instance_erreur;

    //---------------------------------------------
    //Extraction de l'archive
    //---------------------------------------------

    //Instance QZipReader
    QZipReader ddz_global(nom, QIODevice::ReadOnly);
    //Extraction
    ddz_global.extractAll(QDir::tempPath());


    //---------------------------------------------
    //Ouverture du fichier principal (DDW)
    //---------------------------------------------
    QString nom_fichier = nom.split("/").last();
    nom_fichier.remove(nom_fichier.size()-4, nom_fichier.size()).append(".ddw").prepend(QDir::tempPath()+"/");
    QFile file(nom_fichier);
    if(file.open(QFile::ReadOnly)){
        QTextStream in(&file);
        contenu = in.readAll();
        file.close();
        retour.append(contenu);
    }
    else{
        instance_erreur.Erreur_msg(QObject::tr("DDZ : Erreur lors de la lecture du contenu du document."), QMessageBox::Ignore);
        retour.append("NULL");
        return retour;
    }

    //-----------------------------------------------------
    //Renommage des images contenues (selon l'OS)
    //-----------------------------------------------------
    int nb_images = retour.at(0).count("<img src=");

    //Il y a des images, on rentre dans la boucle
    if(nb_images > 0){
        //Définition de la RegExp
        QRegExp regexp_images("<img[^>]*src=\"([^\"]*)");

        //Récupération des images
        int pos = 0; QStringList list;
        while ((pos = regexp_images.indexIn(contenu, pos)) != -1){
            list << regexp_images.cap(1);
            pos += regexp_images.matchedLength();
        }

        if(nb_images != list.size()){
            //On a pas trouvé toutes les images (ou on en a trouvé trop, ce qui est pire)
            instance_erreur.Erreur_msg(QObject::tr("Problème lors de la détection d'images -> annulation de l'ouverture"), QMessageBox::Ignore);
            retour.append("NULL");
            return retour;
        }

        //On change le chemin des images
        for(int i=0; i<list.size(); i++){
            QString nom_image = list.at(i).split("/").last();
            QString temp = retour.at(0);
            temp.replace(list.at(i), QDir::tempPath()+"/"+nom_image);
            retour.removeFirst();
            retour.prepend(temp);
        }
    }

    //Ouverture de la configuration
    QFile fileConfig(QDir::tempPath()+"/config.xml");
QString *erreur = new QString;int *er1 =new int;int *er2 = new int;
    QDomDocument config("Config");
        if(!fileConfig.open(QIODevice::ReadOnly)){
            instance_erreur.Erreur_msg(QObject::tr("DDZ : Erreur lors de l'ouverture du fichier de configuration"), QMessageBox::Ignore);
            retour.append("NULL");
            return retour;
        }
        QString contenuxml = fileConfig.readAll().simplified();
        if (!config.setContent(contenuxml, true, erreur, er1, er2)){
            instance_erreur.Erreur_msg(QObject::tr("DDZ : Impossible d'attribuer le fichier de configuration à la variable QDomDocument"), QMessageBox::Ignore);
            retour.append("NULL");
            return retour;
        }
    fileConfig.close();


    QDomElement racine = config.documentElement();
    //Lecture de la langue
    QDomNodeList langue = racine.elementsByTagName("langue");
    if(!langue.isEmpty()){
        QString Slangue = langue.at(0).toElement().text();
        QRegExp is_dico("^[a-z]{2}_[A-Z]{2}$");
        if(is_dico.exactMatch(Slangue)){
            retour.append(Slangue);
        }
        else{
            retour.append("default");
        }
    }

    QDomNodeList liste_annexes = racine.elementsByTagName("annexe");
    if(!liste_annexes.isEmpty()){
        for(int i=0; i<liste_annexes.count(); i++){
            retour.append(QDir::tempPath()+"/"+liste_annexes.at(i).toElement().text());
        }
    }

    //Mots ignorés
    QDomNodeList liste_mots = racine.elementsByTagName("mot");
    if(!liste_mots.isEmpty()){
        for(int i=0; i<liste_mots.count(); i++){
            motsIgnores.append(liste_mots.at(i).toElement().text());
        }
    }

    return retour;
}
예제 #8
0
int mainTest(int argNumber, char* argString[])
{
    //Init Logger
    Logger::getInstance()->setLoggingLevel(eINFO);

    //We create a folder for background substraction configuration file. BGSLib will crash if that folder doesn't exist.
    boost::filesystem::create_directory("config");

    //We load the tracking configuration
    po::options_description fileConfig("Configuration file options");
    po::variables_map vm = LoadConfigurationSettings(argNumber, argString, fileConfig);
    if(vm.count("logging-level") >0)
    {
        unsigned int level = vm["logging-level"].as<unsigned int>();
        if(level >= 0 && level <= eNONE)
            Logger::getInstance()->setLoggingLevel(ELoggingLevel(level));
    }


    //We load the video
    bool overrideTotalNbFrame = false;
    unsigned int lastFrame = -1;
    InputFrameProviderIface* vfm = LoadVideo(vm, overrideTotalNbFrame, lastFrame);
    try
    {
        if(vfm && vfm->isOpen())
        {
            LOGINFO("Starting tracker");

            bool success = true;
            DrawableTimer dt;


            float pixelByMeter = 1;
            if(vm.count("scaleratio-filename") > 0 && vm["scaleratio-filename"].as<std::string>() != "none" && vm["scaleratio-filename"].as<std::string>() != "None")
            {
                success = Utils::IO::LoadScalar<float>(vm["scaleratio-filename"].as<std::string>(), pixelByMeter);
                if(!success)
                {
                    pixelByMeter = 1;
                    LOGWARNING("Can't load scale ratio file. Using 1px/m ratio");
                }
            }

            cv::Mat homography = cv::Mat::eye(3,3, CV_32FC1);
            if(vm.count("homography-filename") > 0 && vm["homography-filename"].as<std::string>() != "none" && vm["homography-filename"].as<std::string>() != "None")
            {
                success = Utils::IO::LoadMatrix<double>(vm["homography-filename"].as<std::string>(), homography);
                if(!success)
                {
                    homography = cv::Mat::eye(3,3, CV_32FC1);
                    LOGWARNING("Can't load homography file. Using identity.");
                }
            }
            cv::Mat mask;

            if(vm.count("mask-filename") > 0 && vm["mask-filename"].as<std::string>() != "none" && vm["mask-filename"].as<std::string>() != "None")
            {
                mask = cv::imread(vm["mask-filename"].as<std::string>());
                cv::cvtColor(mask, mask, CV_BGR2GRAY);
            }
            else
            {
                mask = cv::Mat(vfm->getHeight(), vfm->getWidth(), CV_8UC1);
                mask.setTo(cv::Scalar(255,255,255));
            }


            /*if(vm.count("aerialview-filename") > 0)
            {
                std::string aerialfn(vm["aerialview-filename"].as<std::string>());
                const cv::Mat aerialView = cv::imread(aerialfn);
            }*/


            DrawingFlags drawFlags = LoadDrawingFlags(vm);
            BlobTrackerAlgorithmParams algoParams = LoadTrackerParams(vm);
            DisplayInstruction();

            ApplicationContext context(mask, homography,(float)vfm->getNbFPS(), pixelByMeter, drawFlags, algoParams, vm["record-bgs"].as<bool>(), vfm);
            TrackerPersistance op(&context, vm["object-sqlite-filename"].as<std::string>());
            op.init();
            std::string bgsRecord = vm["bgs-filepath"].as<std::string>();
            context.setBGSPath(bgsRecord);
            std::string bgsType = vm["bgs-type"].as<std::string>();

            Tracker t(&context, bgsType);
            if(bgsType == "PlaybackBGS" && vm.count("bgs-filepath") > 0)
            {
                IBGS* bgs = t.getBlobDetector()->getBGS();
                PlaybackBGS* pbBGS = dynamic_cast<PlaybackBGS*>(bgs);
                if(pbBGS)
                    pbBGS->setPath(bgsRecord);
//                std::cout<<"remove playBackBgs\n";
//                exit(-1);
            }

            //bgs-filepath
            cv::Mat m;
            bool stepByStep = false;
            bool quit = false;
            bool displayMemory = vm["draw-memory"].as<bool>();


            if(!vfm->isOpen())
            {
                LOGERROR("Can't open video file");
                return 0;
            }
            int nbFrameProcess = 0;
            while(vfm->getNextFrame(m) && !quit && (!overrideTotalNbFrame || vfm->getNextFramePos() <= vfm->getNbFrame()) &&  (vfm->getNextFramePos() <= lastFrame || lastFrame == -1))
            {
                context.setCurrentFrame(m);
                dt.start();
                t.processFrame(m);
                dt.stop();
                if(context.getRefDrawingFlags()->mDrawFPS)
                    dt.drawFPS(m);

                cv::Mat trajectoryPictureClone = m.clone();
                if(drawFlags.mDrawPerspective)
                {
                    t.draw(m);
                    #ifdef _WIN32
                    if(displayMemory)
                    {
                        PROCESS_MEMORY_COUNTERS memCounter;
                        bool result = GetProcessMemoryInfo(GetCurrentProcess(), &memCounter, sizeof( memCounter ));
                        float nbMeg = memCounter.WorkingSetSize/(1048576.f);
                        cv::putText(m, Utils::String::toString(nbMeg)+ " Mo", cv::Point(0,m.rows-5), cv::FONT_HERSHEY_DUPLEX, 1, cv::Scalar(0,255,255),2);
                    }
                    #endif
                    cv::imshow("Video", m);
                    int key;
                    if(stepByStep)
                    {
                        key = cv::waitKey();
                    }
                    else
                        key = cv::waitKey(1);

                    if(key == 's')
                    {
                        stepByStep = !stepByStep;
                    }
                    else if(key == 'm')
                    {
                        displayMemory = !displayMemory;
                    }
                    else if(key == 'q')
                    {
                        std::cout << "Quit was requested. Exiting...";
                        quit = true;
                    }
                    else
                        UpdateContextFromKeys(&context, key);
                }
                ++nbFrameProcess;
                if(nbFrameProcess %50 == 0)
                    std::cout << "Frame " << nbFrameProcess << std::endl;
            }
            delete vfm;
        }
        else
        {
            LOGWARNING("Config file not loaded");
            LOGINFO("Loaded options:\n" << getParameterDescription(fileConfig, vm));

            if (vm.count("help"))
            {
                std::cout << fileConfig << std::endl;
            }
        }
    }
    catch(std::exception& e)
    {
        LOGASSERT(false, "Unhandled exception: " << e.what());
    }



    Logger::getInstance()->cleanUp();
    return 0;
}
예제 #9
0
void BGDialog::loadWallpaperFilesList()
{

    // Wallpapers
    // the following QMap is lower cased names mapped to cased names and URLs
    // this way we get case insensitive sorting
    QMap<QString, QPair<QString, QString> > papers;

    //search for .desktop files before searching for images without .desktop files
    QStringList lst = m_pDirs->findAllResources("wallpaper", "*desktop", KStandardDirs::NoDuplicates);
    QStringList files;
    for (QStringList::ConstIterator it = lst.constBegin(); it != lst.constEnd(); ++it) {
        KDesktopFile fileConfig(*it);
        KConfigGroup cg = fileConfig.group("Wallpaper");

        QString imageCaption = cg.readEntry("Name");
        QString fileName = cg.readEntry("File");

        if (imageCaption.isEmpty()) {
            imageCaption = fileName;
            imageCaption.replace('_', ' ');
            imageCaption = KStringHandler::capwords(imageCaption);
        }

        // avoid name collisions
        QString rs = imageCaption;
        QString lrs = rs.toLower();
        for (int n = 1; papers.find(lrs) != papers.end(); ++n) {
            rs = imageCaption + " (" + QString::number(n) + ')';
            lrs = rs.toLower();
        }
        int slash = (*it).lastIndexOf('/') + 1;
        QString directory = (*it).left(slash);
        if (cg.readEntry("ImageType") == QLatin1String("pixmap")) {
            papers[lrs] = qMakePair(rs, QString(directory + fileName));
            files.append(directory + fileName);
        }
    }

    //now find any wallpapers that don't have a .desktop file
    lst = m_pDirs->findAllResources("wallpaper", "*", KStandardDirs::NoDuplicates);
    for (QStringList::ConstIterator it = lst.constBegin(); it != lst.constEnd(); ++it) {
        if (!(*it).endsWith(".desktop") && files.filter(*it).empty()) {
            // First try to see if we have a comment describing the image.  If we do
            // just use the first line of said comment.
            KFileMetaInfo metaInfo(*it);
            QString imageCaption;

            if (metaInfo.isValid() && metaInfo.item("Comment").isValid())
                imageCaption = metaInfo.item("Comment").value().toString().section('\n', 0, 0);

            if (imageCaption.isEmpty()) {
                int slash = (*it).lastIndexOf('/') + 1;
                int endDot = (*it).lastIndexOf('.');

                // strip the extension if it exists
                if (endDot != -1 && endDot > slash)
                    imageCaption = (*it).mid(slash, endDot - slash);
                else
                    imageCaption = (*it).mid(slash);

                imageCaption.replace('_', ' ');
                imageCaption = KStringHandler::capwords(imageCaption);
            }

            // avoid name collisions
            QString rs = imageCaption;
            QString lrs = rs.toLower();
            for (int n = 1; papers.find(lrs) != papers.end(); ++n) {
                rs = imageCaption + " (" + QString::number(n) + ')';
                lrs = rs.toLower();
            }
            papers[lrs] = qMakePair(rs, *it);
        }
    }

    KComboBox *comboWallpaper = m_urlWallpaperBox;
    comboWallpaper->clear();
    m_wallpaper.clear();
    int i = 0;
    for (QMap<QString, QPair<QString, QString> >::Iterator it = papers.begin();
            it != papers.end();
            ++it) {
        comboWallpaper->addItem(it.value().first);
        m_wallpaper[it.value().second] = i;
        i++;
    }
}