mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
* Style fixes for FdoNotifyPlugin.
This commit is contained in:
@@ -38,16 +38,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FdoNotifyPlugin.h"
|
#include "FdoNotifyPlugin.h"
|
||||||
#include "utils/TomahawkUtils.h"
|
|
||||||
#include "ImageConverter.h"
|
#include "ImageConverter.h"
|
||||||
#include "FreedesktopNotificationsProxy.h"
|
#include "FreedesktopNotificationsProxy.h"
|
||||||
|
|
||||||
#include "TomahawkSettings.h"
|
#include "TomahawkSettings.h"
|
||||||
|
|
||||||
|
#include "utils/TomahawkUtils.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/TomahawkUtilsGui.h"
|
#include "utils/TomahawkUtilsGui.h"
|
||||||
|
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
|
#include <QDBusPendingCallWatcher>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
// QTextDocument provides Qt::escape()
|
// QTextDocument provides Qt::escape()
|
||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
@@ -63,7 +65,7 @@ FdoNotifyPlugin::FdoNotifyPlugin()
|
|||||||
, m_nowPlayingId( 0 )
|
, m_nowPlayingId( 0 )
|
||||||
, m_wmSupportsBodyMarkup( false )
|
, m_wmSupportsBodyMarkup( false )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
m_supportedPushTypes << InfoNotifyUser << InfoNowPlaying << InfoTrackUnresolved << InfoNowStopped << InfoInboxReceived;
|
m_supportedPushTypes << InfoNotifyUser << InfoNowPlaying << InfoTrackUnresolved << InfoNowStopped << InfoInboxReceived;
|
||||||
|
|
||||||
// Query the window manager for its capabilties in styling notifications.
|
// Query the window manager for its capabilties in styling notifications.
|
||||||
@@ -72,13 +74,13 @@ FdoNotifyPlugin::FdoNotifyPlugin()
|
|||||||
QDBusPendingReply<QStringList> reply = notifications_interface->GetCapabilities();
|
QDBusPendingReply<QStringList> reply = notifications_interface->GetCapabilities();
|
||||||
|
|
||||||
QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher( reply, this );
|
QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher( reply, this );
|
||||||
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(dbusCapabilitiesReplyReceived(QDBusPendingCallWatcher*)));
|
connect( watcher, SIGNAL( finished( QDBusPendingCallWatcher* ) ), SLOT( dbusCapabilitiesReplyReceived( QDBusPendingCallWatcher* ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FdoNotifyPlugin::~FdoNotifyPlugin()
|
FdoNotifyPlugin::~FdoNotifyPlugin()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -88,11 +90,12 @@ FdoNotifyPlugin::dbusCapabilitiesReplyReceived( QDBusPendingCallWatcher* watcher
|
|||||||
QDBusMessage reply = watcher->reply();
|
QDBusMessage reply = watcher->reply();
|
||||||
watcher->deleteLater();
|
watcher->deleteLater();
|
||||||
|
|
||||||
if (reply.type() == QDBusMessage::ErrorMessage) {
|
if ( reply.type() == QDBusMessage::ErrorMessage )
|
||||||
|
{
|
||||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Failed to request capabilities of notifications";
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Failed to request capabilities of notifications";
|
||||||
}
|
}
|
||||||
|
|
||||||
const QStringList &capability_list = reply.arguments().at( 0 ).toStringList();
|
const QStringList& capability_list = reply.arguments().first().toStringList();
|
||||||
m_wmSupportsBodyMarkup = capability_list.contains( "body-markup" );
|
m_wmSupportsBodyMarkup = capability_list.contains( "body-markup" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +103,7 @@ FdoNotifyPlugin::dbusCapabilitiesReplyReceived( QDBusPendingCallWatcher* watcher
|
|||||||
void
|
void
|
||||||
FdoNotifyPlugin::pushInfo( Tomahawk::InfoSystem::InfoPushData pushData )
|
FdoNotifyPlugin::pushInfo( Tomahawk::InfoSystem::InfoPushData pushData )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "showing notification: " << TomahawkSettings::instance()->songChangeNotificationEnabled();
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "showing notification:" << TomahawkSettings::instance()->songChangeNotificationEnabled();
|
||||||
|
|
||||||
if ( !TomahawkSettings::instance()->songChangeNotificationEnabled() )
|
if ( !TomahawkSettings::instance()->songChangeNotificationEnabled() )
|
||||||
return;
|
return;
|
||||||
@@ -164,6 +167,7 @@ FdoNotifyPlugin::notifyUser( const QString& messageText )
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FdoNotifyPlugin::inboxReceived( const QVariant& input )
|
void FdoNotifyPlugin::inboxReceived( const QVariant& input )
|
||||||
{
|
{
|
||||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
@@ -174,7 +178,6 @@ void FdoNotifyPlugin::inboxReceived(const QVariant &input)
|
|||||||
|
|
||||||
if ( !map.contains( "trackinfo" ) || !map[ "trackinfo" ].canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
if ( !map.contains( "trackinfo" ) || !map[ "trackinfo" ].canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( !map.contains( "sourceinfo" ) || !map[ "sourceinfo" ].canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
if ( !map.contains( "sourceinfo" ) || !map[ "sourceinfo" ].canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -227,6 +230,7 @@ void FdoNotifyPlugin::inboxReceived(const QVariant &input)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FdoNotifyPlugin::nowPlaying( const QVariant& input )
|
FdoNotifyPlugin::nowPlaying( const QVariant& input )
|
||||||
{
|
{
|
||||||
@@ -235,7 +239,6 @@ FdoNotifyPlugin::nowPlaying( const QVariant& input )
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
QVariantMap map = input.toMap();
|
QVariantMap map = input.toMap();
|
||||||
|
|
||||||
if ( !map.contains( "trackinfo" ) || !map[ "trackinfo" ].canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
if ( !map.contains( "trackinfo" ) || !map[ "trackinfo" ].canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -300,8 +303,7 @@ FdoNotifyPlugin::nowPlaying( const QVariant& input )
|
|||||||
);
|
);
|
||||||
|
|
||||||
QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher( reply, this );
|
QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher( reply, this );
|
||||||
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
|
connect( watcher, SIGNAL( finished( QDBusPendingCallWatcher* ) ), SLOT( RegisterFinished( dbusPlayingReplyReceived* ) ) );
|
||||||
this, SLOT(RegisterFinished(dbusPlayingReplyReceived*)));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,14 +316,16 @@ FdoNotifyPlugin::dbusPlayingReplyReceived( QDBusPendingCallWatcher* watcher )
|
|||||||
{
|
{
|
||||||
QDBusMessage reply = watcher->reply();
|
QDBusMessage reply = watcher->reply();
|
||||||
watcher->deleteLater();
|
watcher->deleteLater();
|
||||||
if (reply.type() == QDBusMessage::ErrorMessage) {
|
|
||||||
|
if ( reply.type() == QDBusMessage::ErrorMessage )
|
||||||
|
{
|
||||||
tLog(LOGVERBOSE) << "Failed to grab media keys" << reply.errorName() << reply.errorMessage();
|
tLog(LOGVERBOSE) << "Failed to grab media keys" << reply.errorName() << reply.errorMessage();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QVariantList& list = reply.arguments();
|
const QVariantList& list = reply.arguments();
|
||||||
if ( list.count() > 0 )
|
if ( !list.isEmpty() )
|
||||||
m_nowPlayingId = list.at( 0 ).toInt();
|
m_nowPlayingId = list.first().toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
} //ns InfoSystem
|
} //ns InfoSystem
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
#include "infosystem/InfoSystem.h"
|
#include "infosystem/InfoSystem.h"
|
||||||
#include "FreedesktopNotificationsProxy.h"
|
#include "FreedesktopNotificationsProxy.h"
|
||||||
|
|
||||||
#include <QtDBus>
|
class QDBusPendingCallWatcher;
|
||||||
|
|
||||||
namespace Tomahawk
|
namespace Tomahawk
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user