You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

105 regels
2.9 KiB

  1. #include "StatusWindow.h"
  2. #include "ui_StatusWindow.h"
  3. #include <QScrollBar>
  4. #include <QDateTime>
  5. #include "defines.h"
  6. #include "LogsSorter.h"
  7. CStatusWindow::CStatusWindow(QWidget *parent) :
  8. QWidget(parent),
  9. ui(new Ui::CStatusWindow)
  10. {
  11. ui->setupUi(this);
  12. setAutoFillBackground(true);
  13. mProgramPtr = 0;
  14. connect(ui->mForceScanBtn,&QPushButton::pressed,this,&CStatusWindow::ManualScanBtnPressed);
  15. ui->mSoftVersionLbl->setText(QString("Version: %1").arg(SOFTWARE_VERSION));
  16. ui->mMsgTxtEditBox->setReadOnly(true);
  17. }
  18. CStatusWindow::~CStatusWindow()
  19. {
  20. delete ui;
  21. }
  22. int CStatusWindow::AddGeneralMsgBoxLineEntry(QString NewLine, QColor Color)
  23. {
  24. NewLine.remove('\n');
  25. NewLine.remove('\r');
  26. NewLine.append('\n');
  27. NewLine.prepend(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss - "));
  28. AddColoredLineToGenMsgBox(NewLine,Color);
  29. //Limit the number of lines in the MsgBox to avoid overruns...
  30. // if(mGenMsgListBoxTextLines.size() >= GENERAL_MESSAGES_MAX_LOG_LINES)
  31. // {
  32. // mGenMsgListBoxTextLines.removeFirst();
  33. // mGenMsgListBoxTextLines.append(NewLine);
  34. // ui->mMsgTxtEditBox->clear();
  35. // for(int i = 0; i < mGenMsgListBoxTextLines.size(); i++)
  36. // {
  37. // AddColoredLineToGenMsgBox(mGenMsgListBoxTextLines[i],Color);
  38. // }
  39. // }
  40. // else
  41. // {
  42. // mGenMsgListBoxTextLines.append(NewLine);
  43. // AddColoredLineToGenMsgBox(NewLine,Color);
  44. // }
  45. ui->mMsgTxtEditBox->verticalScrollBar()->setValue(ui->mMsgTxtEditBox->verticalScrollBar()->maximum());
  46. return RET_OK;
  47. }
  48. int CStatusWindow::AddColoredLineToGenMsgBox(QString Line, QColor Color)
  49. {
  50. if(Line.isEmpty())
  51. {
  52. return RET_GENERAL_ERROR;
  53. }
  54. // if(Line.at(0) == QChar('%'))
  55. // {
  56. // if(Line.at(1) == QChar('E')) //The line is describing an error... write it red
  57. // {
  58. // ui->mMsgTxtEditBox->setTextColor(Qt::red);
  59. // }
  60. // else if(Line.at(1) == QChar('W')) //The line is describing a warning... write it yellow
  61. // {
  62. // ui->mMsgTxtEditBox->setTextColor(Qt::blue);
  63. // }
  64. // else if(Line.at(1) == QChar('S')) //The line is describing a warning... write it yellow
  65. // {
  66. // ui->mMsgTxtEditBox->setTextColor(Qt::darkGreen);
  67. // }
  68. // else
  69. // {
  70. // qDebug("GeneralStatusPage: Logic error in general message box line encoding... you should check into that");
  71. // return RET_GENERAL_ERROR;
  72. // }
  73. // Line.remove(0,2);
  74. // }
  75. ui->mMsgTxtEditBox->setTextColor(Color);
  76. ui->mMsgTxtEditBox->insertPlainText(Line);
  77. ui->mMsgTxtEditBox->setTextColor(Qt::black);
  78. return RET_OK;
  79. }
  80. void CStatusWindow::ManualScanBtnPressed()
  81. {
  82. AddGeneralMsgBoxLineEntry("Lancement d'un scan manuel.",Qt::darkBlue);
  83. mProgramPtr->LauchManualScanRequest();
  84. AddGeneralMsgBoxLineEntry("Scan manuel terminé.",Qt::darkBlue);
  85. }