1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-21 00:09:47 +01:00

Determine the notification icon size on the default font height.

This commit is contained in:
Uwe L. Korn 2013-02-13 15:20:27 +01:00
parent 461f650dbd
commit 93b06e5d95
2 changed files with 24 additions and 3 deletions

View File

@ -44,7 +44,10 @@
#include "TomahawkSettings.h"
#include "utils/Logger.h"
#include "utils/TomahawkUtilsGui.h"
#include <QPainter>
#include <QSvgRenderer>
#include <QtDBus/QDBusConnection>
#include <QtDBus/QDBusMessage>
#include <QtGui/QImage>
@ -105,6 +108,16 @@ FdoNotifyPlugin::pushInfo( Tomahawk::InfoSystem::InfoPushData pushData )
}
/**
* Determine a consistent size for the cover image depending on the default font height
*/
int
FdoNotifyPlugin::getNotificationIconHeight()
{
return 6*TomahawkUtils::defaultFontHeight();
}
void
FdoNotifyPlugin::notifyUser( const QString &messageText )
{
@ -118,7 +131,7 @@ FdoNotifyPlugin::notifyUser( const QString &messageText )
arguments << QStringList(); //actions
QVariantMap dict;
dict["desktop-entry"] = QString( "tomahawk" );
dict[ "image_data" ] = ImageConverter::variantForImage( QImage( RESPATH "icons/tomahawk-icon-128x128.png" ) );
dict[ "image_data" ] = ImageConverter::variantForImage( QImage( RESPATH "icons/tomahawk-icon-512x512.png" ).scaledToHeight( getNotificationIconHeight() ) );
arguments << dict; //hints
arguments << qint32( -1 ); //expire_timeout
message.setArguments( arguments );
@ -159,10 +172,16 @@ FdoNotifyPlugin::nowPlaying( const QVariant &input )
arguments << QStringList(); //actions
QVariantMap dict;
dict["desktop-entry"] = QString( "tomahawk" );
// If there is a cover availble use it, else use Tomahawk logo as default.
QImage image;
if ( map.contains( "coveruri" ) && map[ "coveruri" ].canConvert< QString >() )
dict[ "image_data" ] = ImageConverter::variantForImage( QImage( map[ "coveruri" ].toString(), "PNG" ) );
image = QImage( map[ "coveruri" ].toString(), "PNG" );
else
dict[ "image_data" ] = ImageConverter::variantForImage( QImage( RESPATH "icons/tomahawk-icon-128x128.png" ) );
image = QImage( RESPATH "icons/tomahawk-icon-512x512.png" );
// Convert image to QVariant and scale to a consistent size.
dict[ "image_data" ] = ImageConverter::variantForImage( image.scaledToHeight( getNotificationIconHeight() ) );
arguments << dict; //hints
arguments << qint32( -1 ); //expire_timeout
message.setArguments( arguments );

View File

@ -56,6 +56,8 @@ protected slots:
}
private:
int getNotificationIconHeight();
void notifyUser( const QString &messageText );
void nowPlaying( const QVariant &input );