Ejemplo n.º 1
0
void SearchWidget::accept()
{
    if(ui->checkBox_regex->isChecked()) {
        QRegExp regex(ui->comboBox_search->currentText(),
            ui->checkBox_caseSensitive->isChecked() ? Qt::CaseSensitive: Qt::CaseInsensitive,
            QRegExp::RegExp2);
        if(!regex.isValid()) {
            QString message;
            QTextStream(&message)
                << tr("The pattern \"")
                << ui->comboBox_search->currentText()
                << tr("\" is invalid.");
            QMessageBox::critical(this, YApplication::displayAppName(), message);
            ui->comboBox_search->setFocus();
            return;
        }
    }
    SearchCriteria sc(
        ui->comboBox_search->currentText(),
        ui->checkBox_caseSensitive->isChecked(),
        ui->checkBox_regex->isChecked());
    SearchInfo::instance().acceptNewSearch(sc);
    QDialog::accept();
}
Ejemplo n.º 2
0
void HardwareHiqsdr :: processAnswer (QStringList list)
{
    if (list[0] == "*getserial?") {
       // try to set the serial
       qDebug() << Q_FUNC_INFO<<list[2];
       // change the title bar
       QString x;
       x.clear(); 
       QTextStream(&x) << windowTitle() << " - SN: " << list[2];

       setWindowTitle(x) ;
    }

    if (list[0] == "*getpreselector?") {
       // try to set the serial
       qDebug() << Q_FUNC_INFO << list [1] << list[2] << list[3] ;
       // change the preselector buttons
       int x = list[1].toInt() ;
       
       if (x >= 0 && x < 16) {
           psel[x]->setText(list[3]);
       }
    }
    
    if (list[0] == "getpreampstatus?") {
       // try to set the serial
       qDebug() << Q_FUNC_INFO << list [1] << list[2] << list[3] ;
       // change the preamp button
       int x = list[1].toInt() ;
       
       if (x >= 0 && x <= 1) {
           preampVal = x;
           preamp->setChecked((preampVal == 1) ? true : false);   
       }
    }
}
Ejemplo n.º 3
0
// search local database for discID
bool Dbase::Search(Cddb::Matches& res, const Cddb::discid_t discID)
{
    res.matches.empty();

    if (CacheGet(res, discID))
        return true;

    QFileInfoList list = QDir(GetDB()).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
    for (QFileInfoList::const_iterator it = list.begin(); it != list.end(); ++it)
    {
        QString genre = it->baseName();

        QFileInfoList ids = QDir(it->canonicalFilePath()).entryInfoList(QDir::Files);
        for (QFileInfoList::const_iterator it2 = ids.begin(); it2 != ids.end(); ++it2)
        {
            if (it2->baseName().toUInt(0,16) == discID)
            {
                QFile file(it2->canonicalFilePath());
                if (file.open(QIODevice::ReadOnly | QIODevice::Text))
                {
                    Cddb::Album a = QTextStream(&file).readAll();
                    a.discGenre = genre;
                    a.discID = discID;
                    LOG(VB_MEDIA, LOG_INFO, QString("LocalCDDB found %1 in ").
                        arg(discID,0,16) + genre + " : " +
                        a.artist + " / " + a.title);

                    CachePut(a);
                    res.matches.push_back(Cddb::Match(genre,discID,a.artist,a.title));
                }

            }
        }
    }
    return res.matches.size() > 0;
}
Ejemplo n.º 4
0
luabind::object LuaEngine::loadClassAPI(const QString &path)
{
    if(loadedFiles.contains(path))
    {
        return loadedFiles[path];
    }

    QFile luaCoreFile(path);
    if(!luaCoreFile.open(QIODevice::ReadOnly)){
        qWarning() << "Failed to load up \"" << path << "\"! Wrong path or insufficient access?";
        shutdown();
        return luabind::object();
    }

    //Now read our code.
    QString luaCoreCode = QTextStream(&luaCoreFile).readAll();

    //Now load our code by lua and check for common compile errors
    int errorCode = luautil_loadclass(L, luaCoreCode.toLocal8Bit().data(), luaCoreCode.length(), m_coreFile.section('/', -1).section('\\', -1).toLocal8Bit().data());
    //If we get an error, then handle it
    if(errorCode){
        qWarning() << "Got lua error, reporting...";
        m_errorReporterFunc(QString(lua_tostring(L, -1)), QString(""));
        m_lateShutdown = true;
        return luabind::object();
    }

    luabind::object tReturn(luabind::from_stack(L, -1));
    if(luabind::type(tReturn) != LUA_TUSERDATA){
        qWarning() << "Invalid return type of loading class";
        return luabind::object();
    }

    loadedFiles[path]=tReturn;
    return tReturn;
}
Ejemplo n.º 5
0
void UI::actionMedium() {
    QString command;

    // reset the current selection
    switch(agc) {
    case AGC_LONG:
        widget.actionLong->setChecked(FALSE);
        break;
    case AGC_SLOW:
        widget.actionSlow->setChecked(FALSE);
        break;
    case AGC_MEDIUM:
        widget.actionMedium->setChecked(FALSE);
        break;
    case AGC_FAST:
        widget.actionFast->setChecked(FALSE);
        break;
    }
    agc=AGC_MEDIUM;

    command.clear(); QTextStream(&command) << "SetAGC " << agc;
    connection.sendCommand(command);

}
Ejemplo n.º 6
0
void Pt_MSlider::cleanup()
{
    // save a shot (for debugging)
#define SCREENSHOT
#ifdef SCREENSHOT
    QString kuva;
    QTextStream(&kuva)
            << "view_"
            << ".png";
    if (!written.contains(kuva)) {
        this->pixmap->save(kuva, "png", -1);
        this->written.append(kuva);
    }
#endif

    delete this->m_subject;
    this->m_subject = 0;

    delete this->painter;
    this->painter = 0;
    delete this->pixmap;
    this->pixmap = 0;

}
Ejemplo n.º 7
0
PixelScene::PixelScene(QObject *parent) :
    QGraphicsScene(parent)
{
    for(int i = 0; i < windowYNumber*windowXNumber*windowHeight*windowWidth; i++)
        pixels.append(new Pixel());
    for(int i = 0; i < windowYNumber; i++)
    {
        for(int j = 0; j < windowXNumber; j++)
        {
            Window* w = new Window();
            for(int k = 0; k < windowHeight; k++)
            {
                for(int l = 0; l < windowWidth; l++)
                {
                    int x1 = j*windowWidth*pixelSize + j*gapWidth + l*pixelSize;
                    int x2 = j*windowWidth*pixelSize + j*gapWidth + (l+1)*pixelSize;
                    int y1 = i*windowHeight*pixelSize + i*gapHeight + k*pixelSize;
                    int y2 = i*windowHeight*pixelSize + i*gapHeight + (k+1)*pixelSize;

                    int index = i*windowWidth*windowHeight*windowXNumber + j*windowWidth + k*windowWidth*windowXNumber + l;
                    pixels[index]->rect.adjust(x1,y1,x2,y2);
                    pixels[index]->window = w;
                    pixels[index]->index = index;
                    w->indexes.append(index);
                    addItem(pixels[index]);
                }
            }
            windows.append(w);
        }
    }
    onlypixelswidth = pixelSize * windowWidth * windowXNumber;
    onlypixelsheight = pixelSize * windowHeight * windowYNumber;
    width = onlypixelswidth + gapWidth * (windowXNumber-1);
    height = onlypixelsheight + gapHeight * (windowYNumber-1);
    QTextStream(stdout) << "Onlypixels:" << endl;
    QTextStream(stdout) << onlypixelswidth << endl;
    QTextStream(stdout) << onlypixelsheight << endl;
    QTextStream(stdout) << "Whole image:" << endl;
    QTextStream(stdout) << width << endl;
    QTextStream(stdout) << height << endl;
}
Ejemplo n.º 8
0
bool Database::addAlbum(Album *newAlbum)
{
    int new_id;
    QString text;

    // obter indice a adicionar
    QSqlQuery last_id;
    last_id.prepare("select ID_Album from Album order by ID_Album DESC Limit 1;");

    if(last_id.exec())
    {
        last_id.next();
        new_id = last_id.value(0).toInt();
        qDebug() << "Ultimo ID=" << new_id;
        new_id++; // ID do proximo elemento a adicionar
        newAlbum->setIdBD(new_id);
    }else{
        return false;
    }

    // Adicionar Info à DB
    QSqlQuery add_album;
    text = "";
    QTextStream(&text) << "insert into Album (Nome,Ano,Genero,Diretoria,Descricao) values ('";
    QTextStream(&text) << newAlbum->getNome() << "','";
    QTextStream(&text) << newAlbum->getAno() << "','";
    QTextStream(&text) << newAlbum->getGenero() << "','";
    QTextStream(&text) << newAlbum->getDiretoria() << "','";
    QTextStream(&text) << newAlbum->getDescricao() << "') ;";
    add_album.prepare(text);

    if(!add_album.exec())
    {
        qDebug() << "Album Nao Adicionado";
        return false;
    }

    return true;
}
Ejemplo n.º 9
0
void doMagicIn(QString path, QString q, QString OPath)
{
    QRegExp isMask = QRegExp("*m.gif");
    isMask.setPatternSyntax(QRegExp::Wildcard);

    QRegExp isBackupDir = QRegExp("*/_backup/");
    isBackupDir.setPatternSyntax(QRegExp::Wildcard);

    if(isBackupDir.exactMatch(path))
        return; //Skip backup directories

    if(isMask.exactMatch(q))
        return;

    QImage target;
    QString imgFileM;
    QStringList tmp = q.split(".", QString::SkipEmptyParts);
    if(tmp.size()==2)
        imgFileM = tmp[0] + "m." + tmp[1];
    else
        return;

    //skip unexists pairs
    if(!QFile(path+q).exists())
        return;

    if(!QFile(path+imgFileM).exists())
    {
        QString saveTo;

        QImage image = loadQImage(path+q);
        if(image.isNull()) return;

        QTextStream(stdout) << QString(path+q+"\n").toUtf8().data();

        saveTo = QString(OPath+(tmp[0].toLower())+".gif");
        //overwrite source image (convert BMP to GIF)
        if(toGif( image, saveTo ) ) //Write gif
        {
            QTextStream(stdout) <<"GIF-1 only\n";
        }
        else
        {
            QTextStream(stdout) <<"BMP-1 only\n";
            image.save(saveTo, "BMP"); //If failed, write BMP
        }
        return;
    }

    if(!noBackUp)
    {
        //create backup dir
        QDir backup(path+"_backup/");
        if(!backup.exists())
        {
            QTextStream(stdout) << QString("Create backup with path %1\n").arg(path+"_backup");
            if(!backup.mkdir("."))
                QTextStream(stderr) << QString("WARNING! Can't create backup directory %1\n").arg(path+"_backup");

        }

        //create Back UP of source images
        if(!QFile(path+"_backup/"+q).exists())
            QFile::copy(path+q, path+"_backup/"+q);
        if(!QFile(path+"_backup/"+imgFileM).exists())
            QFile::copy(path+imgFileM, path+"_backup/"+imgFileM);
    }

    QImage image = loadQImage(path+q);
    QImage mask = loadQImage(path+imgFileM);

    if(mask.isNull()) //Skip null masks
        return;

    target = setAlphaMask(image, mask);

    if(!target.isNull())
    {
        //Save before fix
        //target.save(OPath+tmp[0]+"_before.png");
        //mask.save(OPath+tmp[0]+"_mask_before.png");
        QTextStream(stdout) << QString(path+q+"\n").toUtf8().data();

        //fix
        if(image.size()!= mask.size())
            mask = mask.copy(0,0, image.width(), image.height());

        mask = target.alphaChannel();
        mask.invertPixels();

        //Save after fix
        //target.save(OPath+tmp[0]+"_after.bmp", "BMP");
        QString saveTo;


        saveTo = QString(OPath+(tmp[0].toLower())+".gif");

        //overwrite source image (convert BMP to GIF)
        if(toGif(image, saveTo ) ) //Write gif
        {
            QTextStream(stdout) <<"GIF-1 ";
        }
        else
        {
            QTextStream(stdout) <<"BMP-1 ";
            image.save(saveTo, "BMP"); //If failed, write BMP
        }

        saveTo = QString(OPath+(tmp[0].toLower())+"m.gif");

        //overwrite mask image
        if( toGif(mask, saveTo ) ) //Write gif
        {
            QTextStream(stdout) <<"GIF-2\n";
        }
        else
        {
            mask.save(saveTo, "BMP"); //If failed, write BMP
            QTextStream(stdout) <<"BMP-2\n";
        }
    }
    else
        QTextStream(stderr) << path+q+" - WRONG!\n";
}
Ejemplo n.º 10
0
// load given song
void Song::loadProject( const QString & fileName )
{
	QDomNode node;

	m_loadingProject = true;

	Engine::projectJournal()->setJournalling( false );

	m_oldFileName = m_fileName;
	m_fileName = fileName;

	DataFile dataFile( m_fileName );
	// if file could not be opened, head-node is null and we create
	// new project
	if( dataFile.head().isNull() )
	{
		if( m_loadOnLaunch )
		{
			createNewProject();
		}
		m_fileName = m_oldFileName;
		return;
	}

	m_oldFileName = m_fileName;

	clearProject();

	clearErrors();

	DataFile::LocaleHelper localeHelper( DataFile::LocaleHelper::ModeLoad );

	Engine::mixer()->requestChangeInModel();

	// get the header information from the DOM
	m_tempoModel.loadSettings( dataFile.head(), "bpm" );
	m_timeSigModel.loadSettings( dataFile.head(), "timesig" );
	m_masterVolumeModel.loadSettings( dataFile.head(), "mastervol" );
	m_masterPitchModel.loadSettings( dataFile.head(), "masterpitch" );

	if( m_playPos[Mode_PlaySong].m_timeLine )
	{
		// reset loop-point-state
		m_playPos[Mode_PlaySong].m_timeLine->toggleLoopPoints( 0 );
	}

	if( !dataFile.content().firstChildElement( "track" ).isNull() )
	{
		m_globalAutomationTrack->restoreState( dataFile.content().
						firstChildElement( "track" ) );
	}

	//Backward compatibility for LMMS <= 0.4.15
	PeakController::initGetControllerBySetting();

	// Load mixer first to be able to set the correct range for FX channels
	node = dataFile.content().firstChildElement( Engine::fxMixer()->nodeName() );
	if( !node.isNull() )
	{
		Engine::fxMixer()->restoreState( node.toElement() );
		if( gui )
		{
			// refresh FxMixerView
			gui->fxMixerView()->refreshDisplay();
		}
	}

	node = dataFile.content().firstChild();

	QDomNodeList tclist=dataFile.content().elementsByTagName("trackcontainer");
	m_nLoadingTrack=0;
	for( int i=0,n=tclist.count(); i<n; ++i )
	{
		QDomNode nd=tclist.at(i).firstChild();
		while(!nd.isNull())
		{
			if( nd.isElement() && nd.nodeName() == "track" )
			{
				++m_nLoadingTrack;
				if( nd.toElement().attribute("type").toInt() == Track::BBTrack )
				{
					n += nd.toElement().elementsByTagName("bbtrack").at(0)
						.toElement().firstChildElement().childNodes().count();
				}
				nd=nd.nextSibling();
			}
		}
	}

	while( !node.isNull() )
	{
		if( node.isElement() )
		{
			if( node.nodeName() == "trackcontainer" )
			{
				( (JournallingObject *)( this ) )->restoreState( node.toElement() );
			}
			else if( node.nodeName() == "controllers" )
			{
				restoreControllerStates( node.toElement() );
			}
			else if( gui )
			{
				if( node.nodeName() == gui->getControllerRackView()->nodeName() )
				{
					gui->getControllerRackView()->restoreState( node.toElement() );
				}
				else if( node.nodeName() == gui->pianoRoll()->nodeName() )
				{
					gui->pianoRoll()->restoreState( node.toElement() );
				}
				else if( node.nodeName() == gui->automationEditor()->m_editor->nodeName() )
				{
					gui->automationEditor()->m_editor->restoreState( node.toElement() );
				}
				else if( node.nodeName() == gui->getProjectNotes()->nodeName() )
				{
					 gui->getProjectNotes()->SerializingObject::restoreState( node.toElement() );
				}
				else if( node.nodeName() == m_playPos[Mode_PlaySong].m_timeLine->nodeName() )
				{
					m_playPos[Mode_PlaySong].m_timeLine->restoreState( node.toElement() );
				}
			}
		}
		node = node.nextSibling();
	}

	// quirk for fixing projects with broken positions of TCOs inside
	// BB-tracks
	Engine::getBBTrackContainer()->fixIncorrectPositions();

	// Connect controller links to their controllers
	// now that everything is loaded
	ControllerConnection::finalizeConnections();

	// resolve all IDs so that autoModels are automated
	AutomationPattern::resolveAllIDs();


	Engine::mixer()->doneChangeInModel();

	ConfigManager::inst()->addRecentlyOpenedProject( fileName );

	Engine::projectJournal()->setJournalling( true );

	emit projectLoaded();

	if ( hasErrors())
	{
		if ( gui )
		{
			QMessageBox::warning( NULL, tr("LMMS Error report"), errorSummary(),
							QMessageBox::Ok );
		}
		else
		{
			QTextStream(stderr) << Engine::getSong()->errorSummary() << endl;
		}
	}

	m_loadingProject = false;
	m_modified = false;
	m_loadOnLaunch = false;

	if( gui && gui->mainWindow() )
	{
		gui->mainWindow()->resetWindowTitle();
	}
}
Ejemplo n.º 11
0
bool toGif(QImage& img, QString& path)
{
    int errcode;

    if(QFile(path).exists()) // Remove old file
        QFile::remove(path);

    GifFileType* t = EGifOpenFileName(path.toLocal8Bit().data(),true, &errcode);
    if(!t){
        EGifCloseFile(t, &errcode);
        QTextStream(stdout)  << "Can't open\n";
        return false;
    }

    EGifSetGifVersion(t, true);

    GifColorType* colorArr = new GifColorType[256];
    ColorMapObject* cmo = GifMakeMapObject(256, colorArr);

    bool unfinished = false;
    QImage tarQImg(img.width(), img.height(), QImage::Format_Indexed8);
    QVector<QRgb> table;
    for(int y = 0; y < img.height(); y++){
        for(int x = 0; x < img.width(); x++){
            if(table.size() >= 256){
                unfinished = true;
                break;
            }
            QRgb pix;
            if(!table.contains(pix = img.pixel(x,y))){
                table.push_back(pix);
                tarQImg.setColor(tarQImg.colorCount(), pix);
            }
            tarQImg.setPixel(x,y,table.indexOf(pix));
        }
        if(table.size() >= 256){
            unfinished = true;
            break;
        }
    }

    if(unfinished){
        EGifCloseFile(t, &errcode);
        QTextStream(stdout)  << "Unfinished\n";
        return false;
    }


    for(int l = tarQImg.colorCount(); l < 256; l++){
        tarQImg.setColor(l,0);
    }

    if(tarQImg.colorTable().size() != 256){
        EGifCloseFile(t, &errcode);
        QTextStream(stdout)  << "A lot of colors\n";
        return false;
    }

    QVector<QRgb> clTab = tarQImg.colorTable();

    for(int i = 0; i < 255; i++){
        QRgb rgb = clTab[i];
        colorArr[i].Red = qRed(rgb);
        colorArr[i].Green = qGreen(rgb);
        colorArr[i].Blue = qBlue(rgb);
    }
    cmo->Colors = colorArr;

    errcode = EGifPutScreenDesc(t, img.width(), img.height(), 256, 0, cmo);
    if(errcode != GIF_OK){
        EGifCloseFile(t, &errcode);
        QTextStream(stdout)  << "EGifPutScreenDesc error 1\n";
        return false;
    }

    errcode = EGifPutImageDesc(t, 0, 0, img.width(), img.height(), false, 0);
    if(errcode != GIF_OK){
        EGifCloseFile(t, &errcode);
        QTextStream(stdout)  << "EGifPutImageDesc error 2\n";
        return false;
    }

    //gen byte array
    GifByteType* byteArr = tarQImg.bits();

    for(int h = 0; h < tarQImg.height(); h++){
        errcode = EGifPutLine(t, byteArr, tarQImg.width());
        if(errcode != GIF_OK){
            EGifCloseFile(t, &errcode);
            QTextStream(stdout)  << "EGifPutLine error 3\n";
            return false;
        }

        byteArr += tarQImg.width();
        byteArr += ((tarQImg.width() % 4)!=0 ? 4 - (tarQImg.width() % 4) : 0);
    }

    if(errcode != GIF_OK){
        QTextStream(stdout)  << "GIF error 4\n";
        return false;
    }
    EGifCloseFile(t, &errcode);

    return true;
}
Ejemplo n.º 12
0
	BOOL ReplaceIconResource(LPSTR lpFileName, LPCTSTR lpName, UINT langId, LPICONDIR pIconDir,	LPICONIMAGE* pIconImage)
	{
		BOOL res=true;
		HANDLE	hFile3=NULL;
		LPMEMICONDIR lpInitGrpIconDir=new MEMICONDIR;

		//LPICONIMAGE pIconImage;
		HINSTANCE hUi;
		BYTE *test,*test1,*temp,*temp1;
		DWORD cbInit=0,cbOffsetDir=0,cbOffset=0,cbInitOffset=0;
		WORD cbRes=0;
		int i;

		hUi = LoadLibraryExA(lpFileName,NULL,DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
		HRSRC hRsrc = FindResourceEx(hUi, RT_GROUP_ICON, lpName,langId);
		//nu stiu de ce returneaza 104 wtf???
		//cbRes=SizeofResource( hUi, hRsrc );
		HGLOBAL hGlobal = LoadResource( hUi, hRsrc );
		test1 =(BYTE*) LockResource( hGlobal );
		temp1=test1;
	//	temp1=new BYTE[118];
	//	CopyMemory(temp1,test1,118);
		if (test1)
			{
			lpInitGrpIconDir->idReserved=(WORD)*test1;
			test1=test1+sizeof(WORD);
			lpInitGrpIconDir->idType=(WORD)*test1;
			test1=test1+sizeof(WORD);
			lpInitGrpIconDir->idCount=(WORD)*test1;
			test1=test1+sizeof(WORD);
			}
		else
			{
			lpInitGrpIconDir->idReserved=0;
			lpInitGrpIconDir->idType=1;
			lpInitGrpIconDir->idCount=0;
			}

		lpInitGrpIconDir->idEntries=new MEMICONDIRENTRY[lpInitGrpIconDir->idCount];

		for(i=0;i<lpInitGrpIconDir->idCount;i++)
			{
			lpInitGrpIconDir->idEntries[i].bWidth=(BYTE)*test1;
			test1=test1+sizeof(BYTE);
			lpInitGrpIconDir->idEntries[i].bHeight=(BYTE)*test1;
			test1=test1+sizeof(BYTE);
			lpInitGrpIconDir->idEntries[i].bColorCount=(BYTE)*test1;
			test1=test1+sizeof(BYTE);
			lpInitGrpIconDir->idEntries[i].bReserved=(BYTE)*test1;
			test1=test1+sizeof(BYTE);
			lpInitGrpIconDir->idEntries[i].wPlanes=(WORD)*test1;
			test1=test1+sizeof(WORD);
			lpInitGrpIconDir->idEntries[i].wBitCount=(WORD)*test1;
			test1=test1+sizeof(WORD);
			//nu merge cu (DWORD)*test
			lpInitGrpIconDir->idEntries[i].dwBytesInRes=pIconDir->idEntries[i].dwBytesInRes;
			test1=test1+sizeof(DWORD);
			lpInitGrpIconDir->idEntries[i].nID=(WORD)*test1;
			test1=test1+sizeof(WORD);
			}
		//	memcpy( lpInitGrpIconDir->idEntries, test, cbRes-3*sizeof(WORD) );

		UnlockResource((HGLOBAL)test1);

		LPMEMICONDIR lpGrpIconDir=new MEMICONDIR;
		lpGrpIconDir->idReserved=pIconDir->idReserved;
		lpGrpIconDir->idType=pIconDir->idType;
		lpGrpIconDir->idCount=pIconDir->idCount;
		cbRes=3*sizeof(WORD)+lpGrpIconDir->idCount*sizeof(MEMICONDIRENTRY);
		test=new BYTE[cbRes];
		temp=test;
		CopyMemory(test,&lpGrpIconDir->idReserved,sizeof(WORD));
		test=test+sizeof(WORD);
		CopyMemory(test,&lpGrpIconDir->idType,sizeof(WORD));
		test=test+sizeof(WORD);
		CopyMemory(test,&lpGrpIconDir->idCount,sizeof(WORD));
		test=test+sizeof(WORD);

		lpGrpIconDir->idEntries=new MEMICONDIRENTRY[lpGrpIconDir->idCount];
		for(i=0;i<lpGrpIconDir->idCount;i++)
			{
			lpGrpIconDir->idEntries[i].bWidth=pIconDir->idEntries[i].bWidth;
			CopyMemory(test,&lpGrpIconDir->idEntries[i].bWidth,sizeof(BYTE));
			test=test+sizeof(BYTE);
			lpGrpIconDir->idEntries[i].bHeight=pIconDir->idEntries[i].bHeight;
			CopyMemory(test,&lpGrpIconDir->idEntries[i].bHeight,sizeof(BYTE));
			test=test+sizeof(BYTE);
			lpGrpIconDir->idEntries[i].bColorCount=pIconDir->idEntries[i].bColorCount;
			CopyMemory(test,&lpGrpIconDir->idEntries[i].bColorCount,sizeof(BYTE));
			test=test+sizeof(BYTE);
			lpGrpIconDir->idEntries[i].bReserved=pIconDir->idEntries[i].bReserved;
			CopyMemory(test,&lpGrpIconDir->idEntries[i].bReserved,sizeof(BYTE));
			test=test+sizeof(BYTE);
			lpGrpIconDir->idEntries[i].wPlanes=pIconDir->idEntries[i].wPlanes;
			CopyMemory(test,&lpGrpIconDir->idEntries[i].wPlanes,sizeof(WORD));
			test=test+sizeof(WORD);
			lpGrpIconDir->idEntries[i].wBitCount=pIconDir->idEntries[i].wBitCount;
			CopyMemory(test,&lpGrpIconDir->idEntries[i].wBitCount,sizeof(WORD));
			test=test+sizeof(WORD);
			lpGrpIconDir->idEntries[i].dwBytesInRes=pIconDir->idEntries[i].dwBytesInRes;
			CopyMemory(test,&lpGrpIconDir->idEntries[i].dwBytesInRes,sizeof(DWORD));
			test=test+sizeof(DWORD);
			if(i<lpInitGrpIconDir->idCount) //nu am depasit numarul initial de RT_ICON
				lpGrpIconDir->idEntries[i].nID=lpInitGrpIconDir->idEntries[i].nID;
			else
				{
				nMaxID++;
				lpGrpIconDir->idEntries[i].nID=i+1; //adaug noile ICO la sfarsitul RT_ICON-urilor
				}
			CopyMemory(test,&lpGrpIconDir->idEntries[i].nID,sizeof(WORD));
			test=test+sizeof(WORD);
			}

		//offsetul de unde incep structurile ICONIMAGE
		cbInitOffset=3*sizeof(WORD)+lpGrpIconDir->idCount*sizeof(ICONDIRENTRY);
		cbOffset=cbInitOffset; //cbOffset=118

		FreeLibrary(hUi);

		HANDLE hUpdate;
//		_chmod((char*)lpFileName,_S_IWRITE);
		hUpdate = BeginUpdateResourceA(lpFileName, FALSE); //false sa nu stearga resursele neupdated
		if(hUpdate==NULL)
			{
			QTextStream(stdout, QIODevice::WriteOnly) << "erreur BeginUpdateResource " << lpFileName << "\n";
			res=false;
			}
		//aici e cu lang NEUTRAL
		//res=UpdateResource(hUpdate,RT_GROUP_ICON,MAKEINTRESOURCE(6000),langId,lpGrpIconDir,cbRes);
		res=UpdateResource(hUpdate,RT_GROUP_ICON,lpName,langId,temp,cbRes);
		if(res==false)
			QTextStream(stdout, QIODevice::WriteOnly) << "erreur UpdateResource RT_GROUP_ICON " << lpFileName << "\n";

		for(i=0;i<lpGrpIconDir->idCount;i++)
			{
			res=UpdateResource(hUpdate,RT_ICON,MAKEINTRESOURCE(lpGrpIconDir->idEntries[i].nID),langId,pIconImage[i],lpGrpIconDir->idEntries[i].dwBytesInRes);
			if(res==false)
				QTextStream(stdout, QIODevice::WriteOnly) << "erreur UpdateResource RT_ICON " << lpFileName << "\n";
			}

		for(i=lpGrpIconDir->idCount;i<lpInitGrpIconDir->idCount;++i)
			{
			res=UpdateResource(hUpdate,RT_ICON,MAKEINTRESOURCE(lpInitGrpIconDir->idEntries[i].nID),langId,NULL,0);
			if(res==false)
				QTextStream(stdout, QIODevice::WriteOnly) << "erreur to delete resource " << lpFileName << "\n";	
			}

		if(!EndUpdateResource(hUpdate,FALSE)) //false ->resource updates will take effect.
			QTextStream(stdout, QIODevice::WriteOnly) << "eroare EndUpdateResource" << lpFileName << "\n";

		//	FreeResource(hGlobal);
		delete[] lpGrpIconDir->idEntries;
		delete lpGrpIconDir;
		delete[] temp;

		return res;
	}
Ejemplo n.º 13
0
void GroundStation::print_info_packet(Protocol::InfoPacket &packet){
    QTextStream(stdout) << "Type: InfoPacket" << endl;
    QTextStream(stdout) << "Points Storable: " << packet.GetStorable() << endl;
    QTextStream(stdout) << "Battery State: " << packet.GetBattery() << endl;
    QTextStream(stdout) << "Other : " << QString::fromStdString(packet.GetOther()) << endl;
 }
Ejemplo n.º 14
0
void Database::moveAchievement(int level, int id){
    QString cmd;
    QTextStream(&cmd)<<"delete from achievement where level = "<<level*100+id;
    query.exec(cmd);
}
Ejemplo n.º 15
0
void HuboInitWidget::handleJointStateButton(int id)
{
    QString lineStatus;
    QString toolStatus;
    
    QTextStream(&lineStatus) << QString::fromLocal8Bit(h_param.joint[id].name) << " ";
    QTextStream(&lineStatus) << QString::number(h_state.joint[id].pos) << " -- ";
    QTextStream(&toolStatus) << QString::fromLocal8Bit(h_param.joint[id].name) << ":";
    if(h_state.status[id].homeFlag != 6)
    {
        QTextStream(&lineStatus) << "H:" << h_state.status[id].homeFlag << " ";
        QTextStream(&toolStatus) << "\nNot Homed";
    }
    else
        QTextStream(&toolStatus) << "\nHomed";
    if(h_state.joint[id].zeroed==1)
    {
        QTextStream(&lineStatus) << "Z ";
        QTextStream(&toolStatus) << "\nZeroed";
    }
    if(h_state.status[id].jam == 1)
    {
        QTextStream(&lineStatus) << "JAM ";
        QTextStream(&toolStatus) << "\nMechanical Jam";
    }
    if(h_state.status[id].pwmSaturated == 1)
    {
        QTextStream(&lineStatus) << "PWM ";
        QTextStream(&toolStatus) << "\nPWM Saturated";
    }
    if(h_state.status[id].bigError == 1)
    {
        QTextStream(&lineStatus) << "BigE ";
        QTextStream(&toolStatus) << "\nBig Error (Needs to be Reset)";
    }
    if(h_state.status[id].encError == 1)
    {
        QTextStream(&lineStatus) << "ENC ";
        QTextStream(&toolStatus) << "\nEncoder Error";
    }
    if(h_state.status[id].driverFault == 1)
    {
        QTextStream(&lineStatus) << "DF ";
        QTextStream(&toolStatus) << "\nDrive Fault";
    }
    if(h_state.status[id].posMinError == 1)
    {
        QTextStream(&lineStatus) << "POS< ";
        QTextStream(&toolStatus) << "\nMinimum Position Error";
    }
    if(h_state.status[id].posMaxError == 1)
    {
        QTextStream(&lineStatus) << "POS> ";
        QTextStream(&toolStatus) << "\nMaximum Position Error";
    }
    if(h_state.status[id].velError == 1)
    {
        QTextStream(&lineStatus) << "VEL ";
        QTextStream(&toolStatus) << "\nVelocity Error";
    }
    if(h_state.status[id].accError == 1)
    {
        QTextStream(&lineStatus) << "ACC ";
        QTextStream(&toolStatus) << "\nAcceleration Error";
    }
    if(h_state.status[id].tempError == 1)
    {
        QTextStream(&lineStatus) << "TMP ";
        QTextStream(&toolStatus) << "\nTemperature Error";
    }
    
    stateFlags->setText(lineStatus);
    stateFlags->setToolTip(toolStatus);
}
Ejemplo n.º 16
0
void ImageSearchQuerySettings::addKeyValueToUrl(const QString& key, const QString& val)
{
	QString urlPart;
	QTextStream(&urlPart) << "&" << key << "=" << QUrl::toPercentEncoding( val );
	m_searchUrl.append(urlPart);
}
Ejemplo n.º 17
0
void NetworkProgram::downloadFinished(QNetworkReply* reply) {
    _program = QScriptProgram(QTextStream(reply).readAll(), reply->url().toString());
    reply->deleteLater();
    finishedLoading(true);
    emit loaded();
}
Ejemplo n.º 18
0
int main(int argc, char** argv)
{
  QApplication app(argc, argv);

  ctkCommandLineParser parser;
  // Use Unix-style argument names
  parser.setArgumentPrefix("--", "-");

  // Add command line argument names
  parser.addArgument("help", "h", QVariant::Bool, "Print usage information and exit.");
  parser.addArgument("interactive", "I", QVariant::Bool, "Enable interactive mode");

  // Parse the command line arguments
  bool ok = false;
  QHash<QString, QVariant> parsedArgs = parser.parseArguments(QCoreApplication::arguments(), &ok);
  if (!ok)
  {
    QTextStream(stderr, QIODevice::WriteOnly) << "Error parsing arguments: "
                                              << parser.errorString() << "\n";
    return EXIT_FAILURE;
  }

  // Show a help message
  if (parsedArgs.contains("help") || parsedArgs.contains("h"))
  {
    QTextStream(stdout, QIODevice::WriteOnly) << "ctkSimplePythonShell\n"
          << "Usage\n\n"
          << "  ctkSimplePythonShell [options] [<path-to-python-script> ...]\n\n"
          << "Options\n"
          << parser.helpText();
    return EXIT_SUCCESS;
  }
  
  ctkSimplePythonManager pythonManager;
  
  ctkPythonShell shell(&pythonManager);
  shell.setAttribute(Qt::WA_QuitOnClose, true);
  shell.resize(600, 280);
  shell.show();

  shell.setProperty("isInteractive", parsedArgs.contains("interactive"));

  pythonManager.addObjectToPythonMain("_ctkPythonShellInstance", &shell);

  ctkTestWrappedQProperty testWrappedQProperty;
  pythonManager.addObjectToPythonMain("_testWrappedQPropertyInstance", &testWrappedQProperty);

  ctkTestWrappedQInvokable testWrappedQInvokable;
  pythonManager.addObjectToPythonMain("_testWrappedQInvokableInstance", &testWrappedQInvokable);

  ctkTestWrappedSlot testWrappedSlot;
  pythonManager.addObjectToPythonMain("_testWrappedSlotInstance", &testWrappedSlot);

#ifdef CTK_WRAP_PYTHONQT_USE_VTK
  ctkTestWrappedVTKQInvokable testWrappedVTKQInvokable;
  pythonManager.addObjectToPythonMain("_testWrappedVTKQInvokableInstance", &testWrappedVTKQInvokable);

  ctkTestWrappedVTKSlot testWrappedVTKSlot;
  pythonManager.addObjectToPythonMain("_testWrappedVTKSlotInstance", &testWrappedVTKSlot);

  ctkTestWrappedQListOfVTKObject testWrappedQListOfVTKObject;
  pythonManager.addObjectToPythonMain("_testWrappedQListOfVTKObjectInstance", &testWrappedQListOfVTKObject);
#endif

  foreach(const QString& script, parser.unparsedArguments())
    {
    pythonManager.executeFile(script);
    }
  
  return app.exec();
}
Ejemplo n.º 19
0
QWidget *GdbOptionsPage::createPage(QWidget *parent)
{
    QWidget *w = new QWidget(parent);
    m_ui = new GdbOptionsPageUi;
    m_ui->setupUi(w);

    m_group.clear();
    m_group.insert(debuggerCore()->action(GdbStartupCommands),
        m_ui->textEditStartupCommands);
    m_group.insert(debuggerCore()->action(LoadGdbInit),
        m_ui->checkBoxLoadGdbInit);
    m_group.insert(debuggerCore()->action(AutoEnrichParameters),
        m_ui->checkBoxAutoEnrichParameters);
    m_group.insert(debuggerCore()->action(UseDynamicType),
        m_ui->checkBoxUseDynamicType);
    m_group.insert(debuggerCore()->action(TargetAsync),
        m_ui->checkBoxTargetAsync);
    m_group.insert(debuggerCore()->action(WarnOnReleaseBuilds),
        m_ui->checkBoxWarnOnReleaseBuilds);
    m_group.insert(debuggerCore()->action(AdjustBreakpointLocations),
        m_ui->checkBoxAdjustBreakpointLocations);
    m_group.insert(debuggerCore()->action(BreakOnWarning),
        m_ui->checkBoxBreakOnWarning);
    m_group.insert(debuggerCore()->action(BreakOnFatal),
        m_ui->checkBoxBreakOnFatal);
    m_group.insert(debuggerCore()->action(BreakOnAbort),
        m_ui->checkBoxBreakOnAbort);
    m_group.insert(debuggerCore()->action(GdbWatchdogTimeout),
        m_ui->spinBoxGdbWatchdogTimeout);
    m_group.insert(debuggerCore()->action(AttemptQuickStart),
        m_ui->checkBoxAttemptQuickStart);

    m_group.insert(debuggerCore()->action(UseMessageBoxForSignals),
        m_ui->checkBoxUseMessageBoxForSignals);
    m_group.insert(debuggerCore()->action(SkipKnownFrames),
        m_ui->checkBoxSkipKnownFrames);
    m_group.insert(debuggerCore()->action(EnableReverseDebugging),
        m_ui->checkBoxEnableReverseDebugging);
    m_group.insert(debuggerCore()->action(GdbWatchdogTimeout), 0);

    //m_ui->groupBoxPluginDebugging->hide();

    //m_ui->lineEditSelectedPluginBreakpointsPattern->
    //    setEnabled(debuggerCore()->action(SelectedPluginBreakpoints)->value().toBool());
    //connect(m_ui->radioButtonSelectedPluginBreakpoints, SIGNAL(toggled(bool)),
    //    m_ui->lineEditSelectedPluginBreakpointsPattern, SLOT(setEnabled(bool)));

    if (m_searchKeywords.isEmpty()) {
        QLatin1Char sep(' ');
        QTextStream(&m_searchKeywords)
                << sep << m_ui->groupBoxGeneral->title()
                << sep << m_ui->checkBoxLoadGdbInit->text()
                << sep << m_ui->checkBoxTargetAsync->text()
                << sep << m_ui->checkBoxWarnOnReleaseBuilds->text()
                << sep << m_ui->checkBoxUseDynamicType->text()
                << sep << m_ui->labelGdbWatchdogTimeout->text()
                << sep << m_ui->checkBoxEnableReverseDebugging->text()
                << sep << m_ui->checkBoxSkipKnownFrames->text()
                << sep << m_ui->checkBoxUseMessageBoxForSignals->text()
                << sep << m_ui->checkBoxAdjustBreakpointLocations->text()
                << sep << m_ui->checkBoxAttemptQuickStart->text()
        //        << sep << m_ui->groupBoxPluginDebugging->title()
        //        << sep << m_ui->radioButtonAllPluginBreakpoints->text()
        //        << sep << m_ui->radioButtonSelectedPluginBreakpoints->text()
        //        << sep << m_ui->labelSelectedPluginBreakpoints->text()
        //        << sep << m_ui->radioButtonNoPluginBreakpoints->text()
        ;
        m_searchKeywords.remove(QLatin1Char('&'));
    }

    return w;
}
Ejemplo n.º 20
0
bool KOfxDirectConnectDlg::init()
{
  show();

  QByteArray request = m_connector.statementRequest();
  if (request.isEmpty()) {
    hide();
    return false;
  }

  // For debugging, dump out the request
#if 0
  QFile g("request.ofx");
  g.open(QIODevice::WriteOnly);
  QTextStream(&g) << m_connector.url() << "\n" << QString(request);
  g.close();
#endif

  QDir homeDir(QDir::home());
  if (homeDir.exists("ofxlog.txt")) {
    d->m_fpTrace.setFileName(QString("%1/ofxlog.txt").arg(QDir::homePath()));
    d->m_fpTrace.open(QIODevice::WriteOnly | QIODevice::Append);
  }

  if (d->m_fpTrace.isOpen()) {
    QByteArray data = m_connector.url().toUtf8();
    d->m_fpTrace.write("url: ", 5);
    d->m_fpTrace.write(data, strlen(data));
    d->m_fpTrace.write("\n", 1);
    d->m_fpTrace.write("request:\n", 9);
    QByteArray trcData(request);  // make local copy
    trcData.replace('\r', "");
    d->m_fpTrace.write(trcData, trcData.size());
    d->m_fpTrace.write("\n", 1);
    d->m_fpTrace.write("response:\n", 10);
  }

  qDebug("creating job");
  m_job = KIO::http_post(QUrl(m_connector.url()), request, KIO::HideProgressInfo);

  // open the temp file. We come around here twice if init() is called twice
  if (m_tmpfile) {
    qDebug() << "Already connected, using " << m_tmpfile->fileName();
    delete m_tmpfile; //delete otherwise we mem leak
  }
  m_tmpfile = new QTemporaryFile();
  // for debugging purposes one might want to leave the temp file around
  // in order to achieve this, please uncomment the next line
  // m_tmpfile->setAutoRemove(false);
  if (!m_tmpfile->open()) {
    qWarning("Unable to open tempfile '%s' for download.", qPrintable(m_tmpfile->fileName()));
    return false;
  }

  m_job->addMetaData("content-type", "Content-type: application/x-ofx");

  connect(m_job, SIGNAL(result(KJob*)), this, SLOT(slotOfxFinished(KJob*)));
  connect(m_job, SIGNAL(data(KIO::Job*,QByteArray)), this, SLOT(slotOfxData(KIO::Job*,QByteArray)));

  setStatus(QString("Contacting %1...").arg(m_connector.url()));
  kProgress1->setMaximum(3);
  kProgress1->setValue(1);
  return true;
}
Ejemplo n.º 21
0
// ----------------------------------------------------------------------------------
bool addResourceBITMAP(QString executablePath, QString resourceName, QString resourcePath)
{
	// Load file
	// Get the bmp into memory
	char* resPath = (char*) malloc(strlen(resourcePath.toStdString().c_str()) * sizeof(char));
	strcpy(resPath, resourcePath.toStdString().c_str());
	//HANDLE hIcon = LoadImage(NULL, TEXT(resPath), IMAGE_ICON, 0, 0, LR_LOADFROMFILE|LR_DEFAULTSIZE);
	//LPVOID lpResLock = LockResource(hIcon);

	HANDLE hFile = CreateFile(resPath, GENERIC_READ, 0, NULL,
									  OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	if(hFile == NULL)
		{
		QTextStream(stdout, QIODevice::WriteOnly) << "Could not load ico file.\n";
		return false;
		}

	DWORD FileSize = GetFileSize(hFile, NULL);

	//reading image into global memory.
	BYTE* pBuffer = new BYTE[FileSize];
	DWORD nRead = 0;
	ReadFile(hFile, pBuffer, FileSize, &nRead, NULL);

	qDebug() << "Resource: " << FileSize << hFile;

	// just skipping the header information and  calculating modifying size.
	BYTE *newBuffer   = pBuffer  + sizeof(BITMAPFILEHEADER);
	DWORD NewFileSize = FileSize - sizeof(BITMAPFILEHEADER);

	// Write in the new resources
	char* exePath = (char*) malloc(strlen(executablePath.toStdString().c_str()) * sizeof(char));
	strcpy(exePath, executablePath.toStdString().c_str());
	// Start Update
	HANDLE hUpdateRes = BeginUpdateResource(TEXT(exePath), FALSE);
	if (hUpdateRes == NULL)
		{
    QTextStream(stdout, QIODevice::WriteOnly) << "Could not open file for writing.\n";
    return false;
		}

	qDebug() << "name" << resourceName.toStdString().c_str();
	qDebug() << "path " << resourcePath;
	// update resouce.
	bool result = UpdateResource(hUpdateRes,
										RT_ICON,
										TEXT(resourceName.toStdString().c_str()),
										MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
										(LPVOID)newBuffer, NewFileSize);
	if(!result)
		{
		QTextStream(stdout, QIODevice::WriteOnly) << "Resource Could not be added.\n";
		return false;
		}

	if(!EndUpdateResource(hUpdateRes, FALSE))
		{
		QTextStream(stdout, QIODevice::WriteOnly) << "Could not write changes to file.\n";
		return false;
		}

	// release handle and memory.
  CloseHandle(hFile);
	delete[] pBuffer;
	return true;
}
Ejemplo n.º 22
0
// ----------------------------------------------------------------------------------
int main(int argc, char* argv[])
{
	ctkCommandLineParser commandLine;
	commandLine.setArgumentPrefix("--", "-");

	commandLine.beginGroup(QString("Option"));
	commandLine.addArgument("help", "h", QVariant::Bool,
		"Display available command line arguments.");
	commandLine.addArgument("list-resources", "l", QVariant::String,
		"List all resources of an executable or library.");
	commandLine.addArgument("add-resource-bitmap", "", QVariant::StringList,
		"Add resource using the provided <path/to/exec/or/lib> <resourceName> and <path/to/resource>");
	commandLine.addArgument("update-resource-ico", "", QVariant::StringList,
		"Add resource using the provided <path/to/exec/or/lib> <resourceName> and <path/to/resource>");
	commandLine.addArgument("delete-resource", "", QVariant::StringList,
		"Delete resource using the provided <path/to/exec/or/lib> <resourceType> <resourceName>");
	commandLine.endGroup();

	bool ok;
	QHash<QString, QVariant> parsedArgs = commandLine.parseArguments(argc, argv, &ok);
	if (!ok)
		{
		QTextStream(stdout, QIODevice::WriteOnly) << "Error parsing arguments : " << commandLine.errorString() << "\n";
		return EXIT_FAILURE;
		}

	if(parsedArgs.contains("help") || parsedArgs.contains("h"))
		{
		QTextStream(stdout, QIODevice::WriteOnly) << commandLine.helpText() << "\n";
		return EXIT_SUCCESS;
		}

	char* exePath;
	HMODULE hExe;       // handle to existing .EXE file

	if(parsedArgs.contains("list-resources") || parsedArgs.contains("l"))
		{
		// Load the .EXE file that contains the dialog box you want to copy.
		exePath =
			(char*) malloc(strlen(parsedArgs.value("list-resources").toString().toStdString().c_str()) * sizeof(char));
		strcpy(exePath, parsedArgs.value("list-resources").toString().toStdString().c_str());
		hExe = loadLibraryEx(TEXT(exePath), NULL, LOAD_LIBRARY_AS_IMAGE_RESOURCE);

		// List all resources
		EnumResourceTypes(hExe, (ENUMRESTYPEPROC)EnumTypesFunc, 0);

		for (int i = 0; i < resources::Resources.size() ; ++i)
			{
			QTextStream(stdout, QIODevice::WriteOnly) << "Type : " << resources::Resources.at(i).Type <<  " -- " << resources::types[resources::Resources.at(i).Type.toInt()] << "\n";
			QTextStream(stdout, QIODevice::WriteOnly) << "\tName : " << resources::Resources.at(i).Name << "\n";
			QTextStream(stdout, QIODevice::WriteOnly) << "\t\tLang : " << resources::Resources.at(i).Lang << "\n";
			}

		// Clean up.
		if (!FreeLibrary(hExe))
			{
			QTextStream(stdout, QIODevice::WriteOnly) << "Could not free executable : " << exePath << "\n";
			return EXIT_FAILURE;
			}
		}

	else if(parsedArgs.contains("delete-resource"))
		{
		QStringList arguments = parsedArgs.value("delete-resource").toStringList();
		exePath = (char*) malloc(strlen(arguments.at(0).toStdString().c_str()) * sizeof(char));
		strcpy(exePath, arguments.at(0).toStdString().c_str());
		hExe = loadLibraryEx(TEXT(exePath), NULL, LOAD_LIBRARY_AS_IMAGE_RESOURCE);

		// List all resources
		EnumResourceTypes(hExe, (ENUMRESTYPEPROC)EnumTypesFunc, 0);
		FreeLibrary(hExe);

		bool resultat = removeResource(arguments.at(0), arguments.at(1), arguments.at(2));
		if(!resultat)
			{
			return EXIT_FAILURE;
			}
		}

	else if(parsedArgs.contains("add-resource-bitmap"))
		{
		QStringList arguments = parsedArgs.value("add-resource-bitmap").toStringList();

		bool result = addResourceBITMAP(arguments.at(0), arguments.at(1), arguments.at(2));
		if(!result)
			{
			QTextStream(stdout, QIODevice::WriteOnly) << "Resource bitmap couldn't be added.\n";
			return EXIT_FAILURE;
			}
		QTextStream(stdout, QIODevice::WriteOnly) << "Resource bitmap added.\n";
		return EXIT_SUCCESS;
		}

	else if(parsedArgs.contains("update-resource-ico"))
		{
		QStringList arguments = parsedArgs.value("update-resource-ico").toStringList();

		bool result = updateResourceICO(arguments.at(0), arguments.at(1), arguments.at(2));
		if(!result)
			{
			QTextStream(stdout, QIODevice::WriteOnly) << "Resource ico couldn't be updated.\n";
			return EXIT_FAILURE;
			}
		QTextStream(stdout, QIODevice::WriteOnly) << "Resource ico updated.\n";
		return EXIT_SUCCESS;
		}

  return EXIT_SUCCESS;
}
Ejemplo n.º 23
0
int main(int argc, char *argv[])
{
    QCoreApplication::addLibraryPath(".");
    QCoreApplication a(argc, argv);

    QStringList filters;
    QDir imagesDir;
    QString path;
    QString OPath;
    QStringList fileList;

    bool walkSubDirs=false;
    bool nopause=false;
    bool cOpath=false;
    bool singleFiles=false;

    QString argPath;
    QString argOPath;

    QTextStream(stdout) <<"============================================================================\n";
    QTextStream(stdout) <<"Lazily-made image masks fix tool by Wohlstand. Version "<< _FILE_VERSION << _FILE_RELEASE << "\n";
    QTextStream(stdout) <<"============================================================================\n";
    QTextStream(stdout) <<"This program is distributed under the GNU GPLv3 license\n";
    QTextStream(stdout) <<"============================================================================\n";

    QRegExp isGif = QRegExp("*.gif");
    isGif.setPatternSyntax(QRegExp::Wildcard);

    QRegExp isMask = QRegExp("*m.gif");
    isMask.setPatternSyntax(QRegExp::Wildcard);

    if(a.arguments().size()==1)
    {
        goto DisplayHelp;
    }

    for(int arg=0; arg<a.arguments().size(); arg++)
    {
        if(a.arguments().at(arg)=="--help")
        {
            goto DisplayHelp;
        }
        else
        if(a.arguments().at(arg)=="-N")
        {
            noBackUp=true;
        }
        else
        if(a.arguments().at(arg)=="-W")
        {
            walkSubDirs=true;
        }
//        else
//        if(a.arguments().at(arg)=="-G")
//        {
//            DarkGray=true;
//        }
        else
        if(a.arguments().at(arg)=="--nopause")
        {
            nopause=true;
        }
        else
        {
            //if begins from "-O"
            if(a.arguments().at(arg).size()>=2 && a.arguments().at(arg).at(0)=='-'&& a.arguments().at(arg).at(1)=='O')
              {  argOPath=a.arguments().at(arg); argOPath.remove(0,2); }
            else
            {
                if(isMask.exactMatch(a.arguments().at(arg)))
                    continue;
                else
                    if(isGif.exactMatch(a.arguments().at(arg)))
                    {
                        fileList << a.arguments().at(arg);
                        singleFiles=true;
                    }
                else
                    argPath=a.arguments().at(arg);
            }
        }
    }

    if(!singleFiles)
    {
        if(argPath.isEmpty()) goto WrongInputPath;
        if(!QDir(argPath).exists()) goto WrongInputPath;

        imagesDir.setPath(argPath);
        filters << "*.gif" << "*.GIF";
        imagesDir.setSorting(QDir::Name);
        imagesDir.setNameFilters(filters);

        path = imagesDir.absolutePath() + "/";
    }

    if(!argOPath.isEmpty())
    {
        OPath = argOPath;
        if(!QFileInfo(OPath).isDir())
            goto WrongOutputPath;

        OPath = QDir(OPath).absolutePath() + "/";
    }
    else
    {
        cOpath=true;
        OPath=path;
    }

    QTextStream(stdout) <<"============================================================================\n";
    QTextStream(stdout) <<"Converting images...\n";
    QTextStream(stdout) <<"============================================================================\n";

    if(!singleFiles)
        QTextStream(stdout) << QString("Input path:  "+path+"\n").toUtf8().data();
    QTextStream(stdout) << QString("Output path: "+OPath+"\n").toUtf8().data();
    QTextStream(stdout) <<"============================================================================\n";
    if(singleFiles) //By files
    {
        foreach(QString q, fileList)
        {
            path=QFileInfo(q).absoluteDir().path()+"/";
            QString fname = QFileInfo(q).fileName();
            if(cOpath) OPath=path;
            doMagicIn(path, fname, OPath);
        }
    }
Ejemplo n.º 24
0
/*
 * Convert integer to QString
 */
QString MainWindow::toQString(int num)
{
    QString tmp;
    QTextStream(&tmp)<<num;
    return tmp;
}
Ejemplo n.º 25
0
void Database::addAcievement(int level, int id){
    qDebug()<<"insert into database: "<<level<<" "<<id;
    QString cmd;
    QTextStream(&cmd)<<"insert into achievement values("<<level*100+id<<")";
    query.exec(cmd);
}
Ejemplo n.º 26
0
void GroundStation::print_ack_packet(Protocol::AckPacket& packet){
    QTextStream(stdout) << "Type: AckPacket" << endl;

}
Ejemplo n.º 27
0
Archivo: main.cpp Proyecto: Fale/qtmoko
int main(int argc, char *argv[])
{
    enum ExitCode
    {
        Success,
        ParseFailure,
        ArgumentError,
        WriteError,
        FileFailure
    };

    QCoreApplication app(argc, argv);

    QTextStream errorStream(stderr);

    if (argc != 2)
    {
        errorStream << PrettyPrint::tr(
                       "Usage: prettyprint <path to XML file>\n");
        return ArgumentError;
    }

    QString inputFilePath(QCoreApplication::arguments().at(1));
    QFile inputFile(inputFilePath);

    if (!QFile::exists(inputFilePath))
    {
        errorStream << PrettyPrint::tr(
                       "File %1 does not exist.\n").arg(inputFilePath);
        return FileFailure;

    } else if (!inputFile.open(QIODevice::ReadOnly)) {
        errorStream << PrettyPrint::tr(
                       "Failed to open file %1.\n").arg(inputFilePath);
        return FileFailure;
    }

    QFile outputFile;
    if (!outputFile.open(stdout, QIODevice::WriteOnly))
    {
        QTextStream(stderr) << PrettyPrint::tr("Failed to open stdout.");
        return WriteError;
    }

    QXmlStreamReader reader(&inputFile);
    int indentation = 0;
    QHash<int,QPair<int, int> > indentationStack;

    while (!reader.atEnd())
    {
        reader.readNext();
        if (reader.isStartElement()) {
            indentationStack[indentation] = QPair<int,int>(
                reader.lineNumber(), reader.columnNumber());
            indentation += 1;
        } else if (reader.isEndElement()) {
            indentationStack.remove(indentation);
            indentation -= 1;
        }

        if (reader.error())
        {
            errorStream << PrettyPrint::tr(
                           "Error: %1 in file %2 at line %3, column %4.\n").arg(
                               reader.errorString(), inputFilePath,
                               QString::number(reader.lineNumber()),
                               QString::number(reader.columnNumber()));
            if (indentationStack.contains(indentation-1)) {
                int line = indentationStack[indentation-1].first;
                int column = indentationStack[indentation-1].second;
                errorStream << PrettyPrint::tr(
                               "Opened at line %1, column %2.\n").arg(
                                   QString::number(line),
                                   QString::number(column));
            }
            return ParseFailure;

        } else if (reader.isStartElement() && !reader.name().isEmpty()) {
            outputFile.write(QByteArray().fill(' ', indentation));
            outputFile.write(reader.name().toString().toLocal8Bit());
            outputFile.write(QString(" line %1, column %2\n").arg(
                reader.lineNumber()).arg(reader.columnNumber()).toLocal8Bit());
        }
    }

    return Success;
}
Ejemplo n.º 28
0
void GroundStation::print_action_packet(Protocol::ActionPacket& packet){
    double 	lat, lon;
    float	alt, speed;

    QTextStream(stdout) << "Type: ActionPacket" << endl;
    Protocol::ActionType type = packet.GetAction();

    switch(type)
    {
        case Protocol::ActionType::Start : QTextStream(stdout) << "Start: " << (uint8_t)type << endl; break;
        case Protocol::ActionType::RequestInfo : QTextStream(stdout) << "Request Info: " << (uint8_t)type << endl; break;
        case Protocol::ActionType::AddWaypoint : QTextStream(stdout) << "Add Waypoint: " << (uint8_t)type << endl; break;
        case Protocol::ActionType::SetHome : QTextStream(stdout) << "Set Home: " << (uint8_t)type << endl; break;
        case Protocol::ActionType::RemoveWaypoint : QTextStream(stdout) << "Remove Waypoint: " << (uint8_t)type << endl; break;
        case Protocol::ActionType::Stop : QTextStream(stdout) << "Stop: " << (uint8_t)type << endl; break;
        case Protocol::ActionType::Shutdown : QTextStream(stdout) << "Shutdown: " << (uint8_t)type << endl; break;
        default :   QTextStream(stdout) << "Unknown Type: " << (uint8_t)type << endl; break;
    }

    Protocol::Waypoint waypoint = packet.GetWaypoint();
    lat = waypoint.lat;
    lon = waypoint.lon;
    alt = waypoint.alt;
    speed = waypoint.speed;

    QTextStream(stdout) << "Latitude: " << lat << endl;
    QTextStream(stdout) << "Longitude: " << lon << endl;
    QTextStream(stdout) << "Altitude: " << alt << endl;
    QTextStream(stdout) << "Speed: " << speed << endl;


}
Ejemplo n.º 29
0
    //________________________________________________
    bool WidgetExplorer::eventFilter( QObject* object, QEvent* event )
    {

        if( object->isWidgetType() )
        {
            QString type( _eventTypes[event->type()] );
            if( !type.isEmpty() )
            {
                QTextStream( stdout ) << "Oxygen::WidgetExplorer::eventFilter - widget: " << object << " (" << object->metaObject()->className() << ")";
                QTextStream( stdout ) << " type: " << type  << endl;
            }
        }

        switch( event->type() )
        {
            case QEvent::Paint:
            if( _drawWidgetRects )
            {
                QWidget* widget( qobject_cast<QWidget*>( object ) );
                if( !widget ) return false;

                QPainter painter( widget );
                painter.setRenderHints(QPainter::Antialiasing);
                painter.setBrush( Qt::NoBrush );
                painter.setPen( Qt::red );
                painter.drawRect( widget->rect() );
                painter.end();
            }
            break;

            case QEvent::MouseButtonPress:
            {

                // cast event and check button
                QMouseEvent* mouseEvent( static_cast<QMouseEvent*>( event ) );
                if( mouseEvent->button() != Qt::LeftButton ) break;

                // case widget and check (should not be necessary)
                QWidget* widget( qobject_cast<QWidget*>(object) );
                if( !widget ) return false;

                QTextStream( stdout )
                    << "Oxygen::WidgetExplorer::eventFilter -"
                    << " event: " << event << " type: " << eventType( event->type() )
                    << " widget: " << widgetInformation( widget )
                    << endl;

                // print parent information
                QWidget* parent( widget->parentWidget() );
                while( parent )
                {
                    QTextStream( stdout ) << "    parent: " << widgetInformation( parent ) << endl;
                    parent = parent->parentWidget();
                }
                QTextStream( stdout ) << "" << endl;

            }
            break;

            default: break;

        }

        // always return false to go on with normal chain
        return false;

    }
Ejemplo n.º 30
0
void ImageSearchQuerySettings::addKeyValueToUrl(const QString& key, const int val)
{
	QString urlPart;
	QTextStream(&urlPart) << "&" << key << "=" << val;
	m_searchUrl.append(urlPart);
}