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

List:       kde-commits
Subject:    extragear/multimedia/amarok/src
From:       Nikolaj Hald Nielsen <nhnFreespirit () gmail ! com>
Date:       2009-07-02 8:37:24
Message-ID: 1246523844.002458.5956.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 990288 by nhnielsen:

More "Show Cover" improvements by Pascal Pollet <pascal@bongosoft.de>
- Much smoother zooming.
- No longer try to center on screen as that causes issues on multi screen setups.

CCBUG: 175901



 M  +7 -1      covermanager/CoverFetchingActions.cpp  
 M  +6 -3      covermanager/CoverViewDialog.h  
 M  +14 -30    widgets/PixmapViewer.cpp  
 M  +1 -1      widgets/PixmapViewer.h  


--- trunk/extragear/multimedia/amarok/src/covermanager/CoverFetchingActions.cpp \
#990287:990288 @@ -15,7 +15,10 @@
  ****************************************************************************************/
  
 #include "CoverFetchingActions.h"
+#include "Debug.h"
 
+#include <QDesktopWidget>
+
 #include <KIcon>
 #include <KFile>
 #include <KFileDialog>
@@ -65,7 +68,10 @@
 
 void DisplayCoverAction::slotTriggered()
 {
-    ( new CoverViewDialog( m_albums.first(), qobject_cast<QWidget*>( parent() ) ) \
)->show(); +    QWidget *p = dynamic_cast<QWidget*>( parent() );
+    int parentScreen = KApplication::desktop()->screenNumber( p );
+
+    ( new CoverViewDialog( m_albums.first(), QApplication::desktop()->screen( \
parentScreen ) ) )->show();  }
 
 
--- trunk/extragear/multimedia/amarok/src/covermanager/CoverViewDialog.h \
#990287:990288 @@ -20,13 +20,14 @@
 #include "meta/Meta.h"
 #include "widgets/PixmapViewer.h"
 
-#include <QHBoxLayout>
-
 #include <KApplication>
 #include <KDialog> //baseclass
 #include <KLocale>
 #include <KWindowSystem>
 
+#include <QHBoxLayout>
+#include <QDesktopWidget>
+
 class AMAROK_EXPORT CoverViewDialog : public QDialog
 {
     public:
@@ -44,7 +45,9 @@
                             album->albumArtist()? album->albumArtist()->prettyName() \
: i18n( "Various Artists" ),  album->prettyName() ) ) );
 
-            PixmapViewer *pixmapViewer = new PixmapViewer( this, album->image( 0 ) \
/* full sized image */ ); +            int screenNumber = \
KApplication::desktop()->screenNumber( parent ); +
+            PixmapViewer *pixmapViewer = new PixmapViewer( this, album->image( 0 ) \
/* full sized image */, screenNumber );  QHBoxLayout *layout = new QHBoxLayout( this \
);  layout->addWidget( pixmapViewer );
             layout->setSizeConstraint( QLayout::SetFixedSize );
--- trunk/extragear/multimedia/amarok/src/widgets/PixmapViewer.cpp #990287:990288
@@ -30,32 +30,30 @@
 #include <QWheelEvent>
 
 
-PixmapViewer::PixmapViewer( QWidget *widget, const QPixmap pix )
+PixmapViewer::PixmapViewer( QWidget *widget, const QPixmap pix, int screenNumber)
         : QWidget( widget )
 {
 
     m_pixmap = new QPixmap( pix );
     m_zoomFactor = 1.0; // initial zoom
 
-    if ( KApplication::desktop()->width() < m_pixmap->width() )
+    if ( KApplication::desktop()->availableGeometry( screenNumber ).width() < \
m_pixmap->width() || +            KApplication::desktop()->availableGeometry( \
screenNumber ).height() < m_pixmap->height() )  {
-        m_zoomFactor = ( ( float ) KApplication::desktop()->width() /
-                        ( float ) m_pixmap->width() ) - 0.5;
+        float zoomFactorX =
+            ( (float) KApplication::desktop()->availableGeometry( screenNumber \
).width() / +             (float) m_pixmap->width() );
+        float zoomFactorY =
+            ( (float) KApplication::desktop()->availableGeometry( screenNumber \
).height() / +             (float) m_pixmap->height() );
+
+        m_zoomFactor = std::min( zoomFactorX, zoomFactorY ) * 0.8;
     }
 
     setMinimumSize( m_pixmap->width() * m_zoomFactor, m_pixmap->height() * \
m_zoomFactor );  
-    // move window to the center of the screen
-    // (multiple screens: same screen as parent widget)
-    QWidget *p = dynamic_cast<QWidget*>( parent() );
-    p->move( ( KApplication::desktop()->availableGeometry( p ).width()
-              - ( m_pixmap->width() * m_zoomFactor ) ) / 2,
-            ( KApplication::desktop()->availableGeometry( p ).height()
-              - ( m_pixmap->height() * m_zoomFactor ) ) / 2 );
-
 }
 
-
 void
 PixmapViewer::setZoomFactor( float f )
 {
@@ -75,19 +73,18 @@
     if ( p )
         resize( p->width(), p->height() );
 
-    repaint();
 }
 
 void
 PixmapViewer::paintEvent( QPaintEvent *event )
 {
+    Q_UNUSED(event);
+
     int xoffset, yoffset;
-    bool drawBorder = false;
 
     if ( width() > m_pixmap->width() * m_zoomFactor )
     {
         xoffset = ( width() - m_pixmap->width() * m_zoomFactor ) / 2;
-        drawBorder = true;
     }
     else
     {
@@ -97,31 +94,18 @@
     if ( height() > m_pixmap->height()*m_zoomFactor )
     {
         yoffset = ( height() - m_pixmap->height() * m_zoomFactor ) / 2;
-        drawBorder = true;
     }
     else
     {
         yoffset = 0;
     }
-
-    QWidget *parentWidget = dynamic_cast<QWidget*>( parent() );
-    parentWidget->move( ( KApplication::desktop()->availableGeometry( parentWidget \
                ).width()
-                         - ( m_pixmap->width() * m_zoomFactor ) ) / 2,
-                       ( KApplication::desktop()->availableGeometry( parentWidget \
                ).height()
-                         - ( m_pixmap->height() * m_zoomFactor ) ) / 2 );
-
+    
     QPainter p( this );
     p.save();
     p.translate( xoffset, yoffset );
     p.scale( m_zoomFactor, m_zoomFactor );
     p.drawPixmap( 0, 0, *m_pixmap );
     p.restore();
-    if ( drawBorder )
-    {
-        p.setPen( Qt::black );
-        p.drawRect( xoffset - 1, yoffset - 1, m_pixmap->width() * m_zoomFactor + 1,
-                    m_pixmap->height() * m_zoomFactor + 1 );
-    }
 }
 
 void
--- trunk/extragear/multimedia/amarok/src/widgets/PixmapViewer.h #990287:990288
@@ -32,7 +32,7 @@
     Q_OBJECT
 
 public:
-    PixmapViewer( QWidget *widget, const QPixmap pixmap );
+    PixmapViewer( QWidget *widget, const QPixmap pixmap, int screenNumber );
 
 public slots:
     void setZoomFactor( float f );


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

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