diff --git a/data/images/no-album-art-placeholder.png b/data/images/no-album-art-placeholder.png
index 009700a4a..725597649 100644
Binary files a/data/images/no-album-art-placeholder.png and b/data/images/no-album-art-placeholder.png differ
diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt
index 78d252976..b5fbd59f3 100644
--- a/src/libtomahawk/CMakeLists.txt
+++ b/src/libtomahawk/CMakeLists.txt
@@ -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 )
diff --git a/src/libtomahawk/audio/audioengine.cpp b/src/libtomahawk/audio/audioengine.cpp
index 2e43c13de..f2bdceb16 100644
--- a/src/libtomahawk/audio/audioengine.cpp
+++ b/src/libtomahawk/audio/audioengine.cpp
@@ -520,10 +520,6 @@ AudioEngine::onStateChanged( Phonon::State newState, Phonon::State oldState )
if ( newState == Phonon::PlayingState )
setState( Playing );
- if ( !m_expectStop )
- return;
- m_expectStop = false;
-
if ( oldState == Phonon::PlayingState )
{
qint64 duration = m_mediaObject->totalTime() > 0 ? m_mediaObject->totalTime() : m_currentTrack->duration() * 1000;
@@ -533,7 +529,6 @@ AudioEngine::onStateChanged( Phonon::State newState, Phonon::State oldState )
case Phonon::PausedState:
{
stopped = ( duration - 1000 < m_mediaObject->currentTime() );
-
if ( !stopped )
setState( Paused );
@@ -548,8 +543,9 @@ AudioEngine::onStateChanged( Phonon::State newState, Phonon::State oldState )
break;
}
- if ( stopped )
+ if ( stopped && m_expectStop )
{
+ m_expectStop = false;
qDebug() << "Loading next track.";
loadNextTrack();
}
diff --git a/src/libtomahawk/globalactionmanager.cpp b/src/libtomahawk/globalactionmanager.cpp
index ad85da31c..6169a40c7 100644
--- a/src/libtomahawk/globalactionmanager.cpp
+++ b/src/libtomahawk/globalactionmanager.cpp
@@ -668,12 +668,18 @@ GlobalActionManager::showPlaylist()
void
GlobalActionManager::waitingForResolved( bool success )
{
+ if( m_waitingToPlay.data() != sender() )
+ {
+ m_waitingToPlay.clear();
+ return;
+ }
+
if( success && !m_waitingToPlay.isNull() && !m_waitingToPlay->results().isEmpty() ) { // play it!
// AudioEngine::instance()->playItem( AudioEngine::instance()->playlist(), m_waitingToPlay->results().first() );
AudioEngine::instance()->play();
- }
- m_waitingToPlay.clear();
+ m_waitingToPlay.clear();
+ }
}
QString
diff --git a/src/libtomahawk/pipeline.cpp b/src/libtomahawk/pipeline.cpp
index 30ac98b1a..8a253ce3a 100644
--- a/src/libtomahawk/pipeline.cpp
+++ b/src/libtomahawk/pipeline.cpp
@@ -209,7 +209,7 @@ Pipeline::reportResults( QID qid, const QList< result_ptr >& results )
}
else
{
- new FuncTimeout( 500, boost::bind( &Pipeline::timeoutShunt, this, q ), this );
+ new FuncTimeout( 50, boost::bind( &Pipeline::timeoutShunt, this, q ), this );
}
}
@@ -246,7 +246,7 @@ Pipeline::shuntNext()
}
setQIDState( q, rc );
- new FuncTimeout( 500, boost::bind( &Pipeline::shunt, this, q ), this );
+ new FuncTimeout( 50, boost::bind( &Pipeline::shunt, this, q ), this );
}
diff --git a/src/libtomahawk/playlist/albumitemdelegate.cpp b/src/libtomahawk/playlist/albumitemdelegate.cpp
index 7871a7bc9..aac8c1777 100644
--- a/src/libtomahawk/playlist/albumitemdelegate.cpp
+++ b/src/libtomahawk/playlist/albumitemdelegate.cpp
@@ -38,8 +38,7 @@ AlbumItemDelegate::AlbumItemDelegate( QAbstractItemView* parent, AlbumProxyModel
, m_model( proxy )
{
m_shadowPixmap = QPixmap( RESPATH "images/cover-shadow.png" );
- m_defaultCover = QPixmap( RESPATH "images/no-album-art-placeholder.png" )
- .scaled( QSize( 120, 120 ), Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
+ m_defaultCover = QPixmap( RESPATH "images/no-album-art-placeholder.png" );
}
@@ -62,18 +61,20 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
initStyleOption( &opt, QModelIndex() );
qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter );
+#ifndef Q_OS_MAC
if ( option.state & QStyle::State_Selected )
{
opt.palette.setColor( QPalette::Text, opt.palette.color( QPalette::HighlightedText ) );
}
-
+#endif
painter->save();
// painter->setRenderHint( QPainter::Antialiasing );
// painter->drawPixmap( option.rect.adjusted( 4, 4, -4, -38 ), m_shadowPixmap );
QPixmap cover = item->cover.isNull() ? m_defaultCover : item->cover;
- painter->drawPixmap( option.rect.adjusted( 6, 4, -6, -41 ), cover );
+ QRect r = option.rect.adjusted( 6, 4, -6, -41 );
+ painter->drawPixmap( r, cover.scaled( r.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
painter->setPen( opt.palette.color( QPalette::Text ) );
QTextOption to;
diff --git a/src/libtomahawk/playlist/infobar/infobar.ui b/src/libtomahawk/playlist/infobar/infobar.ui
index 379101249..e7e81d7d8 100644
--- a/src/libtomahawk/playlist/infobar/infobar.ui
+++ b/src/libtomahawk/playlist/infobar/infobar.ui
@@ -25,7 +25,7 @@
InfoBar
-
+
-
diff --git a/src/libtomahawk/playlist/playlistitemdelegate.cpp b/src/libtomahawk/playlist/playlistitemdelegate.cpp
index dca3c7c92..ac2336b3c 100644
--- a/src/libtomahawk/playlist/playlistitemdelegate.cpp
+++ b/src/libtomahawk/playlist/playlistitemdelegate.cpp
@@ -67,7 +67,7 @@ PlaylistItemDelegate::sizeHint( const QStyleOptionViewItem& option, const QModel
{
int style = index.data( TrackModel::StyleRole ).toInt();
if ( style == TrackModel::Short )
- size.setHeight( 48 );
+ size.setHeight( 44 );
}
return size;
@@ -198,7 +198,7 @@ PlaylistItemDelegate::paintShort( QPainter* painter, const QStyleOptionViewItem&
painter->setPen( opt.palette.text().color() );
QRect ir = r.adjusted( 4, 0, -option.rect.width() + option.rect.height() - 8 + r.left(), 0 );
- painter->drawPixmap( ir, pixmap );
+ painter->drawPixmap( ir, pixmap.scaled( ir.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
//painter->drawPixmap( ir, item->cover );
QFont boldFont = opt.font;
diff --git a/src/libtomahawk/playlist/topbar/searchlineedit.cpp b/src/libtomahawk/playlist/topbar/searchlineedit.cpp
index 683e6e135..e7ed3fdca 100644
--- a/src/libtomahawk/playlist/topbar/searchlineedit.cpp
+++ b/src/libtomahawk/playlist/topbar/searchlineedit.cpp
@@ -52,6 +52,8 @@ void SearchLineEdit::init()
addWidget(m_clearButton, RightSide);
m_clearButton->hide();
+ setWidgetSpacing(5);
+
updateTextMargins();
setInactiveText(tr("Search"));
}
diff --git a/src/libtomahawk/playlist/treeitemdelegate.cpp b/src/libtomahawk/playlist/treeitemdelegate.cpp
index 554f83c61..feb67ba38 100644
--- a/src/libtomahawk/playlist/treeitemdelegate.cpp
+++ b/src/libtomahawk/playlist/treeitemdelegate.cpp
@@ -40,8 +40,7 @@ TreeItemDelegate::TreeItemDelegate( ArtistView* parent, TreeProxyModel* proxy )
, m_model( proxy )
{
m_nowPlayingIcon = QPixmap( RESPATH "images/now-playing-speaker.png" );
- m_defaultCover = QPixmap( RESPATH "images/no-album-art-placeholder.png" )
- .scaled( QSize( 120, 120 ), Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
+ m_defaultCover = QPixmap( RESPATH "images/no-album-art-placeholder.png" );
}
@@ -135,7 +134,7 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
// painter->drawPixmap( r, QPixmap( RESPATH "images/cover-shadow.png" ) );
QPixmap cover = item->cover.isNull() ? m_defaultCover : item->cover;
- painter->drawPixmap( r, cover );
+ painter->drawPixmap( r, cover.scaled( r.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
QTextOption to;
to.setAlignment( Qt::AlignVCenter );
diff --git a/src/libtomahawk/tomahawksettings.cpp b/src/libtomahawk/tomahawksettings.cpp
index 40fa85624..d05152b25 100644
--- a/src/libtomahawk/tomahawksettings.cpp
+++ b/src/libtomahawk/tomahawksettings.cpp
@@ -447,6 +447,17 @@ TomahawkSettings::setVerboseNotifications( bool notifications )
setValue( "ui/notifications/verbose", notifications );
}
+bool
+TomahawkSettings::showOfflineSources() const
+{
+ return value( "collection/sources/showoffline", false ).toBool();
+}
+
+void
+TomahawkSettings::setShowOfflineSources( bool show )
+{
+ setValue( "collection/sources/showoffline", show );
+}
QByteArray
TomahawkSettings::playlistColumnSizes( const QString& playlistid ) const
diff --git a/src/libtomahawk/tomahawksettings.h b/src/libtomahawk/tomahawksettings.h
index d3ffd1c3a..f22d530dc 100644
--- a/src/libtomahawk/tomahawksettings.h
+++ b/src/libtomahawk/tomahawksettings.h
@@ -71,6 +71,10 @@ public:
bool verboseNotifications() const;
void setVerboseNotifications( bool notifications );
+ // Collection Stuff
+ bool showOfflineSources() const;
+ void setShowOfflineSources( bool show );
+
/// Playlist stuff
QByteArray playlistColumnSizes( const QString& playlistid ) const;
void setPlaylistColumnSizes( const QString& playlistid, const QByteArray& state );
diff --git a/src/libtomahawk/utils/tomahawkutils.cpp b/src/libtomahawk/utils/tomahawkutils.cpp
index 4a371461c..0e310f6c5 100644
--- a/src/libtomahawk/utils/tomahawkutils.cpp
+++ b/src/libtomahawk/utils/tomahawkutils.cpp
@@ -460,5 +460,11 @@ setNam( QNetworkAccessManager* nam )
s_nam = QWeakPointer< QNetworkAccessManager >( nam );
}
+#ifndef Q_OS_MAC
+void
+bringToFront() {
+
+}
+#endif
} // ns
diff --git a/src/libtomahawk/utils/tomahawkutils.h b/src/libtomahawk/utils/tomahawkutils.h
index d30658878..f3c1263c1 100644
--- a/src/libtomahawk/utils/tomahawkutils.h
+++ b/src/libtomahawk/utils/tomahawkutils.h
@@ -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
diff --git a/src/libtomahawk/utils/tomahawkutils_mac.mm b/src/libtomahawk/utils/tomahawkutils_mac.mm
new file mode 100644
index 000000000..d7e710237
--- /dev/null
+++ b/src/libtomahawk/utils/tomahawkutils_mac.mm
@@ -0,0 +1,13 @@
+#include "tomahawkutils.h"
+
+#import
+
+namespace TomahawkUtils
+{
+
+void
+bringToFront() {
+ [NSApp activateIgnoringOtherApps:YES];
+}
+
+}
diff --git a/src/libtomahawk/viewmanager.cpp b/src/libtomahawk/viewmanager.cpp
index aa95667b5..e02441276 100644
--- a/src/libtomahawk/viewmanager.cpp
+++ b/src/libtomahawk/viewmanager.cpp
@@ -240,10 +240,10 @@ ViewManager::show( const Tomahawk::album_ptr& album )
{
view = new PlaylistView();
PlaylistModel* model = new PlaylistModel();
+ model->append( album );
view->setPlaylistModel( model );
view->setFrameShape( QFrame::NoFrame );
view->setAttribute( Qt::WA_MacShowFocusRect, 0 );
- model->append( album );
m_albumViews.insert( album, view );
}
diff --git a/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.ui b/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.ui
index 738ebffca..d09c557f7 100644
--- a/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.ui
+++ b/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget.ui
@@ -14,9 +14,18 @@
Form
+
+ 4
+
-
-
-
-
+
+
+ Qt::Horizontal
+
+
+ 1
+
+
-
-
-
+
+
+ true
+
+
-
- -
+
+
-
-
-
+
+
+ true
+
+
-
-
+
+
-
@@ -63,6 +80,11 @@
+
+ PlaylistView
+ QTreeView
+
+
HeaderLabel
QLabel
@@ -73,11 +95,6 @@
QTreeView
-
- PlaylistView
- QTreeView
-
-
diff --git a/src/resolvers/qtscriptresolver.cpp b/src/resolvers/qtscriptresolver.cpp
index 0aa7dd90b..63b887b90 100644
--- a/src/resolvers/qtscriptresolver.cpp
+++ b/src/resolvers/qtscriptresolver.cpp
@@ -68,14 +68,14 @@ QtScriptResolverHelper::compress( const QString& data )
QString
-QtScriptResolverHelper::readCompressed(const QString& fileName)
+QtScriptResolverHelper::readCompressed( const QString& fileName )
{
return compress( readRaw( fileName ) );
}
QString
-QtScriptResolverHelper::readBase64(const QString& fileName)
+QtScriptResolverHelper::readBase64( const QString& fileName )
{
return readRaw( fileName ).toBase64();
}
@@ -91,7 +91,8 @@ QtScriptResolverHelper::resolverData()
}
-void QtScriptResolverHelper::log(const QString& message)
+void
+QtScriptResolverHelper::log( const QString& message )
{
qDebug() << m_scriptPath << ":" << message;
}
@@ -104,6 +105,14 @@ QtScriptResolverHelper::setResolverConfig( QVariantMap config )
}
+void
+ScriptEngine::javaScriptConsoleMessage( const QString& message, int lineNumber, const QString& sourceID )
+{
+ qDebug() << "JAVASCRIPT:" << m_scriptPath << message << lineNumber << sourceID;
+ Q_ASSERT( false );
+}
+
+
QtScriptResolver::QtScriptResolver( const QString& scriptPath )
: Tomahawk::ExternalResolver( scriptPath )
, m_ready( false )
@@ -118,7 +127,8 @@ QtScriptResolver::QtScriptResolver( const QString& scriptPath )
{
qDebug() << Q_FUNC_INFO << "Failed loading JavaScript resolver:" << scriptPath;
m_error = Tomahawk::ExternalResolver::FileNotFound;
- } else
+ }
+ else
{
init();
}
@@ -132,6 +142,7 @@ QtScriptResolver::~QtScriptResolver()
delete m_engine;
}
+
void
QtScriptResolver::reload()
{
@@ -145,6 +156,7 @@ QtScriptResolver::reload()
}
}
+
void
QtScriptResolver::init()
{
@@ -176,13 +188,13 @@ QtScriptResolver::init()
resolverInit();
QVariantMap m = resolverSettings();
- m_name = m.value( "name" ).toString();
- m_weight = m.value( "weight", 0 ).toUInt();
- m_timeout = m.value( "timeout", 25 ).toUInt() * 1000;
+ m_name = m.value( "name" ).toString();
+ m_weight = m.value( "weight", 0 ).toUInt();
+ m_timeout = m.value( "timeout", 25 ).toUInt() * 1000;
// load config widget and apply settings
loadUi();
- QVariantMap config = resolverUserConfig();
+ QVariantMap config = resolverUserConfig();
fillDataInWidgets( config );
qDebug() << Q_FUNC_INFO << m_name << m_weight << m_timeout;
@@ -191,32 +203,31 @@ QtScriptResolver::init()
Tomahawk::Pipeline::instance()->addResolver( this );
}
+
Tomahawk::ExternalResolver::ErrorState
QtScriptResolver::error() const
{
return m_error;
}
+
void
QtScriptResolver::resolve( const Tomahawk::query_ptr& query )
{
if ( QThread::currentThread() != thread() )
{
-// qDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
QMetaObject::invokeMethod( this, "resolve", Qt::QueuedConnection, Q_ARG(Tomahawk::query_ptr, query) );
return;
}
-// qDebug() << Q_FUNC_INFO << query->toString();
QString eval;
-
if ( !query->isFullTextQuery() )
{
eval = QString( RESOLVER_LEGACY_CODE2 "resolver.resolve( '%1', '%2', '%3', '%4' );" )
- .arg( query->id().replace( "'", "\\'" ) )
- .arg( query->artist().replace( "'", "\\'" ) )
- .arg( query->album().replace( "'", "\\'" ) )
- .arg( query->track().replace( "'", "\\'" ) );
+ .arg( query->id().replace( "'", "\\'" ) )
+ .arg( query->artist().replace( "'", "\\'" ) )
+ .arg( query->album().replace( "'", "\\'" ) )
+ .arg( query->track().replace( "'", "\\'" ) );
}
else
{
@@ -225,9 +236,9 @@ QtScriptResolver::resolve( const Tomahawk::query_ptr& query )
"} else {"
" resolve( '%1', '', '', '%2' );"
"}"
- )
- .arg( query->id().replace( "'", "\\'" ) )
- .arg( query->fullTextQuery().replace( "'", "\\'" ) );
+ )
+ .arg( query->id().replace( "'", "\\'" ) )
+ .arg( query->fullTextQuery().replace( "'", "\\'" ) );
}
QList< Tomahawk::result_ptr > results;
diff --git a/src/resolvers/qtscriptresolver.h b/src/resolvers/qtscriptresolver.h
index f9ec1a370..c337075e5 100644
--- a/src/resolvers/qtscriptresolver.h
+++ b/src/resolvers/qtscriptresolver.h
@@ -50,7 +50,7 @@ public slots:
QString compress( const QString& data );
QVariantMap resolverData();
- void log( const QString& message);
+ void log( const QString& message );
bool fakeEnv() { return false; }
private:
@@ -86,8 +86,7 @@ public slots:
}
protected:
- virtual void javaScriptConsoleMessage( const QString & message, int lineNumber, const QString & sourceID )
- { qDebug() << "JAVASCRIPT:" << m_scriptPath << message << lineNumber << sourceID; Q_ASSERT(false);}
+ virtual void javaScriptConsoleMessage( const QString& message, int lineNumber, const QString& sourceID );
private:
QtScriptResolver* m_parent;
diff --git a/src/sourcetree/sourcesproxymodel.cpp b/src/sourcetree/sourcesproxymodel.cpp
index 094238688..855ec1ef0 100644
--- a/src/sourcetree/sourcesproxymodel.cpp
+++ b/src/sourcetree/sourcesproxymodel.cpp
@@ -44,21 +44,12 @@ SourcesProxyModel::SourcesProxyModel( SourcesModel* model, QObject* parent )
void
-SourcesProxyModel::showOfflineSources()
+SourcesProxyModel::showOfflineSources( bool offlineSourcesShown )
{
- m_filtered = false;
+ m_filtered = !offlineSourcesShown;
invalidateFilter();
}
-
-void
-SourcesProxyModel::hideOfflineSources()
-{
- m_filtered = true;
- invalidateFilter();
-}
-
-
bool
SourcesProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
{
diff --git a/src/sourcetree/sourcesproxymodel.h b/src/sourcetree/sourcesproxymodel.h
index cd4cfbf9c..4599d8c5c 100644
--- a/src/sourcetree/sourcesproxymodel.h
+++ b/src/sourcetree/sourcesproxymodel.h
@@ -31,8 +31,7 @@ public:
explicit SourcesProxyModel( SourcesModel* model, QObject* parent = 0 );
public slots:
- void showOfflineSources();
- void hideOfflineSources();
+ void showOfflineSources( bool offlineSourcesShown );
void selectRequested( const QModelIndex& );
diff --git a/src/sourcetree/sourcetreeview.cpp b/src/sourcetree/sourcetreeview.cpp
index fe5a9e66b..cd6139d91 100644
--- a/src/sourcetree/sourcetreeview.cpp
+++ b/src/sourcetree/sourcetreeview.cpp
@@ -26,6 +26,7 @@
#include "sourcetree/items/collectionitem.h"
#include "audio/audioengine.h"
#include "sourceplaylistinterface.h"
+#include "tomahawksettings.h"
#include
#include
@@ -110,7 +111,7 @@ SourceTreeView::SourceTreeView( QWidget* parent )
connect( this, SIGNAL( expanded( QModelIndex ) ), this, SLOT( onItemExpanded( QModelIndex ) ) );
// connect( selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), SLOT( onSelectionChanged() ) );
- hideOfflineSources();
+ showOfflineSources( TomahawkSettings::instance()->showOfflineSources() );
// Light-blue sourcetree on osx
#ifdef Q_WS_MAC
@@ -199,19 +200,11 @@ SourceTreeView::setupMenus()
void
-SourceTreeView::showOfflineSources()
+SourceTreeView::showOfflineSources( bool offlineSourcesShown )
{
- m_proxyModel->showOfflineSources();
+ m_proxyModel->showOfflineSources( offlineSourcesShown );
}
-
-void
-SourceTreeView::hideOfflineSources()
-{
- m_proxyModel->hideOfflineSources();
-}
-
-
void
SourceTreeView::onItemActivated( const QModelIndex& index )
{
diff --git a/src/sourcetree/sourcetreeview.h b/src/sourcetree/sourcetreeview.h
index a33b3f7c5..54054732a 100644
--- a/src/sourcetree/sourcetreeview.h
+++ b/src/sourcetree/sourcetreeview.h
@@ -38,8 +38,7 @@ public:
explicit SourceTreeView( QWidget* parent = 0 );
public slots:
- void showOfflineSources();
- void hideOfflineSources();
+ void showOfflineSources( bool offlineSourcesShown );
void renamePlaylist();
signals:
diff --git a/src/tomahawkapp.cpp b/src/tomahawkapp.cpp
index fe9883838..88cb21e27 100644
--- a/src/tomahawkapp.cpp
+++ b/src/tomahawkapp.cpp
@@ -250,6 +250,8 @@ TomahawkApp::init()
Tomahawk::setApplicationHandler( this );
increaseMaxFileDescriptors();
+
+ setQuitOnLastWindowClosed( false );
#endif
// Connect up shortcuts
@@ -570,7 +572,7 @@ void
TomahawkApp::activate()
{
#ifndef TOMAHAWK_HEADLESS
- mainWindow()->show();
+ TomahawkUtils::bringToFront();
#endif
}
@@ -578,6 +580,7 @@ TomahawkApp::activate()
bool
TomahawkApp::loadUrl( const QString& url )
{
+ activate();
if ( url.startsWith( "tomahawk://" ) )
return GlobalActionManager::instance()->parseTomahawkLink( url );
else
diff --git a/src/tomahawkapp.h b/src/tomahawkapp.h
index 69b78fe3e..ea13702e7 100644
--- a/src/tomahawkapp.h
+++ b/src/tomahawkapp.h
@@ -95,10 +95,10 @@ public:
Tomahawk::ExternalResolver* resolverForPath( const QString& scriptPath );
// PlatformInterface
- virtual void activate();
virtual bool loadUrl( const QString& url );
public slots:
+ virtual void activate();
void instanceStarted( KDSingleApplicationGuard::Instance );
private slots:
diff --git a/src/tomahawktrayicon.cpp b/src/tomahawktrayicon.cpp
index 88615f6c3..2b0405004 100644
--- a/src/tomahawktrayicon.cpp
+++ b/src/tomahawktrayicon.cpp
@@ -30,6 +30,7 @@
TomahawkTrayIcon::TomahawkTrayIcon( QObject* parent )
: QSystemTrayIcon( parent )
, m_currentAnimationFrame( 0 )
+ , m_showWindowAction( 0 )
{
QIcon icon( RESPATH "icons/tomahawk-icon-128x128.png" );
setIcon( icon );
@@ -45,6 +46,15 @@ TomahawkTrayIcon::TomahawkTrayIcon( QObject* parent )
m_contextMenu->addSeparator();
m_prevAction = m_contextMenu->addAction( tr( "Previous Track" ) );
m_nextAction = m_contextMenu->addAction( tr( "Next Track" ) );
+
+#ifdef Q_OS_MAC
+ // On mac you can close the windows while leaving the app open. We then need a way to show the main window again
+ m_contextMenu->addSeparator();
+ m_showWindowAction = m_contextMenu->addAction( tr( "Hide Tomahawk Window" ) );
+ m_showWindowAction->setData( true );
+ connect( m_showWindowAction, SIGNAL( triggered() ), this, SLOT( showWindow() ) );
+#endif
+
m_contextMenu->addSeparator();
m_quitAction = m_contextMenu->addAction( tr( "Quit" ) );
@@ -69,6 +79,33 @@ TomahawkTrayIcon::~TomahawkTrayIcon()
delete m_contextMenu;
}
+void
+TomahawkTrayIcon::setShowHideWindow( bool show )
+{
+ if ( show )
+ {
+ m_showWindowAction->setText( tr( "Hide Tomahawk Window" ) );
+ m_showWindowAction->setData( show );
+ } else {
+ m_showWindowAction->setText( tr( "Show Tomahawk Window" ) );
+ }
+ m_showWindowAction->setData( show );
+}
+
+void
+TomahawkTrayIcon::showWindow()
+{
+ if( !m_showWindowAction->data().toBool() )
+ {
+ APP->mainWindow()->show();
+ APP->mainWindow()->raise();
+
+ setShowHideWindow( true );
+ } else {
+ APP->mainWindow()->hide();
+ setShowHideWindow( false );
+ }
+}
void
TomahawkTrayIcon::setResult( const Tomahawk::result_ptr& result )
diff --git a/src/tomahawktrayicon.h b/src/tomahawktrayicon.h
index 2cef11872..c78a8b173 100644
--- a/src/tomahawktrayicon.h
+++ b/src/tomahawktrayicon.h
@@ -33,12 +33,15 @@ public:
TomahawkTrayIcon( QObject* parent );
virtual bool event( QEvent* e );
+ void setShowHideWindow( bool show = true );
+
public slots:
void setResult( const Tomahawk::result_ptr& result );
private slots:
void onAnimationTimer();
void onActivated( QSystemTrayIcon::ActivationReason reason );
+ void showWindow();
private:
void refreshToolTip();
@@ -57,6 +60,8 @@ private:
QAction* m_prevAction;
QAction* m_nextAction;
QAction* m_quitAction;
+
+ QAction* m_showWindowAction;
};
#endif // TOMAHAWK_TRAYICON_H
diff --git a/src/tomahawkwindow.cpp b/src/tomahawkwindow.cpp
index 7fcbd08ca..07b2207e6 100644
--- a/src/tomahawkwindow.cpp
+++ b/src/tomahawkwindow.cpp
@@ -160,13 +160,11 @@ TomahawkWindow::saveSettings()
void
TomahawkWindow::applyPlatformTweaks()
{
-#ifdef Q_WS_X11
// HACK QtCurve causes an infinite loop on startup. This is because setStyle calls setPalette, which calls ensureBaseStyle,
// which loads QtCurve. QtCurve calls setPalette, which creates an infinite loop. The UI will look like CRAP with QtCurve, but
// the user is asking for it explicitly... so he's gonna be stuck with an ugly UI.
if ( !QString( qApp->style()->metaObject()->className() ).toLower().contains( "qtcurve" ) )
qApp->setStyle( new ProxyStyle() );
-#endif
#ifdef Q_WS_MAC
setUnifiedTitleAndToolBarOnMac( true );
@@ -208,6 +206,9 @@ TomahawkWindow::setupSideBar()
ui->splitter->setStretchFactor( 1, 3 );
ui->splitter->setCollapsible( 1, false );
ui->splitter->setHandleWidth( 1 );
+
+ ui->actionShowOfflineSources->setChecked( TomahawkSettings::instance()->showOfflineSources() );
+
}
@@ -300,8 +301,7 @@ TomahawkWindow::setupSignals()
connect( ui->actionCreate_New_Station, SIGNAL( triggered() ), SLOT( createStation() ));
connect( ui->actionAboutTomahawk, SIGNAL( triggered() ), SLOT( showAboutTomahawk() ) );
connect( ui->actionExit, SIGNAL( triggered() ), qApp, SLOT( quit() ) );
- connect( ui->actionHideOfflineSources, SIGNAL( triggered() ), m_sourcetree, SLOT( hideOfflineSources() ) );
- connect( ui->actionShowOfflineSources, SIGNAL( triggered() ), m_sourcetree, SLOT( showOfflineSources() ) );
+ connect( ui->actionShowOfflineSources, SIGNAL( triggered() ), SLOT( showOfflineSources() ) );
connect( ui->actionPlay, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( playPause() ) );
connect( ui->actionNext, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( previous() ) );
@@ -362,6 +362,8 @@ TomahawkWindow::closeEvent( QCloseEvent* e )
e->ignore();
return;
}
+#else
+ m_trayIcon->setShowHideWindow( false );
#endif
e->accept();
@@ -476,6 +478,13 @@ TomahawkWindow::pluginMenuRemoved( QMenu* menu )
}
}
+void
+TomahawkWindow::showOfflineSources()
+{
+ m_sourcetree->showOfflineSources( ui->actionShowOfflineSources->isChecked() );
+ TomahawkSettings::instance()->setShowOfflineSources( ui->actionShowOfflineSources->isChecked() );
+}
+
void
TomahawkWindow::loadSpiff()
@@ -669,7 +678,7 @@ void
TomahawkWindow::onSearch()
{
ViewManager::instance()->show( new SearchWidget( m_searchWidget->searchEdit->text(), this ) );
- m_searchWidget->searchEdit->setText( QString() );
+ m_searchWidget->searchEdit->clear();
}
diff --git a/src/tomahawkwindow.h b/src/tomahawkwindow.h
index ed529893d..49605a048 100644
--- a/src/tomahawkwindow.h
+++ b/src/tomahawkwindow.h
@@ -71,6 +71,7 @@ public slots:
void rescanCollectionManually();
void pluginMenuAdded(QMenu*);
void pluginMenuRemoved(QMenu*);
+ void showOfflineSources();
private slots:
void onSipConnected();
diff --git a/src/tomahawkwindow.ui b/src/tomahawkwindow.ui
index 0f506a40c..dad448a42 100644
--- a/src/tomahawkwindow.ui
+++ b/src/tomahawkwindow.ui
@@ -35,7 +35,7 @@
0
0
1000
- 20
+ 22
@@ -164,6 +163,9 @@
+
+ true
+
Show Offline Sources