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 ++++++++++++++---- klipper/toplevel.h | 3 +++ 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'klipper') 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(); } diff --git a/klipper/toplevel.h b/klipper/toplevel.h index 735698487..20a6a3027 100644 --- a/klipper/toplevel.h +++ b/klipper/toplevel.h @@ -173,6 +173,9 @@ private: KAction* configureAction; KAction* quitAction; QPixmap m_pixmap; + QPixmap m_scaledpixmap; + int m_iconOrigWidth; + int m_iconOrigHeight; bool bPopupAtMouse :1; bool bKeepContents :1; bool bURLGrabber :1; -- cgit v1.2.3