Example #1
0
void MainWindow::on_SaveFile_clicked()
{
    if(indexOfSelection()==-1)
        ui->statusBarApp->showMessage("Select client before",10000);
    int index=ui->listWidgetClient->currentRow();
    if(index==-1)
    {
        ui->statusBarApp->showMessage("No client selected!",10000);
        return;
    }
    else
    {
        //save file here
        QString file = QFileDialog::getSaveFileName(
                           this,
                           tr("Select one file to save"),
                           "~/",
                           tr("All files")+" (*)");
        QFile fileDes(file);
        if(file=="")
        {
            ui->statusBarApp->showMessage("Canceled!",10000);
            return;
        }
        if(fileDes.open(QIODevice::WriteOnly))
        {
            fileDes.write(localSocket.at(indexOfSelection())->IncomingData);
            fileDes.close();
        }
        else
            ui->statusBarApp->showMessage("Unabled to open the file in write!",10000);
    }
}
Example #2
0
bool StringTable::load()
{
    if (QFile::exists("txt:german.lan"))
        m_language = "German";
    if (QFile::exists("txt:english.lan"))
        m_language = "English";

    DesFile fileDes("txt:deeptext.des");
    fileDes.setSection("Text");

    if (!fileDes.contains("Text190"))
        return false;

    for (int i = 0; ; i++) {
        const QString key = QString("Text%1").arg(i);
        if (!fileDes.contains(key))
            break;

        m_tableDesktop.append(fileDes.value(key).toString());
    }

    fileDes.load("txt:fightext.des");
    fileDes.setSection("Text");

    for (int i = 0; ; i++) {
        const QString key = QString("Text%1").arg(i);
        if (!fileDes.contains(key))
            break;

        m_tableFight.append(fileDes.value(key).toString());
    }

    return true;
}
Example #3
0
void MainWindow::on_LoadFile_clicked()
{
    if(indexOfSelection()==-1)
        ui->statusBarApp->showMessage("Select client before",10000);
    //load file here
    QString file = QFileDialog::getOpenFileName(
                       this,
                       tr("Select one file to open"),
                       "~/",
                       tr("All files")+" (*)");
    QFile fileDes(file);
    if(file=="")
    {
        ui->statusBarApp->showMessage("Canceled!",10000);
        return;
    }
    if(fileDes.size()>1024*1024)
    {
        ui->statusBarApp->showMessage("File to big to be read",10000);
        return;
    }
    ui->comboBoxTypeTx->setCurrentIndex(1);
    on_comboBoxTypeTx_currentIndexChanged("toHex");
    if(fileDes.open(QIODevice::ReadOnly))
    {
        ui->textEditToClient->setPlainText(fileDes.readAll().toHex());
        fileDes.close();
    }
    else
        ui->statusBarApp->showMessage("Unabled to open the file in read!",10000);
    on_textEditToClient_textChanged();
}