Procházet zdrojové kódy

V2.1.6 新增播放列表功能

huihui před 4 roky
rodič
revize
0b3a96a916

+ 5 - 2
VideoPlayer.pro

@@ -36,6 +36,7 @@ include(module/DragAbleWidget/DragAbleWidget.pri)
 
 SOURCES += \
     src/Widget/SetVideoUrlDialog.cpp \
+    src/Widget/mymessagebox_withTitle.cpp \
     src/main.cpp \
     src/AppConfig.cpp \
     src/Base/FunctionTransfer.cpp \
@@ -49,13 +50,15 @@ HEADERS  += \
     src/MainWindow.h \
     src/Widget/SetVideoUrlDialog.h \
     src/Widget/ShowVideoWidget.h \
-    src/Widget/VideoSlider.h
+    src/Widget/VideoSlider.h \
+    src/Widget/mymessagebox_withTitle.h
 
 
 FORMS    += \
     src/MainWindow.ui \
     src/Widget/SetVideoUrlDialog.ui \
-    src/Widget/ShowVideoWidget.ui
+    src/Widget/ShowVideoWidget.ui \
+    src/Widget/mymessagebox_withTitle.ui
 
 RESOURCES += \
     resources/resources.qrc

binární
bin32/VideoPlayer.exe


+ 25 - 7
module/DragAbleWidget/DragAbleWidget.cpp

@@ -105,16 +105,22 @@ void DragAbleWidget::mousePressEvent(QMouseEvent *event)
         }
     }
 
-    switch(event->button()) {
+    switch(event->button())
+    {
     case Qt::LeftButton:
         if (isMax || this->isFullScreen()) break;
         isLeftPressDown = true;
         checkCursorDirect(event->globalPos());
 
-        if(dir != NONE) {
+        if(dir != NONE)
+        {
             this->mouseGrabber();
-        } else {
-            dragPosition = event->globalPos() - this->frameGeometry().topLeft();
+            mIsResizeMode = true;
+        }
+        else
+        {
+            dragPosition  = event->globalPos() - this->frameGeometry().topLeft();
+            mIsResizeMode = false;
         }
         break;
 //    case Qt::RightButton:
@@ -141,11 +147,23 @@ void DragAbleWidget::mouseMoveEvent(QMouseEvent *event)
     QPoint tl = mapToGlobal(rect.topLeft());
     QPoint rb = mapToGlobal(rect.bottomRight());
 
-    if(!isLeftPressDown) {
+    if (isMax || this->isFullScreen()) return;
+    if (!isLeftPressDown)
+    {
         checkCursorDirect(gloPoint);
-    } else {
+        return;
+    }
 
-        if(dir != NONE) {
+//    if(!isLeftPressDown)
+//    {
+//        checkCursorDirect(gloPoint);
+//    }
+//    else
+    {
+
+//        if(dir != NONE)
+        if (mIsResizeMode)
+        {
             QRect rMove(tl, rb);
 
             switch(dir) {

+ 4 - 2
module/DragAbleWidget/DragAbleWidget.h

@@ -45,10 +45,12 @@ protected:
     void mousePressEvent(QMouseEvent *event);
 
 private:
-    bool isMax; //是否最大化
+    bool isMax = false; //是否最大化
     QRect mLocation;
 
-    bool isLeftPressDown;  // 判断左键是否按下
+    bool mIsResizeMode = false;
+
+    bool isLeftPressDown = false;  // 判断左键是否按下
     QPoint dragPosition;   // 窗口移动拖动时需要记住的点
     int dir;        // 窗口大小改变时,记录改变方向
 

+ 8 - 8
module/DragAbleWidget/DragAbleWidget.ui

@@ -36,18 +36,18 @@
 {
 	border:3px solid  rgb(46, 165, 255);
 	background-color: rgba(255, 255, 255, 0);
-	border-radius:5px;
+	border-radius:0px;
 }
 
 QWidget#widget_back
 {
-border-radius:3px;
+border-radius:0px;
 }
 
 QWidget#widget_title
 {
-	border-top-right-radius:5px;
-	border-top-left-radius:5px;
+	border-top-right-radius:0px;
+	border-top-left-radius:0px;
 }
 
 QWidget#widget_container
@@ -280,7 +280,7 @@ font-family:&quot;微软雅黑&quot;;</string>
                       <string/>
                      </property>
                      <property name="icon">
-                      <iconset resource="../resources/resources.qrc">
+                      <iconset resource="../../resources/resources.qrc">
                        <normaloff>:/image/showminisizebtn.png</normaloff>:/image/showminisizebtn.png</iconset>
                      </property>
                      <property name="iconSize">
@@ -324,7 +324,7 @@ font-family:&quot;微软雅黑&quot;;</string>
                       <string/>
                      </property>
                      <property name="icon">
-                      <iconset resource="../resources/resources.qrc">
+                      <iconset resource="../../resources/resources.qrc">
                        <normaloff>:/image/showmaxsizebtn.png</normaloff>:/image/showmaxsizebtn.png</iconset>
                      </property>
                      <property name="iconSize">
@@ -359,7 +359,7 @@ font-family:&quot;微软雅黑&quot;;</string>
                    <string/>
                   </property>
                   <property name="icon">
-                   <iconset resource="../resources/resources.qrc">
+                   <iconset resource="../../resources/resources.qrc">
                     <normaloff>:/image/close_normal.png</normaloff>:/image/close_normal.png</iconset>
                   </property>
                   <property name="iconSize">
@@ -403,7 +403,7 @@ font-family:&quot;微软雅黑&quot;;</string>
   </layout>
  </widget>
  <resources>
-  <include location="../resources/resources.qrc"/>
+  <include location="../../resources/resources.qrc"/>
  </resources>
  <connections/>
 </ui>

+ 4 - 4
resources/main.rc

@@ -3,8 +3,8 @@
 IDI_ICON1       ICON      "main.ico"
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION    1,0,0,0
- PRODUCTVERSION 1,0,0,0
+ FILEVERSION    2,1,6,0
+ PRODUCTVERSION 2,1,6,0
  FILEFLAGS      0x0L
  FILEFLAGSMASK  0x3fL
  FILEOS         VOS_NT_WINDOWS32
@@ -17,12 +17,12 @@ BEGIN
         BEGIN
             VALUE "CompanyName", "云天之巅 blog.yundiantech.com"
             VALUE "FileDescription", "我的播放器"
-            VALUE "FileVersion", "1.0.0"
+            VALUE "FileVersion", "2.1.6"
             VALUE "LegalCopyright", "云天之巅 blog.yundiantech.com"
             VALUE "InternalName", "我的播放器"
             VALUE "OriginalFilename", "我的播放器"
             VALUE "ProductName", "我的播放器"
-            VALUE "ProductVersion", "1.0.0"
+            VALUE "ProductVersion", "2.1.6"
         END
     END
     BLOCK "VarFileInfo"

+ 1 - 1
src/AppConfig.cpp

@@ -37,7 +37,7 @@
 
 QString AppConfig::APPID = "{a1db97ad-b8ed-11e9-a297-0235d2b38928}";
 int AppConfig::VERSION = 1;
-QString AppConfig::VERSION_NAME = "2.1.5";
+QString AppConfig::VERSION_NAME = "2.1.6";
 
 MainWindow *AppConfig::gMainWindow = NULL;
 QRect AppConfig::gMainWindowRect;

+ 57 - 17
src/Base/FunctionTransfer.cpp

@@ -14,6 +14,11 @@ FunctionTransfer::FunctionTransfer(QObject *parent) :
     //因为std::function<void()>是自定义的类型 要跨线程传递需要先注册一下
     qRegisterMetaType<std::function<void()>>();
 
+    mOnlyRunOneceFunc = nullptr;
+
+    mTimer = new QTimer;
+    connect(mTimer, &QTimer::timeout, this, &FunctionTransfer::slotTimerTimeOut);
+
     connect(this, SIGNAL(comming(std::function<void()>)), this, SLOT(slotExec(std::function<void()>)), Qt::BlockingQueuedConnection);
     connect(this, SIGNAL(comming_noBlock(std::function<void()>)), this, SLOT(slotExec(std::function<void()>)), Qt::QueuedConnection);
 }
@@ -23,6 +28,11 @@ FunctionTransfer::~FunctionTransfer()
 
 }
 
+void FunctionTransfer::init()
+{
+    init(QThread::currentThreadId());
+}
+
 void FunctionTransfer::init(Qt::HANDLE id)
 {
     gMainThreadId = id;
@@ -48,6 +58,11 @@ bool FunctionTransfer::isMainThread()
 }
 
 void FunctionTransfer::runInMainThread(std::function<void()> f, bool isBlock)
+{
+    runInMainThread(FunctionTransfer::main_thread_forward, f, isBlock);
+}
+
+void FunctionTransfer::runInMainThread(FunctionTransfer *pointer, std::function<void()> f, bool isBlock)
 {
 //    FunctionTransfer::main_thread_forward->exec(f, isBlock);
     if(FunctionTransfer::isMainThread())
@@ -56,33 +71,58 @@ void FunctionTransfer::runInMainThread(std::function<void()> f, bool isBlock)
     }
     else
     {
+        FunctionTransfer *p = pointer;
+
+        if (p == nullptr)
+        {
+            p = FunctionTransfer::main_thread_forward;
+        }
+
         if (isBlock)
         {
-            Q_EMIT FunctionTransfer::main_thread_forward->comming(f);
+            Q_EMIT pointer->comming(f);
         }
         else
         {
-            Q_EMIT FunctionTransfer::main_thread_forward->comming_noBlock(f);
+            Q_EMIT pointer->comming_noBlock(f);
         }
     }
 }
 
+void FunctionTransfer::runOnece(std::function<void()> f, const int &time)
+{
+    runOnece(FunctionTransfer::main_thread_forward, f, time);
+}
+
+void FunctionTransfer::runOnece(FunctionTransfer *pointer, std::function<void()> f, const int &time)
+{
+    if (time < 0) return;
+
+    FunctionTransfer::runInMainThread(pointer, [=]
+    {
+        ///检测升级
+        FunctionTransfer *p = pointer;
+        if (p == nullptr)
+        {
+            p = FunctionTransfer::main_thread_forward;
+        }
+
+        p->mOnlyRunOneceFunc = f;
+        p->mTimer->stop();
+        p->mTimer->start(time);
+    });
+}
+
 void FunctionTransfer::slotExec(std::function<void()> f)
 {
     f();
-//    if(FunctionTransfer::isMainThread())
-//    {
-//        f();
-//    }
-//    else
-//    {
-//        if (isBlock)
-//        {
-//            Q_EMIT this->comming(f);
-//        }
-//        else
-//        {
-//            Q_EMIT this->comming_noBlock(f);
-//        }
-//    }
+}
+
+void FunctionTransfer::slotTimerTimeOut()
+{
+    if (QObject::sender() == mTimer)
+    {
+        mTimer->stop();
+        mOnlyRunOneceFunc();
+    }
 }

+ 15 - 2
src/Base/FunctionTransfer.h

@@ -5,6 +5,8 @@
 
 #include <QThread>
 #include <QObject>
+#include <QTimer>
+#include <QMutex>
 
 //#ifdef QT_NO_KEYWORDS
 //#define signals Q_SIGNALS
@@ -21,12 +23,18 @@ public:
     explicit FunctionTransfer(QObject *parent = 0);
     ~FunctionTransfer();
 
+    static void init(); //此函数必须在主函数运行
     static void init(Qt::HANDLE id);
     static bool isMainThread();
 
 public:
-    ///@brief 制定函数f在main中执行
+    ///@brief 指定函数f在主线程中中执行
     static void runInMainThread(std::function<void()> f, bool isBlock = false);
+    static void runInMainThread(FunctionTransfer *pointer, std::function<void()> f, bool isBlock = false);
+
+    ///@brief time时间内在主线程中仅执行一次
+    static void runOnece(std::function<void()> f, const int &time);
+    static void runOnece(FunctionTransfer *pointer, std::function<void()> f, const int &time);
 
 private:
     static Qt::HANDLE gMainThreadId;
@@ -34,6 +42,11 @@ private:
     //在全局数据区实例化一个FunctionTransfer的实例,该实例所在的线程就是主线程。
     static FunctionTransfer *main_thread_forward;
 
+public:
+    ///用于实现,一定时间内执行一次函数(有且仅有一次)
+    QTimer *mTimer;
+    std::function<void()> mOnlyRunOneceFunc;
+
 Q_SIGNALS:
     ///@brief 在别的线程有函数对象传来
     void comming(std::function<void()> f);
@@ -42,7 +55,7 @@ Q_SIGNALS:
 private Q_SLOTS:
     ///@brief 执行函数对象
     void slotExec(std::function<void()> f);
-
+    void slotTimerTimeOut();
 };
 
 #endif // FUNCTIONTRANSFER_H

+ 374 - 19
src/MainWindow.cpp

@@ -20,6 +20,7 @@
 #include "Base/FunctionTransfer.h"
 
 #include "Widget/SetVideoUrlDialog.h"
+#include "Widget/mymessagebox_withTitle.h"
 
 Q_DECLARE_METATYPE(VideoPlayerState)
 
@@ -40,8 +41,27 @@ MainWindow::MainWindow(QWidget *parent) :
     //因为VideoPlayer::PlayerState是自定义的类型 要跨线程传递需要先注册一下
     qRegisterMetaType<VideoPlayerState>();
 
+    mPopMenu = new QMenu(this);
+
+    mAddVideoAction              = new QAction(QIcon("images/open.png"), QStringLiteral("打开网络流"), this);
+    mEditVideoAction             = new QAction(QIcon("images/open.png"), QStringLiteral("修改数据"), this);
+    mDeleteVideoAction           = new QAction(QIcon("images/open.png"), QStringLiteral("删除"), this);
+    mClearVideoAction            = new QAction(QIcon("images/open.png"), QStringLiteral("清空"), this);
+
+    mPopMenu->addAction(mAddVideoAction);
+//    mPopMenu->addAction(mEditVideoAction);
+//    mPopMenu->addSeparator();       //添加分离器
+    mPopMenu->addAction(mDeleteVideoAction);
+    mPopMenu->addAction(mClearVideoAction);
+
+    connect(mAddVideoAction,     &QAction::triggered, this, &MainWindow::slotActionClick);
+    connect(mEditVideoAction,    &QAction::triggered, this, &MainWindow::slotActionClick);
+    connect(mDeleteVideoAction,  &QAction::triggered, this, &MainWindow::slotActionClick);
+    connect(mClearVideoAction,   &QAction::triggered, this, &MainWindow::slotActionClick);
+
     connect(ui->pushButton_open, &QPushButton::clicked, this, &MainWindow::slotBtnClick);
     connect(ui->toolButton_open, &QPushButton::clicked, this, &MainWindow::slotBtnClick);
+    connect(ui->pushButton_clear,&QPushButton::clicked, this, &MainWindow::slotBtnClick);
     connect(ui->pushButton_play, &QPushButton::clicked, this, &MainWindow::slotBtnClick);
     connect(ui->pushButton_pause,&QPushButton::clicked, this, &MainWindow::slotBtnClick);
     connect(ui->pushButton_stop, &QPushButton::clicked, this, &MainWindow::slotBtnClick);
@@ -50,12 +70,21 @@ MainWindow::MainWindow(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->listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
+
+    connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &MainWindow::slotItemDoubleClicked);
+    connect(ui->listWidget, &QListWidget::customContextMenuRequested, this, &MainWindow::slotCustomContextMenuRequested);
+
     ui->page_video->setMouseTracking(true);
     ui->widget_videoPlayer->setMouseTracking(true);
 //    ui->page_video->installEventFilter(this);
     ui->widget_videoPlayer->installEventFilter(this);
     ui->widget_container->installEventFilter(this);
 
+    mCurrentIndex = 0;
+    mCurrentItem = nullptr;
+    mIsNeedPlayNext = false;
+
     mPlayer = new VideoPlayer();
     mPlayer->setVideoPlayerCallBack(this);
 
@@ -77,6 +106,37 @@ MainWindow::MainWindow(QWidget *parent) :
 
     mVolume = mPlayer->getVolume();
 
+    std::thread([=]
+    {
+        while (1)
+        {
+            AppConfig::mSleep(500);
+
+            static QPoint lastPoint = QPoint(0, 0);
+
+            FunctionTransfer::runInMainThread([=]()
+            {
+                QPoint point = QCursor::pos();
+
+                if (this->geometry().contains(point))
+                {
+                    if (lastPoint != point)
+                    {
+                        if (!mTimer_CheckControlWidget->isActive())
+                        {
+                            showOutControlWidget();
+                        }
+
+                        mTimer_CheckControlWidget->stop();
+                        mTimer_CheckControlWidget->start();
+
+                        lastPoint = point;
+                    }
+                }
+            });
+        }
+
+    }).detach();
 }
 
 MainWindow::~MainWindow()
@@ -139,6 +199,109 @@ void MainWindow::hideControlWidget()
 }
 
 
+void MainWindow::setVideoNums(const int &nums)
+{
+    ui->label_num->setText(QStringLiteral("%1个文件").arg(nums));
+}
+
+void MainWindow::addVideoFiles(const QStringList &videoFileList)
+{
+    if (!videoFileList.isEmpty())
+    {
+        QString filePath = videoFileList.first();
+        AppConfig::gVideoFilePath = QFileInfo(filePath).absoluteDir().path();
+        AppConfig::saveConfigInfoToFile();
+    }
+
+    for (QString filePath : videoFileList)
+    {
+        addVideoFile(filePath);
+    }
+}
+
+void MainWindow::addVideoFile(const QString &filePath)
+{
+    QFileInfo fileInfo(filePath);
+
+    QListWidgetItem *item = new QListWidgetItem();
+    item->setText(fileInfo.fileName());
+    ui->listWidget->addItem(item);
+
+    mVideoFileList.append(filePath);
+
+    setVideoNums(mVideoFileList.size());
+}
+
+void MainWindow::clear()
+{
+    stopPlay();
+    ui->listWidget->clear();
+    mVideoFileList.clear();
+
+    setVideoNums(mVideoFileList.size());
+}
+
+void MainWindow::startPlay()
+{
+    playVideo(0);
+}
+
+void MainWindow::stopPlay()
+{
+    if (mCurrentItem != nullptr)
+    {
+        mCurrentItem->setBackgroundColor(QColor(0, 0, 0, 0));
+    }
+
+    mCurrentItem = nullptr;
+
+    mIsNeedPlayNext = false;
+    mPlayer->stop(true);
+}
+
+void MainWindow::playVideo(const int &index)
+{
+    int playIndex = index;
+
+//    ///播放到最后一个后,从头开始播放
+//    {
+//        if ((playIndex < 0) || (mVideoFileList.size() <= playIndex))
+//        {
+//            playIndex = 0;
+//        }
+//    }
+
+    if (index >= 0 && mVideoFileList.size() > playIndex)
+    {
+        mCurrentIndex = playIndex;
+
+        QString filePath = mVideoFileList.at(playIndex);
+
+qDebug()<<__FUNCTION__<<filePath<<playIndex;
+
+        playVideoFile(filePath);
+
+//        ui->listWidget->setCurrentRow(playIndex);
+        QListWidgetItem *item = ui->listWidget->item(playIndex);
+
+        if (mCurrentItem != nullptr)
+        {
+            mCurrentItem->setBackgroundColor(QColor(0, 0, 0, 0));
+        }
+
+        mCurrentItem = item;
+
+        mCurrentItem->setBackgroundColor(QColor(75, 92, 196));
+    }
+}
+
+void MainWindow::playVideoFile(const QString &filePath)
+{
+    mIsNeedPlayNext = false;
+    mPlayer->stop(true);
+    mPlayer->startPlay(filePath.toStdString());
+}
+
 void MainWindow::slotSliderMoved(int value)
 {
     if (QObject::sender() == ui->horizontalSlider)
@@ -182,40 +345,155 @@ void MainWindow::slotTimerTimeOut()
     }
 }
 
-void MainWindow::slotBtnClick(bool isChecked)
+
+void MainWindow::doAdd()
 {
-    if (QObject::sender() == ui->pushButton_play)
+    QStringList fileList = QFileDialog::getOpenFileNames(
+               this, QStringLiteral("选择要播放的文件"),
+                AppConfig::gVideoFilePath,//初始目录
+                QStringLiteral("视频文件 (*.flv *.rmvb *.avi *.MP4 *.mkv);;")
+                +QStringLiteral("音频文件 (*.mp3 *.wma *.wav);;")
+                +QStringLiteral("所有文件 (*.*)"));
+
+    if (!fileList.isEmpty())
     {
-        mPlayer->play();
+        addVideoFiles(fileList);
     }
-    else if (QObject::sender() == ui->pushButton_pause)
+
+    ///第一次添加,则直接播放
+    if (mVideoFileList.size() == fileList.size())
     {
-        mPlayer->pause();
+        startPlay();
     }
-    else if (QObject::sender() == ui->pushButton_stop)
+}
+
+void MainWindow::doAddStream()
+{
+    SetVideoUrlDialog dialog;
+
+//        dialog.setVideoUrl(AppConfig::gVideoFilePath);
+
+    if (dialog.exec() == QDialog::Accepted)
     {
-        mPlayer->stop(true);
+        QString s = dialog.getVideoUrl();
+
+        if (!s.isEmpty())
+        {
+            mIsNeedPlayNext = false;
+            mPlayer->stop(true); //如果在播放则先停止
+            mPlayer->startPlay(s.toStdString());
+
+            AppConfig::gVideoFilePath = s;
+            AppConfig::saveConfigInfoToFile();
+        }
+    }
+}
+
+void MainWindow::doDelete()
+{
+    QList<int> RowList;
+
+    QList<QListWidgetItem*> selectedItemList = ui->listWidget->selectedItems();
+
+    for (QListWidgetItem* item : selectedItemList)
+    {
+        int rowValue = ui->listWidget->row(item);
+
+        int index = RowList.size();
+        for (int i=0;i<RowList.size();i++)
+        {
+            int value = RowList.at(i);
+
+            if (rowValue > value)
+            {
+                index = i;
+                break;
+            }
+        }
+
+        RowList.insert(index, rowValue);
     }
-    else if (QObject::sender() == ui->pushButton_open || QObject::sender() == ui->toolButton_open)
+qDebug()<<__FUNCTION__<<RowList;
+    if (RowList.isEmpty())
     {
-        SetVideoUrlDialog dialog;
+        int ret = MyMessageBox_WithTitle::showWarningText(QStringLiteral("警告"),
+                                                           QStringLiteral("请先选择需要删除的数据!"),
+                                                           NULL,
+                                                           QStringLiteral("关闭"));
+        return;
+    }
 
-        dialog.setVideoUrl(AppConfig::gVideoFilePath);
+    int ret = MyMessageBox_WithTitle::showWarningText(QStringLiteral("警告"),
+                                                       QStringLiteral("确定删除这%1条数据么?").arg(RowList.size()),
+                                                       QStringLiteral("确定"),
+                                                       QStringLiteral("取消"));
 
-        if (dialog.exec() == QDialog::Accepted)
+    if (ret == QDialog::Accepted)
+    {
+        for(int i=0; i<RowList.size(); i++)
         {
-            QString s = dialog.getVideoUrl();
+            int row = RowList.at(i);
+
+            mVideoFileList.removeAt(i);
+
+            QListWidgetItem *item = ui->listWidget->takeItem(row);
 
-            if (!s.isEmpty())
+            if (mCurrentItem == item)
             {
-                mPlayer->stop(true); //如果在播放则先停止
-                mPlayer->startPlay(s.toStdString());
+                mCurrentItem = nullptr;
+            }
+
+            delete item;
 
-                AppConfig::gVideoFilePath = s;
-                AppConfig::saveConfigInfoToFile();
+            if (row <= mCurrentIndex)
+            {
+                mCurrentIndex --;
             }
         }
+    }
+
+    setVideoNums(mVideoFileList.size());
+}
+
+void MainWindow::doClear()
+{
+    int ret = MyMessageBox_WithTitle::showWarningText(QStringLiteral("警告"),
+                                                       QStringLiteral("确定要清空所有数据么?"),
+                                                       QStringLiteral("确定"),
+                                                       QStringLiteral("取消"));
+
+    if (ret == QDialog::Accepted)
+    {
+        clear();
+    }
+}
 
+void MainWindow::slotBtnClick(bool isChecked)
+{
+    if (QObject::sender() == ui->pushButton_play)
+    {
+        mPlayer->play();
+    }
+    else if (QObject::sender() == ui->pushButton_pause)
+    {
+        mPlayer->pause();
+    }
+    else if (QObject::sender() == ui->pushButton_stop)
+    {
+        mIsNeedPlayNext = false;
+        mPlayer->stop(true);
+    }
+    else if (QObject::sender() == ui->pushButton_open)
+    {
+        doAdd();
+    }
+    else if (QObject::sender() == ui->pushButton_clear)
+    {
+        doClear();
+    }
+    else if (QObject::sender() == ui->toolButton_open)
+    {
+        doAddStream();
     }
     else if (QObject::sender() == ui->pushButton_volume)
     {
@@ -244,6 +522,68 @@ void MainWindow::slotBtnClick(bool isChecked)
 
 }
 
+
+void MainWindow::slotItemDoubleClicked(QListWidgetItem *item)
+{
+    if (QObject::sender() == ui->listWidget)
+    {
+        int index = ui->listWidget->row(item);
+        playVideo(index);
+    }
+}
+
+void MainWindow::slotCustomContextMenuRequested()
+{
+//    QPoint point(ui->listWidget->mapFromGlobal(QCursor::pos()));//获取控件的全局坐标
+
+//    int h = ui->tableWidget->horizontalHeader()->height();
+
+//    point.setY(point.y() - h);
+
+//    QTableWidgetItem *item = ui->tableWidget->itemAt(point);
+
+//    if (item == NULL || !item->isSelected())
+//    {
+//        ui->tableWidget->clearSelection();
+
+//        mAddUserAction->setEnabled(true);
+//        mEditUserAction->setEnabled(false);
+//        mDeleteUserAction->setEnabled(false);
+//        mExportAction->setEnabled(false);
+//        mUploadAction_Selected->setEnabled(false);
+//    }
+//    else
+//    {
+//        mAddUserAction->setEnabled(false);
+//        mEditUserAction->setEnabled(true);
+//        mDeleteUserAction->setEnabled(true);
+//        mExportAction->setEnabled(true);
+//        mUploadAction_Selected->setEnabled(true);
+//    }
+
+    mPopMenu->exec(QCursor::pos());
+}
+
+void MainWindow::slotActionClick()
+{
+    if (QObject::sender() == mAddVideoAction)
+    {
+        doAddStream();
+    }
+    else if (QObject::sender() == mEditVideoAction)
+    {
+
+    }
+    else if (QObject::sender() == mDeleteVideoAction)
+    {
+        doDelete();
+    }
+    else if (QObject::sender() == mClearVideoAction)
+    {
+        doClear();
+    }
+}
+
 ///打开文件失败
 void MainWindow::onOpenVideoFileFailed(const int &code)
 {
@@ -293,6 +633,7 @@ void MainWindow::onPlayerStateChanged(const VideoPlayerState &state, const bool
 {
     FunctionTransfer::runInMainThread([=]()
     {
+qDebug()<<__FUNCTION__<<state<<mIsNeedPlayNext;
         if (state == VideoPlayer_Stop)
         {
             ui->stackedWidget->setCurrentWidget(ui->page_open);
@@ -306,6 +647,13 @@ void MainWindow::onPlayerStateChanged(const VideoPlayerState &state, const bool
 
             mTimer->stop();
 
+            if (mIsNeedPlayNext)
+            {
+                mCurrentIndex++;
+                playVideo(mCurrentIndex);
+            }
+
+            mIsNeedPlayNext = true;
         }
         else if (state == VideoPlayer_Playing)
         {
@@ -322,6 +670,8 @@ void MainWindow::onPlayerStateChanged(const VideoPlayerState &state, const bool
             ui->pushButton_pause->show();
 
             mTimer->start();
+
+            mIsNeedPlayNext = true;
         }
         else if (state == VideoPlayer_Pause)
         {
@@ -337,6 +687,11 @@ void MainWindow::onDisplayVideo(std::shared_ptr<VideoFrame> videoFrame)
     ui->widget_videoPlayer->inputOneFrame(videoFrame);
 }
 
+void MainWindow::closeEvent(QCloseEvent *event)
+{
+    mPlayer->stop(true);
+}
+
 //图片显示部件时间过滤器处理
 bool MainWindow::eventFilter(QObject *target, QEvent *event)
 {
@@ -350,8 +705,8 @@ bool MainWindow::eventFilter(QObject *target, QEvent *event)
             QResizeEvent * e = (QResizeEvent*)event;
             int w = e->size().width();
             int h = e->size().height();
-            ui->stackedWidget->move(0, 0);
-            ui->stackedWidget->resize(w, h);
+            ui->widget_video_back->move(0, 0);
+            ui->widget_video_back->resize(w, h);
 
             int x = 0;
             int y = h - ui->widget_controller->height();

+ 39 - 0
src/MainWindow.h

@@ -8,6 +8,7 @@
 #define MAINWINDOW_H
 
 #include <QWidget>
+#include <QListWidgetItem>
 
 #include <QImage>
 #include <QPaintEvent>
@@ -15,6 +16,9 @@
 #include <QPushButton>
 #include <QPropertyAnimation>
 
+#include <QMenu>
+#include <QAction>
+
 #include "VideoPlayer/VideoPlayer.h"
 #include "DragAbleWidget.h"
 
@@ -31,7 +35,15 @@ public:
     explicit MainWindow(QWidget *parent = 0);
     ~MainWindow();
 
+    void addVideoFiles(const QStringList &videoFileList);
+    void addVideoFile(const QString &filePath);
+    void clear();
+
+    void startPlay(); //播放第一个
+    void stopPlay();
+
 protected:
+    void closeEvent(QCloseEvent *event);
     bool eventFilter(QObject *target, QEvent *event);
 
 private:
@@ -46,12 +58,39 @@ private:
     void showOutControlWidget(); //显示底部控制控件
     void hideControlWidget();    //隐藏底部控制控件
 
+
+    QMenu* mPopMenu;
+
+    QAction *mAddVideoAction;
+    QAction *mEditVideoAction;
+    QAction *mDeleteVideoAction;
+    QAction *mClearVideoAction;
+
+    void doAdd();
+    void doAddStream();
+    void doDelete();
+    void doClear();
+
+    void setVideoNums(const int &nums);
+
+    QList<QString> mVideoFileList;
+
+    int mCurrentIndex;
+    QListWidgetItem *mCurrentItem;
+    bool mIsNeedPlayNext;
+
+    void playVideo(const int &index);
+    void playVideoFile(const QString &filePath);
+
 private slots:
     ///播放器相关的槽函数
     void slotSliderMoved(int value);
     void slotTimerTimeOut();
     void slotBtnClick(bool isChecked);
+    void slotItemDoubleClicked(QListWidgetItem *item);
 
+    void slotCustomContextMenuRequested();
+    void slotActionClick();
 
     ///以下函数,是播放器的回调函数,用于输出信息给界面
 protected:

+ 452 - 183
src/MainWindow.ui

@@ -38,158 +38,6 @@
 }
 </string>
      </property>
-     <widget class="QStackedWidget" name="stackedWidget">
-      <property name="geometry">
-       <rect>
-        <x>80</x>
-        <y>40</y>
-        <width>931</width>
-        <height>381</height>
-       </rect>
-      </property>
-      <property name="currentIndex">
-       <number>2</number>
-      </property>
-      <widget class="QWidget" name="page_open">
-       <layout class="QVBoxLayout" name="verticalLayout_6">
-        <property name="spacing">
-         <number>0</number>
-        </property>
-        <property name="leftMargin">
-         <number>0</number>
-        </property>
-        <property name="topMargin">
-         <number>0</number>
-        </property>
-        <property name="rightMargin">
-         <number>0</number>
-        </property>
-        <property name="bottomMargin">
-         <number>0</number>
-        </property>
-        <item>
-         <widget class="QWidget" name="widget_showopen" native="true">
-          <property name="sizePolicy">
-           <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
-            <horstretch>0</horstretch>
-            <verstretch>0</verstretch>
-           </sizepolicy>
-          </property>
-          <property name="styleSheet">
-           <string notr="true">QWidget#widget_showopen
-{
-	
-	background-color: rgba(60, 65, 68,100);
-}</string>
-          </property>
-          <layout class="QVBoxLayout" name="verticalLayout_5">
-           <item>
-            <layout class="QHBoxLayout" name="horizontalLayout_3">
-             <item>
-              <spacer name="horizontalSpacer">
-               <property name="orientation">
-                <enum>Qt::Horizontal</enum>
-               </property>
-               <property name="sizeHint" stdset="0">
-                <size>
-                 <width>40</width>
-                 <height>20</height>
-                </size>
-               </property>
-              </spacer>
-             </item>
-             <item>
-              <widget class="QToolButton" name="toolButton_open">
-               <property name="minimumSize">
-                <size>
-                 <width>160</width>
-                 <height>50</height>
-                </size>
-               </property>
-               <property name="cursor">
-                <cursorShape>PointingHandCursor</cursorShape>
-               </property>
-               <property name="text">
-                <string>打开文件</string>
-               </property>
-              </widget>
-             </item>
-             <item>
-              <spacer name="horizontalSpacer_2">
-               <property name="orientation">
-                <enum>Qt::Horizontal</enum>
-               </property>
-               <property name="sizeHint" stdset="0">
-                <size>
-                 <width>40</width>
-                 <height>20</height>
-                </size>
-               </property>
-              </spacer>
-             </item>
-            </layout>
-           </item>
-          </layout>
-         </widget>
-        </item>
-       </layout>
-      </widget>
-      <widget class="QWidget" name="page_audio">
-       <layout class="QVBoxLayout" name="verticalLayout_2">
-        <item>
-         <widget class="QLabel" name="label">
-          <property name="styleSheet">
-           <string notr="true">image: url(:/image/audio.png);</string>
-          </property>
-          <property name="text">
-           <string/>
-          </property>
-         </widget>
-        </item>
-       </layout>
-      </widget>
-      <widget class="QWidget" name="page_video">
-       <layout class="QVBoxLayout" name="verticalLayout_8">
-        <property name="spacing">
-         <number>0</number>
-        </property>
-        <property name="leftMargin">
-         <number>0</number>
-        </property>
-        <property name="topMargin">
-         <number>0</number>
-        </property>
-        <property name="rightMargin">
-         <number>0</number>
-        </property>
-        <property name="bottomMargin">
-         <number>0</number>
-        </property>
-        <item>
-         <widget class="ShowVideoWidget" name="widget_videoPlayer" native="true">
-          <property name="enabled">
-           <bool>true</bool>
-          </property>
-          <property name="sizePolicy">
-           <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
-            <horstretch>0</horstretch>
-            <verstretch>0</verstretch>
-           </sizepolicy>
-          </property>
-          <property name="mouseTracking">
-           <bool>true</bool>
-          </property>
-          <property name="styleSheet">
-           <string notr="true">QWidget#widget_videoPlayer
-{
-	background-color: rgb(255, 55, 195);
-}</string>
-          </property>
-         </widget>
-        </item>
-       </layout>
-      </widget>
-     </widget>
      <widget class="QWidget" name="widget_controller" native="true">
       <property name="geometry">
        <rect>
@@ -226,37 +74,6 @@
          <property name="rightMargin">
           <number>0</number>
          </property>
-         <item>
-          <widget class="QPushButton" name="pushButton_open">
-           <property name="minimumSize">
-            <size>
-             <width>36</width>
-             <height>36</height>
-            </size>
-           </property>
-           <property name="cursor">
-            <cursorShape>PointingHandCursor</cursorShape>
-           </property>
-           <property name="styleSheet">
-            <string notr="true">QPushButton{ 
-image: url(:image/open_normal.png);
-border-radius:0px; 
-} 
-QPushButton:hover{ 
-image: url(:image/open_focus.png);
-border-radius:0px; 
-} 
-QPushButton:pressed{ 
-image: url(:image/open_normal.png);
-border-radius:0px; 
-}
-</string>
-           </property>
-           <property name="text">
-            <string/>
-           </property>
-          </widget>
-         </item>
          <item>
           <spacer name="horizontalSpacer_3">
            <property name="orientation">
@@ -686,6 +503,458 @@ font: 16px &quot;微软雅黑&quot;;
        </item>
       </layout>
      </widget>
+     <widget class="QWidget" name="widget_video_back" native="true">
+      <property name="geometry">
+       <rect>
+        <x>120</x>
+        <y>80</y>
+        <width>681</width>
+        <height>301</height>
+       </rect>
+      </property>
+      <layout class="QHBoxLayout" name="horizontalLayout_4">
+       <property name="leftMargin">
+        <number>0</number>
+       </property>
+       <property name="topMargin">
+        <number>0</number>
+       </property>
+       <property name="rightMargin">
+        <number>0</number>
+       </property>
+       <property name="bottomMargin">
+        <number>0</number>
+       </property>
+       <item>
+        <widget class="QStackedWidget" name="stackedWidget">
+         <property name="currentIndex">
+          <number>1</number>
+         </property>
+         <widget class="QWidget" name="page_open">
+          <layout class="QVBoxLayout" name="verticalLayout_6">
+           <property name="spacing">
+            <number>0</number>
+           </property>
+           <property name="leftMargin">
+            <number>0</number>
+           </property>
+           <property name="topMargin">
+            <number>0</number>
+           </property>
+           <property name="rightMargin">
+            <number>0</number>
+           </property>
+           <property name="bottomMargin">
+            <number>0</number>
+           </property>
+           <item>
+            <widget class="QWidget" name="widget_showopen" native="true">
+             <property name="sizePolicy">
+              <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+               <horstretch>0</horstretch>
+               <verstretch>0</verstretch>
+              </sizepolicy>
+             </property>
+             <property name="styleSheet">
+              <string notr="true">QWidget#widget_showopen
+{
+	
+	background-color: rgba(60, 65, 68,100);
+}</string>
+             </property>
+             <layout class="QVBoxLayout" name="verticalLayout_5">
+              <item>
+               <layout class="QHBoxLayout" name="horizontalLayout_3">
+                <item>
+                 <spacer name="horizontalSpacer">
+                  <property name="orientation">
+                   <enum>Qt::Horizontal</enum>
+                  </property>
+                  <property name="sizeHint" stdset="0">
+                   <size>
+                    <width>40</width>
+                    <height>20</height>
+                   </size>
+                  </property>
+                 </spacer>
+                </item>
+                <item>
+                 <widget class="QToolButton" name="toolButton_open">
+                  <property name="minimumSize">
+                   <size>
+                    <width>160</width>
+                    <height>50</height>
+                   </size>
+                  </property>
+                  <property name="cursor">
+                   <cursorShape>PointingHandCursor</cursorShape>
+                  </property>
+                  <property name="text">
+                   <string>打开文件</string>
+                  </property>
+                 </widget>
+                </item>
+                <item>
+                 <spacer name="horizontalSpacer_2">
+                  <property name="orientation">
+                   <enum>Qt::Horizontal</enum>
+                  </property>
+                  <property name="sizeHint" stdset="0">
+                   <size>
+                    <width>40</width>
+                    <height>20</height>
+                   </size>
+                  </property>
+                 </spacer>
+                </item>
+               </layout>
+              </item>
+             </layout>
+            </widget>
+           </item>
+          </layout>
+         </widget>
+         <widget class="QWidget" name="page_audio">
+          <layout class="QVBoxLayout" name="verticalLayout_2">
+           <item>
+            <widget class="QLabel" name="label">
+             <property name="styleSheet">
+              <string notr="true">image: url(:/image/audio.png);</string>
+             </property>
+             <property name="text">
+              <string/>
+             </property>
+            </widget>
+           </item>
+          </layout>
+         </widget>
+         <widget class="QWidget" name="page_video">
+          <layout class="QVBoxLayout" name="verticalLayout_8">
+           <property name="spacing">
+            <number>0</number>
+           </property>
+           <property name="leftMargin">
+            <number>0</number>
+           </property>
+           <property name="topMargin">
+            <number>0</number>
+           </property>
+           <property name="rightMargin">
+            <number>0</number>
+           </property>
+           <property name="bottomMargin">
+            <number>0</number>
+           </property>
+           <item>
+            <widget class="ShowVideoWidget" name="widget_videoPlayer" native="true">
+             <property name="enabled">
+              <bool>true</bool>
+             </property>
+             <property name="sizePolicy">
+              <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+               <horstretch>0</horstretch>
+               <verstretch>0</verstretch>
+              </sizepolicy>
+             </property>
+             <property name="mouseTracking">
+              <bool>true</bool>
+             </property>
+             <property name="styleSheet">
+              <string notr="true">QWidget#widget_videoPlayer
+{
+	background-color: rgb(255, 55, 195);
+}</string>
+             </property>
+            </widget>
+           </item>
+          </layout>
+         </widget>
+        </widget>
+       </item>
+       <item>
+        <widget class="QWidget" name="widget_list" native="true">
+         <property name="maximumSize">
+          <size>
+           <width>180</width>
+           <height>16777215</height>
+          </size>
+         </property>
+         <property name="styleSheet">
+          <string notr="true">QWidget#widget_left
+{
+	background-color: rgb(47, 48, 57);
+}
+</string>
+         </property>
+         <layout class="QVBoxLayout" name="verticalLayout_4">
+          <property name="spacing">
+           <number>0</number>
+          </property>
+          <property name="leftMargin">
+           <number>0</number>
+          </property>
+          <property name="topMargin">
+           <number>0</number>
+          </property>
+          <property name="rightMargin">
+           <number>0</number>
+          </property>
+          <property name="bottomMargin">
+           <number>0</number>
+          </property>
+          <item>
+           <widget class="QWidget" name="widget_4" native="true">
+            <layout class="QHBoxLayout" name="horizontalLayout_5">
+             <property name="spacing">
+              <number>0</number>
+             </property>
+             <property name="leftMargin">
+              <number>12</number>
+             </property>
+             <property name="topMargin">
+              <number>0</number>
+             </property>
+             <property name="rightMargin">
+              <number>12</number>
+             </property>
+             <property name="bottomMargin">
+              <number>0</number>
+             </property>
+             <item>
+              <widget class="QLabel" name="label_3">
+               <property name="styleSheet">
+                <string notr="true">color:#ffffff;
+font-size:12px;</string>
+               </property>
+               <property name="text">
+                <string>列表:</string>
+               </property>
+              </widget>
+             </item>
+             <item>
+              <widget class="QLabel" name="label_num">
+               <property name="styleSheet">
+                <string notr="true">color:#ffffff;
+font-size:12px;</string>
+               </property>
+               <property name="text">
+                <string>0个文件</string>
+               </property>
+              </widget>
+             </item>
+             <item>
+              <spacer name="horizontalSpacer_4">
+               <property name="orientation">
+                <enum>Qt::Horizontal</enum>
+               </property>
+               <property name="sizeHint" stdset="0">
+                <size>
+                 <width>40</width>
+                 <height>20</height>
+                </size>
+               </property>
+              </spacer>
+             </item>
+             <item>
+              <widget class="QPushButton" name="pushButton_open">
+               <property name="minimumSize">
+                <size>
+                 <width>36</width>
+                 <height>36</height>
+                </size>
+               </property>
+               <property name="cursor">
+                <cursorShape>PointingHandCursor</cursorShape>
+               </property>
+               <property name="styleSheet">
+                <string notr="true">QPushButton{ 
+image: url(:image/open_normal.png);
+border-radius:0px; 
+} 
+QPushButton:hover{ 
+image: url(:image/open_focus.png);
+border-radius:0px; 
+} 
+QPushButton:pressed{ 
+image: url(:image/open_normal.png);
+border-radius:0px; 
+}
+</string>
+               </property>
+               <property name="text">
+                <string/>
+               </property>
+              </widget>
+             </item>
+             <item>
+              <spacer name="horizontalSpacer_7">
+               <property name="orientation">
+                <enum>Qt::Horizontal</enum>
+               </property>
+               <property name="sizeType">
+                <enum>QSizePolicy::Fixed</enum>
+               </property>
+               <property name="sizeHint" stdset="0">
+                <size>
+                 <width>6</width>
+                 <height>20</height>
+                </size>
+               </property>
+              </spacer>
+             </item>
+             <item>
+              <widget class="QPushButton" name="pushButton_clear">
+               <property name="minimumSize">
+                <size>
+                 <width>32</width>
+                 <height>32</height>
+                </size>
+               </property>
+               <property name="maximumSize">
+                <size>
+                 <width>32</width>
+                 <height>32</height>
+                </size>
+               </property>
+               <property name="cursor">
+                <cursorShape>PointingHandCursor</cursorShape>
+               </property>
+               <property name="styleSheet">
+                <string notr="true">QPushButton{ 
+	padding:6px;
+	border:none;
+	image: url(:/player/image/videoplayer/delete.png);
+}  
+QPushButton:hover{ 
+padding:3px;
+} 
+QPushButton:pressed{ 
+
+}
+</string>
+               </property>
+               <property name="text">
+                <string/>
+               </property>
+              </widget>
+             </item>
+            </layout>
+           </widget>
+          </item>
+          <item>
+           <widget class="QWidget" name="widget_5" native="true">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
+            <property name="styleSheet">
+             <string notr="true">QWidget#widget_5
+{
+	border-radius:0px;
+border-top-style: solid; 
+border-top-width: 2px; 
+border-top-color: #cccccc; 
+}</string>
+            </property>
+            <layout class="QVBoxLayout" name="verticalLayout_9">
+             <property name="spacing">
+              <number>0</number>
+             </property>
+             <property name="leftMargin">
+              <number>0</number>
+             </property>
+             <property name="topMargin">
+              <number>0</number>
+             </property>
+             <property name="rightMargin">
+              <number>0</number>
+             </property>
+             <property name="bottomMargin">
+              <number>0</number>
+             </property>
+             <item>
+              <widget class="QListWidget" name="listWidget">
+               <property name="styleSheet">
+                <string notr="true">QListWidget
+{
+	border:none;
+	background-color: transparent;
+}
+
+QListView::item{
+
+padding:0 0px; 
+font-size:14px;
+height:30px;
+font-family: &quot;微软雅黑&quot;;
+color: rgb(255,255,255);
+}
+
+QListView::item:hover {
+background-color: rgba(255, 255, 255, 100);
+}
+
+QListView::item:selected {
+/*background-color: #4B5CC4;*/
+background-color: rgba(255, 255, 255, 130);
+}
+
+
+/*
+QListView::item:selected:!active {
+border-radius:5px; 
+border:1px solid rgb(210, 225, 230);
+background-color: qlineargradient(spread:reflect, x1:0.501, y1:0, x2:0.506, y2:0.489182, stop:0.0284091 rgba(255, 255, 255, 255), stop:1 rgba(255, 170, 0, 255));
+}
+QListView::item:selected:active {
+border-radius:5px; 
+border:1px solid rgb(210, 225, 230);
+background-color: qlineargradient(spread:reflect, x1:0.501, y1:0, x2:0.506, y2:0.489182, stop:0.0284091 rgba(255, 255, 255, 255), stop:1 rgba(255, 170, 0, 255));
+}
+*/</string>
+               </property>
+               <property name="horizontalScrollBarPolicy">
+                <enum>Qt::ScrollBarAlwaysOff</enum>
+               </property>
+               <property name="showDropIndicator" stdset="0">
+                <bool>true</bool>
+               </property>
+               <property name="selectionMode">
+                <enum>QAbstractItemView::ExtendedSelection</enum>
+               </property>
+               <property name="selectionRectVisible">
+                <bool>false</bool>
+               </property>
+              </widget>
+             </item>
+             <item>
+              <spacer name="verticalSpacer">
+               <property name="orientation">
+                <enum>Qt::Vertical</enum>
+               </property>
+               <property name="sizeType">
+                <enum>QSizePolicy::Fixed</enum>
+               </property>
+               <property name="sizeHint" stdset="0">
+                <size>
+                 <width>20</width>
+                 <height>10</height>
+                </size>
+               </property>
+              </spacer>
+             </item>
+            </layout>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
+      </layout>
+     </widget>
+     <zorder>widget_video_back</zorder>
+     <zorder>widget_controller</zorder>
     </widget>
    </item>
   </layout>

+ 96 - 0
src/Widget/mymessagebox_withTitle.cpp

@@ -0,0 +1,96 @@
+#include "mymessagebox_withTitle.h"
+#include "ui_mymessagebox_withTitle.h"
+
+MyMessageBox_WithTitle::MyMessageBox_WithTitle(QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::MyMessageBox_WithTitle)
+{
+    ui->setupUi(this);
+
+    setWindowFlags(Qt::WindowStaysOnTopHint|Qt::FramelessWindowHint);  //ʹ´°¿ÚµÄ±êÌâÀ¸Òþ²Ø
+    setAttribute(Qt::WA_TranslucentBackground, true);
+
+}
+
+MyMessageBox_WithTitle::~MyMessageBox_WithTitle()
+{
+    delete ui;
+}
+
+void MyMessageBox_WithTitle::setText(QString title,QString text,QString acceptBtnText,QString rejectBtnText)
+{
+    ui->lab_Title->setText(title);
+    ui->lab_info->setText(text);
+
+    if (acceptBtnText != NULL)
+    {
+        ui->pushButton_accept->setText(acceptBtnText);
+    }
+    else
+    {
+        ui->pushButton_accept->hide();
+    }
+
+    if (rejectBtnText == NULL)
+    {
+        ui->pushButto_reject->hide();
+    }
+    else
+    {
+        ui->pushButto_reject->setText(rejectBtnText);
+    }
+}
+
+int MyMessageBox_WithTitle::showText(QString title,QString text,QString acceptBtnText,QString rejectBtnText)
+{
+    MyMessageBox_WithTitle dialog;
+    dialog.setText(title,text,acceptBtnText,rejectBtnText);
+    dialog.setMode(2);
+    return dialog.exec();
+}
+
+int MyMessageBox_WithTitle::showSucceesText(QString title,QString text,QString acceptBtnText,QString rejectBtnText)
+{
+    MyMessageBox_WithTitle dialog;
+    dialog.setText(title,text,acceptBtnText,rejectBtnText);
+    dialog.setMode(1);
+    return dialog.exec();
+}
+
+int MyMessageBox_WithTitle::showErroText(QString title,QString text,QString acceptBtnText,QString rejectBtnText)
+{
+    MyMessageBox_WithTitle dialog;
+    dialog.setText(title,text,acceptBtnText,rejectBtnText);
+    dialog.setMode(2);
+    return dialog.exec();
+}
+
+int MyMessageBox_WithTitle::showWarningText(QString title,QString text,QString acceptBtnText,QString rejectBtnText)
+{
+    MyMessageBox_WithTitle dialog;
+    dialog.setText(title,text,acceptBtnText,rejectBtnText);
+    dialog.setMode(3);
+    return dialog.exec();
+}
+
+void MyMessageBox_WithTitle::setMode(int mode)
+{
+    if (mode == 1)
+    {
+        ui->lab_ico_succees->show();
+        ui->lab_ico_erro->hide();
+        ui->lab_ico_warnning->hide();
+    }
+    else if (mode == 2)
+    {
+        ui->lab_ico_succees->hide();
+        ui->lab_ico_erro->show();
+        ui->lab_ico_warnning->hide();
+    }
+    else
+    {
+        ui->lab_ico_succees->hide();
+        ui->lab_ico_erro->hide();
+        ui->lab_ico_warnning->show();
+    }
+}

+ 33 - 0
src/Widget/mymessagebox_withTitle.h

@@ -0,0 +1,33 @@
+#ifndef MYMESSAGEBOX_WITHTITLE_H
+#define MYMESSAGEBOX_WITHTITLE_H
+
+#include <QDialog>
+
+namespace Ui {
+class MyMessageBox_WithTitle;
+}
+
+class MyMessageBox_WithTitle : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit MyMessageBox_WithTitle(QWidget *parent = 0);
+    ~MyMessageBox_WithTitle();
+
+    static int showSucceesText(QString title,QString text,QString acceptBtnText = NULL,QString rejectBtnText = NULL);
+    static int showErroText(QString title,QString text,QString acceptBtnText = NULL,QString rejectBtnText = NULL);
+    static int showWarningText(QString title,QString text,QString acceptBtnText = NULL,QString rejectBtnText = NULL);
+
+    static int showText(QString title,QString text,QString acceptBtnText = NULL,QString rejectBtnText = NULL);
+
+    void setMode(int mode); //1-succees 2-erro 3-danger
+
+private:
+    Ui::MyMessageBox_WithTitle *ui;
+
+    void setText(QString title,QString text,QString acceptBtnText = NULL,QString rejectBtnText = NULL);
+
+};
+
+#endif // MYMESSAGEBOX_WITHTITLE_H

+ 719 - 0
src/Widget/mymessagebox_withTitle.ui

@@ -0,0 +1,719 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MyMessageBox_WithTitle</class>
+ <widget class="QDialog" name="MyMessageBox_WithTitle">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>1136</width>
+    <height>658</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Epen Teacher</string>
+  </property>
+  <layout class="QHBoxLayout" name="horizontalLayout_4">
+   <property name="leftMargin">
+    <number>0</number>
+   </property>
+   <property name="topMargin">
+    <number>0</number>
+   </property>
+   <property name="rightMargin">
+    <number>0</number>
+   </property>
+   <property name="bottomMargin">
+    <number>0</number>
+   </property>
+   <item>
+    <widget class="QWidget" name="widget_back" native="true">
+     <property name="styleSheet">
+      <string notr="true">QWidget#widget_back
+{
+	background-color: rgba(255, 255, 255, 0);
+border:0px solid rgb(33, 33, 33);
+margin:1px; /*距离边框距离*/ 
+}
+</string>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout_5">
+      <item>
+       <spacer name="verticalSpacer_4">
+        <property name="orientation">
+         <enum>Qt::Vertical</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>20</width>
+          <height>40</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+      <item>
+       <layout class="QHBoxLayout" name="horizontalLayout_7">
+        <property name="leftMargin">
+         <number>23</number>
+        </property>
+        <property name="rightMargin">
+         <number>23</number>
+        </property>
+        <item>
+         <spacer name="horizontalSpacer_3">
+          <property name="orientation">
+           <enum>Qt::Horizontal</enum>
+          </property>
+          <property name="sizeHint" stdset="0">
+           <size>
+            <width>300</width>
+            <height>20</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+        <item>
+         <widget class="QWidget" name="widget_background" native="true">
+          <property name="minimumSize">
+           <size>
+            <width>500</width>
+            <height>210</height>
+           </size>
+          </property>
+          <property name="styleSheet">
+           <string notr="true">QWidget#widget_background
+{
+	border:1px solid #03091b;
+	background-color: rgba(0, 0, 0, 1);
+border:1px solid #cccccc;
+}
+</string>
+          </property>
+          <layout class="QVBoxLayout" name="verticalLayout">
+           <property name="spacing">
+            <number>0</number>
+           </property>
+           <property name="leftMargin">
+            <number>1</number>
+           </property>
+           <property name="topMargin">
+            <number>1</number>
+           </property>
+           <property name="rightMargin">
+            <number>1</number>
+           </property>
+           <property name="bottomMargin">
+            <number>1</number>
+           </property>
+           <item>
+            <widget class="QWidget" name="widget_title" native="true">
+             <property name="sizePolicy">
+              <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+               <horstretch>0</horstretch>
+               <verstretch>0</verstretch>
+              </sizepolicy>
+             </property>
+             <property name="minimumSize">
+              <size>
+               <width>100</width>
+               <height>32</height>
+              </size>
+             </property>
+             <property name="styleSheet">
+              <string notr="true"/>
+             </property>
+             <layout class="QHBoxLayout" name="horizontalLayout_2">
+              <property name="spacing">
+               <number>3</number>
+              </property>
+              <property name="leftMargin">
+               <number>23</number>
+              </property>
+              <property name="topMargin">
+               <number>0</number>
+              </property>
+              <property name="rightMargin">
+               <number>0</number>
+              </property>
+              <property name="bottomMargin">
+               <number>0</number>
+              </property>
+              <item>
+               <spacer name="horizontalSpacer_5">
+                <property name="orientation">
+                 <enum>Qt::Horizontal</enum>
+                </property>
+                <property name="sizeHint" stdset="0">
+                 <size>
+                  <width>40</width>
+                  <height>20</height>
+                 </size>
+                </property>
+               </spacer>
+              </item>
+              <item>
+               <widget class="QWidget" name="widget_menu" native="true">
+                <property name="sizePolicy">
+                 <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+                  <horstretch>0</horstretch>
+                  <verstretch>0</verstretch>
+                 </sizepolicy>
+                </property>
+                <layout class="QHBoxLayout" name="horizontalLayout">
+                 <property name="spacing">
+                  <number>0</number>
+                 </property>
+                 <property name="leftMargin">
+                  <number>0</number>
+                 </property>
+                 <property name="topMargin">
+                  <number>0</number>
+                 </property>
+                 <property name="rightMargin">
+                  <number>0</number>
+                 </property>
+                 <property name="bottomMargin">
+                  <number>0</number>
+                 </property>
+                 <item>
+                  <widget class="QPushButton" name="btnMenu_Close">
+                   <property name="sizePolicy">
+                    <sizepolicy hsizetype="Minimum" vsizetype="Expanding">
+                     <horstretch>0</horstretch>
+                     <verstretch>0</verstretch>
+                    </sizepolicy>
+                   </property>
+                   <property name="minimumSize">
+                    <size>
+                     <width>40</width>
+                     <height>0</height>
+                    </size>
+                   </property>
+                   <property name="cursor">
+                    <cursorShape>ArrowCursor</cursorShape>
+                   </property>
+                   <property name="focusPolicy">
+                    <enum>Qt::NoFocus</enum>
+                   </property>
+                   <property name="toolTip">
+                    <string>关闭</string>
+                   </property>
+                   <property name="styleSheet">
+                    <string notr="true">QPushButton{ 
+image: url(:image/close_2_normal.png);
+border-radius:0px; 
+} 
+QPushButton:hover{ 
+image: url(:image/close_hover.png);
+border-radius:0px; 
+	background-color: qlineargradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:0 rgba(238, 0, 0, 128), stop:1 rgba(238, 44, 44, 255));
+}
+
+
+QPushButton:pressed{ 
+image: url(:image/close_hover.png);
+border-radius:0px; 
+}
+</string>
+                   </property>
+                   <property name="text">
+                    <string/>
+                   </property>
+                   <property name="flat">
+                    <bool>true</bool>
+                   </property>
+                  </widget>
+                 </item>
+                </layout>
+               </widget>
+              </item>
+             </layout>
+            </widget>
+           </item>
+           <item>
+            <widget class="QWidget" name="widget_main" native="true">
+             <property name="styleSheet">
+              <string notr="true"/>
+             </property>
+             <layout class="QVBoxLayout" name="verticalLayout_2">
+              <property name="spacing">
+               <number>0</number>
+              </property>
+              <property name="leftMargin">
+               <number>28</number>
+              </property>
+              <property name="topMargin">
+               <number>0</number>
+              </property>
+              <property name="rightMargin">
+               <number>26</number>
+              </property>
+              <property name="bottomMargin">
+               <number>26</number>
+              </property>
+              <item>
+               <widget class="QLabel" name="lab_Title">
+                <property name="sizePolicy">
+                 <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+                  <horstretch>0</horstretch>
+                  <verstretch>0</verstretch>
+                 </sizepolicy>
+                </property>
+                <property name="styleSheet">
+                 <string notr="true">font: 22px &quot;微软雅黑&quot;;
+color:#ffffff;
+</string>
+                </property>
+                <property name="text">
+                 <string>提示</string>
+                </property>
+                <property name="alignment">
+                 <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+                </property>
+               </widget>
+              </item>
+              <item>
+               <spacer name="verticalSpacer_3">
+                <property name="orientation">
+                 <enum>Qt::Vertical</enum>
+                </property>
+                <property name="sizeType">
+                 <enum>QSizePolicy::Fixed</enum>
+                </property>
+                <property name="sizeHint" stdset="0">
+                 <size>
+                  <width>20</width>
+                  <height>20</height>
+                 </size>
+                </property>
+               </spacer>
+              </item>
+              <item>
+               <layout class="QHBoxLayout" name="horizontalLayout_5">
+                <property name="spacing">
+                 <number>18</number>
+                </property>
+                <property name="topMargin">
+                 <number>0</number>
+                </property>
+                <item>
+                 <layout class="QVBoxLayout" name="verticalLayout_3">
+                  <property name="spacing">
+                   <number>0</number>
+                  </property>
+                  <item>
+                   <widget class="QLabel" name="lab_ico_succees">
+                    <property name="sizePolicy">
+                     <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+                      <horstretch>0</horstretch>
+                      <verstretch>0</verstretch>
+                     </sizepolicy>
+                    </property>
+                    <property name="maximumSize">
+                     <size>
+                      <width>38</width>
+                      <height>38</height>
+                     </size>
+                    </property>
+                    <property name="styleSheet">
+                     <string notr="true">font: 18px &quot;微软雅黑&quot;;
+color:#666666;</string>
+                    </property>
+                    <property name="text">
+                     <string/>
+                    </property>
+                    <property name="pixmap">
+                     <pixmap>:/image/ic-icon-success.png</pixmap>
+                    </property>
+                    <property name="scaledContents">
+                     <bool>false</bool>
+                    </property>
+                    <property name="alignment">
+                     <set>Qt::AlignCenter</set>
+                    </property>
+                    <property name="wordWrap">
+                     <bool>false</bool>
+                    </property>
+                   </widget>
+                  </item>
+                  <item>
+                   <widget class="QLabel" name="lab_ico_erro">
+                    <property name="sizePolicy">
+                     <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+                      <horstretch>0</horstretch>
+                      <verstretch>0</verstretch>
+                     </sizepolicy>
+                    </property>
+                    <property name="maximumSize">
+                     <size>
+                      <width>38</width>
+                      <height>38</height>
+                     </size>
+                    </property>
+                    <property name="styleSheet">
+                     <string notr="true">font: 18px &quot;微软雅黑&quot;;
+color:#666666;</string>
+                    </property>
+                    <property name="text">
+                     <string/>
+                    </property>
+                    <property name="pixmap">
+                     <pixmap>:/image/ic-icon-error.png</pixmap>
+                    </property>
+                    <property name="scaledContents">
+                     <bool>false</bool>
+                    </property>
+                    <property name="alignment">
+                     <set>Qt::AlignCenter</set>
+                    </property>
+                    <property name="wordWrap">
+                     <bool>false</bool>
+                    </property>
+                   </widget>
+                  </item>
+                  <item>
+                   <widget class="QLabel" name="lab_ico_warnning">
+                    <property name="sizePolicy">
+                     <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+                      <horstretch>0</horstretch>
+                      <verstretch>0</verstretch>
+                     </sizepolicy>
+                    </property>
+                    <property name="maximumSize">
+                     <size>
+                      <width>38</width>
+                      <height>38</height>
+                     </size>
+                    </property>
+                    <property name="styleSheet">
+                     <string notr="true">font: 18px &quot;微软雅黑&quot;;
+color:#666666;</string>
+                    </property>
+                    <property name="text">
+                     <string/>
+                    </property>
+                    <property name="pixmap">
+                     <pixmap>:/image/ic-icon-danger.png</pixmap>
+                    </property>
+                    <property name="scaledContents">
+                     <bool>false</bool>
+                    </property>
+                    <property name="alignment">
+                     <set>Qt::AlignCenter</set>
+                    </property>
+                    <property name="wordWrap">
+                     <bool>false</bool>
+                    </property>
+                   </widget>
+                  </item>
+                  <item>
+                   <spacer name="verticalSpacer_2">
+                    <property name="orientation">
+                     <enum>Qt::Vertical</enum>
+                    </property>
+                    <property name="sizeHint" stdset="0">
+                     <size>
+                      <width>20</width>
+                      <height>40</height>
+                     </size>
+                    </property>
+                   </spacer>
+                  </item>
+                 </layout>
+                </item>
+                <item>
+                 <layout class="QVBoxLayout" name="verticalLayout_4">
+                  <property name="spacing">
+                   <number>0</number>
+                  </property>
+                  <property name="rightMargin">
+                   <number>0</number>
+                  </property>
+                  <item>
+                   <widget class="QLabel" name="lab_info">
+                    <property name="sizePolicy">
+                     <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+                      <horstretch>0</horstretch>
+                      <verstretch>0</verstretch>
+                     </sizepolicy>
+                    </property>
+                    <property name="minimumSize">
+                     <size>
+                      <width>0</width>
+                      <height>38</height>
+                     </size>
+                    </property>
+                    <property name="styleSheet">
+                     <string notr="true">font: 18px &quot;微软雅黑&quot;;
+color:#f8f8fa;</string>
+                    </property>
+                    <property name="text">
+                     <string>提示信息</string>
+                    </property>
+                    <property name="scaledContents">
+                     <bool>false</bool>
+                    </property>
+                    <property name="alignment">
+                     <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+                    </property>
+                    <property name="wordWrap">
+                     <bool>true</bool>
+                    </property>
+                   </widget>
+                  </item>
+                  <item>
+                   <spacer name="verticalSpacer">
+                    <property name="orientation">
+                     <enum>Qt::Vertical</enum>
+                    </property>
+                    <property name="sizeType">
+                     <enum>QSizePolicy::Preferred</enum>
+                    </property>
+                    <property name="sizeHint" stdset="0">
+                     <size>
+                      <width>20</width>
+                      <height>20</height>
+                     </size>
+                    </property>
+                   </spacer>
+                  </item>
+                 </layout>
+                </item>
+               </layout>
+              </item>
+              <item>
+               <layout class="QHBoxLayout" name="horizontalLayout_3">
+                <property name="spacing">
+                 <number>0</number>
+                </property>
+                <item>
+                 <spacer name="horizontalSpacer">
+                  <property name="orientation">
+                   <enum>Qt::Horizontal</enum>
+                  </property>
+                  <property name="sizeHint" stdset="0">
+                   <size>
+                    <width>40</width>
+                    <height>20</height>
+                   </size>
+                  </property>
+                 </spacer>
+                </item>
+                <item>
+                 <widget class="QPushButton" name="pushButton_accept">
+                  <property name="minimumSize">
+                   <size>
+                    <width>82</width>
+                    <height>40</height>
+                   </size>
+                  </property>
+                  <property name="cursor">
+                   <cursorShape>PointingHandCursor</cursorShape>
+                  </property>
+                  <property name="focusPolicy">
+                   <enum>Qt::StrongFocus</enum>
+                  </property>
+                  <property name="styleSheet">
+                   <string notr="true">QPushButton
+{ 
+background-color:#4b5cc4;
+color: #f8f8fa;
+font-size:14px;
+font-family:&quot;微软雅黑&quot;;
+
+border:1px solid #4b5cc4;
+border-radius: 0px; 
+
+} 
+QPushButton:hover{ 
+background-color:#8386bc;
+} 
+QPushButton:pressed{ 
+background-color:#8386bc;
+}
+
+
+
+
+
+
+</string>
+                  </property>
+                  <property name="text">
+                   <string>确定</string>
+                  </property>
+                  <property name="icon">
+                   <iconset>
+                    <normaloff>:/image/update.png</normaloff>:/image/update.png</iconset>
+                  </property>
+                  <property name="iconSize">
+                   <size>
+                    <width>20</width>
+                    <height>20</height>
+                   </size>
+                  </property>
+                 </widget>
+                </item>
+                <item>
+                 <spacer name="horizontalSpacer_4">
+                  <property name="orientation">
+                   <enum>Qt::Horizontal</enum>
+                  </property>
+                  <property name="sizeType">
+                   <enum>QSizePolicy::Fixed</enum>
+                  </property>
+                  <property name="sizeHint" stdset="0">
+                   <size>
+                    <width>16</width>
+                    <height>20</height>
+                   </size>
+                  </property>
+                 </spacer>
+                </item>
+                <item>
+                 <widget class="QPushButton" name="pushButto_reject">
+                  <property name="minimumSize">
+                   <size>
+                    <width>82</width>
+                    <height>40</height>
+                   </size>
+                  </property>
+                  <property name="cursor">
+                   <cursorShape>PointingHandCursor</cursorShape>
+                  </property>
+                  <property name="focusPolicy">
+                   <enum>Qt::StrongFocus</enum>
+                  </property>
+                  <property name="styleSheet">
+                   <string notr="true">QPushButton
+{ 
+background-color: #e7ecf1; 
+color: #333333;
+font-size:14px;
+font-family:&quot;微软雅黑&quot;;
+
+border:1px solid #c8cbd3;
+border-radius: 0px; 
+
+padding: 3px;
+
+} 
+QPushButton:hover{ 
+background-color: #c7ccd1; 
+} 
+QPushButton:pressed{ 
+background-color: #c7ccd1; 
+}
+
+
+
+</string>
+                  </property>
+                  <property name="text">
+                   <string>取消</string>
+                  </property>
+                  <property name="icon">
+                   <iconset>
+                    <normaloff>:/image/close.png</normaloff>:/image/close.png</iconset>
+                  </property>
+                  <property name="iconSize">
+                   <size>
+                    <width>20</width>
+                    <height>20</height>
+                   </size>
+                  </property>
+                 </widget>
+                </item>
+               </layout>
+              </item>
+             </layout>
+            </widget>
+           </item>
+          </layout>
+         </widget>
+        </item>
+        <item>
+         <spacer name="horizontalSpacer_2">
+          <property name="orientation">
+           <enum>Qt::Horizontal</enum>
+          </property>
+          <property name="sizeHint" stdset="0">
+           <size>
+            <width>331</width>
+            <height>20</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+       </layout>
+      </item>
+      <item>
+       <spacer name="verticalSpacer_5">
+        <property name="orientation">
+         <enum>Qt::Vertical</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>20</width>
+          <height>40</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+     </layout>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>btnMenu_Close</sender>
+   <signal>clicked()</signal>
+   <receiver>MyMessageBox_WithTitle</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>732</x>
+     <y>34</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>998</x>
+     <y>28</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>pushButton_accept</sender>
+   <signal>clicked()</signal>
+   <receiver>MyMessageBox_WithTitle</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>568</x>
+     <y>173</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>557</x>
+     <y>417</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>pushButto_reject</sender>
+   <signal>clicked()</signal>
+   <receiver>MyMessageBox_WithTitle</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>672</x>
+     <y>173</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>654</x>
+     <y>423</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>