mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 00:24:12 +02:00
fix menus for jreen and jabber plugins. now added when connected, removed when disconnected.
and no crashy.
This commit is contained in:
@@ -38,6 +38,9 @@ signals:
|
|||||||
void peerOnline( const QString& );
|
void peerOnline( const QString& );
|
||||||
void peerOffline( const QString& );
|
void peerOffline( const QString& );
|
||||||
void msgReceived( const QString& from, const QString& msg );
|
void msgReceived( const QString& from, const QString& msg );
|
||||||
|
|
||||||
|
void addMenu( QMenu* menu );
|
||||||
|
void removeMenu( QMenu* menu );
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_INTERFACE( SipPlugin, "tomahawk.Sip/1.0" )
|
Q_DECLARE_INTERFACE( SipPlugin, "tomahawk.Sip/1.0" )
|
||||||
|
@@ -286,6 +286,6 @@ SipHandler::onError( int code, const QString& msg )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
SipPlugin* sip = qobject_cast<SipPlugin*>(sender());
|
SipPlugin* sip = qobject_cast<SipPlugin*>(sender());
|
||||||
QTimer::singleShot( 10000, sip, SLOT( connect() ) );
|
QTimer::singleShot( 10000, sip, SLOT( connectPlugin() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,15 +9,9 @@
|
|||||||
|
|
||||||
JabberPlugin::JabberPlugin()
|
JabberPlugin::JabberPlugin()
|
||||||
: p( 0 ),
|
: p( 0 ),
|
||||||
m_menu ( 0 )
|
m_menu ( 0 ),
|
||||||
|
m_addFriendAction( 0 )
|
||||||
{
|
{
|
||||||
if( !accountName().isEmpty() )
|
|
||||||
m_menu = new QMenu(QString("Jabber (").append(accountName()).append(")"));
|
|
||||||
|
|
||||||
m_addFriendAction = m_menu->addAction("Add Friend...");
|
|
||||||
|
|
||||||
connect(m_addFriendAction, SIGNAL(triggered()),
|
|
||||||
this, SLOT(showAddFriendDialog()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -86,8 +80,8 @@ JabberPlugin::connectPlugin( bool startup )
|
|||||||
QObject::connect( p, SIGNAL( peerOffline( QString ) ), SIGNAL( peerOffline( QString ) ) );
|
QObject::connect( p, SIGNAL( peerOffline( QString ) ), SIGNAL( peerOffline( QString ) ) );
|
||||||
QObject::connect( p, SIGNAL( msgReceived( QString, QString ) ), SIGNAL( msgReceived( QString, QString ) ) );
|
QObject::connect( p, SIGNAL( msgReceived( QString, QString ) ), SIGNAL( msgReceived( QString, QString ) ) );
|
||||||
|
|
||||||
QObject::connect( p, SIGNAL( connected() ), SIGNAL( connected() ) );
|
QObject::connect( p, SIGNAL( connected() ), SLOT( onConnected() ) );
|
||||||
QObject::connect( p, SIGNAL( disconnected() ), SIGNAL( disconnected() ) );
|
QObject::connect( p, SIGNAL( disconnected() ), SIGNAL( onDisconnected() ) );
|
||||||
QObject::connect( p, SIGNAL( authError( int, QString ) ), SLOT( onAuthError( int, QString ) ) );
|
QObject::connect( p, SIGNAL( authError( int, QString ) ), SLOT( onAuthError( int, QString ) ) );
|
||||||
|
|
||||||
p->resolveHostSRV();
|
p->resolveHostSRV();
|
||||||
@@ -95,6 +89,38 @@ JabberPlugin::connectPlugin( bool startup )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
JabberPlugin::onConnected()
|
||||||
|
{
|
||||||
|
if( !m_menu ) {
|
||||||
|
m_menu = new QMenu( QString( "Jabber (").append( accountName() ).append( ")" ) );
|
||||||
|
|
||||||
|
m_addFriendAction = m_menu->addAction( "Add Friend..." );
|
||||||
|
|
||||||
|
connect( m_addFriendAction, SIGNAL( triggered() ),
|
||||||
|
this, SLOT( showAddFriendDialog() ) ) ;
|
||||||
|
|
||||||
|
emit addMenu( m_menu );
|
||||||
|
}
|
||||||
|
|
||||||
|
emit connected();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
JabberPlugin::onDisconnected()
|
||||||
|
{
|
||||||
|
if( m_menu && m_addFriendAction ) {
|
||||||
|
emit removeMenu( m_menu );
|
||||||
|
|
||||||
|
delete m_menu;
|
||||||
|
m_menu = 0;
|
||||||
|
m_addFriendAction = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit disconnected();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
JabberPlugin::onAuthError( int code, const QString& message )
|
JabberPlugin::onAuthError( int code, const QString& message )
|
||||||
|
@@ -32,6 +32,8 @@ public slots:
|
|||||||
|
|
||||||
void disconnectPlugin()
|
void disconnectPlugin()
|
||||||
{
|
{
|
||||||
|
onDisconnected();
|
||||||
|
|
||||||
if ( p )
|
if ( p )
|
||||||
p->disconnect();
|
p->disconnect();
|
||||||
|
|
||||||
@@ -60,7 +62,9 @@ public slots:
|
|||||||
private slots:
|
private slots:
|
||||||
void onAuthError( int, const QString& );
|
void onAuthError( int, const QString& );
|
||||||
void showAddFriendDialog();
|
void showAddFriendDialog();
|
||||||
|
void onConnected();
|
||||||
|
void onDisconnected();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Jabber_p* p;
|
Jabber_p* p;
|
||||||
QMenu* m_menu;
|
QMenu* m_menu;
|
||||||
|
@@ -10,14 +10,9 @@
|
|||||||
|
|
||||||
JabberPlugin::JabberPlugin()
|
JabberPlugin::JabberPlugin()
|
||||||
: p( 0 )
|
: p( 0 )
|
||||||
|
, m_menu( 0 )
|
||||||
|
, m_addFriendAction( 0 )
|
||||||
{
|
{
|
||||||
m_menu = new QMenu(QString("JREEN (").append(accountName()).append(")"));
|
|
||||||
m_addFriendAction = m_menu->addAction("Add Friend...");
|
|
||||||
QAction *connectAction = m_menu->addAction("Connect");
|
|
||||||
|
|
||||||
connect(m_addFriendAction, SIGNAL(triggered()),
|
|
||||||
this, SLOT(showAddFriendDialog()));
|
|
||||||
connect(connectAction, SIGNAL(triggered()), SLOT(connectPlugin()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JabberPlugin::~JabberPlugin()
|
JabberPlugin::~JabberPlugin()
|
||||||
@@ -92,8 +87,8 @@ JabberPlugin::connectPlugin( bool startup )
|
|||||||
QObject::connect( p, SIGNAL( peerOffline( QString ) ), SIGNAL( peerOffline( QString ) ) );
|
QObject::connect( p, SIGNAL( peerOffline( QString ) ), SIGNAL( peerOffline( QString ) ) );
|
||||||
QObject::connect( p, SIGNAL( msgReceived( QString, QString ) ), SIGNAL( msgReceived( QString, QString ) ) );
|
QObject::connect( p, SIGNAL( msgReceived( QString, QString ) ), SIGNAL( msgReceived( QString, QString ) ) );
|
||||||
|
|
||||||
QObject::connect( p, SIGNAL( connected() ), SIGNAL( connected() ) );
|
QObject::connect( p, SIGNAL( connected() ), SIGNAL( onConnected() ) );
|
||||||
QObject::connect( p, SIGNAL( disconnected() ), SIGNAL( disconnected() ) );
|
QObject::connect( p, SIGNAL( disconnected() ), SIGNAL( onDisconnected() ) );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -101,6 +96,8 @@ JabberPlugin::connectPlugin( bool startup )
|
|||||||
void
|
void
|
||||||
JabberPlugin::disconnectPlugin()
|
JabberPlugin::disconnectPlugin()
|
||||||
{
|
{
|
||||||
|
onDisconnected();
|
||||||
|
|
||||||
if ( p )
|
if ( p )
|
||||||
p->disconnect();
|
p->disconnect();
|
||||||
|
|
||||||
@@ -108,6 +105,38 @@ JabberPlugin::disconnectPlugin()
|
|||||||
p = 0;
|
p = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
JabberPlugin::onConnected()
|
||||||
|
{
|
||||||
|
if( !m_menu ) {
|
||||||
|
m_menu = new QMenu( QString( "JREEN (" ).append( accountName() ).append(")" ) );
|
||||||
|
m_addFriendAction = m_menu->addAction( "Add Friend..." );
|
||||||
|
QAction *connectAction = m_menu->addAction( "Connect" );
|
||||||
|
|
||||||
|
connect( m_addFriendAction, SIGNAL(triggered() ),
|
||||||
|
this, SLOT( showAddFriendDialog() ) );
|
||||||
|
connect( connectAction, SIGNAL( triggered() ), SLOT( connectPlugin() ) );
|
||||||
|
|
||||||
|
emit addMenu( m_menu );
|
||||||
|
}
|
||||||
|
|
||||||
|
emit connected();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
JabberPlugin::onDisconnected()
|
||||||
|
{
|
||||||
|
if( m_menu && m_addFriendAction ) {
|
||||||
|
emit removeMenu( m_menu );
|
||||||
|
|
||||||
|
delete m_menu;
|
||||||
|
m_menu = 0;
|
||||||
|
m_addFriendAction = 0; // deleted by menu
|
||||||
|
}
|
||||||
|
|
||||||
|
emit disconnected();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
JabberPlugin::sendMsg(const QString& to, const QString& msg)
|
JabberPlugin::sendMsg(const QString& to, const QString& msg)
|
||||||
{
|
{
|
||||||
|
@@ -35,6 +35,8 @@ public slots:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void showAddFriendDialog();
|
void showAddFriendDialog();
|
||||||
|
void onConnected();
|
||||||
|
void onDisconnected();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Jabber_p* p;
|
Jabber_p* p;
|
||||||
|
@@ -157,10 +157,8 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
|
|||||||
// propagate sip menu
|
// propagate sip menu
|
||||||
foreach( SipPlugin *plugin, APP->sipHandler()->plugins() )
|
foreach( SipPlugin *plugin, APP->sipHandler()->plugins() )
|
||||||
{
|
{
|
||||||
if ( plugin->menu() )
|
connect( plugin, SIGNAL( addMenu( QMenu* ) ), this, SLOT( pluginMenuAdded( QMenu* ) ) );
|
||||||
{
|
connect( plugin, SIGNAL( removeMenu( QMenu* ) ), this, SLOT( pluginMenuRemoved( QMenu* ) ) );
|
||||||
ui->menuNetwork->addMenu( plugin->menu() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
@@ -337,6 +335,25 @@ TomahawkWindow::addPeerManually()
|
|||||||
Servent::instance()->connectToPeer( addr, port, key );
|
Servent::instance()->connectToPeer( addr, port, key );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TomahawkWindow::pluginMenuAdded( QMenu* menu )
|
||||||
|
{
|
||||||
|
ui->menuNetwork->addMenu( menu );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TomahawkWindow::pluginMenuRemoved( QMenu* menu )
|
||||||
|
{
|
||||||
|
foreach( QAction* action, ui->menuNetwork->actions() )
|
||||||
|
{
|
||||||
|
if( action->menu() == menu )
|
||||||
|
{
|
||||||
|
ui->menuNetwork->removeAction( action );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkWindow::loadSpiff()
|
TomahawkWindow::loadSpiff()
|
||||||
|
@@ -45,6 +45,8 @@ public slots:
|
|||||||
void loadSpiff();
|
void loadSpiff();
|
||||||
void showSettingsDialog();
|
void showSettingsDialog();
|
||||||
void updateCollectionManually();
|
void updateCollectionManually();
|
||||||
|
void pluginMenuAdded(QMenu*);
|
||||||
|
void pluginMenuRemoved(QMenu*);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onSipConnected();
|
void onSipConnected();
|
||||||
|
Reference in New Issue
Block a user