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

GeneralTesting.cpp 3.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #include "GeneralTesting.h"
  2. #include <QFileDialog>
  3. #include <QStandardPaths>
  4. GeneralTesting::GeneralTesting(QWidget* parent)
  5. : QMainWindow(parent)
  6. , m_bIsNormalShow(true)
  7. , m_fInitWidth(1920.0) // 初始化宽度
  8. , m_fInitHeight(1080.0) // 初始化高度
  9. , m_bMoving(false)
  10. , m_fMaxWidth(0.0)
  11. , m_fMaxHeight(0.0)
  12. // 窗口界面
  13. , m_pFrameConfig(nullptr)
  14. , m_pParamParse(nullptr)
  15. , m_pVideoParse(nullptr)
  16. {
  17. ui.setupUi(this);
  18. // Set the icon for the main window
  19. setWindowIcon(QIcon(":/GeneralTesting/UI/gtt128x128.png"));
  20. createWidget(); // 创建子窗口
  21. getWindowRatio();
  22. }
  23. GeneralTesting::~GeneralTesting()
  24. {
  25. if (m_pFrameConfig) {
  26. delete m_pFrameConfig;
  27. m_pFrameConfig = nullptr;
  28. }
  29. if (m_pParamParse) {
  30. delete m_pParamParse;
  31. m_pParamParse = nullptr;
  32. }
  33. if (m_pVideoParse) {
  34. delete m_pVideoParse;
  35. m_pVideoParse = nullptr;
  36. }
  37. }
  38. void GeneralTesting::createWidget()
  39. {
  40. m_pFrameConfig = new FrameConfig(this);
  41. m_pParamParse = new ParamParse(this);
  42. m_pVideoParse = new VideoParse(this);
  43. connect(m_pFrameConfig, &FrameConfig::switchModelType, m_pParamParse,
  44. &ParamParse::switchModelType);
  45. connect(m_pFrameConfig, &FrameConfig::switchModelType, m_pVideoParse,
  46. &VideoParse::switchModelType);
  47. connect(m_pFrameConfig, &FrameConfig::parseStatus, m_pParamParse, &ParamParse::parseStatus);
  48. connect(m_pFrameConfig, &FrameConfig::parseStatus, m_pVideoParse, &VideoParse::parseStatus);
  49. ui.sw_pageSwitch->addWidget(m_pFrameConfig);
  50. ui.sw_pageSwitch->addWidget(m_pParamParse);
  51. ui.sw_pageSwitch->addWidget(m_pVideoParse);
  52. ui.sw_pageSwitch->setCurrentWidget(m_pFrameConfig);
  53. }
  54. // 获取屏幕分辨率
  55. void GeneralTesting::getWindowRatio()
  56. {
  57. QScreen* m_pScreen = QApplication::primaryScreen();
  58. m_windMaxSize = m_pScreen->availableVirtualSize();
  59. m_fMaxWidth = m_windMaxSize.width();
  60. m_fMaxHeight = m_windMaxSize.height();
  61. if (m_fInitWidth < m_fMaxWidth && m_fInitHeight < m_fMaxHeight) {
  62. float fDeltaWidth = (m_fMaxWidth - m_fInitWidth) / 2.0;
  63. float fDeltaHeight = (m_fMaxHeight - m_fInitHeight) / 2.0;
  64. this->setGeometry(fDeltaWidth, fDeltaHeight, m_fInitWidth, m_fInitHeight);
  65. this->setWindowFlags(windowFlags() & ~Qt::WindowMaximizeButtonHint);
  66. } else {
  67. // 最大化窗体,此时默认占满可使用屏幕尺寸.
  68. this->setWindowState(Qt::WindowMaximized);
  69. }
  70. }
  71. void GeneralTesting::mousePressEvent(QMouseEvent* event)
  72. {
  73. if (event->button() == Qt::LeftButton) {
  74. m_bMoving = true;
  75. QCursor cursor = this->cursor();
  76. Qt::CursorShape shape = cursor.shape();
  77. }
  78. }
  79. void GeneralTesting::mouseReleaseEvent(QMouseEvent* event)
  80. {
  81. if (event->button() == Qt::LeftButton) {
  82. m_bMoving = false;
  83. }
  84. }
  85. void GeneralTesting::mouseDoubleClickEvent(QMouseEvent* event)
  86. {
  87. if (event->button() == Qt::LeftButton) {
  88. }
  89. }
  90. void GeneralTesting::mouseMoveEvent(QMouseEvent* event)
  91. {
  92. if (event->button() == Qt::LeftButton) {
  93. }
  94. }
  95. void GeneralTesting::on_actionQuit_triggered()
  96. {
  97. this->close();
  98. }
  99. void GeneralTesting::on_actionImport_triggered()
  100. {
  101. auto fileName = QFileDialog::getOpenFileName(
  102. this, tr("Open Log File"), QStandardPaths::displayName(QStandardPaths::HomeLocation),
  103. tr("Binary File (*.bin)"));
  104. }
  105. void GeneralTesting::on_actionMain_triggered()
  106. {
  107. ui.sw_pageSwitch->setCurrentWidget(m_pFrameConfig);
  108. }
  109. void GeneralTesting::on_actionConfig_triggered()
  110. {
  111. ui.sw_pageSwitch->setCurrentWidget(m_pParamParse);
  112. }
  113. void GeneralTesting::on_actionVideo_triggered()
  114. {
  115. ui.sw_pageSwitch->setCurrentWidget(m_pVideoParse);
  116. }