mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kutils: implement option to smooth the volume on load
would be great to do it on stop but that would delay e.g. Dolphin close event if media preview is active. anyway, don't think any other media player has such feature Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
b8fad75c78
commit
e008c17c9a
2 changed files with 22 additions and 1 deletions
|
@ -20,6 +20,7 @@
|
|||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QTimer>
|
||||
#include <QTimeLine>
|
||||
|
||||
#include "kdebug.h"
|
||||
#include "klocale.h"
|
||||
|
@ -37,9 +38,11 @@ public:
|
|||
bool m_dragdrop;
|
||||
bool m_fullscreen;
|
||||
bool m_hiddencontrols;
|
||||
bool m_smoothvolume;
|
||||
QWidget *m_parent;
|
||||
QMainWindow *m_parenthack;
|
||||
QSize m_parentsizehack;
|
||||
QTimeLine m_volumeline;
|
||||
int m_timerid;
|
||||
QString m_path;
|
||||
bool m_replay;
|
||||
|
@ -56,6 +59,7 @@ KMediaWidget::KMediaWidget(QWidget *parent, KMediaOptions options)
|
|||
d->m_dragdrop = (options & DragDrop) != options;
|
||||
d->m_fullscreen = (options & FullscreenVideo) != options;
|
||||
d->m_hiddencontrols = (options & HiddenControls) != options;
|
||||
d->m_smoothvolume = (options & SmoothVolume) != options;
|
||||
d->m_parent = parent;
|
||||
|
||||
d->m_ui->w_play->setIcon(KIcon("media-playback-start"));
|
||||
|
@ -65,6 +69,8 @@ KMediaWidget::KMediaWidget(QWidget *parent, KMediaOptions options)
|
|||
d->m_ui->w_volume->setValue(d->m_player->volume());
|
||||
d->m_ui->w_fullscreen->setIcon(KIcon("view-fullscreen"));
|
||||
|
||||
connect(&d->m_volumeline, SIGNAL(frameChanged(int)), this, SLOT(setVolume(int)));
|
||||
|
||||
connect(d->m_ui->w_play, SIGNAL(clicked()), this, SLOT(setPlay()));
|
||||
// connect(d->m_ui->w_position, SIGNAL(sliderMoved(int)), this, SLOT(setPosition(int)));
|
||||
connect(d->m_ui->w_position, SIGNAL(sliderReleased()), this, SLOT(_setPosition()));
|
||||
|
@ -98,6 +104,9 @@ KMediaWidget::~KMediaWidget()
|
|||
if (d->m_timerid >= 0) {
|
||||
killTimer(d->m_timerid);
|
||||
}
|
||||
while (d->m_volumeline.state() == QTimeLine::Running) {
|
||||
QCoreApplication::processEvents();
|
||||
}
|
||||
d->m_player->stop();
|
||||
d->m_player->deleteLater();
|
||||
delete d->m_ui;
|
||||
|
@ -113,6 +122,16 @@ void KMediaWidget::open(const QString &path)
|
|||
d->m_ui->w_play->setEnabled(true);
|
||||
d->m_ui->w_position->setEnabled(true);
|
||||
|
||||
while (d->m_volumeline.state() == QTimeLine::Running) {
|
||||
QCoreApplication::processEvents();
|
||||
}
|
||||
if (d->m_smoothvolume) {
|
||||
d->m_volumeline.setFrameRange(0, d->m_player->volume());
|
||||
d->m_volumeline.setDuration(3000);
|
||||
d->m_volumeline.setDirection(QTimeLine::Forward);
|
||||
d->m_player->setVolume(0);
|
||||
d->m_volumeline.start();
|
||||
}
|
||||
d->m_player->load(path);
|
||||
|
||||
d->m_ui->w_position->setEnabled(d->m_player->isSeekable());
|
||||
|
|
|
@ -67,8 +67,10 @@ public:
|
|||
FullscreenVideo = 0x2,
|
||||
//! @brief After a certain amount of time the controls will hide and show again when needed
|
||||
HiddenControls = 0x4,
|
||||
//! @brief Whenever path is loaded the volume is slowly increased
|
||||
SmoothVolume = 0x8,
|
||||
//! @brief All available options
|
||||
AllOptions = DragDrop | FullscreenVideo | HiddenControls,
|
||||
AllOptions = DragDrop | FullscreenVideo | HiddenControls | SmoothVolume,
|
||||
//! @brief Default options
|
||||
DefaultOptions = NoOptions
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue