mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-04 21:27:58 +02:00
* Cleaned up DiagnosticsDialog.
This commit is contained in:
@@ -22,10 +22,6 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "accounts/AccountManager.h"
|
|
||||||
#include "network/Servent.h"
|
|
||||||
#include "SourceList.h"
|
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
@@ -34,8 +30,13 @@
|
|||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "utils/Logger.h"
|
#include "accounts/AccountManager.h"
|
||||||
|
#include "network/Servent.h"
|
||||||
|
#include "SourceList.h"
|
||||||
|
|
||||||
#include "sip/SipHandler.h"
|
#include "sip/SipHandler.h"
|
||||||
|
#include "utils/TomahawkUtilsGui.h"
|
||||||
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
|
|
||||||
DiagnosticsDialog::DiagnosticsDialog( QWidget *parent )
|
DiagnosticsDialog::DiagnosticsDialog( QWidget *parent )
|
||||||
@@ -44,10 +45,9 @@ DiagnosticsDialog::DiagnosticsDialog( QWidget *parent )
|
|||||||
{
|
{
|
||||||
ui->setupUi( this );
|
ui->setupUi( this );
|
||||||
|
|
||||||
connect( ui->clipboardButton, SIGNAL( clicked() ), this, SLOT( copyToClipboard() ) );
|
connect( ui->clipboardButton, SIGNAL( clicked() ), SLOT( copyToClipboard() ) );
|
||||||
connect( ui->buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
|
connect( ui->logfileButton, SIGNAL( clicked() ), SLOT( openLogfile() ) );
|
||||||
|
connect( ui->buttonBox, SIGNAL( rejected() ), SLOT( reject() ) );
|
||||||
ui->scrollAreaWidgetContents->setLayout( new QVBoxLayout() );
|
|
||||||
|
|
||||||
updateLogView();
|
updateLogView();
|
||||||
}
|
}
|
||||||
@@ -58,16 +58,10 @@ DiagnosticsDialog::updateLogView()
|
|||||||
{
|
{
|
||||||
QString log;
|
QString log;
|
||||||
|
|
||||||
log.append(
|
log.append( QString( "TOMAHAWK DIAGNOSTICS LOG -%1 \n\n" ).arg( QDateTime::currentDateTime().toString() ) );
|
||||||
QString("TOMAHAWK DIAGNOSTICS LOG -%1 \n\n")
|
|
||||||
.arg( QDateTime::currentDateTime().toString() )
|
|
||||||
);
|
|
||||||
|
|
||||||
// network
|
|
||||||
log.append( "TOMAHAWK-VERSION: " TOMAHAWK_VERSION "\n\n" );
|
log.append( "TOMAHAWK-VERSION: " TOMAHAWK_VERSION "\n\n" );
|
||||||
|
|
||||||
// network
|
|
||||||
log.append( "NETWORK:\n General:\n" );
|
log.append( "NETWORK:\n General:\n" );
|
||||||
|
|
||||||
if ( Servent::instance()->visibleExternally() )
|
if ( Servent::instance()->visibleExternally() )
|
||||||
{
|
{
|
||||||
log.append(
|
log.append(
|
||||||
@@ -86,9 +80,7 @@ DiagnosticsDialog::updateLogView()
|
|||||||
log.append( " visible: false" );
|
log.append( " visible: false" );
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->scrollAreaWidgetContents->layout()->addWidget( new QLabel( log, this ) );
|
log.append( "ACCOUNTS:\n" );
|
||||||
// Peers / Accounts, TODO
|
|
||||||
ui->scrollAreaWidgetContents->layout()->addWidget( new QLabel( "ACCOUNTS:\n", this ) );
|
|
||||||
|
|
||||||
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 );
|
||||||
@@ -98,167 +90,98 @@ DiagnosticsDialog::updateLogView()
|
|||||||
if ( !account || !account->sipPlugin() )
|
if ( !account || !account->sipPlugin() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
connect( account, SIGNAL( connectionStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ),
|
connect( account, SIGNAL( connectionStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ), SLOT( updateLogView() ), Qt::UniqueConnection );
|
||||||
SLOT( onAccountConnectionStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ) );
|
connect( account, SIGNAL( error( int, QString ) ), SLOT( updateLogView() ), Qt::UniqueConnection );
|
||||||
connect( account, SIGNAL( error( int, QString ) ),
|
connect( account->sipPlugin(), SIGNAL( peerOnline( QString ) ), SLOT( updateLogView() ), Qt::UniqueConnection );
|
||||||
SLOT( onAccountError( int, QString ) ) );
|
connect( account->sipPlugin(), SIGNAL( peerOffline( QString ) ), SLOT( updateLogView() ), Qt::UniqueConnection );
|
||||||
|
connect( account->sipPlugin(), SIGNAL( sipInfoReceived( QString, SipInfo ) ), SLOT( updateLogView() ), Qt::UniqueConnection );
|
||||||
|
connect( account->sipPlugin(), SIGNAL( softwareVersionReceived( QString, QString ) ), SLOT( updateLogView() ), Qt::UniqueConnection );
|
||||||
|
|
||||||
connect( account->sipPlugin(), SIGNAL( peerOnline( QString ) ), SLOT( onPeerOnline( QString ) ) );
|
log.append( accountLog( account ) + "\n" );
|
||||||
connect( account->sipPlugin(), SIGNAL( peerOffline( QString ) ), SLOT( onPeerOffline( QString ) ) );
|
|
||||||
connect( account->sipPlugin(), SIGNAL( sipInfoReceived( QString, SipInfo ) ), SLOT( onSipInfoReceived( QString, SipInfo ) ) );
|
|
||||||
connect( account->sipPlugin(), SIGNAL( softwareVersionReceived( QString, QString ) ), SLOT( onSoftwareVersionReceived( QString, QString ) ) );
|
|
||||||
|
|
||||||
QLabel* accountInfoLabel = new QLabel( this );
|
|
||||||
ui->scrollAreaWidgetContents->layout()->addWidget( accountInfoLabel );
|
|
||||||
m_accountDescriptionStore.insert( account, accountInfoLabel );
|
|
||||||
|
|
||||||
updateAccountLabel( account );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->scrollAreaWidgetContents->layout()->addItem( new QSpacerItem( 1, 1, QSizePolicy::Fixed, QSizePolicy::Expanding ) );
|
ui->text->setText( log );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DiagnosticsDialog::copyToClipboard()
|
DiagnosticsDialog::copyToClipboard()
|
||||||
{
|
{
|
||||||
QString log;
|
QApplication::clipboard()->setText( ui->text->toPlainText() );
|
||||||
foreach ( QLabel* label, m_accountDescriptionStore.values() )
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DiagnosticsDialog::openLogfile()
|
||||||
|
{
|
||||||
|
TomahawkUtils::openUrl( Logger::logFile() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
DiagnosticsDialog::accountLog( Tomahawk::Accounts::Account* account )
|
||||||
|
{
|
||||||
|
QString accountInfo;
|
||||||
|
QString stateString;
|
||||||
|
switch( account->connectionState() )
|
||||||
{
|
{
|
||||||
log += label->text() + "\n\n";
|
case Tomahawk::Accounts::Account::Connecting:
|
||||||
|
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 )
|
||||||
|
);
|
||||||
|
|
||||||
QApplication::clipboard()->setText( log );
|
foreach( const QString& peerId, account->sipPlugin()->peersOnline() )
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DiagnosticsDialog::onAccountConnectionStateChanged( Tomahawk::Accounts::Account::ConnectionState /* state */ )
|
|
||||||
{
|
|
||||||
Tomahawk::Accounts::Account* account = qobject_cast< Tomahawk::Accounts::Account* >( sender() );
|
|
||||||
Q_ASSERT( account );
|
|
||||||
|
|
||||||
updateAccountLabel( account );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DiagnosticsDialog::onAccountError( int /* errorId */ , QString /* errorString */ )
|
|
||||||
{
|
|
||||||
Tomahawk::Accounts::Account* account = qobject_cast< Tomahawk::Accounts::Account* >( sender() );
|
|
||||||
Q_ASSERT( account );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DiagnosticsDialog::onPeerOnline( const QString& )
|
|
||||||
{
|
|
||||||
Tomahawk::Accounts::Account* account = qobject_cast< SipPlugin* >( sender() )->account();
|
|
||||||
Q_ASSERT( account );
|
|
||||||
|
|
||||||
updateAccountLabel( account );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DiagnosticsDialog::onPeerOffline( const QString& )
|
|
||||||
{
|
|
||||||
Tomahawk::Accounts::Account* account = qobject_cast< SipPlugin* >( sender() )->account();
|
|
||||||
Q_ASSERT( account );
|
|
||||||
|
|
||||||
updateAccountLabel( account );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DiagnosticsDialog::onSipInfoReceived( const QString& /* peerId */ , const SipInfo& /* info */ )
|
|
||||||
{
|
|
||||||
Tomahawk::Accounts::Account* account = qobject_cast< SipPlugin* >( sender() )->account();
|
|
||||||
Q_ASSERT( account );
|
|
||||||
|
|
||||||
updateAccountLabel( account );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DiagnosticsDialog::onSoftwareVersionReceived( const QString& /* peerId */ , const QString& /* versionString */ )
|
|
||||||
{
|
|
||||||
Tomahawk::Accounts::Account* account = qobject_cast< SipPlugin* >( sender() )->account();
|
|
||||||
Q_ASSERT( account );
|
|
||||||
|
|
||||||
updateAccountLabel( account );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DiagnosticsDialog::updateAccountLabel( Tomahawk::Accounts::Account* account )
|
|
||||||
{
|
|
||||||
QLabel* accountInfoLabel = m_accountDescriptionStore.value( account );
|
|
||||||
|
|
||||||
if ( accountInfoLabel )
|
|
||||||
{
|
{
|
||||||
QString accountInfo;
|
QString versionString = SipHandler::instance()->versionString( peerId );
|
||||||
QString stateString;
|
SipInfo sipInfo = SipHandler::instance()->sipInfo( peerId );
|
||||||
switch( account->connectionState() )
|
if ( !sipInfo.isValid() )
|
||||||
{
|
{
|
||||||
case Tomahawk::Accounts::Account::Connecting:
|
accountInfo.append(
|
||||||
stateString = "Connecting";
|
QString(" %1: %2 %3" /*"(%4)"*/ "\n")
|
||||||
break;
|
.arg( peerId )
|
||||||
case Tomahawk::Accounts::Account::Connected:
|
.arg( "sipinfo invalid" )
|
||||||
stateString = "Connected";
|
.arg( versionString )
|
||||||
break;
|
// .arg( connected ? "connected" : "not connected")
|
||||||
|
);
|
||||||
case Tomahawk::Accounts::Account::Disconnected:
|
|
||||||
stateString = "Disconnected";
|
|
||||||
break;
|
|
||||||
case Tomahawk::Accounts::Account::Disconnecting:
|
|
||||||
stateString = "Disconnecting";
|
|
||||||
}
|
}
|
||||||
accountInfo.append(
|
else if ( sipInfo.isVisible() )
|
||||||
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() )
|
|
||||||
{
|
{
|
||||||
QString versionString = SipHandler::instance()->versionString( peerId );
|
accountInfo.append(
|
||||||
SipInfo sipInfo = SipHandler::instance()->sipInfo( peerId );
|
QString(" %1: %2:%3 %4" /*" (%5)"*/ "\n")
|
||||||
if ( !sipInfo.isValid() )
|
.arg( peerId )
|
||||||
{
|
.arg( sipInfo.host() )
|
||||||
accountInfo.append(
|
.arg( sipInfo.port() )
|
||||||
QString(" %1: %2 %3" /*"(%4)"*/ "\n")
|
.arg( versionString )
|
||||||
.arg( peerId )
|
// .arg( connected ? "connected" : "not connected")
|
||||||
.arg( "sipinfo invalid" )
|
);
|
||||||
.arg( versionString )
|
}
|
||||||
// .arg( connected ? "connected" : "not connected")
|
else
|
||||||
);
|
{
|
||||||
}
|
accountInfo.append(
|
||||||
else if ( sipInfo.isVisible() )
|
QString(" %1: visible: false %2" /*" (%3)"*/ "\n")
|
||||||
{
|
.arg( peerId )
|
||||||
accountInfo.append(
|
.arg( versionString )
|
||||||
QString(" %1: %2:%3 %4" /*" (%5)"*/ "\n")
|
// .arg( connected ? "connected" : "not connected")
|
||||||
.arg( peerId )
|
);
|
||||||
.arg( sipInfo.host() )
|
|
||||||
.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" );
|
|
||||||
|
|
||||||
accountInfoLabel->setText( accountInfo );
|
|
||||||
}
|
}
|
||||||
|
accountInfo.append( "\n" );
|
||||||
|
|
||||||
|
return accountInfo;
|
||||||
}
|
}
|
@@ -45,19 +45,11 @@ public:
|
|||||||
private slots:
|
private slots:
|
||||||
void updateLogView();
|
void updateLogView();
|
||||||
void copyToClipboard();
|
void copyToClipboard();
|
||||||
|
void openLogfile();
|
||||||
void onAccountConnectionStateChanged( Tomahawk::Accounts::Account::ConnectionState state );
|
|
||||||
void onAccountError( int errorId, QString errorString );
|
QString accountLog( Tomahawk::Accounts::Account* );
|
||||||
void onPeerOnline( const QString& );
|
|
||||||
void onPeerOffline( const QString& );
|
|
||||||
void onSipInfoReceived( const QString& peerId, const SipInfo& info );
|
|
||||||
void onSoftwareVersionReceived( const QString& peerId, const QString& versionString );
|
|
||||||
|
|
||||||
void updateAccountLabel( Tomahawk::Accounts::Account* );
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QMap< Tomahawk::Accounts::Account*, QLabel* > m_accountDescriptionStore;
|
|
||||||
|
|
||||||
Ui::DiagnosticsDialog* ui;
|
Ui::DiagnosticsDialog* ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -26,20 +26,10 @@
|
|||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QScrollArea" name="scrollArea">
|
<widget class="QTextBrowser" name="text">
|
||||||
<property name="widgetResizable">
|
<property name="lineWrapMode">
|
||||||
<bool>true</bool>
|
<enum>QTextEdit::NoWrap</enum>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>708</width>
|
|
||||||
<height>386</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@@ -49,7 +39,14 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="clipboardButton">
|
<widget class="QPushButton" name="clipboardButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Copy to Clipboard</string>
|
<string>&Copy to Clipboard</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="logfileButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Open &Log-file</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Reference in New Issue
Block a user