summaryrefslogtreecommitdiffstats
path: root/klipper/toplevel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'klipper/toplevel.cpp')
-rw-r--r--klipper/toplevel.cpp18
1 files changed, 14 insertions, 4 deletions
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();
}