mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Determine the notification icon size on the default font height.
This commit is contained in:
@@ -44,7 +44,10 @@
|
|||||||
#include "TomahawkSettings.h"
|
#include "TomahawkSettings.h"
|
||||||
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
#include "utils/TomahawkUtilsGui.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QSvgRenderer>
|
||||||
#include <QtDBus/QDBusConnection>
|
#include <QtDBus/QDBusConnection>
|
||||||
#include <QtDBus/QDBusMessage>
|
#include <QtDBus/QDBusMessage>
|
||||||
#include <QtGui/QImage>
|
#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
|
void
|
||||||
FdoNotifyPlugin::notifyUser( const QString &messageText )
|
FdoNotifyPlugin::notifyUser( const QString &messageText )
|
||||||
{
|
{
|
||||||
@@ -118,7 +131,7 @@ FdoNotifyPlugin::notifyUser( const QString &messageText )
|
|||||||
arguments << QStringList(); //actions
|
arguments << QStringList(); //actions
|
||||||
QVariantMap dict;
|
QVariantMap dict;
|
||||||
dict["desktop-entry"] = QString( "tomahawk" );
|
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 << dict; //hints
|
||||||
arguments << qint32( -1 ); //expire_timeout
|
arguments << qint32( -1 ); //expire_timeout
|
||||||
message.setArguments( arguments );
|
message.setArguments( arguments );
|
||||||
@@ -159,10 +172,16 @@ FdoNotifyPlugin::nowPlaying( const QVariant &input )
|
|||||||
arguments << QStringList(); //actions
|
arguments << QStringList(); //actions
|
||||||
QVariantMap dict;
|
QVariantMap dict;
|
||||||
dict["desktop-entry"] = QString( "tomahawk" );
|
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 >() )
|
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
|
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 << dict; //hints
|
||||||
arguments << qint32( -1 ); //expire_timeout
|
arguments << qint32( -1 ); //expire_timeout
|
||||||
message.setArguments( arguments );
|
message.setArguments( arguments );
|
||||||
|
@@ -56,6 +56,8 @@ protected slots:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int getNotificationIconHeight();
|
||||||
|
|
||||||
void notifyUser( const QString &messageText );
|
void notifyUser( const QString &messageText );
|
||||||
|
|
||||||
void nowPlaying( const QVariant &input );
|
void nowPlaying( const QVariant &input );
|
||||||
|
Reference in New Issue
Block a user