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

List:       kde-commits
Subject:    kdeartwork/styles/plastik
From:       Sandro Giessl <sandro () giessl ! com>
Date:       2004-05-03 14:24:20
Message-ID: 20040503142420.0B2389265 () office ! kde ! org
[Download RAW message or body]

CVS commit by giessl: 

The same result can be achieved without focusWidget...

CCMAIL: 80807-done@bugs.kde.org


  M +16 -25    plastik.cpp   1.73
  M +0 -1      plastik.h   1.24


--- kdeartwork/styles/plastik/plastik.cpp  #1.72:1.73
@@ -156,5 +156,4 @@ PlastikStyle::PlastikStyle() : KStyle( A
 {
     hoverWidget = 0;
-    focusWidget = 0;
 
     QSettings settings;
@@ -1749,7 +1748,9 @@ void PlastikStyle::drawPrimitive(Primiti
             bool isReadOnly = false;
             bool isEnabled = true;
-            if ( focusWidget && ::qt_cast<QLineEdit*>(focusWidget) )
+            // panel is highlighted by default if it has focus, but if we have access to the
+            // widget itself we can try to avoid highlighting in case it's readOnly or disabled.
+            if (p->device() && dynamic_cast<QLineEdit*>(p->device()))
             {
-                QLineEdit* lineEdit = static_cast<QLineEdit*>(focusWidget);
+                QLineEdit* lineEdit = dynamic_cast<QLineEdit*>(p->device());
                 isReadOnly = lineEdit->isReadOnly();
                 isEnabled = lineEdit->isEnabled();
@@ -2663,11 +2664,9 @@ void PlastikStyle::drawComplexControl(Co
 
             const QComboBox *cb = dynamic_cast<const QComboBox *>(widget);
-            bool editable, hasFocus;
             // at the moment cb is only needed to check if the combo box is editable or not.
             // if cb doesn't exist, just assume false and the app (gideon! ;) ) at least doesn't crash.
-            if(!cb) {
-                editable = false;
-                hasFocus = false;
-            } else {
+            bool editable = false;
+            bool hasFocus = false;
+            if (cb) {
                 editable = cb->editable();
                 hasFocus = cb->hasFocus();
@@ -2846,4 +2845,8 @@ void PlastikStyle::drawComplexControl(Co
             PrimitiveElement pe;
 
+            bool hasFocus = false;
+            if (sw)
+                hasFocus = sw->hasFocus();
+
             const QColor buttonColor = enabled?cg.button():cg.background();
             const QColor inputColor = enabled?cg.base():cg.background();
@@ -2934,5 +2937,5 @@ void PlastikStyle::drawComplexControl(Co
             const QRect Rcontent = QRect(reverseLayout?r.left()+1+handleWidth+1:r.left()+1, r.top()+1,
                     r.width()-1-2-handleWidth, r.height()-2);
-            if (_inputFocusHighlight && widget == focusWidget && enabled)
+            if (_inputFocusHighlight && hasFocus && enabled)
             {
               p->setPen( getColor(cg,FocusHighlight).dark(130) );
@@ -2946,5 +2949,5 @@ void PlastikStyle::drawComplexControl(Co
             p->drawLine(Rcontent.left()+1, Rcontent.top(),
                     reverseLayout?Rcontent.right()-1:Rcontent.right(), Rcontent.top() );
-            if (_inputFocusHighlight && widget == focusWidget && enabled)
+            if (_inputFocusHighlight && hasFocus && enabled)
             {
               p->setPen( getColor(cg,FocusHighlight).light(130) );
@@ -3272,12 +3275,6 @@ bool PlastikStyle::eventFilter(QObject *
         {
             QWidget* spinbox = widget->parentWidget();
-            if ( ev->type() == QEvent::FocusIn ) 
+            if ((ev->type() == QEvent::FocusIn) || (ev->type() == QEvent::FocusOut))
             {
-                focusWidget = spinbox;
-                spinbox->repaint(false);
-            }
-            else if ( ev->type() == QEvent::FocusOut && spinbox == focusWidget )
-            {
-                focusWidget = 0;
                 spinbox->repaint(false);
             }
@@ -3285,12 +3282,6 @@ bool PlastikStyle::eventFilter(QObject *
         }
 
-        if ( ev->type() == QEvent::FocusIn ) 
-        {
-            focusWidget = widget;
-            widget->repaint(false);
-        }
-        else if ( ev->type() == QEvent::FocusOut && obj == focusWidget )
+        if ((ev->type() == QEvent::FocusIn) || (ev->type() == QEvent::FocusOut))
         {
-            focusWidget = 0;
             widget->repaint(false);
         }

--- kdeartwork/styles/plastik/plastik.h  #1.23:1.24
@@ -251,5 +251,4 @@ protected:
 
     QWidget* hoverWidget;
-    QWidget* focusWidget;
 protected slots:
     void khtmlWidgetDestroyed(QObject* w);


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

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