mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-21 01:11:21 +00:00
Sound-"Preview" as requested by tackat. Hope this isn't too hacky.
Replaced private KFileIVI *m_pActiveItem by KonqIconViewWidgetPrivate *d in KonqIconViewWidget. Keeps the instance size and adds a d pointer for free svn path=/trunk/kdebase/libkonq/; revision=96407
This commit is contained in:
parent
b158886001
commit
39cb0603bd
|
@ -16,7 +16,7 @@
|
|||
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
INCLUDES = $(all_includes)
|
||||
INCLUDES = $(all_includes) -I$(kde_includes)/arts
|
||||
SUBDIRS = pics favicons
|
||||
|
||||
lib_LTLIBRARIES = libkonq.la
|
||||
|
@ -56,6 +56,13 @@ include_HEADERS = konq_popupmenu.h knewmenu.h \
|
|||
konq_pixmapprovider.h \
|
||||
konq_faviconmgr.h
|
||||
|
||||
kde_module_LTLIBRARIES = libkonqsound.la
|
||||
libkonqsound_la_SOURCES = konq_sound.cpp
|
||||
libkonqsound_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
|
||||
libkonqsound_la_LIBADD = -lsoundserver_idl -lartskde
|
||||
|
||||
noinst_HEADERS = konq_sound.h
|
||||
|
||||
messages:
|
||||
$(XGETTEXT) *.cc *.h -o $(podir)/libkonq.pot
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <qdragobject.h>
|
||||
#include <qlist.h>
|
||||
#include <qregion.h>
|
||||
#include <qtimer.h>
|
||||
|
||||
#include <kapp.h>
|
||||
#include <kcursor.h>
|
||||
|
@ -45,16 +46,27 @@
|
|||
#include <kipc.h>
|
||||
#include <kiconeffect.h>
|
||||
#include <kurldrag.h>
|
||||
#include <klibloader.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
|
||||
struct KonqIconViewWidgetPrivate
|
||||
{
|
||||
KFileIVI *pActiveItem;
|
||||
bool bSoundPreviews;
|
||||
KFileIVI *pSoundItem;
|
||||
QObject *pSoundPlayer;
|
||||
QTimer *pSoundTimer;
|
||||
};
|
||||
|
||||
KonqIconViewWidget::KonqIconViewWidget( QWidget * parent, const char * name, WFlags f, bool kdesktop )
|
||||
: KIconView( parent, name, f ),
|
||||
m_rootItem( 0L ), m_size( 0 ) /* default is DesktopIcon size */,
|
||||
m_bDesktop( kdesktop ),
|
||||
m_bSetGridX( !kdesktop ) /* No line breaking on the desktop */
|
||||
{
|
||||
d = new KonqIconViewWidgetPrivate;
|
||||
connect( this, SIGNAL( dropped( QDropEvent *, const QValueList<QIconDragItem> & ) ),
|
||||
this, SLOT( slotDropped( QDropEvent*, const QValueList<QIconDragItem> & ) ) );
|
||||
|
||||
|
@ -81,7 +93,11 @@ KonqIconViewWidget::KonqIconViewWidget( QWidget * parent, const char * name, WFl
|
|||
setAutoArrange( true );
|
||||
setSorting( true, sortDirection() );
|
||||
m_bSortDirsFirst = true;
|
||||
m_pActiveItem = 0;
|
||||
d->pActiveItem = 0;
|
||||
d->bSoundPreviews = false;
|
||||
d->pSoundItem = 0;
|
||||
d->pSoundPlayer = 0;
|
||||
d->pSoundTimer = 0;
|
||||
m_pImagePreviewJob = 0L;
|
||||
m_bMousePressed = false;
|
||||
m_LineupMode = LineupBoth;
|
||||
|
@ -95,6 +111,8 @@ KonqIconViewWidget::~KonqIconViewWidget()
|
|||
{
|
||||
stopImagePreview();
|
||||
KonqUndoManager::decRef();
|
||||
delete d->pSoundPlayer;
|
||||
delete d;
|
||||
}
|
||||
|
||||
void KonqIconViewWidget::slotItemRenamed(QIconViewItem *item, const QString &name)
|
||||
|
@ -118,42 +136,86 @@ void KonqIconViewWidget::slotIconChanged( int group )
|
|||
void KonqIconViewWidget::slotOnItem( QIconViewItem *item )
|
||||
{
|
||||
// Reset icon of previous item
|
||||
if (m_pActiveItem != 0L)
|
||||
m_pActiveItem->setIcon( m_size, KIcon::DefaultState, false, true );
|
||||
if (d->pActiveItem != 0L)
|
||||
d->pActiveItem->setIcon( m_size, KIcon::DefaultState, false, true );
|
||||
|
||||
if ( !m_bMousePressed &&
|
||||
!static_cast<KFileIVI *>(item)->isThumbnail() &&
|
||||
(KGlobal::iconLoader()->iconEffect()->fingerprint(KIcon::Desktop, KIcon::DefaultState) !=
|
||||
KGlobal::iconLoader()->iconEffect()->fingerprint(KIcon::Desktop, KIcon::ActiveState) ) )
|
||||
{
|
||||
m_pActiveItem = static_cast<KFileIVI *>(item);
|
||||
m_pActiveItem->setIcon( m_size, KIcon::ActiveState, false, true );
|
||||
d->pActiveItem = static_cast<KFileIVI *>(item);
|
||||
d->pActiveItem->setIcon( m_size, KIcon::ActiveState, false, true );
|
||||
//kdDebug(1203) << "desktop;defaultstate=" << KGlobal::iconLoader()->iconEffect()->fingerprint(KIcon::Desktop, KIcon::DefaultState) << endl;
|
||||
//kdDebug(1203) << "desktop;activestate=" << KGlobal::iconLoader()->iconEffect()->fingerprint(KIcon::Desktop, KIcon::ActiveState) << endl;
|
||||
} else
|
||||
// Feature disabled during mouse clicking, e.g. rectangular selection
|
||||
// also disabled if the item is a thumbnail
|
||||
m_pActiveItem = 0L;
|
||||
d->pActiveItem = 0L;
|
||||
if (d->bSoundPreviews && static_cast<KFileIVI *>(item)->item()->mimetype().startsWith("audio/"))
|
||||
{
|
||||
d->pSoundItem = static_cast<KFileIVI *>(item);
|
||||
if (!d->pSoundTimer)
|
||||
{
|
||||
d->pSoundTimer = new QTimer(this);
|
||||
connect(d->pSoundTimer, SIGNAL(timeout()), SLOT(slotStartSoundPreview()));
|
||||
}
|
||||
if (d->pSoundTimer->isActive())
|
||||
d->pSoundTimer->stop();
|
||||
d->pSoundTimer->start(500, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d->pSoundPlayer)
|
||||
{
|
||||
delete d->pSoundPlayer;
|
||||
d->pSoundPlayer = 0;
|
||||
}
|
||||
d->pSoundItem = 0;
|
||||
if (d->pSoundTimer && d->pSoundTimer->isActive())
|
||||
d->pSoundTimer->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void KonqIconViewWidget::slotOnViewport()
|
||||
{
|
||||
if (m_pActiveItem == 0L)
|
||||
if (d->pActiveItem == 0L)
|
||||
return;
|
||||
m_pActiveItem->setIcon( m_size, KIcon::DefaultState, false, true );
|
||||
m_pActiveItem = 0L;
|
||||
d->pActiveItem->setIcon( m_size, KIcon::DefaultState, false, true );
|
||||
d->pActiveItem = 0L;
|
||||
if (d->pSoundPlayer)
|
||||
{
|
||||
delete d->pSoundPlayer;
|
||||
d->pSoundPlayer = 0;
|
||||
}
|
||||
d->pSoundItem = 0;
|
||||
if (d->pSoundTimer && d->pSoundTimer->isActive())
|
||||
d->pSoundTimer->stop();
|
||||
}
|
||||
|
||||
void KonqIconViewWidget::slotStartSoundPreview()
|
||||
{
|
||||
if (!d->pSoundItem)
|
||||
return;
|
||||
KLibFactory *factory = KLibLoader::self()->factory("libkonqsound");
|
||||
if (factory)
|
||||
{
|
||||
QStringList args;
|
||||
args << d->pSoundItem->item()->url().url();
|
||||
d->pSoundPlayer = factory->create(this, 0, "KPlayObject", args);
|
||||
}
|
||||
}
|
||||
|
||||
void KonqIconViewWidget::clear()
|
||||
{
|
||||
KIconView::clear();
|
||||
m_pActiveItem = 0L;
|
||||
d->pActiveItem = 0L;
|
||||
}
|
||||
|
||||
void KonqIconViewWidget::takeItem( QIconViewItem *item )
|
||||
{
|
||||
if ( m_pActiveItem == static_cast<KFileIVI *>(item) )
|
||||
m_pActiveItem = 0L;
|
||||
if ( d->pActiveItem == static_cast<KFileIVI *>(item) )
|
||||
d->pActiveItem = 0L;
|
||||
|
||||
if ( m_pImagePreviewJob )
|
||||
m_pImagePreviewJob->itemRemoved( static_cast<KFileIVI *>(item) );
|
||||
|
@ -165,8 +227,8 @@ void KonqIconViewWidget::setThumbnailPixmap( KFileIVI * item, const QPixmap & pi
|
|||
{
|
||||
if ( item )
|
||||
{
|
||||
if ( m_pActiveItem == item )
|
||||
m_pActiveItem = 0L;
|
||||
if ( d->pActiveItem == item )
|
||||
d->pActiveItem = 0L;
|
||||
item->setThumbnailPixmap( pixmap );
|
||||
if ( m_bSetGridX && item->width() > gridX() )
|
||||
{
|
||||
|
@ -286,6 +348,7 @@ void KonqIconViewWidget::startImagePreview( const QStringList &previewSettings,
|
|||
connect( m_pImagePreviewJob, SIGNAL( result( KIO::Job * ) ),
|
||||
this, SIGNAL( imagePreviewFinished() ) );
|
||||
m_pImagePreviewJob->startImagePreview();
|
||||
d->bSoundPreviews = previewSettings.contains( "audio/" );
|
||||
}
|
||||
|
||||
void KonqIconViewWidget::stopImagePreview()
|
||||
|
|
|
@ -203,6 +203,7 @@ protected slots:
|
|||
void slotIconChanged(int);
|
||||
void slotOnItem(QIconViewItem *);
|
||||
void slotOnViewport();
|
||||
void slotStartSoundPreview();
|
||||
|
||||
protected:
|
||||
virtual QDragObject *dragObject();
|
||||
|
@ -252,7 +253,7 @@ protected:
|
|||
bool m_bSetGridX;
|
||||
|
||||
private:
|
||||
KFileIVI * m_pActiveItem;
|
||||
struct KonqIconViewWidgetPrivate *d;
|
||||
|
||||
};
|
||||
|
||||
|
|
68
lib/konq/konq_sound.cc
Normal file
68
lib/konq/konq_sound.cc
Normal file
|
@ -0,0 +1,68 @@
|
|||
/* This file is part of the KDE Project
|
||||
Copyright (c) 2001 Malte Starostik <malte.starostik@t-online.de>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License version 2 as published by the Free Software Foundation.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
#include <kurl.h>
|
||||
#include <kplayobjectfactory.h>
|
||||
|
||||
#include "konq_sound.moc"
|
||||
|
||||
KonqSoundFactory::KonqSoundFactory(QObject *parent, const char *name)
|
||||
: KLibFactory(parent, name)
|
||||
{
|
||||
m_soundServer = Arts::Reference("global:Arts_SoundServerV2");
|
||||
m_factory = new KPlayObjectFactory(m_soundServer);
|
||||
}
|
||||
|
||||
KonqSoundFactory::~KonqSoundFactory()
|
||||
{
|
||||
delete m_factory;
|
||||
}
|
||||
|
||||
QObject *KonqSoundFactory::createObject(QObject *, const char *,
|
||||
const char *className, const QStringList &args)
|
||||
{
|
||||
if (qstrcmp(className, "KPlayObject") == 0 && args.count())
|
||||
{
|
||||
if (m_soundServer.isNull())
|
||||
return 0;
|
||||
KPlayObject *obj = m_factory->createPlayObject(args[0], true);
|
||||
if (obj)
|
||||
{
|
||||
if (obj->object().isNull())
|
||||
delete obj;
|
||||
else
|
||||
{
|
||||
obj->play();
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
KLibFactory *init_libkonqsound()
|
||||
{
|
||||
return new KonqSoundFactory();
|
||||
}
|
||||
};
|
||||
|
||||
// vim: ts=4 sw=4 noet
|
52
lib/konq/konq_sound.h
Normal file
52
lib/konq/konq_sound.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* This file is part of the KDE Project
|
||||
Copyright (c) 2001 Malte Starostik <malte.starostik@t-online.de>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License version 2 as published by the Free Software Foundation.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
#ifndef __konq_sound_h__
|
||||
#define __konq_sound_h__
|
||||
|
||||
#include <qobject.h>
|
||||
|
||||
#include <klibloader.h>
|
||||
#include <soundserver.h>
|
||||
|
||||
class KURL;
|
||||
class KPlayObject;
|
||||
class KPlayObjectFactory;
|
||||
|
||||
class KonqSoundFactory : public KLibFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KonqSoundFactory(QObject *parent = 0, const char *name = 0);
|
||||
virtual ~KonqSoundFactory();
|
||||
|
||||
protected:
|
||||
virtual QObject *createObject(QObject * = 0, const char * = 0,
|
||||
const char *className = "QObject", const QStringList &args = QStringList());
|
||||
|
||||
private:
|
||||
Arts::Dispatcher m_dispatcher;
|
||||
Arts::SoundServerV2 m_soundServer;
|
||||
KPlayObjectFactory *m_factory;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// vim: ts=4 sw=4 noet
|
Loading…
Reference in a new issue