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

List:       kde-commits
Subject:    branches/KDE/3.5/kdegraphics/kolourpaint/widgets
From:       Clarence Dang <dang () kde ! org>
Date:       2005-09-04 11:05:11
Message-ID: 1125831911.158390.26707.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 456979 by dang:

   * Prevent accidental drags in the Colour Palette from pasting text
     containing the colour code

   * Cells in the bottom row and cells in the rightmost column of the Colour
     Palette are now the same size as the other cells



 M  +36 -6     kpcolortoolbar.cpp  
 M  +2 -0      kpcolortoolbar.h  


--- branches/KDE/3.5/kdegraphics/kolourpaint/widgets/kpcolortoolbar.cpp #456978:456979
@@ -458,11 +458,13 @@
 {
     setName (name);
 
-    KColorCells::setShading (false);  // no 3D look
-
-    // don't let the user clobber the palette too easily
-    KColorCells::setAcceptDrops (false);
-
+    setShading (false);  // no 3D look
+    
+    // Trap KColorDrag so that kpMainWindow does not trap it.
+    // See our impl of dropEvent().
+    setAcceptDrops (true);
+    setAcceptDrags (true);
+    
     connect (this, SIGNAL (colorDoubleClicked (int)),
              SLOT (slotColorDoubleClicked (int)));
 
@@ -528,7 +530,11 @@
     setNumRows (r);
     setNumCols (c);
 
-    setFixedSize (c * 26, r * 26);
+    setCellWidth (26);
+    setCellHeight (26);
+    
+    setFixedSize (numCols () * cellWidth () + frameWidth () * 2,
+                  numRows () * cellHeight () + frameWidth () * 2);
 
 /*
     kdDebug () << "\tlimits: array=" << sizeof (colors) / sizeof (colors [0])
@@ -592,6 +598,18 @@
     m_orientation = o;
 }
 
+// virtual protected [base KColorCells]
+void kpColorCells::dropEvent (QDropEvent *e)
+{
+    // Eat event so that:
+    //
+    // 1. User doesn't clobber the palette (until we support reconfigurable
+    //    palettes)
+    // 2. kpMainWindow::dropEvent() doesn't try to paste colour code as text
+    //    (when the user slips and drags colour cell a little instead of clicking)
+    e->accept ();
+}
+
 // virtual protected
 void kpColorCells::paintCell (QPainter *painter, int row, int col)
 {
@@ -655,6 +673,18 @@
     m_mouseButton = -1;
 }
 
+// protected virtual [base KColorCells]
+void kpColorCells::resizeEvent (QResizeEvent *e)
+{
+    // KColorCells::resizeEvent() tries to adjust the cellWidth and cellHeight
+    // to the current dimensions but doesn't take into account
+    // frame{Width,Height}().
+    //
+    // In any case, we already set the cell{Width,Height} and a fixed
+    // widget size and don't want any of it changed.  Eat the resize event.
+    (void) e;
+}
+
 // protected slot
 void kpColorCells::slotColorSelected (int cell)
 {
--- branches/KDE/3.5/kdegraphics/kolourpaint/widgets/kpcolortoolbar.h #456978:456979
@@ -139,8 +139,10 @@
 protected:
     Qt::Orientation m_orientation;
 
+    virtual void dropEvent (QDropEvent *e);
     virtual void paintCell (QPainter *painter, int row, int col);
     virtual void mouseReleaseEvent (QMouseEvent *e);
+    virtual void resizeEvent (QResizeEvent *e);
 
     int m_mouseButton;
 
[prev in list] [next in list] [prev in thread] [next in thread] 

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