mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 18:32:53 +00:00
gwenview: drop video support
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
48c8cdac1e
commit
11326ec0ef
17 changed files with 12 additions and 641 deletions
|
@ -11,14 +11,17 @@
|
|||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="2" column="0">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Background color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<widget class="QSlider" name="kcfg_ViewBackgroundValue">
|
||||
|
@ -76,36 +79,6 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Videos:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="kcfg_ListVideos">
|
||||
<property name="text">
|
||||
<string>Show videos</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
|
@ -547,8 +547,7 @@ struct MainWindow::Private
|
|||
MimeTypeUtils::KIND_DIR
|
||||
| MimeTypeUtils::KIND_ARCHIVE
|
||||
| MimeTypeUtils::KIND_RASTER_IMAGE
|
||||
| MimeTypeUtils::KIND_SVG_IMAGE
|
||||
| MimeTypeUtils::KIND_VIDEO);
|
||||
| MimeTypeUtils::KIND_SVG_IMAGE);
|
||||
|
||||
connect(mDirModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
|
||||
q, SLOT(slotDirModelNewItems()));
|
||||
|
@ -1364,7 +1363,6 @@ void MainWindow::toggleSlideShow()
|
|||
switch (kind) {
|
||||
case MimeTypeUtils::KIND_SVG_IMAGE:
|
||||
case MimeTypeUtils::KIND_RASTER_IMAGE:
|
||||
case MimeTypeUtils::KIND_VIDEO:
|
||||
list << item.url();
|
||||
break;
|
||||
default:
|
||||
|
@ -1441,7 +1439,6 @@ void MainWindow::toggleMenuBar()
|
|||
void MainWindow::loadConfig()
|
||||
{
|
||||
d->mDirModel->setBlackListedExtensions(GwenviewConfig::blackListedExtensions());
|
||||
d->mDirModel->adjustKindFilter(MimeTypeUtils::KIND_VIDEO, GwenviewConfig::listVideos());
|
||||
|
||||
d->mFileOpenRecentAction->loadEntries(KConfigGroup(KGlobal::config(), "Recent Files"));
|
||||
d->mStartMainPage->loadConfig();
|
||||
|
|
|
@ -82,7 +82,6 @@ void DocumentDirFinder::slotItemsAdded(const KUrl& dir, const KFileItemList& lis
|
|||
|
||||
case MimeTypeUtils::KIND_RASTER_IMAGE:
|
||||
case MimeTypeUtils::KIND_SVG_IMAGE:
|
||||
case MimeTypeUtils::KIND_VIDEO:
|
||||
finish(dir, DocumentDirFound);
|
||||
return;
|
||||
|
||||
|
|
|
@ -104,10 +104,7 @@ struct ThumbnailPagePrivate : public Ui_ThumbnailPage
|
|||
mRecursiveDirModel = new RecursiveDirModel(q);
|
||||
|
||||
KindProxyModel* kindProxyModel = new KindProxyModel(q);
|
||||
kindProxyModel->setKindFilter(
|
||||
MimeTypeUtils::KIND_RASTER_IMAGE
|
||||
| MimeTypeUtils::KIND_SVG_IMAGE
|
||||
| MimeTypeUtils::KIND_VIDEO);
|
||||
kindProxyModel->setKindFilter(MimeTypeUtils::KIND_RASTER_IMAGE | MimeTypeUtils::KIND_SVG_IMAGE);
|
||||
kindProxyModel->setSourceModel(mRecursiveDirModel);
|
||||
|
||||
QSortFilterProxyModel *sortModel = new QSortFilterProxyModel(q);
|
||||
|
|
|
@ -27,7 +27,6 @@ set(gwenviewlib_SRCS
|
|||
document/loadingjob.cpp
|
||||
document/savejob.cpp
|
||||
document/svgdocumentloadedimpl.cpp
|
||||
document/videodocumentloadedimpl.cpp
|
||||
documentview/abstractdocumentviewadapter.cpp
|
||||
documentview/abstractimageview.cpp
|
||||
documentview/abstractrasterimageviewtool.cpp
|
||||
|
@ -40,7 +39,6 @@ set(gwenviewlib_SRCS
|
|||
documentview/rasterimageview.cpp
|
||||
documentview/rasterimageviewadapter.cpp
|
||||
documentview/svgviewadapter.cpp
|
||||
documentview/videoviewadapter.cpp
|
||||
about.cpp
|
||||
abstractimageoperation.cpp
|
||||
disabledactionshortcutmonitor.cpp
|
||||
|
|
|
@ -56,7 +56,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "orientation.h"
|
||||
#include "svgdocumentloadedimpl.h"
|
||||
#include "urlutils.h"
|
||||
#include "videodocumentloadedimpl.h"
|
||||
#include "gwenviewconfig.h"
|
||||
|
||||
namespace Gwenview
|
||||
|
@ -122,10 +121,6 @@ struct LoadingDocumentImplPrivate
|
|||
case MimeTypeUtils::KIND_SVG_IMAGE:
|
||||
return false;
|
||||
|
||||
case MimeTypeUtils::KIND_VIDEO:
|
||||
q->switchToImpl(new VideoDocumentLoadedImpl(q->document()));
|
||||
return true;
|
||||
|
||||
default:
|
||||
q->setDocumentErrorString(
|
||||
i18nc("@info", "Gwenview cannot display documents of type %1.", mimeType)
|
||||
|
@ -159,9 +154,6 @@ struct LoadingDocumentImplPrivate
|
|||
q->switchToImpl(new SvgDocumentLoadedImpl(q->document(), mData));
|
||||
break;
|
||||
|
||||
case MimeTypeUtils::KIND_VIDEO:
|
||||
break;
|
||||
|
||||
default:
|
||||
kWarning() << "We should not reach this point!";
|
||||
break;
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
// vim: set tabstop=4 shiftwidth=4 expandtab:
|
||||
/*
|
||||
Gwenview: an image viewer
|
||||
Copyright 2009 Aurélien Gâteau <agateau@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
// Self
|
||||
#include "moc_videodocumentloadedimpl.cpp"
|
||||
|
||||
// Qt
|
||||
|
||||
// KDE
|
||||
#include <KDebug>
|
||||
|
||||
// Local
|
||||
|
||||
namespace Gwenview
|
||||
{
|
||||
|
||||
struct VideoDocumentLoadedImplPrivate
|
||||
{
|
||||
};
|
||||
|
||||
VideoDocumentLoadedImpl::VideoDocumentLoadedImpl(Document* document)
|
||||
: AbstractDocumentImpl(document)
|
||||
, d(new VideoDocumentLoadedImplPrivate)
|
||||
{
|
||||
}
|
||||
|
||||
VideoDocumentLoadedImpl::~VideoDocumentLoadedImpl()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void VideoDocumentLoadedImpl::init()
|
||||
{
|
||||
emit loaded();
|
||||
}
|
||||
|
||||
Document::LoadingState VideoDocumentLoadedImpl::loadingState() const
|
||||
{
|
||||
return Document::Loaded;
|
||||
}
|
||||
|
||||
void VideoDocumentLoadedImpl::setImage(const QImage&)
|
||||
{
|
||||
kWarning() << "Should not be called";
|
||||
}
|
||||
|
||||
} // namespace
|
|
@ -1,54 +0,0 @@
|
|||
// vim: set tabstop=4 shiftwidth=4 expandtab:
|
||||
/*
|
||||
Gwenview: an image viewer
|
||||
Copyright 2009 Aurélien Gâteau <agateau@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
#ifndef VIDEODOCUMENTLOADEDIMPL_H
|
||||
#define VIDEODOCUMENTLOADEDIMPL_H
|
||||
|
||||
// Qt
|
||||
|
||||
// KDE
|
||||
|
||||
// Local
|
||||
#include <lib/document/abstractdocumentimpl.h>
|
||||
|
||||
namespace Gwenview
|
||||
{
|
||||
|
||||
struct VideoDocumentLoadedImplPrivate;
|
||||
class VideoDocumentLoadedImpl : public AbstractDocumentImpl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VideoDocumentLoadedImpl(Document*);
|
||||
~VideoDocumentLoadedImpl();
|
||||
|
||||
virtual void init();
|
||||
|
||||
virtual Document::LoadingState loadingState() const;
|
||||
|
||||
virtual void setImage(const QImage&);
|
||||
|
||||
private:
|
||||
VideoDocumentLoadedImplPrivate* const d;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif /* VIDEODOCUMENTLOADEDIMPL_H */
|
|
@ -52,7 +52,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
|
|||
#include <lib/documentview/rasterimageview.h>
|
||||
#include <lib/documentview/rasterimageviewadapter.h>
|
||||
#include <lib/documentview/svgviewadapter.h>
|
||||
#include <lib/documentview/videoviewadapter.h>
|
||||
#include <lib/hud/hudbutton.h>
|
||||
#include <lib/hud/hudwidget.h>
|
||||
#include <lib/graphicswidgetfloater.h>
|
||||
|
@ -359,11 +358,6 @@ void DocumentView::createAdapterForDocument()
|
|||
case MimeTypeUtils::KIND_SVG_IMAGE:
|
||||
adapter = new SvgViewAdapter;
|
||||
break;
|
||||
case MimeTypeUtils::KIND_VIDEO:
|
||||
adapter = new VideoViewAdapter;
|
||||
connect(adapter, SIGNAL(videoFinished()),
|
||||
SIGNAL(videoFinished()));
|
||||
break;
|
||||
case MimeTypeUtils::KIND_UNKNOWN:
|
||||
adapter = new MessageViewAdapter;
|
||||
static_cast<MessageViewAdapter*>(adapter)->setErrorMessage(i18n("Gwenview does not know how to display this kind of document"));
|
||||
|
|
|
@ -1,356 +0,0 @@
|
|||
// vim: set tabstop=4 shiftwidth=4 expandtab:
|
||||
/*
|
||||
Gwenview: an image viewer
|
||||
Copyright 2009 Aurélien Gâteau <agateau@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
// Self
|
||||
#include "moc_videoviewadapter.cpp"
|
||||
|
||||
// Qt
|
||||
#include <Phonon/AudioOutput>
|
||||
#include <Phonon/MediaObject>
|
||||
#include <Phonon/Path>
|
||||
#include <Phonon/VideoWidget>
|
||||
#include <QAction>
|
||||
#include <QGraphicsLinearLayout>
|
||||
#include <QGraphicsProxyWidget>
|
||||
#include <QHBoxLayout>
|
||||
#include <QtGui/qevent.h>
|
||||
#include <QtCore/qdatetime.h>
|
||||
|
||||
// KDE
|
||||
#include <KDebug>
|
||||
#include <KIcon>
|
||||
#include <KUrl>
|
||||
|
||||
// Local
|
||||
#include <document/documentfactory.h>
|
||||
#include <hud/hudbutton.h>
|
||||
#include <hud/hudslider.h>
|
||||
#include <hud/hudwidget.h>
|
||||
#include <graphicswidgetfloater.h>
|
||||
|
||||
namespace Gwenview
|
||||
{
|
||||
|
||||
struct VideoViewAdapterPrivate
|
||||
{
|
||||
VideoViewAdapter* q;
|
||||
Phonon::MediaObject* mMediaObject;
|
||||
Phonon::VideoWidget* mVideoWidget;
|
||||
Phonon::AudioOutput* mAudioOutput;
|
||||
HudWidget* mHud;
|
||||
GraphicsWidgetFloater* mFloater;
|
||||
|
||||
HudSlider* mSeekSlider;
|
||||
QTime mLastSeekSliderActionTime;
|
||||
|
||||
QAction* mPlayPauseAction;
|
||||
QAction* mMuteAction;
|
||||
|
||||
HudSlider* mVolumeSlider;
|
||||
QTime mLastVolumeSliderChangeTime;
|
||||
|
||||
Document::Ptr mDocument;
|
||||
|
||||
void setupActions()
|
||||
{
|
||||
mPlayPauseAction = new QAction(q);
|
||||
mPlayPauseAction->setShortcut(Qt::Key_P);
|
||||
QObject::connect(mPlayPauseAction, SIGNAL(triggered()),
|
||||
q, SLOT(slotPlayPauseClicked()));
|
||||
QObject::connect(mMediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
|
||||
q, SLOT(updatePlayUi()));
|
||||
|
||||
mMuteAction = new QAction(q);
|
||||
mMuteAction->setShortcut(Qt::Key_M);
|
||||
QObject::connect(mMuteAction, SIGNAL(triggered()),
|
||||
q, SLOT(slotMuteClicked()));
|
||||
QObject::connect(mAudioOutput, SIGNAL(mutedChanged(bool)),
|
||||
q, SLOT(updateMuteAction()));
|
||||
}
|
||||
|
||||
void setupHud(QGraphicsWidget* parent)
|
||||
{
|
||||
// Play/Pause
|
||||
HudButton* playPauseButton = new HudButton;
|
||||
playPauseButton->setDefaultAction(mPlayPauseAction);
|
||||
|
||||
// Seek
|
||||
mSeekSlider = new HudSlider;
|
||||
mSeekSlider->setPageStep(5000);
|
||||
mSeekSlider->setSingleStep(200);
|
||||
QObject::connect(mSeekSlider, SIGNAL(actionTriggered(int)),
|
||||
q, SLOT(slotSeekSliderActionTriggered(int)));
|
||||
QObject::connect(mMediaObject, SIGNAL(tick(qint64)),
|
||||
q, SLOT(slotTicked(qint64)));
|
||||
QObject::connect(mMediaObject, SIGNAL(totalTimeChanged(qint64)),
|
||||
q, SLOT(updatePlayUi()));
|
||||
QObject::connect(mMediaObject, SIGNAL(seekableChanged(bool)),
|
||||
q, SLOT(updatePlayUi()));
|
||||
|
||||
// Mute
|
||||
HudButton* muteButton = new HudButton;
|
||||
muteButton->setDefaultAction(mMuteAction);
|
||||
|
||||
// Volume
|
||||
mVolumeSlider = new HudSlider;
|
||||
mVolumeSlider->setMinimumWidth(100);
|
||||
mVolumeSlider->setRange(0, 100);
|
||||
mVolumeSlider->setPageStep(5);
|
||||
mVolumeSlider->setSingleStep(1);
|
||||
QObject::connect(mVolumeSlider, SIGNAL(valueChanged(int)),
|
||||
q, SLOT(slotVolumeSliderChanged(int)));
|
||||
QObject::connect(mAudioOutput, SIGNAL(volumeChanged(qreal)),
|
||||
q, SLOT(slotOutputVolumeChanged(qreal)));
|
||||
|
||||
// Layout
|
||||
QGraphicsWidget* hudContent = new QGraphicsWidget;
|
||||
QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(hudContent);
|
||||
layout->addItem(playPauseButton);
|
||||
layout->addItem(mSeekSlider);
|
||||
layout->setStretchFactor(mSeekSlider, 5);
|
||||
layout->addItem(muteButton);
|
||||
layout->addItem(mVolumeSlider);
|
||||
layout->setStretchFactor(mVolumeSlider, 1);
|
||||
|
||||
// Create hud
|
||||
mHud = new HudWidget(parent);
|
||||
mHud->init(hudContent, HudWidget::OptionNone);
|
||||
mHud->setZValue(1);
|
||||
|
||||
// Init floater
|
||||
mFloater = new GraphicsWidgetFloater(parent);
|
||||
mFloater->setChildWidget(mHud);
|
||||
mFloater->setAlignment(Qt::AlignJustify | Qt::AlignBottom);
|
||||
}
|
||||
|
||||
bool isPlaying() const
|
||||
{
|
||||
switch (mMediaObject->state()) {
|
||||
case Phonon::PlayingState:
|
||||
case Phonon::BufferingState:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void updateHudVisibility(int yPos)
|
||||
{
|
||||
const int floaterY = mVideoWidget->height() - mFloater->verticalMargin() - mHud->effectiveSizeHint(Qt::MinimumSize).height() * 3 / 2;
|
||||
if (yPos < floaterY) {
|
||||
mHud->fadeOut();
|
||||
} else {
|
||||
mHud->fadeIn();
|
||||
}
|
||||
}
|
||||
|
||||
void keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
if (event->modifiers() != Qt::NoModifier) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event->key()) {
|
||||
case Qt::Key_Left:
|
||||
mSeekSlider->triggerAction(QAbstractSlider::SliderSingleStepSub);
|
||||
break;
|
||||
case Qt::Key_Right:
|
||||
mSeekSlider->triggerAction(QAbstractSlider::SliderSingleStepAdd);
|
||||
break;
|
||||
case Qt::Key_Up:
|
||||
q->previousImageRequested();
|
||||
break;
|
||||
case Qt::Key_Down:
|
||||
q->nextImageRequested();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This is a workaround for a bug in QGraphicsProxyWidget: it does not forward
|
||||
* double-click events to the proxy-fied widget.
|
||||
*
|
||||
* QGraphicsProxyWidget::mouseDoubleClickEvent() correctly forwards the event
|
||||
* to its QWidget, but it is never called. This is because for it to be called,
|
||||
* the implementation of mousePressEvent() must call
|
||||
* QGraphicsItem::mousePressEvent() but it does not.
|
||||
*/
|
||||
class DoubleClickableProxyWidget : public QGraphicsProxyWidget
|
||||
{
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent* event)
|
||||
{
|
||||
QGraphicsWidget::mousePressEvent(event);
|
||||
}
|
||||
};
|
||||
|
||||
VideoViewAdapter::VideoViewAdapter()
|
||||
: d(new VideoViewAdapterPrivate)
|
||||
{
|
||||
d->q = this;
|
||||
d->mMediaObject = new Phonon::MediaObject(this);
|
||||
d->mMediaObject->setTickInterval(350);
|
||||
connect(d->mMediaObject, SIGNAL(finished()), SIGNAL(videoFinished()));
|
||||
|
||||
d->mVideoWidget = new Phonon::VideoWidget;
|
||||
d->mVideoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
d->mVideoWidget->setAttribute(Qt::WA_Hover);
|
||||
d->mVideoWidget->installEventFilter(this);
|
||||
|
||||
Phonon::createPath(d->mMediaObject, d->mVideoWidget);
|
||||
|
||||
d->mAudioOutput = new Phonon::AudioOutput(Phonon::VideoCategory, this);
|
||||
Phonon::createPath(d->mMediaObject, d->mAudioOutput);
|
||||
|
||||
QGraphicsProxyWidget* proxy = new DoubleClickableProxyWidget;
|
||||
proxy->setFlag(QGraphicsItem::ItemIsSelectable); // Needed for doubleclick to work
|
||||
proxy->setWidget(d->mVideoWidget);
|
||||
proxy->setAcceptHoverEvents(true);
|
||||
setWidget(proxy);
|
||||
|
||||
d->setupActions();
|
||||
d->setupHud(proxy);
|
||||
|
||||
updatePlayUi();
|
||||
updateMuteAction();
|
||||
}
|
||||
|
||||
VideoViewAdapter::~VideoViewAdapter()
|
||||
{
|
||||
// This prevents a memory leak that can occur after switching
|
||||
// to the next/previous video. For details see:
|
||||
// https://git.reviewboard.kde.org/r/108070/
|
||||
d->mMediaObject->stop();
|
||||
|
||||
delete d;
|
||||
}
|
||||
|
||||
void VideoViewAdapter::setDocument(Document::Ptr doc)
|
||||
{
|
||||
d->mHud->show();
|
||||
d->mDocument = doc;
|
||||
d->mMediaObject->setCurrentSource(d->mDocument->url());
|
||||
d->mMediaObject->play();
|
||||
// If we do not use a queued connection, the signal arrives too early,
|
||||
// preventing the listing of the dir content when Gwenview is started with
|
||||
// a video as an argument.
|
||||
QMetaObject::invokeMethod(this, "completed", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
Document::Ptr VideoViewAdapter::document() const
|
||||
{
|
||||
return d->mDocument;
|
||||
}
|
||||
|
||||
void VideoViewAdapter::slotPlayPauseClicked()
|
||||
{
|
||||
if (d->isPlaying()) {
|
||||
d->mMediaObject->pause();
|
||||
} else {
|
||||
d->mMediaObject->play();
|
||||
}
|
||||
}
|
||||
|
||||
void VideoViewAdapter::slotMuteClicked()
|
||||
{
|
||||
d->mAudioOutput->setMuted(!d->mAudioOutput->isMuted());
|
||||
}
|
||||
|
||||
bool VideoViewAdapter::eventFilter(QObject*, QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::MouseMove) {
|
||||
d->updateHudVisibility(static_cast<QMouseEvent*>(event)->y());
|
||||
} else if (event->type() == QEvent::KeyPress) {
|
||||
d->keyPressEvent(static_cast<QKeyEvent*>(event));
|
||||
} else if (event->type() == QEvent::MouseButtonDblClick) {
|
||||
if (static_cast<QMouseEvent*>(event)->modifiers() == Qt::NoModifier) {
|
||||
toggleFullScreenRequested();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void VideoViewAdapter::updatePlayUi()
|
||||
{
|
||||
if (d->isPlaying()) {
|
||||
d->mPlayPauseAction->setIcon(KIcon("media-playback-pause"));
|
||||
} else {
|
||||
d->mPlayPauseAction->setIcon(KIcon("media-playback-start"));
|
||||
}
|
||||
|
||||
d->mLastSeekSliderActionTime.restart();
|
||||
d->mSeekSlider->setRange(0, d->mMediaObject->totalTime());
|
||||
|
||||
switch (d->mMediaObject->state()) {
|
||||
case Phonon::PlayingState:
|
||||
case Phonon::BufferingState:
|
||||
case Phonon::PausedState:
|
||||
d->mSeekSlider->setEnabled(true);
|
||||
break;
|
||||
case Phonon::StoppedState:
|
||||
case Phonon::LoadingState:
|
||||
case Phonon::ErrorState:
|
||||
d->mSeekSlider->setEnabled(false);
|
||||
d->mSeekSlider->setValue(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void VideoViewAdapter::updateMuteAction()
|
||||
{
|
||||
d->mMuteAction->setIcon(
|
||||
KIcon(d->mAudioOutput->isMuted() ? "player-volume-muted" : "player-volume")
|
||||
);
|
||||
}
|
||||
|
||||
void VideoViewAdapter::slotVolumeSliderChanged(int value)
|
||||
{
|
||||
d->mLastVolumeSliderChangeTime.restart();
|
||||
d->mAudioOutput->setVolume(value / 100.);
|
||||
}
|
||||
|
||||
void VideoViewAdapter::slotOutputVolumeChanged(qreal value)
|
||||
{
|
||||
if (d->mLastVolumeSliderChangeTime.isValid() && d->mLastVolumeSliderChangeTime.elapsed() < 2000) {
|
||||
return;
|
||||
}
|
||||
d->mVolumeSlider->setValue(qRound(value * 100));
|
||||
}
|
||||
|
||||
void VideoViewAdapter::slotSeekSliderActionTriggered(int /*action*/)
|
||||
{
|
||||
d->mLastSeekSliderActionTime.restart();
|
||||
d->mMediaObject->seek(d->mSeekSlider->sliderPosition());
|
||||
}
|
||||
|
||||
void VideoViewAdapter::slotTicked(qint64 value)
|
||||
{
|
||||
if (d->mLastSeekSliderActionTime.isValid() && d->mLastSeekSliderActionTime.elapsed() < 2000) {
|
||||
return;
|
||||
}
|
||||
if (!d->mSeekSlider->isSliderDown()) {
|
||||
d->mSeekSlider->setValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
|
@ -1,76 +0,0 @@
|
|||
// vim: set tabstop=4 shiftwidth=4 expandtab:
|
||||
/*
|
||||
Gwenview: an image viewer
|
||||
Copyright 2009 Aurélien Gâteau <agateau@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
#ifndef VIDEOVIEWADAPTER_H
|
||||
#define VIDEOVIEWADAPTER_H
|
||||
|
||||
#include <lib/gwenviewlib_export.h>
|
||||
|
||||
// Qt
|
||||
|
||||
// KDE
|
||||
|
||||
// Local
|
||||
#include <lib/documentview/abstractdocumentviewadapter.h>
|
||||
|
||||
namespace Gwenview
|
||||
{
|
||||
|
||||
struct VideoViewAdapterPrivate;
|
||||
class GWENVIEWLIB_EXPORT VideoViewAdapter : public AbstractDocumentViewAdapter
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VideoViewAdapter();
|
||||
~VideoViewAdapter();
|
||||
|
||||
virtual MimeTypeUtils::Kind kind() const
|
||||
{
|
||||
return MimeTypeUtils::KIND_VIDEO;
|
||||
}
|
||||
|
||||
virtual Document::Ptr document() const;
|
||||
|
||||
virtual void setDocument(Document::Ptr);
|
||||
|
||||
Q_SIGNALS:
|
||||
void videoFinished();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject*, QEvent*);
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotPlayPauseClicked();
|
||||
void updatePlayUi();
|
||||
void slotMuteClicked();
|
||||
void updateMuteAction();
|
||||
void slotVolumeSliderChanged(int);
|
||||
void slotOutputVolumeChanged(qreal);
|
||||
void slotSeekSliderActionTriggered(int);
|
||||
void slotTicked(qint64);
|
||||
|
||||
private:
|
||||
friend struct VideoViewAdapterPrivate;
|
||||
VideoViewAdapterPrivate* const d;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif /* VIDEOVIEWADAPTER_H */
|
|
@ -166,10 +166,6 @@
|
|||
<default>1</default>
|
||||
<!-- 1 == PreviewItemDelegate::FileNameDetail -->
|
||||
</entry>
|
||||
|
||||
<entry name="ListVideos" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
</group>
|
||||
|
||||
<group name="Print">
|
||||
|
|
|
@ -158,9 +158,6 @@ Kind mimeTypeKind(const QString& mimeType)
|
|||
if (svgImageMimeTypes().contains(mimeType)) {
|
||||
return KIND_SVG_IMAGE;
|
||||
}
|
||||
if (mimeType.startsWith(QLatin1String("video/"))) {
|
||||
return KIND_VIDEO;
|
||||
}
|
||||
if (mimeType.startsWith(QLatin1String("inode/directory"))) {
|
||||
return KIND_DIR;
|
||||
}
|
||||
|
|
|
@ -52,8 +52,7 @@ enum Kind {
|
|||
KIND_ARCHIVE = 1 << 2,
|
||||
KIND_FILE = 1 << 3,
|
||||
KIND_RASTER_IMAGE = 1 << 4,
|
||||
KIND_SVG_IMAGE = 1 << 5,
|
||||
KIND_VIDEO = 1 << 6
|
||||
KIND_SVG_IMAGE = 1 << 5
|
||||
};
|
||||
Q_DECLARE_FLAGS(Kinds, Kind)
|
||||
|
||||
|
|
|
@ -162,16 +162,9 @@ struct SlideShowPrivate
|
|||
|
||||
void doStart()
|
||||
{
|
||||
if (MimeTypeUtils::urlKind(mCurrentUrl) == MimeTypeUtils::KIND_VIDEO) {
|
||||
LOG("mState = WaitForEndOfUrl");
|
||||
// Just in case
|
||||
mTimer->stop();
|
||||
mState = WaitForEndOfUrl;
|
||||
} else {
|
||||
LOG("mState = Started");
|
||||
mTimer->start();
|
||||
mState = Started;
|
||||
}
|
||||
LOG("mState = Started");
|
||||
mTimer->start();
|
||||
mState = Started;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -455,13 +455,6 @@ void ThumbnailProvider::checkThumbnail()
|
|||
size = QSize(width, height);
|
||||
} else {
|
||||
kWarning() << "Thumbnail for" << mOriginalUri << "does not contain correct image size information";
|
||||
// Don't try to determine the size of a video, it probably won't work and
|
||||
// will cause high I/O usage with big files (bug #307007).
|
||||
if (MimeTypeUtils::urlKind(mCurrentUrl) == MimeTypeUtils::KIND_VIDEO) {
|
||||
emitThumbnailLoaded(thumb, QSize());
|
||||
determineNextIcon();
|
||||
return;
|
||||
}
|
||||
KFileMetaInfo fmi(mCurrentUrl);
|
||||
if (fmi.isValid()) {
|
||||
KFileMetaInfoItem item = fmi.item("Dimensions");
|
||||
|
|
|
@ -582,14 +582,7 @@ void ThumbnailView::setBrokenThumbnail(const KFileItem& item)
|
|||
}
|
||||
Thumbnail& thumbnail = it.value();
|
||||
MimeTypeUtils::Kind kind = MimeTypeUtils::fileItemKind(item);
|
||||
if (kind == MimeTypeUtils::KIND_VIDEO) {
|
||||
// Special case for videos because our kde install may come without
|
||||
// support for video thumbnails so we show the mimetype icon instead of
|
||||
// a broken image icon
|
||||
ThumbnailGroup::Enum group = ThumbnailGroup::fromPixelSize(d->mThumbnailSize.height());
|
||||
QPixmap pix = item.pixmap(ThumbnailGroup::pixelSize(group));
|
||||
thumbnail.initAsIcon(pix);
|
||||
} else if (kind == MimeTypeUtils::KIND_DIR) {
|
||||
if (kind == MimeTypeUtils::KIND_DIR) {
|
||||
// Special case for folders because ThumbnailProvider does not return a
|
||||
// thumbnail if there is no images
|
||||
thumbnail.mWaitingForThumbnail = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue