1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-11 08:34:34 +02:00

Bring to front on mac when a tomahawkurl is opened in Tomahawk. Will add linux and win-specific code as well.

This commit is contained in:
Leo Franchi
2011-07-21 11:20:41 -04:00
parent 4ac6c32a45
commit 57cdd0d960
5 changed files with 29 additions and 2 deletions

View File

@@ -420,7 +420,8 @@ IF( APPLE )
SET( libSources ${libSources}
infosystem/infoplugins/mac/adium.mm
infosystem/infoplugins/mac/adiumplugin.cpp )
infosystem/infoplugins/mac/adiumplugin.cpp
utils/tomahawkutils_mac.mm )
SET( libHeaders ${libHeaders}
infosystem/infoplugins/mac/adium.h
@@ -433,6 +434,8 @@ IF( APPLE )
${COREFOUNDATION_LIBRARY}
${FOUNDATION_LIBRARY}
${SCRIPTINGBRIDGE_LIBRARY}
/System/Library/Frameworks/AppKit.framework
)
ENDIF( APPLE )

View File

@@ -460,5 +460,11 @@ setNam( QNetworkAccessManager* nam )
s_nam = QWeakPointer< QNetworkAccessManager >( nam );
}
#ifndef Q_OS_MAC
void
bringToFront() {
}
#endif
} // ns

View File

@@ -80,6 +80,9 @@ namespace TomahawkUtils
DLLEXPORT void setProxyFactory( TomahawkUtils::NetworkProxyFactory* factory );
DLLEXPORT void setNam( QNetworkAccessManager* nam );
/// Platform-specific bringing tomahawk mainwindow to front, b/c qt's activate() and such don't seem to work well enough for us
DLLEXPORT void bringToFront();
}
#endif // TOMAHAWKUTILS_H

View File

@@ -0,0 +1,14 @@
#include "tomahawkutils.h"
#import <AppKit/NSApplication.h>
namespace TomahawkUtils
{
void
bringToFront() {
qDebug() << "foo";
[NSApp activateIgnoringOtherApps:YES];
}
}

View File

@@ -570,7 +570,7 @@ void
TomahawkApp::activate()
{
#ifndef TOMAHAWK_HEADLESS
mainWindow()->show();
TomahawkUtils::bringToFront();
#endif
}
@@ -578,6 +578,7 @@ TomahawkApp::activate()
bool
TomahawkApp::loadUrl( const QString& url )
{
activate();
if ( url.startsWith( "tomahawk://" ) )
return GlobalActionManager::instance()->parseTomahawkLink( url );
else