Browse Source

Part of batch commit to enable true tasktray resize support for Trinity applications

git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/amarok@1124763 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
v3.5.13-sru
tpearson 12 years ago
parent
commit
448423a4ca
  1. 30
      amarok/src/systray.cpp
  2. 1
      amarok/src/systray.h

30
amarok/src/systray.cpp

@ -3,6 +3,7 @@
//
// Contributors: Stanislav Karchebny <berkus@users.sf.net>, (C) 2003
// berkus, mxcl, eros, eean
// Timothy Pearson <kb9vqf@pearsoncomputing.net> (c) 2010
//
// Copyright: like rest of Amarok
//
@ -23,9 +24,9 @@
namespace Amarok
{
static QPixmap
loadOverlay( const char *iconName )
loadOverlay( const char *iconName, int iconWidth )
{
return QImage( locate( "data", QString( "amarok/images/b_%1.png" ).arg( iconName ) ), "PNG" ).smoothScale( 10, 10 );
return QImage( locate( "data", QString( "amarok/images/b_%1.png" ).arg( iconName ) ), "PNG" ).smoothScale( ((iconWidth/2)-(iconWidth/20)), ((iconWidth/2)-(iconWidth/20)) );
}
}
@ -54,9 +55,9 @@ Amarok::TrayIcon::TrayIcon( QWidget *playerWidget )
quit->disconnect();
connect( quit, SIGNAL(activated()), kapp, SLOT(quit()) );
baseIcon = KSystemTray::loadIcon( "amarok" );
playOverlay = Amarok::loadOverlay( "play" );
pauseOverlay = Amarok::loadOverlay( "pause" );
baseIcon = KSystemTray::loadSizedIcon( "amarok", width() );
playOverlay = Amarok::loadOverlay( "play", width() );
pauseOverlay = Amarok::loadOverlay( "pause", width() );
overlayVisible = false;
//paintIcon();
@ -101,6 +102,25 @@ Amarok::TrayIcon::event( QEvent *e )
}
}
void Amarok::TrayIcon::resizeEvent ( QResizeEvent * )
{
// Honor Free Desktop specifications that allow for arbitrary system tray icon sizes
baseIcon = KSystemTray::loadSizedIcon( "amarok", width() );
if (overlay == &pauseOverlay) {
pauseOverlay = Amarok::loadOverlay( "pause", width() );
overlay = &pauseOverlay;
}
if (overlay == &playOverlay) {
playOverlay = Amarok::loadOverlay( "play", width() );
overlay = &playOverlay;
}
playOverlay = Amarok::loadOverlay( "play", width() );
pauseOverlay = Amarok::loadOverlay( "pause", width() );
grayedIcon = QPixmap();
alternateIcon = QPixmap();
paintIcon( -1, true );
}
void
Amarok::TrayIcon::engineStateChanged( Engine::State state, Engine::State /*oldState*/ )
{

1
amarok/src/systray.h

@ -30,6 +30,7 @@ protected:
virtual void engineTrackPositionChanged( long position, bool /*userSeek*/ );
// get notified of 'highlight' color change
virtual void paletteChange( const QPalette & oldPalette );
void resizeEvent ( QResizeEvent * );
private:
bool event( QEvent* );

Loading…
Cancel
Save