[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/multimedia/amarok/playground/src/context/applets/videoclip
From:       Simon Esneault <simon.esneault () gmail ! com>
Date:       2009-06-06 18:32:30
Message-ID: 1244313150.582768.22454.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 978307 by sesneault:

- Clean code and output in debug + minor fixes
- Video added to the playlist now have the name of the artist, and the image downloaded


 M  +28 -32    VideoclipApplet.cpp  
 M  +13 -10    VideoclipApplet.h  


--- trunk/extragear/multimedia/amarok/playground/src/context/applets/videoclip/VideoclipApplet.cpp \
#978306:978307 @@ -52,6 +52,7 @@
 #include <QToolButton>
 #include <QScrollArea>
 
+#define DEBUG_PREFIX "VideoclipApplet"
 
 VideoclipApplet::VideoclipApplet( QObject* parent, const QVariantList& args )
         : Context::Applet( parent, args )
@@ -72,9 +73,14 @@
 
     // HACK
     m_height = 300;
+    
+    // TODO inherit a phonon VideoWidget to unable mouse interaction (double click full screen etc ...)
     m_videoWidget = new Phonon::VideoWidget();
     m_videoWidget->setParent( Context::ContextView::self()->viewport(), Qt::SubWindow | \
Qt::FramelessWindowHint );  m_videoWidget->hide();
+	// For this we should inherit the videowidget in a separate class
+//	connect(m_videoWidget, SIGNAL( mouseDoubleClickEvent() ), m_videoWidget, SLOT( setFullScreen( \
m_videoWidget->fullScreen() ) ) ); +	
     Phonon::Path path = Phonon::createPath( m_mediaObject, m_videoWidget );
     if ( !path.isValid() )
         warning() << "Phonon path is invalid.";
@@ -138,10 +144,12 @@
     if ( m_videoWidget && m_mediaObject && m_mediaObject->hasVideo() )
     {
         debug() << " VideoclipApplet | Show VideoWidget";
+		m_widget->hide();
         m_videoWidget->show();
     }
-    else if( m_videoWidget )
+    else if( m_videoWidget && m_widget )
     {
+		m_widget->show();
         m_videoWidget->hide();
     }
 }
@@ -154,7 +162,10 @@
     Q_UNUSED( reason )
     
     if( m_videoWidget )
+	{
+		m_widget->show();
         m_videoWidget->hide();
+	}
 }
 
 void 
@@ -169,7 +180,7 @@
     m_widget->resize( size().width() - 2 * standardPadding(), size().height() - \
m_headerText->boundingRect().height() - 2*standardPadding() );  m_videoWidget->setGeometry( QRect(
         pos().toPoint()+QPoint( 2 * standardPadding(), m_headerText->boundingRect().height() + 3 * \
                standardPadding() ),
-        size().toSize()-QSize( 4 * standardPadding(),  m_headerText->boundingRect().height() + 6 * \
standardPadding() ) ) ); +        size().toSize()-QSize( 4 * standardPadding(),  \
m_headerText->boundingRect().height() + 5 * standardPadding() ) ) );  }
 
 
@@ -226,13 +237,11 @@
         
         // if we get a message, show it
         if ( data.contains( "message" ) && data["message"].toString().contains("Fetching"))
-        {
 			setBusy( true );
-			
-        }
 		else if ( data.contains( "message" ) )
 		{
 			QLabel *mess = new QLabel( data["message"].toString() );
+            mess->setAlignment(Qt::AlignTop);
             m_layout->addWidget( mess, Qt::AlignTop );
             m_layoutWidgetList.push_back( mess );		
 			setBusy( false );
@@ -243,43 +252,44 @@
             for (int i=0; i< data.size(); i++ )
             {
                 
-                VideoInfo item = data[ QString().setNum(i) ].value<VideoInfo>() ;
+                VideoInfo *item = data[ QString().setNum(i) ].value<VideoInfo *>() ;
                   // Create a pixmap with nice border
-                QPixmap pix( The::svgHandler()->addBordersToPixmap( item.cover, 5, "Thumbnail", true \
).scaledToHeight( 85 ) ) ; +                QPixmap pix( The::svgHandler()->addBordersToPixmap( \
*item->cover, 5, "Thumbnail", true ).scaledToHeight( 85 ) ) ;  
                 // Prepare the QtoolButon, we will send all the information to the callback via the text
                 QToolButton *icon = new QToolButton();
-                icon->setText( item.videolink + QString (" | ") + item.title + QString (" | ") + \
item.source); +                icon->setText( item->videolink + QString (" | ") + item->title + QString \
(" | ") + item->source  +                    + QString (" | ") + item->artist);
                 icon->setToolButtonStyle( Qt::ToolButtonIconOnly );
                 icon->setAutoRaise( true );
                 icon->setIcon( QIcon( pix ) );
                 icon->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
                 icon->resize( pix.size() );
                 icon->setIconSize( pix.size() ) ;
-                icon->setToolTip( QString( "<html><body>" ) + item.desc + QString( "</body></html>" ) );
+                icon->setToolTip( QString( "<html><body>" ) + item->desc + QString( "</body></html>" ) \
);  
                 connect ( icon, SIGNAL( clicked( bool ) ), this, SLOT ( appendVideoClip( ) ) );
                 
                 // create link (and resize, no more than 3 lines long)
-                QString title( item.title );
+                QString title( item->title );
                 if ( title.size() > 45 ) title.resize( 45 );
-                QLabel *link = new QLabel( QString( "<html><body><a href=\"" ) + item.url + QString( \
"\">" ) + title + QString( "</a>" ) ); +                QLabel *link = new QLabel( QString( \
"<html><body><a href=\"" ) + item->url + QString( "\">" ) + title + QString( "</a>" ) );  \
link->setOpenExternalLinks( true );  link->setWordWrap( true );
 
-                QLabel *duration =  new QLabel( item.duration + QString( "<br>" ) + item.views + \
QString( " views" ) ); +                QLabel *duration =  new QLabel( item->duration + QString( "<br>" \
) + item->views + QString( " views" ) );  
                 KRatingWidget* rating = new KRatingWidget;
-                rating->setRating(( int )( item.rating * 2. ) );
+                rating->setRating(( int )( item->rating * 2. ) );
                 rating->setMaximumWidth(( int )(( width / 3 )*2 ) );
                 rating->setMinimumWidth(( int )(( width / 3 )*2 ) );
 
                 QLabel *webi = new QLabel;
-                if ( item.source == QString( "youtube" ) )
+                if ( item->source == QString( "youtube" ) )
                     webi->setPixmap( *m_pixYoutube );
-                else if ( item.source == QString( "dailymotion" ) )
+                else if ( item->source == QString( "dailymotion" ) )
                     webi->setPixmap( *m_pixDailymotion );
-                else if ( item.source == QString( "vimeo" ) )
+                else if ( item->source == QString( "vimeo" ) )
                     webi->setPixmap( *m_pixVimeo );
 
 
@@ -335,27 +345,13 @@
         MetaStream::Track *tra = new MetaStream::Track(KUrl( lst.at( 0 ) ) );
         tra->setTitle( lst.at( 1 ) );
         tra->setAlbum( lst.at( 2 ) );
-        tra->setArtist( "stream" );
-		//debug () << "Image size"<<button->iconSize().height();
-        tra->album()->setImage( *m_pixYoutube );
+        tra->setArtist( lst.at( 3 ) );
+        tra->album()->setImage( button->icon().pixmap( button->iconSize().height() ) );
         Meta::TrackPtr track( tra );
-      
         //append to the playlist the newly retrieved
         The::playlistController()->insertOptioned(track , Playlist::Append );
     }
 }
 
-
-//     for (int i=0; i<data["title"].toStringList().size();i++)
-//     {
-//             debug() << "VideoclipApplet::title: " << data[ "title" ].toStringList().at(i);
-//             debug() << "VideoclipApplet::id: " << data[ "id" ].toStringList().at(i);
-//             debug() << "VideoclipApplet::cover: " << data[ "cover" ].toStringList().at(i);
-//             debug() << "VideoclipApplet::duration: " << data[ "duration" ].toStringList().at(i);
-//             debug() << "VideoclipApplet::views: " << data[ "views" ].toStringList().at(i);
-//             debug() << "VideoclipApplet::description: " << data[ "description" \
                ].toStringList().at(i);
-//     }
-
-
 #include "VideoclipApplet.moc"
 
--- trunk/extragear/multimedia/amarok/playground/src/context/applets/videoclip/VideoclipApplet.h \
#978306:978307 @@ -1,7 +1,8 @@
 /***************************************************************************
- *   Plasma applet for showing video in the context view.                  *
+ *   Plasma applet for showing video from youtube dailymotion and          *
+ *   vimeo in the context view.                                            *
  *                                                                         *
- *   Copyright (c) 2008 Mark Kretschmann <kretschmann@kde.org>             *
+ *   Copyright 2009 Simon Esneault <simon.esneault@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  *
@@ -36,19 +37,21 @@
 class QGraphicsWidget;
 class QHBoxLayout;
 
-//! Struct VideoInfo, contain all the info
+//!  Struct VideoInfo, contain all the info vor a video
 struct VideoInfo {
     QString url;        // Url for the browser (http://www.youtube.com/watch?v=153d9tc3Oao )
-    QString title;      
-    QString coverurl;   
+    QString title;      // Name of the video
+    QString coverurl;   // url of the cover
     QString duration;   // formatted as a QString(mm:ss)
     QString desc;       // full description
-    QPixmap cover;      // Image data
-    QString views;      
+    QPixmap * cover;    // Image data
+    QString views;      // number of view of the video
     float rating;       // rating should be beetween 0 to 5
     QString videolink;  // direct video link to the downloadable file
-    QString source;     // "youtub" or "dailymotion" or "vimeo" or whatever
-    int relavancy;      // used to filter and order the files
+    QString source;     // "youtube" or "dailymotion" or "vimeo" or whatever
+    int relevancy;      // used to filter and order the files
+    int length;         // length in seconds 
+    QString artist;     // The artist just to show it in the artist name
 };
 
  /** VideoclipApplet will display videoclip from internet, relatively to the current playing song
@@ -95,7 +98,7 @@
 
 };
 
-Q_DECLARE_METATYPE ( VideoInfo );
+Q_DECLARE_METATYPE ( VideoInfo *);
 K_EXPORT_AMAROK_APPLET( videoclip, VideoclipApplet )
 
 #endif /* VIDEOCLIP_APPLET_H */


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic