From 5ccb957341daaf5c223a49391f3076e95832ac1f Mon Sep 17 00:00:00 2001 From: tpearson Date: Mon, 10 May 2010 03:04:21 +0000 Subject: Part of batch commit to enable true tasktray resize support for Trinity applications git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1124757 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- klipper/toplevel.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'klipper/toplevel.cpp') diff --git a/klipper/toplevel.cpp b/klipper/toplevel.cpp index cc5de3f63..748d4a78f 100644 --- a/klipper/toplevel.cpp +++ b/klipper/toplevel.cpp @@ -196,7 +196,9 @@ KlipperWidget::KlipperWidget( QWidget *parent, KConfig* config ) connect( poll, SIGNAL( clipboardChanged( bool ) ), this, SLOT( newClipData( bool ) ) ); - m_pixmap = KSystemTray::loadIcon( "klipper" ); + m_pixmap = KSystemTray::loadSizedIcon( "klipper", width() ); + m_iconOrigWidth = width(); + m_iconOrigHeight = height(); adjustSize(); globalKeys = new KGlobalAccel(this); @@ -290,11 +292,19 @@ void KlipperWidget::mousePressEvent(QMouseEvent *e) void KlipperWidget::paintEvent(QPaintEvent *) { QPainter p(this); - int x = (width() - m_pixmap.width()) / 2; - int y = (height() - m_pixmap.height()) / 2; + // Honor Free Desktop specifications that allow for arbitrary system tray icon sizes + if ((m_iconOrigWidth != width()) || (m_iconOrigHeight != height())) { + QImage newIcon; + m_pixmap = KSystemTray::loadSizedIcon( "klipper", width() ); + newIcon = m_pixmap; + newIcon = newIcon.smoothScale(width(), height()); + m_scaledpixmap = newIcon; + } + int x = (width() - m_scaledpixmap.width()) / 2; + int y = (height() - m_scaledpixmap.height()) / 2; if ( x < 0 ) x = 0; if ( y < 0 ) y = 0; - p.drawPixmap(x , y, m_pixmap); + p.drawPixmap(x, y, m_scaledpixmap); p.end(); } -- cgit v1.2.1