1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-24 09:49:42 +01:00

add error handling to resolver in stall so we hide the spinner

This commit is contained in:
Leo Franchi 2012-05-13 17:36:32 -04:00
parent 021cd54687
commit be76cc49d3
10 changed files with 63 additions and 14 deletions

View File

@ -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
AccountDelegate::doUpdateIndex( const QPersistentModelIndex& idx )
{

View File

@ -43,6 +43,8 @@ public:
public slots:
void startInstalling( const QPersistentModelIndex& idx );
void doneInstalling ( const QPersistentModelIndex& idx );
void errorInstalling ( const QPersistentModelIndex& idx );
void doUpdateIndex( const QPersistentModelIndex& idx );

View File

@ -97,7 +97,7 @@ SettingsDialog::SettingsDialog( QWidget *parent )
ui->enableProxyCheckBox->setChecked( useProxy );
ui->proxyButton->setEnabled( useProxy );
createIcons();
#ifdef Q_WS_X11
ui->listWidget->setFrameShape( QFrame::StyledPanel );
@ -142,6 +142,7 @@ SettingsDialog::SettingsDialog( QWidget *parent )
connect( m_accountProxy, SIGNAL( startInstalling( QPersistentModelIndex ) ), accountDelegate, SLOT( startInstalling(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 ) ) );
ui->accountsView->setModel( m_accountProxy );
@ -262,7 +263,7 @@ SettingsDialog::~SettingsDialog()
}
else
qDebug() << "Settings dialog cancelled, NOT saving prefs.";
delete ui;
}

View File

@ -503,6 +503,9 @@ AtticaManager::payloadFetched()
QNetworkReply* reply = qobject_cast< QNetworkReply* >( sender() );
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
if ( reply->error() == QNetworkReply::NoError )
{
@ -515,8 +518,6 @@ AtticaManager::payloadFetched()
f.write( reply->readAll() );
f.close();
bool installedSuccessfully = false;
const QString resolverId = reply->property( "resolverId" ).toString();
if ( m_resolverStates[ resolverId ].binary )
{
// First ensure the signature matches. If we can't verify it, abort!
@ -554,19 +555,24 @@ AtticaManager::payloadFetched()
installedSuccessfully = true;
}
}
if ( installedSuccessfully )
{
m_resolverStates[ resolverId ].state = Installed;
TomahawkSettingsGui::instanceGui()->setAtticaResolverStates( m_resolverStates );
emit resolverInstalled( resolverId );
emit resolverStateChanged( resolverId );
}
}
else
{
tLog() << "Failed to download attica payload...:" << reply->errorString();
}
if ( installedSuccessfully )
{
m_resolverStates[ resolverId ].state = Installed;
TomahawkSettingsGui::instanceGui()->setAtticaResolverStates( m_resolverStates );
emit resolverInstalled( resolverId );
emit resolverStateChanged( resolverId );
}
else
{
emit resolverInstallationFailed( resolverId );
}
}

View File

@ -109,6 +109,7 @@ signals:
void resolverStateChanged( const QString& resolverId );
void resolverInstalled( const QString& resolverId );
void resolverUninstalled( const QString& resolverId );
void resolverInstallationFailed( const QString& resolverId );
private slots:
void providerAdded( const Attica::Provider& );

View File

@ -35,6 +35,7 @@ AccountModel::AccountModel( QObject* parent )
: QAbstractListModel( parent )
{
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( 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
AccountModel::rowCount( const QModelIndex& ) const
{

View File

@ -96,6 +96,8 @@ signals:
void startInstalling( const QPersistentModelIndex& idx );
void doneInstalling( const QPersistentModelIndex& idx );
void errorInstalling( const QPersistentModelIndex& idx );
private slots:
void loadData();
@ -103,6 +105,7 @@ private slots:
void accountRemoved( Tomahawk::Accounts::Account* );
void accountStateChanged( Account*, Accounts::Account::ConnectionState );
void resolverInstallFailed( const QString& resolverId );
private:
QList< AccountModelNode* > m_accounts;
QSet< QString > m_waitingForAtticaInstall;

View File

@ -38,6 +38,7 @@ AccountModelFilterProxy::setSourceModel( QAbstractItemModel* sourceModel )
connect( sourceModel, SIGNAL( scrollTo( QModelIndex ) ), this, SLOT( onScrollTo( QModelIndex ) ) );
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( errorInstalling( QPersistentModelIndex ) ) );
QSortFilterProxyModel::setSourceModel( sourceModel );
}
@ -86,3 +87,11 @@ AccountModelFilterProxy::onStartInstalling( const QPersistentModelIndex& idx )
{
emit startInstalling( mapFromSource( idx ) );
}
void
AccountModelFilterProxy::onErrorInstalling( const QPersistentModelIndex& idx )
{
emit errorInstalling( mapFromSource( idx ) );
}

View File

@ -42,6 +42,7 @@ signals:
void startInstalling( const QPersistentModelIndex& idx );
void doneInstalling( const QPersistentModelIndex& idx );
void errorInstalling( const QPersistentModelIndex& idx );
protected:
virtual bool filterAcceptsRow ( int sourceRow, const QModelIndex& sourceParent ) const;
@ -51,6 +52,7 @@ private slots:
void onStartInstalling( const QPersistentModelIndex& idx );
void onDoneInstalling( const QPersistentModelIndex& idx );
void onErrorInstalling( const QPersistentModelIndex& idx );
private:
Tomahawk::Accounts::AccountType m_filterType;

View File

@ -783,7 +783,7 @@ extractScriptPayload( const QString& filename, const QString& resolverId )
bool
TomahawkUtils::unzipFileInFolder( const QString &zipFileName, const QDir &folder )
unzipFileInFolder( const QString &zipFileName, const QDir &folder )
{
Q_ASSERT( !zipFileName.isEmpty() );
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;
copyWithAuthentication( src, dest, 0 );
#elif Q_OS_WIN
#elif defined(Q_OS_WIN)
#endif
// No support for binary resolvers on linux! Shouldn't even have been allowed to see/install..