1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 22:26:32 +02:00

rework some startup order to load servent before UI components

This commit is contained in:
Leo Franchi
2012-02-17 16:05:31 -05:00
parent 5083849514
commit a1c69b0b43
10 changed files with 45 additions and 10 deletions

View File

@@ -74,6 +74,7 @@ ViewManager::ViewManager( QObject* parent )
, m_whatsHotWidget( new WhatsHotWidget() ) , m_whatsHotWidget( new WhatsHotWidget() )
, m_topLovedWidget( 0 ) , m_topLovedWidget( 0 )
, m_currentMode( PlaylistInterface::Tree ) , m_currentMode( PlaylistInterface::Tree )
, m_loaded( false )
{ {
s_instance = this; s_instance = this;
@@ -112,6 +113,10 @@ ViewManager::ViewManager( QObject* parent )
connect( &m_filterTimer, SIGNAL( timeout() ), SLOT( applyFilter() ) ); connect( &m_filterTimer, SIGNAL( timeout() ), SLOT( applyFilter() ) );
connect( m_infobar, SIGNAL( filterTextChanged( QString ) ), SLOT( setFilter( QString ) ) ); connect( m_infobar, SIGNAL( filterTextChanged( QString ) ), SLOT( setFilter( QString ) ) );
connect( m_infobar, SIGNAL( autoUpdateChanged( int ) ), SLOT( autoUpdateChanged( int ) ) ); connect( m_infobar, SIGNAL( autoUpdateChanged( int ) ), SLOT( autoUpdateChanged( int ) ) );
connect( this, SIGNAL( tomahawkLoaded() ), m_whatsHotWidget, SLOT( fetchData() ) );
connect( this, SIGNAL( tomahawkLoaded() ), m_welcomeWidget, SLOT( loadData() ) );
/* connect( m_infobar, SIGNAL( flatMode() ), SLOT( setTableMode() ) ); /* connect( m_infobar, SIGNAL( flatMode() ), SLOT( setTableMode() ) );
connect( m_infobar, SIGNAL( artistMode() ), SLOT( setTreeMode() ) ); connect( m_infobar, SIGNAL( artistMode() ), SLOT( setTreeMode() ) );
connect( m_infobar, SIGNAL( albumMode() ), SLOT( setAlbumMode() ) );*/ connect( m_infobar, SIGNAL( albumMode() ), SLOT( setAlbumMode() ) );*/
@@ -811,6 +816,15 @@ ViewManager::createDynamicPlaylist( const Tomahawk::source_ptr& src, const QVari
} }
void
ViewManager::setTomahawkLoaded()
{
m_loaded = true;
emit tomahawkLoaded();
}
ViewPage* ViewPage*
ViewManager::pageForCollection( const collection_ptr& col ) const ViewManager::pageForCollection( const collection_ptr& col ) const
{ {

View File

@@ -106,6 +106,8 @@ public:
// linked to the sidebar. call it right after creating the playlist // linked to the sidebar. call it right after creating the playlist
PlaylistView* createPageForPlaylist( const Tomahawk::playlist_ptr& pl ); PlaylistView* createPageForPlaylist( const Tomahawk::playlist_ptr& pl );
bool isTomahawkLoaded() const { return m_loaded; }
signals: signals:
void numSourcesChanged( unsigned int sources ); void numSourcesChanged( unsigned int sources );
void numTracksChanged( unsigned int tracks ); void numTracksChanged( unsigned int tracks );
@@ -130,6 +132,7 @@ signals:
void showQueueRequested(); void showQueueRequested();
void hideQueueRequested(); void hideQueueRequested();
void tomahawkLoaded();
public slots: public slots:
Tomahawk::ViewPage* showSuperCollection(); Tomahawk::ViewPage* showSuperCollection();
Tomahawk::ViewPage* showWelcomePage(); Tomahawk::ViewPage* showWelcomePage();
@@ -164,6 +167,8 @@ public slots:
void createPlaylist( const Tomahawk::source_ptr& src, const QVariant& contents ); void createPlaylist( const Tomahawk::source_ptr& src, const QVariant& contents );
void createDynamicPlaylist( const Tomahawk::source_ptr& src, const QVariant& contents ); void createDynamicPlaylist( const Tomahawk::source_ptr& src, const QVariant& contents );
void setTomahawkLoaded();
private slots: private slots:
void setFilter( const QString& filter ); void setFilter( const QString& filter );
void applyFilter(); void applyFilter();
@@ -217,6 +222,8 @@ private:
QTimer m_filterTimer; QTimer m_filterTimer;
QString m_filter; QString m_filter;
bool m_loaded;
static ViewManager* s_instance; static ViewManager* s_instance;
}; };

View File

@@ -80,7 +80,6 @@ WelcomeWidget::WelcomeWidget( QWidget* parent )
m_recentAlbumsModel = new AlbumModel( ui->additionsView ); m_recentAlbumsModel = new AlbumModel( ui->additionsView );
ui->additionsView->setAlbumModel( m_recentAlbumsModel ); ui->additionsView->setAlbumModel( m_recentAlbumsModel );
ui->additionsView->proxyModel()->sort( -1 ); ui->additionsView->proxyModel()->sort( -1 );
m_recentAlbumsModel->addFilteredCollection( collection_ptr(), 20, DatabaseCommand_AllAlbums::ModificationTime, true );
m_timer = new QTimer( this ); m_timer = new QTimer( this );
connect( m_timer, SIGNAL( timeout() ), SLOT( checkQueries() ) ); connect( m_timer, SIGNAL( timeout() ), SLOT( checkQueries() ) );
@@ -98,6 +97,14 @@ WelcomeWidget::~WelcomeWidget()
} }
void
WelcomeWidget::loadData()
{
m_recentAlbumsModel->addFilteredCollection( collection_ptr(), 20, DatabaseCommand_AllAlbums::ModificationTime, true );
}
Tomahawk::playlistinterface_ptr Tomahawk::playlistinterface_ptr
WelcomeWidget::playlistInterface() const WelcomeWidget::playlistInterface() const
{ {

View File

@@ -105,6 +105,7 @@ public slots:
void updatePlaylists(); void updatePlaylists();
void updateRecentAdditions(); void updateRecentAdditions();
void loadData();
private slots: private slots:
void onSourcesReady(); void onSourcesReady();
void onSourceAdded( const Tomahawk::source_ptr& source ); void onSourceAdded( const Tomahawk::source_ptr& source );

View File

@@ -103,8 +103,6 @@ WhatsHotWidget::WhatsHotWidget( QWidget* parent )
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) ); SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) ); connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
QTimer::singleShot( 0, this, SLOT( fetchData() ) );
} }

View File

@@ -82,9 +82,9 @@ signals:
void destroyed( QWidget* widget ); void destroyed( QWidget* widget );
public slots: public slots:
void fetchData();
private slots: private slots:
void fetchData();
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output ); void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
void infoSystemFinished( QString target ); void infoSystemFinished( QString target );
void leftCrumbIndexChanged( QModelIndex ); void leftCrumbIndexChanged( QModelIndex );

View File

@@ -75,9 +75,6 @@ public:
SourcesModel::CategoryType categoryType() { return m_category; } SourcesModel::CategoryType categoryType() { return m_category; }
signals:
void toggleExpandRequest( SourceTreeItem* );
private: private:
SourcesModel::CategoryType m_category; SourcesModel::CategoryType m_category;
CategoryAddItem* m_addItem; CategoryAddItem* m_addItem;

View File

@@ -119,6 +119,8 @@ using namespace Tomahawk;
TomahawkApp::TomahawkApp( int& argc, char *argv[] ) TomahawkApp::TomahawkApp( int& argc, char *argv[] )
: TOMAHAWK_APPLICATION( argc, argv ) : TOMAHAWK_APPLICATION( argc, argv )
, m_headless( false )
, m_loaded( false )
{ {
setOrganizationName( QLatin1String( TOMAHAWK_ORGANIZATION_NAME ) ); setOrganizationName( QLatin1String( TOMAHAWK_ORGANIZATION_NAME ) );
setOrganizationDomain( QLatin1String( TOMAHAWK_ORGANIZATION_DOMAIN ) ); setOrganizationDomain( QLatin1String( TOMAHAWK_ORGANIZATION_DOMAIN ) );
@@ -423,7 +425,7 @@ TomahawkApp::registerMetaTypes()
qRegisterMetaType< Tomahawk::InfoSystem::InfoRequestData >( "Tomahawk::InfoSystem::InfoRequestData" ); qRegisterMetaType< Tomahawk::InfoSystem::InfoRequestData >( "Tomahawk::InfoSystem::InfoRequestData" );
qRegisterMetaType< Tomahawk::InfoSystem::InfoSystemCache* >( "Tomahawk::InfoSystem::InfoSystemCache*" ); qRegisterMetaType< Tomahawk::InfoSystem::InfoSystemCache* >( "Tomahawk::InfoSystem::InfoSystemCache*" );
qRegisterMetaType< QList< Tomahawk::InfoSystem::InfoStringHash > >("QList< Tomahawk::InfoSystem::InfoStringHash > "); qRegisterMetaType< QList< Tomahawk::InfoSystem::InfoStringHash > >("QList< Tomahawk::InfoSystem::InfoStringHash > ");
qRegisterMetaTypeStreamOperators< QList< Tomahawk::InfoSystem::InfoStringHash > >("QList< Tomahawk::InfoSystem::InfoStringHash > "); qRegisterMetaTypeStreamOperators< QList< Tomahawk::InfoSystem::InfoStringHash > >("QList< Tomahawk::InfoSystem::InfoStringHash > ");
qRegisterMetaType< QPersistentModelIndex >( "QPersistentModelIndex" ); qRegisterMetaType< QPersistentModelIndex >( "QPersistentModelIndex" );
@@ -516,7 +518,7 @@ TomahawkApp::initServent()
} }
} }
// Called after Servent emits ready()
void void
TomahawkApp::initSIP() TomahawkApp::initSIP()
{ {
@@ -531,6 +533,9 @@ TomahawkApp::initSIP()
//SipHandler::instance()->refreshProxy(); //SipHandler::instance()->refreshProxy();
SipHandler::instance()->loadFromConfig( true ); SipHandler::instance()->loadFromConfig( true );
} }
m_loaded = true;
emit tomahawkLoaded();
} }

View File

@@ -89,6 +89,11 @@ public:
// PlatformInterface // PlatformInterface
virtual bool loadUrl( const QString& url ); virtual bool loadUrl( const QString& url );
bool isTomahawkLoaded() const { return m_loaded; }
signals:
void tomahawkLoaded();
public slots: public slots:
virtual void activate(); virtual void activate();
void instanceStarted( KDSingleApplicationGuard::Instance ); void instanceStarted( KDSingleApplicationGuard::Instance );
@@ -128,7 +133,7 @@ private:
TomahawkWindow* m_mainwindow; TomahawkWindow* m_mainwindow;
#endif #endif
bool m_headless; bool m_headless, m_loaded;
QxtHttpServerConnector m_connector; QxtHttpServerConnector m_connector;
QxtHttpSessionManager m_session; QxtHttpSessionManager m_session;

View File

@@ -86,6 +86,7 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
ViewManager* vm = new ViewManager( this ); ViewManager* vm = new ViewManager( this );
connect( vm, SIGNAL( showQueueRequested() ), SLOT( showQueue() ) ); connect( vm, SIGNAL( showQueueRequested() ), SLOT( showQueue() ) );
connect( vm, SIGNAL( hideQueueRequested() ), SLOT( hideQueue() ) ); connect( vm, SIGNAL( hideQueueRequested() ), SLOT( hideQueue() ) );
connect( APP, SIGNAL( tomahawkLoaded() ), vm, SLOT( setTomahawkLoaded() ) ); // Pass loaded signal into libtomahawk so components in there can connect to ViewManager
ui->setupUi( this ); ui->setupUi( this );