mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 13:47:26 +02:00
Add some shortcuts for mac
Fix osx shortcuts
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
#define APP TomahawkApp::instance()
|
#define APP TomahawkApp::instance()
|
||||||
|
|
||||||
#include "headlesscheck.h"
|
#include "headlesscheck.h"
|
||||||
#include "tomahawkapp_mac.h" // for PlatforInterface
|
#include "mac/tomahawkapp_mac.h" // for PlatforInterface
|
||||||
|
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
@@ -29,6 +29,7 @@ class XMPPBot;
|
|||||||
|
|
||||||
namespace Tomahawk
|
namespace Tomahawk
|
||||||
{
|
{
|
||||||
|
class ShortcutHandler;
|
||||||
namespace InfoSystem
|
namespace InfoSystem
|
||||||
{
|
{
|
||||||
class InfoSystem;
|
class InfoSystem;
|
||||||
@@ -99,6 +100,7 @@ private:
|
|||||||
SipHandler* m_sipHandler;
|
SipHandler* m_sipHandler;
|
||||||
Servent* m_servent;
|
Servent* m_servent;
|
||||||
XMPPBot* m_xmppBot;
|
XMPPBot* m_xmppBot;
|
||||||
|
Tomahawk::ShortcutHandler* m_shortcutHandler;
|
||||||
|
|
||||||
#ifndef NO_LIBLASTFM
|
#ifndef NO_LIBLASTFM
|
||||||
Scrobbler* m_scrobbler;
|
Scrobbler* m_scrobbler;
|
||||||
|
@@ -39,6 +39,7 @@ SET( tomahawkSources ${tomahawkSources}
|
|||||||
musicscanner.cpp
|
musicscanner.cpp
|
||||||
scriptresolver.cpp
|
scriptresolver.cpp
|
||||||
scrobbler.cpp
|
scrobbler.cpp
|
||||||
|
shortcuthandler.cpp
|
||||||
|
|
||||||
tomahawkapp.cpp
|
tomahawkapp.cpp
|
||||||
main.cpp
|
main.cpp
|
||||||
@@ -59,8 +60,8 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
|
|||||||
|
|
||||||
|
|
||||||
IF( APPLE )
|
IF( APPLE )
|
||||||
SET( tomahawkHeaders ${tomahawkHeaders} tomahawkapp_mac.h )
|
SET( tomahawkHeaders ${tomahawkHeaders} mac/tomahawkapp_mac.h mac/macshortcuthandler.h )
|
||||||
SET( tomahawkSources ${tomahawkSources} tomahawkapp_mac.mm )
|
SET( tomahawkSources ${tomahawkSources} mac/tomahawkapp_mac.mm mac/macshortcuthandler.cpp )
|
||||||
ENDIF( APPLE )
|
ENDIF( APPLE )
|
||||||
|
|
||||||
SET( tomahawkHeaders ${tomahawkHeaders}
|
SET( tomahawkHeaders ${tomahawkHeaders}
|
||||||
@@ -78,6 +79,7 @@ SET( tomahawkHeaders ${tomahawkHeaders}
|
|||||||
musicscanner.h
|
musicscanner.h
|
||||||
scriptresolver.h
|
scriptresolver.h
|
||||||
scrobbler.h
|
scrobbler.h
|
||||||
|
shortcuthandler.h
|
||||||
)
|
)
|
||||||
|
|
||||||
SET( tomahawkHeadersGui ${tomahawkHeadersGui}
|
SET( tomahawkHeadersGui ${tomahawkHeadersGui}
|
||||||
@@ -115,6 +117,7 @@ INCLUDE_DIRECTORIES(
|
|||||||
topbar
|
topbar
|
||||||
utils
|
utils
|
||||||
libtomahawk
|
libtomahawk
|
||||||
|
mac
|
||||||
|
|
||||||
../alsa-playback
|
../alsa-playback
|
||||||
../rtaudio
|
../rtaudio
|
||||||
|
@@ -62,6 +62,15 @@ AudioEngine::~AudioEngine()
|
|||||||
delete m_audio;
|
delete m_audio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AudioEngine::playPause()
|
||||||
|
{
|
||||||
|
if( m_audio->isPlaying() )
|
||||||
|
pause();
|
||||||
|
else
|
||||||
|
play();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioEngine::play()
|
AudioEngine::play()
|
||||||
@@ -141,6 +150,11 @@ AudioEngine::setVolume( int percentage )
|
|||||||
emit volumeChanged( percentage );
|
emit volumeChanged( percentage );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AudioEngine::mute()
|
||||||
|
{
|
||||||
|
setVolume( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioEngine::onTrackAboutToClose()
|
AudioEngine::onTrackAboutToClose()
|
||||||
|
@@ -40,6 +40,7 @@ public:
|
|||||||
PlaylistInterface* playlist() const { return m_playlist; }
|
PlaylistInterface* playlist() const { return m_playlist; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void playPause();
|
||||||
void play();
|
void play();
|
||||||
void pause();
|
void pause();
|
||||||
void stop();
|
void stop();
|
||||||
@@ -51,6 +52,7 @@ public slots:
|
|||||||
void lowerVolume() { setVolume( volume() - AUDIO_VOLUME_STEP ); }
|
void lowerVolume() { setVolume( volume() - AUDIO_VOLUME_STEP ); }
|
||||||
void raiseVolume() { setVolume( volume() + AUDIO_VOLUME_STEP ); }
|
void raiseVolume() { setVolume( volume() + AUDIO_VOLUME_STEP ); }
|
||||||
void onVolumeChanged( float volume ) { emit volumeChanged( volume * 100 ); }
|
void onVolumeChanged( float volume ) { emit volumeChanged( volume * 100 ); }
|
||||||
|
void mute();
|
||||||
|
|
||||||
void playItem( PlaylistInterface* playlist, const Tomahawk::result_ptr& result );
|
void playItem( PlaylistInterface* playlist, const Tomahawk::result_ptr& result );
|
||||||
void setPlaylist( PlaylistInterface* playlist ) { m_playlist = playlist; }
|
void setPlaylist( PlaylistInterface* playlist ) { m_playlist = playlist; }
|
||||||
|
31
src/mac/macshortcuthandler.cpp
Normal file
31
src/mac/macshortcuthandler.cpp
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#include "macshortcuthandler.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <IOKit/hidsystem/ev_keymap.h>
|
||||||
|
|
||||||
|
using namespace Tomahawk;
|
||||||
|
|
||||||
|
MacShortcutHandler::MacShortcutHandler(QObject *parent) :
|
||||||
|
Tomahawk::ShortcutHandler(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MacShortcutHandler::macMediaKeyPressed( int key )
|
||||||
|
{
|
||||||
|
switch (key) {
|
||||||
|
case NX_KEYTYPE_PLAY:
|
||||||
|
qDebug() << "emitting PlayPause pressed";
|
||||||
|
emit playPause();
|
||||||
|
break;
|
||||||
|
case NX_KEYTYPE_FAST:
|
||||||
|
qDebug() << "emitting next pressed";
|
||||||
|
emit next();
|
||||||
|
break;
|
||||||
|
case NX_KEYTYPE_REWIND:
|
||||||
|
qDebug() << "emitting prev pressed";
|
||||||
|
emit previous();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
22
src/mac/macshortcuthandler.h
Normal file
22
src/mac/macshortcuthandler.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#ifndef MACSHORTCUTHANDLER_H
|
||||||
|
#define MACSHORTCUTHANDLER_H
|
||||||
|
|
||||||
|
#include "shortcuthandler.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
namespace Tomahawk {
|
||||||
|
|
||||||
|
|
||||||
|
class MacShortcutHandler : public ShortcutHandler
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit MacShortcutHandler(QObject *parent = 0);
|
||||||
|
|
||||||
|
void macMediaKeyPressed( int key );
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // MACSHORTCUTHANDLER_H
|
@@ -8,6 +8,8 @@ class QString;
|
|||||||
|
|
||||||
namespace Tomahawk {
|
namespace Tomahawk {
|
||||||
|
|
||||||
|
class MacShortcutHandler;
|
||||||
|
|
||||||
/// Interface between cocoa and tomahawk
|
/// Interface between cocoa and tomahawk
|
||||||
class PlatformInterface {
|
class PlatformInterface {
|
||||||
public:
|
public:
|
||||||
@@ -19,7 +21,7 @@ class PlatformInterface {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void macMain();
|
void macMain();
|
||||||
//void setShortcutHandler(GlobalShortcuts* handler);
|
void setShortcutHandler(Tomahawk::MacShortcutHandler* engine);
|
||||||
// used for opening files with tomahawk
|
// used for opening files with tomahawk
|
||||||
void setApplicationHandler(PlatformInterface* handler);
|
void setApplicationHandler(PlatformInterface* handler);
|
||||||
|
|
@@ -1,5 +1,6 @@
|
|||||||
#include "tomahawkapp_mac.h"
|
#include "tomahawkapp_mac.h"
|
||||||
#include "tomahawkapp_macdelegate.h"
|
#include "tomahawkapp_macdelegate.h"
|
||||||
|
#include "macshortcuthandler.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#import <AppKit/NSApplication.h>
|
#import <AppKit/NSApplication.h>
|
||||||
@@ -19,17 +20,17 @@
|
|||||||
// See: http://www.rogueamoeba.com/utm/2007/09/29/apple-keyboard-media-key-event-handling/
|
// See: http://www.rogueamoeba.com/utm/2007/09/29/apple-keyboard-media-key-event-handling/
|
||||||
|
|
||||||
@interface MacApplication :NSApplication {
|
@interface MacApplication :NSApplication {
|
||||||
// MacGlobalShortcutBackend* shortcut_handler_;
|
Tomahawk::MacShortcutHandler* shortcut_handler_;
|
||||||
Tomahawk::PlatformInterface* application_handler_;
|
Tomahawk::PlatformInterface* application_handler_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- (MacGlobalShortcutBackend*) shortcut_handler;
|
- (Tomahawk::MacShortcutHandler*) shortcutHandler;
|
||||||
//- (void) SetShortcutHandler: (MacGlobalShortcutBackend*)handler;
|
- (void) setShortcutHandler: (Tomahawk::MacShortcutHandler*)handler;
|
||||||
|
|
||||||
- (Tomahawk::PlatformInterface*) application_handler;
|
- (Tomahawk::PlatformInterface*) application_handler;
|
||||||
- (void) SetApplicationHandler: (Tomahawk::PlatformInterface*)handler;
|
- (void) setApplicationHandler: (Tomahawk::PlatformInterface*)handler;
|
||||||
- (void)getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
|
- (void) getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
|
||||||
//- (void) mediaKeyEvent: (int)key state: (BOOL)state repeat: (BOOL)repeat;
|
- (void) mediaKeyEvent: (int)key state: (BOOL)state repeat: (BOOL)repeat;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
@@ -78,40 +79,26 @@
|
|||||||
|
|
||||||
- (id) init {
|
- (id) init {
|
||||||
if ((self = [super init])) {
|
if ((self = [super init])) {
|
||||||
// [self SetShortcutHandler:nil];
|
[self setShortcutHandler:nil];
|
||||||
[self SetApplicationHandler:nil];
|
[self setApplicationHandler:nil];
|
||||||
|
|
||||||
NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager];
|
|
||||||
[em
|
|
||||||
setEventHandler:self
|
|
||||||
andSelector:@selector(getUrl:withReplyEvent:)
|
|
||||||
forEventClass:kInternetEventClass
|
|
||||||
andEventID:kAEGetURL];
|
|
||||||
[em
|
|
||||||
setEventHandler:self
|
|
||||||
andSelector:@selector(getUrl:withReplyEvent:)
|
|
||||||
forEventClass:'WWW!'
|
|
||||||
andEventID:'OURL'];
|
|
||||||
NSString *bundleID = [[NSBundle mainBundle] bundleIdentifier];
|
|
||||||
OSStatus httpResult = LSSetDefaultHandlerForURLScheme((CFStringRef)@"tomahawk", (CFStringRef)bundleID);
|
|
||||||
//TODO: Check httpResult and httpsResult for errors
|
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
- (MacGlobalShortcutBackend*) shortcut_handler {
|
- (Tomahawk::MacShortcutHandler*) shortcutHandler {
|
||||||
return shortcut_handler_;
|
return shortcut_handler_;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) SetShortcutHandler: (MacGlobalShortcutBackend*)handler {
|
- (void) setShortcutHandler: (Tomahawk::MacShortcutHandler*)handler {
|
||||||
|
qDebug() << "Setting shortcut handler of MacAPp";
|
||||||
shortcut_handler_ = handler;
|
shortcut_handler_ = handler;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
- (Tomahawk::PlatformInterface*) application_handler {
|
- (Tomahawk::PlatformInterface*) application_handler {
|
||||||
return application_handler_;
|
return application_handler_;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) SetApplicationHandler: (Tomahawk::PlatformInterface*)handler {
|
- (void) setApplicationHandler: (Tomahawk::PlatformInterface*)handler {
|
||||||
AppDelegate* delegate = [[AppDelegate alloc] initWithHandler:handler];
|
AppDelegate* delegate = [[AppDelegate alloc] initWithHandler:handler];
|
||||||
[self setDelegate:delegate];
|
[self setDelegate:delegate];
|
||||||
}
|
}
|
||||||
@@ -123,30 +110,19 @@
|
|||||||
int keystate = (((keyflags & 0xFF00) >> 8)) == 0xA;
|
int keystate = (((keyflags & 0xFF00) >> 8)) == 0xA;
|
||||||
int keyrepeat = (keyflags & 0x1);
|
int keyrepeat = (keyflags & 0x1);
|
||||||
|
|
||||||
//[self mediaKeyEvent: keycode state: keystate repeat: keyrepeat];
|
[self mediaKeyEvent: keycode state: keystate repeat: keyrepeat];
|
||||||
}
|
}
|
||||||
|
|
||||||
[super sendEvent: event];
|
[super sendEvent: event];
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
-(void) mediaKeyEvent: (int)key state: (BOOL)state repeat: (BOOL)repeat {
|
-(void) mediaKeyEvent: (int)key state: (BOOL)state repeat: (BOOL)repeat {
|
||||||
if (!shortcut_handler_) {
|
if (!shortcut_handler_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (state == 0) {
|
if (state == 0) {
|
||||||
shortcut_handler_->MacMediaKeyPressed(key);
|
shortcut_handler_->macMediaKeyPressed(key);
|
||||||
}
|
}
|
||||||
} */
|
|
||||||
|
|
||||||
- (void)getUrl:(NSAppleEventDescriptor *)event
|
|
||||||
withReplyEvent:(NSAppleEventDescriptor *)replyEvent
|
|
||||||
{
|
|
||||||
// Get the URL
|
|
||||||
NSString *urlStr = [[event paramDescriptorForKeyword:keyDirectObject]
|
|
||||||
stringValue];
|
|
||||||
qDebug() << "Wants to open:" << [urlStr UTF8String];
|
|
||||||
|
|
||||||
//TODO: Your custom URL handling code here
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@@ -161,13 +137,13 @@ void Tomahawk::macMain() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
void setShortcutHandler(MacGlobalShortcutBackend* handler) {
|
void Tomahawk::setShortcutHandler(Tomahawk::MacShortcutHandler* handler) {
|
||||||
[NSApp SetShortcutHandler: handler];
|
[NSApp setShortcutHandler: handler];
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
void Tomahawk::setApplicationHandler(Tomahawk::PlatformInterface* handler) {
|
void Tomahawk::setApplicationHandler(Tomahawk::PlatformInterface* handler) {
|
||||||
[NSApp SetApplicationHandler: handler];
|
[NSApp setApplicationHandler: handler];
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckForUpdates() {
|
void CheckForUpdates() {
|
13
src/shortcuthandler.cpp
Normal file
13
src/shortcuthandler.cpp
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#include "shortcuthandler.h"
|
||||||
|
|
||||||
|
using namespace Tomahawk;
|
||||||
|
|
||||||
|
ShortcutHandler::ShortcutHandler( QObject *parent )
|
||||||
|
: QObject( parent )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ShortcutHandler::~ShortcutHandler()
|
||||||
|
{
|
||||||
|
}
|
34
src/shortcuthandler.h
Normal file
34
src/shortcuthandler.h
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#ifndef SHORTCUTHANDLER_H
|
||||||
|
#define SHORTCUTHANDLER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
namespace Tomahawk {
|
||||||
|
/**
|
||||||
|
Base class for various shortcut plugins on different platforms
|
||||||
|
*/
|
||||||
|
class ShortcutHandler : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
virtual ~ShortcutHandler();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
// add more as needed
|
||||||
|
void playPause();
|
||||||
|
void pause();
|
||||||
|
void stop();
|
||||||
|
void previous();
|
||||||
|
void next();
|
||||||
|
|
||||||
|
void volumeUp();
|
||||||
|
void volumeDown();
|
||||||
|
void mute();
|
||||||
|
protected:
|
||||||
|
explicit ShortcutHandler( QObject *parent = 0 );
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // SHORTCUTHANDLER_H
|
@@ -24,8 +24,11 @@
|
|||||||
#include "web/api_v1.h"
|
#include "web/api_v1.h"
|
||||||
#include "scriptresolver.h"
|
#include "scriptresolver.h"
|
||||||
#include "sourcelist.h"
|
#include "sourcelist.h"
|
||||||
|
#include "shortcuthandler.h"
|
||||||
|
#include "tomahawksettings.h"
|
||||||
|
|
||||||
#include "audio/audioengine.h"
|
#include "audio/audioengine.h"
|
||||||
|
#include "utils/xspfloader.h"
|
||||||
|
|
||||||
#ifndef TOMAHAWK_HEADLESS
|
#ifndef TOMAHAWK_HEADLESS
|
||||||
#include "tomahawkwindow.h"
|
#include "tomahawkwindow.h"
|
||||||
@@ -34,7 +37,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
#include "tomahawkapp_mac.h"
|
#include "mac/macshortcuthandler.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -42,8 +45,6 @@
|
|||||||
|
|
||||||
#define LOGFILE TomahawkUtils::appDataDir().filePath( "tomahawk.log" ).toLocal8Bit()
|
#define LOGFILE TomahawkUtils::appDataDir().filePath( "tomahawk.log" ).toLocal8Bit()
|
||||||
#define LOGFILE_SIZE 1024 * 512
|
#define LOGFILE_SIZE 1024 * 512
|
||||||
#include "tomahawksettings.h"
|
|
||||||
#include <utils/xspfloader.h>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
ofstream logfile;
|
ofstream logfile;
|
||||||
@@ -114,6 +115,7 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
|
|||||||
, m_audioEngine( 0 )
|
, m_audioEngine( 0 )
|
||||||
, m_sipHandler( 0 )
|
, m_sipHandler( 0 )
|
||||||
, m_servent( 0 )
|
, m_servent( 0 )
|
||||||
|
, m_shortcutHandler( 0 )
|
||||||
, m_mainwindow( 0 )
|
, m_mainwindow( 0 )
|
||||||
, m_infoSystem( 0 )
|
, m_infoSystem( 0 )
|
||||||
{
|
{
|
||||||
@@ -160,35 +162,49 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
|
|||||||
qDebug() << "Init Echonest Factory.";
|
qDebug() << "Init Echonest Factory.";
|
||||||
GeneratorFactory::registerFactory( "echonest", new EchonestFactory );
|
GeneratorFactory::registerFactory( "echonest", new EchonestFactory );
|
||||||
|
|
||||||
#ifndef NO_LIBLASTFM
|
// Register shortcut handler for this platform
|
||||||
qDebug() << "Init Scrobbler.";
|
#ifdef Q_WS_MAC
|
||||||
m_scrobbler = new Scrobbler( this );
|
m_shortcutHandler = new MacShortcutHandler( this );
|
||||||
qDebug() << "Setting NAM.";
|
Tomahawk::setShortcutHandler( static_cast<MacShortcutHandler*>( m_shortcutHandler) );
|
||||||
TomahawkUtils::setNam( new lastfm::NetworkAccessManager( this ) );
|
|
||||||
|
|
||||||
connect( m_audioEngine, SIGNAL( started( const Tomahawk::result_ptr& ) ),
|
Tomahawk::setApplicationHandler( this );
|
||||||
m_scrobbler, SLOT( trackStarted( const Tomahawk::result_ptr& ) ), Qt::QueuedConnection );
|
|
||||||
|
|
||||||
connect( m_audioEngine, SIGNAL( paused() ),
|
|
||||||
m_scrobbler, SLOT( trackPaused() ), Qt::QueuedConnection );
|
|
||||||
|
|
||||||
connect( m_audioEngine, SIGNAL( resumed() ),
|
|
||||||
m_scrobbler, SLOT( trackResumed() ), Qt::QueuedConnection );
|
|
||||||
|
|
||||||
connect( m_audioEngine, SIGNAL( stopped() ),
|
|
||||||
m_scrobbler, SLOT( trackStopped() ), Qt::QueuedConnection );
|
|
||||||
#else
|
|
||||||
qDebug() << "Setting NAM.";
|
|
||||||
TomahawkUtils::setNam( new QNetworkAccessManager );
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
// Connect up shortcuts
|
||||||
Tomahawk::setApplicationHandler( this );
|
connect( m_shortcutHandler, SIGNAL( playPause() ), m_audioEngine, SLOT( playPause() ) );
|
||||||
|
connect( m_shortcutHandler, SIGNAL( pause() ), m_audioEngine, SLOT( pause() ) );
|
||||||
|
connect( m_shortcutHandler, SIGNAL( stop() ), m_audioEngine, SLOT( stop() ) );
|
||||||
|
connect( m_shortcutHandler, SIGNAL( previous() ), m_audioEngine, SLOT( previous() ) );
|
||||||
|
connect( m_shortcutHandler, SIGNAL( next() ), m_audioEngine, SLOT( next() ) );
|
||||||
|
connect( m_shortcutHandler, SIGNAL( volumeUp() ), m_audioEngine, SLOT( raiseVolume() ) );
|
||||||
|
connect( m_shortcutHandler, SIGNAL( volumeDown() ), m_audioEngine, SLOT( lowerVolume() ) );
|
||||||
|
connect( m_shortcutHandler, SIGNAL( mute() ), m_audioEngine, SLOT( mute() ) );
|
||||||
|
|
||||||
|
#ifndef NO_LIBLASTFM
|
||||||
|
qDebug() << "Init Scrobbler.";
|
||||||
|
m_scrobbler = new Scrobbler( this );
|
||||||
|
qDebug() << "Setting NAM.";
|
||||||
|
TomahawkUtils::setNam( new lastfm::NetworkAccessManager( this ) );
|
||||||
|
|
||||||
|
connect( m_audioEngine, SIGNAL( started( const Tomahawk::result_ptr& ) ),
|
||||||
|
m_scrobbler, SLOT( trackStarted( const Tomahawk::result_ptr& ) ), Qt::QueuedConnection );
|
||||||
|
|
||||||
|
connect( m_audioEngine, SIGNAL( paused() ),
|
||||||
|
m_scrobbler, SLOT( trackPaused() ), Qt::QueuedConnection );
|
||||||
|
|
||||||
|
connect( m_audioEngine, SIGNAL( resumed() ),
|
||||||
|
m_scrobbler, SLOT( trackResumed() ), Qt::QueuedConnection );
|
||||||
|
|
||||||
|
connect( m_audioEngine, SIGNAL( stopped() ),
|
||||||
|
m_scrobbler, SLOT( trackStopped() ), Qt::QueuedConnection );
|
||||||
|
#else
|
||||||
|
qDebug() << "Setting NAM.";
|
||||||
|
TomahawkUtils::setNam( new QNetworkAccessManager );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set up proxy
|
// Set up proxy
|
||||||
if( TomahawkSettings::instance()->proxyType() != QNetworkProxy::NoProxy &&
|
if( TomahawkSettings::instance()->proxyType() != QNetworkProxy::NoProxy &&
|
||||||
!TomahawkSettings::instance()->proxyHost().isEmpty() )
|
!TomahawkSettings::instance()->proxyHost().isEmpty() )
|
||||||
{
|
{
|
||||||
qDebug() << "Setting proxy to saved values";
|
qDebug() << "Setting proxy to saved values";
|
||||||
TomahawkUtils::setProxy( new QNetworkProxy( static_cast<QNetworkProxy::ProxyType>(TomahawkSettings::instance()->proxyType()), TomahawkSettings::instance()->proxyHost(), TomahawkSettings::instance()->proxyPort(), TomahawkSettings::instance()->proxyUsername(), TomahawkSettings::instance()->proxyPassword() ) );
|
TomahawkUtils::setProxy( new QNetworkProxy( static_cast<QNetworkProxy::ProxyType>(TomahawkSettings::instance()->proxyType()), TomahawkSettings::instance()->proxyHost(), TomahawkSettings::instance()->proxyPort(), TomahawkSettings::instance()->proxyUsername(), TomahawkSettings::instance()->proxyPassword() ) );
|
||||||
|
Reference in New Issue
Block a user