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

List:       kde-commits
Subject:    extragear/multimedia/amarok/src/popupdropper
From:       Jeff Mitchell <kde-dev () emailgoeshere ! com>
Date:       2007-06-19 23:50:54
Message-ID: 1182297054.917965.22547.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 677817 by mitchell:

More work...nothing works still but getting close to getting custom items on the QGV


 M  +17 -5     PopupDropperBaseItem.cpp  
 M  +8 -7      PopupDropperBaseItem.h  
 M  +20 -2     PopupDropperScene.cpp  


--- trunk/extragear/multimedia/amarok/src/popupdropper/PopupDropperBaseItem.cpp \
#677816:677817 @@ -20,16 +20,19 @@
 #include "debug.h"
 #include "PopupDropperBaseItem.h"
 
+#include <QFont>
 #include <QGraphicsScene>
-#include <QGraphicsBaseItem>
+#include <QGraphicsItem>
 #include <QPainter>
 #include <QRectF>
 
 using namespace PopupDropperNS;
 
-PopupDropperBaseItem::PopupDropperBaseItem( QGraphicsItem* parent )
-                                    : QGraphicsItem( parent )
+PopupDropperBaseItem::PopupDropperBaseItem( int whichami, QGraphicsItem* parent )
+                                    : QObject( 0 )
+                                    , QGraphicsItem( parent )
                                     , m_scalingPercent( 0.0 )
+                                    , m_whichami( whichami )
 {
     DEBUG_BLOCK
 }
@@ -40,10 +43,19 @@
 }
 
 QRectF
-boundingRect() const
+PopupDropperBaseItem::boundingRect() const
 {
+    return QRectF( 30*m_whichami, 30*m_whichami, 20, 20 );
+}
 
+void
+PopupDropperBaseItem::paint( QPainter *painter, const QStyleOptionGraphicsItem \
*option, QWidget *widget ) +{
+    Q_UNUSED(option);
+    Q_UNUSED(widget);
+    painter->setFont( QFont("Times", 48, QFont::Bold) );
+    painter->setPen( Qt::white );
+    painter->drawText( 0, 0, QChar( m_whichami ) );
 }
 
 #include "PopupDropperBaseItem.moc"
-
--- trunk/extragear/multimedia/amarok/src/popupdropper/PopupDropperBaseItem.h \
#677816:677817 @@ -20,11 +20,10 @@
 
 #include "amarok_export.h"
 
-#include <QGraphicsBaseItem>
+#include <QGraphicsItem>
 #include <QObject>
 #include <QtGlobal>
 
-class QGraphicsScene;
 class QPainter;
 class QRectF;
 
@@ -35,24 +34,26 @@
 
 namespace PopupDropperNS {
 
-    class PopupDropperBaseItem : public QGraphicsItem
+    class PopupDropperBaseItem : public QObject, public QGraphicsItem
     {
+        
         Q_OBJECT
-    
+
         public:
     
             /**
             * Creates a new PopupDropperBaseItem.
             * 
             */
-            PopupDropperBaseItem( QGraphicsItem* parent = 0 );
+            PopupDropperBaseItem( int whichami, QGraphicsItem* parent = 0 );
             ~PopupDropperBaseItem();
 
             //Reimplementations
             QRectF boundingRect() const;
-            void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, \
QWidget *widget); +            void paint( QPainter *painter, const \
QStyleOptionGraphicsItem *option, QWidget *widget );  
-            qreal m_scalingPercent;
+            float       m_scalingPercent;
+            int         m_whichami;
     };
 }
 #endif /* AMAROK_POPUPDROPPER_BASEITEM_H */
--- trunk/extragear/multimedia/amarok/src/popupdropper/PopupDropperScene.cpp \
#677816:677817 @@ -20,6 +20,7 @@
 #include "debug.h"
 #include "PopupDropperScene.h"
 #include "PopupDropperView.h"
+#include "PopupDropperBaseItem.h"
 
 #include <QGraphicsItem>
 #include <QGraphicsScene>
@@ -39,6 +40,7 @@
     m_fadeInTL.setFrameRange( 0, 10 );
     m_fadeOutTL.setFrameRange( 0, 10 );
     m_spinInTL.setFrameRange( 0, SPIN_IN_FRAMES );
+    debug() << "SPIN IN FRAMES = " << SPIN_IN_FRAMES << endl;
 }
 
 PopupDropperScene::~PopupDropperScene()
@@ -62,6 +64,14 @@
 PopupDropperScene::startPDV()
 {
     DEBUG_BLOCK
+    PopupDropperBaseItem *temp;
+    for( int i = 1; i <= 5; ++i )
+    {
+        temp = new PopupDropperBaseItem( i );
+        temp->scale( 100, 100 );
+        addItem( temp );
+        temp->show();
+    }
     m_pdv->show();
     m_fadeInTL.start();
     m_spinInTL.start();
@@ -81,6 +91,15 @@
     DEBUG_BLOCK
     m_pdv->hide();
     //delete all items we've added -- not children()!
+    QGraphicsItem *temp;
+    QList<QGraphicsItem *> itemlist = items();
+    for( int i = 0; i < itemlist.size(); ++i )
+    {
+        temp = itemlist.at(i);
+        removeItem( temp );
+        delete temp;
+    }
+ 
 }
 
 //SLOT
@@ -88,6 +107,7 @@
 PopupDropperScene::updateIconSpinIn( int frame )
 {
     DEBUG_BLOCK
+    debug() << "frame number = " << frame << endl;
     QGraphicsItem * currItem;
     qreal percentage = frame * 100.0 / SPIN_IN_FRAMES;
     QList<QGraphicsItem *> itemlist = items();
@@ -95,8 +115,6 @@
     {
         currItem = itemlist.at(i);
         currItem->scale( percentage, percentage );
-        if( frame == 1 )
-            currItem->show();
     }
     m_pdv->update();
 }


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

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