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

List:       kde-commits
Subject:    koffice/karbon/widgets
From:       Jan Hambrecht <jaham () gmx ! net>
Date:       2007-02-08 21:07:33
Message-ID: 1170968853.496420.668.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 631716 by jaham:

Only draw the stroke 3D outline if there is
no stroke set, hwich looks better for thin 
strokes. Did some cleanup as well.



 M  +39 -52    vstrokefillpreview.cc  
 M  +3 -8      vstrokefillpreview.h  


--- trunk/koffice/karbon/widgets/vstrokefillpreview.cc #631715:631716
@@ -22,7 +22,6 @@
 
 #include <QColor>
 #include <QPaintEvent>
-#include <QFrame>
 #include <QMouseEvent>
 #include <QEvent>
 #include <QPoint>
@@ -30,15 +29,11 @@
 #include <QPainter>
 #include <QBrush>
 #include <QGradient>
-#include <QDockWidget>
 
-#include <kdebug.h>
-
 #include <KoPathShape.h>
 #include <KoShapeBorderModel.h>
 #include <KoZoomHandler.h>
 
-#include "vcolordlg.h"
 #include "vstrokefillpreview.h"
 
 #define PANEL_SIZEX 50.0
@@ -51,6 +46,7 @@
     setFocusPolicy( Qt::NoFocus );
 
     setFrameStyle( QFrame::GroupBoxPanel | QFrame::Sunken );
+    setMaximumHeight( PANEL_SIZEY );
 
     installEventFilter( this );
     m_pixmap = QPixmap( int( PANEL_SIZEX ), int( PANEL_SIZEY ) );
@@ -72,6 +68,21 @@
     QFrame::paintEvent( event );
 }
 
+QSize VStrokeFillPreview::sizeHint() const
+{
+    return QSize( PANEL_SIZEX, PANEL_SIZEY );
+}
+
+QSize VStrokeFillPreview::minimumSizeHint() const
+{
+    return QSize( PANEL_SIZEX, PANEL_SIZEY );
+}
+
+QSizePolicy VStrokeFillPreview::sizePolicy() const
+{
+    return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
+}
+
 bool VStrokeFillPreview::eventFilter( QObject *, QEvent *event )
 {
     QMouseEvent* e = static_cast<QMouseEvent *>( event );
@@ -110,35 +121,6 @@
         update( m_stroke, m_fill );
     }
 
-    if( event && event->type() == QEvent::MouseButtonDblClick )
-    {
-        if( m_fillRect.contains( QPointF( ex, ey ) ) )
-        {
-            //VColorDlg* dialog = new VColorDlg( m_fill->color(), this );
-#if 0
-// needs porting:
-// error: no matching function for call to `VFill::setColor(Qt::GlobalColor)'
-
-            if( dialog->exec() == QDialog::Accepted )
-            {
-                if( m_part && m_part->document().selection() ) m_part->addCommand( \
                new VFillCmd( &m_part->document(), VFill( dialog->Color() ) ), true \
                );
-            }
-#endif
-            //delete dialog;
-        }
-        else if( m_strokeRect.contains( QPointF( ex, ey ) ) )
-        {
-            //VColorDlg* dialog = new VColorDlg( m_stroke->color(), this );
-#if 0
-// needs porting:
-            if( dialog->exec() == QDialog::Accepted )
-            {
-                if( m_part && m_part->document().selection() ) m_part->addCommand( \
                new VStrokeCmd( &m_part->document(), dialog->Color() ), true );
-            }
-#endif
-            //delete dialog;
-        }
-    }
     return false;
 }
 
@@ -288,28 +270,33 @@
         painter.restore();
     }
 
-    // show 3D outline of stroke part
-    painter.setBrush( Qt::NoBrush );
+    // only draw th 3D ouline when no stroke is set
+    // which looks better for thin strokes
+    if( ! stroke )
+    {
+        // show 3D outline of stroke part
+        painter.setBrush( Qt::NoBrush );
 
-    painter.setPen( Qt::white );
-    painter.drawLine( QPointF( m_strokeRect.right() + 1, m_strokeRect.top() - 1 ),
-                      QPointF( m_strokeRect.left() - 1, m_strokeRect.top() - 1 ) );
-    painter.drawLine( QPointF( m_strokeRect.left() - 1, m_strokeRect.top() - 1 ),
-                      QPointF( m_strokeRect.left() - 1, m_strokeRect.bottom() + 1 ) \
); +        painter.setPen( Qt::white );
+        painter.drawLine( QPointF( m_strokeRect.right() + 1, m_strokeRect.top() - 1 \
), +                        QPointF( m_strokeRect.left() - 1, m_strokeRect.top() - 1 \
) ); +        painter.drawLine( QPointF( m_strokeRect.left() - 1, m_strokeRect.top() \
- 1 ), +                        QPointF( m_strokeRect.left() - 1, \
m_strokeRect.bottom() + 1 ) );  
-    painter.setPen( QColor( 127, 127, 127 ) );
-    painter.drawLine( QPointF( m_strokeRect.right() + 1, m_strokeRect.top() - 1 ),
-                      QPointF( m_strokeRect.right() + 1, m_strokeRect.bottom() + 1 ) \
                );
-    painter.drawLine( QPointF( m_strokeRect.right() + 1, m_strokeRect.bottom() + 1 \
                ),
-                      QPointF( m_strokeRect.left() - 1, m_strokeRect.bottom() + 1 ) \
); +        painter.setPen( QColor( 127, 127, 127 ) );
+        painter.drawLine( QPointF( m_strokeRect.right() + 1, m_strokeRect.top() - 1 \
), +                        QPointF( m_strokeRect.right() + 1, m_strokeRect.bottom() \
+ 1 ) ); +        painter.drawLine( QPointF( m_strokeRect.right() + 1, \
m_strokeRect.bottom() + 1 ), +                        QPointF( m_strokeRect.left() - \
1, m_strokeRect.bottom() + 1 ) );  
-    painter.setPen( Qt::black );
-    painter.drawLine( innerRect.topRight(), innerRect.topLeft() );
-    painter.drawLine( innerRect.topLeft(), innerRect.bottomLeft() );
+        painter.setPen( Qt::black );
+        painter.drawLine( innerRect.topRight(), innerRect.topLeft() );
+        painter.drawLine( innerRect.topLeft(), innerRect.bottomLeft() );
 
-    painter.setPen( Qt::white );
-    painter.drawLine( innerRect.topRight(), innerRect.bottomRight() );
-    painter.drawLine( innerRect.bottomRight(), innerRect.bottomLeft() );
+        painter.setPen( Qt::white );
+        painter.drawLine( innerRect.topRight(), innerRect.bottomRight() );
+        painter.drawLine( innerRect.bottomRight(), innerRect.bottomLeft() );
+    }
 
     if( ! stroke )
     {
--- trunk/koffice/karbon/widgets/vstrokefillpreview.h #631715:631716
@@ -26,8 +26,6 @@
 #include <QFrame>
 #include <QPixmap>
 
-#include <KoDockFactory.h>
-
 class QEvent;
 class QPaintEvent;
 class QBrush;
@@ -45,12 +43,9 @@
     /// Destroys the preview widget
     ~VStrokeFillPreview();
 
-    virtual QSize sizeHint() const
-        { return QSize( 50, 50 ); }
-    virtual QSize minimumSizeHint() const
-        { return QSize( 20, 20 ); }
-    virtual QSizePolicy sizePolicy() const
-        { return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); }
+    virtual QSize sizeHint() const;
+    virtual QSize minimumSizeHint() const;
+    virtual QSizePolicy sizePolicy() const;
 
     /**
      * Updates the preview with the given fill and stroke


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

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