Skip to content

Commit

Permalink
add video widget
Browse files Browse the repository at this point in the history
Change-Id: I65b8ed5ff0f69aebd76a5c73523aea5d41168265
  • Loading branch information
justforlxz committed Mar 27, 2018
1 parent 9e5398c commit d83b014
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 18 deletions.
12 changes: 3 additions & 9 deletions src/mainwindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ private Q_SLOTS:
void updateModule(const int index);
void animationHandle();

BaseModuleWidget *initVideoWidgt();
BaseModuleWidget *initDesktopModeModule();
BaseModuleWidget *initWMModeModule();
BaseModuleWidget *initIconModule();
Expand Down
2 changes: 1 addition & 1 deletion src/modules/normalmodule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ NormalModule::NormalModule(QWidget *parent)
icon->updateSmaillIcon();
wm->updateSmaillIcon();

video->hide();
video->show();
desktop->hide();
icon->hide();
wm->hide();
Expand Down
29 changes: 25 additions & 4 deletions src/modules/videowidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,39 @@
#include <QMediaPlayer>
#include <QPushButton>
#include <QTimer>
#include <QHBoxLayout>

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);
}
10 changes: 8 additions & 2 deletions src/modules/videowidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,24 @@
#ifndef VIDEOWIDGET_H
#define VIDEOWIDGET_H

#include <DVideoWidget>
#include "moduleinterface.h"

#include <QVideoWidget>
#include <QMediaPlayer>
#include <dimagebutton.h>

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;
};
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/bottomnavigation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d83b014

Please sign in to comment.