mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Changes to the DiagnosticsDialog that updates when any changes happens
This commit is contained in:
committed by
Christian Muehlhaeuser
parent
b62b9c3531
commit
65710f9d51
@@ -26,11 +26,13 @@
|
|||||||
#include "network/Servent.h"
|
#include "network/Servent.h"
|
||||||
#include "SourceList.h"
|
#include "SourceList.h"
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "sip/SipHandler.h"
|
#include "sip/SipHandler.h"
|
||||||
@@ -42,10 +44,12 @@ DiagnosticsDialog::DiagnosticsDialog( QWidget *parent )
|
|||||||
{
|
{
|
||||||
ui->setupUi( this );
|
ui->setupUi( this );
|
||||||
|
|
||||||
connect( ui->updateButton, SIGNAL( clicked() ), this, SLOT( updateLogView() ) );
|
//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() ) );
|
||||||
|
|
||||||
|
ui->scrollAreaWidgetContents->setLayout( new QVBoxLayout() );
|
||||||
|
|
||||||
updateLogView();
|
updateLogView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +64,7 @@ void DiagnosticsDialog::updateLogView()
|
|||||||
|
|
||||||
// network
|
// network
|
||||||
log.append(
|
log.append(
|
||||||
"TOMAHAWK-VERSION: " TOMAHAWK_VERSION "\n\n\n"
|
"TOMAHAWK-VERSION: " TOMAHAWK_VERSION "\n\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
// network
|
// network
|
||||||
@@ -89,11 +93,15 @@ void DiagnosticsDialog::updateLogView()
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
log.append("\n\n");
|
//log.append("\n\n");
|
||||||
|
|
||||||
|
ui->scrollAreaWidgetContents->layout()->addWidget( new QLabel( log, this ) );
|
||||||
|
|
||||||
// Peers / Accounts, TODO
|
// Peers / Accounts, TODO
|
||||||
log.append("ACCOUNTS:\n");
|
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 )
|
||||||
@@ -102,6 +110,13 @@ 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(error(int,QString)), SLOT(onAccountError(int,QString)) );
|
||||||
|
connect( account->sipPlugin(), SIGNAL(peerOnline(QString)), SLOT(onPeerOnline(QString)) );
|
||||||
|
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)) );
|
||||||
|
|
||||||
QString stateString;
|
QString stateString;
|
||||||
switch( account->connectionState() )
|
switch( account->connectionState() )
|
||||||
{
|
{
|
||||||
@@ -118,7 +133,7 @@ void DiagnosticsDialog::updateLogView()
|
|||||||
case Tomahawk::Accounts::Account::Disconnecting:
|
case Tomahawk::Accounts::Account::Disconnecting:
|
||||||
stateString = "Disconnecting";
|
stateString = "Disconnecting";
|
||||||
}
|
}
|
||||||
log.append(
|
accountInfo.append(
|
||||||
QString( " %2 (%1): %3 (%4)\n" )
|
QString( " %2 (%1): %3 (%4)\n" )
|
||||||
.arg( account->accountServiceName() )
|
.arg( account->accountServiceName() )
|
||||||
.arg( account->sipPlugin()->friendlyName() )
|
.arg( account->sipPlugin()->friendlyName() )
|
||||||
@@ -142,7 +157,7 @@ void DiagnosticsDialog::updateLogView()
|
|||||||
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() )
|
||||||
log.append(
|
accountInfo.append(
|
||||||
QString(" %1: %2 %3" /*"(%4)"*/ "\n")
|
QString(" %1: %2 %3" /*"(%4)"*/ "\n")
|
||||||
.arg( peerId )
|
.arg( peerId )
|
||||||
.arg( "sipinfo invalid" )
|
.arg( "sipinfo invalid" )
|
||||||
@@ -150,7 +165,7 @@ void DiagnosticsDialog::updateLogView()
|
|||||||
// .arg( connected ? "connected" : "not connected")
|
// .arg( connected ? "connected" : "not connected")
|
||||||
);
|
);
|
||||||
else if( sipInfo.isVisible() )
|
else if( sipInfo.isVisible() )
|
||||||
log.append(
|
accountInfo.append(
|
||||||
QString(" %1: %2:%3 %4" /*" (%5)"*/ "\n")
|
QString(" %1: %2:%3 %4" /*" (%5)"*/ "\n")
|
||||||
.arg( peerId )
|
.arg( peerId )
|
||||||
.arg( sipInfo.host().hostName() )
|
.arg( sipInfo.host().hostName() )
|
||||||
@@ -160,7 +175,7 @@ void DiagnosticsDialog::updateLogView()
|
|||||||
|
|
||||||
);
|
);
|
||||||
else
|
else
|
||||||
log.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 )
|
||||||
@@ -168,13 +183,134 @@ void DiagnosticsDialog::updateLogView()
|
|||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
log.append("\n");
|
accountInfo.append("\n");
|
||||||
|
|
||||||
|
QLabel *accountInfoLabel = new QLabel( accountInfo, this );
|
||||||
|
|
||||||
|
ui->scrollAreaWidgetContents->layout()->addWidget( accountInfoLabel );
|
||||||
|
|
||||||
|
m_accountDescriptionStore.insert( account, accountInfoLabel );
|
||||||
|
|
||||||
|
accountInfo.clear();
|
||||||
}
|
}
|
||||||
ui->logView->setPlainText(log);
|
//ui->logView->setPlainText(log);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagnosticsDialog::copyToClipboard()
|
void DiagnosticsDialog::copyToClipboard()
|
||||||
{
|
{
|
||||||
QApplication::clipboard()->setText( ui->logView->toPlainText() );
|
//QApplication::clipboard()->setText( ui->logView->toPlainText() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 stateString;
|
||||||
|
switch( account->connectionState() )
|
||||||
|
{
|
||||||
|
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 )
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach( const QString &peerId, account->sipPlugin()->peersOnline() )
|
||||||
|
{
|
||||||
|
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");
|
||||||
|
|
||||||
|
accountInfoLabel->setText( accountInfo );
|
||||||
|
}
|
||||||
|
}
|
@@ -19,7 +19,15 @@
|
|||||||
#ifndef DIGANOSTICSDIALOG_H
|
#ifndef DIGANOSTICSDIALOG_H
|
||||||
#define DIAGNOSTICSDIALOG_H
|
#define DIAGNOSTICSDIALOG_H
|
||||||
|
|
||||||
|
#include "accounts/Account.h"
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QMap>
|
||||||
|
|
||||||
|
|
||||||
|
class QLabel;
|
||||||
|
|
||||||
|
class SipInfo;
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
@@ -38,7 +46,18 @@ private slots:
|
|||||||
void updateLogView();
|
void updateLogView();
|
||||||
void copyToClipboard();
|
void copyToClipboard();
|
||||||
|
|
||||||
|
void onAccountConnectionStateChanged( Tomahawk::Accounts::Account::ConnectionState state );
|
||||||
|
void onAccountError( int errorId, QString errorString );
|
||||||
|
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,7 +26,21 @@
|
|||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTextEdit" name="logView"/>
|
<widget class="QScrollArea" name="scrollArea">
|
||||||
|
<property name="widgetResizable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</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>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
Reference in New Issue
Block a user