[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [Amarok] 58cdbf7: Move coverbling to playground
From: Nikolaj Hald Nielsen <nhnFreespirit () gmail ! com>
Date: 2010-05-22 19:18:11
Message-ID: 201005221918.o4MJIBpd007210 () kore ! kollide ! net
[Download RAW message or body]
A playground/src/context/applets/coverbling/pictureflow.h [License: UNKNOWN]
A playground/src/context/applets/coverbling/pictureflow.cpp [License: UNKNOWN]
A playground/src/context/applets/coverbling/coverblingSettings.ui [License: \
Trivialfile.]
A playground/src/context/applets/coverbling/amarok-context-applet-coverbling.desktop \
[License: Trivialfile.]
A playground/src/context/applets/coverbling/PhotoBrowser.h [License: GPL(v2)]
A playground/src/context/applets/coverbling/PhotoBrowser.cpp [License: GPL(v2)]
A playground/src/context/applets/coverbling/ImageLoader.h [License: GPL(v2)]
A playground/src/context/applets/coverbling/ImageLoader.cpp [License: GPL(v2)]
A playground/src/context/applets/coverbling/CoverBlingApplet.h [License: UNKNOWN]
A playground/src/context/applets/coverbling/CoverBlingApplet.cpp [License: \
UNKNOWN]
A playground/src/context/applets/coverbling/CMakeLists.txt [License: UNKNOWN]
commit 58cdbf7574ab831e69abfbe2bb40d9bb5cf07df2
Author: Nikolaj Hald Nielsen <nhnFreespirit@gmail.com>
Date: Sat May 22 21:20:25 2010 +0200
Move coverbling to playground
diff --git a/playground/src/context/applets/CMakeLists.txt \
b/playground/src/context/applets/CMakeLists.txt index f646aa3..44760ea 100644
--- a/playground/src/context/applets/CMakeLists.txt
+++ b/playground/src/context/applets/CMakeLists.txt
@@ -1,2 +1,2 @@
#add_subdirectory( cloud )
-
+add_subdirectory( coverbling )
diff --git a/playground/src/context/applets/coverbling/CMakeLists.txt \
b/playground/src/context/applets/coverbling/CMakeLists.txt new file mode 100644
index 0000000..688d408
--- /dev/null
+++ b/playground/src/context/applets/coverbling/CMakeLists.txt
@@ -0,0 +1,33 @@
+project(context-coverbling)
+
+set(coverbling_SRCS
+pictureflow.cpp
+CoverBlingApplet.cpp
+ImageLoader.cpp
+PhotoBrowser.cpp
+)
+
+include_directories( ../../..
+ ../..
+ ${KDE4_INCLUDE_DIR}/amarok ) # this way we don't need to prefix \
it with amarok/ (and it compiles this way too :) +
+kde4_add_ui_files( coverbling_SRCS coverblingSettings.ui )
+kde4_add_plugin(amarok_context_applet_coverbling ${coverbling_SRCS})
+
+
+target_link_libraries(amarok_context_applet_coverbling
+ amarokcore
+ amaroklib
+ ${KDE4_PLASMA_LIBS}
+ ${KDE4_KIO_LIBS}
+)
+
+install(TARGETS amarok_context_applet_coverbling DESTINATION ${PLUGIN_INSTALL_DIR})
+install(FILES amarok-context-applet-coverbling.desktop DESTINATION \
${SERVICES_INSTALL_DIR}) +install(FILES blingfastback.png DESTINATION \
${DATA_INSTALL_DIR}/amarok/images/ ) +install(FILES blingtofirst.png DESTINATION \
${DATA_INSTALL_DIR}/amarok/images/ ) +install(FILES blingfastforward.png DESTINATION \
${DATA_INSTALL_DIR}/amarok/images/ ) +install(FILES blingtolast.png DESTINATION \
${DATA_INSTALL_DIR}/amarok/images/ ) +install(FILES blingdefaultcover.png DESTINATION \
${DATA_INSTALL_DIR}/amarok/images/ ) +install(FILES blingfullscreen.png DESTINATION \
${DATA_INSTALL_DIR}/amarok/images/ ) +install(FILES blingjumptoplaying.png \
DESTINATION ${DATA_INSTALL_DIR}/amarok/images/ )
diff --git a/playground/src/context/applets/coverbling/CoverBlingApplet.cpp \
b/playground/src/context/applets/coverbling/CoverBlingApplet.cpp new file mode 100644
index 0000000..6ba7ed8
--- /dev/null
+++ b/playground/src/context/applets/coverbling/CoverBlingApplet.cpp
@@ -0,0 +1,396 @@
+/****************************************************************************************
+ * Copyright (c) 2010 Emmanuel Wagner <menu.wagner@sfr.fr> \
* + * Copyright (c) 2010 Mark Kretschmann <kretschmann@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, see <http://www.gnu.org/licenses/>. \
* + ****************************************************************************************/
+
+#include "CoverBlingApplet.h"
+
+// Amarok
+#include "core/support/Amarok.h"
+#include "EngineController.h"
+#include "core/support/Debug.h"
+#include "context/ContextView.h"
+#include "context/widgets/TextScrollingWidget.h"
+#include "core/collections/Collection.h"
+#include "core-impl/collections/support/CollectionManager.h"
+#include "context/widgets/RatingWidget.h"
+#include "playlist/PlaylistModelStack.h"
+
+// KDE
+#include <KAction>
+#include <KColorScheme>
+#include <KConfigDialog>
+#include <KGlobalSettings>
+#include <Plasma/BusyWidget>
+#include <Plasma/IconWidget>
+#include <Plasma/Theme>
+
+// Qt
+#include <QGraphicsLinearLayout>
+#include <QGraphicsProxyWidget>
+#include <QGraphicsSimpleTextItem>
+#include <QGraphicsWidget>
+#include <QLabel>
+#include <QPixmap>
+#include <QGraphicsPixmapItem>
+#include <KStandardDirs>
+#include <QDesktopWidget>
+
+#define DEBUG_PREFIX "CoverBlingApplet"
+
+
+CoverBlingApplet::CoverBlingApplet( QObject* parent, const QVariantList& args )
+ : Context::Applet( parent, args )
+ , Engine::EngineObserver( The::engineController() )
+{
+ DEBUG_BLOCK
+
+ setHasConfigurationInterface( true );
+}
+
+void
+CoverBlingApplet::init()
+{
+ setBackgroundHints( Plasma::Applet::NoBackground );
+ resize( -1, 400 );
+ m_fullsize = false;
+
+ KConfigGroup config = Amarok::config( "CoverBling Applet" );
+ m_coversize = config.readEntry( "CoverSize", 200 );
+ int reflectioneffect = config.readEntry( "ReflectionEffect", 1 );
+ if ( reflectioneffect == 0 )
+ m_reflectionEffect = PictureFlow::NoReflection;
+ else if ( reflectioneffect == 1 )
+ m_reflectionEffect = PictureFlow::PlainReflection;
+ else if ( reflectioneffect == 2 )
+ m_reflectionEffect = PictureFlow::BlurredReflection;
+
+ m_autojump = config.readEntry( "AutoJump", false );
+ m_animatejump = config.readEntry( "AnimateJump", true );
+ m_layout = new QGraphicsProxyWidget( this );
+ m_openGL = false;
+ //bool setting_opengl = config.readEntry( "OpenGL", false );
+ //if (QGLFormat::hasOpenGL() && setting_opengl) m_openGL = true;
+
+ m_pictureflow = new PhotoBrowser(0,m_openGL);
+ m_layout->setWidget( m_pictureflow );
+
+ m_pictureflow->setRenderHints( QPainter::HighQualityAntialiasing | \
QPainter::SmoothPixmapTransform ); +
+ m_pictureflow->show();
+
+ Collections::Collection *coll = \
CollectionManager::instance()->primaryCollection(); + Collections::QueryMaker *qm \
= coll->queryMaker(); + qm->setAutoDelete( true );
+ qm->setQueryType( Collections::QueryMaker::Album );
+ qm->orderBy( Meta::valArtist );
+
+ connect( qm, SIGNAL( newResultReady( QString, Meta::AlbumList ) ),
+ this, SLOT( slotAlbumQueryResult( QString, Meta::AlbumList ) ) );
+ qm->run();
+
+ m_label = new QGraphicsSimpleTextItem( this );
+ m_label->setBrush( QBrush( Qt::white ) );
+ QFont labelFont;
+ QFont bigFont( labelFont );
+ bigFont.setPointSize( bigFont.pointSize() + 4 );
+ m_label->setFont( labelFont );
+
+ m_ratingWidget = new RatingWidget( this );
+ m_ratingWidget->setRating( 0 );
+ m_ratingWidget->setEnabled( false );
+
+ // Construct icon widgets
+ m_blingtofirst = new Plasma::IconWidget( this );
+ m_blingtofirst->setIcon( KStandardDirs::locate( "data", \
"amarok/images/blingtofirst.png" ) ); + m_blingtofirst->setMaximumSize( 16.0, 16.0 \
); + m_blingtofirst->setToolTip( i18n( "Jump to First" ) );
+
+ m_blingtolast = new Plasma::IconWidget( this );
+ m_blingtolast->setIcon( KStandardDirs::locate( "data", \
"amarok/images/blingtolast.png" ) ); + m_blingtolast->setMaximumSize( 16.0, 16.0 \
); + m_blingtolast->setToolTip( i18n( "Jump to Last" ) );
+
+ m_blingfastback = new Plasma::IconWidget( this );
+ m_blingfastback->setIcon( KStandardDirs::locate( "data", \
"amarok/images/blingfastback.png" ) ); + m_blingfastback->setMaximumSize( 16.0, \
16.0 ); + m_blingfastback->setToolTip( i18n( "Fast Backward" ) );
+
+ m_blingfastforward = new Plasma::IconWidget( this );
+ m_blingfastforward->setIcon( KStandardDirs::locate( "data", \
"amarok/images/blingfastforward.png" ) ); + m_blingfastforward->setMaximumSize( \
16.0, 16.0 ); + m_blingfastforward->setToolTip( i18n( "Fast Forward" ) );
+
+ m_fullscreen = new Plasma::IconWidget( this );
+ m_fullscreen->setIcon( KStandardDirs::locate( "data", \
"amarok/images/blingfullscreen.png" ) ); + m_fullscreen->setMaximumSize( 16.0, \
16.0 ); + m_fullscreen->setToolTip( i18n( "Maximize/Minimize" ) );
+
+ m_jumptoplaying = new Plasma::IconWidget( this );
+ m_jumptoplaying->setIcon( KStandardDirs::locate( "data", \
"amarok/images/blingjumptoplaying.png" ) ); + m_jumptoplaying->setMaximumSize( \
16.0, 16.0 ); + m_jumptoplaying->setToolTip( i18n( "Jump to Current" ) );
+
+ constraintsEvent();
+}
+
+CoverBlingApplet::~CoverBlingApplet()
+{
+ delete m_ratingWidget;
+ delete m_label;
+ delete m_layout;
+}
+
+void CoverBlingApplet::slotAlbumQueryResult( QString collectionId, Meta::AlbumList \
albums ) //SLOT +{
+ DEBUG_BLOCK
+ Q_UNUSED( collectionId );
+
+ m_pictureflow->fillAlbums( albums );
+
+ connect( m_pictureflow, SIGNAL( centerIndexChanged( int ) ), this, SLOT( \
slideChanged( int ) ) ); + connect( m_pictureflow, SIGNAL( doubleClicked( int ) ), \
this, SLOT( appendAlbum( int ) ) ); + connect( m_blingtofirst, SIGNAL( clicked() \
), this, SLOT( skipToFirst() ) ); + connect( m_blingtolast, SIGNAL( clicked() ), \
this, SLOT( skipToLast() ) ); + connect( m_blingfastback, SIGNAL( clicked() ), \
m_pictureflow, SLOT( fastBackward() ) ); + connect( m_blingfastforward, SIGNAL( \
clicked() ), m_pictureflow, SLOT( fastForward() ) ); + connect( m_fullscreen, \
SIGNAL( clicked() ), this, SLOT( toggleFullscreen() ) ); + connect( \
m_jumptoplaying, SIGNAL( clicked() ), this, SLOT( jumpToPlaying() ) ); +}
+
+void CoverBlingApplet::slideChanged( int islideindex )
+{
+ Meta::AlbumPtr album = m_pictureflow->album( islideindex );
+ if ( album )
+ {
+ Meta::ArtistPtr artist = album->albumArtist();
+ QString label = album->prettyName();
+ if ( artist ) label += " - " + artist->prettyName();
+ m_label->setText( label );
+
+ //center the label
+ m_label->setPos( ( size().width() - m_label->boundingRect().width() ) / 2, \
m_label->y() ); +
+ m_label->show();
+ int nbtracks = 0;
+ int rating = 0;
+
+ foreach( Meta::TrackPtr track, album->tracks() )
+ {
+ nbtracks++;
+ if ( track )
+ rating += track->rating();
+ }
+
+ if ( nbtracks )
+ rating = rating / nbtracks;
+
+ m_ratingWidget->setRating( rating );
+ }
+}
+
+void CoverBlingApplet::appendAlbum( int islideindex )
+{
+ Meta::AlbumPtr album = m_pictureflow->album( islideindex );
+ if ( album )
+ {
+ The::playlistController()->insertOptioned( album->tracks(), \
Playlist::AppendAndPlay ); + }
+
+}
+void CoverBlingApplet::constraintsEvent( Plasma::Constraints constraints )
+{
+ Q_UNUSED( constraints )
+
+ prepareGeometryChange();
+ const int vertical_size = boundingRect().height();
+ const int horizontal_size = boundingRect().width();
+ QSize slideSize( vertical_size / 2, vertical_size / 2 );
+
+ if ( !m_fullsize )
+ {
+ slideSize.setWidth( m_coversize );
+ slideSize.setHeight( m_coversize );
+ }
+
+ m_pictureflow->setSlideSize( slideSize );
+ m_pictureflow->setReflectionEffect( m_reflectionEffect );
+ m_pictureflow->setAnimationTime( 10 );
+ m_ratingWidget->setSpacing( 2 );
+ m_ratingWidget->setPos( horizontal_size / 2 - 40, vertical_size - 30 );
+ m_label ->setPos( horizontal_size / 2 - 40, vertical_size - 50 );
+
+ m_blingtofirst->setPos( 20, vertical_size - 30 );
+ m_blingtolast->setPos( horizontal_size - 30, vertical_size - 30 );
+ m_blingfastback->setPos( 50, vertical_size - 30 );
+ m_blingfastforward->setPos( horizontal_size - 60, vertical_size - 30 );
+ m_fullscreen->setPos( horizontal_size - 30, 30 );
+ m_jumptoplaying->setPos( horizontal_size - 60, 30 );
+
+ m_pictureflow->resize( horizontal_size, vertical_size );
+
+ m_label->setPos( ( size().width() - m_label->boundingRect().width() ) / 2, \
m_label->y() ); +}
+
+void
+CoverBlingApplet::paintInterface( QPainter *p, const QStyleOptionGraphicsItem \
*option, const QRect &contentsRect ) +{
+ Q_UNUSED( p );
+ Q_UNUSED( option );
+ Q_UNUSED( contentsRect );
+
+ p->setRenderHint( QPainter::Antialiasing );
+ // tint the whole applet
+ addGradientToAppletBackground( p );
+}
+
+void CoverBlingApplet::toggleFullscreen()
+{
+ if ( m_fullsize )
+ {
+ resize( -1, 400 );
+ }
+ else
+ {
+ //QDesktopWidget* desktop = QApplication::desktop();
+ //if (desktop)
+ {
+ // QRect rect = desktop->screenGeometry();
+ // resize(rect.width(),rect.height());
+ resize( -1, -1 );
+ }
+ }
+ updateConstraints();
+ //constraintsEvent();
+ m_fullsize = !m_fullsize;
+}
+
+void CoverBlingApplet::createConfigurationInterface( KConfigDialog *parent )
+{
+ KConfigGroup configuration = config();
+ QWidget * const settings = new QWidget;
+ ui_Settings.setupUi( settings );
+
+ if ( m_reflectionEffect == PictureFlow::NoReflection )
+ ui_Settings.reflectionEffectCombo->setCurrentIndex( 0 );
+ else if ( m_reflectionEffect == PictureFlow::PlainReflection )
+ ui_Settings.reflectionEffectCombo->setCurrentIndex( 1 );
+ else if ( m_reflectionEffect == PictureFlow::BlurredReflection )
+ ui_Settings.reflectionEffectCombo->setCurrentIndex( 2 );
+ if ( m_coversize )
+ ui_Settings.coversizeSpin->setValue( m_coversize );
+ ui_Settings.autoJumpChk->setChecked( m_autojump );
+ ui_Settings.animJumpChk->setChecked( m_animatejump );
+ //if (m_openGL) ui_Settings.renderingCombo->setCurrentIndex(1);
+ //else ui_Settings.renderingCombo->setCurrentIndex(0);
+ parent->addPage( settings, i18n( "Coverbling Settings" ), "preferences-system" \
); + connect( parent, SIGNAL( accepted() ), this, SLOT( saveSettings( ) ) );
+}
+
+void CoverBlingApplet::saveSettings()
+{
+ m_coversize = ui_Settings.coversizeSpin->value();
+ if ( ui_Settings.reflectionEffectCombo->currentIndex() == 0 )
+ m_reflectionEffect = PictureFlow::NoReflection;
+ else if ( ui_Settings.reflectionEffectCombo->currentIndex() == 1 )
+ m_reflectionEffect = PictureFlow::PlainReflection;
+ else if ( ui_Settings.reflectionEffectCombo->currentIndex() == 2 )
+ m_reflectionEffect = PictureFlow::BlurredReflection;
+ //if (ui_Settings.renderingCombo->currentIndex()==1)
+ //m_openGL = true;
+ //else
+ //m_openGL = false;
+ m_autojump = ui_Settings.autoJumpChk->isChecked();
+ m_animatejump = ui_Settings.animJumpChk->isChecked();
+ KConfigGroup config = Amarok::config( "CoverBling Applet" );
+ config.writeEntry( "CoverSize", m_coversize );
+ config.writeEntry( "ReflectionEffect", ( int ) m_reflectionEffect );
+ config.writeEntry( "AutoJump", m_autojump );
+ config.writeEntry( "AnimateJump", m_animatejump );
+ //config.writeEntry( "OpenGL", (int) m_openGL );
+
+ constraintsEvent();
+}
+
+void CoverBlingApplet::jumpToPlaying()
+{
+ Meta::TrackPtr track = The::engineController()->currentTrack();
+
+ if ( !track )
+ return;
+ Meta::AlbumPtr album = track->album();
+ if ( !album )
+ return;
+ int center = m_pictureflow->centerIndex();
+ if ( m_pictureflow->album( center ) == album )
+ return;
+ int nbslides = m_pictureflow->slideCount();
+ bool found = false;
+ int index = 0;
+ if (nbslides > 0)
+ {
+ for ( int i = 0; i < nbslides;i++ )
+ {
+ Meta::AlbumPtr current_album = m_pictureflow->album( i );
+ if ( current_album == album )
+ {
+ index = i;
+ found = true;
+ break;
+ }
+ }
+ if ( found )
+ {
+ if ( m_animatejump )
+ {
+ if ( center - index > 10 || index - center > 10 )
+ {
+ if ( index > center )
+ m_pictureflow->skipToSlide( index - 10 );
+ else
+ m_pictureflow->skipToSlide( index + 10 );
+ }
+ m_pictureflow->showSlide( index );
+ }
+ else
+ m_pictureflow->skipToSlide( index );
+ slideChanged( index );
+ }
+ }
+}
+
+void CoverBlingApplet::engineNewTrackPlaying( )
+{
+ if ( m_autojump )
+ {
+ jumpToPlaying();
+ }
+}
+
+void CoverBlingApplet::skipToFirst()
+{
+ m_pictureflow->skipToSlide( 0 );
+ slideChanged( 0 );
+}
+
+void CoverBlingApplet::skipToLast()
+{
+ int nbslides = m_pictureflow->slideCount();
+ m_pictureflow->skipToSlide( nbslides - 1 );
+ slideChanged( nbslides - 1 );
+}
+
+#include "CoverBlingApplet.moc"
+
diff --git a/playground/src/context/applets/coverbling/CoverBlingApplet.h \
b/playground/src/context/applets/coverbling/CoverBlingApplet.h new file mode 100644
index 0000000..893165b
--- /dev/null
+++ b/playground/src/context/applets/coverbling/CoverBlingApplet.h
@@ -0,0 +1,95 @@
+/****************************************************************************************
+ * Copyright (c) 2009 Simon Esneault <simon.esneault@gmail.com> \
* + * Copyright (c) 2010 Emmanuel Wagner <manu.wagner@sfr.fr> \
* + * Copyright (c) 2010 Mark Kretschmann <kretschmann@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, see <http://www.gnu.org/licenses/>. \
* + ****************************************************************************************/
+
+//Plasma applet for showing photos from flickr
+
+#ifndef COVERBLING_APPLET_H
+#define COVERBLING_APPLET_H
+
+#include "context/Applet.h"
+#include "context/DataEngine.h"
+#include "core/engine/EngineObserver.h"
+#include "PhotoBrowser.h"
+#include "ui_coverblingSettings.h"
+
+class TextScrollingWidget;
+class KConfigDialog;
+class PhotosScrollWidget;
+class QGraphicsSimpleTextItem;
+class QGraphicsProxyWidget;
+class RatingWidget;
+class QGraphicsPixmapItem;
+
+namespace Plasma
+{
+ class IconWidget;
+}
+
+class CoverBlingApplet : public Context::Applet, public Engine::EngineObserver
+{
+ Q_OBJECT
+
+ public:
+ CoverBlingApplet( QObject* parent, const QVariantList& args );
+ ~CoverBlingApplet();
+
+ void init();
+ void paintInterface( QPainter *painter, const QStyleOptionGraphicsItem \
*option, const QRect &contentsRect ); +
+ // inherited from EngineObserver
+ virtual void engineNewTrackPlaying();
+
+ public slots:
+ void slotAlbumQueryResult( QString collectionId, Meta::AlbumList albums);
+ void slideChanged( int islideindex );
+ void appendAlbum( int islideindex );
+ void toggleFullscreen();
+ void jumpToPlaying();
+ void saveSettings();
+ void skipToFirst();
+ void skipToLast();
+
+ protected :
+ virtual void constraintsEvent( Plasma::Constraints constraints = \
Plasma::AllConstraints ); + void createConfigurationInterface(KConfigDialog \
*parent); +
+ private:
+ PhotoBrowser * m_pictureflow;
+ QGraphicsProxyWidget * m_layout;
+ RatingWidget* m_ratingWidget;
+ QGraphicsSimpleTextItem* m_label;
+
+ Plasma::IconWidget* m_blingtofirst;
+ Plasma::IconWidget* m_blingtolast;
+ Plasma::IconWidget* m_blingfastback;
+ Plasma::IconWidget* m_blingfastforward;
+ Plasma::IconWidget* m_fullscreen;
+ Plasma::IconWidget* m_jumptoplaying;
+
+ bool m_fullsize;
+ bool m_autojump;
+ bool m_animatejump;
+ Ui::coverblingSettings ui_Settings;
+ int m_coversize;
+ PictureFlow::ReflectionEffect m_reflectionEffect;
+ bool m_openGL;
+};
+
+K_EXPORT_AMAROK_APPLET( coverbling, CoverBlingApplet )
+
+#endif /* COVERBLING_APPLET_H */
diff --git a/playground/src/context/applets/coverbling/ImageLoader.cpp \
b/playground/src/context/applets/coverbling/ImageLoader.cpp new file mode 100644
index 0000000..090b780
--- /dev/null
+++ b/playground/src/context/applets/coverbling/ImageLoader.cpp
@@ -0,0 +1,124 @@
+/* PhotoFlow - animated image viewer for mobile devices
+ *
+ * Copyright (C) 2008 Ariya Hidayat (ariya.hidayat@gmail.com)
+ * Copyright (C) 2007 Ariya Hidayat (ariya.hidayat@gmail.com)
+ *
+ * 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 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this library; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA
+ *
+ */
+
+#include "ImageLoader.h"
+#include <qimage.h>
+#include <QPixmap>
+#include <KStandardDirs>
+// load and resize image
+
+
+ImageLoader::ImageLoader(): QThread(),
+ restart( false ), working( false ), idx( -1 )
+{
+}
+
+ImageLoader::~ImageLoader()
+{
+ mutex.lock();
+ condition.wakeOne();
+ mutex.unlock();
+ wait();
+}
+
+bool ImageLoader::busy() const
+{
+ return isRunning() ? working : false;
+}
+
+void ImageLoader::generate( int index, Meta::AlbumPtr iAlbum, QSize size )
+{
+ mutex.lock();
+ this->idx = index;
+ this->m_album = iAlbum;
+ this->size = size;
+ mutex.unlock();
+
+ if ( !isRunning() )
+ start();
+ else
+ {
+ // already running, wake up whenever ready
+ restart = true;
+ condition.wakeOne();
+ }
+}
+
+void ImageLoader::run()
+{
+ for ( ;; )
+ {
+ // copy necessary data
+ mutex.lock();
+ this->working = true;
+ Meta::AlbumPtr album_ptr = this->m_album;
+ QSize size = this->size;
+ mutex.unlock();
+
+ QImage image = PlainImageLoader::loadAndResize( album_ptr, size );
+
+ // let everyone knows it is ready
+ mutex.lock();
+ this->working = false;
+ this->img = image;
+ mutex.unlock();
+
+ // put to sleep
+ mutex.lock();
+ if ( !this->restart )
+ condition.wait( &mutex );
+ restart = false;
+ mutex.unlock();
+ }
+}
+
+PlainImageLoader::PlainImageLoader(): idx( -1 )
+{
+}
+
+void PlainImageLoader::generate( int index, Meta::AlbumPtr iAlbum, QSize size )
+{
+ img = loadAndResize( iAlbum, size );
+ idx = index;
+}
+QPixmap PlainImageLoader::GetPixmap(Meta::AlbumPtr iAlbum)
+{
+ QPixmap pixmap;
+ if ( iAlbum->hasImage() )
+ {
+ pixmap = iAlbum->image();
+ }
+ else
+ {
+ pixmap = QPixmap( KStandardDirs::locate( "data", \
"amarok/images/blingdefaultcover.png" ) ); + }
+ return pixmap;
+}
+QImage PlainImageLoader::loadAndResize( Meta::AlbumPtr iAlbum, QSize size )
+{
+ //qDebug() << <<"ImageLoader::loadAndresize()";
+ QImage image;
+ QPixmap pixmap = GetPixmap(iAlbum);
+ image = pixmap.toImage();
+ image = image.scaled( size, Qt::KeepAspectRatio, Qt::SmoothTransformation );
+ return image;
+}
diff --git a/playground/src/context/applets/coverbling/ImageLoader.h \
b/playground/src/context/applets/coverbling/ImageLoader.h new file mode 100644
index 0000000..9a9d51b
--- /dev/null
+++ b/playground/src/context/applets/coverbling/ImageLoader.h
@@ -0,0 +1,85 @@
+/* PhotoFlow - animated image viewer for mobile devices
+ *
+ * Copyright (C) 2008 Ariya Hidayat (ariya.hidayat@gmail.com)
+ * Copyright (C) 2007 Ariya Hidayat (ariya.hidayat@gmail.com)
+ *
+ * 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 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this library; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA
+ *
+ */
+
+#ifndef IMAGE_THUMBNAIL_H
+#define IMAGE_THUMBNAIL_H
+#include <qimage.h>
+#include <qobject.h>
+#include <qsize.h>
+#include <qthread.h>
+
+#include <qmutex.h>
+#include <qwaitcondition.h>
+
+#include "core/meta/Meta.h"
+class ImageLoader : public QThread
+{
+public:
+ ImageLoader();
+
+ ~ImageLoader();
+
+ // returns FALSE if worker is still busy and can't take the task
+ bool busy() const;
+
+ void generate(int index, Meta::AlbumPtr iAlbum, QSize size);
+
+ int index() const { return idx; }
+
+ QImage result() const { return img; }
+
+protected:
+ void run();
+
+private:
+ QMutex mutex;
+ QWaitCondition condition;
+
+ bool restart;
+ bool working;
+ int idx;
+ Meta::AlbumPtr m_album;
+ QSize size;
+ QImage img;
+};
+
+class PlainImageLoader
+{
+public:
+ PlainImageLoader();
+
+ bool busy() const { return false; }
+
+ void generate(int index, Meta::AlbumPtr iAlbum, QSize size);
+
+ int index() const { return idx; }
+
+ QImage result() const { return img; }
+
+ static QPixmap GetPixmap( Meta::AlbumPtr iAlbum);
+ static QImage loadAndResize( Meta::AlbumPtr iAlbum, QSize size );
+private:
+ int idx;
+ QImage img;
+};
+#endif // IMAGE_THUMBNAIL_H
+
diff --git a/playground/src/context/applets/coverbling/PhotoBrowser.cpp \
b/playground/src/context/applets/coverbling/PhotoBrowser.cpp new file mode 100644
index 0000000..856e9c2
--- /dev/null
+++ b/playground/src/context/applets/coverbling/PhotoBrowser.cpp
@@ -0,0 +1,135 @@
+/* PhotoFlow - animated image viewer for mobile devices
+ *
+ * Copyright (C) 2008 Ariya Hidayat (ariya.hidayat@gmail.com)
+ * Copyright (C) 2007 Ariya Hidayat (ariya.hidayat@gmail.com)
+ *
+ * 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 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this library; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA
+ *
+ */
+
+#include "PhotoBrowser.h"
+
+#include "ImageLoader.h"
+#include "pictureflow.h"
+
+#include <QDir>
+#include <QImage>
+#include <QImageReader>
+#include <QTimer>
+#include "core/meta/Meta.h"
+
+#define ImageLoader PlainImageLoader
+
+class PhotoBrowser::Private
+{
+public:
+ QString imagePath;
+ QTimer* updateTimer;
+ ImageLoader* worker;
+};
+
+PhotoBrowser::PhotoBrowser( QWidget* parent, bool enableOpenGL ): PictureFlow( \
parent,enableOpenGL) +{
+ d = new Private;
+
+ d->updateTimer = new QTimer;
+ connect( d->updateTimer, SIGNAL( timeout() ), this, SLOT( updateImageData() ) );
+ d->worker = new ImageLoader;
+ connect( this, SIGNAL( centerIndexChanged( int ) ), this, SLOT( preload() ) );
+ m_opengl = enableOpenGL;
+}
+
+PhotoBrowser::~PhotoBrowser()
+{
+ delete d->worker;
+ delete d->updateTimer;
+ delete d;
+}
+void PhotoBrowser::fillAlbums( Meta::AlbumList albums )
+{
+ if (m_opengl)
+ setAlbums(albums);
+ else
+ {
+ foreach( Meta::AlbumPtr album, albums )
+ {
+ addAlbum( album );
+ addSlide( QImage() );
+ }
+ setCenterIndex( 0 );
+ preload();
+ }
+}
+void PhotoBrowser::preload()
+{
+ d->updateTimer->start( 100 );
+}
+
+void PhotoBrowser::updateImageData()
+{
+ // can't do anything, wait for the next possibility
+ if ( d->worker->busy() )
+ return;
+
+ // set image of last one
+ if ( d->worker->index() >= 0 )
+ setSlide( d->worker->index(), d->worker->result() );
+
+ // try to load only few images on the left and right side
+ // i.e. all visible ones plus some extra
+#define COUNT 10
+ int indexes[2*COUNT+1];
+ int center = centerIndex();
+ indexes[0] = center;
+ for ( int j = 0; j < COUNT; j++ )
+ {
+ indexes[j*2+1] = center + j + 1;
+ indexes[j*2+2] = center - j - 1;
+ }
+
+ for ( int c = 0; c < 2*COUNT + 1; c++ )
+ {
+ int i = indexes[c];
+ if (( i >= 0 ) && ( i < slideCount() ) )
+ if ( slide( i ).isNull() )
+ {
+ // schedule thumbnail generation
+ Meta::AlbumPtr iAlbum = m_album_list[i];
+ d->worker->generate( i, iAlbum, slideSize() );
+ return;
+ }
+ }
+
+ // no need to generate anything? stop polling...
+ d->updateTimer->stop();
+}
+void PhotoBrowser::fastForward()
+{
+ int nbslides = slideCount();
+ int current = centerIndex();
+ showSlide( current + nbslides / 10 );
+}
+void PhotoBrowser::fastBackward()
+{
+ int nbslides = slideCount();
+ int current = centerIndex();
+ showSlide( current - nbslides / 10 );
+}
+void PhotoBrowser::skipToSlide( int iSlide )
+{
+ setCenterIndex( iSlide );
+ preload();
+}
diff --git a/playground/src/context/applets/coverbling/PhotoBrowser.h \
b/playground/src/context/applets/coverbling/PhotoBrowser.h new file mode 100644
index 0000000..eecbe71
--- /dev/null
+++ b/playground/src/context/applets/coverbling/PhotoBrowser.h
@@ -0,0 +1,52 @@
+/* PhotoFlow - animated image viewer for mobile devices
+ *
+ * Copyright (C) 2008 Ariya Hidayat (ariya.hidayat@gmail.com)
+ * Copyright (C) 2007 Ariya Hidayat (ariya.hidayat@gmail.com)
+ *
+ * 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 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this library; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA
+ *
+ */
+
+#ifndef PHOTO_BROWSER_H
+#define PHOTO_BROWSER_H
+
+#include "pictureflow.h"
+#include "core/meta/Meta.h"
+
+class PhotoBrowser: public PictureFlow
+{
+ Q_OBJECT
+
+public:
+ explicit PhotoBrowser(QWidget* parent = 0, bool enableOpenGL = false);
+ virtual ~PhotoBrowser();
+
+ void fillAlbums(Meta::AlbumList albums);
+public slots:
+ void fastForward();
+ void fastBackward();
+ void skipToSlide(int iSlide);
+private slots:
+ void preload();
+ void updateImageData();
+
+private:
+ class Private;
+ Private *d;
+};
+
+#endif // PHOTO_BROWSER_H
+
diff --git a/playground/src/context/applets/coverbling/amarok-context-applet-coverbling.desktop \
b/playground/src/context/applets/coverbling/amarok-context-applet-coverbling.desktop \
new file mode 100644 index 0000000..6772e71
--- /dev/null
+++ b/playground/src/context/applets/coverbling/amarok-context-applet-coverbling.desktop
@@ -0,0 +1,45 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=CoverBling
+Name[ca]=CoverBling
+Name[ca@valencia]=CoverBling
+Name[cs]=CoverBling
+Name[da]=CoverBling
+Name[de]=CoverBling
+Name[en_GB]=CoverBling
+Name[es]=CoverBling
+Name[et]=CoverBling
+Name[is]=CoverBling
+Name[it]=CoverBling
+Name[ja]=CoverBling
+Name[km]=CoverBling
+Name[nb]=CoverBling
+Name[nds]=CoverBling
+Name[nl]=CoverBling
+Name[pt]=Capas
+Name[pt_BR]=Capas
+Name[ru]=Обложки
+Name[sl]=CoverBling
+Name[sr]=Омотација
+Name[sr@ijekavian]=Омотација
+Name[sr@ijekavianlatin]=Omotacija
+Name[sr@latin]=Omotacija
+Name[sv]=Omslagsutsmyckning
+Name[uk]=CoverBling
+Name[x-test]=xxCoverBlingxx
+Name[zh_TW]=CoverBling
+Type=Service
+ServiceTypes=Plasma/Applet
+
+X-KDE-Library=amarok_context_applet_coverbling
+X-KDE-PluginInfo-Author=manuw2009
+X-KDE-PluginInfo-Email=manu.wagner@sfr.fr
+X-KDE-PluginInfo-Name=coverbling
+X-KDE-PluginInfo-Version=0.10
+X-KDE-PluginInfo-Website=
+X-KDE-PluginInfo-Category=
+X-KDE-PluginInfo-Depends=
+X-KDE-PluginInfo-License=GPL
+X-KDE-PluginInfo-EnabledByDefault=true
+X-KDE-ParentApp=amarok
+X-KDE-PluginInfo-Category=Current
diff --git a/playground/src/context/applets/coverbling/blingdefaultcover.png \
b/playground/src/context/applets/coverbling/blingdefaultcover.png new file mode \
100644 index 0000000..caa4389
Binary files /dev/null and \
b/playground/src/context/applets/coverbling/blingdefaultcover.png \
differ
diff --git a/playground/src/context/applets/coverbling/blingfastback.png \
b/playground/src/context/applets/coverbling/blingfastback.png new file mode 100644
index 0000000..ff45a5e
Binary files /dev/null and \
b/playground/src/context/applets/coverbling/blingfastback.png differ
diff --git a/playground/src/context/applets/coverbling/blingfastforward.png \
b/playground/src/context/applets/coverbling/blingfastforward.png new file mode 100644
index 0000000..b304119
Binary files /dev/null and \
b/playground/src/context/applets/coverbling/blingfastforward.png \
differ
diff --git a/playground/src/context/applets/coverbling/blingfullscreen.png \
b/playground/src/context/applets/coverbling/blingfullscreen.png new file mode 100644
index 0000000..7f67b7f
Binary files /dev/null and \
b/playground/src/context/applets/coverbling/blingfullscreen.png \
differ
diff --git a/playground/src/context/applets/coverbling/blingjumptoplaying.png \
b/playground/src/context/applets/coverbling/blingjumptoplaying.png new file mode \
100644 index 0000000..d1ac7d9
Binary files /dev/null and \
b/playground/src/context/applets/coverbling/blingjumptoplaying.png \
differ
diff --git a/playground/src/context/applets/coverbling/blingtofirst.png \
b/playground/src/context/applets/coverbling/blingtofirst.png new file mode 100644
index 0000000..a8aa79e
Binary files /dev/null and \
b/playground/src/context/applets/coverbling/blingtofirst.png differ
diff --git a/playground/src/context/applets/coverbling/blingtolast.png \
b/playground/src/context/applets/coverbling/blingtolast.png new file mode 100644
index 0000000..26a5cf5
Binary files /dev/null and \
b/playground/src/context/applets/coverbling/blingtolast.png differ
diff --git a/playground/src/context/applets/coverbling/coverblingSettings.ui \
b/playground/src/context/applets/coverbling/coverblingSettings.ui new file mode \
100644 index 0000000..8da5975
--- /dev/null
+++ b/playground/src/context/applets/coverbling/coverblingSettings.ui
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>coverblingSettings</class>
+ <widget class="QWidget" name="coverblingSettings">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>265</width>
+ <height>146</height>
+ </rect>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <property name="labelAlignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Reflection effect</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="reflectionEffectCombo">
+ <item>
+ <property name="text">
+ <string>None</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Plain</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Blurred</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Cover size (pixels)</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSpinBox" name="coversizeSpin">
+ <property name="minimum">
+ <number>10</number>
+ </property>
+ <property name="maximum">
+ <number>500</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="2">
+ <widget class="QCheckBox" name="autoJumpChk">
+ <property name="text">
+ <string>Auto jump to playing</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" colspan="2">
+ <widget class="QCheckBox" name="animJumpChk">
+ <property name="text">
+ <string>Animated jump</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/playground/src/context/applets/coverbling/pictureflow.cpp \
b/playground/src/context/applets/coverbling/pictureflow.cpp new file mode 100644
index 0000000..905bec7
--- /dev/null
+++ b/playground/src/context/applets/coverbling/pictureflow.cpp
@@ -0,0 +1,1169 @@
+/*
+ PictureFlow - animated image show widget
+ http://pictureflow.googlecode.com
+ Copyright (C) 2010 Emmanuel Wagner (manu.wagner@sfr.fr)
+ Ariya's code modifications for amarok
+ Copyright (C) 2008 Ariya Hidayat (ariya@kde.org)
+ Copyright (C) 2007 Ariya Hidayat (ariya@kde.org)
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+*/
+#include "pictureflow.h"
+
+#include <QApplication>
+#include <QCache>
+#include <QHash>
+#include <QImage>
+#include <QKeyEvent>
+#include <QPainter>
+#include <QPixmap>
+#include <QTimer>
+#include <QVector>
+#include <QWidget>
+#include <KStandardDirs>
+
+#include <QGraphicsView>
+#include <QFrame>
+
+// for fixed-point arithmetic, we need minimum 32-bit long
+// long long (64-bit) might be useful for multiplication and division
+typedef long PFreal;
+#define PFREAL_SHIFT 10
+#define PFREAL_ONE (1 << PFREAL_SHIFT)
+
+#define IANGLE_MAX 1024
+#define IANGLE_MASK 1023
+
+inline PFreal fmul( PFreal a, PFreal b )
+{
+ return (( long long )( a ) )*(( long long )( b ) ) >> PFREAL_SHIFT;
+}
+
+inline PFreal fdiv( PFreal num, PFreal den )
+{
+ long long p = ( long long )( num ) << ( PFREAL_SHIFT * 2 );
+ long long q = p / ( long long )den;
+ long long r = q >> PFREAL_SHIFT;
+
+ return r;
+}
+
+inline PFreal fsin( int iangle )
+{
+ // warning: regenerate the table if IANGLE_MAX and PFREAL_SHIFT are changed!
+ static const PFreal tab[] =
+ {
+ 3, 103, 202, 300, 394, 485, 571, 652,
+ 726, 793, 853, 904, 947, 980, 1004, 1019,
+ 1023, 1018, 1003, 978, 944, 901, 849, 789,
+ 721, 647, 566, 479, 388, 294, 196, 97,
+ -4, -104, -203, -301, -395, -486, -572, -653,
+ -727, -794, -854, -905, -948, -981, -1005, -1020,
+ -1024, -1019, -1004, -979, -945, -902, -850, -790,
+ -722, -648, -567, -480, -389, -295, -197, -98,
+ 3
+ };
+
+ while ( iangle < 0 )
+ iangle += IANGLE_MAX;
+ iangle &= IANGLE_MASK;
+
+ int i = ( iangle >> 4 );
+ PFreal p = tab[i];
+ PFreal q = tab[( i+1 )];
+ PFreal g = ( q - p );
+ return p + g * ( iangle - i*16 ) / 16;
+}
+
+inline PFreal fcos( int iangle )
+{
+ return fsin( iangle + ( IANGLE_MAX >> 2 ) );
+}
+
+/* ----------------------------------------------------------
+
+PictureFlowState stores the state of all slides, i.e. all the necessary
+information to be able to render them.
+
+PictureFlowAnimator is responsible to move the slides during the
+transition between slides, to achieve the effect similar to Cover Flow,
+by changing the state.
+
+PictureFlowSoftwareRenderer (or PictureFlowOpenGLRenderer) is
+the actual 3-d renderer. It should render all slides given the state
+(an instance of PictureFlowState).
+
+Instances of all the above three classes are stored in
+PictureFlowPrivate.
+
+------------------------------------------------------- */
+
+struct SlideInfo
+{
+ int slideIndex;
+ int angle;
+ PFreal cx;
+ PFreal cy;
+ int blend;
+};
+
+class PictureFlowState
+{
+public:
+ PictureFlowState();
+ ~PictureFlowState();
+
+ void reposition();
+ void reset();
+
+ QRgb backgroundColor;
+ int slideWidth;
+ int slideHeight;
+ PictureFlow::ReflectionEffect reflectionEffect;
+ QVector<QImage*> slideImages;
+
+ int angle;
+ int spacing;
+ PFreal offsetX;
+ PFreal offsetY;
+
+ SlideInfo centerSlide;
+ QVector<SlideInfo> leftSlides;
+ QVector<SlideInfo> rightSlides;
+ int centerIndex;
+};
+
+class PictureFlowAnimator
+{
+public:
+ PictureFlowAnimator();
+ PictureFlowState* state;
+
+ void start( int slide );
+ void stop( int slide );
+ void update();
+
+ int target;
+ int step;
+ int frame;
+ QTimer animateTimer;
+ int animationDuration;
+};
+
+class PictureFlowAbstractRenderer
+{
+public:
+ PictureFlowAbstractRenderer(): state( 0 ), dirty( false ), widget( 0 ) {}
+ virtual ~PictureFlowAbstractRenderer() {}
+
+ PictureFlowState* state;
+ bool dirty;
+ QWidget* widget;
+ QPainter::RenderHints render_hints;
+ virtual void init() = 0;
+ virtual void paint() = 0;
+};
+
+class PictureFlowSoftwareRenderer: public PictureFlowAbstractRenderer
+{
+public:
+ PictureFlowSoftwareRenderer();
+ ~PictureFlowSoftwareRenderer();
+
+ virtual void init();
+ virtual void paint();
+
+private:
+ QSize size;
+ QRgb bgcolor;
+ int effect;
+ QImage buffer;
+ QVector<PFreal> rays;
+ QImage* blankSurface;
+ QCache<int, QImage> surfaceCache;
+ QHash<int, QImage*> imageHash;
+
+ void render();
+ void renderSlides();
+ QRect renderSlide( const SlideInfo &slide, int col1 = -1, int col2 = -1 );
+ QImage* surface( int slideIndex );
+};
+
+class PictureFlowOpenGLRenderer: public PictureFlowAbstractRenderer
+{
+public:
+ PictureFlowOpenGLRenderer();
+ ~PictureFlowOpenGLRenderer();
+ void init();
+ void paint();
+private :
+ QSize size;
+ QRgb bgcolor;
+ int effect;
+ QImage* blankSurface;
+};
+
+PictureFlowOpenGLRenderer::PictureFlowOpenGLRenderer():
+ PictureFlowAbstractRenderer(), size( 0, 0 ), bgcolor( 0 ), effect( -1 ), \
blankSurface( 0 ) +{
+}
+PictureFlowOpenGLRenderer::~PictureFlowOpenGLRenderer()
+{
+}
+void PictureFlowOpenGLRenderer::init()
+{
+}
+void PictureFlowOpenGLRenderer::paint()
+{
+}
+// ------------- PictureFlowState ---------------------------------------
+
+PictureFlowState::PictureFlowState():
+ backgroundColor( 0 ), slideWidth( 150 ), slideHeight( 200 ),
+ reflectionEffect( PictureFlow::BlurredReflection ), centerIndex( 0 )
+{
+}
+
+PictureFlowState::~PictureFlowState()
+{
+ for ( int i = 0; i < ( int )slideImages.count(); i++ )
+ delete slideImages[i];
+}
+
+// readjust the settings, call this when slide dimension is changed
+void PictureFlowState::reposition()
+{
+ angle = 70 * IANGLE_MAX / 360; // approx. 70 degrees tilted
+
+ offsetX = slideWidth / 2 * ( PFREAL_ONE - fcos( angle ) );
+ offsetY = slideWidth / 2 * fsin( angle );
+ offsetX += slideWidth * PFREAL_ONE;
+ offsetY += slideWidth * PFREAL_ONE / 4;
+ spacing = 40;
+}
+
+// adjust slides so that they are in "steady state" position
+void PictureFlowState::reset()
+{
+ centerSlide.angle = 0;
+ centerSlide.cx = 0;
+ centerSlide.cy = 0;
+ centerSlide.slideIndex = centerIndex;
+ centerSlide.blend = 256;
+
+ leftSlides.resize( 6 );
+ for ( int i = 0; i < ( int )leftSlides.count(); i++ )
+ {
+ SlideInfo& si = leftSlides[i];
+ si.angle = angle;
+ si.cx = -( offsetX + spacing * i * PFREAL_ONE );
+ si.cy = offsetY;
+ si.slideIndex = centerIndex - 1 - i;
+ si.blend = 256;
+ if ( i == ( int )leftSlides.count() - 2 )
+ si.blend = 128;
+ if ( i == ( int )leftSlides.count() - 1 )
+ si.blend = 0;
+ }
+
+ rightSlides.resize( 6 );
+ for ( int i = 0; i < ( int )rightSlides.count(); i++ )
+ {
+ SlideInfo& si = rightSlides[i];
+ si.angle = -angle;
+ si.cx = offsetX + spacing * i * PFREAL_ONE;
+ si.cy = offsetY;
+ si.slideIndex = centerIndex + 1 + i;
+ si.blend = 256;
+ if ( i == ( int )rightSlides.count() - 2 )
+ si.blend = 128;
+ if ( i == ( int )rightSlides.count() - 1 )
+ si.blend = 0;
+ }
+}
+
+// ------------- PictureFlowAnimator ---------------------------------------
+
+PictureFlowAnimator::PictureFlowAnimator():
+ state( 0 ), target( 0 ), step( 0 ), frame( 0 ), animationDuration( 30 )
+{
+}
+
+void PictureFlowAnimator::start( int slide )
+{
+ target = slide;
+ if ( !animateTimer.isActive() && state )
+ {
+ step = ( target < state->centerSlide.slideIndex ) ? -1 : 1;
+ animateTimer.start( animationDuration );
+ }
+}
+
+void PictureFlowAnimator::stop( int slide )
+{
+ step = 0;
+ target = slide;
+ frame = slide << 16;
+ animateTimer.stop();
+}
+
+void PictureFlowAnimator::update()
+{
+ if ( !animateTimer.isActive() )
+ return;
+ if ( step == 0 )
+ return;
+ if ( !state )
+ return;
+
+ int speed = 16384 / 4;
+
+#if 1
+ // deaccelerate when approaching the target
+ const int max = 2 * 65536;
+
+ int fi = frame;
+ fi -= ( target << 16 );
+ if ( fi < 0 )
+ fi = -fi;
+ fi = qMin( fi, max );
+
+ int ia = IANGLE_MAX * ( fi - max / 2 ) / ( max * 2 );
+ speed = 512 + 16384 * ( PFREAL_ONE + fsin( ia ) ) / PFREAL_ONE;
+#endif
+
+ frame += speed * step;
+
+ int index = frame >> 16;
+ int pos = frame & 0xffff;
+ int neg = 65536 - pos;
+ int tick = ( step < 0 ) ? neg : pos;
+ PFreal ftick = ( tick * PFREAL_ONE ) >> 16;
+
+ if ( step < 0 )
+ index++;
+
+ if ( state->centerIndex != index )
+ {
+ state->centerIndex = index;
+ frame = index << 16;
+ state->centerSlide.slideIndex = state->centerIndex;
+ for ( int i = 0; i < ( int )state->leftSlides.count(); i++ )
+ state->leftSlides[i].slideIndex = state->centerIndex - 1 - i;
+ for ( int i = 0; i < ( int )state->rightSlides.count(); i++ )
+ state->rightSlides[i].slideIndex = state->centerIndex + 1 + i;
+ }
+
+ state->centerSlide.angle = ( step * tick * state->angle ) >> 16;
+ state->centerSlide.cx = -step * fmul( state->offsetX, ftick );
+ state->centerSlide.cy = fmul( state->offsetY, ftick );
+
+ if ( state->centerIndex == target )
+ {
+ stop( target );
+ state->reset();
+ return;
+ }
+
+ for ( int i = 0; i < ( int )state->leftSlides.count(); i++ )
+ {
+ SlideInfo& si = state->leftSlides[i];
+ si.angle = state->angle;
+ si.cx = -( state->offsetX + state->spacing * i * PFREAL_ONE + step * \
state->spacing * ftick ); + si.cy = state->offsetY;
+ }
+
+ for ( int i = 0; i < ( int )state->rightSlides.count(); i++ )
+ {
+ SlideInfo& si = state->rightSlides[i];
+ si.angle = -state->angle;
+ si.cx = state->offsetX + state->spacing * i * PFREAL_ONE - step * \
state->spacing * ftick; + si.cy = state->offsetY;
+ }
+
+ if ( step > 0 )
+ {
+ PFreal ftick = ( neg * PFREAL_ONE ) >> 16;
+ state->rightSlides[0].angle = -( neg * state->angle ) >> 16;
+ state->rightSlides[0].cx = fmul( state->offsetX, ftick );
+ state->rightSlides[0].cy = fmul( state->offsetY, ftick );
+ }
+ else
+ {
+ PFreal ftick = ( pos * PFREAL_ONE ) >> 16;
+ state->leftSlides[0].angle = ( pos * state->angle ) >> 16;
+ state->leftSlides[0].cx = -fmul( state->offsetX, ftick );
+ state->leftSlides[0].cy = fmul( state->offsetY, ftick );
+ }
+
+ // must change direction ?
+ if ( target < index ) if ( step > 0 )
+ step = -1;
+ if ( target > index ) if ( step < 0 )
+ step = 1;
+
+ // the first and last slide must fade in/fade out
+ int nleft = state->leftSlides.count();
+ int nright = state->rightSlides.count();
+ int fade = pos / 256;
+
+ for ( int index = 0; index < nleft; index++ )
+ {
+ int blend = 256;
+ if ( index == nleft - 1 )
+ blend = ( step > 0 ) ? 0 : 128 - fade / 2;
+ if ( index == nleft - 2 )
+ blend = ( step > 0 ) ? 128 - fade / 2 : 256 - fade / 2;
+ if ( index == nleft - 3 )
+ blend = ( step > 0 ) ? 256 - fade / 2 : 256;
+ state->leftSlides[index].blend = blend;
+ }
+ for ( int index = 0; index < nright; index++ )
+ {
+ int blend = ( index < nright - 2 ) ? 256 : 128;
+ if ( index == nright - 1 )
+ blend = ( step > 0 ) ? fade / 2 : 0;
+ if ( index == nright - 2 )
+ blend = ( step > 0 ) ? 128 + fade / 2 : fade / 2;
+ if ( index == nright - 3 )
+ blend = ( step > 0 ) ? 256 : 128 + fade / 2;
+ state->rightSlides[index].blend = blend;
+ }
+
+}
+
+// ------------- PictureFlowSoftwareRenderer ---------------------------------------
+
+PictureFlowSoftwareRenderer::PictureFlowSoftwareRenderer():
+ PictureFlowAbstractRenderer(), size( 0, 0 ), bgcolor( 0 ), effect( -1 ), \
blankSurface( 0 ) +{
+}
+
+PictureFlowSoftwareRenderer::~PictureFlowSoftwareRenderer()
+{
+ surfaceCache.clear();
+ buffer = QImage();
+ delete blankSurface;
+}
+
+void PictureFlowSoftwareRenderer::paint()
+{
+ if ( !widget )
+ return;
+
+ if ( widget->size() != size )
+ init();
+
+ if ( state->backgroundColor != bgcolor )
+ {
+ bgcolor = state->backgroundColor;
+ surfaceCache.clear();
+ }
+
+ if (( int )( state->reflectionEffect ) != effect )
+ {
+ effect = ( int )state->reflectionEffect;
+ surfaceCache.clear();
+ }
+
+ if ( dirty )
+ render();
+
+ QPainter painter( widget );
+ painter.setRenderHints( render_hints );
+ painter.drawImage( QPoint( 0, 0 ), buffer );
+}
+
+void PictureFlowSoftwareRenderer::init()
+{
+ if ( !widget )
+ return;
+
+ surfaceCache.clear();
+ blankSurface = 0;
+
+ size = widget->size();
+ int ww = size.width();
+ int wh = size.height();
+ int w = ( ww + 1 ) / 2;
+ int h = ( wh + 1 ) / 2;
+
+ buffer = QImage( ww, wh, QImage::Format_RGB32 );
+ buffer.fill( bgcolor );
+
+ rays.resize( w*2 );
+ for ( int i = 0; i < w; i++ )
+ {
+ PFreal gg = (( PFREAL_ONE >> 1 ) + i * PFREAL_ONE ) / ( 2 * h );
+ rays[w-i-1] = -gg;
+ rays[w+i] = gg;
+ }
+
+ dirty = true;
+}
+
+// TODO: optimize this with lookup tables
+static QRgb blendColor( QRgb c1, QRgb c2, int blend )
+{
+ int r = qRed( c1 ) * blend / 256 + qRed( c2 ) * ( 256 - blend ) / 256;
+ int g = qGreen( c1 ) * blend / 256 + qGreen( c2 ) * ( 256 - blend ) / 256;
+ int b = qBlue( c1 ) * blend / 256 + qBlue( c2 ) * ( 256 - blend ) / 256;
+ return qRgb( r, g, b );
+}
+
+
+static QImage* prepareSurface( const QImage* slideImage, int w, int h, QRgb bgcolor,
+ PictureFlow::ReflectionEffect reflectionEffect )
+{
+
+ Qt::TransformationMode mode = Qt::SmoothTransformation;
+ QImage img = slideImage->scaled( w, h, Qt::IgnoreAspectRatio, mode );
+
+ // slightly larger, to accomodate for the reflection
+ int hs = h * 2;
+ int hofs = h / 3;
+
+ // offscreen buffer: black is sweet
+ QImage* result = new QImage( hs, w, QImage::Format_RGB32 );
+ result->fill( bgcolor );
+
+ // transpose the image, this is to speed-up the rendering
+ // because we process one column at a time
+ // (and much better and faster to work row-wise, i.e in one scanline)
+ for ( int x = 0; x < w; x++ )
+ for ( int y = 0; y < h; y++ )
+ result->setPixel( hofs + y, x, img.pixel( x, y ) );
+
+ if ( reflectionEffect != PictureFlow::NoReflection )
+ {
+ // create the reflection
+ int ht = hs - h - hofs;
+ int hte = ht;
+ for ( int x = 0; x < w; x++ )
+ for ( int y = 0; y < ht; y++ )
+ {
+ QRgb color = img.pixel( x, img.height() - y - 1 );
+ result->setPixel( h + hofs + y, x, blendColor( color, bgcolor, 128*( \
hte - y ) / hte ) ); + }
+
+ if ( reflectionEffect == PictureFlow::BlurredReflection )
+ {
+ // blur the reflection everything first
+ // Based on exponential blur algorithm by Jani Huhtanen
+ QRect rect( hs / 2, 0, hs / 2, w );
+ rect &= result->rect();
+
+ int r1 = rect.top();
+ int r2 = rect.bottom();
+ int c1 = rect.left();
+ int c2 = rect.right();
+
+ int bpl = result->bytesPerLine();
+ int rgba[4];
+ unsigned char* p;
+
+ // how many times blur is applied?
+ // for low-end system, limit this to only 1 loop
+ for ( int loop = 0; loop < 2; loop++ )
+ {
+ for ( int col = c1; col <= c2; col++ )
+ {
+ p = result->scanLine( r1 ) + col * 4;
+ for ( int i = 0; i < 3; i++ )
+ rgba[i] = p[i] << 4;
+
+ p += bpl;
+ for ( int j = r1; j < r2; j++, p += bpl )
+ for ( int i = 0; i < 3; i++ )
+ p[i] = ( rgba[i] += ((( p[i] << 4 ) - rgba[i] ) ) >> 1 ) \
>> 4; + }
+
+ for ( int row = r1; row <= r2; row++ )
+ {
+ p = result->scanLine( row ) + c1 * 4;
+ for ( int i = 0; i < 3; i++ )
+ rgba[i] = p[i] << 4;
+
+ p += 4;
+ for ( int j = c1; j < c2; j++, p += 4 )
+ for ( int i = 0; i < 3; i++ )
+ p[i] = ( rgba[i] += ((( p[i] << 4 ) - rgba[i] ) ) >> 1 ) \
>> 4; + }
+
+ for ( int col = c1; col <= c2; col++ )
+ {
+ p = result->scanLine( r2 ) + col * 4;
+ for ( int i = 0; i < 3; i++ )
+ rgba[i] = p[i] << 4;
+
+ p -= bpl;
+ for ( int j = r1; j < r2; j++, p -= bpl )
+ for ( int i = 0; i < 3; i++ )
+ p[i] = ( rgba[i] += ((( p[i] << 4 ) - rgba[i] ) ) >> 1 ) \
>> 4; + }
+
+ for ( int row = r1; row <= r2; row++ )
+ {
+ p = result->scanLine( row ) + c2 * 4;
+ for ( int i = 0; i < 3; i++ )
+ rgba[i] = p[i] << 4;
+
+ p -= 4;
+ for ( int j = c1; j < c2; j++, p -= 4 )
+ for ( int i = 0; i < 3; i++ )
+ p[i] = ( rgba[i] += ((( p[i] << 4 ) - rgba[i] ) ) >> 1 ) \
>> 4; + }
+ }
+
+ // overdraw to leave only the reflection blurred (but not the actual \
image) + for ( int x = 0; x < w; x++ )
+ for ( int y = 0; y < h; y++ )
+ result->setPixel( hofs + y, x, img.pixel( x, y ) );
+ }
+ }
+
+ return result;
+}
+
+QImage* PictureFlowSoftwareRenderer::surface( int slideIndex )
+{
+ if ( !state )
+ return 0;
+ if ( slideIndex < 0 )
+ return 0;
+ if ( slideIndex >= ( int )state->slideImages.count() )
+ return 0;
+
+ int key = slideIndex;
+
+ QImage* img = state->slideImages.at( slideIndex );
+ bool empty = img ? img->isNull() : true;
+ if ( empty )
+ {
+ surfaceCache.remove( key );
+ imageHash.remove( slideIndex );
+ if ( !blankSurface )
+ {
+ int sw = state->slideWidth;
+ int sh = state->slideHeight;
+
+ QImage img = QImage( sw, sh, QImage::Format_RGB32 );
+
+ QPainter painter( &img );
+ painter.setRenderHints( render_hints );
+ QPoint p1( sw*4 / 10, 0 );
+ QPoint p2( sw*6 / 10, sh );
+ QLinearGradient linearGrad( p1, p2 );
+ linearGrad.setColorAt( 0, Qt::black );
+ linearGrad.setColorAt( 1, Qt::white );
+ painter.setBrush( linearGrad );
+ painter.fillRect( 0, 0, sw, sh, QBrush( linearGrad ) );
+
+ painter.setPen( QPen( QColor( 64, 64, 64 ), 4 ) );
+ painter.setBrush( QBrush() );
+ painter.drawRect( 2, 2, sw - 3, sh - 3 );
+ painter.end();
+
+ blankSurface = prepareSurface( &img, sw, sh, bgcolor, \
state->reflectionEffect ); + }
+ return blankSurface;
+ }
+ bool exist = imageHash.contains( slideIndex );
+ if ( exist )
+ if ( img == imageHash.find( slideIndex ).value() )
+ if ( surfaceCache.contains( key ) )
+ return surfaceCache[key];
+
+ QImage* sr = prepareSurface( img, state->slideWidth, state->slideHeight, \
bgcolor, state->reflectionEffect ); + surfaceCache.insert( key, sr );
+ imageHash.insert( slideIndex, img );
+
+ return sr;
+}
+
+// Renders a slide to offscreen buffer. Returns a rect of the rendered area.
+// col1 and col2 limit the column for rendering.
+QRect PictureFlowSoftwareRenderer::renderSlide( const SlideInfo &slide, int col1, \
int col2 ) +{
+ int blend = slide.blend;
+ if ( !blend )
+ return QRect();
+
+ QImage* src = surface( slide.slideIndex );
+ if ( !src )
+ return QRect();
+
+ QRect rect( 0, 0, 0, 0 );
+
+ int sw = src->height();
+ int sh = src->width();
+ int h = buffer.height();
+ int w = buffer.width();
+
+ if ( col1 > col2 )
+ {
+ int c = col2;
+ col2 = col1;
+ col1 = c;
+ }
+
+ col1 = ( col1 >= 0 ) ? col1 : 0;
+ col2 = ( col2 >= 0 ) ? col2 : w - 1;
+ col1 = qMin( col1, w - 1 );
+ col2 = qMin( col2, w - 1 );
+
+ int zoom = 100;
+ int distance = h * 100 / zoom;
+ PFreal sdx = fcos( slide.angle );
+ PFreal sdy = fsin( slide.angle );
+ PFreal xs = slide.cx - state->slideWidth * sdx / 2;
+ PFreal ys = slide.cy - state->slideWidth * sdy / 2;
+ PFreal dist = distance * PFREAL_ONE;
+
+ int xi = qMax(( PFreal )0, (( w * PFREAL_ONE / 2 ) + fdiv( xs * h, dist + ys ) ) \
>> PFREAL_SHIFT ); + if ( xi >= w )
+ return rect;
+
+ bool flag = false;
+ rect.setLeft( xi );
+ for ( int x = qMax( xi, col1 ); x <= col2; x++ )
+ {
+ PFreal hity = 0;
+ PFreal fk = rays[x];
+ if ( sdy )
+ {
+ fk = fk - fdiv( sdx, sdy );
+ hity = -fdiv(( rays[x] * distance - slide.cx + slide.cy * sdx / sdy ), \
fk ); + }
+
+ dist = distance * PFREAL_ONE + hity;
+ if ( dist < 0 )
+ continue;
+
+ PFreal hitx = fmul( dist, rays[x] );
+ PFreal hitdist = fdiv( hitx - slide.cx, sdx );
+
+ int column = sw / 2 + ( hitdist >> PFREAL_SHIFT );
+ if ( column >= sw )
+ break;
+ if ( column < 0 )
+ continue;
+
+ rect.setRight( x );
+ if ( !flag )
+ rect.setLeft( x );
+ flag = true;
+
+ int y1 = h / 2;
+ int y2 = y1 + 1;
+ QRgb* pixel1 = ( QRgb* )( buffer.scanLine( y1 ) ) + x;
+ QRgb* pixel2 = ( QRgb* )( buffer.scanLine( y2 ) ) + x;
+ QRgb pixelstep = pixel2 - pixel1;
+
+ int center = ( sh / 2 );
+ int dy = dist / h;
+ int p1 = center * PFREAL_ONE - dy / 2;
+ int p2 = center * PFREAL_ONE + dy / 2;
+
+ const QRgb *ptr = ( const QRgb* )( src->scanLine( column ) );
+ if ( blend == 256 )
+ while (( y1 >= 0 ) && ( y2 < h ) && ( p1 >= 0 ) )
+ {
+ *pixel1 = ptr[p1 >> PFREAL_SHIFT];
+ *pixel2 = ptr[p2 >> PFREAL_SHIFT];
+ p1 -= dy;
+ p2 += dy;
+ y1--;
+ y2++;
+ pixel1 -= pixelstep;
+ pixel2 += pixelstep;
+ }
+ else
+ while (( y1 >= 0 ) && ( y2 < h ) && ( p1 >= 0 ) )
+ {
+ QRgb c1 = ptr[p1 >> PFREAL_SHIFT];
+ QRgb c2 = ptr[p2 >> PFREAL_SHIFT];
+ *pixel1 = blendColor( c1, bgcolor, blend );
+ *pixel2 = blendColor( c2, bgcolor, blend );
+ p1 -= dy;
+ p2 += dy;
+ y1--;
+ y2++;
+ pixel1 -= pixelstep;
+ pixel2 += pixelstep;
+ }
+ }
+
+ rect.setTop( 0 );
+ rect.setBottom( h - 1 );
+ return rect;
+}
+
+void PictureFlowSoftwareRenderer::renderSlides()
+{
+ int nleft = state->leftSlides.count();
+ int nright = state->rightSlides.count();
+
+ QRect r = renderSlide( state->centerSlide );
+ int c1 = r.left();
+ int c2 = r.right();
+
+ for ( int index = 0; index < nleft; index++ )
+ {
+ QRect rs = renderSlide( state->leftSlides[index], 0, c1 - 1 );
+ if ( !rs.isEmpty() )
+ c1 = rs.left();
+ }
+ for ( int index = 0; index < nright; index++ )
+ {
+ QRect rs = renderSlide( state->rightSlides[index], c2 + 1, buffer.width() );
+ if ( !rs.isEmpty() )
+ c2 = rs.right();
+ }
+}
+
+// Render the slides. Updates only the offscreen buffer.
+void PictureFlowSoftwareRenderer::render()
+{
+ buffer.fill( state->backgroundColor );
+ renderSlides();
+ dirty = false;
+}
+
+// -----------------------------------------
+
+class PictureFlowPrivate
+{
+public:
+ PictureFlowState* state;
+ PictureFlowAnimator* animator;
+ PictureFlowAbstractRenderer* renderer;
+ QTimer triggerTimer;
+};
+
+
+PictureFlow::PictureFlow( QWidget* parent, bool enableOpenGL): QWidget( parent )
+{
+ d = new PictureFlowPrivate;
+ m_opengl = enableOpenGL;
+ //m_openglwidget = 0;
+ d->state = new PictureFlowState;
+ d->state->reset();
+ d->state->reposition();
+
+ if (!m_opengl)
+ {
+ d->renderer = new PictureFlowSoftwareRenderer;
+ d->renderer->widget = this;
+ }
+ else
+ {
+ d->renderer = new PictureFlowOpenGLRenderer;
+ //m_openglwidget = new CoverBling(0,m_album_list);
+ //m_openglwidget->setParent(this);
+ }
+ d->renderer->state = d->state;
+ d->renderer->init();
+
+ d->animator = new PictureFlowAnimator;
+ d->animator->state = d->state;
+ QObject::connect( &d->animator->animateTimer, SIGNAL( timeout() ), this, SLOT( \
updateAnimation() ) ); +
+ QObject::connect( &d->triggerTimer, SIGNAL( timeout() ), this, SLOT( render() ) \
); + setAttribute( Qt::WA_StaticContents, true );
+ setAttribute( Qt::WA_OpaquePaintEvent, true );
+ setAttribute( Qt::WA_NoSystemBackground, true );
+}
+
+PictureFlow::~PictureFlow()
+{
+ delete d->renderer;
+ delete d->animator;
+ delete d->state;
+ delete d;
+}
+void PictureFlow::setOpenGLMode(bool activateOpenGL)
+{
+ m_opengl = activateOpenGL;
+}
+int PictureFlow::slideCount() const
+{
+ return d->state->slideImages.count();
+}
+
+QColor PictureFlow::backgroundColor() const
+{
+ return QColor( d->state->backgroundColor );
+}
+
+void PictureFlow::setBackgroundColor( const QColor& c )
+{
+ d->state->backgroundColor = c.rgb();
+ triggerRender();
+}
+
+QSize PictureFlow::slideSize() const
+{
+ return QSize( d->state->slideWidth, d->state->slideHeight );
+}
+
+void PictureFlow::setSlideSize( QSize size )
+{
+ d->state->slideWidth = size.width();
+ d->state->slideHeight = size.height();
+ d->state->reposition();
+ triggerRender();
+}
+
+PictureFlow::ReflectionEffect PictureFlow::reflectionEffect() const
+{
+ return d->state->reflectionEffect;
+}
+
+void PictureFlow::setReflectionEffect( ReflectionEffect effect )
+{
+ d->state->reflectionEffect = effect;
+ triggerRender();
+}
+void PictureFlow::setRenderHints( QPainter::RenderHints iHints )
+{
+ d->renderer->render_hints = iHints;
+ triggerRender();
+}
+void PictureFlow::setAnimationTime( int iTime )
+{
+ d->animator->animationDuration = iTime;
+}
+QImage PictureFlow::slide( int index ) const
+{
+ QImage* i = 0;
+ if (( index >= 0 ) && ( index < slideCount() ) )
+ i = d->state->slideImages[index];
+ return i ? QImage( *i ) : QImage();
+}
+
+void PictureFlow::addSlide( const QImage& image )
+{
+ int c = d->state->slideImages.count();
+ d->state->slideImages.resize( c + 1 );
+ d->state->slideImages[c] = new QImage( image );
+ triggerRender();
+}
+
+void PictureFlow::addSlide( const QPixmap& pixmap )
+{
+ addSlide( pixmap.toImage() );
+}
+
+void PictureFlow::setSlide( int index, const QImage& image )
+{
+ if (( index >= 0 ) && ( index < slideCount() ) )
+ {
+ QImage* i = image.isNull() ? 0 : new QImage( image );
+ delete d->state->slideImages[index];
+ d->state->slideImages[index] = i;
+ triggerRender();
+ }
+}
+
+void PictureFlow::setSlide( int index, const QPixmap& pixmap )
+{
+ setSlide( index, pixmap.toImage() );
+}
+void PictureFlow::addAlbum( Meta::AlbumPtr iAlbum )
+{
+ m_album_list.append( iAlbum );
+ //QPixmap* no_cover_pix = new QPixmap( KStandardDirs::locate( "data", \
"amarok/images/blingdefaultcover.png" ) ); +}
+void PictureFlow::setAlbums(Meta::AlbumList iAlbums)
+{
+ m_album_list = iAlbums;
+ //m_openglwidget->resize(-1,-1);
+ //d->renderer->widget = m_openglwidget;
+ //if (m_openglwidget)
+ //{
+ //m_openglwidget->init(m_album_list,QSize(150,150));
+ //m_openglwidget->show();
+
+ //}
+
+}
+Meta::AlbumPtr PictureFlow::album( int index )
+{
+ Meta::AlbumPtr album;
+ if (index < m_album_list.size() && index >= 0)
+ {
+ album = m_album_list[index];
+ }
+ return album;
+}
+int PictureFlow::centerIndex() const
+{
+ return d->state->centerIndex;
+}
+
+void PictureFlow::setCenterIndex( int index )
+{
+ index = qMin( index, slideCount() - 1 );
+ index = qMax( index, 0 );
+ d->state->centerIndex = index;
+ d->state->reset();
+ d->animator->stop( index );
+ triggerRender();
+}
+
+void PictureFlow::clear()
+{
+ int c = d->state->slideImages.count();
+ for ( int i = 0; i < c; i++ )
+ delete d->state->slideImages[i];
+ d->state->slideImages.resize( 0 );
+
+ d->state->reset();
+ triggerRender();
+}
+
+void PictureFlow::render()
+{
+ d->renderer->dirty = true;
+ update();
+}
+
+void PictureFlow::triggerRender()
+{
+ d->triggerTimer.setSingleShot( true );
+ d->triggerTimer.start( 0 );
+}
+
+void PictureFlow::showPrevious()
+{
+ int step = d->animator->step;
+ int center = d->state->centerIndex;
+
+ if ( step > 0 )
+ d->animator->start( center );
+
+ if ( step == 0 )
+ if ( center > 0 )
+ d->animator->start( center - 1 );
+
+ if ( step < 0 )
+ d->animator->target = qMax( 0, center - 2 );
+}
+
+void PictureFlow::showNext()
+{
+ int step = d->animator->step;
+ int center = d->state->centerIndex;
+
+ if ( step < 0 )
+ d->animator->start( center );
+
+ if ( step == 0 )
+ if ( center < slideCount() - 1 )
+ d->animator->start( center + 1 );
+
+ if ( step > 0 )
+ d->animator->target = qMin( center + 2, slideCount() - 1 );
+}
+
+void PictureFlow::showSlide( int index )
+{
+ index = qMax( index, 0 );
+ index = qMin( slideCount() - 1, index );
+ if ( index == d->state->centerSlide.slideIndex )
+ return;
+
+ d->animator->start( index );
+}
+
+void PictureFlow::keyPressEvent( QKeyEvent* event )
+{
+ if ( event->key() == Qt::Key_Left )
+ {
+ if ( event->modifiers() == Qt::ControlModifier )
+ showSlide( centerIndex() - 10 );
+ else
+ showPrevious();
+ event->accept();
+ return;
+ }
+
+ if ( event->key() == Qt::Key_Right )
+ {
+ if ( event->modifiers() == Qt::ControlModifier )
+ showSlide( centerIndex() + 10 );
+ else
+ showNext();
+ event->accept();
+ return;
+ }
+
+ event->ignore();
+}
+
+void PictureFlow::mousePressEvent( QMouseEvent* event )
+{
+ if ( event->x() > ( width() / 2 + ( d->state->slideWidth ) / 2 ) )
+ showNext();
+ if ( event->x() < ( width() / 2 - ( d->state->slideWidth ) / 2 ) )
+ showPrevious();
+}
+void PictureFlow::mouseDoubleClickEvent( QMouseEvent* event )
+{
+ if ((( event->x() <= ( width() / 2 + ( d->state->slideWidth ) / 2 ) ) && ( \
event->x() >= ( width() / 2 - ( d->state->slideWidth ) / 2 ) ) ) && (( event->y() <= \
( height() / 2 + ( d->state->slideHeight ) / 2 ) ) && ( event->y() >= ( height() / 2 \
- ( d->state->slideHeight ) / 2 ) ) ) ) + emit doubleClicked( \
d->state->centerIndex ); +}
+void PictureFlow::wheelEvent( QWheelEvent * event )
+{
+ int numDegrees = event->delta() / 8;
+ int numSteps = numDegrees / 15;
+ bool forward = TRUE;
+ if ( numSteps < 0 )
+ {
+ forward = FALSE;
+ numSteps = -numSteps;
+ }
+ for ( int i = 1;i <= numSteps;i++ )
+ {
+ if ( forward ) showNext();
+ else showPrevious();
+ }
+}
+void PictureFlow::paintEvent( QPaintEvent* event )
+{
+ Q_UNUSED( event );
+ d->renderer->paint();
+}
+
+void PictureFlow::resizeEvent( QResizeEvent* event )
+{
+ triggerRender();
+ QWidget::resizeEvent( event );
+}
+
+void PictureFlow::updateAnimation()
+{
+ int old_center = d->state->centerIndex;
+ d->animator->update();
+ triggerRender();
+ if ( d->state->centerIndex != old_center )
+ emit centerIndexChanged( d->state->centerIndex );
+}
+
diff --git a/playground/src/context/applets/coverbling/pictureflow.h \
b/playground/src/context/applets/coverbling/pictureflow.h new file mode 100644
index 0000000..a339876
--- /dev/null
+++ b/playground/src/context/applets/coverbling/pictureflow.h
@@ -0,0 +1,217 @@
+/*
+ PictureFlow - animated image show widget
+ http://pictureflow.googlecode.com
+ Copyright (C) 2010 Emmanuel Wagner (manu.wagner@sfr.fr)
+ Ariya's code modifications for amarok
+ Copyright (C) 2008 Ariya Hidayat (ariya@kde.org)
+ Copyright (C) 2007 Ariya Hidayat (ariya@kde.org)
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+*/
+
+#ifndef PICTUREFLOW_H
+#define PICTUREFLOW_H
+
+#include <qwidget.h>
+#include "core/meta/Meta.h"
+#include <qpainter.h>
+#include <QHBoxLayout>
+//#include "CoverBling.h"
+
+class PictureFlowPrivate;
+
+/*!
+ Class PictureFlow implements an image show widget with animation effect
+ like Apple's CoverFlow (in iTunes and iPod). Images are arranged in form
+ of slides, one main slide is shown at the center with few slides on
+ the left and right sides of the center slide. When the next or previous
+ slide is brought to the front, the whole slides flow to the right or
+ the right with smooth animation effect; until the new slide is finally
+ placed at the center.
+
+ */
+class PictureFlow : public QWidget
+{
+Q_OBJECT
+
+ Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
+ Q_PROPERTY(QSize slideSize READ slideSize WRITE setSlideSize)
+ Q_PROPERTY(int slideCount READ slideCount)
+ Q_PROPERTY(int centerIndex READ centerIndex WRITE setCenterIndex)
+
+public:
+
+ enum ReflectionEffect
+ {
+ NoReflection,
+ PlainReflection,
+ BlurredReflection
+ };
+
+ /*!
+ Creates a new PictureFlow widget.
+ */
+ PictureFlow(QWidget* parent = 0, bool enableOpenGL = false);
+
+ /*!
+ Destroys the widget.
+ */
+ ~PictureFlow();
+
+ /*!
+ Returns the background color.
+ */
+ QColor backgroundColor() const;
+
+ /*!
+ Sets the background color. By default it is black.
+ */
+ void setBackgroundColor(const QColor& c);
+
+ void setOpenGLMode(bool activateOpenGL);
+ /*!
+ Returns the dimension of each slide (in pixels).
+ */
+ QSize slideSize() const;
+
+ /*!
+ Sets the dimension of each slide (in pixels).
+ */
+ void setSlideSize(QSize size);
+
+ /*!
+ Returns the total number of slides.
+ */
+ int slideCount() const;
+
+ /*!
+ Returns QImage of specified slide.
+ */
+ QImage slide(int index) const;
+
+ /*!
+ Returns the index of slide currently shown in the middle of the viewport.
+ */
+ int centerIndex() const;
+
+ /*!
+ Returns the effect applied to the reflection.
+ */
+ ReflectionEffect reflectionEffect() const;
+
+ /*!
+ Sets the effect applied to the reflection. The default is PlainReflection.
+ */
+ void setReflectionEffect(ReflectionEffect effect);
+
+ void setRenderHints(QPainter::RenderHints);
+
+ void setAnimationTime(int iTime);
+
+public slots:
+
+ Meta::AlbumPtr album(int index);
+
+ void setAlbums(Meta::AlbumList iAlbums);
+
+ void addAlbum(Meta::AlbumPtr iAlbum);
+ /*!
+ Adds a new slide.
+ */
+ void addSlide(const QImage& image);
+
+ /*!
+ Adds a new slide.
+ */
+ void addSlide(const QPixmap& pixmap);
+
+ /*!
+ Sets an image for specified slide. If the slide already exists,
+ it will be replaced.
+ */
+ void setSlide(int index, const QImage& image);
+
+ /*!
+ Sets a pixmap for specified slide. If the slide already exists,
+ it will be replaced.
+ */
+ void setSlide(int index, const QPixmap& pixmap);
+
+ /*!
+ Sets slide to be shown in the middle of the viewport. No animation
+ effect will be produced, unlike using showSlide.
+ */
+ void setCenterIndex(int index);
+
+ /*!
+ Clears all slides.
+ */
+ void clear();
+
+ /*!
+ Shows previous slide using animation effect.
+ */
+ void showPrevious();
+
+ /*!
+ Shows next slide using animation effect.
+ */
+ void showNext();
+
+ /*!
+ Go to specified slide using animation effect.
+ */
+ void showSlide(int index);
+
+ /*!
+ Rerender the widget. Normally this function will be automatically invoked
+ whenever necessary, e.g. during the transition animation.
+ */
+ void render();
+
+ /*!
+ Schedules a rendering update. Unlike render(), this function does not cause
+ immediate rendering.
+ */
+ void triggerRender();
+
+signals:
+ void centerIndexChanged(int index);
+ void doubleClicked(int index);
+protected:
+ void paintEvent(QPaintEvent *event);
+ void keyPressEvent(QKeyEvent* event);
+ void mousePressEvent(QMouseEvent* event);
+ void resizeEvent(QResizeEvent* event);
+ void mouseDoubleClickEvent(QMouseEvent* event);
+ void wheelEvent(QWheelEvent * event);
+ Meta::AlbumList m_album_list;
+ bool m_opengl;
+private slots:
+ void updateAnimation();
+
+private:
+ PictureFlowPrivate* d;
+
+ //CoverBling* m_openglwidget;
+ //QHBoxLayout* m_opengllayout;
+};
+
+#endif // PICTUREFLOW_H
+
diff --git a/src/context/applets/CMakeLists.txt b/src/context/applets/CMakeLists.txt
index edb28de..707bfa8 100644
--- a/src/context/applets/CMakeLists.txt
+++ b/src/context/applets/CMakeLists.txt
@@ -5,7 +5,6 @@ add_subdirectory( info )
add_subdirectory( wikipedia )
add_subdirectory( videoclip )
add_subdirectory( photos )
-add_subdirectory( coverbling )
if( LIBLASTFM_FOUND )
add_subdirectory( upcomingevents )
diff --git a/src/context/applets/coverbling/CMakeLists.txt \
b/src/context/applets/coverbling/CMakeLists.txt deleted file mode 100644
index 688d408..0000000
--- a/src/context/applets/coverbling/CMakeLists.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-project(context-coverbling)
-
-set(coverbling_SRCS
-pictureflow.cpp
-CoverBlingApplet.cpp
-ImageLoader.cpp
-PhotoBrowser.cpp
-)
-
-include_directories( ../../..
- ../..
- ${KDE4_INCLUDE_DIR}/amarok ) # this way we don't need to prefix \
it with amarok/ (and it compiles this way too :)
-
-kde4_add_ui_files( coverbling_SRCS coverblingSettings.ui )
-kde4_add_plugin(amarok_context_applet_coverbling ${coverbling_SRCS})
-
-
-target_link_libraries(amarok_context_applet_coverbling
- amarokcore
- amaroklib
- ${KDE4_PLASMA_LIBS}
- ${KDE4_KIO_LIBS}
-)
-
-install(TARGETS amarok_context_applet_coverbling DESTINATION ${PLUGIN_INSTALL_DIR})
-install(FILES amarok-context-applet-coverbling.desktop DESTINATION \
${SERVICES_INSTALL_DIR})
-install(FILES blingfastback.png DESTINATION ${DATA_INSTALL_DIR}/amarok/images/ )
-install(FILES blingtofirst.png DESTINATION ${DATA_INSTALL_DIR}/amarok/images/ )
-install(FILES blingfastforward.png DESTINATION ${DATA_INSTALL_DIR}/amarok/images/ )
-install(FILES blingtolast.png DESTINATION ${DATA_INSTALL_DIR}/amarok/images/ )
-install(FILES blingdefaultcover.png DESTINATION ${DATA_INSTALL_DIR}/amarok/images/ )
-install(FILES blingfullscreen.png DESTINATION ${DATA_INSTALL_DIR}/amarok/images/ )
-install(FILES blingjumptoplaying.png DESTINATION ${DATA_INSTALL_DIR}/amarok/images/ \
)
diff --git a/src/context/applets/coverbling/CoverBlingApplet.cpp \
b/src/context/applets/coverbling/CoverBlingApplet.cpp deleted file mode 100644
index 6ba7ed8..0000000
--- a/src/context/applets/coverbling/CoverBlingApplet.cpp
+++ /dev/null
@@ -1,396 +0,0 @@
-/****************************************************************************************
- * Copyright (c) 2010 Emmanuel Wagner <menu.wagner@sfr.fr> \
*
- * Copyright (c) 2010 Mark Kretschmann <kretschmann@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, see <http://www.gnu.org/licenses/>. \
*
- ****************************************************************************************/
-
-#include "CoverBlingApplet.h"
-
-// Amarok
-#include "core/support/Amarok.h"
-#include "EngineController.h"
-#include "core/support/Debug.h"
-#include "context/ContextView.h"
-#include "context/widgets/TextScrollingWidget.h"
-#include "core/collections/Collection.h"
-#include "core-impl/collections/support/CollectionManager.h"
-#include "context/widgets/RatingWidget.h"
-#include "playlist/PlaylistModelStack.h"
-
-// KDE
-#include <KAction>
-#include <KColorScheme>
-#include <KConfigDialog>
-#include <KGlobalSettings>
-#include <Plasma/BusyWidget>
-#include <Plasma/IconWidget>
-#include <Plasma/Theme>
-
-// Qt
-#include <QGraphicsLinearLayout>
-#include <QGraphicsProxyWidget>
-#include <QGraphicsSimpleTextItem>
-#include <QGraphicsWidget>
-#include <QLabel>
-#include <QPixmap>
-#include <QGraphicsPixmapItem>
-#include <KStandardDirs>
-#include <QDesktopWidget>
-
-#define DEBUG_PREFIX "CoverBlingApplet"
-
-
-CoverBlingApplet::CoverBlingApplet( QObject* parent, const QVariantList& args )
- : Context::Applet( parent, args )
- , Engine::EngineObserver( The::engineController() )
-{
- DEBUG_BLOCK
-
- setHasConfigurationInterface( true );
-}
-
-void
-CoverBlingApplet::init()
-{
- setBackgroundHints( Plasma::Applet::NoBackground );
- resize( -1, 400 );
- m_fullsize = false;
-
- KConfigGroup config = Amarok::config( "CoverBling Applet" );
- m_coversize = config.readEntry( "CoverSize", 200 );
- int reflectioneffect = config.readEntry( "ReflectionEffect", 1 );
- if ( reflectioneffect == 0 )
- m_reflectionEffect = PictureFlow::NoReflection;
- else if ( reflectioneffect == 1 )
- m_reflectionEffect = PictureFlow::PlainReflection;
- else if ( reflectioneffect == 2 )
- m_reflectionEffect = PictureFlow::BlurredReflection;
-
- m_autojump = config.readEntry( "AutoJump", false );
- m_animatejump = config.readEntry( "AnimateJump", true );
- m_layout = new QGraphicsProxyWidget( this );
- m_openGL = false;
- //bool setting_opengl = config.readEntry( "OpenGL", false );
- //if (QGLFormat::hasOpenGL() && setting_opengl) m_openGL = true;
-
- m_pictureflow = new PhotoBrowser(0,m_openGL);
- m_layout->setWidget( m_pictureflow );
-
- m_pictureflow->setRenderHints( QPainter::HighQualityAntialiasing | \
QPainter::SmoothPixmapTransform );
-
- m_pictureflow->show();
-
- Collections::Collection *coll = \
CollectionManager::instance()->primaryCollection();
- Collections::QueryMaker *qm = coll->queryMaker();
- qm->setAutoDelete( true );
- qm->setQueryType( Collections::QueryMaker::Album );
- qm->orderBy( Meta::valArtist );
-
- connect( qm, SIGNAL( newResultReady( QString, Meta::AlbumList ) ),
- this, SLOT( slotAlbumQueryResult( QString, Meta::AlbumList ) ) );
- qm->run();
-
- m_label = new QGraphicsSimpleTextItem( this );
- m_label->setBrush( QBrush( Qt::white ) );
- QFont labelFont;
- QFont bigFont( labelFont );
- bigFont.setPointSize( bigFont.pointSize() + 4 );
- m_label->setFont( labelFont );
-
- m_ratingWidget = new RatingWidget( this );
- m_ratingWidget->setRating( 0 );
- m_ratingWidget->setEnabled( false );
-
- // Construct icon widgets
- m_blingtofirst = new Plasma::IconWidget( this );
- m_blingtofirst->setIcon( KStandardDirs::locate( "data", \
"amarok/images/blingtofirst.png" ) );
- m_blingtofirst->setMaximumSize( 16.0, 16.0 );
- m_blingtofirst->setToolTip( i18n( "Jump to First" ) );
-
- m_blingtolast = new Plasma::IconWidget( this );
- m_blingtolast->setIcon( KStandardDirs::locate( "data", \
"amarok/images/blingtolast.png" ) );
- m_blingtolast->setMaximumSize( 16.0, 16.0 );
- m_blingtolast->setToolTip( i18n( "Jump to Last" ) );
-
- m_blingfastback = new Plasma::IconWidget( this );
- m_blingfastback->setIcon( KStandardDirs::locate( "data", \
"amarok/images/blingfastback.png" ) );
- m_blingfastback->setMaximumSize( 16.0, 16.0 );
- m_blingfastback->setToolTip( i18n( "Fast Backward" ) );
-
- m_blingfastforward = new Plasma::IconWidget( this );
- m_blingfastforward->setIcon( KStandardDirs::locate( "data", \
"amarok/images/blingfastforward.png" ) );
- m_blingfastforward->setMaximumSize( 16.0, 16.0 );
- m_blingfastforward->setToolTip( i18n( "Fast Forward" ) );
-
- m_fullscreen = new Plasma::IconWidget( this );
- m_fullscreen->setIcon( KStandardDirs::locate( "data", \
"amarok/images/blingfullscreen.png" ) );
- m_fullscreen->setMaximumSize( 16.0, 16.0 );
- m_fullscreen->setToolTip( i18n( "Maximize/Minimize" ) );
-
- m_jumptoplaying = new Plasma::IconWidget( this );
- m_jumptoplaying->setIcon( KStandardDirs::locate( "data", \
"amarok/images/blingjumptoplaying.png" ) );
- m_jumptoplaying->setMaximumSize( 16.0, 16.0 );
- m_jumptoplaying->setToolTip( i18n( "Jump to Current" ) );
-
- constraintsEvent();
-}
-
-CoverBlingApplet::~CoverBlingApplet()
-{
- delete m_ratingWidget;
- delete m_label;
- delete m_layout;
-}
-
-void CoverBlingApplet::slotAlbumQueryResult( QString collectionId, Meta::AlbumList \
albums ) //SLOT
-{
- DEBUG_BLOCK
- Q_UNUSED( collectionId );
-
- m_pictureflow->fillAlbums( albums );
-
- connect( m_pictureflow, SIGNAL( centerIndexChanged( int ) ), this, SLOT( \
slideChanged( int ) ) );
- connect( m_pictureflow, SIGNAL( doubleClicked( int ) ), this, SLOT( appendAlbum( \
int ) ) );
- connect( m_blingtofirst, SIGNAL( clicked() ), this, SLOT( skipToFirst() ) );
- connect( m_blingtolast, SIGNAL( clicked() ), this, SLOT( skipToLast() ) );
- connect( m_blingfastback, SIGNAL( clicked() ), m_pictureflow, SLOT( \
fastBackward() ) );
- connect( m_blingfastforward, SIGNAL( clicked() ), m_pictureflow, SLOT( \
fastForward() ) );
- connect( m_fullscreen, SIGNAL( clicked() ), this, SLOT( toggleFullscreen() ) );
- connect( m_jumptoplaying, SIGNAL( clicked() ), this, SLOT( jumpToPlaying() ) );
-}
-
-void CoverBlingApplet::slideChanged( int islideindex )
-{
- Meta::AlbumPtr album = m_pictureflow->album( islideindex );
- if ( album )
- {
- Meta::ArtistPtr artist = album->albumArtist();
- QString label = album->prettyName();
- if ( artist ) label += " - " + artist->prettyName();
- m_label->setText( label );
-
- //center the label
- m_label->setPos( ( size().width() - m_label->boundingRect().width() ) / 2, \
m_label->y() );
-
- m_label->show();
- int nbtracks = 0;
- int rating = 0;
-
- foreach( Meta::TrackPtr track, album->tracks() )
- {
- nbtracks++;
- if ( track )
- rating += track->rating();
- }
-
- if ( nbtracks )
- rating = rating / nbtracks;
-
- m_ratingWidget->setRating( rating );
- }
-}
-
-void CoverBlingApplet::appendAlbum( int islideindex )
-{
- Meta::AlbumPtr album = m_pictureflow->album( islideindex );
- if ( album )
- {
- The::playlistController()->insertOptioned( album->tracks(), \
Playlist::AppendAndPlay );
- }
-
-}
-void CoverBlingApplet::constraintsEvent( Plasma::Constraints constraints )
-{
- Q_UNUSED( constraints )
-
- prepareGeometryChange();
- const int vertical_size = boundingRect().height();
- const int horizontal_size = boundingRect().width();
- QSize slideSize( vertical_size / 2, vertical_size / 2 );
-
- if ( !m_fullsize )
- {
- slideSize.setWidth( m_coversize );
- slideSize.setHeight( m_coversize );
- }
-
- m_pictureflow->setSlideSize( slideSize );
- m_pictureflow->setReflectionEffect( m_reflectionEffect );
- m_pictureflow->setAnimationTime( 10 );
- m_ratingWidget->setSpacing( 2 );
- m_ratingWidget->setPos( horizontal_size / 2 - 40, vertical_size - 30 );
- m_label ->setPos( horizontal_size / 2 - 40, vertical_size - 50 );
-
- m_blingtofirst->setPos( 20, vertical_size - 30 );
- m_blingtolast->setPos( horizontal_size - 30, vertical_size - 30 );
- m_blingfastback->setPos( 50, vertical_size - 30 );
- m_blingfastforward->setPos( horizontal_size - 60, vertical_size - 30 );
- m_fullscreen->setPos( horizontal_size - 30, 30 );
- m_jumptoplaying->setPos( horizontal_size - 60, 30 );
-
- m_pictureflow->resize( horizontal_size, vertical_size );
-
- m_label->setPos( ( size().width() - m_label->boundingRect().width() ) / 2, \
m_label->y() );
-}
-
-void
-CoverBlingApplet::paintInterface( QPainter *p, const QStyleOptionGraphicsItem \
*option, const QRect &contentsRect )
-{
- Q_UNUSED( p );
- Q_UNUSED( option );
- Q_UNUSED( contentsRect );
-
- p->setRenderHint( QPainter::Antialiasing );
- // tint the whole applet
- addGradientToAppletBackground( p );
-}
-
-void CoverBlingApplet::toggleFullscreen()
-{
- if ( m_fullsize )
- {
- resize( -1, 400 );
- }
- else
- {
- //QDesktopWidget* desktop = QApplication::desktop();
- //if (desktop)
- {
- // QRect rect = desktop->screenGeometry();
- // resize(rect.width(),rect.height());
- resize( -1, -1 );
- }
- }
- updateConstraints();
- //constraintsEvent();
- m_fullsize = !m_fullsize;
-}
-
-void CoverBlingApplet::createConfigurationInterface( KConfigDialog *parent )
-{
- KConfigGroup configuration = config();
- QWidget * const settings = new QWidget;
- ui_Settings.setupUi( settings );
-
- if ( m_reflectionEffect == PictureFlow::NoReflection )
- ui_Settings.reflectionEffectCombo->setCurrentIndex( 0 );
- else if ( m_reflectionEffect == PictureFlow::PlainReflection )
- ui_Settings.reflectionEffectCombo->setCurrentIndex( 1 );
- else if ( m_reflectionEffect == PictureFlow::BlurredReflection )
- ui_Settings.reflectionEffectCombo->setCurrentIndex( 2 );
- if ( m_coversize )
- ui_Settings.coversizeSpin->setValue( m_coversize );
- ui_Settings.autoJumpChk->setChecked( m_autojump );
- ui_Settings.animJumpChk->setChecked( m_animatejump );
- //if (m_openGL) ui_Settings.renderingCombo->setCurrentIndex(1);
- //else ui_Settings.renderingCombo->setCurrentIndex(0);
- parent->addPage( settings, i18n( "Coverbling Settings" ), "preferences-system" \
);
- connect( parent, SIGNAL( accepted() ), this, SLOT( saveSettings( ) ) );
-}
-
-void CoverBlingApplet::saveSettings()
-{
- m_coversize = ui_Settings.coversizeSpin->value();
- if ( ui_Settings.reflectionEffectCombo->currentIndex() == 0 )
- m_reflectionEffect = PictureFlow::NoReflection;
- else if ( ui_Settings.reflectionEffectCombo->currentIndex() == 1 )
- m_reflectionEffect = PictureFlow::PlainReflection;
- else if ( ui_Settings.reflectionEffectCombo->currentIndex() == 2 )
- m_reflectionEffect = PictureFlow::BlurredReflection;
- //if (ui_Settings.renderingCombo->currentIndex()==1)
- //m_openGL = true;
- //else
- //m_openGL = false;
- m_autojump = ui_Settings.autoJumpChk->isChecked();
- m_animatejump = ui_Settings.animJumpChk->isChecked();
- KConfigGroup config = Amarok::config( "CoverBling Applet" );
- config.writeEntry( "CoverSize", m_coversize );
- config.writeEntry( "ReflectionEffect", ( int ) m_reflectionEffect );
- config.writeEntry( "AutoJump", m_autojump );
- config.writeEntry( "AnimateJump", m_animatejump );
- //config.writeEntry( "OpenGL", (int) m_openGL );
-
- constraintsEvent();
-}
-
-void CoverBlingApplet::jumpToPlaying()
-{
- Meta::TrackPtr track = The::engineController()->currentTrack();
-
- if ( !track )
- return;
- Meta::AlbumPtr album = track->album();
- if ( !album )
- return;
- int center = m_pictureflow->centerIndex();
- if ( m_pictureflow->album( center ) == album )
- return;
- int nbslides = m_pictureflow->slideCount();
- bool found = false;
- int index = 0;
- if (nbslides > 0)
- {
- for ( int i = 0; i < nbslides;i++ )
- {
- Meta::AlbumPtr current_album = m_pictureflow->album( i );
- if ( current_album == album )
- {
- index = i;
- found = true;
- break;
- }
- }
- if ( found )
- {
- if ( m_animatejump )
- {
- if ( center - index > 10 || index - center > 10 )
- {
- if ( index > center )
- m_pictureflow->skipToSlide( index - 10 );
- else
- m_pictureflow->skipToSlide( index + 10 );
- }
- m_pictureflow->showSlide( index );
- }
- else
- m_pictureflow->skipToSlide( index );
- slideChanged( index );
- }
- }
-}
-
-void CoverBlingApplet::engineNewTrackPlaying( )
-{
- if ( m_autojump )
- {
- jumpToPlaying();
- }
-}
-
-void CoverBlingApplet::skipToFirst()
-{
- m_pictureflow->skipToSlide( 0 );
- slideChanged( 0 );
-}
-
-void CoverBlingApplet::skipToLast()
-{
- int nbslides = m_pictureflow->slideCount();
- m_pictureflow->skipToSlide( nbslides - 1 );
- slideChanged( nbslides - 1 );
-}
-
-#include "CoverBlingApplet.moc"
-
diff --git a/src/context/applets/coverbling/CoverBlingApplet.h \
b/src/context/applets/coverbling/CoverBlingApplet.h deleted file mode 100644
index 893165b..0000000
--- a/src/context/applets/coverbling/CoverBlingApplet.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************************
- * Copyright (c) 2009 Simon Esneault <simon.esneault@gmail.com> \
*
- * Copyright (c) 2010 Emmanuel Wagner <manu.wagner@sfr.fr> \
*
- * Copyright (c) 2010 Mark Kretschmann <kretschmann@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, see <http://www.gnu.org/licenses/>. \
*
- ****************************************************************************************/
-
-//Plasma applet for showing photos from flickr
-
-#ifndef COVERBLING_APPLET_H
-#define COVERBLING_APPLET_H
-
-#include "context/Applet.h"
-#include "context/DataEngine.h"
-#include "core/engine/EngineObserver.h"
-#include "PhotoBrowser.h"
-#include "ui_coverblingSettings.h"
-
-class TextScrollingWidget;
-class KConfigDialog;
-class PhotosScrollWidget;
-class QGraphicsSimpleTextItem;
-class QGraphicsProxyWidget;
-class RatingWidget;
-class QGraphicsPixmapItem;
-
-namespace Plasma
-{
- class IconWidget;
-}
-
-class CoverBlingApplet : public Context::Applet, public Engine::EngineObserver
-{
- Q_OBJECT
-
- public:
- CoverBlingApplet( QObject* parent, const QVariantList& args );
- ~CoverBlingApplet();
-
- void init();
- void paintInterface( QPainter *painter, const QStyleOptionGraphicsItem \
*option, const QRect &contentsRect );
-
- // inherited from EngineObserver
- virtual void engineNewTrackPlaying();
-
- public slots:
- void slotAlbumQueryResult( QString collectionId, Meta::AlbumList albums);
- void slideChanged( int islideindex );
- void appendAlbum( int islideindex );
- void toggleFullscreen();
- void jumpToPlaying();
- void saveSettings();
- void skipToFirst();
- void skipToLast();
-
- protected :
- virtual void constraintsEvent( Plasma::Constraints constraints = \
Plasma::AllConstraints );
- void createConfigurationInterface(KConfigDialog *parent);
-
- private:
- PhotoBrowser * m_pictureflow;
- QGraphicsProxyWidget * m_layout;
- RatingWidget* m_ratingWidget;
- QGraphicsSimpleTextItem* m_label;
-
- Plasma::IconWidget* m_blingtofirst;
- Plasma::IconWidget* m_blingtolast;
- Plasma::IconWidget* m_blingfastback;
- Plasma::IconWidget* m_blingfastforward;
- Plasma::IconWidget* m_fullscreen;
- Plasma::IconWidget* m_jumptoplaying;
-
- bool m_fullsize;
- bool m_autojump;
- bool m_animatejump;
- Ui::coverblingSettings ui_Settings;
- int m_coversize;
- PictureFlow::ReflectionEffect m_reflectionEffect;
- bool m_openGL;
-};
-
-K_EXPORT_AMAROK_APPLET( coverbling, CoverBlingApplet )
-
-#endif /* COVERBLING_APPLET_H */
diff --git a/src/context/applets/coverbling/ImageLoader.cpp \
b/src/context/applets/coverbling/ImageLoader.cpp deleted file mode 100644
index 090b780..0000000
--- a/src/context/applets/coverbling/ImageLoader.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/* PhotoFlow - animated image viewer for mobile devices
- *
- * Copyright (C) 2008 Ariya Hidayat (ariya.hidayat@gmail.com)
- * Copyright (C) 2007 Ariya Hidayat (ariya.hidayat@gmail.com)
- *
- * 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 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA
- *
- */
-
-#include "ImageLoader.h"
-#include <qimage.h>
-#include <QPixmap>
-#include <KStandardDirs>
-// load and resize image
-
-
-ImageLoader::ImageLoader(): QThread(),
- restart( false ), working( false ), idx( -1 )
-{
-}
-
-ImageLoader::~ImageLoader()
-{
- mutex.lock();
- condition.wakeOne();
- mutex.unlock();
- wait();
-}
-
-bool ImageLoader::busy() const
-{
- return isRunning() ? working : false;
-}
-
-void ImageLoader::generate( int index, Meta::AlbumPtr iAlbum, QSize size )
-{
- mutex.lock();
- this->idx = index;
- this->m_album = iAlbum;
- this->size = size;
- mutex.unlock();
-
- if ( !isRunning() )
- start();
- else
- {
- // already running, wake up whenever ready
- restart = true;
- condition.wakeOne();
- }
-}
-
-void ImageLoader::run()
-{
- for ( ;; )
- {
- // copy necessary data
- mutex.lock();
- this->working = true;
- Meta::AlbumPtr album_ptr = this->m_album;
- QSize size = this->size;
- mutex.unlock();
-
- QImage image = PlainImageLoader::loadAndResize( album_ptr, size );
-
- // let everyone knows it is ready
- mutex.lock();
- this->working = false;
- this->img = image;
- mutex.unlock();
-
- // put to sleep
- mutex.lock();
- if ( !this->restart )
- condition.wait( &mutex );
- restart = false;
- mutex.unlock();
- }
-}
-
-PlainImageLoader::PlainImageLoader(): idx( -1 )
-{
-}
-
-void PlainImageLoader::generate( int index, Meta::AlbumPtr iAlbum, QSize size )
-{
- img = loadAndResize( iAlbum, size );
- idx = index;
-}
-QPixmap PlainImageLoader::GetPixmap(Meta::AlbumPtr iAlbum)
-{
- QPixmap pixmap;
- if ( iAlbum->hasImage() )
- {
- pixmap = iAlbum->image();
- }
- else
- {
- pixmap = QPixmap( KStandardDirs::locate( "data", \
"amarok/images/blingdefaultcover.png" ) );
- }
- return pixmap;
-}
-QImage PlainImageLoader::loadAndResize( Meta::AlbumPtr iAlbum, QSize size )
-{
- //qDebug() << <<"ImageLoader::loadAndresize()";
- QImage image;
- QPixmap pixmap = GetPixmap(iAlbum);
- image = pixmap.toImage();
- image = image.scaled( size, Qt::KeepAspectRatio, Qt::SmoothTransformation );
- return image;
-}
diff --git a/src/context/applets/coverbling/ImageLoader.h \
b/src/context/applets/coverbling/ImageLoader.h deleted file mode 100644
index 9a9d51b..0000000
--- a/src/context/applets/coverbling/ImageLoader.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* PhotoFlow - animated image viewer for mobile devices
- *
- * Copyright (C) 2008 Ariya Hidayat (ariya.hidayat@gmail.com)
- * Copyright (C) 2007 Ariya Hidayat (ariya.hidayat@gmail.com)
- *
- * 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 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA
- *
- */
-
-#ifndef IMAGE_THUMBNAIL_H
-#define IMAGE_THUMBNAIL_H
-#include <qimage.h>
-#include <qobject.h>
-#include <qsize.h>
-#include <qthread.h>
-
-#include <qmutex.h>
-#include <qwaitcondition.h>
-
-#include "core/meta/Meta.h"
-class ImageLoader : public QThread
-{
-public:
- ImageLoader();
-
- ~ImageLoader();
-
- // returns FALSE if worker is still busy and can't take the task
- bool busy() const;
-
- void generate(int index, Meta::AlbumPtr iAlbum, QSize size);
-
- int index() const { return idx; }
-
- QImage result() const { return img; }
-
-protected:
- void run();
-
-private:
- QMutex mutex;
- QWaitCondition condition;
-
- bool restart;
- bool working;
- int idx;
- Meta::AlbumPtr m_album;
- QSize size;
- QImage img;
-};
-
-class PlainImageLoader
-{
-public:
- PlainImageLoader();
-
- bool busy() const { return false; }
-
- void generate(int index, Meta::AlbumPtr iAlbum, QSize size);
-
- int index() const { return idx; }
-
- QImage result() const { return img; }
-
- static QPixmap GetPixmap( Meta::AlbumPtr iAlbum);
- static QImage loadAndResize( Meta::AlbumPtr iAlbum, QSize size );
-private:
- int idx;
- QImage img;
-};
-#endif // IMAGE_THUMBNAIL_H
-
diff --git a/src/context/applets/coverbling/PhotoBrowser.cpp \
b/src/context/applets/coverbling/PhotoBrowser.cpp deleted file mode 100644
index 856e9c2..0000000
--- a/src/context/applets/coverbling/PhotoBrowser.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/* PhotoFlow - animated image viewer for mobile devices
- *
- * Copyright (C) 2008 Ariya Hidayat (ariya.hidayat@gmail.com)
- * Copyright (C) 2007 Ariya Hidayat (ariya.hidayat@gmail.com)
- *
- * 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 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA
- *
- */
-
-#include "PhotoBrowser.h"
-
-#include "ImageLoader.h"
-#include "pictureflow.h"
-
-#include <QDir>
-#include <QImage>
-#include <QImageReader>
-#include <QTimer>
-#include "core/meta/Meta.h"
-
-#define ImageLoader PlainImageLoader
-
-class PhotoBrowser::Private
-{
-public:
- QString imagePath;
- QTimer* updateTimer;
- ImageLoader* worker;
-};
-
-PhotoBrowser::PhotoBrowser( QWidget* parent, bool enableOpenGL ): PictureFlow( \
parent,enableOpenGL)
-{
- d = new Private;
-
- d->updateTimer = new QTimer;
- connect( d->updateTimer, SIGNAL( timeout() ), this, SLOT( updateImageData() ) );
- d->worker = new ImageLoader;
- connect( this, SIGNAL( centerIndexChanged( int ) ), this, SLOT( preload() ) );
- m_opengl = enableOpenGL;
-}
-
-PhotoBrowser::~PhotoBrowser()
-{
- delete d->worker;
- delete d->updateTimer;
- delete d;
-}
-void PhotoBrowser::fillAlbums( Meta::AlbumList albums )
-{
- if (m_opengl)
- setAlbums(albums);
- else
- {
- foreach( Meta::AlbumPtr album, albums )
- {
- addAlbum( album );
- addSlide( QImage() );
- }
- setCenterIndex( 0 );
- preload();
- }
-}
-void PhotoBrowser::preload()
-{
- d->updateTimer->start( 100 );
-}
-
-void PhotoBrowser::updateImageData()
-{
- // can't do anything, wait for the next possibility
- if ( d->worker->busy() )
- return;
-
- // set image of last one
- if ( d->worker->index() >= 0 )
- setSlide( d->worker->index(), d->worker->result() );
-
- // try to load only few images on the left and right side
- // i.e. all visible ones plus some extra
-#define COUNT 10
- int indexes[2*COUNT+1];
- int center = centerIndex();
- indexes[0] = center;
- for ( int j = 0; j < COUNT; j++ )
- {
- indexes[j*2+1] = center + j + 1;
- indexes[j*2+2] = center - j - 1;
- }
-
- for ( int c = 0; c < 2*COUNT + 1; c++ )
- {
- int i = indexes[c];
- if (( i >= 0 ) && ( i < slideCount() ) )
- if ( slide( i ).isNull() )
- {
- // schedule thumbnail generation
- Meta::AlbumPtr iAlbum = m_album_list[i];
- d->worker->generate( i, iAlbum, slideSize() );
- return;
- }
- }
-
- // no need to generate anything? stop polling...
- d->updateTimer->stop();
-}
-void PhotoBrowser::fastForward()
-{
- int nbslides = slideCount();
- int current = centerIndex();
- showSlide( current + nbslides / 10 );
-}
-void PhotoBrowser::fastBackward()
-{
- int nbslides = slideCount();
- int current = centerIndex();
- showSlide( current - nbslides / 10 );
-}
-void PhotoBrowser::skipToSlide( int iSlide )
-{
- setCenterIndex( iSlide );
- preload();
-}
diff --git a/src/context/applets/coverbling/PhotoBrowser.h \
b/src/context/applets/coverbling/PhotoBrowser.h deleted file mode 100644
index eecbe71..0000000
--- a/src/context/applets/coverbling/PhotoBrowser.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* PhotoFlow - animated image viewer for mobile devices
- *
- * Copyright (C) 2008 Ariya Hidayat (ariya.hidayat@gmail.com)
- * Copyright (C) 2007 Ariya Hidayat (ariya.hidayat@gmail.com)
- *
- * 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 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA
- *
- */
-
-#ifndef PHOTO_BROWSER_H
-#define PHOTO_BROWSER_H
-
-#include "pictureflow.h"
-#include "core/meta/Meta.h"
-
-class PhotoBrowser: public PictureFlow
-{
- Q_OBJECT
-
-public:
- explicit PhotoBrowser(QWidget* parent = 0, bool enableOpenGL = false);
- virtual ~PhotoBrowser();
-
- void fillAlbums(Meta::AlbumList albums);
-public slots:
- void fastForward();
- void fastBackward();
- void skipToSlide(int iSlide);
-private slots:
- void preload();
- void updateImageData();
-
-private:
- class Private;
- Private *d;
-};
-
-#endif // PHOTO_BROWSER_H
-
diff --git a/src/context/applets/coverbling/amarok-context-applet-coverbling.desktop \
b/src/context/applets/coverbling/amarok-context-applet-coverbling.desktop deleted \
file mode 100644 index 6772e71..0000000
--- a/src/context/applets/coverbling/amarok-context-applet-coverbling.desktop
+++ /dev/null
@@ -1,45 +0,0 @@
-[Desktop Entry]
-Encoding=UTF-8
-Name=CoverBling
-Name[ca]=CoverBling
-Name[ca@valencia]=CoverBling
-Name[cs]=CoverBling
-Name[da]=CoverBling
-Name[de]=CoverBling
-Name[en_GB]=CoverBling
-Name[es]=CoverBling
-Name[et]=CoverBling
-Name[is]=CoverBling
-Name[it]=CoverBling
-Name[ja]=CoverBling
-Name[km]=CoverBling
-Name[nb]=CoverBling
-Name[nds]=CoverBling
-Name[nl]=CoverBling
-Name[pt]=Capas
-Name[pt_BR]=Capas
-Name[ru]=Обложки
-Name[sl]=CoverBling
-Name[sr]=Омотација
-Name[sr@ijekavian]=Омотација
-Name[sr@ijekavianlatin]=Omotacija
-Name[sr@latin]=Omotacija
-Name[sv]=Omslagsutsmyckning
-Name[uk]=CoverBling
-Name[x-test]=xxCoverBlingxx
-Name[zh_TW]=CoverBling
-Type=Service
-ServiceTypes=Plasma/Applet
-
-X-KDE-Library=amarok_context_applet_coverbling
-X-KDE-PluginInfo-Author=manuw2009
-X-KDE-PluginInfo-Email=manu.wagner@sfr.fr
-X-KDE-PluginInfo-Name=coverbling
-X-KDE-PluginInfo-Version=0.10
-X-KDE-PluginInfo-Website=
-X-KDE-PluginInfo-Category=
-X-KDE-PluginInfo-Depends=
-X-KDE-PluginInfo-License=GPL
-X-KDE-PluginInfo-EnabledByDefault=true
-X-KDE-ParentApp=amarok
-X-KDE-PluginInfo-Category=Current
diff --git a/src/context/applets/coverbling/blingdefaultcover.png \
b/src/context/applets/coverbling/blingdefaultcover.png deleted file mode 100644
index caa4389..0000000
Binary files a/src/context/applets/coverbling/blingdefaultcover.png and /dev/null \
differ
diff --git a/src/context/applets/coverbling/blingfastback.png \
b/src/context/applets/coverbling/blingfastback.png deleted file mode 100644
index ff45a5e..0000000
Binary files a/src/context/applets/coverbling/blingfastback.png and /dev/null differ
diff --git a/src/context/applets/coverbling/blingfastforward.png \
b/src/context/applets/coverbling/blingfastforward.png deleted file mode 100644
index b304119..0000000
Binary files a/src/context/applets/coverbling/blingfastforward.png and /dev/null \
differ
diff --git a/src/context/applets/coverbling/blingfullscreen.png \
b/src/context/applets/coverbling/blingfullscreen.png deleted file mode 100644
index 7f67b7f..0000000
Binary files a/src/context/applets/coverbling/blingfullscreen.png and /dev/null \
differ
diff --git a/src/context/applets/coverbling/blingjumptoplaying.png \
b/src/context/applets/coverbling/blingjumptoplaying.png deleted file mode 100644
index d1ac7d9..0000000
Binary files a/src/context/applets/coverbling/blingjumptoplaying.png and /dev/null \
differ
diff --git a/src/context/applets/coverbling/blingtofirst.png \
b/src/context/applets/coverbling/blingtofirst.png deleted file mode 100644
index a8aa79e..0000000
Binary files a/src/context/applets/coverbling/blingtofirst.png and /dev/null differ
diff --git a/src/context/applets/coverbling/blingtolast.png \
b/src/context/applets/coverbling/blingtolast.png deleted file mode 100644
index 26a5cf5..0000000
Binary files a/src/context/applets/coverbling/blingtolast.png and /dev/null differ
diff --git a/src/context/applets/coverbling/coverblingSettings.ui \
b/src/context/applets/coverbling/coverblingSettings.ui deleted file mode 100644
index 8da5975..0000000
--- a/src/context/applets/coverbling/coverblingSettings.ui
+++ /dev/null
@@ -1,78 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>coverblingSettings</class>
- <widget class="QWidget" name="coverblingSettings">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>265</width>
- <height>146</height>
- </rect>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <property name="labelAlignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
- </property>
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Reflection effect</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QComboBox" name="reflectionEffectCombo">
- <item>
- <property name="text">
- <string>None</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Plain</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Blurred</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Cover size (pixels)</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QSpinBox" name="coversizeSpin">
- <property name="minimum">
- <number>10</number>
- </property>
- <property name="maximum">
- <number>500</number>
- </property>
- </widget>
- </item>
- <item row="2" column="0" colspan="2">
- <widget class="QCheckBox" name="autoJumpChk">
- <property name="text">
- <string>Auto jump to playing</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0" colspan="2">
- <widget class="QCheckBox" name="animJumpChk">
- <property name="text">
- <string>Animated jump</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/src/context/applets/coverbling/pictureflow.cpp \
b/src/context/applets/coverbling/pictureflow.cpp deleted file mode 100644
index 905bec7..0000000
--- a/src/context/applets/coverbling/pictureflow.cpp
+++ /dev/null
@@ -1,1169 +0,0 @@
-/*
- PictureFlow - animated image show widget
- http://pictureflow.googlecode.com
- Copyright (C) 2010 Emmanuel Wagner (manu.wagner@sfr.fr)
- Ariya's code modifications for amarok
- Copyright (C) 2008 Ariya Hidayat (ariya@kde.org)
- Copyright (C) 2007 Ariya Hidayat (ariya@kde.org)
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-*/
-#include "pictureflow.h"
-
-#include <QApplication>
-#include <QCache>
-#include <QHash>
-#include <QImage>
-#include <QKeyEvent>
-#include <QPainter>
-#include <QPixmap>
-#include <QTimer>
-#include <QVector>
-#include <QWidget>
-#include <KStandardDirs>
-
-#include <QGraphicsView>
-#include <QFrame>
-
-// for fixed-point arithmetic, we need minimum 32-bit long
-// long long (64-bit) might be useful for multiplication and division
-typedef long PFreal;
-#define PFREAL_SHIFT 10
-#define PFREAL_ONE (1 << PFREAL_SHIFT)
-
-#define IANGLE_MAX 1024
-#define IANGLE_MASK 1023
-
-inline PFreal fmul( PFreal a, PFreal b )
-{
- return (( long long )( a ) )*(( long long )( b ) ) >> PFREAL_SHIFT;
-}
-
-inline PFreal fdiv( PFreal num, PFreal den )
-{
- long long p = ( long long )( num ) << ( PFREAL_SHIFT * 2 );
- long long q = p / ( long long )den;
- long long r = q >> PFREAL_SHIFT;
-
- return r;
-}
-
-inline PFreal fsin( int iangle )
-{
- // warning: regenerate the table if IANGLE_MAX and PFREAL_SHIFT are changed!
- static const PFreal tab[] =
- {
- 3, 103, 202, 300, 394, 485, 571, 652,
- 726, 793, 853, 904, 947, 980, 1004, 1019,
- 1023, 1018, 1003, 978, 944, 901, 849, 789,
- 721, 647, 566, 479, 388, 294, 196, 97,
- -4, -104, -203, -301, -395, -486, -572, -653,
- -727, -794, -854, -905, -948, -981, -1005, -1020,
- -1024, -1019, -1004, -979, -945, -902, -850, -790,
- -722, -648, -567, -480, -389, -295, -197, -98,
- 3
- };
-
- while ( iangle < 0 )
- iangle += IANGLE_MAX;
- iangle &= IANGLE_MASK;
-
- int i = ( iangle >> 4 );
- PFreal p = tab[i];
- PFreal q = tab[( i+1 )];
- PFreal g = ( q - p );
- return p + g * ( iangle - i*16 ) / 16;
-}
-
-inline PFreal fcos( int iangle )
-{
- return fsin( iangle + ( IANGLE_MAX >> 2 ) );
-}
-
-/* ----------------------------------------------------------
-
-PictureFlowState stores the state of all slides, i.e. all the necessary
-information to be able to render them.
-
-PictureFlowAnimator is responsible to move the slides during the
-transition between slides, to achieve the effect similar to Cover Flow,
-by changing the state.
-
-PictureFlowSoftwareRenderer (or PictureFlowOpenGLRenderer) is
-the actual 3-d renderer. It should render all slides given the state
-(an instance of PictureFlowState).
-
-Instances of all the above three classes are stored in
-PictureFlowPrivate.
-
-------------------------------------------------------- */
-
-struct SlideInfo
-{
- int slideIndex;
- int angle;
- PFreal cx;
- PFreal cy;
- int blend;
-};
-
-class PictureFlowState
-{
-public:
- PictureFlowState();
- ~PictureFlowState();
-
- void reposition();
- void reset();
-
- QRgb backgroundColor;
- int slideWidth;
- int slideHeight;
- PictureFlow::ReflectionEffect reflectionEffect;
- QVector<QImage*> slideImages;
-
- int angle;
- int spacing;
- PFreal offsetX;
- PFreal offsetY;
-
- SlideInfo centerSlide;
- QVector<SlideInfo> leftSlides;
- QVector<SlideInfo> rightSlides;
- int centerIndex;
-};
-
-class PictureFlowAnimator
-{
-public:
- PictureFlowAnimator();
- PictureFlowState* state;
-
- void start( int slide );
- void stop( int slide );
- void update();
-
- int target;
- int step;
- int frame;
- QTimer animateTimer;
- int animationDuration;
-};
-
-class PictureFlowAbstractRenderer
-{
-public:
- PictureFlowAbstractRenderer(): state( 0 ), dirty( false ), widget( 0 ) {}
- virtual ~PictureFlowAbstractRenderer() {}
-
- PictureFlowState* state;
- bool dirty;
- QWidget* widget;
- QPainter::RenderHints render_hints;
- virtual void init() = 0;
- virtual void paint() = 0;
-};
-
-class PictureFlowSoftwareRenderer: public PictureFlowAbstractRenderer
-{
-public:
- PictureFlowSoftwareRenderer();
- ~PictureFlowSoftwareRenderer();
-
- virtual void init();
- virtual void paint();
-
-private:
- QSize size;
- QRgb bgcolor;
- int effect;
- QImage buffer;
- QVector<PFreal> rays;
- QImage* blankSurface;
- QCache<int, QImage> surfaceCache;
- QHash<int, QImage*> imageHash;
-
- void render();
- void renderSlides();
- QRect renderSlide( const SlideInfo &slide, int col1 = -1, int col2 = -1 );
- QImage* surface( int slideIndex );
-};
-
-class PictureFlowOpenGLRenderer: public PictureFlowAbstractRenderer
-{
-public:
- PictureFlowOpenGLRenderer();
- ~PictureFlowOpenGLRenderer();
- void init();
- void paint();
-private :
- QSize size;
- QRgb bgcolor;
- int effect;
- QImage* blankSurface;
-};
-
-PictureFlowOpenGLRenderer::PictureFlowOpenGLRenderer():
- PictureFlowAbstractRenderer(), size( 0, 0 ), bgcolor( 0 ), effect( -1 ), \
blankSurface( 0 )
-{
-}
-PictureFlowOpenGLRenderer::~PictureFlowOpenGLRenderer()
-{
-}
-void PictureFlowOpenGLRenderer::init()
-{
-}
-void PictureFlowOpenGLRenderer::paint()
-{
-}
-// ------------- PictureFlowState ---------------------------------------
-
-PictureFlowState::PictureFlowState():
- backgroundColor( 0 ), slideWidth( 150 ), slideHeight( 200 ),
- reflectionEffect( PictureFlow::BlurredReflection ), centerIndex( 0 )
-{
-}
-
-PictureFlowState::~PictureFlowState()
-{
- for ( int i = 0; i < ( int )slideImages.count(); i++ )
- delete slideImages[i];
-}
-
-// readjust the settings, call this when slide dimension is changed
-void PictureFlowState::reposition()
-{
- angle = 70 * IANGLE_MAX / 360; // approx. 70 degrees tilted
-
- offsetX = slideWidth / 2 * ( PFREAL_ONE - fcos( angle ) );
- offsetY = slideWidth / 2 * fsin( angle );
- offsetX += slideWidth * PFREAL_ONE;
- offsetY += slideWidth * PFREAL_ONE / 4;
- spacing = 40;
-}
-
-// adjust slides so that they are in "steady state" position
-void PictureFlowState::reset()
-{
- centerSlide.angle = 0;
- centerSlide.cx = 0;
- centerSlide.cy = 0;
- centerSlide.slideIndex = centerIndex;
- centerSlide.blend = 256;
-
- leftSlides.resize( 6 );
- for ( int i = 0; i < ( int )leftSlides.count(); i++ )
- {
- SlideInfo& si = leftSlides[i];
- si.angle = angle;
- si.cx = -( offsetX + spacing * i * PFREAL_ONE );
- si.cy = offsetY;
- si.slideIndex = centerIndex - 1 - i;
- si.blend = 256;
- if ( i == ( int )leftSlides.count() - 2 )
- si.blend = 128;
- if ( i == ( int )leftSlides.count() - 1 )
- si.blend = 0;
- }
-
- rightSlides.resize( 6 );
- for ( int i = 0; i < ( int )rightSlides.count(); i++ )
- {
- SlideInfo& si = rightSlides[i];
- si.angle = -angle;
- si.cx = offsetX + spacing * i * PFREAL_ONE;
- si.cy = offsetY;
- si.slideIndex = centerIndex + 1 + i;
- si.blend = 256;
- if ( i == ( int )rightSlides.count() - 2 )
- si.blend = 128;
- if ( i == ( int )rightSlides.count() - 1 )
- si.blend = 0;
- }
-}
-
-// ------------- PictureFlowAnimator ---------------------------------------
-
-PictureFlowAnimator::PictureFlowAnimator():
- state( 0 ), target( 0 ), step( 0 ), frame( 0 ), animationDuration( 30 )
-{
-}
-
-void PictureFlowAnimator::start( int slide )
-{
- target = slide;
- if ( !animateTimer.isActive() && state )
- {
- step = ( target < state->centerSlide.slideIndex ) ? -1 : 1;
- animateTimer.start( animationDuration );
- }
-}
-
-void PictureFlowAnimator::stop( int slide )
-{
- step = 0;
- target = slide;
- frame = slide << 16;
- animateTimer.stop();
-}
-
-void PictureFlowAnimator::update()
-{
- if ( !animateTimer.isActive() )
- return;
- if ( step == 0 )
- return;
- if ( !state )
- return;
-
- int speed = 16384 / 4;
-
-#if 1
- // deaccelerate when approaching the target
- const int max = 2 * 65536;
-
- int fi = frame;
- fi -= ( target << 16 );
- if ( fi < 0 )
- fi = -fi;
- fi = qMin( fi, max );
-
- int ia = IANGLE_MAX * ( fi - max / 2 ) / ( max * 2 );
- speed = 512 + 16384 * ( PFREAL_ONE + fsin( ia ) ) / PFREAL_ONE;
-#endif
-
- frame += speed * step;
-
- int index = frame >> 16;
- int pos = frame & 0xffff;
- int neg = 65536 - pos;
- int tick = ( step < 0 ) ? neg : pos;
- PFreal ftick = ( tick * PFREAL_ONE ) >> 16;
-
- if ( step < 0 )
- index++;
-
- if ( state->centerIndex != index )
- {
- state->centerIndex = index;
- frame = index << 16;
- state->centerSlide.slideIndex = state->centerIndex;
- for ( int i = 0; i < ( int )state->leftSlides.count(); i++ )
- state->leftSlides[i].slideIndex = state->centerIndex - 1 - i;
- for ( int i = 0; i < ( int )state->rightSlides.count(); i++ )
- state->rightSlides[i].slideIndex = state->centerIndex + 1 + i;
- }
-
- state->centerSlide.angle = ( step * tick * state->angle ) >> 16;
- state->centerSlide.cx = -step * fmul( state->offsetX, ftick );
- state->centerSlide.cy = fmul( state->offsetY, ftick );
-
- if ( state->centerIndex == target )
- {
- stop( target );
- state->reset();
- return;
- }
-
- for ( int i = 0; i < ( int )state->leftSlides.count(); i++ )
- {
- SlideInfo& si = state->leftSlides[i];
- si.angle = state->angle;
- si.cx = -( state->offsetX + state->spacing * i * PFREAL_ONE + step * \
state->spacing * ftick );
- si.cy = state->offsetY;
- }
-
- for ( int i = 0; i < ( int )state->rightSlides.count(); i++ )
- {
- SlideInfo& si = state->rightSlides[i];
- si.angle = -state->angle;
- si.cx = state->offsetX + state->spacing * i * PFREAL_ONE - step * \
state->spacing * ftick;
- si.cy = state->offsetY;
- }
-
- if ( step > 0 )
- {
- PFreal ftick = ( neg * PFREAL_ONE ) >> 16;
- state->rightSlides[0].angle = -( neg * state->angle ) >> 16;
- state->rightSlides[0].cx = fmul( state->offsetX, ftick );
- state->rightSlides[0].cy = fmul( state->offsetY, ftick );
- }
- else
- {
- PFreal ftick = ( pos * PFREAL_ONE ) >> 16;
- state->leftSlides[0].angle = ( pos * state->angle ) >> 16;
- state->leftSlides[0].cx = -fmul( state->offsetX, ftick );
- state->leftSlides[0].cy = fmul( state->offsetY, ftick );
- }
-
- // must change direction ?
- if ( target < index ) if ( step > 0 )
- step = -1;
- if ( target > index ) if ( step < 0 )
- step = 1;
-
- // the first and last slide must fade in/fade out
- int nleft = state->leftSlides.count();
- int nright = state->rightSlides.count();
- int fade = pos / 256;
-
- for ( int index = 0; index < nleft; index++ )
- {
- int blend = 256;
- if ( index == nleft - 1 )
- blend = ( step > 0 ) ? 0 : 128 - fade / 2;
- if ( index == nleft - 2 )
- blend = ( step > 0 ) ? 128 - fade / 2 : 256 - fade / 2;
- if ( index == nleft - 3 )
- blend = ( step > 0 ) ? 256 - fade / 2 : 256;
- state->leftSlides[index].blend = blend;
- }
- for ( int index = 0; index < nright; index++ )
- {
- int blend = ( index < nright - 2 ) ? 256 : 128;
- if ( index == nright - 1 )
- blend = ( step > 0 ) ? fade / 2 : 0;
- if ( index == nright - 2 )
- blend = ( step > 0 ) ? 128 + fade / 2 : fade / 2;
- if ( index == nright - 3 )
- blend = ( step > 0 ) ? 256 : 128 + fade / 2;
- state->rightSlides[index].blend = blend;
- }
-
-}
-
-// ------------- PictureFlowSoftwareRenderer ---------------------------------------
-
-PictureFlowSoftwareRenderer::PictureFlowSoftwareRenderer():
- PictureFlowAbstractRenderer(), size( 0, 0 ), bgcolor( 0 ), effect( -1 ), \
blankSurface( 0 )
-{
-}
-
-PictureFlowSoftwareRenderer::~PictureFlowSoftwareRenderer()
-{
- surfaceCache.clear();
- buffer = QImage();
- delete blankSurface;
-}
-
-void PictureFlowSoftwareRenderer::paint()
-{
- if ( !widget )
- return;
-
- if ( widget->size() != size )
- init();
-
- if ( state->backgroundColor != bgcolor )
- {
- bgcolor = state->backgroundColor;
- surfaceCache.clear();
- }
-
- if (( int )( state->reflectionEffect ) != effect )
- {
- effect = ( int )state->reflectionEffect;
- surfaceCache.clear();
- }
-
- if ( dirty )
- render();
-
- QPainter painter( widget );
- painter.setRenderHints( render_hints );
- painter.drawImage( QPoint( 0, 0 ), buffer );
-}
-
-void PictureFlowSoftwareRenderer::init()
-{
- if ( !widget )
- return;
-
- surfaceCache.clear();
- blankSurface = 0;
-
- size = widget->size();
- int ww = size.width();
- int wh = size.height();
- int w = ( ww + 1 ) / 2;
- int h = ( wh + 1 ) / 2;
-
- buffer = QImage( ww, wh, QImage::Format_RGB32 );
- buffer.fill( bgcolor );
-
- rays.resize( w*2 );
- for ( int i = 0; i < w; i++ )
- {
- PFreal gg = (( PFREAL_ONE >> 1 ) + i * PFREAL_ONE ) / ( 2 * h );
- rays[w-i-1] = -gg;
- rays[w+i] = gg;
- }
-
- dirty = true;
-}
-
-// TODO: optimize this with lookup tables
-static QRgb blendColor( QRgb c1, QRgb c2, int blend )
-{
- int r = qRed( c1 ) * blend / 256 + qRed( c2 ) * ( 256 - blend ) / 256;
- int g = qGreen( c1 ) * blend / 256 + qGreen( c2 ) * ( 256 - blend ) / 256;
- int b = qBlue( c1 ) * blend / 256 + qBlue( c2 ) * ( 256 - blend ) / 256;
- return qRgb( r, g, b );
-}
-
-
-static QImage* prepareSurface( const QImage* slideImage, int w, int h, QRgb bgcolor,
- PictureFlow::ReflectionEffect reflectionEffect )
-{
-
- Qt::TransformationMode mode = Qt::SmoothTransformation;
- QImage img = slideImage->scaled( w, h, Qt::IgnoreAspectRatio, mode );
-
- // slightly larger, to accomodate for the reflection
- int hs = h * 2;
- int hofs = h / 3;
-
- // offscreen buffer: black is sweet
- QImage* result = new QImage( hs, w, QImage::Format_RGB32 );
- result->fill( bgcolor );
-
- // transpose the image, this is to speed-up the rendering
- // because we process one column at a time
- // (and much better and faster to work row-wise, i.e in one scanline)
- for ( int x = 0; x < w; x++ )
- for ( int y = 0; y < h; y++ )
- result->setPixel( hofs + y, x, img.pixel( x, y ) );
-
- if ( reflectionEffect != PictureFlow::NoReflection )
- {
- // create the reflection
- int ht = hs - h - hofs;
- int hte = ht;
- for ( int x = 0; x < w; x++ )
- for ( int y = 0; y < ht; y++ )
- {
- QRgb color = img.pixel( x, img.height() - y - 1 );
- result->setPixel( h + hofs + y, x, blendColor( color, bgcolor, 128*( \
hte - y ) / hte ) );
- }
-
- if ( reflectionEffect == PictureFlow::BlurredReflection )
- {
- // blur the reflection everything first
- // Based on exponential blur algorithm by Jani Huhtanen
- QRect rect( hs / 2, 0, hs / 2, w );
- rect &= result->rect();
-
- int r1 = rect.top();
- int r2 = rect.bottom();
- int c1 = rect.left();
- int c2 = rect.right();
-
- int bpl = result->bytesPerLine();
- int rgba[4];
- unsigned char* p;
-
- // how many times blur is applied?
- // for low-end system, limit this to only 1 loop
- for ( int loop = 0; loop < 2; loop++ )
- {
- for ( int col = c1; col <= c2; col++ )
- {
- p = result->scanLine( r1 ) + col * 4;
- for ( int i = 0; i < 3; i++ )
- rgba[i] = p[i] << 4;
-
- p += bpl;
- for ( int j = r1; j < r2; j++, p += bpl )
- for ( int i = 0; i < 3; i++ )
- p[i] = ( rgba[i] += ((( p[i] << 4 ) - rgba[i] ) ) >> 1 ) \
>> 4;
- }
-
- for ( int row = r1; row <= r2; row++ )
- {
- p = result->scanLine( row ) + c1 * 4;
- for ( int i = 0; i < 3; i++ )
- rgba[i] = p[i] << 4;
-
- p += 4;
- for ( int j = c1; j < c2; j++, p += 4 )
- for ( int i = 0; i < 3; i++ )
- p[i] = ( rgba[i] += ((( p[i] << 4 ) - rgba[i] ) ) >> 1 ) \
>> 4;
- }
-
- for ( int col = c1; col <= c2; col++ )
- {
- p = result->scanLine( r2 ) + col * 4;
- for ( int i = 0; i < 3; i++ )
- rgba[i] = p[i] << 4;
-
- p -= bpl;
- for ( int j = r1; j < r2; j++, p -= bpl )
- for ( int i = 0; i < 3; i++ )
- p[i] = ( rgba[i] += ((( p[i] << 4 ) - rgba[i] ) ) >> 1 ) \
>> 4;
- }
-
- for ( int row = r1; row <= r2; row++ )
- {
- p = result->scanLine( row ) + c2 * 4;
- for ( int i = 0; i < 3; i++ )
- rgba[i] = p[i] << 4;
-
- p -= 4;
- for ( int j = c1; j < c2; j++, p -= 4 )
- for ( int i = 0; i < 3; i++ )
- p[i] = ( rgba[i] += ((( p[i] << 4 ) - rgba[i] ) ) >> 1 ) \
>> 4;
- }
- }
-
- // overdraw to leave only the reflection blurred (but not the actual \
image)
- for ( int x = 0; x < w; x++ )
- for ( int y = 0; y < h; y++ )
- result->setPixel( hofs + y, x, img.pixel( x, y ) );
- }
- }
-
- return result;
-}
-
-QImage* PictureFlowSoftwareRenderer::surface( int slideIndex )
-{
- if ( !state )
- return 0;
- if ( slideIndex < 0 )
- return 0;
- if ( slideIndex >= ( int )state->slideImages.count() )
- return 0;
-
- int key = slideIndex;
-
- QImage* img = state->slideImages.at( slideIndex );
- bool empty = img ? img->isNull() : true;
- if ( empty )
- {
- surfaceCache.remove( key );
- imageHash.remove( slideIndex );
- if ( !blankSurface )
- {
- int sw = state->slideWidth;
- int sh = state->slideHeight;
-
- QImage img = QImage( sw, sh, QImage::Format_RGB32 );
-
- QPainter painter( &img );
- painter.setRenderHints( render_hints );
- QPoint p1( sw*4 / 10, 0 );
- QPoint p2( sw*6 / 10, sh );
- QLinearGradient linearGrad( p1, p2 );
- linearGrad.setColorAt( 0, Qt::black );
- linearGrad.setColorAt( 1, Qt::white );
- painter.setBrush( linearGrad );
- painter.fillRect( 0, 0, sw, sh, QBrush( linearGrad ) );
-
- painter.setPen( QPen( QColor( 64, 64, 64 ), 4 ) );
- painter.setBrush( QBrush() );
- painter.drawRect( 2, 2, sw - 3, sh - 3 );
- painter.end();
-
- blankSurface = prepareSurface( &img, sw, sh, bgcolor, \
state->reflectionEffect );
- }
- return blankSurface;
- }
- bool exist = imageHash.contains( slideIndex );
- if ( exist )
- if ( img == imageHash.find( slideIndex ).value() )
- if ( surfaceCache.contains( key ) )
- return surfaceCache[key];
-
- QImage* sr = prepareSurface( img, state->slideWidth, state->slideHeight, \
bgcolor, state->reflectionEffect );
- surfaceCache.insert( key, sr );
- imageHash.insert( slideIndex, img );
-
- return sr;
-}
-
-// Renders a slide to offscreen buffer. Returns a rect of the rendered area.
-// col1 and col2 limit the column for rendering.
-QRect PictureFlowSoftwareRenderer::renderSlide( const SlideInfo &slide, int col1, \
int col2 )
-{
- int blend = slide.blend;
- if ( !blend )
- return QRect();
-
- QImage* src = surface( slide.slideIndex );
- if ( !src )
- return QRect();
-
- QRect rect( 0, 0, 0, 0 );
-
- int sw = src->height();
- int sh = src->width();
- int h = buffer.height();
- int w = buffer.width();
-
- if ( col1 > col2 )
- {
- int c = col2;
- col2 = col1;
- col1 = c;
- }
-
- col1 = ( col1 >= 0 ) ? col1 : 0;
- col2 = ( col2 >= 0 ) ? col2 : w - 1;
- col1 = qMin( col1, w - 1 );
- col2 = qMin( col2, w - 1 );
-
- int zoom = 100;
- int distance = h * 100 / zoom;
- PFreal sdx = fcos( slide.angle );
- PFreal sdy = fsin( slide.angle );
- PFreal xs = slide.cx - state->slideWidth * sdx / 2;
- PFreal ys = slide.cy - state->slideWidth * sdy / 2;
- PFreal dist = distance * PFREAL_ONE;
-
- int xi = qMax(( PFreal )0, (( w * PFREAL_ONE / 2 ) + fdiv( xs * h, dist + ys ) ) \
>> PFREAL_SHIFT );
- if ( xi >= w )
- return rect;
-
- bool flag = false;
- rect.setLeft( xi );
- for ( int x = qMax( xi, col1 ); x <= col2; x++ )
- {
- PFreal hity = 0;
- PFreal fk = rays[x];
- if ( sdy )
- {
- fk = fk - fdiv( sdx, sdy );
- hity = -fdiv(( rays[x] * distance - slide.cx + slide.cy * sdx / sdy ), \
fk );
- }
-
- dist = distance * PFREAL_ONE + hity;
- if ( dist < 0 )
- continue;
-
- PFreal hitx = fmul( dist, rays[x] );
- PFreal hitdist = fdiv( hitx - slide.cx, sdx );
-
- int column = sw / 2 + ( hitdist >> PFREAL_SHIFT );
- if ( column >= sw )
- break;
- if ( column < 0 )
- continue;
-
- rect.setRight( x );
- if ( !flag )
- rect.setLeft( x );
- flag = true;
-
- int y1 = h / 2;
- int y2 = y1 + 1;
- QRgb* pixel1 = ( QRgb* )( buffer.scanLine( y1 ) ) + x;
- QRgb* pixel2 = ( QRgb* )( buffer.scanLine( y2 ) ) + x;
- QRgb pixelstep = pixel2 - pixel1;
-
- int center = ( sh / 2 );
- int dy = dist / h;
- int p1 = center * PFREAL_ONE - dy / 2;
- int p2 = center * PFREAL_ONE + dy / 2;
-
- const QRgb *ptr = ( const QRgb* )( src->scanLine( column ) );
- if ( blend == 256 )
- while (( y1 >= 0 ) && ( y2 < h ) && ( p1 >= 0 ) )
- {
- *pixel1 = ptr[p1 >> PFREAL_SHIFT];
- *pixel2 = ptr[p2 >> PFREAL_SHIFT];
- p1 -= dy;
- p2 += dy;
- y1--;
- y2++;
- pixel1 -= pixelstep;
- pixel2 += pixelstep;
- }
- else
- while (( y1 >= 0 ) && ( y2 < h ) && ( p1 >= 0 ) )
- {
- QRgb c1 = ptr[p1 >> PFREAL_SHIFT];
- QRgb c2 = ptr[p2 >> PFREAL_SHIFT];
- *pixel1 = blendColor( c1, bgcolor, blend );
- *pixel2 = blendColor( c2, bgcolor, blend );
- p1 -= dy;
- p2 += dy;
- y1--;
- y2++;
- pixel1 -= pixelstep;
- pixel2 += pixelstep;
- }
- }
-
- rect.setTop( 0 );
- rect.setBottom( h - 1 );
- return rect;
-}
-
-void PictureFlowSoftwareRenderer::renderSlides()
-{
- int nleft = state->leftSlides.count();
- int nright = state->rightSlides.count();
-
- QRect r = renderSlide( state->centerSlide );
- int c1 = r.left();
- int c2 = r.right();
-
- for ( int index = 0; index < nleft; index++ )
- {
- QRect rs = renderSlide( state->leftSlides[index], 0, c1 - 1 );
- if ( !rs.isEmpty() )
- c1 = rs.left();
- }
- for ( int index = 0; index < nright; index++ )
- {
- QRect rs = renderSlide( state->rightSlides[index], c2 + 1, buffer.width() );
- if ( !rs.isEmpty() )
- c2 = rs.right();
- }
-}
-
-// Render the slides. Updates only the offscreen buffer.
-void PictureFlowSoftwareRenderer::render()
-{
- buffer.fill( state->backgroundColor );
- renderSlides();
- dirty = false;
-}
-
-// -----------------------------------------
-
-class PictureFlowPrivate
-{
-public:
- PictureFlowState* state;
- PictureFlowAnimator* animator;
- PictureFlowAbstractRenderer* renderer;
- QTimer triggerTimer;
-};
-
-
-PictureFlow::PictureFlow( QWidget* parent, bool enableOpenGL): QWidget( parent )
-{
- d = new PictureFlowPrivate;
- m_opengl = enableOpenGL;
- //m_openglwidget = 0;
- d->state = new PictureFlowState;
- d->state->reset();
- d->state->reposition();
-
- if (!m_opengl)
- {
- d->renderer = new PictureFlowSoftwareRenderer;
- d->renderer->widget = this;
- }
- else
- {
- d->renderer = new PictureFlowOpenGLRenderer;
- //m_openglwidget = new CoverBling(0,m_album_list);
- //m_openglwidget->setParent(this);
- }
- d->renderer->state = d->state;
- d->renderer->init();
-
- d->animator = new PictureFlowAnimator;
- d->animator->state = d->state;
- QObject::connect( &d->animator->animateTimer, SIGNAL( timeout() ), this, SLOT( \
updateAnimation() ) );
-
- QObject::connect( &d->triggerTimer, SIGNAL( timeout() ), this, SLOT( render() ) \
);
- setAttribute( Qt::WA_StaticContents, true );
- setAttribute( Qt::WA_OpaquePaintEvent, true );
- setAttribute( Qt::WA_NoSystemBackground, true );
-}
-
-PictureFlow::~PictureFlow()
-{
- delete d->renderer;
- delete d->animator;
- delete d->state;
- delete d;
-}
-void PictureFlow::setOpenGLMode(bool activateOpenGL)
-{
- m_opengl = activateOpenGL;
-}
-int PictureFlow::slideCount() const
-{
- return d->state->slideImages.count();
-}
-
-QColor PictureFlow::backgroundColor() const
-{
- return QColor( d->state->backgroundColor );
-}
-
-void PictureFlow::setBackgroundColor( const QColor& c )
-{
- d->state->backgroundColor = c.rgb();
- triggerRender();
-}
-
-QSize PictureFlow::slideSize() const
-{
- return QSize( d->state->slideWidth, d->state->slideHeight );
-}
-
-void PictureFlow::setSlideSize( QSize size )
-{
- d->state->slideWidth = size.width();
- d->state->slideHeight = size.height();
- d->state->reposition();
- triggerRender();
-}
-
-PictureFlow::ReflectionEffect PictureFlow::reflectionEffect() const
-{
- return d->state->reflectionEffect;
-}
-
-void PictureFlow::setReflectionEffect( ReflectionEffect effect )
-{
- d->state->reflectionEffect = effect;
- triggerRender();
-}
-void PictureFlow::setRenderHints( QPainter::RenderHints iHints )
-{
- d->renderer->render_hints = iHints;
- triggerRender();
-}
-void PictureFlow::setAnimationTime( int iTime )
-{
- d->animator->animationDuration = iTime;
-}
-QImage PictureFlow::slide( int index ) const
-{
- QImage* i = 0;
- if (( index >= 0 ) && ( index < slideCount() ) )
- i = d->state->slideImages[index];
- return i ? QImage( *i ) : QImage();
-}
-
-void PictureFlow::addSlide( const QImage& image )
-{
- int c = d->state->slideImages.count();
- d->state->slideImages.resize( c + 1 );
- d->state->slideImages[c] = new QImage( image );
- triggerRender();
-}
-
-void PictureFlow::addSlide( const QPixmap& pixmap )
-{
- addSlide( pixmap.toImage() );
-}
-
-void PictureFlow::setSlide( int index, const QImage& image )
-{
- if (( index >= 0 ) && ( index < slideCount() ) )
- {
- QImage* i = image.isNull() ? 0 : new QImage( image );
- delete d->state->slideImages[index];
- d->state->slideImages[index] = i;
- triggerRender();
- }
-}
-
-void PictureFlow::setSlide( int index, const QPixmap& pixmap )
-{
- setSlide( index, pixmap.toImage() );
-}
-void PictureFlow::addAlbum( Meta::AlbumPtr iAlbum )
-{
- m_album_list.append( iAlbum );
- //QPixmap* no_cover_pix = new QPixmap( KStandardDirs::locate( "data", \
"amarok/images/blingdefaultcover.png" ) );
-}
-void PictureFlow::setAlbums(Meta::AlbumList iAlbums)
-{
- m_album_list = iAlbums;
- //m_openglwidget->resize(-1,-1);
- //d->renderer->widget = m_openglwidget;
- //if (m_openglwidget)
- //{
- //m_openglwidget->init(m_album_list,QSize(150,150));
- //m_openglwidget->show();
-
- //}
-
-}
-Meta::AlbumPtr PictureFlow::album( int index )
-{
- Meta::AlbumPtr album;
- if (index < m_album_list.size() && index >= 0)
- {
- album = m_album_list[index];
- }
- return album;
-}
-int PictureFlow::centerIndex() const
-{
- return d->state->centerIndex;
-}
-
-void PictureFlow::setCenterIndex( int index )
-{
- index = qMin( index, slideCount() - 1 );
- index = qMax( index, 0 );
- d->state->centerIndex = index;
- d->state->reset();
- d->animator->stop( index );
- triggerRender();
-}
-
-void PictureFlow::clear()
-{
- int c = d->state->slideImages.count();
- for ( int i = 0; i < c; i++ )
- delete d->state->slideImages[i];
- d->state->slideImages.resize( 0 );
-
- d->state->reset();
- triggerRender();
-}
-
-void PictureFlow::render()
-{
- d->renderer->dirty = true;
- update();
-}
-
-void PictureFlow::triggerRender()
-{
- d->triggerTimer.setSingleShot( true );
- d->triggerTimer.start( 0 );
-}
-
-void PictureFlow::showPrevious()
-{
- int step = d->animator->step;
- int center = d->state->centerIndex;
-
- if ( step > 0 )
- d->animator->start( center );
-
- if ( step == 0 )
- if ( center > 0 )
- d->animator->start( center - 1 );
-
- if ( step < 0 )
- d->animator->target = qMax( 0, center - 2 );
-}
-
-void PictureFlow::showNext()
-{
- int step = d->animator->step;
- int center = d->state->centerIndex;
-
- if ( step < 0 )
- d->animator->start( center );
-
- if ( step == 0 )
- if ( center < slideCount() - 1 )
- d->animator->start( center + 1 );
-
- if ( step > 0 )
- d->animator->target = qMin( center + 2, slideCount() - 1 );
-}
-
-void PictureFlow::showSlide( int index )
-{
- index = qMax( index, 0 );
- index = qMin( slideCount() - 1, index );
- if ( index == d->state->centerSlide.slideIndex )
- return;
-
- d->animator->start( index );
-}
-
-void PictureFlow::keyPressEvent( QKeyEvent* event )
-{
- if ( event->key() == Qt::Key_Left )
- {
- if ( event->modifiers() == Qt::ControlModifier )
- showSlide( centerIndex() - 10 );
- else
- showPrevious();
- event->accept();
- return;
- }
-
- if ( event->key() == Qt::Key_Right )
- {
- if ( event->modifiers() == Qt::ControlModifier )
- showSlide( centerIndex() + 10 );
- else
- showNext();
- event->accept();
- return;
- }
-
- event->ignore();
-}
-
-void PictureFlow::mousePressEvent( QMouseEvent* event )
-{
- if ( event->x() > ( width() / 2 + ( d->state->slideWidth ) / 2 ) )
- showNext();
- if ( event->x() < ( width() / 2 - ( d->state->slideWidth ) / 2 ) )
- showPrevious();
-}
-void PictureFlow::mouseDoubleClickEvent( QMouseEvent* event )
-{
- if ((( event->x() <= ( width() / 2 + ( d->state->slideWidth ) / 2 ) ) && ( \
event->x() >= ( width() / 2 - ( d->state->slideWidth ) / 2 ) ) ) && (( event->y() <= \
( height() / 2 + ( d->state->slideHeight ) / 2 ) ) && ( event->y() >= ( height() / 2 \
- ( d->state->slideHeight ) / 2 ) ) ) )
- emit doubleClicked( d->state->centerIndex );
-}
-void PictureFlow::wheelEvent( QWheelEvent * event )
-{
- int numDegrees = event->delta() / 8;
- int numSteps = numDegrees / 15;
- bool forward = TRUE;
- if ( numSteps < 0 )
- {
- forward = FALSE;
- numSteps = -numSteps;
- }
- for ( int i = 1;i <= numSteps;i++ )
- {
- if ( forward ) showNext();
- else showPrevious();
- }
-}
-void PictureFlow::paintEvent( QPaintEvent* event )
-{
- Q_UNUSED( event );
- d->renderer->paint();
-}
-
-void PictureFlow::resizeEvent( QResizeEvent* event )
-{
- triggerRender();
- QWidget::resizeEvent( event );
-}
-
-void PictureFlow::updateAnimation()
-{
- int old_center = d->state->centerIndex;
- d->animator->update();
- triggerRender();
- if ( d->state->centerIndex != old_center )
- emit centerIndexChanged( d->state->centerIndex );
-}
-
diff --git a/src/context/applets/coverbling/pictureflow.h \
b/src/context/applets/coverbling/pictureflow.h deleted file mode 100644
index a339876..0000000
--- a/src/context/applets/coverbling/pictureflow.h
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- PictureFlow - animated image show widget
- http://pictureflow.googlecode.com
- Copyright (C) 2010 Emmanuel Wagner (manu.wagner@sfr.fr)
- Ariya's code modifications for amarok
- Copyright (C) 2008 Ariya Hidayat (ariya@kde.org)
- Copyright (C) 2007 Ariya Hidayat (ariya@kde.org)
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-*/
-
-#ifndef PICTUREFLOW_H
-#define PICTUREFLOW_H
-
-#include <qwidget.h>
-#include "core/meta/Meta.h"
-#include <qpainter.h>
-#include <QHBoxLayout>
-//#include "CoverBling.h"
-
-class PictureFlowPrivate;
-
-/*!
- Class PictureFlow implements an image show widget with animation effect
- like Apple's CoverFlow (in iTunes and iPod). Images are arranged in form
- of slides, one main slide is shown at the center with few slides on
- the left and right sides of the center slide. When the next or previous
- slide is brought to the front, the whole slides flow to the right or
- the right with smooth animation effect; until the new slide is finally
- placed at the center.
-
- */
-class PictureFlow : public QWidget
-{
-Q_OBJECT
-
- Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
- Q_PROPERTY(QSize slideSize READ slideSize WRITE setSlideSize)
- Q_PROPERTY(int slideCount READ slideCount)
- Q_PROPERTY(int centerIndex READ centerIndex WRITE setCenterIndex)
-
-public:
-
- enum ReflectionEffect
- {
- NoReflection,
- PlainReflection,
- BlurredReflection
- };
-
- /*!
- Creates a new PictureFlow widget.
- */
- PictureFlow(QWidget* parent = 0, bool enableOpenGL = false);
-
- /*!
- Destroys the widget.
- */
- ~PictureFlow();
-
- /*!
- Returns the background color.
- */
- QColor backgroundColor() const;
-
- /*!
- Sets the background color. By default it is black.
- */
- void setBackgroundColor(const QColor& c);
-
- void setOpenGLMode(bool activateOpenGL);
- /*!
- Returns the dimension of each slide (in pixels).
- */
- QSize slideSize() const;
-
- /*!
- Sets the dimension of each slide (in pixels).
- */
- void setSlideSize(QSize size);
-
- /*!
- Returns the total number of slides.
- */
- int slideCount() const;
-
- /*!
- Returns QImage of specified slide.
- */
- QImage slide(int index) const;
-
- /*!
- Returns the index of slide currently shown in the middle of the viewport.
- */
- int centerIndex() const;
-
- /*!
- Returns the effect applied to the reflection.
- */
- ReflectionEffect reflectionEffect() const;
-
- /*!
- Sets the effect applied to the reflection. The default is PlainReflection.
- */
- void setReflectionEffect(ReflectionEffect effect);
-
- void setRenderHints(QPainter::RenderHints);
-
- void setAnimationTime(int iTime);
-
-public slots:
-
- Meta::AlbumPtr album(int index);
-
- void setAlbums(Meta::AlbumList iAlbums);
-
- void addAlbum(Meta::AlbumPtr iAlbum);
- /*!
- Adds a new slide.
- */
- void addSlide(const QImage& image);
-
- /*!
- Adds a new slide.
- */
- void addSlide(const QPixmap& pixmap);
-
- /*!
- Sets an image for specified slide. If the slide already exists,
- it will be replaced.
- */
- void setSlide(int index, const QImage& image);
-
- /*!
- Sets a pixmap for specified slide. If the slide already exists,
- it will be replaced.
- */
- void setSlide(int index, const QPixmap& pixmap);
-
- /*!
- Sets slide to be shown in the middle of the viewport. No animation
- effect will be produced, unlike using showSlide.
- */
- void setCenterIndex(int index);
-
- /*!
- Clears all slides.
- */
- void clear();
-
- /*!
- Shows previous slide using animation effect.
- */
- void showPrevious();
-
- /*!
- Shows next slide using animation effect.
- */
- void showNext();
-
- /*!
- Go to specified slide using animation effect.
- */
- void showSlide(int index);
-
- /*!
- Rerender the widget. Normally this function will be automatically invoked
- whenever necessary, e.g. during the transition animation.
- */
- void render();
-
- /*!
- Schedules a rendering update. Unlike render(), this function does not cause
- immediate rendering.
- */
- void triggerRender();
-
-signals:
- void centerIndexChanged(int index);
- void doubleClicked(int index);
-protected:
- void paintEvent(QPaintEvent *event);
- void keyPressEvent(QKeyEvent* event);
- void mousePressEvent(QMouseEvent* event);
- void resizeEvent(QResizeEvent* event);
- void mouseDoubleClickEvent(QMouseEvent* event);
- void wheelEvent(QWheelEvent * event);
- Meta::AlbumList m_album_list;
- bool m_opengl;
-private slots:
- void updateAnimation();
-
-private:
- PictureFlowPrivate* d;
-
- //CoverBling* m_openglwidget;
- //QHBoxLayout* m_opengllayout;
-};
-
-#endif // PICTUREFLOW_H
-
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic