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

Add contact support.

This commit is contained in:
Teo Mrnjavac
2012-08-14 12:17:36 +02:00
parent cf742f61ca
commit f313ba473e
2 changed files with 43 additions and 1 deletions

View File

@@ -22,6 +22,7 @@
#include "SlideSwitchButton.h" #include "SlideSwitchButton.h"
#include "accounts/Account.h" #include "accounts/Account.h"
#include "accounts/AccountModel.h" #include "accounts/AccountModel.h"
#include "sip/SipPlugin.h"
#include "utils/TomahawkUtilsGui.h" #include "utils/TomahawkUtilsGui.h"
#include "utils/AnimatedSpinner.h" #include "utils/AnimatedSpinner.h"
#include "widgets/ElidedLabel.h" #include "widgets/ElidedLabel.h"
@@ -33,6 +34,7 @@
#include <QMenu> #include <QMenu>
#include <QPixmap> #include <QPixmap>
#include <QPushButton> #include <QPushButton>
#include <QTimer>
#include <QToolButton> #include <QToolButton>
AccountWidget::AccountWidget( QWidget* parent ) AccountWidget::AccountWidget( QWidget* parent )
@@ -124,6 +126,8 @@ AccountWidget::AccountWidget( QWidget* parent )
m_inviteButton->setFixedWidth( m_inviteButton->logicalDpiX() * 0.8 ); m_inviteButton->setFixedWidth( m_inviteButton->logicalDpiX() * 0.8 );
m_inviteButton->setText( tr( "Invite" ) ); m_inviteButton->setText( tr( "Invite" ) );
vLayout->addWidget( m_inviteButton, 1, 1 ); vLayout->addWidget( m_inviteButton, 1, 1 );
setInviteWidgetsEnabled( false );
} }
AccountWidget::~AccountWidget() AccountWidget::~AccountWidget()
@@ -169,21 +173,25 @@ AccountWidget::update( const QPersistentModelIndex& idx, int accountIdx )
m_spinner->fadeOut(); m_spinner->fadeOut();
m_statusToggle->setChecked( false ); m_statusToggle->setChecked( false );
m_statusToggle->setBackChecked( false ); m_statusToggle->setBackChecked( false );
setInviteWidgetsEnabled( false );
break; break;
case Tomahawk::Accounts::Account::Connecting: case Tomahawk::Accounts::Account::Connecting:
m_spinner->fadeIn(); m_spinner->fadeIn();
m_statusToggle->setChecked( true ); m_statusToggle->setChecked( true );
m_statusToggle->setBackChecked( false ); m_statusToggle->setBackChecked( false );
setInviteWidgetsEnabled( false );
break; break;
case Tomahawk::Accounts::Account::Connected: case Tomahawk::Accounts::Account::Connected:
m_spinner->fadeOut(); m_spinner->fadeOut();
m_statusToggle->setChecked( true ); m_statusToggle->setChecked( true );
m_statusToggle->setBackChecked( true ); m_statusToggle->setBackChecked( true );
setInviteWidgetsEnabled( true );
break; break;
case Tomahawk::Accounts::Account::Disconnecting: case Tomahawk::Accounts::Account::Disconnecting:
m_spinner->fadeIn(); m_spinner->fadeIn();
m_statusToggle->setChecked( false ); m_statusToggle->setChecked( false );
m_statusToggle->setBackChecked( true ); m_statusToggle->setBackChecked( true );
setInviteWidgetsEnabled( false );
} }
} }
} }
@@ -207,6 +215,36 @@ AccountWidget::changeAccountConnectionState( bool connected )
} }
} }
void
AccountWidget::sendInvite()
{
Tomahawk::Accounts::Account* account =
m_myFactoryIdx.data( Tomahawk::Accounts::AccountModel::ChildrenOfFactoryRole )
.value< QList< Tomahawk::Accounts::Account* > >().at( m_myAccountIdx );
if ( account )
{
if ( !m_inviteEdit->text().isEmpty() )
account->sipPlugin()->addContact( m_inviteEdit->text() );
m_inviteButton->setEnabled( false );
m_inviteEdit->setEnabled( false );
QTimer::singleShot( 500, this, SLOT( clearInviteWidgets() ) );
}
}
void
AccountWidget::clearInviteWidgets()
{
setInviteWidgetsEnabled( m_statusToggle->backChecked() );
m_inviteEdit->clear();
}
void
AccountWidget::setInviteWidgetsEnabled( bool enabled )
{
m_inviteButton->setEnabled( enabled );
m_inviteEdit->setEnabled( enabled );
}
void void
AccountWidget::setupConnections( const QPersistentModelIndex& idx, int accountIdx ) AccountWidget::setupConnections( const QPersistentModelIndex& idx, int accountIdx )
{ {
@@ -220,6 +258,7 @@ AccountWidget::setupConnections( const QPersistentModelIndex& idx, int accountId
{ {
connect( m_statusToggle, SIGNAL( toggled( bool ) ), connect( m_statusToggle, SIGNAL( toggled( bool ) ),
this, SLOT( changeAccountConnectionState( bool ) ) ); this, SLOT( changeAccountConnectionState( bool ) ) );
//TODO: invite/tweet connect( m_inviteButton, SIGNAL( clicked() ),
this, SLOT( sendInvite() ) );
} }
} }

View File

@@ -44,6 +44,9 @@ public:
private slots: private slots:
void changeAccountConnectionState( bool connected ); void changeAccountConnectionState( bool connected );
void sendInvite();
void clearInviteWidgets();
void setInviteWidgetsEnabled( bool enabled );
private: private:
QLabel* m_imageLabel; QLabel* m_imageLabel;