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

List:       kde-commits
Subject:    branches/KDE/3.5/kdetoys/kweather
From:       Benoit Minisini <gambas () users ! sourceforge ! net>
Date:       2008-07-28 10:48:06
Message-ID: 1217242086.866492.21489.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 838616 by bminisini:

BUG: 146007

Fix kweather transparency.
Make the kweather button behave like other kicker buttons.


 M  +5 -3      dockwidget.cpp  
 M  +14 -2     kweather.cpp  
 M  +6 -0      kweather.h  
 M  +29 -16    weatherbutton.cpp  


--- branches/KDE/3.5/kdetoys/kweather/dockwidget.cpp #838615:838616
@@ -24,6 +24,7 @@
 #include <qlayout.h>
 #include <qlabel.h>
 #include <qtimer.h>
+#include <qobjectlist.h>
 
 #include <kdebug.h>
 #include <kglobalsettings.h>
@@ -33,12 +34,11 @@
         const char *name) : QWidget(parent,name), m_locationCode( location ), \
m_orientation( Horizontal )  {
     m_font = KGlobalSettings::generalFont();
+    setBackgroundOrigin( AncestorOrigin );
     initDock();
     connect(m_button, SIGNAL( clicked() ), SIGNAL( buttonClicked() ));
 
     m_weatherService = new WeatherService_stub( "KWeatherService", "WeatherService" \
                );
-
-    setBackgroundOrigin( AncestorOrigin );
 }
 
 dockwidget::~dockwidget()
@@ -191,6 +191,8 @@
     layout->addWidget(m_lblWind);
     layout->addWidget(m_lblPres);
 
+    mainLayout->addSpacing(8);
+
     updateFont();
 
     QTimer::singleShot( 0, this, SLOT( showWeather() ) );
@@ -366,7 +368,7 @@
     }
 
     updateFont();
-    return w;
+    return w + 4;
 }
 
 int dockwidget::heightForWidth( int w )
--- branches/KDE/3.5/kdetoys/kweather/kweather.cpp #838615:838616
@@ -31,6 +31,7 @@
 
 #include <qfile.h>
 #include <qtimer.h>
+#include <qpalette.h>
 
 #include "kweather.h"
 #include "reportview.h"
@@ -57,6 +58,7 @@
 	kdDebug(12004) << "Constructor " << endl;
 	setObjId("weatherIface");
 
+	setBackgroundOrigin( QWidget::AncestorOrigin );
 	loadPrefs();
 	initContextMenu();
 	initDCOP();
@@ -64,7 +66,7 @@
 	dockWidget = new dockwidget(reportLocation, this, "dockwidget");
 	connect(dockWidget, SIGNAL(buttonClicked()), SLOT(doReport()));
 	dockWidget->setViewMode(mViewMode);
-	dockWidget->setPaletteForegroundColor(mTextColor);
+	setLabelColor();
 
 	timeOut = new QTimer(this, "timeOut" );
 	connect(timeOut, SIGNAL(timeout()), SLOT(timeout()));
@@ -328,7 +330,7 @@
 
     dockWidget->setLocationCode(reportLocation);
     dockWidget->setViewMode(mViewMode);
-    dockWidget->setPaletteForegroundColor(mTextColor);
+    setLabelColor();
     emit updateLayout();
 
     if (logOn && !fileName.isEmpty())
@@ -410,4 +412,14 @@
 	dockWidget->resizeView(e->size());
 }
 
+void kweather::setLabelColor()
+{
+	setPaletteForegroundColor(mTextColor);
+}
+
+void kweather::paletteChange(const QPalette &)
+{
+	setLabelColor();
+}
+
 #include "kweather.moc"
--- branches/KDE/3.5/kdetoys/kweather/kweather.h #838615:838616
@@ -28,6 +28,7 @@
 class reportView;
 class KPopupMenu;
 class WeatherService_stub;
+class QPalette;
 
 class kweather : public KPanelApplet, public weatherIface
 {
@@ -41,11 +42,16 @@
 	int heightForWidth(int i) const;
 	int widthForHeight(int i) const;
 	void refresh(QString);
+	void setBackground();
+	void setLabelColor();
 
 public slots: // Public slots
 	void preferences();
 	void about();
 
+protected:
+	void paletteChange(const QPalette &);
+
 protected slots:
 	void doReport();
 	void timeout();
--- branches/KDE/3.5/kdetoys/kweather/weatherbutton.cpp #838615:838616
@@ -47,32 +47,45 @@
 
 void WeatherButton::drawButton( QPainter *p )
 {
-    if ( isDown() || isOn() )
-    {
-        p->setPen( Qt::black );
-        p->drawLine( 0, 0, width()-1, 0 );
-        p->drawLine( 0, 0, 0, height()-1 );
-        p->setPen( colorGroup().light() );
-        p->drawLine( 0, height()-1, width()-1, height()-1 );
-        p->drawLine( width()-1, 0, width()-1, height()-1 );
-    }
-
-    drawButtonLabel( p );
+    drawButtonLabel(p);
 }
 
 void WeatherButton::drawButtonLabel( QPainter *p )
 {
-    if ( pixmap() )
+    if (!pixmap())
     {
-        QPixmap pix = m_highlight? m_activeIcon : m_normalIcon;
+        return;
+    }
 
-        if ( isOn() || isDown() )
-            p->translate( 2, 2 );
+    QPixmap pix = m_highlight? m_activeIcon : m_normalIcon;
 
-        p->drawPixmap( pixmapOrigin(), pix );
+    if (isOn() || isDown())
+    {
+        pix = pix.convertToImage().smoothScale(pix.width() - 2,
+                                               pix.height() - 2);
     }
+
+    int h = height();
+    int w = width();
+    int ph = pix.height();
+    int pw = pix.width();
+    int margin = 3;
+    QPoint origin(margin / 2, margin / 2);
+
+    if (ph < (h - margin))
+    {
+        origin.setY((h - ph) / 2);
+    }
+
+    if (pw < (w - margin))
+    {
+        origin.setX((w - pw) / 2);
+    }
+
+    p->drawPixmap(origin, pix);
 }
 
+
 void WeatherButton::setPixmap( const QPixmap &pix )
 {
     QButton::setPixmap( pix );


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

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