shownControls->usedControls
controlsVisible sets the whole controls widget visible/invisile svn path=/trunk/KDE/kdelibs/; revision=925247
This commit is contained in:
parent
1e4e0d86b4
commit
fd1b73ba56
@ -44,6 +44,7 @@ public:
|
|||||||
VideoWidgetPrivate(VideoWidget *video)
|
VideoWidgetPrivate(VideoWidget *video)
|
||||||
: q(video),
|
: q(video),
|
||||||
ticking(false),
|
ticking(false),
|
||||||
|
forceControlsVisible(false),
|
||||||
animId(0),
|
animId(0),
|
||||||
hideTimer(0),
|
hideTimer(0),
|
||||||
shownControls(VideoWidget::NoControls),
|
shownControls(VideoWidget::NoControls),
|
||||||
@ -74,6 +75,7 @@ public:
|
|||||||
void animateControlWidget(bool show);
|
void animateControlWidget(bool show);
|
||||||
void hideControlWidget();
|
void hideControlWidget();
|
||||||
void slidingCompleted(QGraphicsItem *item);
|
void slidingCompleted(QGraphicsItem *item);
|
||||||
|
bool spaceForControlsAvailable();
|
||||||
|
|
||||||
|
|
||||||
VideoWidget *q;
|
VideoWidget *q;
|
||||||
@ -83,6 +85,7 @@ public:
|
|||||||
Phonon::MediaObject *media;
|
Phonon::MediaObject *media;
|
||||||
|
|
||||||
bool ticking;
|
bool ticking;
|
||||||
|
bool forceControlsVisible;
|
||||||
|
|
||||||
//control widgets
|
//control widgets
|
||||||
int animId;
|
int animId;
|
||||||
@ -202,11 +205,22 @@ void VideoWidgetPrivate::slidingCompleted(QGraphicsItem *item)
|
|||||||
|
|
||||||
if (controlsWidget->pos().y() < 0) {
|
if (controlsWidget->pos().y() < 0) {
|
||||||
controlsWidget->hide();
|
controlsWidget->hide();
|
||||||
} else {
|
} else if (!forceControlsVisible) {
|
||||||
hideTimer->start(3000);
|
hideTimer->start(3000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VideoWidgetPrivate::spaceForControlsAvailable()
|
||||||
|
{
|
||||||
|
if (controlsWidget) {
|
||||||
|
QSize hint = controlsWidget->effectiveSizeHint(Qt::MinimumSize).toSize();
|
||||||
|
return (q->size().width() >= hint.width()) &&
|
||||||
|
(q->size().height() >= hint.height());
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VideoWidget::VideoWidget(QGraphicsWidget *parent)
|
VideoWidget::VideoWidget(QGraphicsWidget *parent)
|
||||||
@ -257,7 +271,7 @@ QString VideoWidget::url() const
|
|||||||
return d->media->currentSource().url().toString();
|
return d->media->currentSource().url().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoWidget::setShownControls(Controls controls)
|
void VideoWidget::setUsedControls(Controls controls)
|
||||||
{
|
{
|
||||||
d->shownControls = controls;
|
d->shownControls = controls;
|
||||||
|
|
||||||
@ -394,7 +408,7 @@ void VideoWidget::setShownControls(Controls controls)
|
|||||||
d->controlsWidget->hide();
|
d->controlsWidget->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoWidget::Controls VideoWidget::shownControls() const
|
VideoWidget::Controls VideoWidget::usedControls() const
|
||||||
{
|
{
|
||||||
return d->shownControls;
|
return d->shownControls;
|
||||||
}
|
}
|
||||||
@ -435,6 +449,19 @@ qint64 VideoWidget::remainingTime() const
|
|||||||
return d->media->remainingTime();
|
return d->media->remainingTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VideoWidget::setControlsVisible(bool visible)
|
||||||
|
{
|
||||||
|
if (d->controlsWidget) {
|
||||||
|
d->forceControlsVisible = visible;
|
||||||
|
d->animateControlWidget(visible);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VideoWidget::controlsVisible() const
|
||||||
|
{
|
||||||
|
return d->controlsWidget != 0 && d->controlsWidget->isVisible();
|
||||||
|
}
|
||||||
|
|
||||||
void VideoWidget::setStyleSheet(const QString &stylesheet)
|
void VideoWidget::setStyleSheet(const QString &stylesheet)
|
||||||
{
|
{
|
||||||
d->videoWidget->setStyleSheet(stylesheet);
|
d->videoWidget->setStyleSheet(stylesheet);
|
||||||
@ -457,6 +484,10 @@ void VideoWidget::resizeEvent(QGraphicsSceneResizeEvent *event)
|
|||||||
|
|
||||||
if (d->controlsWidget) {
|
if (d->controlsWidget) {
|
||||||
d->controlsWidget->resize(event->newSize().width(), d->controlsWidget->size().height());
|
d->controlsWidget->resize(event->newSize().width(), d->controlsWidget->size().height());
|
||||||
|
|
||||||
|
if (d->spaceForControlsAvailable()) {
|
||||||
|
d->animateControlWidget(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,7 +495,9 @@ void VideoWidget::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(event)
|
Q_UNUSED(event)
|
||||||
|
|
||||||
if (d->controlsWidget) {
|
if (d->controlsWidget &&
|
||||||
|
!d->forceControlsVisible &&
|
||||||
|
d->spaceForControlsAvailable()) {
|
||||||
d->animateControlWidget(true);
|
d->animateControlWidget(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -473,7 +506,7 @@ void VideoWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(event)
|
Q_UNUSED(event)
|
||||||
|
|
||||||
if (d->controlsWidget) {
|
if (d->controlsWidget && !d->forceControlsVisible) {
|
||||||
d->hideTimer->start(1000);
|
d->hideTimer->start(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -482,9 +515,15 @@ void VideoWidget::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(event)
|
Q_UNUSED(event)
|
||||||
|
|
||||||
|
if (d->forceControlsVisible) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
d->hideTimer->start(3000);
|
d->hideTimer->start(3000);
|
||||||
|
|
||||||
if (d->controlsWidget && !d->controlsWidget->isVisible()) {
|
if (d->controlsWidget &&
|
||||||
|
!d->controlsWidget->isVisible() &&
|
||||||
|
d->spaceForControlsAvailable()) {
|
||||||
d->animateControlWidget(true);
|
d->animateControlWidget(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,8 @@ class PLASMA_EXPORT VideoWidget : public QGraphicsProxyWidget
|
|||||||
Q_PROPERTY(QString currentTime READ currentTime)
|
Q_PROPERTY(QString currentTime READ currentTime)
|
||||||
Q_PROPERTY(QString totalTime READ totalTime)
|
Q_PROPERTY(QString totalTime READ totalTime)
|
||||||
Q_PROPERTY(QString remainingTime READ remainingTime)
|
Q_PROPERTY(QString remainingTime READ remainingTime)
|
||||||
Q_PROPERTY(Controls shownControls READ shownControls WRITE setShownControls)
|
Q_PROPERTY(Controls usedControls READ usedControls WRITE setUsedControls)
|
||||||
|
Q_PROPERTY(bool controlsVisible READ controlsVisible WRITE setControlsVisible)
|
||||||
Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
|
Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -112,18 +113,31 @@ public:
|
|||||||
qint64 remainingTime() const;
|
qint64 remainingTime() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set what control widgets to show
|
* Set what control widgets to use
|
||||||
*
|
*
|
||||||
* @arg controls OR combination of Controls flags
|
* @arg controls bitwise OR combination of Controls flags
|
||||||
* @see Controls
|
* @see Controls
|
||||||
*/
|
*/
|
||||||
void setShownControls(Controls controls);
|
void setUsedControls(Controls controls);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the video controls that are being show right now
|
* @return the video controls that are used and shown
|
||||||
* @see Controls
|
* @see Controls
|
||||||
*/
|
*/
|
||||||
Controls shownControls() const;
|
Controls usedControls() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show/hide the main controls widget, if any of them is used
|
||||||
|
*
|
||||||
|
* @arg visible if we want to show or hide the main controls
|
||||||
|
* @see setUsedControls()
|
||||||
|
*/
|
||||||
|
void setControlsVisible(bool visible);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if the controls widget is being shown right now
|
||||||
|
*/
|
||||||
|
bool controlsVisible() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the stylesheet used to control the visual display of this VideoWidget
|
* Sets the stylesheet used to control the visual display of this VideoWidget
|
||||||
|
Loading…
Reference in New Issue
Block a user