mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-15 02:24:50 +02:00
Initial work on latch functionality
This commit is contained in:
@@ -27,6 +27,7 @@ set( libSources
|
|||||||
query.cpp
|
query.cpp
|
||||||
result.cpp
|
result.cpp
|
||||||
source.cpp
|
source.cpp
|
||||||
|
sourceplaylistinterface.cpp
|
||||||
viewpage.cpp
|
viewpage.cpp
|
||||||
viewmanager.cpp
|
viewmanager.cpp
|
||||||
globalactionmanager.cpp
|
globalactionmanager.cpp
|
||||||
@@ -189,6 +190,7 @@ set( libHeaders
|
|||||||
resolver.h
|
resolver.h
|
||||||
result.h
|
result.h
|
||||||
source.h
|
source.h
|
||||||
|
sourceplaylistinterface.h
|
||||||
viewpage.h
|
viewpage.h
|
||||||
viewmanager.h
|
viewmanager.h
|
||||||
globalactionmanager.h
|
globalactionmanager.h
|
||||||
|
@@ -146,7 +146,9 @@ void
|
|||||||
AudioEngine::previous()
|
AudioEngine::previous()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
loadPreviousTrack();
|
if ( !m_playlist->skipSeekRestrictions() == PlaylistInterface::NoSkip &&
|
||||||
|
!m_playlist->skipSeekRestrictions() == PlaylistInterface::NoSkipSeek )
|
||||||
|
loadPreviousTrack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -154,13 +156,19 @@ void
|
|||||||
AudioEngine::next()
|
AudioEngine::next()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
loadNextTrack();
|
if ( !m_playlist->skipSeekRestrictions() == PlaylistInterface::NoSkip &&
|
||||||
|
!m_playlist->skipSeekRestrictions() == PlaylistInterface::NoSkipSeek )
|
||||||
|
loadNextTrack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioEngine::seek( int ms )
|
AudioEngine::seek( int ms )
|
||||||
{
|
{
|
||||||
|
if ( m_playlist->skipSeekRestrictions() == PlaylistInterface::NoSeek ||
|
||||||
|
m_playlist->skipSeekRestrictions() == PlaylistInterface::NoSkipSeek )
|
||||||
|
return;
|
||||||
|
|
||||||
if ( isPlaying() || isPaused() )
|
if ( isPlaying() || isPaused() )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << ms;
|
qDebug() << Q_FUNC_INFO << ms;
|
||||||
|
@@ -35,6 +35,7 @@ class DLLEXPORT PlaylistInterface
|
|||||||
public:
|
public:
|
||||||
enum RepeatMode { NoRepeat, RepeatOne, RepeatAll };
|
enum RepeatMode { NoRepeat, RepeatOne, RepeatAll };
|
||||||
enum ViewMode { Unknown, Tree, Flat, Album };
|
enum ViewMode { Unknown, Tree, Flat, Album };
|
||||||
|
enum SkipSeekRestrictions { NoRestrictions, NoSkip, NoSeek, NoSkipSeek };
|
||||||
|
|
||||||
PlaylistInterface( QObject* parent = 0 ) : m_object( parent ) {}
|
PlaylistInterface( QObject* parent = 0 ) : m_object( parent ) {}
|
||||||
virtual ~PlaylistInterface() {}
|
virtual ~PlaylistInterface() {}
|
||||||
@@ -51,6 +52,7 @@ public:
|
|||||||
virtual PlaylistInterface::RepeatMode repeatMode() const = 0;
|
virtual PlaylistInterface::RepeatMode repeatMode() const = 0;
|
||||||
virtual bool shuffled() const = 0;
|
virtual bool shuffled() const = 0;
|
||||||
virtual PlaylistInterface::ViewMode viewMode() const { return Unknown; }
|
virtual PlaylistInterface::ViewMode viewMode() const { return Unknown; }
|
||||||
|
virtual PlaylistInterface::SkipSeekRestrictions skipSeekRestrictions() const { return NoRestrictions; }
|
||||||
|
|
||||||
virtual QString filter() const { return m_filter; }
|
virtual QString filter() const { return m_filter; }
|
||||||
virtual void setFilter( const QString& pattern ) { m_filter = pattern; }
|
virtual void setFilter( const QString& pattern ) { m_filter = pattern; }
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "collection.h"
|
#include "collection.h"
|
||||||
#include "sourcelist.h"
|
#include "sourcelist.h"
|
||||||
|
#include "sourceplaylistinterface.h"
|
||||||
|
|
||||||
#include "network/controlconnection.h"
|
#include "network/controlconnection.h"
|
||||||
#include "database/databasecommand_addsource.h"
|
#include "database/databasecommand_addsource.h"
|
||||||
@@ -267,6 +268,18 @@ Source::trackCount() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Tomahawk::playlistinterface_ptr
|
||||||
|
Source::getPlaylistInterface()
|
||||||
|
{
|
||||||
|
if ( m_playlistInterface.isNull() )
|
||||||
|
{
|
||||||
|
Tomahawk::source_ptr source = SourceList::instance()->get( id() );
|
||||||
|
m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::SourcePlaylistInterface( source ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_playlistInterface;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Source::onPlaybackStarted( const Tomahawk::query_ptr& query )
|
Source::onPlaybackStarted( const Tomahawk::query_ptr& query )
|
||||||
{
|
{
|
||||||
|
@@ -77,6 +77,8 @@ public:
|
|||||||
Tomahawk::query_ptr currentTrack() const { return m_currentTrack; }
|
Tomahawk::query_ptr currentTrack() const { return m_currentTrack; }
|
||||||
QString textStatus() const { return m_textStatus; }
|
QString textStatus() const { return m_textStatus; }
|
||||||
|
|
||||||
|
Tomahawk::playlistinterface_ptr getPlaylistInterface();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void syncedWithDatabase();
|
void syncedWithDatabase();
|
||||||
void online();
|
void online();
|
||||||
@@ -124,6 +126,8 @@ private:
|
|||||||
ControlConnection* m_cc;
|
ControlConnection* m_cc;
|
||||||
|
|
||||||
QPixmap* m_avatar;
|
QPixmap* m_avatar;
|
||||||
|
|
||||||
|
Tomahawk::playlistinterface_ptr m_playlistInterface;
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
62
src/libtomahawk/sourceplaylistinterface.cpp
Normal file
62
src/libtomahawk/sourceplaylistinterface.cpp
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
|
*
|
||||||
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Tomahawk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "sourceplaylistinterface.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "source.h"
|
||||||
|
#include "pipeline.h"
|
||||||
|
|
||||||
|
using namespace Tomahawk;
|
||||||
|
|
||||||
|
SourcePlaylistInterface::SourcePlaylistInterface( Tomahawk::source_ptr& source )
|
||||||
|
: PlaylistInterface( this )
|
||||||
|
, m_source( source )
|
||||||
|
{
|
||||||
|
connect( source.data(), SIGNAL( playbackStarted( const Tomahawk::query_ptr& ) ), SLOT( onSourcePlaybackStarted( const Tomahawk::query_ptr& ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Tomahawk::result_ptr
|
||||||
|
SourcePlaylistInterface::siblingItem( int itemsAway )
|
||||||
|
{
|
||||||
|
Q_UNUSED( itemsAway );
|
||||||
|
return m_source->currentTrack()->results().first();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Tomahawk::result_ptr
|
||||||
|
SourcePlaylistInterface::nextItem()
|
||||||
|
{
|
||||||
|
return m_source->currentTrack()->results().first();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList<Tomahawk::query_ptr>
|
||||||
|
SourcePlaylistInterface::tracks()
|
||||||
|
{
|
||||||
|
return m_source->collection()->tracks();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SourcePlaylistInterface::onSourcePlaybackStarted( const Tomahawk::query_ptr& query ) const
|
||||||
|
{
|
||||||
|
Pipeline::instance()->resolve( query, true );
|
||||||
|
}
|
74
src/libtomahawk/sourceplaylistinterface.h
Normal file
74
src/libtomahawk/sourceplaylistinterface.h
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
|
*
|
||||||
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Tomahawk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TOMAHAWKSOURCEPLAYLISTINTERFACE_H
|
||||||
|
#define TOMAHAWKSOURCEPLAYLISTINTERFACE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
|
||||||
|
#include "typedefs.h"
|
||||||
|
#include "collection.h"
|
||||||
|
#include "playlistinterface.h"
|
||||||
|
|
||||||
|
#include "dllmacro.h"
|
||||||
|
|
||||||
|
namespace Tomahawk
|
||||||
|
{
|
||||||
|
|
||||||
|
class DLLEXPORT SourcePlaylistInterface : public QObject, public PlaylistInterface
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
SourcePlaylistInterface( Tomahawk::source_ptr& source );
|
||||||
|
|
||||||
|
QList<Tomahawk::query_ptr> tracks();
|
||||||
|
|
||||||
|
virtual int trackCount() const { return 1; }
|
||||||
|
virtual int unfilteredTrackCount() const { return 1; }
|
||||||
|
|
||||||
|
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
||||||
|
virtual Tomahawk::result_ptr nextItem();
|
||||||
|
|
||||||
|
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
||||||
|
virtual PlaylistInterface::SkipSeekRestrictions skipSeekRestrictions() const { return PlaylistInterface::NoSkipSeek; }
|
||||||
|
|
||||||
|
virtual bool shuffled() const { return false; }
|
||||||
|
virtual void setFilter( const QString& /*pattern*/ ) {}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
virtual void setRepeatMode( PlaylistInterface::RepeatMode ) {}
|
||||||
|
virtual void setShuffled( bool ) {}
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||||
|
void shuffleModeChanged( bool enabled );
|
||||||
|
void trackCountChanged( unsigned int tracks );
|
||||||
|
void sourceTrackCountChanged( unsigned int tracks );
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onSourcePlaybackStarted( const Tomahawk::query_ptr& query ) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Tomahawk::source_ptr m_source;
|
||||||
|
};
|
||||||
|
|
||||||
|
}; // ns
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user