widget.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. // m_tSwitch->setQSS(":/QSS/QSS/TransmitterSwitch_dark.qss");
  24. /* 初始化WebAPI */
  25. m_tSwitch->setWebAPIInfo("http://192.1.3.133:31000/v6/", "2e36b53ccd2a433b9a803b98d683ed91", "TMS");
  26. /* 添加设备信息,测试用 */
  27. // addTestDevice();
  28. }
  29. Widget::~Widget()
  30. {
  31. if(m_tSwitch != nullptr)
  32. {
  33. delete m_tSwitch;
  34. m_tSwitch = nullptr;
  35. }
  36. if(m_layout != nullptr)
  37. {
  38. delete m_layout;
  39. m_layout = nullptr;
  40. }
  41. delete ui;
  42. }
  43. /* 导入数据按钮 */
  44. void Widget::on_pBtn_getData_clicked()
  45. {
  46. if(m_tSwitch == nullptr)
  47. {
  48. LH_WRITE_ERROR("TransmitterSwitch is nullptr");
  49. return;
  50. }
  51. m_tSwitch->getExecPlanFromEQM();
  52. }
  53. /* 导出数据按钮 */
  54. void Widget::on_pBtn_saveData_clicked()
  55. {
  56. if(m_tSwitch == nullptr)
  57. {
  58. LH_WRITE_ERROR("TransmitterSwitch is nullptr");
  59. return;
  60. }
  61. m_tSwitch->saveExecPlanToEQM();
  62. }
  63. /* 切换亮色/暗色的按钮 */
  64. void Widget::on_pBtn_light_dark_clicked()
  65. {
  66. if(m_tSwitch == nullptr)
  67. {
  68. LH_WRITE_ERROR("TransmitterSwitch is nullptr");
  69. return;
  70. }
  71. if(LHStyleManager::Instance()->GetCurSkinStyle() == SkinStyle::eWhiteStyle)
  72. {
  73. LHStyleManager::Instance()->SetSkinStyle(SkinStyle::eBlackStyle);
  74. LH_WRITE_LOG_DEBUG("切换为暗色");
  75. }else {
  76. LHStyleManager::Instance()->SetSkinStyle(SkinStyle::eWhiteStyle);
  77. LH_WRITE_LOG_DEBUG("切换为亮色");
  78. }
  79. }
  80. /* 添加测试用的设备信息 */
  81. void Widget::addTestDevice()
  82. {
  83. auto devType = DevTypeContainer.getDevType(955);
  84. if(devType.PTTypeCode == -1)
  85. {
  86. return;
  87. }
  88. DeviceInfo devInfo;
  89. devInfo.devName = "衢州台主发射机";
  90. devInfo.PTTypeCode = 955;
  91. devInfo.DTID = 1;
  92. devInfo.DID = 1;
  93. devInfo.ChannelID = 1;
  94. devInfo.DevType = devType;
  95. DeviceContainer.addDevice(devInfo);
  96. devInfo.devName = "衢州台备发射机";
  97. devInfo.PTTypeCode = 955;
  98. devInfo.DTID = 1;
  99. devInfo.DID = 2;
  100. devInfo.ChannelID = 2;
  101. devInfo.DevType = devType;
  102. DeviceContainer.addDevice(devInfo);
  103. }