Skip to content

Commit

Permalink
Added option for visible control chars in ASCII (early works) + GUI t…
Browse files Browse the repository at this point in the history
…weaks
  • Loading branch information
Mich committed Jan 12, 2020
1 parent a3503e6 commit 79d01f7
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 94 deletions.
44 changes: 31 additions & 13 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ void MainWindow::settingsLoadAll()

ui->tabWidgetControlSection->setCurrentIndex(appSettings.value("GUI_Elements/tabWidgetControlSection.currentIndex").value<int>());

ui->radioButtonScrollToButtom->setChecked(appSettings.value("GUI_Elements/radioButtonScrollToButtom.isChecked").value<bool>());
ui->checkBoxScrollToButtom->setChecked(appSettings.value("GUI_Elements/checkBoxScrollToButtom.isChecked").value<bool>());

ui->lineEditCustomParsingRules->setText(appSettings.value("data/lineEditCustomParsingRules.text").value<QString>());
ui->lineEditUDPTargetIP->setText(appSettings.value("data/lineEditUDPTargetIP.text").value<QString>());
Expand Down Expand Up @@ -446,7 +446,7 @@ void MainWindow::settingsSaveAll()

appSettings.setValue("GUI_Elements/tabWidgetControlSection.currentIndex", ui->tabWidgetControlSection->currentIndex());

appSettings.setValue("GUI_Elements/radioButtonScrollToButtom.isChecked", ui->radioButtonScrollToButtom->isChecked());
appSettings.setValue("GUI_Elements/checkBoxScrollToButtom.isChecked", ui->checkBoxScrollToButtom->isChecked());


appSettings.setValue("data/lineEditCustomParsingRules.text", ui->lineEditCustomParsingRules->text());
Expand Down Expand Up @@ -879,6 +879,10 @@ void MainWindow::addLog(QString text, bool appendAsLine)
if (ui->checkBoxShowTime->isChecked())
text = currentDateTime + text;

// Replace control chars
if (ui->checkBoxShowControlChars->isChecked())
text = controlCharactersVisibleConvert(text);

if (!appendAsLine)
{
int sliderPosVertical = ui->textBrowserLogs->verticalScrollBar()->value();
Expand All @@ -890,7 +894,7 @@ void MainWindow::addLog(QString text, bool appendAsLine)
ui->textBrowserLogs->horizontalScrollBar()->setValue(sliderPosHorizontal);


if (!ui->radioButtonScrollToButtom->isChecked())
if (!ui->checkBoxScrollToButtom->isChecked())
ui->textBrowserLogs->verticalScrollBar()->setValue(sliderPosVertical);
else
ui->textBrowserLogs->verticalScrollBar()->setValue( ui->textBrowserLogs->verticalScrollBar()->maximum());
Expand All @@ -902,6 +906,20 @@ void MainWindow::addLog(QString text, bool appendAsLine)
}
}

QString MainWindow::controlCharactersVisibleConvert(QString text)
{
if (text.replace("\r\n", "\\r\\n\r\n").isEmpty())
{
text.replace("\r", "\\r\r");
text.replace("\n", "\\n\n");
}

text.replace(' ', QChar(183));
text.replace("\t", "\\t\t");

return text;
}

void MainWindow::addLogBytes(QByteArray bytes, bool hexToBinary, bool appendAsLine)
{
if (ui->pushButtonTextLogToggle->isChecked() == false)
Expand Down Expand Up @@ -933,7 +951,7 @@ void MainWindow::addLogBytes(QByteArray bytes, bool hexToBinary, bool appendAsLi

ui->textBrowserLogs->horizontalScrollBar()->setValue(sliderPosHorizontal);

if (!ui->radioButtonScrollToButtom->isChecked())
if (!ui->checkBoxScrollToButtom->isChecked())
ui->textBrowserLogs->verticalScrollBar()->setValue(sliderPosVertical);
else
ui->textBrowserLogs->verticalScrollBar()->setValue( ui->textBrowserLogs->verticalScrollBar()->maximum());
Expand Down Expand Up @@ -2237,15 +2255,15 @@ void MainWindow::on_toolButtonHideTable_clicked()

void MainWindow::on_comboBoxAddTextMode_currentIndexChanged(int index)
{
if (index == 1)
{
ui->radioButtonScrollToButtom->setCheckable(false);
// ui->radioButtonScrollToButtom->setChecked(false);
}
else
{
ui->radioButtonScrollToButtom->setCheckable(true);
}
// if (index == 1)
// {
// ui->radioButtonScrollToButtom->setCheckable(false);
// ui->radioButtonScrollToButtom->setChecked(false);
// }
// else
// {
// ui->radioButtonScrollToButtom->setCheckable(true);
// }
}

void MainWindow::on_actionHide_parser_data_triggered()
Expand Down
1 change: 1 addition & 0 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ private slots:
void setupTable();
void writeLogToFile(QString rawLine, QStringList labelList, QList<double> dataList, QList<long> timeList);
void addLogBytes(QByteArray bytes, bool hexToBinary = false, bool appendAsLine = false);
QString controlCharactersVisibleConvert(QString text);
protected:
void keyPressEvent(QKeyEvent *event);
};
Expand Down
Loading

0 comments on commit 79d01f7

Please sign in to comment.