예제 #1
0
void MainWindow::Supprimer_Session(QString Nom_Session)
{
    int reponse = QMessageBox::question(this, "Vraiment?", "Etes-vous sûr de vouloir supprimer la session "+Nom_Session+" ?", QMessageBox::Yes | QMessageBox::No);
    if (reponse == QMessageBox::Yes)
    {
        //toute la philosophie est de ne modifier que le fichier liste_session et de réinstancier le paramètre F_Accueil !

        QFile *fichier = Fenetre_Accueil->get_Liste_Sessions();
        fichier->open(QIODevice::ReadWrite | QIODevice::Text);
        QTextStream flux(fichier);
        QString contenu;

        while (!flux.atEnd())
        {
            QString ligne=flux.readLine();
            if (ligne!=Nom_Session)
                contenu=contenu.append(ligne+"\n");
        }

        fichier->resize(0);

        fichier->write(contenu.toLatin1(),contenu.size());
        fichier->close();

        F_Accueil *Nlle_fenetre = new F_Accueil;
        Nlle_fenetre->setParent(this);
        Nlle_fenetre->move(0,0);
        Fenetre_Accueil=Nlle_fenetre;
        QObject::connect(Fenetre_Accueil,SIGNAL(Signal_Ouvrir_Session(QString)),this,SLOT(Afficher_Fenetre_Session(QString)));

        Retour_Accueil();
    }

}
예제 #2
0
void UEFITool::saveImageFile()
{
    QString path = QFileDialog::getSaveFileName(this, tr("Save BIOS image file"),".","BIOS image files (*.rom *.bin *.cap *.bio *.fd *.wph *.efi);;All files (*.*)");
    
    if (path.isEmpty())
        return;

    QByteArray reconstructed;
    UINT8 result = ffsEngine->reconstructImageFile(reconstructed);
    showMessages();
    if (result) {
        QMessageBox::critical(this, tr("Image reconstruction failed"), tr("Error code: %1").arg(result), QMessageBox::Ok);
        return;
    }

    QFile outputFile;
    outputFile.setFileName(path);
    if (!outputFile.open(QFile::WriteOnly)) {
        QMessageBox::critical(this, tr("Image reconstruction failed"), tr("Can't open output file for rewriting"), QMessageBox::Ok);
        return;
    }

    outputFile.resize(0);
    outputFile.write(reconstructed);
    outputFile.close();
    if (QMessageBox::information(this, tr("Image reconstruction successful"), tr("Open reconstructed file?"), QMessageBox::Yes, QMessageBox::No)
        == QMessageBox::Yes)
        openImageFile(path);
}
예제 #3
0
//-----------------------------------------------------------------
void Exporter::exportDoc()
{

    QTextDocument *document = buildFinalDoc();

    if(ui->fileTypeComboBox->currentIndex() == 0)
        format = "html";
    if(ui->fileTypeComboBox->currentIndex() == 1)
        format = "odt";
    if(ui->fileTypeComboBox->currentIndex() == 2){
        format = "txt";
        QMessageBox::information(this, tr("Project Exporter"), tr("You have selected the .txt format. There is no formatting !"), QMessageBox::Ok);

    }

    QTextDocumentWriter writer;
    QByteArray array;
    QString fileName(ui->pathLineEdit->text() + "/" + ui->fileNameLineEdit->text() + "." + format);
    writer.setFormat(array.append(format));
    writer.setFileName(fileName);
    writer.setCodec(QTextCodec::codecForName("UTF-8"));
    writer.write(document);

    if(format=="html"){

        QFile *textFile = new QFile;
        textFile->setFileName(fileName);
        bool opened = textFile->open(QFile::ReadWrite | QFile::Text);
        //                qDebug() << opened ;
        QTextStream textFileStream( textFile );
        QString textString(textFileStream.readAll());
        if (textFile->resize(0))
        {
            QRegExp regExpCss("<style type=\x0022text/css\x0022>.*</style>");
            regExpCss.setMinimal(true);
            textString = textString.replace( regExpCss, "<style type=\x0022text/css\x0022>p, li { white-space: pre-wrap; } p{line-height: 2em; font-family:'Liberation Serif'; font-size:12pt;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:72px;}</style>");
            //                qDebug() << textString;
            QByteArray array;
            array.append(textString);
            textFile->write(array);
        }

        textFile->close();

    }




    QApplication::restoreOverrideCursor();

    QMessageBox::information(this, tr("Project exported"), tr("This project was successfully exported !"), QMessageBox::Ok);
}
bool LoadSaveManager::save(const ILoadSave &loadSave)
{
    QFile file {m_configFilePath};
    if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) {
        qCWarning(QLoggingCategory("load-save-manager")) << "Failed to open config file"
                                                         << m_configFilePath;
        return false;
    }
    QJsonParseError error {-1, QJsonParseError::NoError};
    QJsonDocument document {QJsonDocument::fromJson(file.readAll(), &error)};

    QJsonObject config {document.object()};
    loadSave.save(config);
    document.setObject(config);
    file.resize(0);
    file.write(document.toJson(QJsonDocument::Indented));
    file.close();
    return true;
}
예제 #5
0
	void writeSparse(QFile& file, const AttributeMap& data)
	{
		FNTRACE("ini", "", "writeSparse", QString("file %1, %2 rows of data").arg(file.fileName()).arg(data.size()));

		if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate))
			ETHROW(Exception(QString("Unable to open %1 for writing.").arg(file.fileName())));

		file.resize(0);
		QTextStream fout(&file);

		int max_key_length = 0;
		for (AttributeMap::const_iterator iter = data.begin(); iter != data.end(); ++iter)
		{
			if (iter.key().length() > max_key_length)
				max_key_length = iter.key().length();
		}
		for (AttributeMap::const_iterator iter = data.begin(); iter != data.end(); ++iter)
		{
			fout << iter.key();
			for (int i = iter.key().length(); i < max_key_length; ++i)
				fout << ' ';
			fout << " = " << iter.value() << "\n";
		}
	}
예제 #6
0
void UEFITool::extract(const UINT8 mode)
{
    QModelIndex index = ui->structureTreeView->selectionModel()->currentIndex();
    if (!index.isValid())
        return;

    TreeModel* model = ffsEngine->treeModel();
    UINT8 type = model->type(index);

    QString path;
    if (mode == EXTRACT_MODE_AS_IS) {
        switch (type) {
        case Capsule:
            path = QFileDialog::getSaveFileName(this, tr("Save capsule to file"),".","Capsule files (*.cap *.bin);;All files (*.*)");
            break;
        case Image:
            path = QFileDialog::getSaveFileName(this, tr("Save image to file"),".","Image files (*.rom *.bin);;All files (*.*)");
            break;
        case Region:
            path = QFileDialog::getSaveFileName(this, tr("Save region to file"),".","Region files (*.rgn *.bin);;All files (*.*)");
            break;
        case Padding:
            path = QFileDialog::getSaveFileName(this, tr("Save padding to file"),".","Padding files (*.pad *.bin);;All files (*.*)");
            break;
        case Volume:
            path = QFileDialog::getSaveFileName(this, tr("Save volume to file"),".","Volume files (*.vol *.bin);;All files (*.*)");
            break;
        case File:
            path = QFileDialog::getSaveFileName(this, tr("Save FFS file to file"),".","FFS files (*.ffs *.bin);;All files (*.*)");
            break;
        case Section:
            path = QFileDialog::getSaveFileName(this, tr("Save section file to file"),".","Section files (*.sct *.bin);;All files (*.*)");
            break;
        default:
            path = QFileDialog::getSaveFileName(this, tr("Save object to file"),".","Binary files (*.bin);;All files (*.*)");
        }
    }
    else if (mode == EXTRACT_MODE_BODY) {
        switch (type) {
        case Capsule:
            path = QFileDialog::getSaveFileName(this, tr("Save capsule body to image file"),".","Image files (*.rom *.bin);;All files (*.*)");
            break;
        case File: {
            if (model->subtype(index) == EFI_FV_FILETYPE_ALL || model->subtype(index) == EFI_FV_FILETYPE_RAW)
                path = QFileDialog::getSaveFileName(this, tr("Save FFS file body to raw file"),".","Raw files (*.raw *.bin);;All files (*.*)");
            else
                path = QFileDialog::getSaveFileName(this, tr("Save FFS file body to file"),".","FFS file body files (*.fbd *.bin);;All files (*.*)");
        }
            break;
        case Section: {
            if (model->subtype(index) == EFI_SECTION_COMPRESSION || model->subtype(index) == EFI_SECTION_GUID_DEFINED || model->subtype(index) == EFI_SECTION_DISPOSABLE)
                path = QFileDialog::getSaveFileName(this, tr("Save encapsulation section body to FFS body file"),".","FFS file body files (*.fbd *.bin);;All files (*.*)");
            else if (model->subtype(index) == EFI_SECTION_FIRMWARE_VOLUME_IMAGE)
                path = QFileDialog::getSaveFileName(this, tr("Save section body to volume file"),".","Volume files (*.vol *.bin);;All files (*.*)");
            else if (model->subtype(index) == EFI_SECTION_RAW)
                path = QFileDialog::getSaveFileName(this, tr("Save section body to raw file"),".","Raw files (*.raw *.bin);;All files (*.*)");
            else
                path = QFileDialog::getSaveFileName(this, tr("Save section body to file"),".","Binary files (*.bin);;All files (*.*)");
        }
            break;
        default:
            path = QFileDialog::getSaveFileName(this, tr("Save object to file"),".","Binary files (*.bin);;All files (*.*)");
        }
    }
    else
        path = QFileDialog::getSaveFileName(this, tr("Save object to file"),".","Binary files (*.bin);;All files (*.*)");

    QByteArray extracted;
    UINT8 result = ffsEngine->extract(index, extracted, mode);
    if (result) {
        QMessageBox::critical(this, tr("Extraction failed"), tr("Error code: %1").arg(result), QMessageBox::Ok);
        return;
    }

    QFile outputFile;
    outputFile.setFileName(path);
    if (!outputFile.open(QFile::WriteOnly)) {
        QMessageBox::critical(this, tr("Extraction failed"), tr("Can't open output file for rewriting"), QMessageBox::Ok);
        return;
    }
    outputFile.resize(0);
    outputFile.write(extracted);
    outputFile.close();

}