From be5389144b23dad9f4b131118e158138fdd027b5 Mon Sep 17 00:00:00 2001 From: tpearson Date: Mon, 10 May 2010 03:03:22 +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/kdelibs@1124756 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kdeui/ksystemtray.cpp | 18 +++++++++++++----- kdeui/ksystemtray.h | 13 ++++++++++++- 2 files changed, 25 insertions(+), 6 deletions(-) (limited to 'kdeui') diff --git a/kdeui/ksystemtray.cpp b/kdeui/ksystemtray.cpp index 593bc6bc0..33d7f3506 100644 --- a/kdeui/ksystemtray.cpp +++ b/kdeui/ksystemtray.cpp @@ -29,9 +29,9 @@ #include "kaboutdata.h" #ifdef Q_WS_X11 -#include -#include -#include +#include +#include +#include #endif #include @@ -62,7 +62,7 @@ KSystemTray::KSystemTray( QWidget* parent, const char* name ) #ifdef Q_WS_X11 QXEmbed::initialize(); #endif - + d = new KSystemTrayPrivate; d->actionCollection = new KActionCollection(this); @@ -95,6 +95,9 @@ KSystemTray::KSystemTray( QWidget* parent, const char* name ) } setCaption( KGlobal::instance()->aboutData()->programName()); setAlignment( alignment() | Qt::AlignVCenter | Qt::AlignHCenter ); + + // Handle the possibility that the requested system tray size is something other than 22x22 pixels, per the Free Desktop specifications + setScaledContents(true); } KSystemTray::~KSystemTray() @@ -306,7 +309,7 @@ KActionCollection* KSystemTray::actionCollection() { return d->actionCollection; } - + QPixmap KSystemTray::loadIcon( const QString &icon, KInstance *instance ) { KConfig *appCfg = kapp->config(); @@ -315,6 +318,11 @@ QPixmap KSystemTray::loadIcon( const QString &icon, KInstance *instance ) return instance->iconLoader()->loadIcon( icon, KIcon::Panel, iconWidth ); } +QPixmap KSystemTray::loadSizedIcon( const QString &icon, int iconWidth, KInstance *instance ) +{ + return instance->iconLoader()->loadIcon( icon, KIcon::Panel, iconWidth ); +} + void KSystemTray::setPixmap( const QPixmap& p ) { QLabel::setPixmap( p ); diff --git a/kdeui/ksystemtray.h b/kdeui/ksystemtray.h index 04dce718a..b0dab69b6 100644 --- a/kdeui/ksystemtray.h +++ b/kdeui/ksystemtray.h @@ -108,7 +108,7 @@ public: * configuration dialog). The default value is KAboutData::programName(). */ virtual void setCaption( const QString& title ); - + /** * Loads an icon @p icon using the icon loader class of the given instance @p instance. * The icon is applied the panel effect as it should only be used to be shown in the @@ -119,6 +119,17 @@ public: */ static QPixmap loadIcon( const QString &icon, KInstance *instance=KGlobal::instance() ); + /** + * Loads an icon @p icon using the icon loader class of the given instance @p instance. + * The icon is applied the panel effect as it should only be used to be shown in the + * system tray. + * It's commonly used in the form : systray->setPixmap( systray->loadIcon( "mysystray", iconWidth ) ); + * This is essentially the same as loadIcon(), but with a forced icon size + * + * @since 3.5.12 + */ + static QPixmap loadSizedIcon( const QString &icon, int iconWidth, KInstance *instance=KGlobal::instance() ); + signals: /** * Emitted when quit is selected in the menu. If you want to perform any other -- cgit v1.2.1