Browse Source

V1.8.0

1.界面细节调整
叶海辉 6 years ago
parent
commit
35bbfc92ec

BIN
bin/VideoPlayer.exe


+ 14 - 0
module/DragAbleWidget/DragAbleWidget.cpp

@@ -20,6 +20,12 @@ DragAbleWidget::DragAbleWidget(QWidget *parent) :
 {
     ui->setupUi(this);
 
+    ///定时器用于定制检测鼠标位置,防止鼠标快速移入窗口,没有检测到,导致鼠标箭头呈现拖拉的形状
+    mTimer = new QTimer;
+    mTimer->setInterval(1000);
+    connect(mTimer, &QTimer::timeout, this, &DragAbleWidget::slotTimerTimeOut);
+    mTimer->start();
+
 ///改变窗体大小相关
     isMax = false;
 
@@ -448,3 +454,11 @@ void DragAbleWidget::on_btnMenu_Min_clicked()
         qApp->sendEvent(ui->btnMenu_Min, &evt);
     });
 }
+
+void DragAbleWidget::slotTimerTimeOut()
+{
+    if (QObject::sender() == mTimer)
+    {
+        checkCursorDirect(QCursor::pos());
+    }
+}

+ 5 - 0
module/DragAbleWidget/DragAbleWidget.h

@@ -8,6 +8,7 @@
 #define DRAGABLEWIDGET_H
 
 #include <QWidget>
+#include <QTimer>
 
 namespace Ui {
 class DragAbleWidget;
@@ -33,6 +34,8 @@ public:
 private:
     Ui::DragAbleWidget *ui;
 
+    QTimer *mTimer;
+
     ///以下是改变窗体大小相关
     ////////
 protected:
@@ -58,6 +61,8 @@ private:
     void doChangeFullScreen();
 
 private slots:
+    void slotTimerTimeOut();
+
     void on_btnMenu_Close_clicked();
     void on_btnMenu_Max_clicked();
     void on_btnMenu_Min_clicked();

+ 89 - 28
src/Widget/VideoPlayerWidget.cpp

@@ -49,14 +49,22 @@ VideoPlayerWidget::VideoPlayerWidget(QWidget *parent) :
     connect(ui->horizontalSlider, SIGNAL(sig_valueChanged(int)), this, SLOT(slotSliderMoved(int)));
     connect(ui->horizontalSlider_volume, SIGNAL(valueChanged(int)), this, SLOT(slotSliderMoved(int)));
 
+    ui->page_video->setMouseTracking(true);
+    ui->page_video->installEventFilter(this);
     ui->widget_container->installEventFilter(this);
 
     mPlayer = this;
 
     mTimer = new QTimer; //定时器-获取当前视频时间
-    connect(mTimer,SIGNAL(timeout()),this,SLOT(slotTimerTimeOut()));
+    connect(mTimer, &QTimer::timeout, this, &VideoPlayerWidget::slotTimerTimeOut);
     mTimer->setInterval(500);
 
+    mTimer_CheckControlWidget = new QTimer; //用于控制控制界面的出现和隐藏
+    connect(mTimer_CheckControlWidget, &QTimer::timeout, this, &VideoPlayerWidget::slotTimerTimeOut);
+    mTimer_CheckControlWidget->setInterval(1500);
+
+    mAnimation_ControlWidget  = new QPropertyAnimation(ui->widget_controller, "geometry");
+
     ui->stackedWidget->setCurrentWidget(ui->page_open);
     ui->pushButton_pause->hide();
 
@@ -72,6 +80,56 @@ VideoPlayerWidget::~VideoPlayerWidget()
     delete ui;
 }
 
+void VideoPlayerWidget::showOutControlWidget()
+{
+
+    mAnimation_ControlWidget->setDuration(800);
+
+    int w = ui->widget_controller->width();
+    int h = ui->widget_controller->height();
+    int x = 0;
+    int y = ui->widget_container->height() - ui->widget_controller->height();
+
+    if (ui->widget_controller->isHidden())
+    {
+        ui->widget_controller->show();
+        mAnimation_ControlWidget->setStartValue(ui->widget_controller->geometry());
+    }
+    else
+    {
+        mAnimation_ControlWidget->setStartValue(ui->widget_controller->geometry());
+    }
+
+//    mAnimation_ControlWidget->setKeyValueAt(0, QRect(0, 0, 00, 00));
+//    mAnimation_ControlWidget->setKeyValueAt(0.4, QRect(20, 250, 20, 30));
+//    mAnimation_ControlWidget->setKeyValueAt(0.8, QRect(100, 250, 20, 30));
+//    mAnimation_ControlWidget->setKeyValueAt(1, QRect(250, 250, 100, 30));
+    mAnimation_ControlWidget->setEndValue(QRect(x, y, w, h));
+    mAnimation_ControlWidget->setEasingCurve(QEasingCurve::Linear); //设置动画效果
+
+    mAnimation_ControlWidget->start();
+
+}
+
+void VideoPlayerWidget::hideControlWidget()
+{
+    mAnimation_ControlWidget->setTargetObject(ui->widget_controller);
+
+    mAnimation_ControlWidget->setDuration(300);
+
+    int w = ui->widget_controller->width();
+    int h = ui->widget_controller->height();
+    int x = 0;
+    int y = ui->widget_container->height() + h;
+
+    mAnimation_ControlWidget->setStartValue(ui->widget_controller->geometry());
+    mAnimation_ControlWidget->setEndValue(QRect(x, y, w, h));
+    mAnimation_ControlWidget->setEasingCurve(QEasingCurve::Linear); //设置动画效果
+
+    mAnimation_ControlWidget->start();
+}
+
+
 void VideoPlayerWidget::slotSliderMoved(int value)
 {
     if (QObject::sender() == ui->horizontalSlider)
@@ -100,6 +158,11 @@ void VideoPlayerWidget::slotTimerTimeOut()
         QString str = QString("%1:%2").arg(mStr.right(2)).arg(sStr.right(2));
         ui->label_currenttime->setText(str);
     }
+    else if (QObject::sender() == mTimer_CheckControlWidget)
+    {
+        mTimer_CheckControlWidget->stop();
+        hideControlWidget();
+    }
 }
 
 void VideoPlayerWidget::slotBtnClick(bool isChecked)
@@ -273,6 +336,9 @@ bool VideoPlayerWidget::eventFilter(QObject *target, QEvent *event)
     {
         if(event->type() == QEvent::Resize)
         {
+            ///停止动画,防止此时刚好开始动画,导致位置出错
+            mAnimation_ControlWidget->stop();
+
             QResizeEvent * e = (QResizeEvent*)event;
             int w = e->size().width();
             int h = e->size().height();
@@ -284,35 +350,30 @@ bool VideoPlayerWidget::eventFilter(QObject *target, QEvent *event)
             ui->widget_controller->move(x, y);
             ui->widget_controller->resize(w, ui->widget_controller->height());
         }
-//        else if(event->type() == QEvent::Enter)
-//        {
-//            qDebug("Enter...");
-//        }
-//        else if(event->type() == QEvent::Leave)
-//        {
-//            qDebug("Leave...");
-//        }
-
-//        qDebug("The imageWidget generate the event!");
-//        if(event->type() == QEvent::MouseButtonPress)
-//        {
-//            QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
-//            if(mouseEvent->buttons() & Qt::LeftButton)
-//            {
-//                qDebug("The Left Button Event!");
-
-//            }
-//            else if(mouseEvent->buttons() & Qt::RightButton)
-//            {
-//                qDebug("The Right Button Event!");
-
-//            }
-
-//            return true;
-//        }
+    }
+    else if(target == ui->page_video)
+    {
+        if(event->type() == QEvent::MouseMove)
+        {
+            if (!mTimer_CheckControlWidget->isActive())
+            {
+                showOutControlWidget();
+            }
+
+            mTimer_CheckControlWidget->stop();
+            mTimer_CheckControlWidget->start();
+        }
+        else if(event->type() == QEvent::Enter)
+        {
+            ui->widget_controller->show();
+        }
+        else if(event->type() == QEvent::Leave)
+        {
+            mTimer_CheckControlWidget->stop();
+            mTimer_CheckControlWidget->start();
+        }
     }
 
     //其它部件产生的事件则交给基类处理
     return DragAbleWidget::eventFilter(target, event);
 }
-

+ 6 - 1
src/Widget/VideoPlayerWidget.h

@@ -13,6 +13,7 @@
 #include <QPaintEvent>
 #include <QTimer>
 #include <QPushButton>
+#include <QPropertyAnimation>
 
 #include "VideoPlayer/VideoPlayer.h"
 #include "DragAbleWidget.h"
@@ -38,9 +39,13 @@ private:
 
     VideoPlayer *mPlayer; //播放线程
     QTimer *mTimer; //定时器-获取当前视频时间
-
     float mVolume;
 
+    QTimer *mTimer_CheckControlWidget; //用于控制控制界面的出现和隐藏
+    QPropertyAnimation *mAnimation_ControlWidget;   //控制底部控制控件的出现和隐藏
+    void showOutControlWidget(); //显示底部控制控件
+    void hideControlWidget();    //隐藏底部控制控件
+
 private slots:
     ///播放器相关的槽函数
     void slotSliderMoved(int value);