From d83b0148b71e0efd259e6512298b0207a58fa7d0 Mon Sep 17 00:00:00 2001 From: haruyukilxz Date: Tue, 27 Mar 2018 13:26:46 +0800 Subject: [PATCH] add video widget Change-Id: I65b8ed5ff0f69aebd76a5c73523aea5d41168265 --- src/mainwindow.cc | 12 +++--------- src/mainwindow.h | 1 - src/modules/normalmodule.cc | 2 +- src/modules/videowidget.cc | 29 +++++++++++++++++++++++++---- src/modules/videowidget.h | 10 ++++++++-- src/widgets/bottomnavigation.cc | 2 +- 6 files changed, 38 insertions(+), 18 deletions(-) diff --git a/src/mainwindow.cc b/src/mainwindow.cc index 7a31d49..b4f669a 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -102,7 +102,7 @@ void MainWindow::initUI() m_nextBtn = new QPushButton(tr("next"), this); - m_current = initVideoWidgt(); + m_current = new VideoWidget(m_fakerWidget); m_current->setFixedSize(WINDOW_SIZE); m_current->show(); @@ -137,7 +137,8 @@ void MainWindow::updateModule(const int index) m_last = m_current; switch (index) { case 1: - m_current = initVideoWidgt(); + m_current = new VideoWidget(m_fakerWidget); + m_current->setFixedSize(WINDOW_SIZE); m_previousBtn->hide(); break; case 2: @@ -171,13 +172,6 @@ void MainWindow::animationHandle() } } -BaseModuleWidget *MainWindow::initVideoWidgt() -{ - BaseModuleWidget* w = new BaseModuleWidget(new VideoWidget, m_fakerWidget); - w->setFixedSize(WINDOW_SIZE); - return w; -} - BaseModuleWidget *MainWindow::initDesktopModeModule() { DesktopModeModule *module = new DesktopModeModule; diff --git a/src/mainwindow.h b/src/mainwindow.h index 12cc585..fd6d939 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -45,7 +45,6 @@ private Q_SLOTS: void updateModule(const int index); void animationHandle(); - BaseModuleWidget *initVideoWidgt(); BaseModuleWidget *initDesktopModeModule(); BaseModuleWidget *initWMModeModule(); BaseModuleWidget *initIconModule(); diff --git a/src/modules/normalmodule.cc b/src/modules/normalmodule.cc index 2745fc7..3bfb994 100644 --- a/src/modules/normalmodule.cc +++ b/src/modules/normalmodule.cc @@ -130,7 +130,7 @@ NormalModule::NormalModule(QWidget *parent) icon->updateSmaillIcon(); wm->updateSmaillIcon(); - video->hide(); + video->show(); desktop->hide(); icon->hide(); wm->hide(); diff --git a/src/modules/videowidget.cc b/src/modules/videowidget.cc index c85a4c6..c586c35 100644 --- a/src/modules/videowidget.cc +++ b/src/modules/videowidget.cc @@ -21,18 +21,39 @@ #include #include #include +#include VideoWidget::VideoWidget(QWidget *parent) - : DVideoWidget(parent) + : ModuleInterface(parent) + , m_video(new QVideoWidget(this)) , m_player(new QMediaPlayer(this)) , m_control(new DImageButton()) { - setSource(m_player); + QHBoxLayout *layout = new QHBoxLayout; + layout->setMargin(0); + layout->setSpacing(0); - setSourceVideoPixelRatio(devicePixelRatioF()); + layout->addWidget(m_video); - setGeometry(QRect(0, 0, 700, 450)); + setLayout(layout); + + m_player->setVideoOutput(m_video); + + m_player->setMedia(QUrl("file:///home/haruyukilxz/Videos/羽毛的光芒.mp4")); + m_video->setAspectRatioMode(Qt::KeepAspectRatioByExpanding); + + m_video->setGeometry(0, 0, 700, 450); m_player->play(); m_player->pause(); } + +void VideoWidget::updateBigIcon() +{ + m_video->setFixedSize(700, 450); +} + +void VideoWidget::updateSmaillIcon() +{ + m_video->setFixedSize(580, 450); +} diff --git a/src/modules/videowidget.h b/src/modules/videowidget.h index 442379c..c53ecf0 100644 --- a/src/modules/videowidget.h +++ b/src/modules/videowidget.h @@ -19,18 +19,24 @@ #ifndef VIDEOWIDGET_H #define VIDEOWIDGET_H -#include +#include "moduleinterface.h" + +#include #include #include DWIDGET_USE_NAMESPACE -class VideoWidget : public DVideoWidget { +class VideoWidget : public ModuleInterface { Q_OBJECT public: explicit VideoWidget(QWidget *parent = nullptr); + void updateBigIcon() Q_DECL_OVERRIDE; + void updateSmaillIcon() Q_DECL_OVERRIDE; + private: + QVideoWidget *m_video; QMediaPlayer* m_player; DImageButton* m_control; }; diff --git a/src/widgets/bottomnavigation.cc b/src/widgets/bottomnavigation.cc index ab1f955..1678c6c 100644 --- a/src/widgets/bottomnavigation.cc +++ b/src/widgets/bottomnavigation.cc @@ -51,7 +51,7 @@ BottomNavigation::BottomNavigation(QWidget *parent) layout->addWidget(facebook); layout->addWidget(offical); layout->addWidget(community); - layout->addWidget(facebook); + layout->addWidget(feedback); layout->addWidget(thank); setLayout(layout);