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

Compare commits

...

9 Commits

Author SHA1 Message Date
Uwe L. Korn
2ec6a06f2a Use override directly 2014-10-19 16:10:13 +02:00
Uwe L. Korn
36ea2f797f Add Menu Entry to start playlist sync 2014-10-19 16:03:13 +02:00
Uwe L. Korn
e6d8d1faa9 Remove trailing semicolons 2014-10-19 16:03:13 +02:00
Uwe L. Korn
d96458ec72 Make PlaylistUpdaterInterface a QObject 2014-10-19 16:03:13 +02:00
Uwe L. Korn
f42ac00bcb Add skeleton for starting to sync a playlist 2014-10-19 16:03:13 +02:00
Uwe L. Korn
f5395705b5 Add files to CMakeLists 2014-10-19 16:02:43 +02:00
Uwe L. Korn
d8eaf39232 Add ExternalResolverPlaylistUpdater* skeletons 2014-10-19 16:02:43 +02:00
Uwe L. Korn
0c0dfd82cc List resolvers in the menu that can sync playlists 2014-10-19 16:02:43 +02:00
Uwe L. Korn
5da18c59ce Add dummy Sync with menu 2014-10-19 16:02:43 +02:00
10 changed files with 217 additions and 4 deletions

View File

@@ -87,6 +87,8 @@ set( libGuiSources
resolvers/JSResolver.cpp
resolvers/JSResolverHelper.cpp
resolvers/ScriptEngine.cpp
resolvers/playlist/ExternalResolverPlaylistUpdater.cpp
resolvers/playlist/ExternalResolverPlaylistUpdaterFactory.cpp
utils/DpiScaler.cpp
utils/ImageRegistry.cpp

View File

@@ -327,6 +327,13 @@ Pipeline::resolve( QID qid, bool prioritized, bool temporaryQuery )
}
void
Pipeline::startPlaylistSync( ExternalResolver* r, playlist_ptr playlist )
{
// TODO
}
void
Pipeline::reportResults( QID qid, const QList< result_ptr >& results )
{

View File

@@ -78,6 +78,11 @@ public slots:
void resolve( const QList<query_ptr>& qlist, bool prioritized = true, bool temporaryQuery = false );
void resolve( QID qid, bool prioritized = true, bool temporaryQuery = false );
/**
* Initiate syncing of a playlist with a reslover.
*/
void startPlaylistSync( ExternalResolver* r, playlist_ptr playlist );
void start();
void stop();
void databaseReady();

View File

@@ -110,8 +110,9 @@ private:
};
class DLLEXPORT PlaylistUpdaterFactory
class DLLEXPORT PlaylistUpdaterFactory : public QObject
{
Q_OBJECT
public:
PlaylistUpdaterFactory() {}
virtual ~PlaylistUpdaterFactory() {}
@@ -122,7 +123,7 @@ public:
}
Q_DECLARE_METATYPE( Tomahawk::SerializedUpdater );
Q_DECLARE_METATYPE( Tomahawk::SerializedUpdaters );
Q_DECLARE_METATYPE( Tomahawk::SerializedUpdater )
Q_DECLARE_METATYPE( Tomahawk::SerializedUpdaters )
#endif // PLAYLISTUPDATERINTERFACE_H

View File

@@ -0,0 +1,11 @@
#include "ExternalResolverPlaylistUpdater.h"
namespace Tomahawk {
ExternalResolverPlaylistUpdater::ExternalResolverPlaylistUpdater( const playlist_ptr& pl, Resolver* resolver )
: PlaylistUpdaterInterface( pl )
{
// TODO
}
} // namespace Tomahawk

View File

@@ -0,0 +1,64 @@
#ifndef TOMAHAWK_EXTERNALRESOLVERPLAYLISTUPDATER_H
#define TOMAHAWK_EXTERNALRESOLVERPLAYLISTUPDATER_H
#include "playlist/PlaylistUpdaterInterface.h"
namespace Tomahawk {
class ExternalResolverPlaylistUpdater : public PlaylistUpdaterInterface
{
Q_OBJECT
public:
explicit ExternalResolverPlaylistUpdater( const playlist_ptr& pl, Resolver* resolver );
virtual ~ExternalResolverPlaylistUpdater();
// What type you are. If you add a new updater, add the creation code as well.
// virtual QString type() const = 0;
// Small widget to show in playlist header that configures the updater
// virtual QWidget* configurationWidget() const = 0;
// Small overlay over playlist icon in the sidebar to indicate that it has this updater type
// Should be around 16x16 or something
// virtual QPixmap typeIcon() const { return QPixmap(); }
// void remove();
// playlist_ptr playlist() const { return m_playlist; }
// virtual bool sync() const { return false; }
// virtual void setSync( bool ) {}
// virtual bool canSubscribe() const { return false; }
// virtual bool subscribed() const { return false; }
// virtual void setSubscribed( bool ) {}
// virtual void setCollaborative( bool ) {}
// virtual bool collaborative() const { return false; }
// The int data value associated with each question must be unique across *all* playlist updaters,
// as setQuestionResults is called with all questions from all updaters.
// virtual bool hasCustomDeleter() const { return false; }
// virtual PlaylistDeleteQuestions deleteQuestions() const { return PlaylistDeleteQuestions(); }
// virtual void setQuestionResults( const QMap< int, bool > ) {}
public slots:
// virtual void updateNow() {}
// void save();
protected:
// virtual void aboutToDelete() {}
// QVariantHash settings() const;
// void saveSettings( const QVariantHash& settings );
signals:
public slots:
};
} // namespace Tomahawk
#endif // TOMAHAWK_EXTERNALRESOLVERPLAYLISTUPDATER_H

View File

@@ -0,0 +1,54 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2014, Uwe L. Korn <uwelk@xhochy.com>
*
* 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 "ExternalResolverPlaylistUpdaterFactory.h"
#include "Pipeline.h"
namespace Tomahawk {
ExternalResolverPlaylistUpdaterFactory::ExternalResolverPlaylistUpdaterFactory()
{
connect( Pipeline::instance(), SIGNAL( resolverAdded(Tomahawk::Resolver* ) ),
SLOT( resolverAdded( Tomahawk::Resolver* ) ) );
}
ExternalResolverPlaylistUpdaterFactory::~ExternalResolverPlaylistUpdaterFactory()
{
}
QString
ExternalResolverPlaylistUpdaterFactory::type() const
{
}
PlaylistUpdaterInterface*
ExternalResolverPlaylistUpdaterFactory::create( const playlist_ptr& playlist, const QVariantHash& settings )
{
}
void
ExternalResolverPlaylistUpdaterFactory::resolverAdded( Resolver* resolver )
{
}
} // namespace Tomahawk

View File

@@ -0,0 +1,45 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2014, Uwe L. Korn <uwelk@xhochy.com>
*
* 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 TOMAHAWK_EXTERNALRESOLVERPLAYLISTUPDATERFACTORY_H
#define TOMAHAWK_EXTERNALRESOLVERPLAYLISTUPDATERFACTORY_H
#include "playlist/PlaylistUpdaterInterface.h"
#include "DllMacro.h"
namespace Tomahawk {
class DLLEXPORT ExternalResolverPlaylistUpdaterFactory : public PlaylistUpdaterFactory
{
Q_OBJECT
public:
ExternalResolverPlaylistUpdaterFactory();
virtual ~ExternalResolverPlaylistUpdaterFactory();
QString type() const override;
PlaylistUpdaterInterface* create( const playlist_ptr&, const QVariantHash& settings ) override;
private slots:
void resolverAdded( Tomahawk::Resolver* resolver );
};
} // namespace Tomahawk
#endif // TOMAHAWK_EXTERNALRESOLVERPLAYLISTUPDATERFACTORY_H

View File

@@ -62,6 +62,7 @@
#include "jobview/ErrorStatusMessage.h"
#include "jobview/JobStatusModel.h"
#include "jobview/JobStatusView.h"
#include "resolvers/playlist/ExternalResolverPlaylistUpdaterFactory.h"
#include "utils/XspfLoader.h"
#include "utils/JspfLoader.h"
#include "utils/Logger.h"
@@ -655,7 +656,7 @@ TomahawkApp::onInfoSystemReady()
Tomahawk::EchonestCatalogSynchronizer::instance();
PlaylistUpdaterInterface::registerUpdaterFactory( new XspfUpdaterFactory );
// PlaylistUpdaterInterface::registerUpdaterFactory( new SpotifyUpdaterFactory );
PlaylistUpdaterInterface::registerUpdaterFactory( new ExternalResolverPlaylistUpdaterFactory );
// Following work-around/fix taken from Clementine rev. 13e13ccd9a95 and courtesy of David Sansome
// A bug in Qt means the wheel_scroll_lines setting gets ignored and replaced

View File

@@ -44,6 +44,8 @@
#include "utils/TomahawkUtilsGui.h"
#include "widgets/SourceTreePopupDialog.h"
#include "PlaylistEntry.h"
#include "Pipeline.h"
#include "resolvers/ExternalResolver.h"
#include "../../viewpages/dashboard/Dashboard.h"
#include "../../viewpages/whatsnew_0_8/WhatsNew_0_8.h"
@@ -240,6 +242,27 @@ SourceTreeView::setupMenus()
{
QAction* exportPlaylist = m_playlistMenu.addAction( tr( "&Export Playlist") );
connect( exportPlaylist, SIGNAL( triggered() ), this, SLOT( exportPlaylist() ) );
const PlaylistItem* item = itemFromIndex< PlaylistItem >( m_contextMenuIndex );
const playlist_ptr playlist = item->playlist();
if ( playlist )
{
QMenu* playlistSyncMenu = m_playlistMenu.addMenu( tr( "Sync with .." ) );
foreach ( const QPointer<ExternalResolver>& resolver, Tomahawk::Pipeline::instance()->scriptResolvers() )
{
if ( resolver->capabilities().testFlag( ExternalResolver::PlaylistSync ) )
{
// TODO: Add a checkmark to the service that syncs this playlist
// TODO: Actually add an action to sync
QAction* plSync = playlistSyncMenu->addAction( resolver->icon(), resolver->name() );
NewClosure( plSync, SIGNAL( triggered() ),
Pipeline::instance(),
SLOT( startPlaylistSync( ExternalResolver* , playlist_ptr ) ),
resolver, playlist );
}
}
}
}
QAction* deletePlaylistAction = m_playlistMenu.addAction( tr( "&Delete %1" ).arg( SourcesModel::rowTypeToString( type ) ) );