mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Initial work towards merging accounts into GetNewStuffModel
This commit is contained in:
@@ -111,28 +111,31 @@ GetNewStuffDelegate::paint( QPainter* painter, const QStyleOptionViewItem& optio
|
|||||||
// Go from right edge now, stars, install button, and downloaded info
|
// Go from right edge now, stars, install button, and downloaded info
|
||||||
|
|
||||||
// install / status button
|
// install / status button
|
||||||
AtticaManager::ResolverState state = static_cast< AtticaManager::ResolverState >( index.data( GetNewStuffModel::StateRole ).toInt() );
|
GetNewStuffModel::ItemState state = static_cast< GetNewStuffModel::ItemState >( index.data( GetNewStuffModel::StateRole ).toInt() );
|
||||||
QString actionText;
|
QString actionText;
|
||||||
switch( state )
|
switch( state )
|
||||||
{
|
{
|
||||||
case AtticaManager::Uninstalled:
|
case GetNewStuffModel::Uninstalled:
|
||||||
actionText = tr( "Install" );
|
actionText = tr( "Install" );
|
||||||
break;
|
break;
|
||||||
case AtticaManager::Installing:
|
case GetNewStuffModel::Installing:
|
||||||
actionText = tr( "Installing" );
|
actionText = tr( "Installing" );
|
||||||
break;
|
break;
|
||||||
case AtticaManager::Upgrading:
|
case GetNewStuffModel::Upgrading:
|
||||||
actionText = tr( "Upgrading" );
|
actionText = tr( "Upgrading" );
|
||||||
break;
|
break;
|
||||||
case AtticaManager::Failed:
|
case GetNewStuffModel::Failed:
|
||||||
actionText = tr( "Failed" );
|
actionText = tr( "Failed" );
|
||||||
break;
|
break;
|
||||||
case AtticaManager::Installed:
|
case GetNewStuffModel::Installed:
|
||||||
actionText = tr( "Uninstall" );
|
actionText = tr( "Uninstall" );
|
||||||
break;
|
break;
|
||||||
case AtticaManager::NeedsUpgrade:
|
case GetNewStuffModel::NeedsUpgrade:
|
||||||
actionText = tr( "Upgrade" );
|
actionText = tr( "Upgrade" );
|
||||||
break;
|
break;
|
||||||
|
case GetNewStuffModel::CanInstallMore:
|
||||||
|
actionText = tr( "Install Another" );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int btnWidth = m_widestTextWidth + 7;
|
const int btnWidth = m_widestTextWidth + 7;
|
||||||
|
@@ -21,6 +21,9 @@
|
|||||||
#include "ui_GetNewStuffDialog.h"
|
#include "ui_GetNewStuffDialog.h"
|
||||||
#include "GetNewStuffDelegate.h"
|
#include "GetNewStuffDelegate.h"
|
||||||
#include "GetNewStuffModel.h"
|
#include "GetNewStuffModel.h"
|
||||||
|
#include "tomahawksettings.h"
|
||||||
|
|
||||||
|
#include <QtGui/QFileDialog>
|
||||||
|
|
||||||
GetNewStuffDialog::GetNewStuffDialog( QWidget* parent, Qt::WindowFlags f )
|
GetNewStuffDialog::GetNewStuffDialog( QWidget* parent, Qt::WindowFlags f )
|
||||||
: QDialog( parent, f )
|
: QDialog( parent, f )
|
||||||
@@ -29,13 +32,13 @@ GetNewStuffDialog::GetNewStuffDialog( QWidget* parent, Qt::WindowFlags f )
|
|||||||
{
|
{
|
||||||
ui->setupUi( this );
|
ui->setupUi( this );
|
||||||
|
|
||||||
ui->listView->setModel( m_model );
|
ui->accountsList->setModel( m_model );
|
||||||
GetNewStuffDelegate* del = new GetNewStuffDelegate( ui->listView );
|
GetNewStuffDelegate* del = new GetNewStuffDelegate( ui->accountsList );
|
||||||
connect( del, SIGNAL( update( QModelIndex ) ), ui->listView, SLOT( update( QModelIndex ) ) );
|
connect( del, SIGNAL( update( QModelIndex ) ), ui->accountsList, SLOT( update( QModelIndex ) ) );
|
||||||
ui->listView->setItemDelegate( del );
|
ui->accountsList->setItemDelegate( del );
|
||||||
ui->listView->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
|
ui->accountsList->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
|
||||||
|
|
||||||
ui->listView->setMouseTracking( true );
|
ui->accountsList->setMouseTracking( true );
|
||||||
|
|
||||||
setMinimumSize( 560, 350 );
|
setMinimumSize( 560, 350 );
|
||||||
|
|
||||||
@@ -43,8 +46,10 @@ GetNewStuffDialog::GetNewStuffDialog( QWidget* parent, Qt::WindowFlags f )
|
|||||||
setMaximumSize( 560, 350 );
|
setMaximumSize( 560, 350 );
|
||||||
setSizeGripEnabled( false );
|
setSizeGripEnabled( false );
|
||||||
|
|
||||||
ui->listView->setAttribute( Qt::WA_MacShowFocusRect, false );
|
ui->accountsList->setAttribute( Qt::WA_MacShowFocusRect, false );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
connect( ui->installFromFileBtn, SIGNAL( clicked( bool ) ), this, SLOT( installFromFile() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -52,3 +57,19 @@ GetNewStuffDialog::~GetNewStuffDialog()
|
|||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
GetNewStuffDialog::installFromFile()
|
||||||
|
{
|
||||||
|
QString resolver = QFileDialog::getOpenFileName( this, tr( "Load script resolver file" ), TomahawkSettings::instance()->scriptDefaultPath() );
|
||||||
|
|
||||||
|
// m_resolversModel->addResolver( resolver, true );
|
||||||
|
// TODO
|
||||||
|
if( !resolver.isEmpty() )
|
||||||
|
{
|
||||||
|
|
||||||
|
QFileInfo resolverAbsoluteFilePath = resolver;
|
||||||
|
TomahawkSettings::instance()->setScriptDefaultPath( resolverAbsoluteFilePath.absolutePath() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -33,6 +33,9 @@ public:
|
|||||||
explicit GetNewStuffDialog( QWidget *parent = 0, Qt::WindowFlags f = 0 );
|
explicit GetNewStuffDialog( QWidget *parent = 0, Qt::WindowFlags f = 0 );
|
||||||
~GetNewStuffDialog();
|
~GetNewStuffDialog();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void installFromFile();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::GetNewStuffDialog *ui;
|
Ui::GetNewStuffDialog *ui;
|
||||||
GetNewStuffModel* m_model;
|
GetNewStuffModel* m_model;
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>449</width>
|
<width>449</width>
|
||||||
<height>282</height>
|
<height>327</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -15,17 +15,41 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListView" name="listView"/>
|
<widget class="QListView" name="accountsList"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<property name="orientation">
|
<item>
|
||||||
<enum>Qt::Horizontal</enum>
|
<widget class="QPushButton" name="installFromFileBtn">
|
||||||
</property>
|
<property name="text">
|
||||||
<property name="standardButtons">
|
<string>Install from file...</string>
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
</widget>
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
@@ -20,32 +20,73 @@
|
|||||||
|
|
||||||
#include "utils/tomahawkutils.h"
|
#include "utils/tomahawkutils.h"
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
|
#include "AtticaManager.h"
|
||||||
|
#include "accounts/AccountManager.h"
|
||||||
|
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include "AtticaManager.h"
|
|
||||||
|
using namespace Tomahawk;
|
||||||
|
using namespace Accounts;
|
||||||
|
|
||||||
GetNewStuffModel::GetNewStuffModel( QObject* parent )
|
GetNewStuffModel::GetNewStuffModel( QObject* parent )
|
||||||
: QAbstractListModel ( parent )
|
: QAbstractListModel ( parent )
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( AtticaManager::instance()->resolversLoaded() )
|
|
||||||
m_contentList = AtticaManager::instance()->resolvers();
|
|
||||||
|
|
||||||
connect( AtticaManager::instance(), SIGNAL( resolversReloaded( Attica::Content::List ) ), this, SLOT( resolversReloaded( Attica::Content::List ) ) );
|
connect( AtticaManager::instance(), SIGNAL( resolversReloaded( Attica::Content::List ) ), this, SLOT( resolversReloaded( Attica::Content::List ) ) );
|
||||||
connect( AtticaManager::instance(), SIGNAL( resolverStateChanged( QString ) ), this, SLOT( resolverStateChanged( QString ) ) );
|
connect( AtticaManager::instance(), SIGNAL( resolverStateChanged( QString ) ), this, SLOT( resolverStateChanged( QString ) ) );
|
||||||
|
|
||||||
|
loadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
GetNewStuffModel::~GetNewStuffModel()
|
GetNewStuffModel::~GetNewStuffModel()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
GetNewStuffModel::loadData()
|
||||||
|
{
|
||||||
|
foreach ( const QVariant& content, m_contentList )
|
||||||
|
{
|
||||||
|
if ( !isAttica( content ) )
|
||||||
|
{
|
||||||
|
AccountItem* item = content.value< GetNewStuffModel::AccountItem* >();
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_contentList.clear();
|
||||||
|
|
||||||
|
Attica::Content::List fromAttica = AtticaManager::instance()->resolvers();
|
||||||
|
foreach ( const Attica::Content& content, fromAttica )
|
||||||
|
m_contentList.append( QVariant::fromValue< Attica::Content >( content ) );
|
||||||
|
|
||||||
|
QList< AccountFactory* > factories = AccountManager::instance()->factories();
|
||||||
|
QList< Account* > allAccounts = AccountManager::instance()->accounts();
|
||||||
|
foreach ( AccountFactory* fac, factories )
|
||||||
|
{
|
||||||
|
if ( !fac->allowUserCreation() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
AccountItem* item = new AccountItem;
|
||||||
|
item->factory = fac;
|
||||||
|
|
||||||
|
foreach ( Account* acct, allAccounts )
|
||||||
|
{
|
||||||
|
if ( AccountManager::instance()->factoryForAccount( acct ) == fac )
|
||||||
|
item->alreadyExists = true;
|
||||||
|
else
|
||||||
|
item->alreadyExists = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_contentList.append( QVariant::fromValue< GetNewStuffModel::AccountItem* >( item ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GetNewStuffModel::resolversReloaded( const Attica::Content::List& resolvers )
|
GetNewStuffModel::resolversReloaded( const Attica::Content::List& resolvers )
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
m_contentList = resolvers;
|
loadData();
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +95,10 @@ GetNewStuffModel::resolverStateChanged( const QString& resolverId )
|
|||||||
{
|
{
|
||||||
for ( int i = 0; i < m_contentList.count(); i++ )
|
for ( int i = 0; i < m_contentList.count(); i++ )
|
||||||
{
|
{
|
||||||
const Attica::Content resolver = m_contentList[ i ];
|
if ( !isAttica( m_contentList.at( i ) ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const Attica::Content resolver = atticaFromItem( m_contentList.at( i ) );
|
||||||
if ( resolver.id() == resolverId )
|
if ( resolver.id() == resolverId )
|
||||||
{
|
{
|
||||||
QModelIndex idx = index( i, 0, QModelIndex() );
|
QModelIndex idx = index( i, 0, QModelIndex() );
|
||||||
@@ -70,33 +114,82 @@ GetNewStuffModel::data( const QModelIndex& index, int role ) const
|
|||||||
if ( !index.isValid() || !hasIndex( index.row(), index.column(), index.parent() ) )
|
if ( !index.isValid() || !hasIndex( index.row(), index.column(), index.parent() ) )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
Attica::Content resolver = m_contentList[ index.row() ];
|
if ( isAttica( m_contentList.at( index.row() ) ) )
|
||||||
switch ( role )
|
|
||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
const Attica::Content resolver = atticaFromItem( m_contentList.at( index.row() ) );
|
||||||
return resolver.name();
|
switch ( role )
|
||||||
case Qt::DecorationRole:
|
{
|
||||||
return QVariant::fromValue< QPixmap >( AtticaManager::instance()->iconForResolver( resolver ) );
|
case Qt::DisplayRole:
|
||||||
case DownloadUrlRole:
|
return resolver.name();
|
||||||
// TODO
|
case Qt::DecorationRole:
|
||||||
return QUrl();
|
return QVariant::fromValue< QPixmap >( AtticaManager::instance()->iconForResolver( resolver ) );
|
||||||
case RatingRole:
|
case DownloadUrlRole:
|
||||||
return resolver.rating() / 20; // rating is out of 100
|
// TODO
|
||||||
case DownloadCounterRole:
|
return QUrl();
|
||||||
return resolver.downloads();
|
case RatingRole:
|
||||||
case VersionRole:
|
return resolver.rating() / 20; // rating is out of 100
|
||||||
return resolver.version();
|
case DownloadCounterRole:
|
||||||
case DescriptionRole:
|
return resolver.downloads();
|
||||||
return resolver.description();
|
case VersionRole:
|
||||||
case TypeRole:
|
return resolver.version();
|
||||||
return ResolverType;
|
case DescriptionRole:
|
||||||
case AuthorRole:
|
return resolver.description();
|
||||||
return resolver.author();
|
case TypeRole:
|
||||||
case StateRole:
|
return AtticaType;
|
||||||
return (int)AtticaManager::instance()->resolverState( resolver );
|
case AuthorRole:
|
||||||
case UserHasRatedRole:
|
return resolver.author();
|
||||||
return AtticaManager::instance()->userHasRated( resolver );
|
case StateRole:
|
||||||
|
return (int)AtticaManager::instance()->resolverState( resolver );
|
||||||
|
case UserHasRatedRole:
|
||||||
|
return AtticaManager::instance()->userHasRated( resolver );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Account, not from Attica
|
||||||
|
AccountItem* item = accountFromItem( m_contentList.at( index.row() ) );
|
||||||
|
Q_ASSERT( item );
|
||||||
|
switch ( role )
|
||||||
|
{
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
return item->factory->prettyName();
|
||||||
|
case Qt::DecorationRole:
|
||||||
|
return QVariant::fromValue< QPixmap >( item->factory->icon() );
|
||||||
|
case RatingRole:
|
||||||
|
// TODO
|
||||||
|
return 3;
|
||||||
|
// return resolver.rating() / 20; // rating is out of 100
|
||||||
|
case DownloadCounterRole:
|
||||||
|
// TODO
|
||||||
|
return 10;
|
||||||
|
// return resolver.downloads();
|
||||||
|
case VersionRole:
|
||||||
|
return "1.0";
|
||||||
|
// return resolver.version();
|
||||||
|
case DescriptionRole:
|
||||||
|
return item->factory->description();
|
||||||
|
case TypeRole:
|
||||||
|
return AccountType;
|
||||||
|
case AuthorRole:
|
||||||
|
return "Tomahawk Developers";
|
||||||
|
case StateRole:
|
||||||
|
{
|
||||||
|
GetNewStuffModel::ItemState state = Uninstalled;
|
||||||
|
if ( item->factory->isUnique() && item->alreadyExists )
|
||||||
|
state = Installed;
|
||||||
|
else if ( !item->factory->isUnique() && item->alreadyExists )
|
||||||
|
state = CanInstallMore;
|
||||||
|
else if ( !item->alreadyExists )
|
||||||
|
state = Uninstalled;
|
||||||
|
return (int)state;
|
||||||
|
}
|
||||||
|
case UserHasRatedRole:
|
||||||
|
// TODO
|
||||||
|
return true;
|
||||||
|
// return AtticaManager::instance()->userHasRated( resolver );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,43 +207,84 @@ GetNewStuffModel::setData( const QModelIndex &index, const QVariant &value, int
|
|||||||
if ( !hasIndex( index.row(), index.column(), index.parent() ) )
|
if ( !hasIndex( index.row(), index.column(), index.parent() ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if ( isAttica( m_contentList.at( index.row() ) ) )
|
||||||
Attica::Content resolver = m_contentList[ index.row() ];
|
|
||||||
AtticaManager::ResolverState state = AtticaManager::instance()->resolverState( resolver );
|
|
||||||
if ( role == Qt::EditRole )
|
|
||||||
{
|
{
|
||||||
switch( state )
|
Attica::Content resolver = atticaFromItem( m_contentList.at( index.row() ) );
|
||||||
|
AtticaManager::ResolverState state = AtticaManager::instance()->resolverState( resolver );
|
||||||
|
if ( role == Qt::EditRole )
|
||||||
{
|
{
|
||||||
case AtticaManager::Uninstalled:
|
switch( state )
|
||||||
// install
|
{
|
||||||
AtticaManager::instance()->installResolver( resolver );
|
case AtticaManager::Uninstalled:
|
||||||
break;
|
// install
|
||||||
case AtticaManager::Installing:
|
AtticaManager::instance()->installResolver( resolver );
|
||||||
case AtticaManager::Upgrading:
|
break;
|
||||||
// Do nothing, busy
|
case AtticaManager::Installing:
|
||||||
break;
|
case AtticaManager::Upgrading:
|
||||||
case AtticaManager::Installed:
|
// Do nothing, busy
|
||||||
// Uninstall
|
break;
|
||||||
AtticaManager::instance()->uninstallResolver( resolver );
|
case AtticaManager::Installed:
|
||||||
break;
|
// Uninstall
|
||||||
case AtticaManager::NeedsUpgrade:
|
AtticaManager::instance()->uninstallResolver( resolver );
|
||||||
AtticaManager::instance()->upgradeResolver( resolver );
|
break;
|
||||||
break;
|
case AtticaManager::NeedsUpgrade:
|
||||||
default:
|
AtticaManager::instance()->upgradeResolver( resolver );
|
||||||
//FIXME -- this handles e.g. Failed
|
break;
|
||||||
break;
|
default:
|
||||||
};
|
//FIXME -- this handles e.g. Failed
|
||||||
} else if ( role == RatingRole )
|
break;
|
||||||
{
|
};
|
||||||
// For now only allow rating if a resolver is installed!
|
} else if ( role == RatingRole )
|
||||||
if ( state != AtticaManager::Installed && state != AtticaManager::NeedsUpgrade )
|
{
|
||||||
return false;
|
// For now only allow rating if a resolver is installed!
|
||||||
if ( AtticaManager::instance()->userHasRated( resolver ) )
|
if ( state != AtticaManager::Installed && state != AtticaManager::NeedsUpgrade )
|
||||||
return false;
|
return false;
|
||||||
m_contentList[ index.row() ].setRating( value.toInt() * 20 );
|
if ( AtticaManager::instance()->userHasRated( resolver ) )
|
||||||
AtticaManager::instance()->uploadRating( m_contentList[ index.row() ] );
|
return false;
|
||||||
|
resolver.setRating( value.toInt() * 20 );
|
||||||
|
m_contentList[ index.row() ] = QVariant::fromValue< Attica::Content >( resolver );
|
||||||
|
AtticaManager::instance()->uploadRating( resolver );
|
||||||
|
}
|
||||||
|
emit dataChanged( index, index );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AccountItem* item = accountFromItem( m_contentList.at( index.row() ) );
|
||||||
|
if ( role == Qt::EditRole )
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
else if ( role == RatingRole )
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
}
|
}
|
||||||
emit dataChanged( index, index );
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
GetNewStuffModel::isAttica( const QVariant& item ) const
|
||||||
|
{
|
||||||
|
return qstrcmp( item.typeName(),"Attica::Content" ) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GetNewStuffModel::AccountItem*
|
||||||
|
GetNewStuffModel::accountFromItem( const QVariant& item ) const
|
||||||
|
{
|
||||||
|
Q_ASSERT( !isAttica( item ) );
|
||||||
|
|
||||||
|
return item.value< GetNewStuffModel::AccountItem* >();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Attica::Content
|
||||||
|
GetNewStuffModel::atticaFromItem( const QVariant& item ) const
|
||||||
|
{
|
||||||
|
Q_ASSERT( isAttica( item ) );
|
||||||
|
|
||||||
|
return item.value< Attica::Content >();
|
||||||
|
|
||||||
|
}
|
||||||
|
@@ -19,14 +19,17 @@
|
|||||||
#ifndef GETNEWSTUFFMODEL_H
|
#ifndef GETNEWSTUFFMODEL_H
|
||||||
#define GETNEWSTUFFMODEL_H
|
#define GETNEWSTUFFMODEL_H
|
||||||
|
|
||||||
#include <QModelIndex>
|
#include "accounts/Account.h"
|
||||||
|
|
||||||
#include <attica/content.h>
|
#include <attica/content.h>
|
||||||
|
|
||||||
|
#include <QModelIndex>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
|
||||||
class GetNewStuffModel: public QAbstractListModel
|
class GetNewStuffModel: public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum NewStuffRoles {
|
enum NewStuffRoles {
|
||||||
// DisplayRole is title
|
// DisplayRole is title
|
||||||
@@ -43,9 +46,26 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum Types {
|
enum Types {
|
||||||
ResolverType = 0,
|
AtticaType = 0,
|
||||||
|
AccountType = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ItemState {
|
||||||
|
Uninstalled = 0,
|
||||||
|
Installing,
|
||||||
|
Installed,
|
||||||
|
NeedsUpgrade,
|
||||||
|
Upgrading,
|
||||||
|
Failed,
|
||||||
|
CanInstallMore, // accounts that are not unique
|
||||||
|
};
|
||||||
|
|
||||||
|
// plz don't use me kthxbbq
|
||||||
|
typedef struct {
|
||||||
|
Tomahawk::Accounts::AccountFactory* factory;
|
||||||
|
bool alreadyExists;
|
||||||
|
} AccountItem;
|
||||||
|
|
||||||
explicit GetNewStuffModel( QObject* parent = 0 );
|
explicit GetNewStuffModel( QObject* parent = 0 );
|
||||||
virtual ~GetNewStuffModel();
|
virtual ~GetNewStuffModel();
|
||||||
|
|
||||||
@@ -58,7 +78,14 @@ private slots:
|
|||||||
void resolverStateChanged( const QString& resolverId );
|
void resolverStateChanged( const QString& resolverId );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Attica::Content::List m_contentList;
|
void loadData();
|
||||||
|
bool isAttica( const QVariant& item ) const;
|
||||||
|
Attica::Content atticaFromItem( const QVariant& item ) const;
|
||||||
|
AccountItem* accountFromItem( const QVariant& item ) const;
|
||||||
|
|
||||||
|
QVariantList m_contentList;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE( GetNewStuffModel::AccountItem* );
|
||||||
|
|
||||||
#endif // GETNEWSTUFFMODEL_H
|
#endif // GETNEWSTUFFMODEL_H
|
||||||
|
@@ -46,6 +46,7 @@ public:
|
|||||||
|
|
||||||
QString prettyName() const { return "Twitter"; }
|
QString prettyName() const { return "Twitter"; }
|
||||||
QString factoryId() const { return "twitteraccount"; }
|
QString factoryId() const { return "twitteraccount"; }
|
||||||
|
QString description() const { return tr( "Connect to your Twitter followers." ); }
|
||||||
QPixmap icon() const { return QPixmap( ":/twitter-icon.png" ); }
|
QPixmap icon() const { return QPixmap( ":/twitter-icon.png" ); }
|
||||||
Account* createAccount( const QString& pluginId = QString() );
|
Account* createAccount( const QString& pluginId = QString() );
|
||||||
};
|
};
|
||||||
|
@@ -38,6 +38,7 @@ public:
|
|||||||
|
|
||||||
virtual QString prettyName() const { return "Google"; }
|
virtual QString prettyName() const { return "Google"; }
|
||||||
virtual QString factoryId() const { return "googleaccount"; }
|
virtual QString factoryId() const { return "googleaccount"; }
|
||||||
|
QString description() const { return tr( "Connect to GChat to find your friends" ); }
|
||||||
virtual QPixmap icon() const;
|
virtual QPixmap icon() const;
|
||||||
virtual Account* createAccount( const QString& pluginId );
|
virtual Account* createAccount( const QString& pluginId );
|
||||||
};
|
};
|
||||||
|
@@ -47,6 +47,7 @@ public:
|
|||||||
virtual ~XmppAccountFactory() {}
|
virtual ~XmppAccountFactory() {}
|
||||||
|
|
||||||
QString prettyName() const { return "XMPP (Jabber)"; }
|
QString prettyName() const { return "XMPP (Jabber)"; }
|
||||||
|
QString description() const { return tr( "Log on to your Jabber/XMPP account to connect to your friends" ); }
|
||||||
QString factoryId() const { return "xmppaccount"; }
|
QString factoryId() const { return "xmppaccount"; }
|
||||||
QPixmap icon() const { return QPixmap( ":/xmpp-icon.png" ); }
|
QPixmap icon() const { return QPixmap( ":/xmpp-icon.png" ); }
|
||||||
Account* createAccount( const QString& pluginId = QString() );
|
Account* createAccount( const QString& pluginId = QString() );
|
||||||
|
@@ -39,6 +39,7 @@ public:
|
|||||||
|
|
||||||
virtual QString factoryId() const { return "zeroconfaccount"; }
|
virtual QString factoryId() const { return "zeroconfaccount"; }
|
||||||
virtual QString prettyName() const { return "Local Network"; }
|
virtual QString prettyName() const { return "Local Network"; }
|
||||||
|
QString description() const { return tr( "Automatically connect to Tomahawks on the local network" ); }
|
||||||
virtual bool isUnique() const { return true; }
|
virtual bool isUnique() const { return true; }
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
virtual QPixmap icon() const;
|
virtual QPixmap icon() const;
|
||||||
|
@@ -165,10 +165,14 @@ public:
|
|||||||
virtual QString prettyName() const = 0;
|
virtual QString prettyName() const = 0;
|
||||||
// internal name
|
// internal name
|
||||||
virtual QString factoryId() const = 0;
|
virtual QString factoryId() const = 0;
|
||||||
|
// description to be shown when user views a list of account types
|
||||||
|
virtual QString description() const = 0;
|
||||||
// if the user can create multiple
|
// if the user can create multiple
|
||||||
virtual QPixmap icon() const { return QPixmap(); }
|
|
||||||
virtual bool isUnique() const { return false; }
|
virtual bool isUnique() const { return false; }
|
||||||
|
|
||||||
|
virtual QPixmap icon() const { return QPixmap(); }
|
||||||
|
virtual bool allowUserCreation() const { return true; }
|
||||||
|
|
||||||
virtual Account* createAccount( const QString& accountId = QString() ) = 0;
|
virtual Account* createAccount( const QString& accountId = QString() ) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -36,7 +36,9 @@ public:
|
|||||||
|
|
||||||
virtual Account* createAccount(const QString& accountId = QString());
|
virtual Account* createAccount(const QString& accountId = QString());
|
||||||
virtual QString factoryId() const { return "resolveraccount"; }
|
virtual QString factoryId() const { return "resolveraccount"; }
|
||||||
|
virtual QString description() const { return QString(); }
|
||||||
virtual QString prettyName() const { return QString(); } // Internal, not displayed
|
virtual QString prettyName() const { return QString(); } // Internal, not displayed
|
||||||
|
virtual bool allowUserCreation() const { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -61,14 +61,6 @@
|
|||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
using namespace Accounts;
|
using namespace Accounts;
|
||||||
|
|
||||||
static QString
|
|
||||||
md5( const QByteArray& src )
|
|
||||||
{
|
|
||||||
QByteArray const digest = QCryptographicHash::hash( src, QCryptographicHash::Md5 );
|
|
||||||
return QString::fromLatin1( digest.toHex() ).rightJustified( 32, '0' );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SettingsDialog::SettingsDialog( QWidget *parent )
|
SettingsDialog::SettingsDialog( QWidget *parent )
|
||||||
: QDialog( parent )
|
: QDialog( parent )
|
||||||
, ui( new Ui_StackedSettingsDialog )
|
, ui( new Ui_StackedSettingsDialog )
|
||||||
@@ -83,9 +75,6 @@ SettingsDialog::SettingsDialog( QWidget *parent )
|
|||||||
TomahawkUtils::unmarginLayout( layout() );
|
TomahawkUtils::unmarginLayout( layout() );
|
||||||
ui->stackedWidget->setContentsMargins( 4, 4, 4, 0 );
|
ui->stackedWidget->setContentsMargins( 4, 4, 4, 0 );
|
||||||
|
|
||||||
ui->addScript->setFixedWidth( 42 );
|
|
||||||
ui->removeScript->setFixedWidth( ui->addScript->width() );
|
|
||||||
|
|
||||||
ui->checkBoxReporter->setChecked( s->crashReporterEnabled() );
|
ui->checkBoxReporter->setChecked( s->crashReporterEnabled() );
|
||||||
ui->checkBoxHttp->setChecked( s->httpEnabled() );
|
ui->checkBoxHttp->setChecked( s->httpEnabled() );
|
||||||
ui->checkBoxStaticPreferred->setChecked( s->preferStaticHostPort() );
|
ui->checkBoxStaticPreferred->setChecked( s->preferStaticHostPort() );
|
||||||
@@ -123,6 +112,14 @@ SettingsDialog::SettingsDialog( QWidget *parent )
|
|||||||
m_accountModel = new AccountModel( this );
|
m_accountModel = new AccountModel( this );
|
||||||
ui->accountsView->setModel( m_accountModel );
|
ui->accountsView->setModel( m_accountModel );
|
||||||
|
|
||||||
|
connect( ui->addNewServiceBtn, SIGNAL( clicked( bool ) ), this, SLOT( getMoreResolvers() ) );
|
||||||
|
connect( ui->removeServiceBtn, SIGNAL( clicked( bool ) ), this, SLOT( accountDeleted( bool ) ) );
|
||||||
|
|
||||||
|
connect( AtticaManager::instance(), SIGNAL( resolverInstalled( QString ) ), this, SLOT( accountAdded( Tomahawk::Accounts::Account* ) ) );
|
||||||
|
connect( AtticaManager::instance(), SIGNAL( resolverUninstalled( QString ) ), this, SLOT( accountUninstalled( QString ) ) );
|
||||||
|
|
||||||
|
connect( ui->accountsView->selectionModel(), SIGNAL( selectionChanged( QItemSelection,QItemSelection ) ), this, SLOT( accountsSelectionChanged() ) );
|
||||||
|
|
||||||
if ( !Servent::instance()->isReady() )
|
if ( !Servent::instance()->isReady() )
|
||||||
{
|
{
|
||||||
m_sipSpinner = new LoadingSpinner( ui->accountsView );
|
m_sipSpinner = new LoadingSpinner( ui->accountsView );
|
||||||
@@ -132,9 +129,6 @@ SettingsDialog::SettingsDialog( QWidget *parent )
|
|||||||
ui->removeServiceBtn->setEnabled( false );
|
ui->removeServiceBtn->setEnabled( false );
|
||||||
connect( Servent::instance(), SIGNAL( ready() ), this, SLOT( serventReady() ) );
|
connect( Servent::instance(), SIGNAL( ready() ), this, SLOT( serventReady() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
setupAccountButtons();
|
|
||||||
|
|
||||||
ui->staticHostName->setText( s->externalHostname() );
|
ui->staticHostName->setText( s->externalHostname() );
|
||||||
ui->staticPort->setValue( s->externalPort() );
|
ui->staticPort->setValue( s->externalPort() );
|
||||||
ui->proxyButton->setVisible( true );
|
ui->proxyButton->setVisible( true );
|
||||||
@@ -178,18 +172,6 @@ SettingsDialog::SettingsDialog( QWidget *parent )
|
|||||||
ui->pushButtonTestLastfmLogin->setVisible( false );
|
ui->pushButtonTestLastfmLogin->setVisible( false );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// SCRIPT RESOLVER
|
|
||||||
ui->removeScript->setEnabled( false );
|
|
||||||
ui->scriptList->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
|
|
||||||
|
|
||||||
connect( ui->getMoreResolvers, SIGNAL( clicked() ), this, SLOT( getMoreResolvers() ) );
|
|
||||||
|
|
||||||
connect( AtticaManager::instance(), SIGNAL( resolverInstalled( QString ) ), this, SLOT( atticaResolverInstalled( QString ) ) );
|
|
||||||
connect( AtticaManager::instance(), SIGNAL( resolverUninstalled( QString ) ), this, SLOT( atticaResolverUninstalled( QString ) ) );
|
|
||||||
|
|
||||||
connect( ui->scriptList->selectionModel(), SIGNAL( selectionChanged( QItemSelection,QItemSelection ) ), this, SLOT( scriptSelectionChanged() ) );
|
|
||||||
connect( ui->addScript, SIGNAL( clicked( bool ) ), this, SLOT( addScriptResolver() ) );
|
|
||||||
connect( ui->removeScript, SIGNAL( clicked( bool ) ), this, SLOT( removeScriptResolver() ) );
|
|
||||||
connect( ui->proxyButton, SIGNAL( clicked() ), SLOT( showProxySettings() ) );
|
connect( ui->proxyButton, SIGNAL( clicked() ), SLOT( showProxySettings() ) );
|
||||||
connect( ui->checkBoxStaticPreferred, SIGNAL( toggled(bool) ), SLOT( toggleUpnp(bool) ) );
|
connect( ui->checkBoxStaticPreferred, SIGNAL( toggled(bool) ), SLOT( toggleUpnp(bool) ) );
|
||||||
connect( ui->checkBoxStaticPreferred, SIGNAL( toggled(bool) ), SLOT( requiresRestart() ) );
|
connect( ui->checkBoxStaticPreferred, SIGNAL( toggled(bool) ), SLOT( requiresRestart() ) );
|
||||||
@@ -244,7 +226,7 @@ SettingsDialog::serventReady()
|
|||||||
{
|
{
|
||||||
m_sipSpinner->fadeOut();
|
m_sipSpinner->fadeOut();
|
||||||
ui->addNewServiceBtn->setEnabled( true );
|
ui->addNewServiceBtn->setEnabled( true );
|
||||||
ui->removeScript->setEnabled( true );
|
ui->removeServiceBtn->setEnabled( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -310,27 +292,6 @@ SettingsDialog::createIcons()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SettingsDialog::setupAccountButtons()
|
|
||||||
{
|
|
||||||
// foreach( AccountFactory* f, AccountManager::instance()->factories() )
|
|
||||||
// {
|
|
||||||
// if( f->isUnique() && AccountManager::instance()->hasPluginWithFactory( f->factoryId() ) )
|
|
||||||
// {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// QAction* action = new QAction( f->icon(), f->prettyName(), ui->addSipButton );
|
|
||||||
// action->setProperty( "factory", QVariant::fromValue< QObject* >( f ) );
|
|
||||||
// ui->addSipButton->addAction( action );
|
|
||||||
//
|
|
||||||
// connect( action, SIGNAL( triggered(bool) ), this, SLOT( factoryActionTriggered( bool ) ) );
|
|
||||||
// }
|
|
||||||
|
|
||||||
connect( ui->removeServiceBtn, SIGNAL( clicked( bool ) ), this, SLOT( accountDeleted( bool ) ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsDialog::changePage( QListWidgetItem* current, QListWidgetItem* previous )
|
SettingsDialog::changePage( QListWidgetItem* current, QListWidgetItem* previous )
|
||||||
{
|
{
|
||||||
@@ -470,32 +431,6 @@ SettingsDialog::onLastFmFinished()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
void
|
|
||||||
SettingsDialog::addScriptResolver()
|
|
||||||
{
|
|
||||||
QString resolver = QFileDialog::getOpenFileName( this, tr( "Load script resolver file" ), TomahawkSettings::instance()->scriptDefaultPath() );
|
|
||||||
if( !resolver.isEmpty() )
|
|
||||||
{
|
|
||||||
|
|
||||||
QFileInfo resolverAbsoluteFilePath = resolver;
|
|
||||||
TomahawkSettings::instance()->setScriptDefaultPath( resolverAbsoluteFilePath.absolutePath() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SettingsDialog::removeScriptResolver()
|
|
||||||
{
|
|
||||||
// only one selection
|
|
||||||
if( !ui->scriptList->selectionModel()->selectedIndexes().isEmpty() )
|
|
||||||
{
|
|
||||||
QString resolver = ui->scriptList->selectionModel()->selectedIndexes().first().data( ResolversModel::ResolverPath ).toString();
|
|
||||||
AtticaManager::instance()->uninstallResolver( resolver );
|
|
||||||
m_resolversModel->removeResolver( resolver );
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsDialog::getMoreResolvers()
|
SettingsDialog::getMoreResolvers()
|
||||||
@@ -513,30 +448,30 @@ SettingsDialog::getMoreResolvers()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// void
|
void
|
||||||
// SettingsDialog::atticaResolverInstalled( const QString& resolverId )
|
SettingsDialog::accountInstalled(Account* account)
|
||||||
// {
|
{
|
||||||
// m_resolversModel->atticaResolverInstalled( resolverId );
|
// m_resolversModel->atticaResolverInstalled( resolverId );
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
//
|
|
||||||
// void
|
|
||||||
// SettingsDialog::atticaResolverUninstalled ( const QString& resolverId )
|
|
||||||
// {
|
|
||||||
// m_resolversModel->removeResolver( AtticaManager::instance()->pathFromId( resolverId ) );
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsDialog::scriptSelectionChanged()
|
SettingsDialog::accountUninstalled(const QString& acct)
|
||||||
{
|
{
|
||||||
if( !ui->scriptList->selectionModel()->selectedIndexes().isEmpty() )
|
// m_resolversModel->removeResolver( AtticaManager::instance()->pathFromId( resolverId ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SettingsDialog::accountsSelectionChanged()
|
||||||
|
{
|
||||||
|
if( !ui->accountsView->selectionModel()->selectedIndexes().isEmpty() )
|
||||||
{
|
{
|
||||||
ui->removeScript->setEnabled( true );
|
ui->removeServiceBtn->setEnabled( true );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui->removeScript->setEnabled( false );
|
ui->addNewServiceBtn->setEnabled( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -545,46 +480,7 @@ void
|
|||||||
SettingsDialog::getMoreResolversFinished( int ret )
|
SettingsDialog::getMoreResolversFinished( int ret )
|
||||||
{
|
{
|
||||||
Q_UNUSED( ret );
|
Q_UNUSED( ret );
|
||||||
}
|
sender()->deleteLater();
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SettingsDialog::openResolverConfig( const QString& resolver )
|
|
||||||
{
|
|
||||||
Tomahawk::ExternalResolver* r = Tomahawk::Pipeline::instance()->resolverForPath( resolver );
|
|
||||||
Tomahawk::ExternalResolverGui* res = qobject_cast< Tomahawk::ExternalResolverGui* >( r );
|
|
||||||
if( res && res->configUI() )
|
|
||||||
{
|
|
||||||
#ifndef Q_WS_MAC
|
|
||||||
DelegateConfigWrapper dialog( res->configUI(), "Resolver Configuration", this );
|
|
||||||
QWeakPointer< DelegateConfigWrapper > watcher( &dialog );
|
|
||||||
int ret = dialog.exec();
|
|
||||||
if( !watcher.isNull() && ret == QDialog::Accepted )
|
|
||||||
{
|
|
||||||
// send changed config to resolver
|
|
||||||
r->saveConfig();
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// on osx a sheet needs to be non-modal
|
|
||||||
DelegateConfigWrapper* dialog = new DelegateConfigWrapper( res->configUI(), "Resolver Configuration", this, Qt::Sheet );
|
|
||||||
dialog->setProperty( "resolver", QVariant::fromValue< QObject* >( res ) );
|
|
||||||
connect( dialog, SIGNAL( finished( int ) ), this, SLOT( resolverConfigClosed( int ) ) );
|
|
||||||
|
|
||||||
dialog->show();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SettingsDialog::resolverConfigClosed( int value )
|
|
||||||
{
|
|
||||||
if( value == QDialog::Accepted )
|
|
||||||
{
|
|
||||||
DelegateConfigWrapper* dialog = qobject_cast< DelegateConfigWrapper* >( sender() );
|
|
||||||
Tomahawk::ExternalResolver* r = qobject_cast< Tomahawk::ExternalResolver* >( dialog->property( "resolver" ).value< QObject* >() );
|
|
||||||
r->saveConfig();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -627,20 +523,7 @@ SettingsDialog::accountConfigClosed( int value )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsDialog::factoryActionTriggered( bool )
|
SettingsDialog::createAccountFromFactory( AccountFactory* factory )
|
||||||
{
|
|
||||||
Q_ASSERT( sender() && qobject_cast< QAction* >( sender() ) );
|
|
||||||
|
|
||||||
QAction* a = qobject_cast< QAction* >( sender() );
|
|
||||||
Q_ASSERT( qobject_cast< AccountFactory* >( a->property( "factory" ).value< QObject* >() ) );
|
|
||||||
|
|
||||||
AccountFactory* f = qobject_cast< AccountFactory* >( a->property( "factory" ).value< QObject* >() );
|
|
||||||
accountFactoryClicked( f );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SettingsDialog::accountFactoryClicked( AccountFactory* factory )
|
|
||||||
{
|
{
|
||||||
//if exited with OK, create it, if not, delete it immediately!
|
//if exited with OK, create it, if not, delete it immediately!
|
||||||
Account* account = factory->createAccount();
|
Account* account = factory->createAccount();
|
||||||
@@ -708,22 +591,6 @@ SettingsDialog::handleAccountAdded( Account* account, bool added )
|
|||||||
TomahawkSettings::instance()->addAccount( account->accountId() );
|
TomahawkSettings::instance()->addAccount( account->accountId() );
|
||||||
AccountManager::instance()->addAccount( account );
|
AccountManager::instance()->addAccount( account );
|
||||||
AccountManager::instance()->hookupAndEnable( account );
|
AccountManager::instance()->hookupAndEnable( account );
|
||||||
|
|
||||||
// if ( f && f->isUnique() )
|
|
||||||
// {
|
|
||||||
// // remove from actions list
|
|
||||||
// QAction* toremove = 0;
|
|
||||||
// foreach( QAction* a, ui->addSipButton->actions() )
|
|
||||||
// {
|
|
||||||
// if( f == qobject_cast< AccountFactory* >( a->property( "factory" ).value< QObject* >() ) )
|
|
||||||
// {
|
|
||||||
// toremove = a;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if ( toremove )
|
|
||||||
// ui->addSipButton->removeAction( toremove );
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -741,7 +608,7 @@ SettingsDialog::accountContextMenuRequest( const QPoint& p )
|
|||||||
if( idx.isValid() )
|
if( idx.isValid() )
|
||||||
{
|
{
|
||||||
QList< QAction* > acts;
|
QList< QAction* > acts;
|
||||||
acts << new QAction( tr( "Delete Account" ), this );
|
acts << new QAction( tr( "Delete Service" ), this );
|
||||||
acts.first()->setProperty( "accountplugin", idx.data( AccountModel::AccountData ) );
|
acts.first()->setProperty( "accountplugin", idx.data( AccountModel::AccountData ) );
|
||||||
connect( acts.first(), SIGNAL( triggered( bool ) ), this, SLOT( onAccountRowDeleted( bool ) ) );
|
connect( acts.first(), SIGNAL( triggered( bool ) ), this, SLOT( onAccountRowDeleted( bool ) ) );
|
||||||
QMenu::exec( acts, ui->accountsView->mapToGlobal( p ) );
|
QMenu::exec( acts, ui->accountsView->mapToGlobal( p ) );
|
||||||
@@ -754,18 +621,6 @@ SettingsDialog::onAccountRowDeleted( bool )
|
|||||||
{
|
{
|
||||||
Account* account = qobject_cast< Account* >( qobject_cast< QAction* >( sender() )->property( "accountplugin" ).value< QObject* >() );
|
Account* account = qobject_cast< Account* >( qobject_cast< QAction* >( sender() )->property( "accountplugin" ).value< QObject* >() );
|
||||||
|
|
||||||
if( AccountFactory* f = AccountManager::instance()->factoryForAccount( account ) )
|
|
||||||
{
|
|
||||||
// if( f->isUnique() ) // just deleted a unique plugin->re-add to add menu
|
|
||||||
// {
|
|
||||||
// QAction* action = new QAction( f->icon(), f->prettyName(), ui->addSipButton );
|
|
||||||
// action->setProperty( "factory", QVariant::fromValue< QObject* >( f ) );
|
|
||||||
// ui->addSipButton->addAction( action );
|
|
||||||
//
|
|
||||||
// connect( action, SIGNAL( triggered(bool) ), this, SLOT( factoryActionTriggered( bool ) ) );
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
AccountManager::instance()->removeAccount( account );
|
AccountManager::instance()->removeAccount( account );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -780,18 +635,6 @@ SettingsDialog::accountDeleted( bool )
|
|||||||
if( idx.isValid() )
|
if( idx.isValid() )
|
||||||
{
|
{
|
||||||
Account* account = qobject_cast< Account* >( idx.data( AccountModel::AccountData ).value< QObject* >() );
|
Account* account = qobject_cast< Account* >( idx.data( AccountModel::AccountData ).value< QObject* >() );
|
||||||
|
|
||||||
if( AccountFactory* f = AccountManager::instance()->factoryForAccount( account ) )
|
|
||||||
{
|
|
||||||
// if( f->isUnique() ) // just deleted a unique plugin->re-add to add menu
|
|
||||||
// {
|
|
||||||
// QAction* action = new QAction( f->icon(), f->prettyName(), ui->addSipButton );
|
|
||||||
// action->setProperty( "factory", QVariant::fromValue< QObject* >( f ) );
|
|
||||||
// ui->addSipButton->addAction( action );
|
|
||||||
//
|
|
||||||
// connect( action, SIGNAL( triggered(bool) ), this, SLOT( factoryActionTriggered( bool ) ) );
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
AccountManager::instance()->removeAccount( account );
|
AccountManager::instance()->removeAccount( account );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -45,6 +45,7 @@ namespace Tomahawk
|
|||||||
class AccountModel;
|
class AccountModel;
|
||||||
class Account;
|
class Account;
|
||||||
class AccountFactory;
|
class AccountFactory;
|
||||||
|
class Account;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,21 +88,18 @@ private slots:
|
|||||||
void testLastFmLogin();
|
void testLastFmLogin();
|
||||||
void onLastFmFinished();
|
void onLastFmFinished();
|
||||||
|
|
||||||
void scriptSelectionChanged();
|
|
||||||
void getMoreResolvers();
|
|
||||||
void getMoreResolversFinished( int );
|
|
||||||
|
|
||||||
void openResolverConfig( const QString& );
|
|
||||||
|
|
||||||
void openAccountConfig( Tomahawk::Accounts::Account* );
|
void openAccountConfig( Tomahawk::Accounts::Account* );
|
||||||
void factoryActionTriggered ( bool );
|
void createAccountFromFactory( Tomahawk::Accounts::AccountFactory* );
|
||||||
void accountFactoryClicked( Tomahawk::Accounts::AccountFactory* );
|
|
||||||
void accountContextMenuRequest( const QPoint& );
|
void accountContextMenuRequest( const QPoint& );
|
||||||
void accountDeleted( bool );
|
void accountDeleted( bool );
|
||||||
void onAccountRowDeleted( bool );
|
void onAccountRowDeleted( bool );
|
||||||
|
|
||||||
// dialog slots
|
void accountsSelectionChanged();
|
||||||
void resolverConfigClosed( int value );
|
void getMoreResolvers();
|
||||||
|
void getMoreResolversFinished( int );
|
||||||
|
|
||||||
|
void accountInstalled( Tomahawk::Accounts::Account* account );
|
||||||
|
void accountUninstalled( const QString& acct );
|
||||||
|
|
||||||
void accountConfigClosed( int value );
|
void accountConfigClosed( int value );
|
||||||
void accountCreateConfigClosed( int value );
|
void accountCreateConfigClosed( int value );
|
||||||
@@ -115,7 +113,6 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void createIcons();
|
void createIcons();
|
||||||
void setupAccountButtons();
|
|
||||||
void handleAccountAdded( Tomahawk::Accounts::Account* p, bool added );
|
void handleAccountAdded( Tomahawk::Accounts::Account* p, bool added );
|
||||||
|
|
||||||
Ui_StackedSettingsDialog* ui;
|
Ui_StackedSettingsDialog* ui;
|
||||||
|
@@ -365,107 +365,6 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="resolversPage">
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
|
||||||
<property name="margin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="groupBox_3">
|
|
||||||
<property name="title">
|
|
||||||
<string>Script Resolvers</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
|
||||||
<property name="margin">
|
|
||||||
<number>2</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>Script resolvers search for a given track to make it playable.</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="getMoreResolvers">
|
|
||||||
<property name="text">
|
|
||||||
<string>Get more resolvers...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
|
||||||
<item>
|
|
||||||
<widget class="QTreeView" name="scriptList">
|
|
||||||
<property name="alternatingRowColors">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="selectionMode">
|
|
||||||
<enum>QAbstractItemView::SingleSelection</enum>
|
|
||||||
</property>
|
|
||||||
<property name="rootIsDecorated">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="uniformRowHeights">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="itemsExpandable">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="animated">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="headerHidden">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="addScript">
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="../resources.qrc">
|
|
||||||
<normaloff>:/data/images/list-add.png</normaloff>:/data/images/list-add.png</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="removeScript">
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="../resources.qrc">
|
|
||||||
<normaloff>:/data/images/list-remove.png</normaloff>:/data/images/list-remove.png</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer_4">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<widget class="QWidget" name="advancedPage">
|
<widget class="QWidget" name="advancedPage">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<property name="margin">
|
<property name="margin">
|
||||||
|
Reference in New Issue
Block a user