Skip to content

Commit

Permalink
feat: add videowidget
Browse files Browse the repository at this point in the history
Change-Id: I282b5ded88c2089adb16310916067d2c742a1174
  • Loading branch information
justforlxz committed Feb 22, 2018
1 parent 9998b9e commit 48edc98
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ file(GLOB SRCS "src/*.h"

# Find the library
find_package(PkgConfig REQUIRED)
find_package(Dtk REQUIRED Widget)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Concurrent REQUIRED)
find_package(Dtk REQUIRED Widget)
find_package(Qt5Multimedia REQUIRED)
find_package(Qt5MultimediaWidgets REQUIRED)

# driver-manager
add_executable(${BIN_NAME} ${SRCS})
Expand All @@ -31,6 +33,8 @@ target_link_libraries(${BIN_NAME} PRIVATE
${Qt5Widgets_LIBRARIES}
${Qt5Concurrent_LIBRARIES}
${DFrameworkdbus_LIBRARIES}
${Qt5Multimedia_LIBRARIES}
${Qt5MultimediaWidgets_LIBRARIES}
)

if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
Expand Down
16 changes: 16 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,20 @@
MainWindow::MainWindow(QWidget *parent)
: DDialog(parent)
, m_index(1)
, m_nextBtn(new QPushButton(tr("next"), this))
, m_current(nullptr)
, m_last(nullptr)
, m_currentAni(new QPropertyAnimation(this))
, m_lastAni(new QPropertyAnimation(this))
{
setFixedSize(700, 450);

m_current = new VideoWidget(this);

m_current->show();

m_nextBtn->move(550, 405);
m_nextBtn->raise();
}

MainWindow::~MainWindow()
Expand Down Expand Up @@ -60,6 +68,8 @@ void MainWindow::initConnect()
{
connect(m_previousBtn, &DImageButton::clicked, this, &MainWindow::previous);
connect(m_nextBtn, &QPushButton::clicked, this, &MainWindow::next);
connect(m_currentAni, &QPropertyAnimation::finished, this, &MainWindow::animationHandle);
connect(m_lastAni, &QPropertyAnimation::finished, this, &MainWindow::animationHandle);
}

void MainWindow::bindAnimation()
Expand All @@ -81,3 +91,9 @@ void MainWindow::updateModule(const int index)

bindAnimation();
}

void MainWindow::animationHandle()
{
m_last->deleteLater();
m_nextBtn->raise();
}
1 change: 1 addition & 0 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ private Q_SLOTS:
void initConnect();
void bindAnimation();
void updateModule(const int index);
void animationHandle();

private:
int m_index;
Expand Down
13 changes: 13 additions & 0 deletions src/modules/videowidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,21 @@

#include "videowidget.h"

#include <QMediaPlayer>
#include <QPushButton>
#include <QTimer>

VideoWidget::VideoWidget(QWidget *parent)
: DVideoWidget(parent)
, m_player(new QMediaPlayer(this))
, m_control(new DImageButton())
{
setSource(m_player);

setSourceVideoPixelRatio(devicePixelRatioF());

setGeometry(QRect(0, 0, 700, 450));

m_player->play();
m_player->pause();
}
4 changes: 4 additions & 0 deletions src/modules/videowidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#define VIDEOWIDGET_H

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

DWIDGET_USE_NAMESPACE

Expand All @@ -29,6 +31,8 @@ class VideoWidget : public DVideoWidget {
explicit VideoWidget(QWidget *parent = nullptr);

private:
QMediaPlayer* m_player;
DImageButton* m_control;
};

#endif

0 comments on commit 48edc98

Please sign in to comment.