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

Merge branch 'master' into proxytesting

This commit is contained in:
Jeff Mitchell
2011-07-23 10:32:20 -04:00
30 changed files with 201 additions and 91 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

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

View File

@@ -520,10 +520,6 @@ AudioEngine::onStateChanged( Phonon::State newState, Phonon::State oldState )
if ( newState == Phonon::PlayingState ) if ( newState == Phonon::PlayingState )
setState( Playing ); setState( Playing );
if ( !m_expectStop )
return;
m_expectStop = false;
if ( oldState == Phonon::PlayingState ) if ( oldState == Phonon::PlayingState )
{ {
qint64 duration = m_mediaObject->totalTime() > 0 ? m_mediaObject->totalTime() : m_currentTrack->duration() * 1000; 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: case Phonon::PausedState:
{ {
stopped = ( duration - 1000 < m_mediaObject->currentTime() ); stopped = ( duration - 1000 < m_mediaObject->currentTime() );
if ( !stopped ) if ( !stopped )
setState( Paused ); setState( Paused );
@@ -548,8 +543,9 @@ AudioEngine::onStateChanged( Phonon::State newState, Phonon::State oldState )
break; break;
} }
if ( stopped ) if ( stopped && m_expectStop )
{ {
m_expectStop = false;
qDebug() << "Loading next track."; qDebug() << "Loading next track.";
loadNextTrack(); loadNextTrack();
} }

View File

@@ -668,12 +668,18 @@ GlobalActionManager::showPlaylist()
void void
GlobalActionManager::waitingForResolved( bool success ) GlobalActionManager::waitingForResolved( bool success )
{ {
if( m_waitingToPlay.data() != sender() )
{
m_waitingToPlay.clear();
return;
}
if( success && !m_waitingToPlay.isNull() && !m_waitingToPlay->results().isEmpty() ) { // play it! if( success && !m_waitingToPlay.isNull() && !m_waitingToPlay->results().isEmpty() ) { // play it!
// AudioEngine::instance()->playItem( AudioEngine::instance()->playlist(), m_waitingToPlay->results().first() ); // AudioEngine::instance()->playItem( AudioEngine::instance()->playlist(), m_waitingToPlay->results().first() );
AudioEngine::instance()->play(); AudioEngine::instance()->play();
}
m_waitingToPlay.clear(); m_waitingToPlay.clear();
}
} }
QString QString

View File

@@ -209,7 +209,7 @@ Pipeline::reportResults( QID qid, const QList< result_ptr >& results )
} }
else 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 ); setQIDState( q, rc );
new FuncTimeout( 500, boost::bind( &Pipeline::shunt, this, q ), this ); new FuncTimeout( 50, boost::bind( &Pipeline::shunt, this, q ), this );
} }

View File

@@ -38,8 +38,7 @@ AlbumItemDelegate::AlbumItemDelegate( QAbstractItemView* parent, AlbumProxyModel
, m_model( proxy ) , m_model( proxy )
{ {
m_shadowPixmap = QPixmap( RESPATH "images/cover-shadow.png" ); m_shadowPixmap = QPixmap( RESPATH "images/cover-shadow.png" );
m_defaultCover = QPixmap( RESPATH "images/no-album-art-placeholder.png" ) m_defaultCover = QPixmap( RESPATH "images/no-album-art-placeholder.png" );
.scaled( QSize( 120, 120 ), Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
} }
@@ -62,18 +61,20 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
initStyleOption( &opt, QModelIndex() ); initStyleOption( &opt, QModelIndex() );
qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter ); qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter );
#ifndef Q_OS_MAC
if ( option.state & QStyle::State_Selected ) if ( option.state & QStyle::State_Selected )
{ {
opt.palette.setColor( QPalette::Text, opt.palette.color( QPalette::HighlightedText ) ); opt.palette.setColor( QPalette::Text, opt.palette.color( QPalette::HighlightedText ) );
} }
#endif
painter->save(); painter->save();
// painter->setRenderHint( QPainter::Antialiasing ); // painter->setRenderHint( QPainter::Antialiasing );
// painter->drawPixmap( option.rect.adjusted( 4, 4, -4, -38 ), m_shadowPixmap ); // painter->drawPixmap( option.rect.adjusted( 4, 4, -4, -38 ), m_shadowPixmap );
QPixmap cover = item->cover.isNull() ? m_defaultCover : item->cover; 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 ) ); painter->setPen( opt.palette.color( QPalette::Text ) );
QTextOption to; QTextOption to;

View File

@@ -25,7 +25,7 @@
<property name="windowTitle"> <property name="windowTitle">
<string>InfoBar</string> <string>InfoBar</string>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,1,0,0,0">
<item> <item>
<spacer name="horizontalSpacer_3"> <spacer name="horizontalSpacer_3">
<property name="orientation"> <property name="orientation">

View File

@@ -67,7 +67,7 @@ PlaylistItemDelegate::sizeHint( const QStyleOptionViewItem& option, const QModel
{ {
int style = index.data( TrackModel::StyleRole ).toInt(); int style = index.data( TrackModel::StyleRole ).toInt();
if ( style == TrackModel::Short ) if ( style == TrackModel::Short )
size.setHeight( 48 ); size.setHeight( 44 );
} }
return size; return size;
@@ -198,7 +198,7 @@ PlaylistItemDelegate::paintShort( QPainter* painter, const QStyleOptionViewItem&
painter->setPen( opt.palette.text().color() ); painter->setPen( opt.palette.text().color() );
QRect ir = r.adjusted( 4, 0, -option.rect.width() + option.rect.height() - 8 + r.left(), 0 ); 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 ); //painter->drawPixmap( ir, item->cover );
QFont boldFont = opt.font; QFont boldFont = opt.font;

View File

@@ -52,6 +52,8 @@ void SearchLineEdit::init()
addWidget(m_clearButton, RightSide); addWidget(m_clearButton, RightSide);
m_clearButton->hide(); m_clearButton->hide();
setWidgetSpacing(5);
updateTextMargins(); updateTextMargins();
setInactiveText(tr("Search")); setInactiveText(tr("Search"));
} }

View File

@@ -40,8 +40,7 @@ TreeItemDelegate::TreeItemDelegate( ArtistView* parent, TreeProxyModel* proxy )
, m_model( proxy ) , m_model( proxy )
{ {
m_nowPlayingIcon = QPixmap( RESPATH "images/now-playing-speaker.png" ); m_nowPlayingIcon = QPixmap( RESPATH "images/now-playing-speaker.png" );
m_defaultCover = QPixmap( RESPATH "images/no-album-art-placeholder.png" ) m_defaultCover = QPixmap( RESPATH "images/no-album-art-placeholder.png" );
.scaled( QSize( 120, 120 ), Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
} }
@@ -135,7 +134,7 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
// painter->drawPixmap( r, QPixmap( RESPATH "images/cover-shadow.png" ) ); // painter->drawPixmap( r, QPixmap( RESPATH "images/cover-shadow.png" ) );
QPixmap cover = item->cover.isNull() ? m_defaultCover : item->cover; 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; QTextOption to;
to.setAlignment( Qt::AlignVCenter ); to.setAlignment( Qt::AlignVCenter );

View File

@@ -447,6 +447,17 @@ TomahawkSettings::setVerboseNotifications( bool notifications )
setValue( "ui/notifications/verbose", 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 QByteArray
TomahawkSettings::playlistColumnSizes( const QString& playlistid ) const TomahawkSettings::playlistColumnSizes( const QString& playlistid ) const

View File

@@ -71,6 +71,10 @@ public:
bool verboseNotifications() const; bool verboseNotifications() const;
void setVerboseNotifications( bool notifications ); void setVerboseNotifications( bool notifications );
// Collection Stuff
bool showOfflineSources() const;
void setShowOfflineSources( bool show );
/// Playlist stuff /// Playlist stuff
QByteArray playlistColumnSizes( const QString& playlistid ) const; QByteArray playlistColumnSizes( const QString& playlistid ) const;
void setPlaylistColumnSizes( const QString& playlistid, const QByteArray& state ); void setPlaylistColumnSizes( const QString& playlistid, const QByteArray& state );

View File

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

View File

@@ -80,6 +80,9 @@ namespace TomahawkUtils
DLLEXPORT void setProxyFactory( TomahawkUtils::NetworkProxyFactory* factory ); DLLEXPORT void setProxyFactory( TomahawkUtils::NetworkProxyFactory* factory );
DLLEXPORT void setNam( QNetworkAccessManager* nam ); 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 #endif // TOMAHAWKUTILS_H

View File

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

View File

@@ -240,10 +240,10 @@ ViewManager::show( const Tomahawk::album_ptr& album )
{ {
view = new PlaylistView(); view = new PlaylistView();
PlaylistModel* model = new PlaylistModel(); PlaylistModel* model = new PlaylistModel();
model->append( album );
view->setPlaylistModel( model ); view->setPlaylistModel( model );
view->setFrameShape( QFrame::NoFrame ); view->setFrameShape( QFrame::NoFrame );
view->setAttribute( Qt::WA_MacShowFocusRect, 0 ); view->setAttribute( Qt::WA_MacShowFocusRect, 0 );
model->append( album );
m_albumViews.insert( album, view ); m_albumViews.insert( album, view );
} }

View File

@@ -14,9 +14,18 @@
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="3,3"> <layout class="QVBoxLayout" name="verticalLayout_4" stretch="3,3">
<property name="margin">
<number>4</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <widget class="QSplitter" name="splitter">
<item> <property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="handleWidth">
<number>1</number>
</property>
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="HeaderLabel" name="label"> <widget class="HeaderLabel" name="label">
@@ -26,11 +35,15 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="PlaylistView" name="topHits"/> <widget class="PlaylistView" name="topHits">
<property name="headerHidden">
<bool>true</bool>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </widget>
<item> <widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<widget class="HeaderLabel" name="label_2"> <widget class="HeaderLabel" name="label_2">
@@ -40,11 +53,15 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="ArtistView" name="relatedArtists"/> <widget class="ArtistView" name="relatedArtists">
<property name="headerHidden">
<bool>true</bool>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </widget>
</layout> </widget>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
@@ -63,6 +80,11 @@
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget>
<class>PlaylistView</class>
<extends>QTreeView</extends>
<header>playlist/playlistview.h</header>
</customwidget>
<customwidget> <customwidget>
<class>HeaderLabel</class> <class>HeaderLabel</class>
<extends>QLabel</extends> <extends>QLabel</extends>
@@ -73,11 +95,6 @@
<extends>QTreeView</extends> <extends>QTreeView</extends>
<header location="global">artistview.h</header> <header location="global">artistview.h</header>
</customwidget> </customwidget>
<customwidget>
<class>PlaylistView</class>
<extends>QTreeView</extends>
<header location="global">playlistview.h</header>
</customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections/> <connections/>

View File

@@ -68,14 +68,14 @@ QtScriptResolverHelper::compress( const QString& data )
QString QString
QtScriptResolverHelper::readCompressed(const QString& fileName) QtScriptResolverHelper::readCompressed( const QString& fileName )
{ {
return compress( readRaw( fileName ) ); return compress( readRaw( fileName ) );
} }
QString QString
QtScriptResolverHelper::readBase64(const QString& fileName) QtScriptResolverHelper::readBase64( const QString& fileName )
{ {
return readRaw( fileName ).toBase64(); 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; 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 ) QtScriptResolver::QtScriptResolver( const QString& scriptPath )
: Tomahawk::ExternalResolver( scriptPath ) : Tomahawk::ExternalResolver( scriptPath )
, m_ready( false ) , m_ready( false )
@@ -118,7 +127,8 @@ QtScriptResolver::QtScriptResolver( const QString& scriptPath )
{ {
qDebug() << Q_FUNC_INFO << "Failed loading JavaScript resolver:" << scriptPath; qDebug() << Q_FUNC_INFO << "Failed loading JavaScript resolver:" << scriptPath;
m_error = Tomahawk::ExternalResolver::FileNotFound; m_error = Tomahawk::ExternalResolver::FileNotFound;
} else }
else
{ {
init(); init();
} }
@@ -132,6 +142,7 @@ QtScriptResolver::~QtScriptResolver()
delete m_engine; delete m_engine;
} }
void void
QtScriptResolver::reload() QtScriptResolver::reload()
{ {
@@ -145,6 +156,7 @@ QtScriptResolver::reload()
} }
} }
void void
QtScriptResolver::init() QtScriptResolver::init()
{ {
@@ -176,13 +188,13 @@ QtScriptResolver::init()
resolverInit(); resolverInit();
QVariantMap m = resolverSettings(); QVariantMap m = resolverSettings();
m_name = m.value( "name" ).toString(); m_name = m.value( "name" ).toString();
m_weight = m.value( "weight", 0 ).toUInt(); m_weight = m.value( "weight", 0 ).toUInt();
m_timeout = m.value( "timeout", 25 ).toUInt() * 1000; m_timeout = m.value( "timeout", 25 ).toUInt() * 1000;
// load config widget and apply settings // load config widget and apply settings
loadUi(); loadUi();
QVariantMap config = resolverUserConfig(); QVariantMap config = resolverUserConfig();
fillDataInWidgets( config ); fillDataInWidgets( config );
qDebug() << Q_FUNC_INFO << m_name << m_weight << m_timeout; qDebug() << Q_FUNC_INFO << m_name << m_weight << m_timeout;
@@ -191,32 +203,31 @@ QtScriptResolver::init()
Tomahawk::Pipeline::instance()->addResolver( this ); Tomahawk::Pipeline::instance()->addResolver( this );
} }
Tomahawk::ExternalResolver::ErrorState Tomahawk::ExternalResolver::ErrorState
QtScriptResolver::error() const QtScriptResolver::error() const
{ {
return m_error; return m_error;
} }
void void
QtScriptResolver::resolve( const Tomahawk::query_ptr& query ) QtScriptResolver::resolve( const Tomahawk::query_ptr& query )
{ {
if ( QThread::currentThread() != thread() ) if ( QThread::currentThread() != thread() )
{ {
// qDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
QMetaObject::invokeMethod( this, "resolve", Qt::QueuedConnection, Q_ARG(Tomahawk::query_ptr, query) ); QMetaObject::invokeMethod( this, "resolve", Qt::QueuedConnection, Q_ARG(Tomahawk::query_ptr, query) );
return; return;
} }
// qDebug() << Q_FUNC_INFO << query->toString();
QString eval; QString eval;
if ( !query->isFullTextQuery() ) if ( !query->isFullTextQuery() )
{ {
eval = QString( RESOLVER_LEGACY_CODE2 "resolver.resolve( '%1', '%2', '%3', '%4' );" ) eval = QString( RESOLVER_LEGACY_CODE2 "resolver.resolve( '%1', '%2', '%3', '%4' );" )
.arg( query->id().replace( "'", "\\'" ) ) .arg( query->id().replace( "'", "\\'" ) )
.arg( query->artist().replace( "'", "\\'" ) ) .arg( query->artist().replace( "'", "\\'" ) )
.arg( query->album().replace( "'", "\\'" ) ) .arg( query->album().replace( "'", "\\'" ) )
.arg( query->track().replace( "'", "\\'" ) ); .arg( query->track().replace( "'", "\\'" ) );
} }
else else
{ {
@@ -225,9 +236,9 @@ QtScriptResolver::resolve( const Tomahawk::query_ptr& query )
"} else {" "} else {"
" resolve( '%1', '', '', '%2' );" " resolve( '%1', '', '', '%2' );"
"}" "}"
) )
.arg( query->id().replace( "'", "\\'" ) ) .arg( query->id().replace( "'", "\\'" ) )
.arg( query->fullTextQuery().replace( "'", "\\'" ) ); .arg( query->fullTextQuery().replace( "'", "\\'" ) );
} }
QList< Tomahawk::result_ptr > results; QList< Tomahawk::result_ptr > results;

View File

@@ -50,7 +50,7 @@ public slots:
QString compress( const QString& data ); QString compress( const QString& data );
QVariantMap resolverData(); QVariantMap resolverData();
void log( const QString& message); void log( const QString& message );
bool fakeEnv() { return false; } bool fakeEnv() { return false; }
private: private:
@@ -86,8 +86,7 @@ public slots:
} }
protected: protected:
virtual void javaScriptConsoleMessage( const QString & message, int lineNumber, const QString & sourceID ) virtual void javaScriptConsoleMessage( const QString& message, int lineNumber, const QString& sourceID );
{ qDebug() << "JAVASCRIPT:" << m_scriptPath << message << lineNumber << sourceID; Q_ASSERT(false);}
private: private:
QtScriptResolver* m_parent; QtScriptResolver* m_parent;

View File

@@ -44,21 +44,12 @@ SourcesProxyModel::SourcesProxyModel( SourcesModel* model, QObject* parent )
void void
SourcesProxyModel::showOfflineSources() SourcesProxyModel::showOfflineSources( bool offlineSourcesShown )
{ {
m_filtered = false; m_filtered = !offlineSourcesShown;
invalidateFilter(); invalidateFilter();
} }
void
SourcesProxyModel::hideOfflineSources()
{
m_filtered = true;
invalidateFilter();
}
bool bool
SourcesProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const SourcesProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
{ {

View File

@@ -31,8 +31,7 @@ public:
explicit SourcesProxyModel( SourcesModel* model, QObject* parent = 0 ); explicit SourcesProxyModel( SourcesModel* model, QObject* parent = 0 );
public slots: public slots:
void showOfflineSources(); void showOfflineSources( bool offlineSourcesShown );
void hideOfflineSources();
void selectRequested( const QModelIndex& ); void selectRequested( const QModelIndex& );

View File

@@ -26,6 +26,7 @@
#include "sourcetree/items/collectionitem.h" #include "sourcetree/items/collectionitem.h"
#include "audio/audioengine.h" #include "audio/audioengine.h"
#include "sourceplaylistinterface.h" #include "sourceplaylistinterface.h"
#include "tomahawksettings.h"
#include <QAction> #include <QAction>
#include <QApplication> #include <QApplication>
@@ -110,7 +111,7 @@ SourceTreeView::SourceTreeView( QWidget* parent )
connect( this, SIGNAL( expanded( QModelIndex ) ), this, SLOT( onItemExpanded( QModelIndex ) ) ); connect( this, SIGNAL( expanded( QModelIndex ) ), this, SLOT( onItemExpanded( QModelIndex ) ) );
// connect( selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), SLOT( onSelectionChanged() ) ); // connect( selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), SLOT( onSelectionChanged() ) );
hideOfflineSources(); showOfflineSources( TomahawkSettings::instance()->showOfflineSources() );
// Light-blue sourcetree on osx // Light-blue sourcetree on osx
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
@@ -199,19 +200,11 @@ SourceTreeView::setupMenus()
void void
SourceTreeView::showOfflineSources() SourceTreeView::showOfflineSources( bool offlineSourcesShown )
{ {
m_proxyModel->showOfflineSources(); m_proxyModel->showOfflineSources( offlineSourcesShown );
} }
void
SourceTreeView::hideOfflineSources()
{
m_proxyModel->hideOfflineSources();
}
void void
SourceTreeView::onItemActivated( const QModelIndex& index ) SourceTreeView::onItemActivated( const QModelIndex& index )
{ {

View File

@@ -38,8 +38,7 @@ public:
explicit SourceTreeView( QWidget* parent = 0 ); explicit SourceTreeView( QWidget* parent = 0 );
public slots: public slots:
void showOfflineSources(); void showOfflineSources( bool offlineSourcesShown );
void hideOfflineSources();
void renamePlaylist(); void renamePlaylist();
signals: signals:

View File

@@ -250,6 +250,8 @@ TomahawkApp::init()
Tomahawk::setApplicationHandler( this ); Tomahawk::setApplicationHandler( this );
increaseMaxFileDescriptors(); increaseMaxFileDescriptors();
setQuitOnLastWindowClosed( false );
#endif #endif
// Connect up shortcuts // Connect up shortcuts
@@ -570,7 +572,7 @@ void
TomahawkApp::activate() TomahawkApp::activate()
{ {
#ifndef TOMAHAWK_HEADLESS #ifndef TOMAHAWK_HEADLESS
mainWindow()->show(); TomahawkUtils::bringToFront();
#endif #endif
} }
@@ -578,6 +580,7 @@ TomahawkApp::activate()
bool bool
TomahawkApp::loadUrl( const QString& url ) TomahawkApp::loadUrl( const QString& url )
{ {
activate();
if ( url.startsWith( "tomahawk://" ) ) if ( url.startsWith( "tomahawk://" ) )
return GlobalActionManager::instance()->parseTomahawkLink( url ); return GlobalActionManager::instance()->parseTomahawkLink( url );
else else

View File

@@ -95,10 +95,10 @@ public:
Tomahawk::ExternalResolver* resolverForPath( const QString& scriptPath ); Tomahawk::ExternalResolver* resolverForPath( const QString& scriptPath );
// PlatformInterface // PlatformInterface
virtual void activate();
virtual bool loadUrl( const QString& url ); virtual bool loadUrl( const QString& url );
public slots: public slots:
virtual void activate();
void instanceStarted( KDSingleApplicationGuard::Instance ); void instanceStarted( KDSingleApplicationGuard::Instance );
private slots: private slots:

View File

@@ -30,6 +30,7 @@
TomahawkTrayIcon::TomahawkTrayIcon( QObject* parent ) TomahawkTrayIcon::TomahawkTrayIcon( QObject* parent )
: QSystemTrayIcon( parent ) : QSystemTrayIcon( parent )
, m_currentAnimationFrame( 0 ) , m_currentAnimationFrame( 0 )
, m_showWindowAction( 0 )
{ {
QIcon icon( RESPATH "icons/tomahawk-icon-128x128.png" ); QIcon icon( RESPATH "icons/tomahawk-icon-128x128.png" );
setIcon( icon ); setIcon( icon );
@@ -45,6 +46,15 @@ TomahawkTrayIcon::TomahawkTrayIcon( QObject* parent )
m_contextMenu->addSeparator(); m_contextMenu->addSeparator();
m_prevAction = m_contextMenu->addAction( tr( "Previous Track" ) ); m_prevAction = m_contextMenu->addAction( tr( "Previous Track" ) );
m_nextAction = m_contextMenu->addAction( tr( "Next 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_contextMenu->addSeparator();
m_quitAction = m_contextMenu->addAction( tr( "Quit" ) ); m_quitAction = m_contextMenu->addAction( tr( "Quit" ) );
@@ -69,6 +79,33 @@ TomahawkTrayIcon::~TomahawkTrayIcon()
delete m_contextMenu; 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 void
TomahawkTrayIcon::setResult( const Tomahawk::result_ptr& result ) TomahawkTrayIcon::setResult( const Tomahawk::result_ptr& result )

View File

@@ -33,12 +33,15 @@ public:
TomahawkTrayIcon( QObject* parent ); TomahawkTrayIcon( QObject* parent );
virtual bool event( QEvent* e ); virtual bool event( QEvent* e );
void setShowHideWindow( bool show = true );
public slots: public slots:
void setResult( const Tomahawk::result_ptr& result ); void setResult( const Tomahawk::result_ptr& result );
private slots: private slots:
void onAnimationTimer(); void onAnimationTimer();
void onActivated( QSystemTrayIcon::ActivationReason reason ); void onActivated( QSystemTrayIcon::ActivationReason reason );
void showWindow();
private: private:
void refreshToolTip(); void refreshToolTip();
@@ -57,6 +60,8 @@ private:
QAction* m_prevAction; QAction* m_prevAction;
QAction* m_nextAction; QAction* m_nextAction;
QAction* m_quitAction; QAction* m_quitAction;
QAction* m_showWindowAction;
}; };
#endif // TOMAHAWK_TRAYICON_H #endif // TOMAHAWK_TRAYICON_H

View File

@@ -160,13 +160,11 @@ TomahawkWindow::saveSettings()
void void
TomahawkWindow::applyPlatformTweaks() TomahawkWindow::applyPlatformTweaks()
{ {
#ifdef Q_WS_X11
// HACK QtCurve causes an infinite loop on startup. This is because setStyle calls setPalette, which calls ensureBaseStyle, // 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 // 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. // 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" ) ) if ( !QString( qApp->style()->metaObject()->className() ).toLower().contains( "qtcurve" ) )
qApp->setStyle( new ProxyStyle() ); qApp->setStyle( new ProxyStyle() );
#endif
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
setUnifiedTitleAndToolBarOnMac( true ); setUnifiedTitleAndToolBarOnMac( true );
@@ -208,6 +206,9 @@ TomahawkWindow::setupSideBar()
ui->splitter->setStretchFactor( 1, 3 ); ui->splitter->setStretchFactor( 1, 3 );
ui->splitter->setCollapsible( 1, false ); ui->splitter->setCollapsible( 1, false );
ui->splitter->setHandleWidth( 1 ); 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->actionCreate_New_Station, SIGNAL( triggered() ), SLOT( createStation() ));
connect( ui->actionAboutTomahawk, SIGNAL( triggered() ), SLOT( showAboutTomahawk() ) ); connect( ui->actionAboutTomahawk, SIGNAL( triggered() ), SLOT( showAboutTomahawk() ) );
connect( ui->actionExit, SIGNAL( triggered() ), qApp, SLOT( quit() ) ); connect( ui->actionExit, SIGNAL( triggered() ), qApp, SLOT( quit() ) );
connect( ui->actionHideOfflineSources, SIGNAL( triggered() ), m_sourcetree, SLOT( hideOfflineSources() ) ); connect( ui->actionShowOfflineSources, SIGNAL( triggered() ), SLOT( showOfflineSources() ) );
connect( ui->actionShowOfflineSources, SIGNAL( triggered() ), m_sourcetree, SLOT( showOfflineSources() ) );
connect( ui->actionPlay, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( playPause() ) ); connect( ui->actionPlay, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( playPause() ) );
connect( ui->actionNext, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( previous() ) ); connect( ui->actionNext, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( previous() ) );
@@ -362,6 +362,8 @@ TomahawkWindow::closeEvent( QCloseEvent* e )
e->ignore(); e->ignore();
return; return;
} }
#else
m_trayIcon->setShowHideWindow( false );
#endif #endif
e->accept(); 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 void
TomahawkWindow::loadSpiff() TomahawkWindow::loadSpiff()
@@ -669,7 +678,7 @@ void
TomahawkWindow::onSearch() TomahawkWindow::onSearch()
{ {
ViewManager::instance()->show( new SearchWidget( m_searchWidget->searchEdit->text(), this ) ); ViewManager::instance()->show( new SearchWidget( m_searchWidget->searchEdit->text(), this ) );
m_searchWidget->searchEdit->setText( QString() ); m_searchWidget->searchEdit->clear();
} }

View File

@@ -71,6 +71,7 @@ public slots:
void rescanCollectionManually(); void rescanCollectionManually();
void pluginMenuAdded(QMenu*); void pluginMenuAdded(QMenu*);
void pluginMenuRemoved(QMenu*); void pluginMenuRemoved(QMenu*);
void showOfflineSources();
private slots: private slots:
void onSipConnected(); void onSipConnected();

View File

@@ -35,7 +35,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1000</width> <width>1000</width>
<height>20</height> <height>22</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuSettings"> <widget class="QMenu" name="menuSettings">
@@ -56,7 +56,6 @@
<addaction name="actionRescanCollection"/> <addaction name="actionRescanCollection"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionShowOfflineSources"/> <addaction name="actionShowOfflineSources"/>
<addaction name="actionHideOfflineSources"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionExit"/> <addaction name="actionExit"/>
</widget> </widget>
@@ -164,6 +163,9 @@
</property> </property>
</action> </action>
<action name="actionShowOfflineSources"> <action name="actionShowOfflineSources">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text"> <property name="text">
<string>Show Offline Sources</string> <string>Show Offline Sources</string>
</property> </property>