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

List:       kde-commits
Subject:    branches/work/kwin_composite
From:       Philip Edward John Falkner <philip.falkner () gmail ! com>
Date:       2007-03-08 4:44:07
Message-ID: 1173329047.928886.17659.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 640446 by pfalkner:

Port tabbox from QFrame to Q3Frame.

 M  +12 -17    tabbox.cpp  
 M  +4 -4      tabbox.h  


--- branches/work/kwin_composite/tabbox.cpp #640445:640446
@@ -24,7 +24,6 @@
 #include <QApplication>
 #include <qdesktopwidget.h>
 #include <QCursor>
-#include <kstringhandler.h>
 #include <stdarg.h>
 #include <kdebug.h>
 #include <kglobalsettings.h>
@@ -43,12 +42,14 @@
 
 extern QPixmap* kwin_get_menu_pix_hack();
 
-TabBox::TabBox( Workspace *ws, const char *name )
-    : Q3Frame( 0, name, Qt::WNoAutoErase | Qt::X11BypassWindowManagerHint ), client(0), wspace(ws)
+TabBox::TabBox( Workspace *ws )
+    : QFrame( 0, Qt::X11BypassWindowManagerHint )
+    , client(0)
+    , wspace(ws)
     {
     setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
     setLineWidth(2);
-    setMargin(2);
+    setContentsMargins( 2, 2, 2, 2 );
 
     showMiniIcon = false;
 
@@ -321,20 +322,18 @@
 /*!
   Paints the tab box
  */
-void TabBox::drawContents( QPainter * )
+void TabBox::paintEvent( QPaintEvent* e )
     {
-    QRect r(contentsRect());
-    QPixmap pix(r.size());  // do double buffering to avoid flickers
-    pix.fill(this, 0, 0);
+    QFrame::paintEvent( e );
 
-    QPainter p;
-    p.begin(&pix);
+    QPainter p( this );
+    QRect r( contentsRect());
 
     QPixmap* menu_pix = kwin_get_menu_pix_hack();
 
     int iconWidth = showMiniIcon ? 16 : 32;
-    int x = 0;
-    int y = 0;
+    int x = r.x();
+    int y = r.y();
 
     if ( mode () == WindowsMode )
         {
@@ -388,7 +387,7 @@
                   else
                     s += (*it)->caption();
 
-                  s = KStringHandler::cPixelSqueeze(s, fontMetrics(), r.width() - 5 - iconWidth - 8);
+                  s = fontMetrics().elidedText( s, Qt::ElideMiddle, r.width() - 5 - iconWidth - 8 );
 
                   // draw text
                   if ( (*it) == currentClient() )
@@ -503,10 +502,6 @@
                 iDesktop++;
             }
         }
-    p.end();
-
-    QPainter localPainter( this );
-    localPainter.drawImage( QPoint( r.x(), r.y() ), pix.toImage() );
     }
 
 void TabBox::hide()
--- branches/work/kwin_composite/tabbox.h #640445:640446
@@ -12,7 +12,7 @@
 #ifndef KWIN_TABBOX_H
 #define KWIN_TABBOX_H
 
-#include <Q3Frame>
+#include <QFrame>
 #include <QTimer>
 #include "utils.h"
 
@@ -24,11 +24,11 @@
 class Workspace;
 class Client;
 
-class TabBox : public Q3Frame
+class TabBox : public QFrame
     {
     Q_OBJECT
     public:
-        TabBox( Workspace *ws, const char *name=0 );
+        TabBox( Workspace *ws );
         ~TabBox();
 
         Client* currentClient();
@@ -57,7 +57,7 @@
     protected:
         void showEvent( QShowEvent* );
         void hideEvent( QHideEvent* );
-        void drawContents( QPainter * );
+        void paintEvent( QPaintEvent* );
 
     private:
         void createClientList(ClientList &list, int desktop /*-1 = all*/, Client *start, bool chain);
[prev in list] [next in list] [prev in thread] [next in thread] 

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