diff --git a/src/commandwidget.cpp b/src/commandwidget.cpp index 5dcdc25..4e7cfb1 100644 --- a/src/commandwidget.cpp +++ b/src/commandwidget.cpp @@ -473,6 +473,26 @@ void CommandWidget::on_cmdLineEdit_textChanged(const QString text) ui->cmdSlider->setMaximum(text.toInt()); } +void CommandWidget::wheelZoomCtrl(int value) +{ + if (value > 0)//鼠标前滚 + { + void on_pushButton_zoomp_pressed(); + qDebug() << "滚轮变倍+:" << value; + } + else if (value < 0) + { + void on_pushButton_zoomd_pressed(); + qDebug() << "滚轮变倍-:" << value; + } + else if (value == 0) + { + void on_pushButton_zoomp_released(); + qDebug() << "停止变倍:" << value; + } + +} + void CommandWidget::setPodIPConfig(NetworkIPStruct networkIP, bool isConnect) { qDebug() << "ip设置槽函数调用了"; diff --git a/src/commandwidget.h b/src/commandwidget.h index 4b83908..c938311 100644 --- a/src/commandwidget.h +++ b/src/commandwidget.h @@ -216,6 +216,7 @@ private slots: void on_cmdLineEdit_textChanged(const QString text); + private: Ui::CommandWidget *ui; QUdpSocket *m_commandUdpSocket = nullptr; @@ -247,6 +248,8 @@ public: void setTargetTracking(double dir, double pitch); //停止跟踪 void setStopTracking(); + //滚轮控制变倍 + void wheelZoomCtrl(int value); }; #endif // COMMANDWIDGET_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b73dc88..6eccc63 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -127,6 +127,7 @@ void MainWindow::initSignalConnection() { &MainWindow::closeVideoSlot); connect(&streamAddrSettingsDlg, &StreamAddrSettingsDlg::sendUavTypeIndex, ui->commandWidget, &CommandWidget::receiveUavTypeIndex); + } void MainWindow::initNotifyMessageConnection() { @@ -539,6 +540,11 @@ void MainWindow::initPodParam() lastLocation->hide(); connect(&settingDlg, &CommunicationSettingDlg::sendPodData, ui->commandWidget, &CommandWidget::setPodIPConfig); + + connect(_wheelStopTime, &QTimer::timeout, this, [this]() { + ui->commandWidget->wheelZoomCtrl(0); + qDebug() << "滚轮停止了"; + }); } void MainWindow::mousePressEvent(QMouseEvent* event) @@ -623,3 +629,50 @@ void MainWindow::mouseReleaseEvent(QMouseEvent* event) } } } + +void MainWindow::wheelEvent(QWheelEvent* event) +{ + if (ui->videoWidget->underMouse()) + { + // 获取滚轮的滚动方向和角度增量 + _delta = event->angleDelta().y(); + QPointF currentLocation = event->position(); + // qDebug() << "当前位置:" << currentLocation; + + if (_delta > 0) + { + // 向上滚动 + qDebug() << "鼠标滚轮向上滚动" << " 步长:" << _delta; + // if(wheelSub->isVisible()) + // { + // wheelSub->hide(); + // } + // wheelPlus->move((currentLocation - QPoint(wheelPlus->width()/2, wheelPlus->height()/2)).toPoint()); + // wheelPlus->show(); + ui->commandWidget->wheelZoomCtrl(_delta); + } + else if (_delta < 0) + { + // 向下滚动 + // if(wheelPlus->isVisible()) + // { + // wheelPlus->hide(); + // } + // wheelSub->move((currentLocation - QPoint(wheelSub->width()/2, wheelSub->height()/2)).toPoint()); + // wheelSub->show(); + ui->commandWidget->wheelZoomCtrl(_delta); + qDebug() << "鼠标滚轮事向下滚动" << " 步长:" << _delta; + } + + if (!_wheelStopTime->isActive()) + { + _wheelStopTime->start(); + } + else + { + _wheelStopTime->stop(); + _wheelStopTime->start(); + } + } + QWidget::wheelEvent(event); +} diff --git a/src/mainwindow.h b/src/mainwindow.h index 1022393..1fa2b8b 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -55,6 +55,7 @@ protected: signals: void themeChanged(); void sendErrorMessage(QString message, int type); + void wheelSendData(int value); private: void initSignalConnection(); @@ -110,5 +111,7 @@ public: void mouseMoveEvent(QMouseEvent* event) override; // ¼ void mouseReleaseEvent(QMouseEvent* event) override; +protected: + void wheelEvent(QWheelEvent* event) override; }; #endif // MAINWINDOW_H