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

List:       kde-core-devel
Subject:    [PATCH] Cosmetic patches for KDE 3.5.4
From:       Remi Villatel <maxilys () tele2 ! fr>
Date:       2006-08-04 23:00:00
Message-ID: 44D3D170.4040308 () tele2 ! fr
[Download RAW message or body]

Hi there,

Here are the cosmetic patches I've applied since KDE 3.5.2 but of which
I've always delayed the posting for an unknown reason. I hope it's OK to
flood --just a little-- the list.

*kdelibs/kdeui/karrowbutton.cpp.diff*

To prevent the shift of the arrow when the style doesn't want it.
(Hardcoded shifting is a real nuisance.)

Also to set Style_MouseOver when necessary so that Taskbar2's tiny
window list button looks better.

*kdelibs/kdeui/kpopupmenu.cpp.diff*

To remove the unnecessary line drawn with highlight() color on top of
every popup menu title. (A debug feature that was never removed?)

*kdelibs/kdeui/ktabbar.cpp.diff*

To make the tabs respect the reverse layout. (Pixmap on the right, label
on the left.) Note: Doesn't work with 'kcmshell panel' (yet).

*kdelibs/kdeui/ktabctl.cpp.diff*

To remove the (ugly) hardcoded drawing.

*kdelibs/kdeui/ktoolbarbutton.cpp.diff*

To remove the strange grey/blue color used by the label of hovered
toolbuttons (KGlobalSettings::toolBarHighlightColor() is a hardcoded
color) and the hardcoded buttonText() color too. (Most styles fill the
toolbar with background() which may makes buttonText() illegible.)

Also to make the toolbuttons respect the reverse layout. (Pixmap on the
right and label on the left for "Text Alongside Icons" and popup
indicator on the left when available.)

Plus a few simplifications in the drawing.

IMHO, a few "KPE_toolbutton_something" would be really nice to give more
control to the styles plugins.

---------------------

*kdebase/kicker/kicker/ui/k_mnu.cpp.diff*

To re-enable the PopupMenuTitles which are disabled for an unknown
reason. (They are always enabled everywhere else. Why not here too?)

*kdebase/kicker/kicker/ui/popupmenutitle.h.diff*

To remove the unnecessary line drawn with highlight() color on top of
every popup menu title. (Another forgotten debug feature?)

---------------------

I hope a few of them will be accepted so that I won't have to patch KDE
3.5.5 too.  ;-)

-- 
==================
Remi Villatel
maxilys_@_tele2.fr
==================

["k_mnu.cpp.diff" (text/x-patch)]

--- k_mnu.cpp.ORIG	2006-03-17 11:17:32.000000000 +0100
+++ k_mnu.cpp	2006-08-03 07:02:44.000000000 +0200
@@ -195,9 +195,9 @@
     {
         int id;
         id = insertItem(new PopupMenuTitle(i18n("All Applications"), font()), -1 /* id */, 0);
-        setItemEnabled( id, false );
+        setItemEnabled( id, true );
         id = insertItem(new PopupMenuTitle(i18n("Actions"), font()), -1 /* id */, -1);
-        setItemEnabled( id, false );
+        setItemEnabled( id, true );
     }
 
     // create recent menu section
@@ -623,7 +623,7 @@
                         new PopupMenuTitle(
                             RecentlyLaunchedApps::the().caption(), font()),
                         serviceMenuEndId(), 0);
-                    setItemEnabled( id, false );
+                    setItemEnabled( id, true );
                 }
                 insertMenuItem(s, nId++, nIndex);
                 RecentlyLaunchedApps::the().m_nNumMenuItems++;
@@ -714,7 +714,7 @@
                     int id = insertItem(new PopupMenuTitle(
                         RecentlyLaunchedApps::the().caption(),
                             font()), nId - 1, 0);
-                    setItemEnabled( id, false );
+                    setItemEnabled( id, true );
                 }
                 insertMenuItem(s, nId++, KickerSettings::showMenuTitles() ?
                     1 : 0);


["karrowbutton.cpp.diff" (text/x-patch)]

--- karrowbutton.cpp.ORIG	2005-10-10 17:06:38.000000000 +0200
+++ karrowbutton.cpp	2006-08-03 08:13:03.000000000 +0200
@@ -65,7 +65,8 @@
         p->fillRect( rect(), colorGroup().brush( QColorGroup::Background ) );
 	style().drawPrimitive( QStyle::PE_Panel, p, QRect( 0, 0, width(), height() ),
 			       colorGroup(), 
-			       isDown() ? QStyle::Style_Sunken : QStyle::Style_Default,
+			       isDown() ? QStyle::Style_Sunken :
+			       hasMouse() ? QStyle::Style_MouseOver : QStyle::Style_Default,
 			       QStyleOption( 2, 0 ) );
 
 	if (static_cast<unsigned int>(width()) < arrowSize + margin ||
@@ -87,9 +88,9 @@
 		y = (height() - arrowSize) / 2;
 	}
 
-	if (isDown()) {
-		x++;
-		y++;
+	if (isDown()) {
+		x += style().pixelMetric(QStyle::PM_ButtonShiftHorizontal);
+		y += style().pixelMetric(QStyle::PM_ButtonShiftVertical);
 	}
 
 	QStyle::PrimitiveElement e = QStyle::PE_ArrowLeft;


["kpopupmenu.cpp.diff" (text/x-patch)]

--- kpopupmenu.cpp.ORIG	2005-10-10 17:06:38.000000000 +0200
+++ kpopupmenu.cpp	2006-08-03 08:10:37.000000000 +0200
@@ -108,9 +108,6 @@
                        AlignCenter | SingleLine, titleStr);
         }
     }
-
-    p.setPen(palette().active().highlight());
-    p.drawLine(0, 0, r.right(), 0);
 }
 
 QSize KPopupTitle::sizeHint() const


["ktabbar.cpp.diff" (text/x-patch)]

--- ktabbar.cpp.ORIG	2005-10-10 17:06:38.000000000 +0200
+++ ktabbar.cpp	2006-08-03 08:19:26.000000000 +0200
@@ -343,9 +343,15 @@
         int inactiveXShift = style().pixelMetric( QStyle::PM_TabBarTabShiftHorizontal, this );
         int inactiveYShift = style().pixelMetric( QStyle::PM_TabBarTabShiftVertical, this );
 
-        int right = t->text().isEmpty() ? br.right() - pixw : br.left() + 2;
+        int pixX = t->text().isEmpty() ? br.center().x() - pixw / 2 : br.left() + 2;
 
-        p->drawPixmap( right + (selected ? 0 : inactiveXShift),
+        if ( QApplication::reverseLayout() )
+        {
+            r.moveLeft(pixX);
+            pixX = r.right() + 6;
+            r.setRight( r.right() - 2 );
+        }
+        p->drawPixmap( pixX + (selected ? 0 : inactiveXShift),
                        br.center().y() - pixh / 2 + (selected ? 0 : inactiveYShift),
                        pixmap );
     }


["ktabctl.cpp.diff" (text/x-patch)]

--- ktabctl.cpp.ORIG	2005-10-10 17:06:38.000000000 +0200
+++ ktabctl.cpp	2006-08-03 08:22:04.000000000 +0200
@@ -24,6 +24,7 @@
  * However, this is based on the original QTabDialog.
  */
 
+#include <qstyle.h>
 #include <qtabbar.h>
 #include <qpushbutton.h>
 #include <qpainter.h>
@@ -245,24 +246,9 @@
 
     QPainter p;
     p.begin(this);
-
-    int y0 = getChildRect().top() - 1;
-    int y1 = getChildRect().bottom() + 2;
-    int x1 = getChildRect().right() + 2;
-    int x0 = getChildRect().left() - 1;
-
-    p.setPen(colorGroup().light());
-    p.drawLine(x0, y0 - 1, x1 - 1, y0 - 1);      /* 1st top line */
-    p.setPen(colorGroup().midlight());
-    p.drawLine(x0, y0, x1 - 1, y0);      /* 2nd top line */
-    p.setPen(colorGroup().light());
-    p.drawLine(x0, y0 + 1, x0, y1);      /* left line */
-    p.setPen(black);
-    p.drawLine(x1, y1, x0, y1);          /* bottom line */
-    p.drawLine(x1, y1 - 1, x1, y0);
-    p.setPen(colorGroup().dark());
-    p.drawLine(x0 + 1, y1 - 1, x1 - 1, y1 - 1);  /* bottom */
-    p.drawLine(x1 - 1, y1 - 2, x1 - 1, y0 + 1);
+    QRect r = getChildRect();
+    r.addCoords(-1, -1, 1, 1);
+    style().drawPrimitive(QStyle::PE_PanelTabWidget, &p, r, colorGroup());
     p.end();
 }
 


["ktoolbarbutton.cpp.diff" (text/x-patch)]

--- ktoolbarbutton.cpp.ORIG	2005-10-10 17:06:38.000000000 +0200
+++ ktoolbarbutton.cpp	2006-08-03 01:20:25.000000000 +0200
@@ -502,57 +502,56 @@
   QFontMetrics fm(tmp_font);
   QRect textRect;
   int textFlags = 0;
+  int shiftX = 0;
+  int shiftY = 0;
+  if ( isDown() || isOn() )
+  {
+     shiftX = style().pixelMetric(QStyle::PM_ButtonShiftHorizontal);
+     shiftY = style().pixelMetric(QStyle::PM_ButtonShiftVertical);
+  }
+  QPixmap pixmap = 0;
+  int pixW = 0;
+  int pixH = 0;
+  if (d->m_iconText != KToolBar::TextOnly)
+  {
+      pixmap = iconSet().pixmap( QIconSet::Automatic,
+          isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) 
+                      : QIconSet::Disabled,
+          isOn() ? QIconSet::On : QIconSet::Off );
+      pixW = pixmap.width();
+      pixH = pixmap.height();
+  }
 
   if (d->m_iconText == KToolBar::IconOnly) // icon only
   {
-    QPixmap pixmap = iconSet().pixmap( QIconSet::Automatic,
-        isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) :
-            	QIconSet::Disabled,
-        isOn() ? QIconSet::On : QIconSet::Off );
     if( !pixmap.isNull())
     {
-      dx = ( width() - pixmap.width() ) / 2;
-      dy = ( height() - pixmap.height() ) / 2;
-      if ( isDown() && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle )
-      {
-        ++dx;
-        ++dy;
-      }
-      _painter->drawPixmap( dx, dy, pixmap );
+      dx = ( width() - pixW ) / 2;
+      dy = ( height() - pixH ) / 2;
+      _painter->drawPixmap( dx+shiftX, dy+shiftY, pixmap );
     }
   }
   else if (d->m_iconText == KToolBar::IconTextRight) // icon and text (if any)
   {
-    QPixmap pixmap = iconSet().pixmap( QIconSet::Automatic,
-        isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) :
-            	QIconSet::Disabled,
-        isOn() ? QIconSet::On : QIconSet::Off );
     if( !pixmap.isNull())
     {
-      dx = 4;
-      dy = ( height() - pixmap.height() ) / 2;
-      if ( isDown() && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle )
-      {
-        ++dx;
-        ++dy;
-      }
-      _painter->drawPixmap( dx, dy, pixmap );
+        if (! QApplication::reverseLayout())
+            dx = 4;
+        else
+            dx = width() - pixW - 4;
+        dy = ( height() - pixH ) / 2;
+        _painter->drawPixmap( dx+shiftX, dy+shiftY, pixmap );
     }
 
     if (!textLabel().isNull())
     {
-      textFlags = AlignVCenter|AlignLeft;
-      if (!pixmap.isNull())
-        dx = 4 + pixmap.width() + 2;
-      else
-        dx = 4;
-      dy = 0;
-      if ( isDown() && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle )
-      {
-        ++dx;
-        ++dy;
-      }
-      textRect = QRect(dx, dy, width()-dx, height());
+        textFlags = AlignVCenter|AlignAuto;
+        if (! QApplication::reverseLayout())
+            dx = 4 + (pixmap.isNull() ? 0 : pixW + 4);
+        else
+            dx = 4;
+        dy = 0;
+        textRect = QRect(dx+shiftX, dy+shiftY, width()-dx, height());
     }
   }
   else if (d->m_iconText == KToolBar::TextOnly)
@@ -562,30 +561,16 @@
       textFlags = AlignVCenter|AlignLeft;
       dx = (width() - fm.width(textLabel())) / 2;
       dy = (height() - fm.lineSpacing()) / 2;
-      if ( isDown() && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle )
-      {
-        ++dx;
-        ++dy;
-      }
-      textRect = QRect( dx, dy, fm.width(textLabel()), fm.lineSpacing() );
+      textRect = QRect( dx+shiftX, dy+shiftY, fm.width(textLabel()), fm.lineSpacing() );
     }
   }
   else if (d->m_iconText == KToolBar::IconTextBottom)
   {
-    QPixmap pixmap = iconSet().pixmap( QIconSet::Automatic,
-        isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) :
-            	QIconSet::Disabled,
-        isOn() ? QIconSet::On : QIconSet::Off );
     if( !pixmap.isNull())
     {
       dx = (width() - pixmap.width()) / 2;
       dy = (height() - fm.lineSpacing() - pixmap.height()) / 2;
-      if ( isDown() && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle )
-      {
-        ++dx;
-        ++dy;
-      }
-      _painter->drawPixmap( dx, dy, pixmap );
+      _painter->drawPixmap( dx+shiftX, dy+shiftY, pixmap );
     }
 
     if (!textLabel().isNull())
@@ -593,13 +578,7 @@
       textFlags = AlignBottom|AlignHCenter;
       dx = (width() - fm.width(textLabel())) / 2;
       dy = height() - fm.lineSpacing() - 4;
-
-      if ( isDown() && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle )
-      {
-        ++dx;
-        ++dy;
-      }
-      textRect = QRect( dx, dy, fm.width(textLabel()), fm.lineSpacing() );
+      textRect = QRect( dx+shiftX, dy+shiftY, fm.width(textLabel()), fm.lineSpacing() );
     }
   }
 
@@ -609,23 +588,19 @@
       _painter->setFont(KGlobalSettings::toolBarFont());
       if (!isEnabled())
         _painter->setPen(palette().disabled().dark());
-      else if(d->m_isRaised)
-        _painter->setPen(KGlobalSettings::toolBarHighlightColor());
       else
-	_painter->setPen( colorGroup().buttonText() );
+          _painter->setPen( QPalette::foregroundRoleFromMode(this->backgroundMode()) );
       _painter->drawText(textRect, textFlags, textLabel());
   }
 
   if (QToolButton::popup())
   {
-    QStyle::SFlags arrowFlags = QStyle::Style_Default;
-
-    if (isDown())	arrowFlags |= QStyle::Style_Down;
-    if (isEnabled()) 	arrowFlags |= QStyle::Style_Enabled;
+    QRect arrowRect(width()-7, height()-7, 7, 7);
+    if (QApplication::reverseLayout())
+         arrowRect.moveLeft(0);
 
-      style().drawPrimitive(QStyle::PE_ArrowDown, _painter,
-          QRect(width()-7, height()-7, 7, 7), colorGroup(),
-	  arrowFlags, QStyleOption() );
+    style().drawPrimitive(QStyle::PE_ArrowDown, _painter,
+        arrowRect, colorGroup(), flags, QStyleOption() );
   }
 }
 


["popupmenutitle.h.diff" (text/x-patch)]

--- popupmenutitle.h.ORIG	2005-09-10 10:25:31.000000000 +0200
+++ popupmenutitle.h	2006-08-03 08:55:41.000000000 +0200
@@ -57,9 +57,6 @@
                         AlignCenter | SingleLine, 
                         m_desktopName);
         }
-
-        p->setPen(cg.highlight());
-        p->drawLine(0, 0, r.right(), 0);
         p->restore();
     }
 



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

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