|
- #include "GeneralTesting.h"
-
- #include <QFileDialog>
- #include <QStandardPaths>
-
- GeneralTesting::GeneralTesting(QWidget* parent)
- : QMainWindow(parent)
- , m_bIsNormalShow(true)
- , m_fInitWidth(1920.0) // 初始化宽度
- , m_fInitHeight(1080.0) // 初始化高度
- , m_bMoving(false)
- , m_fMaxWidth(0.0)
- , m_fMaxHeight(0.0)
- // 窗口界面
- , m_pFrameConfig(nullptr)
- , m_pParamParse(nullptr)
- , m_pVideoParse(nullptr)
- {
- ui.setupUi(this);
- // Set the icon for the main window
- setWindowIcon(QIcon(":/GeneralTesting/UI/gtt128x128.png"));
- createWidget(); // 创建子窗口
-
- getWindowRatio();
- }
-
- GeneralTesting::~GeneralTesting()
- {
- if (m_pFrameConfig) {
- delete m_pFrameConfig;
- m_pFrameConfig = nullptr;
- }
- if (m_pParamParse) {
- delete m_pParamParse;
- m_pParamParse = nullptr;
- }
- if (m_pVideoParse) {
- delete m_pVideoParse;
- m_pVideoParse = nullptr;
- }
- }
- void GeneralTesting::createWidget()
- {
- m_pFrameConfig = new FrameConfig(this);
- m_pParamParse = new ParamParse(this);
- m_pVideoParse = new VideoParse(this);
- connect(m_pFrameConfig, &FrameConfig::switchModelType, m_pParamParse,
- &ParamParse::switchModelType);
- connect(m_pFrameConfig, &FrameConfig::switchModelType, m_pVideoParse,
- &VideoParse::switchModelType);
- connect(m_pFrameConfig, &FrameConfig::parseStatus, m_pParamParse, &ParamParse::parseStatus);
- connect(m_pFrameConfig, &FrameConfig::parseStatus, m_pVideoParse, &VideoParse::parseStatus);
- ui.sw_pageSwitch->addWidget(m_pFrameConfig);
- ui.sw_pageSwitch->addWidget(m_pParamParse);
- ui.sw_pageSwitch->addWidget(m_pVideoParse);
- ui.sw_pageSwitch->setCurrentWidget(m_pFrameConfig);
- }
-
- // 获取屏幕分辨率
- void GeneralTesting::getWindowRatio()
- {
- QScreen* m_pScreen = QApplication::primaryScreen();
- m_windMaxSize = m_pScreen->availableVirtualSize();
- m_fMaxWidth = m_windMaxSize.width();
- m_fMaxHeight = m_windMaxSize.height();
- if (m_fInitWidth < m_fMaxWidth && m_fInitHeight < m_fMaxHeight) {
- float fDeltaWidth = (m_fMaxWidth - m_fInitWidth) / 2.0;
- float fDeltaHeight = (m_fMaxHeight - m_fInitHeight) / 2.0;
- this->setGeometry(fDeltaWidth, fDeltaHeight, m_fInitWidth, m_fInitHeight);
- this->setWindowFlags(windowFlags() & ~Qt::WindowMaximizeButtonHint);
- } else {
- // 最大化窗体,此时默认占满可使用屏幕尺寸.
- this->setWindowState(Qt::WindowMaximized);
- }
- }
-
- void GeneralTesting::mousePressEvent(QMouseEvent* event)
- {
- if (event->button() == Qt::LeftButton) {
- m_bMoving = true;
- QCursor cursor = this->cursor();
- Qt::CursorShape shape = cursor.shape();
- }
- }
- void GeneralTesting::mouseReleaseEvent(QMouseEvent* event)
- {
- if (event->button() == Qt::LeftButton) {
- m_bMoving = false;
- }
- }
- void GeneralTesting::mouseDoubleClickEvent(QMouseEvent* event)
- {
- if (event->button() == Qt::LeftButton) {
- }
- }
- void GeneralTesting::mouseMoveEvent(QMouseEvent* event)
- {
- if (event->button() == Qt::LeftButton) {
- }
- }
-
- void GeneralTesting::on_actionQuit_triggered()
- {
- this->close();
- }
-
- void GeneralTesting::on_actionImport_triggered()
- {
- auto fileName = QFileDialog::getOpenFileName(
- this, tr("Open Log File"), QStandardPaths::displayName(QStandardPaths::HomeLocation),
- tr("Binary File (*.bin)"));
- }
-
- void GeneralTesting::on_actionMain_triggered()
- {
- ui.sw_pageSwitch->setCurrentWidget(m_pFrameConfig);
- }
-
- void GeneralTesting::on_actionConfig_triggered()
- {
- ui.sw_pageSwitch->setCurrentWidget(m_pParamParse);
- }
-
- void GeneralTesting::on_actionVideo_triggered()
- {
- ui.sw_pageSwitch->setCurrentWidget(m_pVideoParse);
- }
|