Changeset View
Changeset View
Standalone View
Standalone View
src/panels/information/phononwidget.cpp
Show First 20 Lines • Show All 157 Lines • ▼ Show 20 Line(s) | 154 | { | |||
---|---|---|---|---|---|
158 | } | 158 | } | ||
159 | } | 159 | } | ||
160 | 160 | | |||
161 | QUrl PhononWidget::url() const | 161 | QUrl PhononWidget::url() const | ||
162 | { | 162 | { | ||
163 | return m_url; | 163 | return m_url; | ||
164 | } | 164 | } | ||
165 | 165 | | |||
166 | bool PhononWidget::eventFilter(QObject *object, QEvent *event) { | ||||
167 | Q_UNUSED(object); | ||||
168 | if (event->type() == QEvent::MouseButtonPress){ | ||||
169 | QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event); | ||||
170 | if (mouseEvent->button() == Qt::LeftButton) { | ||||
171 | // toggle playback | ||||
172 | if (m_player && m_player->state() == QMediaPlayer::PlayingState) { | ||||
173 | m_player->pause(); | ||||
174 | } else { | ||||
175 | play(); | ||||
176 | } | ||||
177 | return true; | ||||
178 | } | ||||
179 | } | ||||
180 | return false; | ||||
181 | } | ||||
182 | | ||||
166 | void PhononWidget::setVideoSize(const QSize& size) | 183 | void PhononWidget::setVideoSize(const QSize& size) | ||
167 | { | 184 | { | ||
168 | if (m_videoSize != size) { | 185 | if (m_videoSize != size) { | ||
169 | m_videoSize = size; | 186 | m_videoSize = size; | ||
170 | applyVideoSize(); | 187 | applyVideoSize(); | ||
171 | } | 188 | } | ||
172 | } | 189 | } | ||
173 | 190 | | |||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | |||||
253 | { | 270 | { | ||
254 | if (!m_playlist) { | 271 | if (!m_playlist) { | ||
255 | m_playlist = new QMediaPlaylist; | 272 | m_playlist = new QMediaPlaylist; | ||
256 | 273 | | |||
257 | m_player = new QMediaPlayer; | 274 | m_player = new QMediaPlayer; | ||
258 | m_player->setPlaylist(m_playlist); | 275 | m_player->setPlaylist(m_playlist); | ||
259 | 276 | | |||
260 | m_videoWidget = new EmbeddedVideoPlayer(this); | 277 | m_videoWidget = new EmbeddedVideoPlayer(this); | ||
278 | m_videoWidget->installEventFilter(this); | ||||
261 | m_player->setVideoOutput(m_videoWidget); | 279 | m_player->setVideoOutput(m_videoWidget); | ||
262 | m_topLayout->insertWidget(0, m_videoWidget); | 280 | m_topLayout->insertWidget(0, m_videoWidget); | ||
263 | applyVideoSize(); | 281 | applyVideoSize(); | ||
264 | 282 | | |||
265 | connect(m_seekSlider, &QAbstractSlider::sliderMoved, | 283 | connect(m_seekSlider, &QAbstractSlider::sliderMoved, | ||
266 | this, &PhononWidget::setPosition); | 284 | this, &PhononWidget::setPosition); | ||
267 | 285 | | |||
268 | connect(m_player, &QMediaPlayer::stateChanged, this, &PhononWidget::stateChanged); | 286 | connect(m_player, &QMediaPlayer::stateChanged, this, &PhononWidget::stateChanged); | ||
▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines |