widget.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #include "widget.h"
  2. #include "TransmitterSwitchInfo.h"
  3. #include "ui_widget.h"
  4. #include "LHQLogAPI.h"
  5. #include "lhstylemanager.h"
  6. #include "TransmitterswitchInfo.h"
  7. Widget::Widget(QWidget *parent) :
  8. QWidget(parent),
  9. ui(new Ui::Widget)
  10. {
  11. ui->setupUi(this);
  12. /* 设置暗色 */
  13. // LHStyleMgr->SetSkinStyle("Dark");
  14. m_tSwitch = new TransmitterSwitch();
  15. /* 设置一个布局 */
  16. m_layout = new QVBoxLayout(ui->widget_content);
  17. m_layout->addWidget(m_tSwitch);
  18. ui->widget_content->setLayout(m_layout);
  19. /* 设置边距为0 */
  20. m_layout->setMargin(20);
  21. m_layout->setSpacing(0);
  22. /* 设置参数 */
  23. QString qssPath = QApplication::applicationDirPath();
  24. m_tSwitch->setQSSPath(qssPath);
  25. /* 初始化WebAPI */
  26. m_tSwitch->setWebAPIInfo("http://192.1.3.133:31000/v6/", "2e36b53ccd2a433b9a803b98d683ed91", "TMS");
  27. /* 添加设备信息,测试用 */
  28. // addTestDevice();
  29. }
  30. Widget::~Widget()
  31. {
  32. if(m_tSwitch != nullptr)
  33. {
  34. delete m_tSwitch;
  35. m_tSwitch = nullptr;
  36. }
  37. if(m_layout != nullptr)
  38. {
  39. delete m_layout;
  40. m_layout = nullptr;
  41. }
  42. delete ui;
  43. }
  44. /* 导入数据按钮 */
  45. void Widget::on_pBtn_getData_clicked()
  46. {
  47. if(m_tSwitch == nullptr)
  48. {
  49. LH_WRITE_ERROR("TransmitterSwitch is nullptr");
  50. return;
  51. }
  52. m_tSwitch->getExecPlanFromEQM();
  53. }
  54. /* 导出数据按钮 */
  55. void Widget::on_pBtn_saveData_clicked()
  56. {
  57. if(m_tSwitch == nullptr)
  58. {
  59. LH_WRITE_ERROR("TransmitterSwitch is nullptr");
  60. return;
  61. }
  62. m_tSwitch->saveExecPlanToEQM();
  63. }
  64. /* 切换亮色/暗色的按钮 */
  65. void Widget::on_pBtn_light_dark_clicked()
  66. {
  67. if(m_tSwitch == nullptr)
  68. {
  69. LH_WRITE_ERROR("TransmitterSwitch is nullptr");
  70. return;
  71. }
  72. if(LHStyleManager::Instance()->GetCurSkinStyle() == SkinStyle::eWhiteStyle)
  73. {
  74. LHStyleManager::Instance()->SetSkinStyle(SkinStyle::eBlackStyle);
  75. LH_WRITE_LOG_DEBUG("切换为暗色");
  76. }else {
  77. LHStyleManager::Instance()->SetSkinStyle(SkinStyle::eWhiteStyle);
  78. LH_WRITE_LOG_DEBUG("切换为亮色");
  79. }
  80. }
  81. /* 添加测试用的设备信息 */
  82. void Widget::addTestDevice()
  83. {
  84. auto devType = DevTypeContainer.getDevType(955);
  85. if(devType.PTTypeCode == -1)
  86. {
  87. return;
  88. }
  89. DeviceInfo devInfo;
  90. devInfo.devName = "衢州台主发射机";
  91. devInfo.PTTypeCode = 955;
  92. devInfo.DTID = 1;
  93. devInfo.DID = 1;
  94. devInfo.ChannelID = 1;
  95. devInfo.DevType = devType;
  96. DeviceContainer.addDevice(devInfo);
  97. devInfo.devName = "衢州台备发射机";
  98. devInfo.PTTypeCode = 955;
  99. devInfo.DTID = 1;
  100. devInfo.DID = 2;
  101. devInfo.ChannelID = 2;
  102. devInfo.DevType = devType;
  103. DeviceContainer.addDevice(devInfo);
  104. }