mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-16 16:14:36 -04:00
Add escape sequence support to GUI
Also ensures that CR/LF formatted files remain unaltered when importing Fixes #72 reported by Siniša Sudec
This commit is contained in:
parent
0314ca65a8
commit
29dbb49325
3 changed files with 25 additions and 7 deletions
|
@ -77,7 +77,8 @@ void DataWindow::from_file()
|
|||
QString filename;
|
||||
QFile file;
|
||||
QByteArray outstream;
|
||||
|
||||
QString escape_string;
|
||||
|
||||
open_dialog.setWindowTitle("Open File");
|
||||
open_dialog.setDirectory(settings.value("studio/default_dir", QDir::toNativeSeparators(QDir::homePath())).toString());
|
||||
|
||||
|
@ -92,10 +93,27 @@ void DataWindow::from_file()
|
|||
QMessageBox::critical(this, tr("Open Error"), tr("Could not open selected file."));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
outstream = file.readAll();
|
||||
|
||||
txtDataInput->setPlainText(QString(outstream));
|
||||
/* Allow some non-printing (control) characters to be read from file
|
||||
by converting them to escape sequences */
|
||||
escape_string.clear();
|
||||
escape_string.append(QString(outstream));
|
||||
|
||||
escape_string.replace((QChar)'\\', (QString)"\\\\", Qt::CaseInsensitive);
|
||||
escape_string.replace((QChar)0x04, (QString)"\\E", Qt::CaseInsensitive); /* End of Transmission */
|
||||
escape_string.replace((QChar)'\a', (QString)"\\a", Qt::CaseInsensitive); /* Bell */
|
||||
escape_string.replace((QChar)'\b', (QString)"\\b", Qt::CaseInsensitive); /* Backspace */
|
||||
escape_string.replace((QChar)'\t', (QString)"\\t", Qt::CaseInsensitive); /* Horizontal tab */
|
||||
escape_string.replace((QChar)'\v', (QString)"\\v", Qt::CaseInsensitive); /* Vertical tab */
|
||||
escape_string.replace((QChar)'\f', (QString)"\\f", Qt::CaseInsensitive); /* Form feed */
|
||||
escape_string.replace((QChar)'\r', (QString)"\\r", Qt::CaseInsensitive); /* Carriage return */
|
||||
escape_string.replace((QChar)0x1b, (QString)"\\e", Qt::CaseInsensitive); /* Escape */
|
||||
escape_string.replace((QChar)0x1d, (QString)"\\G", Qt::CaseInsensitive); /* Group Separator */
|
||||
escape_string.replace((QChar)0x1e, (QString)"\\R", Qt::CaseInsensitive); /* Record Separator */
|
||||
|
||||
txtDataInput->setPlainText(QString(escape_string));
|
||||
file.close();
|
||||
|
||||
settings.setValue("studio/default_dir", filename.mid(0, filename.lastIndexOf(QDir::separator())));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue