From 79d01f713b20f3863b65b2ea970b57b5fa21f81c Mon Sep 17 00:00:00 2001 From: Mich <-> Date: Sun, 12 Jan 2020 15:59:28 +0100 Subject: [PATCH] Added option for visible control chars in ASCII (early works) + GUI tweaks --- src/mainwindow.cpp | 44 +++++++---- src/mainwindow.h | 1 + src/mainwindow.ui | 187 +++++++++++++++++++++++++-------------------- 3 files changed, 138 insertions(+), 94 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index dcb7327..7d567e3 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -346,7 +346,7 @@ void MainWindow::settingsLoadAll() ui->tabWidgetControlSection->setCurrentIndex(appSettings.value("GUI_Elements/tabWidgetControlSection.currentIndex").value()); - ui->radioButtonScrollToButtom->setChecked(appSettings.value("GUI_Elements/radioButtonScrollToButtom.isChecked").value()); + ui->checkBoxScrollToButtom->setChecked(appSettings.value("GUI_Elements/checkBoxScrollToButtom.isChecked").value()); ui->lineEditCustomParsingRules->setText(appSettings.value("data/lineEditCustomParsingRules.text").value()); ui->lineEditUDPTargetIP->setText(appSettings.value("data/lineEditUDPTargetIP.text").value()); @@ -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()); @@ -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(); @@ -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()); @@ -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) @@ -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()); @@ -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() diff --git a/src/mainwindow.h b/src/mainwindow.h index a8b13ec..b570280 100755 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -183,6 +183,7 @@ private slots: void setupTable(); void writeLogToFile(QString rawLine, QStringList labelList, QList dataList, QList timeList); void addLogBytes(QByteArray bytes, bool hexToBinary = false, bool appendAsLine = false); + QString controlCharactersVisibleConvert(QString text); protected: void keyPressEvent(QKeyEvent *event); }; diff --git a/src/mainwindow.ui b/src/mainwindow.ui index c37aa92..d8c7510 100755 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1538,7 +1538,26 @@ - + + + + + 0 + 0 + + + + <html><head/><body><p>If checked, pressed key will be immidietly sent to the device via Serial or UDP, depending on the active control section tab as long as the <span style=" font-weight:600;">text window remains focused</span>.</p><p>This is very useful for creating a rapidly accesible control interface via serial i.e, you could quickly regulate motor's PWM output by holding &quot;+&quot; or &quot;-&quot; keys, instead of typing &quot;set value ... &quot; every time you need to make a change.</p></body></html> + + + Send Key + + + true + + + + @@ -1553,50 +1572,40 @@ - Text highlight: + Highlight: - - + + - + 0 0 - - QComboBox::AdjustToContents + + Control chars - - - Insert - - - - - Append - - - - + + - + 0 0 - - Disable + + <html><head/><body><p>If checked, received message will be displayed with system clock time in which it was received.</p></body></html> - - true + + Timestamp - + @@ -1615,35 +1624,23 @@ - - + + - + 0 0 - <html><head/><body><p>Choose text post-processing:</p><p><span style=" font-weight:600;">- None</span></p><p><span style=" font-weight:600;">- Trim - remove whitespace form the start and the end of each line.</span></p><p><span style=" font-weight:600;">- Simplify - removes whitespace form the start and the end, and that has each sequence of internal whitespace replaced with a single space.</span></p></body></html> + <html><head/><body><p>Wrap all text inside the text window - may work slowly with large text.</p></body></html> + + + Wrap - - - None - - - - - Trim - - - - - Simplify - - - + @@ -1683,81 +1680,109 @@ - - + + - + 0 0 - - <html><head/><body><p>If checked, received message will be displayed with system clock time in which it was received.</p></body></html> - - Timestamp + Disable + + + true - - + + - + 0 0 - - <html><head/><body><p>Wrap all text inside the text window - may work slowly with large text.</p></body></html> + + <html><head/><body><p>Change text format</p></body></html> - - Wrap + + <html><head/><body><p>Choose message display format:</p><p><span style=" font-weight:600;">- text</span></p><p><span style=" font-weight:600;">- hex (base 16)</span></p><p><span style=" font-weight:600;">- binary (base 2)</span></p></body></html> + + + TXT + + + + + HEX + + + + + BIN + + - - + + - + 0 0 - - <html><head/><body><p>If checked, pressed key will be immidietly sent to the device via Serial or UDP, depending on the active control section tab as long as the <span style=" font-weight:600;">text window remains focused</span>.</p><p>This is very useful for creating a rapidly accesible control interface via serial i.e, you could quickly regulate motor's PWM output by holding &quot;+&quot; or &quot;-&quot; keys, instead of typing &quot;set value ... &quot; every time you need to make a change.</p></body></html> - - - Send Key + + <html><head/><body><p>Text processing modes</p></body></html> - - true + + <html><head/><body><p>Choose text post-processing:</p><p><span style=" font-weight:600;">- None</span></p><p><span style=" font-weight:600;">- Trim - remove whitespace form the start and the end of each line.</span></p><p><span style=" font-weight:600;">- Simplify - removes whitespace form the start and the end, and has each sequence of internal whitespace replaced with a single space.</span></p></body></html> + + + None + + + + + Trim + + + + + Simplify + + - - + + 0 0 + + <html><head/><body><p>New line print method</p></body></html> + - <html><head/><body><p>Choose message display format:</p><p><span style=" font-weight:600;">- text</span></p><p><span style=" font-weight:600;">- hex (base 16)</span></p><p><span style=" font-weight:600;">- binary (base 2)</span></p></body></html> + <html><head/><body><p>Change how new text line is added:</p><p><span style=" font-weight:600;">- Insert - moves the cursor to the end of document and simply pastes new data. Similar to &quot;print()&quot; in Arduino</span></p><p><span style=" font-weight:600;">- Append - adds new text as newline. Acts as &quot;println()&quot;. </span></p><p>One can use &quot;trim&quot; or &quot;simplify&quot; to remove all control characters form the text while still adding it as newline without the escape sequences present.</p></body></html> + + + QComboBox::AdjustToContents - TXT - - - - - HEX + Insert line - BIN + Append line @@ -1839,7 +1864,7 @@ - + 0 @@ -2529,7 +2554,7 @@ p, li { white-space: pre-wrap; } 0 0 1801 - 22 + 27