Files
chenzhen 222dda1e43 1,新增“App_ThermalImageSystem”;
2,新增“Apps”;
3,新增“Common”;
4,新增“FileList”;
5,新增“MediaX”;
6,新增“OpenSource”;
7,新增“Samples”;
8,新增“SoftwareBusinessLines”.
2026-02-14 23:03:23 +08:00

208 lines
4.8 KiB
C++

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFile>
#include <QMessageBox>
#include <QFileDialog>
#include <QString>
#include <QDebug>
#include "commonhelper.h"
#include "frameless_helper.h"
#include <mmsystem.h>
#pragma comment(lib, "winmm")
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
//
m_bMousePressed = false;
//
m_bWindowMenu = false;
//
m_bThreadRunning_CaptureDeviceData = false;
m_ptrThread_CaptureDeviceData = nullptr;
// 初始化界面
InitStyle();
//
this->setFixedWidth(800);
ui->wgtTitleBar->setFixedWidth(790);
// 加载信号槽函数连接
Connect();
this->setWindowTitle("MainWindow_Process02");
}
MainWindow::~MainWindow()
{
//
StopThread_DealDeviceData();
Disconnect();
delete ui;
}
void MainWindow::Connect()
{
connect(&m_varTimer, &QTimer::timeout, this, &MainWindow::OnTimer);
m_varTimer.setTimerType(Qt::PreciseTimer);
m_varTimer.start(40);
}
void MainWindow::Disconnect()
{
m_varTimer.stop();
disconnect(&m_varTimer, &QTimer::timeout, this, &MainWindow::OnTimer);
}
void MainWindow::OnComboxIndexChanged(int nIndex)
{
}
void MainWindow::InitStyle()
{
m_bMousePressed = false;
//安装事件监听器,让标题栏识别鼠标双击
ui->lblTitle->installEventFilter(this);
this->setWindowFlags(Qt::FramelessWindowHint
| Qt::WindowSystemMenuHint
| Qt::WindowMinimizeButtonHint);
/*
FramelessHelper *pHelper = new FramelessHelper(this);
pHelper->activateOn(this); //激活当前窗体
pHelper->setTitleHeight(ui->wgtTitleBar->height()); //设置窗体的标题栏高度
*/
CommonHelper::SetStyle("blue");//"blue"//"dark"
}
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
return QMainWindow::eventFilter(obj, event);
//if (ui->lblTitle == obj)
{
if (event->type() == QEvent::MouseButtonPress)
{
QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(event);
if (mouseEvent->button() == Qt::LeftButton)
{
m_bMousePressed = true;
m_ptMouse = mouseEvent->globalPos() - pos();
mouseEvent->accept();
}
return true;
}
else if (event->type() == QEvent::MouseMove)
{
QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(event);
if (m_bMousePressed && this->windowState() != Qt::WindowMaximized)
{
if (mouseEvent->globalY() <= qApp->desktop()->availableGeometry().bottom())
{
move(mouseEvent->globalPos() - m_ptMouse);
mouseEvent->accept();
}
else
{
qApp->desktop()->cursor().setPos(
qApp->desktop()->cursor().pos().x(),
qApp->desktop()->availableGeometry().bottom()
);
}
}
return true;
}
else if (event->type() == QEvent::MouseButtonRelease)
{
QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(event);
if (mouseEvent->button() == Qt::LeftButton)
{
m_bMousePressed = false;
mouseEvent->accept();
}
return true;
}
}
return QMainWindow::eventFilter(obj, event);
}
void MainWindow::OnTimer()
{
}
void MainWindow::ThreadEntry(ThreadRunFunPtr pRunFun, void* pOwner)
{
MainWindow* pThis = reinterpret_cast<MainWindow*>(pOwner);
if (NULL == pThis)
{
return;
}
(pThis->*pRunFun)();
}
void MainWindow::ThreadFun_CaptureDeviceData()
{
timeBeginPeriod(1);
byte* pReadData = new byte[2688*1024+4096];
std::chrono::system_clock::time_point tm2_2 = std::chrono::system_clock::now();
int nTimeOutCount = 0;
while(m_bThreadRunning_CaptureDeviceData)
{
int nRes = 0;
}
timeEndPeriod(1);
}
bool MainWindow::StartThread_DealDeviceData()
{
StopThread_DealDeviceData();
//
m_bThreadRunning_CaptureDeviceData = true;
m_ptrThread_CaptureDeviceData = new std::thread(std::bind(&MainWindow::ThreadEntry, &MainWindow::ThreadFun_CaptureDeviceData, (void*)this));
return true;
}
void MainWindow::StopThread_DealDeviceData()
{
//
if(m_bThreadRunning_CaptureDeviceData)
{
m_bThreadRunning_CaptureDeviceData = false;
if(nullptr != m_ptrThread_CaptureDeviceData)
{
m_ptrThread_CaptureDeviceData->join();
delete m_ptrThread_CaptureDeviceData;
m_ptrThread_CaptureDeviceData = nullptr;
}
}
}