@@ -257,7 +257,7 @@ void MainWindow::settingsLoadAll()
257
257
appSettings.value (" Info/applicationName" ).value <QString>() != appSettings.applicationName ())
258
258
{
259
259
qDebug () << " Abort loading settings ! organizationName or applicationName incorrect. Config file might be missing." ;
260
- addLog (" App >>\t Error loading settings. Config file incorrect !" );
260
+ addLog (" App >>\t Error loading settings. Config file incorrect !" , true );
261
261
return ;
262
262
}
263
263
}
@@ -866,11 +866,11 @@ void MainWindow::on_updateSerialDeviceList()
866
866
void MainWindow::on_pushButtonRefresh_clicked ()
867
867
{
868
868
qDebug () << " Refreshing serial device list..." ;
869
- this ->addLog (" App >>\t Searching for COM ports..." );
869
+ this ->addLog (" App >>\t Searching for COM ports..." , true );
870
870
this ->on_updateSerialDeviceList ();
871
871
}
872
872
873
- void MainWindow::addLog (QString text)
873
+ void MainWindow::addLog (QString text, bool appendAsLine )
874
874
{
875
875
if (ui->pushButtonTextLogToggle ->isChecked () == false )
876
876
{
@@ -879,9 +879,7 @@ void MainWindow::addLog(QString text)
879
879
if (ui->checkBoxShowTime ->isChecked ())
880
880
text = currentDateTime + text;
881
881
882
- // while (text.endsWith('\n') || text.endsWith('\r'))
883
- // text.chop(1);
884
- if (ui->comboBoxAddTextMode ->currentIndex () == 0 )
882
+ if (!appendAsLine)
885
883
{
886
884
int sliderPosVertical = ui->textBrowserLogs ->verticalScrollBar ()->value ();
887
885
int sliderPosHorizontal = ui->textBrowserLogs ->horizontalScrollBar ()->value ();
@@ -897,14 +895,14 @@ void MainWindow::addLog(QString text)
897
895
else
898
896
ui->textBrowserLogs ->verticalScrollBar ()->setValue ( ui->textBrowserLogs ->verticalScrollBar ()->maximum ());
899
897
}
900
- else if (ui-> comboBoxAddTextMode -> currentIndex () == 1 )
898
+ else
901
899
{
902
900
ui->textBrowserLogs ->appendPlainText (text);
903
901
}
904
902
}
905
903
}
906
904
907
- void MainWindow::addLogBytes (QByteArray bytes, bool hexToBinary)
905
+ void MainWindow::addLogBytes (QByteArray bytes, bool hexToBinary, bool appendAsLine )
908
906
{
909
907
if (ui->pushButtonTextLogToggle ->isChecked () == false )
910
908
{
@@ -925,7 +923,7 @@ void MainWindow::addLogBytes(QByteArray bytes, bool hexToBinary)
925
923
if (ui->checkBoxShowTime ->isChecked ())
926
924
bytesText = currentDateTime + bytesText;
927
925
928
- if (ui-> comboBoxAddTextMode -> currentIndex () == 0 )
926
+ if (!appendAsLine )
929
927
{
930
928
int sliderPosVertical = ui->textBrowserLogs ->verticalScrollBar ()->value ();
931
929
int sliderPosHorizontal = ui->textBrowserLogs ->horizontalScrollBar ()->value ();
@@ -941,7 +939,7 @@ void MainWindow::addLogBytes(QByteArray bytes, bool hexToBinary)
941
939
ui->textBrowserLogs ->verticalScrollBar ()->setValue ( ui->textBrowserLogs ->verticalScrollBar ()->maximum ());
942
940
943
941
}
944
- else if (ui-> comboBoxAddTextMode -> currentIndex () == 1 )
942
+ else
945
943
{
946
944
ui->textBrowserLogs ->appendPlainText (bytesText);
947
945
}
@@ -972,15 +970,15 @@ void MainWindow::on_processSerial()
972
970
973
971
if (ui->comboBoxFormat ->currentIndex () == 0 && serialInput.isEmpty () == false )
974
972
{
975
- addLog (serialInput);
973
+ addLog (serialInput, ui-> comboBoxAddTextMode -> currentIndex () );
976
974
}
977
975
else if (ui->comboBoxFormat ->currentIndex () == 1 && serialInput.length () > 0 )
978
976
{
979
- addLogBytes (serialInput.toUtf8 ());
977
+ addLogBytes (serialInput.toUtf8 (), false , ui-> comboBoxAddTextMode -> currentIndex () );
980
978
}
981
979
else if (ui->comboBoxFormat ->currentIndex () == 2 && serialInput.length () > 0 )
982
980
{
983
- addLogBytes (serialInput.toUtf8 (), true );
981
+ addLogBytes (serialInput.toUtf8 (), true , ui-> comboBoxAddTextMode -> currentIndex () );
984
982
}
985
983
986
984
if (serialInput.isEmpty () == false )
@@ -1025,11 +1023,11 @@ void MainWindow::on_processUDP()
1025
1023
}
1026
1024
else if (ui->comboBoxFormat ->currentIndex () == 1 && udpInput.length () > 0 )
1027
1025
{
1028
- addLogBytes (udpInput.toUtf8 ());
1026
+ addLogBytes (udpInput.toUtf8 (), false , ui-> comboBoxAddTextMode -> currentIndex () );
1029
1027
}
1030
1028
else if (ui->comboBoxFormat ->currentIndex () == 2 && udpInput.length () > 0 )
1031
1029
{
1032
- addLogBytes (udpInput.toUtf8 (), true );
1030
+ addLogBytes (udpInput.toUtf8 (), true , ui-> comboBoxAddTextMode -> currentIndex () );
1033
1031
}
1034
1032
1035
1033
if (udpInput.isEmpty () == false )
@@ -1050,7 +1048,7 @@ void MainWindow::sendUDPDatagram(QString message)
1050
1048
{
1051
1049
if (!networkUDP.isOpen ())
1052
1050
{
1053
- addLog (" App >>\t Unable to send - port closed." );
1051
+ addLog (" App >>\t Unable to send - port closed." , true );
1054
1052
return ;
1055
1053
}
1056
1054
@@ -1247,7 +1245,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
1247
1245
void MainWindow::sendSerial (QString message)
1248
1246
{
1249
1247
if (!serial.send (message))
1250
- this ->addLog (" App >>\t Unable to send! Serial port closed !" );
1248
+ this ->addLog (" App >>\t Unable to send! Serial port closed !" , true );
1251
1249
}
1252
1250
1253
1251
void MainWindow::saveToRAM (QStringList newlabelList, QList<double > newDataList, QList<long > newTimeList, bool saveText, QString text)
@@ -1590,8 +1588,8 @@ void MainWindow::on_pushButtonSerialConnect_toggled(bool checked)
1590
1588
{
1591
1589
if (serial.getAvailiblePortsCount () < 1 )
1592
1590
{
1593
- addLog (" App >>\t No devices available" );
1594
- addLog (" App >>\t Unable to open serial port!" );
1591
+ addLog (" App >>\t No devices available" , true );
1592
+ addLog (" App >>\t Unable to open serial port!" , true );
1595
1593
ui->pushButtonSerialConnect ->setChecked (false );
1596
1594
return ;
1597
1595
}
@@ -1613,13 +1611,13 @@ void MainWindow::on_pushButtonSerialConnect_toggled(bool checked)
1613
1611
1614
1612
connect (serialStringProcessingTimer, SIGNAL (timeout ()), this , SLOT (on_processSerial ()));
1615
1613
1616
- addLog (" App >>\t Serial port opened. " + serial.getSerialInfo () + " DTR: " + QString::number (ui->checkBoxDTR ->isChecked ()));
1614
+ addLog (" App >>\t Serial port opened. " + serial.getSerialInfo () + " DTR: " + QString::number (ui->checkBoxDTR ->isChecked ()), true );
1617
1615
ui->pushButtonSerialConnect ->setText (" Disconnect" );
1618
1616
}
1619
1617
else
1620
1618
{
1621
1619
ui->pushButtonSerialConnect ->setChecked (false );
1622
- addLog (" App >>\t Unable to open serial port!" );
1620
+ addLog (" App >>\t Unable to open serial port!" , true );
1623
1621
}
1624
1622
}
1625
1623
else
@@ -1630,13 +1628,13 @@ void MainWindow::on_pushButtonSerialConnect_toggled(bool checked)
1630
1628
1631
1629
if (serial.end ())
1632
1630
{
1633
- addLog (" App >>\t Connection closed." );
1631
+ addLog (" App >>\t Connection closed." , true );
1634
1632
ui->pushButtonSerialConnect ->setText (" Connect" );
1635
1633
}
1636
1634
else
1637
1635
{
1638
1636
ui->pushButtonSerialConnect ->setChecked (true );
1639
- addLog (" App >>\t ERROR: Unable to close cennection !" );
1637
+ addLog (" App >>\t ERROR: Unable to close cennection !" , true );
1640
1638
}
1641
1639
1642
1640
if (!ui->pushButtonSerialConnect ->isChecked () && !ui->pushButtonUDPConnect ->isChecked ())
@@ -1651,7 +1649,7 @@ void MainWindow::on_actionSave_As_triggered()
1651
1649
1652
1650
if (fileName.isEmpty ())
1653
1651
{
1654
- addLog (" App >>\t Saving file aborted - filename not specified." );
1652
+ addLog (" App >>\t Saving file aborted - filename not specified." , true );
1655
1653
return ;
1656
1654
}
1657
1655
else
@@ -1796,13 +1794,13 @@ void MainWindow::on_pushButtonUDPConnect_toggled(bool checked)
1796
1794
1797
1795
connect (udpStringProcessingTimer, SIGNAL (timeout ()), this , SLOT (on_processUDP ()));
1798
1796
1799
- addLog (" App >>\t UDP port opened." );
1797
+ addLog (" App >>\t UDP port opened." , true );
1800
1798
1801
1799
ui->pushButtonUDPConnect ->setText (" Close Connection" );
1802
1800
}
1803
1801
else
1804
1802
{
1805
- addLog (" App >>\t UDP error. Unable to bind" );
1803
+ addLog (" App >>\t UDP error. Unable to bind" , true );
1806
1804
}
1807
1805
}
1808
1806
else
@@ -1811,7 +1809,7 @@ void MainWindow::on_pushButtonUDPConnect_toggled(bool checked)
1811
1809
{
1812
1810
udpStringProcessingTimer->stop ();
1813
1811
1814
- addLog (" App >>\t UDP port closed." );
1812
+ addLog (" App >>\t UDP port closed." , true );
1815
1813
1816
1814
disconnect (udpStringProcessingTimer, SIGNAL (timeout ()), this , SLOT (on_processUDP ()));
1817
1815
@@ -1861,7 +1859,7 @@ void MainWindow::on_pushButtonLogging_toggled(bool checked)
1861
1859
{
1862
1860
if (ui->checkBoxAutoLogging ->isChecked () == false && ui->lineEditSaveFileName ->text ().isEmpty ())
1863
1861
{
1864
- addLog (" App >>\t logger error - filename not specified !" );
1862
+ addLog (" App >>\t logger error - filename not specified !" , true );
1865
1863
ui->pushButtonLogging ->setChecked (false );
1866
1864
return ;
1867
1865
}
@@ -1872,7 +1870,7 @@ void MainWindow::on_pushButtonLogging_toggled(bool checked)
1872
1870
{
1873
1871
if (!fileLogger.beginLog (ui->lineEditSaveLogPath ->text (), ui->checkBoxAutoLogging ->isChecked (), ui->lineEditSaveFileName ->text ()))
1874
1872
{
1875
- addLog (" App >>\t logger error - unable to open File" );
1873
+ addLog (" App >>\t logger error - unable to open File" , true );
1876
1874
ui->pushButtonLogging ->setChecked (false );
1877
1875
return ;
1878
1876
}
@@ -2116,18 +2114,18 @@ void MainWindow::on_pushButtonLoadFile_clicked()
2116
2114
2117
2115
if (fileReader.readAllAtOnce (&inputFile))
2118
2116
{
2119
- addLog (" App >>\t Read file succesfully... " );
2117
+ addLog (" App >>\t Read file succesfully... " , true );
2120
2118
}
2121
2119
else
2122
2120
{
2123
- addLog (" App >>\t invalid file !" );
2121
+ addLog (" App >>\t invalid file !" , true );
2124
2122
ui->pushButtonLoadFile ->setText (" Load File" );
2125
2123
ui->progressBarLoadFile ->setValue (0 );
2126
2124
}
2127
2125
}
2128
2126
else
2129
2127
{
2130
- addLog (" App >>\t file reader error - invalid file path !" );
2128
+ addLog (" App >>\t file reader error - invalid file path !" , true );
2131
2129
ui->pushButtonLoadFile ->setText (" Load File" );
2132
2130
ui->progressBarLoadFile ->setValue (0 );
2133
2131
}
@@ -2242,7 +2240,7 @@ void MainWindow::on_comboBoxAddTextMode_currentIndexChanged(int index)
2242
2240
if (index == 1 )
2243
2241
{
2244
2242
ui->radioButtonScrollToButtom ->setCheckable (false );
2245
- // ui->radioButtonScrollToButtom->setChecked(false);
2243
+ // ui->radioButtonScrollToButtom->setChecked(false);
2246
2244
}
2247
2245
else
2248
2246
{
0 commit comments