Skip to content

Commit

Permalink
Merge pull request #5 from sgqy/master
Browse files Browse the repository at this point in the history
Let input and output can be the same file
  • Loading branch information
BYVoid committed Feb 2, 2017
2 parents f10480b + b519ebd commit 47b0e26
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/convertfiledialog.cpp
Expand Up @@ -49,14 +49,6 @@ void ConvertFileDialog::convertSlot()
}
input_file.close();

QString output_file_name = ui->leOutput->text();
QFile output_file(output_file_name, this);
if (!output_file.open(QFile::WriteOnly))
{
QMessageBox::critical(this, tr("OpenCC"), tr("Output file not writable."));
return;
}

QString config_file = ui->cbConfig->itemData(ui->cbConfig->currentIndex()).toString();
QByteArray config_file_utf8 = config_file.toUtf8();

Expand All @@ -68,6 +60,15 @@ void ConvertFileDialog::convertSlot()
}

QString txt_in = textreader->readAll(input_file_name);

QString output_file_name = ui->leOutput->text();
QFile output_file(output_file_name, this);
if (!output_file.open(QFile::WriteOnly))
{
QMessageBox::critical(this, tr("OpenCC"), tr("Output file not writable."));
return;
}

QString txt_out = conv.convert(txt_in);
QByteArray txt_out_utf8 = txt_out.toUtf8();

Expand Down

0 comments on commit 47b0e26

Please sign in to comment.