mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 21:57:41 +02:00
add error handling to resolver in stall so we hide the spinner
This commit is contained in:
@@ -734,6 +734,14 @@ AccountDelegate::doneInstalling ( const QPersistentModelIndex& idx )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AccountDelegate::errorInstalling( const QPersistentModelIndex& idx )
|
||||||
|
{
|
||||||
|
// Just hide the loading spinner as we do after a successful install
|
||||||
|
doneInstalling( idx );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AccountDelegate::doUpdateIndex( const QPersistentModelIndex& idx )
|
AccountDelegate::doUpdateIndex( const QPersistentModelIndex& idx )
|
||||||
{
|
{
|
||||||
|
@@ -43,6 +43,8 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void startInstalling( const QPersistentModelIndex& idx );
|
void startInstalling( const QPersistentModelIndex& idx );
|
||||||
void doneInstalling ( const QPersistentModelIndex& idx );
|
void doneInstalling ( const QPersistentModelIndex& idx );
|
||||||
|
void errorInstalling ( const QPersistentModelIndex& idx );
|
||||||
|
|
||||||
|
|
||||||
void doUpdateIndex( const QPersistentModelIndex& idx );
|
void doUpdateIndex( const QPersistentModelIndex& idx );
|
||||||
|
|
||||||
|
@@ -142,6 +142,7 @@ SettingsDialog::SettingsDialog( QWidget *parent )
|
|||||||
|
|
||||||
connect( m_accountProxy, SIGNAL( startInstalling( QPersistentModelIndex ) ), accountDelegate, SLOT( startInstalling(QPersistentModelIndex) ) );
|
connect( m_accountProxy, SIGNAL( startInstalling( QPersistentModelIndex ) ), accountDelegate, SLOT( startInstalling(QPersistentModelIndex) ) );
|
||||||
connect( m_accountProxy, SIGNAL( doneInstalling( QPersistentModelIndex ) ), accountDelegate, SLOT( doneInstalling(QPersistentModelIndex) ) );
|
connect( m_accountProxy, SIGNAL( doneInstalling( QPersistentModelIndex ) ), accountDelegate, SLOT( doneInstalling(QPersistentModelIndex) ) );
|
||||||
|
connect( m_accountProxy, SIGNAL( errorInstalling( QPersistentModelIndex ) ), accountDelegate, SLOT( errorInstalling(QPersistentModelIndex) ) );
|
||||||
connect( m_accountProxy, SIGNAL( scrollTo( QModelIndex ) ), this, SLOT( scrollTo( QModelIndex ) ) );
|
connect( m_accountProxy, SIGNAL( scrollTo( QModelIndex ) ), this, SLOT( scrollTo( QModelIndex ) ) );
|
||||||
|
|
||||||
ui->accountsView->setModel( m_accountProxy );
|
ui->accountsView->setModel( m_accountProxy );
|
||||||
|
@@ -503,6 +503,9 @@ AtticaManager::payloadFetched()
|
|||||||
QNetworkReply* reply = qobject_cast< QNetworkReply* >( sender() );
|
QNetworkReply* reply = qobject_cast< QNetworkReply* >( sender() );
|
||||||
Q_ASSERT( reply );
|
Q_ASSERT( reply );
|
||||||
|
|
||||||
|
bool installedSuccessfully = false;
|
||||||
|
const QString resolverId = reply->property( "resolverId" ).toString();
|
||||||
|
|
||||||
// we got a zip file, save it to a temporary file, then unzip it to our destination data dir
|
// we got a zip file, save it to a temporary file, then unzip it to our destination data dir
|
||||||
if ( reply->error() == QNetworkReply::NoError )
|
if ( reply->error() == QNetworkReply::NoError )
|
||||||
{
|
{
|
||||||
@@ -515,8 +518,6 @@ AtticaManager::payloadFetched()
|
|||||||
f.write( reply->readAll() );
|
f.write( reply->readAll() );
|
||||||
f.close();
|
f.close();
|
||||||
|
|
||||||
bool installedSuccessfully = false;
|
|
||||||
const QString resolverId = reply->property( "resolverId" ).toString();
|
|
||||||
if ( m_resolverStates[ resolverId ].binary )
|
if ( m_resolverStates[ resolverId ].binary )
|
||||||
{
|
{
|
||||||
// First ensure the signature matches. If we can't verify it, abort!
|
// First ensure the signature matches. If we can't verify it, abort!
|
||||||
@@ -554,6 +555,12 @@ AtticaManager::payloadFetched()
|
|||||||
installedSuccessfully = true;
|
installedSuccessfully = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tLog() << "Failed to download attica payload...:" << reply->errorString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( installedSuccessfully )
|
if ( installedSuccessfully )
|
||||||
{
|
{
|
||||||
@@ -562,10 +569,9 @@ AtticaManager::payloadFetched()
|
|||||||
emit resolverInstalled( resolverId );
|
emit resolverInstalled( resolverId );
|
||||||
emit resolverStateChanged( resolverId );
|
emit resolverStateChanged( resolverId );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tLog() << "Failed to download attica payload...:" << reply->errorString();
|
emit resolverInstallationFailed( resolverId );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -109,6 +109,7 @@ signals:
|
|||||||
void resolverStateChanged( const QString& resolverId );
|
void resolverStateChanged( const QString& resolverId );
|
||||||
void resolverInstalled( const QString& resolverId );
|
void resolverInstalled( const QString& resolverId );
|
||||||
void resolverUninstalled( const QString& resolverId );
|
void resolverUninstalled( const QString& resolverId );
|
||||||
|
void resolverInstallationFailed( const QString& resolverId );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void providerAdded( const Attica::Provider& );
|
void providerAdded( const Attica::Provider& );
|
||||||
|
@@ -35,6 +35,7 @@ AccountModel::AccountModel( QObject* parent )
|
|||||||
: QAbstractListModel( parent )
|
: QAbstractListModel( parent )
|
||||||
{
|
{
|
||||||
connect( AtticaManager::instance(), SIGNAL( resolversLoaded( Attica::Content::List ) ), this, SLOT( loadData() ) );
|
connect( AtticaManager::instance(), SIGNAL( resolversLoaded( Attica::Content::List ) ), this, SLOT( loadData() ) );
|
||||||
|
connect( AtticaManager::instance(), SIGNAL( resolverInstallationFailed( QString ) ), this, SLOT( resolverInstallFailed( QString ) ) );
|
||||||
|
|
||||||
connect( AccountManager::instance(), SIGNAL( added( Tomahawk::Accounts::Account* ) ), this, SLOT( accountAdded( Tomahawk::Accounts::Account* ) ) );
|
connect( AccountManager::instance(), SIGNAL( added( Tomahawk::Accounts::Account* ) ), this, SLOT( accountAdded( Tomahawk::Accounts::Account* ) ) );
|
||||||
connect( AccountManager::instance(), SIGNAL( removed( Tomahawk::Accounts::Account* ) ), this, SLOT( accountRemoved( Tomahawk::Accounts::Account* ) ) );
|
connect( AccountManager::instance(), SIGNAL( removed( Tomahawk::Accounts::Account* ) ), this, SLOT( accountRemoved( Tomahawk::Accounts::Account* ) ) );
|
||||||
@@ -689,6 +690,22 @@ AccountModel::accountRemoved( Account* account )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AccountModel::resolverInstallFailed( const QString& resolverId )
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < m_accounts.size(); i++ )
|
||||||
|
{
|
||||||
|
if ( m_accounts[ i ]->type == AccountModelNode::AtticaType && m_accounts[ i ]->atticaContent.id() == resolverId )
|
||||||
|
{
|
||||||
|
qDebug() << "Got failed attica install in account mode, emitting signal!";
|
||||||
|
emit errorInstalling( index( i, 0, QModelIndex() ) );
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
AccountModel::rowCount( const QModelIndex& ) const
|
AccountModel::rowCount( const QModelIndex& ) const
|
||||||
{
|
{
|
||||||
|
@@ -96,6 +96,8 @@ signals:
|
|||||||
|
|
||||||
void startInstalling( const QPersistentModelIndex& idx );
|
void startInstalling( const QPersistentModelIndex& idx );
|
||||||
void doneInstalling( const QPersistentModelIndex& idx );
|
void doneInstalling( const QPersistentModelIndex& idx );
|
||||||
|
void errorInstalling( const QPersistentModelIndex& idx );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void loadData();
|
void loadData();
|
||||||
|
|
||||||
@@ -103,6 +105,7 @@ private slots:
|
|||||||
void accountRemoved( Tomahawk::Accounts::Account* );
|
void accountRemoved( Tomahawk::Accounts::Account* );
|
||||||
void accountStateChanged( Account*, Accounts::Account::ConnectionState );
|
void accountStateChanged( Account*, Accounts::Account::ConnectionState );
|
||||||
|
|
||||||
|
void resolverInstallFailed( const QString& resolverId );
|
||||||
private:
|
private:
|
||||||
QList< AccountModelNode* > m_accounts;
|
QList< AccountModelNode* > m_accounts;
|
||||||
QSet< QString > m_waitingForAtticaInstall;
|
QSet< QString > m_waitingForAtticaInstall;
|
||||||
|
@@ -38,6 +38,7 @@ AccountModelFilterProxy::setSourceModel( QAbstractItemModel* sourceModel )
|
|||||||
connect( sourceModel, SIGNAL( scrollTo( QModelIndex ) ), this, SLOT( onScrollTo( QModelIndex ) ) );
|
connect( sourceModel, SIGNAL( scrollTo( QModelIndex ) ), this, SLOT( onScrollTo( QModelIndex ) ) );
|
||||||
connect( sourceModel, SIGNAL( startInstalling( QPersistentModelIndex ) ), this, SLOT( onStartInstalling( QPersistentModelIndex ) ) );
|
connect( sourceModel, SIGNAL( startInstalling( QPersistentModelIndex ) ), this, SLOT( onStartInstalling( QPersistentModelIndex ) ) );
|
||||||
connect( sourceModel, SIGNAL( doneInstalling( QPersistentModelIndex ) ), this, SLOT( onDoneInstalling( QPersistentModelIndex ) ) );
|
connect( sourceModel, SIGNAL( doneInstalling( QPersistentModelIndex ) ), this, SLOT( onDoneInstalling( QPersistentModelIndex ) ) );
|
||||||
|
connect( sourceModel, SIGNAL( doneInstalling( QPersistentModelIndex ) ), this, SLOT( errorInstalling( QPersistentModelIndex ) ) );
|
||||||
QSortFilterProxyModel::setSourceModel( sourceModel );
|
QSortFilterProxyModel::setSourceModel( sourceModel );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,3 +87,11 @@ AccountModelFilterProxy::onStartInstalling( const QPersistentModelIndex& idx )
|
|||||||
{
|
{
|
||||||
emit startInstalling( mapFromSource( idx ) );
|
emit startInstalling( mapFromSource( idx ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AccountModelFilterProxy::onErrorInstalling( const QPersistentModelIndex& idx )
|
||||||
|
{
|
||||||
|
emit errorInstalling( mapFromSource( idx ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -42,6 +42,7 @@ signals:
|
|||||||
|
|
||||||
void startInstalling( const QPersistentModelIndex& idx );
|
void startInstalling( const QPersistentModelIndex& idx );
|
||||||
void doneInstalling( const QPersistentModelIndex& idx );
|
void doneInstalling( const QPersistentModelIndex& idx );
|
||||||
|
void errorInstalling( const QPersistentModelIndex& idx );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool filterAcceptsRow ( int sourceRow, const QModelIndex& sourceParent ) const;
|
virtual bool filterAcceptsRow ( int sourceRow, const QModelIndex& sourceParent ) const;
|
||||||
@@ -51,6 +52,7 @@ private slots:
|
|||||||
|
|
||||||
void onStartInstalling( const QPersistentModelIndex& idx );
|
void onStartInstalling( const QPersistentModelIndex& idx );
|
||||||
void onDoneInstalling( const QPersistentModelIndex& idx );
|
void onDoneInstalling( const QPersistentModelIndex& idx );
|
||||||
|
void onErrorInstalling( const QPersistentModelIndex& idx );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Tomahawk::Accounts::AccountType m_filterType;
|
Tomahawk::Accounts::AccountType m_filterType;
|
||||||
|
@@ -783,7 +783,7 @@ extractScriptPayload( const QString& filename, const QString& resolverId )
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TomahawkUtils::unzipFileInFolder( const QString &zipFileName, const QDir &folder )
|
unzipFileInFolder( const QString &zipFileName, const QDir &folder )
|
||||||
{
|
{
|
||||||
Q_ASSERT( !zipFileName.isEmpty() );
|
Q_ASSERT( !zipFileName.isEmpty() );
|
||||||
Q_ASSERT( folder.exists() );
|
Q_ASSERT( folder.exists() );
|
||||||
@@ -878,7 +878,7 @@ extractBinaryResolver( const QString& zipFilename, const QString& resolverId, QO
|
|||||||
qDebug() << "OS X: Copying binary resolver from to:" << src << dest;
|
qDebug() << "OS X: Copying binary resolver from to:" << src << dest;
|
||||||
|
|
||||||
copyWithAuthentication( src, dest, 0 );
|
copyWithAuthentication( src, dest, 0 );
|
||||||
#elif Q_OS_WIN
|
#elif defined(Q_OS_WIN)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// No support for binary resolvers on linux! Shouldn't even have been allowed to see/install..
|
// No support for binary resolvers on linux! Shouldn't even have been allowed to see/install..
|
||||||
|
Reference in New Issue
Block a user