Skip to content

Commit 79d01f7

Browse files
author
Mich
committed
Added option for visible control chars in ASCII (early works) + GUI tweaks
1 parent a3503e6 commit 79d01f7

File tree

3 files changed

+138
-94
lines changed

3 files changed

+138
-94
lines changed

src/mainwindow.cpp

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ void MainWindow::settingsLoadAll()
346346

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

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

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

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

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

451451

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

882+
// Replace control chars
883+
if (ui->checkBoxShowControlChars->isChecked())
884+
text = controlCharactersVisibleConvert(text);
885+
882886
if (!appendAsLine)
883887
{
884888
int sliderPosVertical = ui->textBrowserLogs->verticalScrollBar()->value();
@@ -890,7 +894,7 @@ void MainWindow::addLog(QString text, bool appendAsLine)
890894
ui->textBrowserLogs->horizontalScrollBar()->setValue(sliderPosHorizontal);
891895

892896

893-
if (!ui->radioButtonScrollToButtom->isChecked())
897+
if (!ui->checkBoxScrollToButtom->isChecked())
894898
ui->textBrowserLogs->verticalScrollBar()->setValue(sliderPosVertical);
895899
else
896900
ui->textBrowserLogs->verticalScrollBar()->setValue( ui->textBrowserLogs->verticalScrollBar()->maximum());
@@ -902,6 +906,20 @@ void MainWindow::addLog(QString text, bool appendAsLine)
902906
}
903907
}
904908

909+
QString MainWindow::controlCharactersVisibleConvert(QString text)
910+
{
911+
if (text.replace("\r\n", "\\r\\n\r\n").isEmpty())
912+
{
913+
text.replace("\r", "\\r\r");
914+
text.replace("\n", "\\n\n");
915+
}
916+
917+
text.replace(' ', QChar(183));
918+
text.replace("\t", "\\t\t");
919+
920+
return text;
921+
}
922+
905923
void MainWindow::addLogBytes(QByteArray bytes, bool hexToBinary, bool appendAsLine)
906924
{
907925
if (ui->pushButtonTextLogToggle->isChecked() == false)
@@ -933,7 +951,7 @@ void MainWindow::addLogBytes(QByteArray bytes, bool hexToBinary, bool appendAsLi
933951

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

936-
if (!ui->radioButtonScrollToButtom->isChecked())
954+
if (!ui->checkBoxScrollToButtom->isChecked())
937955
ui->textBrowserLogs->verticalScrollBar()->setValue(sliderPosVertical);
938956
else
939957
ui->textBrowserLogs->verticalScrollBar()->setValue( ui->textBrowserLogs->verticalScrollBar()->maximum());
@@ -2237,15 +2255,15 @@ void MainWindow::on_toolButtonHideTable_clicked()
22372255

22382256
void MainWindow::on_comboBoxAddTextMode_currentIndexChanged(int index)
22392257
{
2240-
if (index == 1)
2241-
{
2242-
ui->radioButtonScrollToButtom->setCheckable(false);
2243-
// ui->radioButtonScrollToButtom->setChecked(false);
2244-
}
2245-
else
2246-
{
2247-
ui->radioButtonScrollToButtom->setCheckable(true);
2248-
}
2258+
// if (index == 1)
2259+
// {
2260+
// ui->radioButtonScrollToButtom->setCheckable(false);
2261+
// ui->radioButtonScrollToButtom->setChecked(false);
2262+
// }
2263+
// else
2264+
// {
2265+
// ui->radioButtonScrollToButtom->setCheckable(true);
2266+
// }
22492267
}
22502268

22512269
void MainWindow::on_actionHide_parser_data_triggered()

src/mainwindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ private slots:
183183
void setupTable();
184184
void writeLogToFile(QString rawLine, QStringList labelList, QList<double> dataList, QList<long> timeList);
185185
void addLogBytes(QByteArray bytes, bool hexToBinary = false, bool appendAsLine = false);
186+
QString controlCharactersVisibleConvert(QString text);
186187
protected:
187188
void keyPressEvent(QKeyEvent *event);
188189
};

0 commit comments

Comments
 (0)