mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 11:50:37 +02:00
* Cleanup DiagnosticsDialog. Remove update button and fix copying to clipboard.
This commit is contained in:
@@ -44,7 +44,6 @@ DiagnosticsDialog::DiagnosticsDialog( QWidget *parent )
|
|||||||
{
|
{
|
||||||
ui->setupUi( this );
|
ui->setupUi( this );
|
||||||
|
|
||||||
//connect( ui->updateButton, SIGNAL( clicked() ), this, SLOT( updateLogView() ) );
|
|
||||||
connect( ui->clipboardButton, SIGNAL( clicked() ), this, SLOT( copyToClipboard() ) );
|
connect( ui->clipboardButton, SIGNAL( clicked() ), this, SLOT( copyToClipboard() ) );
|
||||||
connect( ui->buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
|
connect( ui->buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
|
||||||
|
|
||||||
@@ -53,7 +52,9 @@ DiagnosticsDialog::DiagnosticsDialog( QWidget *parent )
|
|||||||
updateLogView();
|
updateLogView();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagnosticsDialog::updateLogView()
|
|
||||||
|
void
|
||||||
|
DiagnosticsDialog::updateLogView()
|
||||||
{
|
{
|
||||||
QString log;
|
QString log;
|
||||||
|
|
||||||
@@ -63,16 +64,11 @@ void DiagnosticsDialog::updateLogView()
|
|||||||
);
|
);
|
||||||
|
|
||||||
// network
|
// network
|
||||||
log.append(
|
log.append( "TOMAHAWK-VERSION: " TOMAHAWK_VERSION "\n\n" );
|
||||||
"TOMAHAWK-VERSION: " TOMAHAWK_VERSION "\n\n"
|
|
||||||
);
|
|
||||||
|
|
||||||
// network
|
// network
|
||||||
log.append(
|
log.append( "NETWORK:\n General:\n" );
|
||||||
"NETWORK:\n"
|
if ( Servent::instance()->visibleExternally() )
|
||||||
" General:\n"
|
|
||||||
);
|
|
||||||
if( Servent::instance()->visibleExternally() )
|
|
||||||
{
|
{
|
||||||
log.append(
|
log.append(
|
||||||
QString(
|
QString(
|
||||||
@@ -87,21 +83,13 @@ void DiagnosticsDialog::updateLogView()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log.append(
|
log.append( " visible: false" );
|
||||||
QString(
|
|
||||||
" visible: false"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
//log.append("\n\n");
|
|
||||||
|
|
||||||
ui->scrollAreaWidgetContents->layout()->addWidget( new QLabel( log, this ) );
|
ui->scrollAreaWidgetContents->layout()->addWidget( new QLabel( log, this ) );
|
||||||
|
|
||||||
// Peers / Accounts, TODO
|
// Peers / Accounts, TODO
|
||||||
ui->scrollAreaWidgetContents->layout()->addWidget( new QLabel( "ACCOUNTS:\n", this ) );
|
ui->scrollAreaWidgetContents->layout()->addWidget( new QLabel( "ACCOUNTS:\n", this ) );
|
||||||
|
|
||||||
QString accountInfo;
|
|
||||||
|
|
||||||
const QList< Tomahawk::source_ptr > sources = SourceList::instance()->sources( true );
|
const QList< Tomahawk::source_ptr > sources = SourceList::instance()->sources( true );
|
||||||
const QList< Tomahawk::Accounts::Account* > accounts = Tomahawk::Accounts::AccountManager::instance()->accounts( Tomahawk::Accounts::SipType );
|
const QList< Tomahawk::Accounts::Account* > accounts = Tomahawk::Accounts::AccountManager::instance()->accounts( Tomahawk::Accounts::SipType );
|
||||||
foreach ( Tomahawk::Accounts::Account* account, accounts )
|
foreach ( Tomahawk::Accounts::Account* account, accounts )
|
||||||
@@ -110,98 +98,40 @@ void DiagnosticsDialog::updateLogView()
|
|||||||
if ( !account || !account->sipPlugin() )
|
if ( !account || !account->sipPlugin() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
connect( account, SIGNAL(connectionStateChanged(Tomahawk::Accounts::Account::ConnectionState)), SLOT(onAccountConnectionStateChanged(Tomahawk::Accounts::Account::ConnectionState)) );
|
connect( account, SIGNAL( connectionStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ),
|
||||||
connect( account, SIGNAL(error(int,QString)), SLOT(onAccountError(int,QString)) );
|
SLOT( onAccountConnectionStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ) );
|
||||||
connect( account->sipPlugin(), SIGNAL(peerOnline(QString)), SLOT(onPeerOnline(QString)) );
|
connect( account, SIGNAL( error( int, QString ) ),
|
||||||
connect( account->sipPlugin(), SIGNAL(peerOffline(QString)), SLOT(onPeerOffline(QString)) );
|
SLOT( onAccountError( int, QString ) ) );
|
||||||
connect( account->sipPlugin(), SIGNAL(sipInfoReceived(QString,SipInfo)), SLOT(onSipInfoReceived(QString,SipInfo)) );
|
|
||||||
connect( account->sipPlugin(), SIGNAL(softwareVersionReceived(QString,QString)), SLOT(onSoftwareVersionReceived(QString,QString)) );
|
|
||||||
|
|
||||||
QString stateString;
|
connect( account->sipPlugin(), SIGNAL( peerOnline( QString ) ), SLOT( onPeerOnline( QString ) ) );
|
||||||
switch( account->connectionState() )
|
connect( account->sipPlugin(), SIGNAL( peerOffline( QString ) ), SLOT( onPeerOffline( QString ) ) );
|
||||||
{
|
connect( account->sipPlugin(), SIGNAL( sipInfoReceived( QString, SipInfo ) ), SLOT( onSipInfoReceived( QString, SipInfo ) ) );
|
||||||
case Tomahawk::Accounts::Account::Connecting:
|
connect( account->sipPlugin(), SIGNAL( softwareVersionReceived( QString, QString ) ), SLOT( onSoftwareVersionReceived( QString, QString ) ) );
|
||||||
stateString = "Connecting";
|
|
||||||
break;
|
|
||||||
case Tomahawk::Accounts::Account::Connected:
|
|
||||||
stateString = "Connected";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Tomahawk::Accounts::Account::Disconnected:
|
|
||||||
stateString = "Disconnected";
|
|
||||||
break;
|
|
||||||
case Tomahawk::Accounts::Account::Disconnecting:
|
|
||||||
stateString = "Disconnecting";
|
|
||||||
}
|
|
||||||
accountInfo.append(
|
|
||||||
QString( " %2 (%1): %3 (%4)\n" )
|
|
||||||
.arg( account->accountServiceName() )
|
|
||||||
.arg( account->sipPlugin()->friendlyName() )
|
|
||||||
.arg( account->accountFriendlyName())
|
|
||||||
.arg( stateString )
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach( const QString &peerId, account->sipPlugin()->peersOnline() )
|
|
||||||
{
|
|
||||||
/* enable this again, when we check the Source.has this peerId
|
|
||||||
bool connected = false;
|
|
||||||
Q_FOREACH( const Tomahawk::source_ptr &source, sources )
|
|
||||||
{
|
|
||||||
if( source->controlConnection() )
|
|
||||||
{
|
|
||||||
connected = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
QString versionString = SipHandler::instance()->versionString( peerId );
|
|
||||||
SipInfo sipInfo = SipHandler::instance()->sipInfo( peerId );
|
|
||||||
if( !sipInfo.isValid() )
|
|
||||||
accountInfo.append(
|
|
||||||
QString(" %1: %2 %3" /*"(%4)"*/ "\n")
|
|
||||||
.arg( peerId )
|
|
||||||
.arg( "sipinfo invalid" )
|
|
||||||
.arg( versionString )
|
|
||||||
// .arg( connected ? "connected" : "not connected")
|
|
||||||
);
|
|
||||||
else if( sipInfo.isVisible() )
|
|
||||||
accountInfo.append(
|
|
||||||
QString(" %1: %2:%3 %4" /*" (%5)"*/ "\n")
|
|
||||||
.arg( peerId )
|
|
||||||
.arg( sipInfo.host().hostName() )
|
|
||||||
.arg( sipInfo.port() )
|
|
||||||
.arg( versionString )
|
|
||||||
// .arg( connected ? "connected" : "not connected")
|
|
||||||
|
|
||||||
);
|
|
||||||
else
|
|
||||||
accountInfo.append(
|
|
||||||
QString(" %1: visible: false %2" /*" (%3)"*/ "\n")
|
|
||||||
.arg( peerId )
|
|
||||||
.arg( versionString )
|
|
||||||
// .arg( connected ? "connected" : "not connected")
|
|
||||||
|
|
||||||
);
|
|
||||||
}
|
|
||||||
accountInfo.append("\n");
|
|
||||||
|
|
||||||
QLabel *accountInfoLabel = new QLabel( accountInfo, this );
|
|
||||||
|
|
||||||
|
QLabel* accountInfoLabel = new QLabel( this );
|
||||||
ui->scrollAreaWidgetContents->layout()->addWidget( accountInfoLabel );
|
ui->scrollAreaWidgetContents->layout()->addWidget( accountInfoLabel );
|
||||||
|
|
||||||
m_accountDescriptionStore.insert( account, accountInfoLabel );
|
m_accountDescriptionStore.insert( account, accountInfoLabel );
|
||||||
|
|
||||||
accountInfo.clear();
|
updateAccountLabel( account );
|
||||||
}
|
}
|
||||||
//ui->logView->setPlainText(log);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagnosticsDialog::copyToClipboard()
|
|
||||||
|
void
|
||||||
|
DiagnosticsDialog::copyToClipboard()
|
||||||
{
|
{
|
||||||
//QApplication::clipboard()->setText( ui->logView->toPlainText() );
|
QString log;
|
||||||
|
foreach ( QLabel* label, m_accountDescriptionStore.values() )
|
||||||
|
{
|
||||||
|
log += label->text() + "\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
QApplication::clipboard()->setText( log );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagnosticsDialog::onAccountConnectionStateChanged(Tomahawk::Accounts::Account::ConnectionState state)
|
|
||||||
|
void
|
||||||
|
DiagnosticsDialog::onAccountConnectionStateChanged( Tomahawk::Accounts::Account::ConnectionState /* state */ )
|
||||||
{
|
{
|
||||||
Tomahawk::Accounts::Account* account = qobject_cast< Tomahawk::Accounts::Account* >( sender() );
|
Tomahawk::Accounts::Account* account = qobject_cast< Tomahawk::Accounts::Account* >( sender() );
|
||||||
Q_ASSERT( account );
|
Q_ASSERT( account );
|
||||||
@@ -209,49 +139,61 @@ void DiagnosticsDialog::onAccountConnectionStateChanged(Tomahawk::Accounts::Acco
|
|||||||
updateAccountLabel( account );
|
updateAccountLabel( account );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagnosticsDialog::onAccountError(int errorId, QString errorString)
|
|
||||||
|
void
|
||||||
|
DiagnosticsDialog::onAccountError( int /* errorId */ , QString /* errorString */ )
|
||||||
{
|
{
|
||||||
Tomahawk::Accounts::Account* account = qobject_cast< Tomahawk::Accounts::Account* >( sender() );
|
Tomahawk::Accounts::Account* account = qobject_cast< Tomahawk::Accounts::Account* >( sender() );
|
||||||
Q_ASSERT( account );
|
Q_ASSERT( account );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagnosticsDialog::onPeerOnline(const QString& )
|
|
||||||
|
void
|
||||||
|
DiagnosticsDialog::onPeerOnline( const QString& )
|
||||||
{
|
{
|
||||||
Tomahawk::Accounts::Account* account = qobject_cast< SipPlugin* >( sender() )->account();
|
Tomahawk::Accounts::Account* account = qobject_cast< SipPlugin* >( sender() )->account();
|
||||||
Q_ASSERT(account);
|
Q_ASSERT( account );
|
||||||
|
|
||||||
updateAccountLabel( account );
|
updateAccountLabel( account );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagnosticsDialog::onPeerOffline(const QString& )
|
|
||||||
|
void
|
||||||
|
DiagnosticsDialog::onPeerOffline( const QString& )
|
||||||
{
|
{
|
||||||
Tomahawk::Accounts::Account* account = qobject_cast< SipPlugin* >( sender() )->account();
|
Tomahawk::Accounts::Account* account = qobject_cast< SipPlugin* >( sender() )->account();
|
||||||
Q_ASSERT(account);
|
Q_ASSERT( account );
|
||||||
|
|
||||||
updateAccountLabel( account );
|
updateAccountLabel( account );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagnosticsDialog::onSipInfoReceived(const QString& peerId, const SipInfo& info)
|
|
||||||
|
void
|
||||||
|
DiagnosticsDialog::onSipInfoReceived( const QString& /* peerId */ , const SipInfo& /* info */ )
|
||||||
{
|
{
|
||||||
Tomahawk::Accounts::Account* account = qobject_cast< SipPlugin* >( sender() )->account();
|
Tomahawk::Accounts::Account* account = qobject_cast< SipPlugin* >( sender() )->account();
|
||||||
Q_ASSERT(account);
|
Q_ASSERT( account );
|
||||||
|
|
||||||
updateAccountLabel( account );
|
updateAccountLabel( account );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagnosticsDialog::onSoftwareVersionReceived(const QString& peerId, const QString& versionString)
|
|
||||||
|
void
|
||||||
|
DiagnosticsDialog::onSoftwareVersionReceived( const QString& /* peerId */ , const QString& /* versionString */ )
|
||||||
{
|
{
|
||||||
Tomahawk::Accounts::Account* account = qobject_cast< SipPlugin* >( sender() )->account();
|
Tomahawk::Accounts::Account* account = qobject_cast< SipPlugin* >( sender() )->account();
|
||||||
Q_ASSERT(account);
|
Q_ASSERT( account );
|
||||||
|
|
||||||
updateAccountLabel( account );
|
updateAccountLabel( account );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagnosticsDialog::updateAccountLabel( Tomahawk::Accounts::Account* account)
|
|
||||||
{
|
|
||||||
QLabel* accountInfoLabel = m_accountDescriptionStore.value(account);
|
|
||||||
|
|
||||||
if( accountInfoLabel )
|
void
|
||||||
|
DiagnosticsDialog::updateAccountLabel( Tomahawk::Accounts::Account* account )
|
||||||
|
{
|
||||||
|
QLabel* accountInfoLabel = m_accountDescriptionStore.value( account );
|
||||||
|
|
||||||
|
if ( accountInfoLabel )
|
||||||
{
|
{
|
||||||
QString accountInfo;
|
QString accountInfo;
|
||||||
QString stateString;
|
QString stateString;
|
||||||
@@ -278,11 +220,12 @@ void DiagnosticsDialog::updateAccountLabel( Tomahawk::Accounts::Account* account
|
|||||||
.arg( stateString )
|
.arg( stateString )
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach( const QString &peerId, account->sipPlugin()->peersOnline() )
|
foreach( const QString& peerId, account->sipPlugin()->peersOnline() )
|
||||||
{
|
{
|
||||||
QString versionString = SipHandler::instance()->versionString( peerId );
|
QString versionString = SipHandler::instance()->versionString( peerId );
|
||||||
SipInfo sipInfo = SipHandler::instance()->sipInfo( peerId );
|
SipInfo sipInfo = SipHandler::instance()->sipInfo( peerId );
|
||||||
if( !sipInfo.isValid() )
|
if ( !sipInfo.isValid() )
|
||||||
|
{
|
||||||
accountInfo.append(
|
accountInfo.append(
|
||||||
QString(" %1: %2 %3" /*"(%4)"*/ "\n")
|
QString(" %1: %2 %3" /*"(%4)"*/ "\n")
|
||||||
.arg( peerId )
|
.arg( peerId )
|
||||||
@@ -290,7 +233,9 @@ void DiagnosticsDialog::updateAccountLabel( Tomahawk::Accounts::Account* account
|
|||||||
.arg( versionString )
|
.arg( versionString )
|
||||||
// .arg( connected ? "connected" : "not connected")
|
// .arg( connected ? "connected" : "not connected")
|
||||||
);
|
);
|
||||||
else if( sipInfo.isVisible() )
|
}
|
||||||
|
else if ( sipInfo.isVisible() )
|
||||||
|
{
|
||||||
accountInfo.append(
|
accountInfo.append(
|
||||||
QString(" %1: %2:%3 %4" /*" (%5)"*/ "\n")
|
QString(" %1: %2:%3 %4" /*" (%5)"*/ "\n")
|
||||||
.arg( peerId )
|
.arg( peerId )
|
||||||
@@ -298,18 +243,19 @@ void DiagnosticsDialog::updateAccountLabel( Tomahawk::Accounts::Account* account
|
|||||||
.arg( sipInfo.port() )
|
.arg( sipInfo.port() )
|
||||||
.arg( versionString )
|
.arg( versionString )
|
||||||
// .arg( connected ? "connected" : "not connected")
|
// .arg( connected ? "connected" : "not connected")
|
||||||
|
|
||||||
);
|
);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
accountInfo.append(
|
accountInfo.append(
|
||||||
QString(" %1: visible: false %2" /*" (%3)"*/ "\n")
|
QString(" %1: visible: false %2" /*" (%3)"*/ "\n")
|
||||||
.arg( peerId )
|
.arg( peerId )
|
||||||
.arg( versionString )
|
.arg( versionString )
|
||||||
// .arg( connected ? "connected" : "not connected")
|
// .arg( connected ? "connected" : "not connected")
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
accountInfo.append("\n");
|
}
|
||||||
|
accountInfo.append( "\n" );
|
||||||
|
|
||||||
accountInfoLabel->setText( accountInfo );
|
accountInfoLabel->setText( accountInfo );
|
||||||
}
|
}
|
||||||
|
@@ -46,13 +46,6 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="updateButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Update</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="clipboardButton">
|
<widget class="QPushButton" name="clipboardButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
Reference in New Issue
Block a user