mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-22 21:54:00 +02:00
Merge pull request #317 from TheOneRing/snorenotify-0.6
Snorenotify 0.6
This commit is contained in:
@@ -404,12 +404,8 @@ if( WIN32 )
|
||||
endif( WIN32 )
|
||||
|
||||
if( WIN32 OR APPLE )
|
||||
if( TOMAHAWK_QT5 )
|
||||
macro_optional_find_package(LibsnoreQt5 QUIET)
|
||||
else()
|
||||
macro_optional_find_package(Libsnore QUIET)
|
||||
endif()
|
||||
macro_log_feature(LIBSNORE_FOUND "Libsnore" "Library for notifications" "https://github.com/TheOneRing/Snorenotify" FALSE "" "")
|
||||
macro_optional_find_package(LibsnoreQt5 0.5.70 QUIET)
|
||||
macro_log_feature(LibsnoreQt5_FOUND "Libsnore" "Library for notifications" "https://projects.kde.org/projects/playground/libs/snorenotify" FALSE "" "")
|
||||
endif()
|
||||
|
||||
find_package(LIBVLC REQUIRED 2.1.0)
|
||||
|
@@ -15,21 +15,25 @@
|
||||
;-----------------------------------------------------------------------------
|
||||
; Some paths.
|
||||
;-----------------------------------------------------------------------------
|
||||
!ifndef MING_PATH
|
||||
!define MING_PATH "/usr/i686-w64-mingw32/sys-root/mingw"
|
||||
!ifndef MINGW_ROOT
|
||||
!define MINGW_ROOT "/usr/i686-w64-mingw32/sys-root/mingw"
|
||||
!endif
|
||||
|
||||
!define APPLICATION_NAME "Tomahawk"
|
||||
!define TARGET_NAME "tomahawk"
|
||||
;define app id needed for Windows 8 notifications
|
||||
!define AppUserModelId @TOMAHAWK_APPLICATION_PACKAGE_NAME@
|
||||
|
||||
!define MING_BIN "${MING_PATH}/bin"
|
||||
!define MING_LIB "${MING_PATH}/lib"
|
||||
!define MINGW_BIN "${MINGW_ROOT}/bin"
|
||||
!define MINGW_LIB "${MINGW_ROOT}/lib"
|
||||
!define MINGW_SHARE "${MINGW_ROOT}/share"
|
||||
|
||||
!define BUILD_PATH "@CMAKE_BINARY_DIR@"
|
||||
!define SOURCE_PATH "@CMAKE_SOURCE_DIR@"
|
||||
!define QT_DLL_PATH "${MING_BIN}"
|
||||
!define SQLITE_DLL_PATH "${MING_LIB}/qt5/plugins/sqldrivers"
|
||||
!define IMAGEFORMATS_DLL_PATH "${MING_LIB}/qt5/plugins/imageformats"
|
||||
!define QT_DLL_PATH "${MINGW_BIN}"
|
||||
!define QT_QML_PATH "${MINGW_SHARE}/qt5/qml"
|
||||
!define SQLITE_DLL_PATH "${MINGW_LIB}/qt5/plugins/sqldrivers"
|
||||
!define IMAGEFORMATS_DLL_PATH "${MINGW_LIB}/qt5/plugins/imageformats"
|
||||
|
||||
; We use official release plugins
|
||||
; mingw32-vlc from obs misses a lot and has even broken ones probably
|
||||
@@ -330,7 +334,7 @@ Section "${APPLICATION_NAME}" SEC_TOMAHAWK_PLAYER
|
||||
File "${QT_DLL_PATH}\Qt5WebKitWidgets.dll"
|
||||
File "${QT_DLL_PATH}\Qt5Multimedia.dll"
|
||||
File "${QT_DLL_PATH}\Qt5MultimediaWidgets.dll"
|
||||
|
||||
File "${QT_DLL_PATH}\Qt5Positioning.dll"
|
||||
|
||||
;Qt deps
|
||||
File "${QT_DLL_PATH}\libpcre16-0.dll"
|
||||
@@ -339,21 +343,19 @@ Section "${APPLICATION_NAME}" SEC_TOMAHAWK_PLAYER
|
||||
File "${QT_DLL_PATH}\libEGL.dll"
|
||||
File "${QT_DLL_PATH}\libGLESv2.dll"
|
||||
File "${QT_DLL_PATH}\libwebp-5.dll"
|
||||
|
||||
;Boost fnord
|
||||
File "${QT_DLL_PATH}\icuuc53.dll"
|
||||
File "${QT_DLL_PATH}\icudata53.dll"
|
||||
File "${QT_DLL_PATH}\icui18n53.dll"
|
||||
File "${QT_DLL_PATH}\icuuc56.dll"
|
||||
File "${QT_DLL_PATH}\icudata56.dll"
|
||||
File "${QT_DLL_PATH}\icui18n56.dll"
|
||||
|
||||
;SQLite driver
|
||||
SetOutPath "$INSTDIR\sqldrivers"
|
||||
File "${SQLITE_DLL_PATH}\qsqlite.dll"
|
||||
SetOutPath "$INSTDIR"
|
||||
File "${MING_BIN}\libsqlite3-0.dll"
|
||||
File "${MINGW_BIN}\libsqlite3-0.dll"
|
||||
|
||||
;Qt platform plugins
|
||||
SetOutPath "$INSTDIR\platforms"
|
||||
File "${MING_LIB}/qt5/plugins/platforms/qwindows.dll"
|
||||
File "${MINGW_LIB}/qt5/plugins/platforms/qwindows.dll"
|
||||
SetOutPath "$INSTDIR"
|
||||
|
||||
;Image plugins
|
||||
@@ -363,9 +365,16 @@ Section "${APPLICATION_NAME}" SEC_TOMAHAWK_PLAYER
|
||||
File "${IMAGEFORMATS_DLL_PATH}\qsvg.dll"
|
||||
SetOutPath "$INSTDIR"
|
||||
|
||||
;Qt qml plugins
|
||||
SetOutPath "$INSTDIR\QtQuick.2"
|
||||
File /r /x *.debug "${QT_QML_PATH}\QtQuick.2\*"
|
||||
SetOutPath "$INSTDIR\QtQuick\Window.2"
|
||||
File /r /x *.debug "${QT_QML_PATH}\QtQuick\Window.2\*"
|
||||
SetOutPath "$INSTDIR"
|
||||
|
||||
;Cygwin/c++ stuff
|
||||
File "${MING_BIN}\libgcc_s_sjlj-1.dll"
|
||||
File "${MING_BIN}\libstdc++-6.dll"
|
||||
File "${MINGW_BIN}\libgcc_s_sjlj-1.dll"
|
||||
File "${MINGW_BIN}\libstdc++-6.dll"
|
||||
|
||||
;VLC
|
||||
File "${VLC_BIN}\libvlc.dll"
|
||||
@@ -375,60 +384,64 @@ Section "${APPLICATION_NAME}" SEC_TOMAHAWK_PLAYER
|
||||
SetOutPath "$INSTDIR"
|
||||
|
||||
; Other
|
||||
File "${MING_BIN}\libtag.dll"
|
||||
File "${MING_BIN}\libpng16-16.dll"
|
||||
File "${MING_BIN}\libjpeg-8.dll"
|
||||
File "${MING_BIN}\zlib1.dll"
|
||||
File "${MINGW_BIN}\libtag.dll"
|
||||
File "${MINGW_BIN}\libpng16-16.dll"
|
||||
File "${MINGW_BIN}\libjpeg-8.dll"
|
||||
File "${MINGW_BIN}\zlib1.dll"
|
||||
File "${MINGW_BIN}\libfreetype-6.dll"
|
||||
File "${MINGW_BIN}\libglib-2.0-0.dll"
|
||||
File "${MINGW_BIN}\libharfbuzz-0.dll"
|
||||
|
||||
File "${MING_BIN}\libechonest5.dll"
|
||||
File "${MING_BIN}\liblastfm5.dll"
|
||||
File "${MING_BIN}\libquazip5.dll"
|
||||
File "${MING_BIN}\libqt5keychain.dll"
|
||||
File "${MINGW_BIN}\libechonest5.dll"
|
||||
File "${MINGW_BIN}\liblastfm5.dll"
|
||||
File "${MINGW_BIN}\libquazip5.dll"
|
||||
File "${MINGW_BIN}\libqt5keychain.dll"
|
||||
|
||||
; GnuTLS
|
||||
File "${MING_BIN}\libgnutls-28.dll"
|
||||
File "${MING_BIN}\libtasn1-6.dll"
|
||||
File "${MING_BIN}\libgmp-10.dll"
|
||||
File "${MING_BIN}\libhogweed-2-4.dll"
|
||||
File "${MING_BIN}\libintl-8.dll"
|
||||
File "${MING_BIN}\libnettle-4-6.dll"
|
||||
File "${MING_BIN}\libp11-kit-0.dll"
|
||||
File "${MING_BIN}\libffi-6.dll"
|
||||
File "${MINGW_BIN}\libgnutls-28.dll"
|
||||
File "${MINGW_BIN}\libtasn1-6.dll"
|
||||
File "${MINGW_BIN}\libgmp-10.dll"
|
||||
File "${MINGW_BIN}\libhogweed-2-4.dll"
|
||||
File "${MINGW_BIN}\libintl-8.dll"
|
||||
File "${MINGW_BIN}\libnettle-4-6.dll"
|
||||
File "${MINGW_BIN}\libp11-kit-0.dll"
|
||||
File "${MINGW_BIN}\libffi-6.dll"
|
||||
|
||||
; Snorenotify
|
||||
File "${MING_BIN}\SnoreToast.exe"
|
||||
File "${MING_BIN}\libsnore-qt5.dll"
|
||||
File "${MING_LIB}\plugins\libsnore-qt5\libsnore_backend_growl.dll"
|
||||
File "${MING_LIB}\plugins\libsnore-qt5\libsnore_backend_snarl.dll"
|
||||
File "${MING_LIB}\plugins\libsnore-qt5\libsnore_backend_snore.dll"
|
||||
File "${MING_LIB}\plugins\libsnore-qt5\libsnore_backend_snoretoast.dll"
|
||||
File "${MINGW_BIN}\SnoreToast.exe"
|
||||
File "${MINGW_BIN}\libsnore-qt5.dll"
|
||||
File "${MINGW_BIN}\snoresettings.exe"
|
||||
File "${MINGW_LIB}\plugins\libsnore-qt5\libsnore_backend_growl.dll"
|
||||
File "${MINGW_LIB}\plugins\libsnore-qt5\libsnore_backend_snarl.dll"
|
||||
File "${MINGW_LIB}\plugins\libsnore-qt5\libsnore_backend_snore.dll"
|
||||
File "${MINGW_LIB}\plugins\libsnore-qt5\libsnore_backend_snoretoast.dll"
|
||||
|
||||
; Snoregrowl
|
||||
File "${MING_BIN}\libsnoregrowl++.dll"
|
||||
File "${MING_BIN}\libsnoregrowl.dll"
|
||||
File "${MINGW_BIN}\libsnoregrowl++.dll"
|
||||
File "${MINGW_BIN}\libsnoregrowl.dll"
|
||||
|
||||
; Jabber
|
||||
File "${MING_BIN}\libjreen-qt5.dll"
|
||||
File "${MING_BIN}\libidn-11.dll"
|
||||
File "${MING_BIN}\libgsasl-7.dll"
|
||||
File "${MING_BIN}\libqca-qt5.dll"
|
||||
File "${MINGW_BIN}\libjreen-qt5.dll"
|
||||
File "${MINGW_BIN}\libidn-11.dll"
|
||||
File "${MINGW_BIN}\libgsasl-7.dll"
|
||||
File "${MINGW_BIN}\libqca-qt5.dll"
|
||||
SetOutPath "$INSTDIR\crypto"
|
||||
File "${MING_LIB}\qca-qt5\crypto\libqca-ossl.dll"
|
||||
File "${MINGW_LIB}\qca-qt5\crypto\libqca-ossl.dll"
|
||||
SetOutPath "$INSTDIR"
|
||||
File "${MING_BIN}\libssl-10.dll"
|
||||
File "${MING_BIN}\libcrypto-10.dll"
|
||||
File "${MINGW_BIN}\libssl-10.dll"
|
||||
File "${MINGW_BIN}\libcrypto-10.dll"
|
||||
|
||||
; LucenePlusPlus
|
||||
File "${MING_BIN}\liblucene++.dll"
|
||||
File "${MING_BIN}\libboost_system-mt.dll"
|
||||
File "${MING_BIN}\libboost_filesystem-mt.dll"
|
||||
File "${MING_BIN}\libboost_iostreams-mt.dll"
|
||||
File "${MING_BIN}\libboost_regex-mt.dll"
|
||||
File "${MING_BIN}\libboost_thread-mt.dll"
|
||||
File "${MING_BIN}\libbz2-1.dll"
|
||||
File "${MINGW_BIN}\liblucene++.dll"
|
||||
File "${MINGW_BIN}\libboost_system-mt.dll"
|
||||
File "${MINGW_BIN}\libboost_filesystem-mt.dll"
|
||||
File "${MINGW_BIN}\libboost_iostreams-mt.dll"
|
||||
File "${MINGW_BIN}\libboost_regex-mt.dll"
|
||||
File "${MINGW_BIN}\libboost_thread-mt.dll"
|
||||
File "${MINGW_BIN}\libbz2-1.dll"
|
||||
|
||||
File "${MING_BIN}\libqtsparkle-qt5.dll"
|
||||
File "${MING_BIN}\libKF5Attica.dll"
|
||||
File "${MINGW_BIN}\libqtsparkle-qt5.dll"
|
||||
File "${MINGW_BIN}\libKF5Attica.dll"
|
||||
SectionEnd
|
||||
|
||||
SectionGroup "Shortcuts"
|
||||
@@ -443,7 +456,7 @@ SectionGroup "Shortcuts"
|
||||
RMDir /r "$SMPROGRAMS\${APPLICATION_NAME}"
|
||||
CreateDirectory "$SMPROGRAMS\${APPLICATION_NAME}"
|
||||
CreateShortCut "$SMPROGRAMS\${APPLICATION_NAME}\LICENSE.lnk" "$INSTDIR\LICENSE.txt"
|
||||
CreateShortCut "$SMPROGRAMS\${APPLICATION_NAME}\${APPLICATION_NAME}.lnk" "$INSTDIR\${APPLICATION_NAME}.exe"
|
||||
CreateShortCut "$SMPROGRAMS\${APPLICATION_NAME}\Notification Settings.lnk" "$INSTDIR\snoresettings.exe" "-a ${APPLICATION_NAME}"
|
||||
!insertmacro SnoreShortcut "$SMPROGRAMS\${APPLICATION_NAME}\${APPLICATION_NAME}.lnk" "$INSTDIR\${APPLICATION_NAME}.exe" "${AppUserModelId}"
|
||||
CreateShortCut "$SMPROGRAMS\${APPLICATION_NAME}\Release notes.lnk" "$INSTDIR\NOTES.txt"
|
||||
CreateShortCut "$SMPROGRAMS\${APPLICATION_NAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe"
|
||||
|
@@ -3,17 +3,15 @@ include_directories(
|
||||
${Boost_INCLUDE_DIR}
|
||||
)
|
||||
if(WIN32 OR APPLE)
|
||||
if(BUILD_GUI AND LIBSNORE_FOUND)
|
||||
if(BUILD_GUI AND LibsnoreQt5_FOUND)
|
||||
SET(snore_srcs
|
||||
snorenotify/SnoreNotifyPlugin.cpp
|
||||
)
|
||||
SET(SNORE_LINK_LIBRARIES ${LINK_LIBRARIES} ${LIBSNORE_LIBRARIES} )
|
||||
|
||||
tomahawk_add_plugin(snorenotify
|
||||
TYPE infoplugin EXPORT_MACRO INFOPLUGINDLLEXPORT_PRO
|
||||
SOURCES "${snore_srcs}" LINK_LIBRARIES "${SNORE_LINK_LIBRARIES}"
|
||||
SOURCES "${snore_srcs}" LINK_LIBRARIES Snore::Libsnore
|
||||
)
|
||||
endif(BUILD_GUI AND LIBSNORE_FOUND)
|
||||
endif()
|
||||
endif(WIN32 OR APPLE)
|
||||
|
||||
list(APPEND simple_plugins
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2013-2014, Patrick von Reth <vonreth@kde.org>
|
||||
* Copyright 2013-2015, Hannah von Reth <vonreth@kde.org>
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
|
||||
*
|
||||
@@ -27,12 +27,13 @@
|
||||
|
||||
#include "TomahawkVersion.h"
|
||||
|
||||
#include <snore/core/application.h>
|
||||
#include <snore/core/notification/icon.h>
|
||||
#include <libsnore/application.h>
|
||||
#include <libsnore/notification/icon.h>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include <QImage>
|
||||
#include <QPixmap>
|
||||
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||
@@ -61,27 +62,13 @@ SnoreNotifyPlugin::SnoreNotifyPlugin()
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||
m_supportedPushTypes << InfoNotifyUser << InfoNowPlaying << InfoTrackUnresolved << InfoNowStopped << InfoInboxReceived;
|
||||
|
||||
m_snore = new Snore::SnoreCore();
|
||||
m_snore->loadPlugins( Snore::SnorePlugin::BACKEND );
|
||||
QString backend = qgetenv( "SNORE_BACKEND" ).constData();
|
||||
|
||||
if( backend.isEmpty() )
|
||||
{
|
||||
m_snore->setPrimaryNotificationBackend();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !m_snore->setPrimaryNotificationBackend( backend ) )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Ivalid or unavailible Snore backend: " << backend << " availible backens: " << m_snore->notificationBackends();
|
||||
m_snore->setPrimaryNotificationBackend();
|
||||
}
|
||||
}
|
||||
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << m_snore->primaryNotificationBackend();
|
||||
Snore::SnoreCore &snore = Snore::SnoreCore::instance();
|
||||
snore.loadPlugins( Snore::SnorePlugin::BACKEND | Snore::SnorePlugin::SECONDARY_BACKEND );
|
||||
snore.setDefaultSettingsValue("Silent", true, Snore::LOCAL_SETTING);
|
||||
|
||||
m_application = Snore::Application( qApp->applicationName(), m_defaultIcon );
|
||||
m_application.hints().setValue( "windows_app_id", TOMAHAWK_APPLICATION_PACKAGE_NAME );
|
||||
m_application.hints().setValue( "use-markup", true );
|
||||
m_application.hints().setValue( "windows-app-id", TOMAHAWK_APPLICATION_PACKAGE_NAME );
|
||||
m_application.hints().setValue( "desktop-entry", TOMAHAWK_APPLICATION_NAME );
|
||||
|
||||
addAlert( InfoNotifyUser, tr( "Notify User" ) );
|
||||
@@ -90,9 +77,10 @@ SnoreNotifyPlugin::SnoreNotifyPlugin()
|
||||
addAlert( InfoNowStopped, tr( "Playback Stopped" ) );
|
||||
addAlert( InfoInboxReceived, tr( "You received a Song recommendation" ) );
|
||||
|
||||
m_snore->registerApplication( m_application );
|
||||
snore.registerApplication( m_application );
|
||||
snore.setDefaultApplication( m_application );
|
||||
|
||||
connect( m_snore, SIGNAL( actionInvoked( Snore::Notification ) ), this, SLOT( slotActionInvoked( Snore::Notification ) ) );
|
||||
connect( &snore, SIGNAL( actionInvoked( Snore::Notification ) ), this, SLOT( slotActionInvoked( Snore::Notification ) ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -100,8 +88,7 @@ SnoreNotifyPlugin::~SnoreNotifyPlugin()
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||
|
||||
m_snore->deregisterApplication( m_application );
|
||||
m_snore->deleteLater();
|
||||
Snore::SnoreCore::instance().deregisterApplication( m_application );
|
||||
}
|
||||
|
||||
void
|
||||
@@ -111,25 +98,19 @@ SnoreNotifyPlugin::pushInfo( Tomahawk::InfoSystem::InfoPushData pushData )
|
||||
if ( !TomahawkSettings::instance()->songChangeNotificationEnabled() )
|
||||
return;
|
||||
|
||||
if( m_snore->primaryNotificationBackend().isNull() )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "no notification backend set";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch ( pushData.type )
|
||||
{
|
||||
case Tomahawk::InfoSystem::InfoTrackUnresolved:
|
||||
notifyUser( Tomahawk::InfoSystem::InfoTrackUnresolved, tr( "The current track could not be resolved. %applicationName will pick back up with the next resolvable track from this source." ) );
|
||||
notifyUser( Tomahawk::InfoSystem::InfoTrackUnresolved, tr( "The current track could not be resolved. %applicationName will pick back up with the next resolvable track from this source." ), m_defaultIcon );
|
||||
return;
|
||||
|
||||
case Tomahawk::InfoSystem::InfoNotifyUser:
|
||||
notifyUser( Tomahawk::InfoSystem::InfoNotifyUser,pushData.infoPair.second.toString() );
|
||||
notifyUser( Tomahawk::InfoSystem::InfoNotifyUser,pushData.infoPair.second.toString(), m_defaultIcon );
|
||||
return;
|
||||
|
||||
case Tomahawk::InfoSystem::InfoNowStopped:
|
||||
notifyUser( Tomahawk::InfoSystem::InfoNowStopped, tr( "%applicationName stopped playback." ) );
|
||||
notifyUser( Tomahawk::InfoSystem::InfoNowStopped, tr( "%applicationName stopped playback." ), m_defaultIcon );
|
||||
return;
|
||||
|
||||
case Tomahawk::InfoSystem::InfoNowPlaying:
|
||||
@@ -157,15 +138,10 @@ SnoreNotifyPlugin::slotActionInvoked( Snore::Notification n )
|
||||
void
|
||||
SnoreNotifyPlugin::notifyUser( Tomahawk::InfoSystem::InfoType type, const QString& messageText, Snore::Icon icon )
|
||||
{
|
||||
if(!icon.isValid())
|
||||
{
|
||||
icon = m_defaultIcon;
|
||||
}
|
||||
const Snore::Alert &alert = m_alerts[ type ];
|
||||
Snore::Notification n( m_application , alert, alert.name(), messageText, icon );
|
||||
m_snore->broadcastNotification( n );
|
||||
Snore::SnoreCore::instance().broadcastNotification( n );
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "showing notification:" << messageText;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
@@ -194,41 +170,28 @@ SnoreNotifyPlugin::nowPlaying( const QVariant& input )
|
||||
|
||||
QString messageText;
|
||||
// If the window manager supports notification styling then use it.
|
||||
if ( m_snore->primaryBackendSupportsRichtext() )
|
||||
{
|
||||
// Remark: If using xml-based markup in notifications, the supplied strings need to be escaped.
|
||||
QString album;
|
||||
if ( !hash[ "album" ].isEmpty() )
|
||||
album = QString( "<br><i>%1</i> %2" ).arg( tr( "on", "'on' is followed by an album name" ) ).arg( Qt::escape( hash[ "album" ] ) );
|
||||
|
||||
messageText = tr( "%1%4 %2%3.", "%1 is a title, %2 is an artist and %3 is replaced by either the previous message or nothing, %4 is the preposition used to link track and artist ('by' in english)" )
|
||||
.arg( Qt::escape( hash[ "title" ] ) )
|
||||
.arg( Qt::escape( hash[ "artist" ] ) )
|
||||
.arg( album )
|
||||
.arg( QString( "<br><i>%1</i>" ).arg( tr( "by", "preposition to link track and artist" ) ) );
|
||||
// Remark: If using xml-based markup in notifications, the supplied strings need to be escaped.
|
||||
QString album;
|
||||
if ( !hash[ "album" ].isEmpty() )
|
||||
album = QString( "<br><i>%1</i> %2" ).arg( tr( "on", "'on' is followed by an album name" ) ).arg( Qt::escape( hash[ "album" ] ) );
|
||||
|
||||
// Dirty hack(TM) so that KNotify/QLabel recognizes the message as Rich Text
|
||||
messageText = QString( "<i></i>%1" ).arg( messageText );
|
||||
}
|
||||
else
|
||||
{
|
||||
QString album;
|
||||
if ( !hash[ "album" ].isEmpty() )
|
||||
album = QString( " %1" ).arg( tr( "on \"%1\"", "%1 is an album name" ).arg( hash[ "album" ] ) );
|
||||
messageText = tr( "%1%4 %2%3.", "%1 is a title, %2 is an artist and %3 is replaced by either the previous message or nothing, %4 is the preposition used to link track and artist ('by' in english)" )
|
||||
.arg( Qt::escape( hash[ "title" ] ) )
|
||||
.arg( Qt::escape( hash[ "artist" ] ) )
|
||||
.arg( album )
|
||||
.arg( QString( "<br><i>%1</i>" ).arg( tr( "by", "preposition to link track and artist" ) ) );
|
||||
|
||||
messageText = tr( "\"%1\" by %2%3.", "%1 is a title, %2 is an artist and %3 is replaced by either the previous message or nothing" )
|
||||
.arg( hash[ "title" ] )
|
||||
.arg( hash[ "artist" ] )
|
||||
.arg( album );
|
||||
}
|
||||
// Dirty hack(TM) so that KNotify/QLabel recognizes the message as Rich Text
|
||||
messageText = QString( "<i></i>%1" ).arg( messageText );
|
||||
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "sending message" << messageText;
|
||||
|
||||
// If there is a cover availble use it, else use Tomahawk logo as default.
|
||||
Snore::Icon image;
|
||||
Snore::Icon image = m_defaultIcon;
|
||||
if ( map.contains( "cover" ) && map[ "cover" ].canConvert< QImage >() )
|
||||
{
|
||||
image = Snore::Icon( map[ "cover" ].value< QImage >() );
|
||||
image = Snore::Icon( QPixmap::fromImage( map[ "cover" ].value< QImage >() ) );
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << image;
|
||||
}
|
||||
notifyUser( InfoNowPlaying, messageText, image );
|
||||
@@ -259,26 +222,15 @@ SnoreNotifyPlugin::inboxReceived( const QVariant& input )
|
||||
return;
|
||||
|
||||
QString messageText;
|
||||
// If the window manager supports notification styling then use it.
|
||||
if ( m_snore->primaryBackendSupportsRichtext() )
|
||||
{
|
||||
// Remark: If using xml-based markup in notifications, the supplied strings need to be escaped.
|
||||
messageText = tr( "%1 sent you\n%2%4 %3.", "%1 is a nickname, %2 is a title, %3 is an artist, %4 is the preposition used to link track and artist ('by' in english)" )
|
||||
.arg( Qt::escape( src["friendlyname"] ) )
|
||||
.arg( Qt::escape( hash[ "title" ] ) )
|
||||
.arg( Qt::escape( hash[ "artist" ] ) )
|
||||
.arg( QString( "\n<i>%1</i>" ).arg( tr( "by", "preposition to link track and artist" ) ) );
|
||||
// Remark: If using xml-based markup in notifications, the supplied strings need to be escaped.
|
||||
messageText = tr( "%1 sent you\n%2%4 %3.", "%1 is a nickname, %2 is a title, %3 is an artist, %4 is the preposition used to link track and artist ('by' in english)" )
|
||||
.arg( Qt::escape( src["friendlyname"] ) )
|
||||
.arg( Qt::escape( hash[ "title" ] ) )
|
||||
.arg( Qt::escape( hash[ "artist" ] ) )
|
||||
.arg( QString( "\n<i>%1</i>" ).arg( tr( "by", "preposition to link track and artist" ) ) );
|
||||
|
||||
// Dirty hack(TM) so that KNotify/QLabel recognizes the message as Rich Text
|
||||
messageText = QString( "<i></i>%1" ).arg( messageText );
|
||||
}
|
||||
else
|
||||
{
|
||||
messageText = tr( "%1 sent you \"%2\" by %3.", "%1 is a nickname, %2 is a title, %3 is an artist" )
|
||||
.arg( src["friendlyname"] )
|
||||
.arg( hash[ "title" ] )
|
||||
.arg( hash[ "artist" ] );
|
||||
}
|
||||
// Dirty hack(TM) so that KNotify/QLabel recognizes the message as Rich Text
|
||||
messageText = QString( "<i></i>%1" ).arg( messageText );
|
||||
|
||||
Snore::Icon icon( RESPATH "images/inbox-512x512.png" );
|
||||
notifyUser( Tomahawk::InfoSystem::InfoInboxReceived, messageText, icon );
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2013-2014, Patrick von Reth <vonreth@kde.org>
|
||||
* Copyright 2013-2015, Hannah von Reth <vonreth@kde.org>
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
|
||||
*
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "../../InfoPluginDllMacro.h"
|
||||
|
||||
#include "infosystem/InfoSystem.h"
|
||||
#include <snore/core/snore.h>
|
||||
#include <libsnore/snore.h>
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
@@ -63,9 +63,8 @@ protected slots:
|
||||
void slotActionInvoked(Snore::Notification n);
|
||||
|
||||
private:
|
||||
void notifyUser( InfoType type, const QString &messageText, Snore::Icon icon = Snore::Icon() );
|
||||
void notifyUser( InfoType type, const QString &messageText, Snore::Icon icon );
|
||||
void addAlert( Tomahawk::InfoSystem::InfoType type, const QString &title );
|
||||
Snore::SnoreCore *m_snore;
|
||||
Snore::Application m_application;
|
||||
Snore::Icon m_defaultIcon;
|
||||
QHash< Tomahawk::InfoSystem::InfoType, Snore::Alert > m_alerts;
|
||||
|
Reference in New Issue
Block a user