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

List:       kde-commits
Subject:    extragear/multimedia/k3b/src
From:       Sebastian Trueg <sebastian () trueg ! de>
Date:       2006-07-31 23:08:10
Message-ID: 1154387290.873222.31773.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 568383 by trueg:

Use K3bToolTip instead of QToolTip for the VideoDVD view. This allows a nice tooltip \
showing a bigger version of the title preview image.


 M  +31 -5     k3btooltip.cpp  
 M  +8 -3      k3btooltip.h  
 M  +1 -1      k3bwidgetshoweffect.h  
 M  +12 -3     rip/k3bvideodvdrippingpreview.cpp  
 M  +3 -0      rip/k3bvideodvdrippingpreview.h  
 M  +17 -5     rip/k3bvideodvdrippingtitlelistview.cpp  


--- trunk/extragear/multimedia/k3b/src/k3btooltip.cpp #568382:568383
@@ -16,8 +16,12 @@
 #include "k3btooltip.h"
 #include "k3bwidgetshoweffect.h"
 
+#include <k3bthememanager.h>
+#include <k3bapplication.h>
+
 #include <qtimer.h>
 #include <qapplication.h>
+#include <qlabel.h>
 
 #include <kdebug.h>
 
@@ -27,7 +31,7 @@
     m_parentWidget( widget ),
     m_currentTip( 0 ),
     m_tipTimer( new QTimer( this ) ),
-    m_tipTimeout( 2000 )
+    m_tipTimeout( 700 )
 {
   m_parentWidget->installEventFilter( this );
   connect( m_tipTimer, SIGNAL(timeout()),
@@ -40,14 +44,33 @@
 }
 
 
-void K3bToolTip::tip( const QRect&, const QString& )
+void K3bToolTip::tip( const QRect& rect, const QString& text, int effect )
 {
-  // FIXME: create a tip widget, show the tip
+  QLabel* label = new QLabel( text, parentWidget() );
+  label->setMargin( 6 );
+  if( K3bTheme* theme = k3bappcore->themeManager()->currentTheme() ) {
+    label->setPaletteBackgroundColor( theme->backgroundColor() );
+    label->setPaletteForegroundColor( theme->foregroundColor() );
+  }
+  tip( rect, label, (K3bWidgetShowEffect::Effect)effect );
 }
 
 
-void K3bToolTip::tip( const QRect& rect, QWidget* w )
+void K3bToolTip::tip( const QRect& rect, const QPixmap& pix, int effect )
 {
+  QLabel* label = new QLabel( parentWidget() );
+  label->setMargin( 6 );
+  if( K3bTheme* theme = k3bappcore->themeManager()->currentTheme() ) {
+    label->setPaletteBackgroundColor( theme->backgroundColor() );
+    label->setPaletteForegroundColor( theme->foregroundColor() );
+  }
+  label->setPixmap( pix );
+  tip( rect, label, (K3bWidgetShowEffect::Effect)effect );
+}
+
+
+void K3bToolTip::tip( const QRect& rect, QWidget* w, int effect )
+{
   // stop the timer
   m_tipTimer->stop();
 
@@ -92,7 +115,10 @@
   m_currentTip = w;
   m_currentTipRect = rect;
   w->move( p );
-  K3bWidgetShowEffect::showWidget( w, K3bWidgetShowEffect::Dissolve );//w->show();
+  if( effect )
+    K3bWidgetShowEffect::showWidget( w, (K3bWidgetShowEffect::Effect)effect );
+  else
+    w->show();
   w->raise();
 }
 
--- trunk/extragear/multimedia/k3b/src/k3btooltip.h #568382:568383
@@ -17,7 +17,10 @@
 #define _K3B_TOOLTIP_H_
 
 #include <qobject.h>
+#include <qpixmap.h>
 
+#include "k3bwidgetshoweffect.h"
+
 class QTimer;
 
 /**
@@ -35,7 +38,7 @@
 
  public slots:
   /**
-   * default is 2 seconds.
+   * default is 700 mseconds (same as QToolTip)
    */
   void setTipTimeout( int msec ) { m_tipTimeout = msec; }
 
@@ -48,12 +51,14 @@
   /**
    * Show a tooltip.
    */
-  void tip( const QRect&, const QString& );
+  void tip( const QRect&, const QString&, int effect = K3bWidgetShowEffect::Dissolve \
); +  void tip( const QRect& rect, const QPixmap& pix, int effect = \
K3bWidgetShowEffect::Dissolve );  
   /**
    * Use some arbitrary widget as the tooltip
+   * \param effect Use 0 for no effect
    */
-  void tip( const QRect&, QWidget* w );
+  void tip( const QRect&, QWidget* w, int effect = K3bWidgetShowEffect::Dissolve );
 
   bool eventFilter( QObject* o, QEvent* e );
 
--- trunk/extragear/multimedia/k3b/src/k3bwidgetshoweffect.h #568382:568383
@@ -36,7 +36,7 @@
  public:
   // FIXME: add an effect direction
   enum Effect {
-    Dissolve,
+    Dissolve = 1,
     Slide
   };
 
--- trunk/extragear/multimedia/k3b/src/rip/k3bvideodvdrippingpreview.cpp \
#568382:568383 @@ -57,14 +57,19 @@
   }
 
   // auto-select a chapter
+  // choose the center chapter, but not the first or last if possible
   if( chapter == 0 )
-    chapter = QMIN( QMAX( dvd[title-1].numChapters()/2, 2 ), \
dvd[title-1].numChapters() ); +    chapter = QMIN( QMAX( \
dvd[title-1].numChapters()/2, 2 ), QMAX( dvd[title-1].numChapters() - 1, 1 ) );  
   // select a frame number
   unsigned int frame = 20;
   if( dvd[title-1][chapter-1].playbackTime().totalFrames() < frame )
     frame = dvd[title-1][chapter-1].playbackTime().totalFrames() / 2;
 
+  m_dvd = dvd;
+  m_title = title;
+  m_chapter = chapter;
+
   m_tempDir = new KTempDir();
   m_tempDir->setAutoDelete( true );
 
@@ -76,7 +81,7 @@
   *m_process << "--dvd_access_delay" << "0";
   *m_process << "-y" << "ppm,null";
   *m_process << "-c" << QString("%1-%2").arg( frame ).arg( frame+1 );
-  *m_process << "-Z" << "100x";
+  *m_process << "-Z" << "x200";
   *m_process << "-o" << m_tempDir->name();
 
   connect( m_process, SIGNAL(processExited(KProcess*)),
@@ -110,7 +115,11 @@
   delete m_process;
   m_process = 0;
 
-  emit previewDone( success );
+  // retry the first chapter in case another failed
+  if( !success && m_chapter > 1 )
+    generatePreview( m_dvd, m_title, 1 );
+  else
+    emit previewDone( success );
 }
 
 #include "k3bvideodvdrippingpreview.moc"
--- trunk/extragear/multimedia/k3b/src/rip/k3bvideodvdrippingpreview.h #568382:568383
@@ -54,6 +54,9 @@
   QImage m_preview;
   KTempDir* m_tempDir;
   KProcess* m_process;
+  int m_title;
+  int m_chapter;
+  K3bVideoDVD::VideoDVD m_dvd;
 };
 
 #endif
--- trunk/extragear/multimedia/k3b/src/rip/k3bvideodvdrippingtitlelistview.cpp \
#568382:568383 @@ -16,6 +16,8 @@
 #include "k3bvideodvdrippingtitlelistview.h"
 #include "k3bvideodvdrippingpreview.h"
 
+#include <k3btooltip.h>
+
 #include <k3bvideodvd.h>
 #include <k3bvideodvdaudiostream.h>
 #include <k3bvideodvdvideostream.h>
@@ -136,6 +138,10 @@
     repaint();
   }
 
+  const QImage& preview() const {
+    return m_preview;
+  }
+
 protected:
   void paintK3bCell( QPainter* p, const QColorGroup& cg, int col, int width, int \
align ) {  if( col == 0 ) {
@@ -269,11 +275,11 @@
 };
 
 
-class K3bVideoDVDRippingTitleListView::TitleToolTip : public QToolTip
+class K3bVideoDVDRippingTitleListView::TitleToolTip : public K3bToolTip
 {
 public:
   TitleToolTip( K3bVideoDVDRippingTitleListView* view )
-    : QToolTip( view->viewport() ),
+    : K3bToolTip( view->viewport() ),
       m_view( view ) {
   }
 
@@ -291,13 +297,19 @@
 
     switch( col ) {
     case 2:
-      // FIXME: show the bigger preview as the tooltip (maybe use K3bToolTip)
+      if( !item->preview().isNull() ) {
+	QPixmap previewPix;
+	if( previewPix.convertFromImage( item->preview() ) )
+	  tip( r, previewPix, 0 );
+      }
       break;
     case 4:
-      tip( r, "<p><b>" + i18n("Audio Streams") + "</b><p>" + audioStreamString( \
item->videoDVDTitle() ) ); +      if( item->videoDVDTitle().numAudioStreams() > 0 )
+	tip( r, "<p><b>" + i18n("Audio Streams") + "</b><p>" + audioStreamString( \
item->videoDVDTitle() ), 0 );  break;
     case 5:
-      tip( r, "<p><b>" + i18n("Subpicture Streams") + "</b><p>" + \
subpictureStreamString( item->videoDVDTitle() ) ); +      if( \
item->videoDVDTitle().numSubPictureStreams() > 0 ) +	tip( r, "<p><b>" + \
i18n("Subpicture Streams") + "</b><p>" + subpictureStreamString( \
item->videoDVDTitle() ), 0 );  break;
     }
   }


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

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