mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-22 08:52:12 +02:00
Show spinner on initial load while loading sip plugins in preferences. Disable Settings action till servent is loaded
This commit is contained in:
parent
08f868c2ce
commit
ee8da33e06
@ -60,6 +60,7 @@ Servent::Servent( QObject* parent )
|
||||
: QTcpServer( parent )
|
||||
, m_port( 0 )
|
||||
, m_externalPort( 0 )
|
||||
, m_ready( false )
|
||||
, m_portfwd( 0 )
|
||||
{
|
||||
s_instance = this;
|
||||
@ -133,6 +134,7 @@ Servent::startListening( QHostAddress ha, bool upnp, int port )
|
||||
tLog() << "Forcing static preferred host and port";
|
||||
m_externalHostname = TomahawkSettings::instance()->externalHostname();
|
||||
m_externalPort = TomahawkSettings::instance()->externalPort();
|
||||
m_ready = true;
|
||||
emit ready();
|
||||
return true;
|
||||
}
|
||||
@ -155,7 +157,10 @@ Servent::startListening( QHostAddress ha, bool upnp, int port )
|
||||
QMetaObject::invokeMethod( this, "setExternalAddress", Qt::QueuedConnection, Q_ARG( QHostAddress, ha ), Q_ARG( unsigned int, m_port ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ready = true;
|
||||
emit ready();
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -227,6 +232,7 @@ Servent::setExternalAddress( QHostAddress ha, unsigned int port )
|
||||
qDebug() << "No external access, LAN and outbound connections only!";
|
||||
}
|
||||
|
||||
m_ready = true;
|
||||
emit ready();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@ -123,6 +123,8 @@ public:
|
||||
QSharedPointer<QIODevice> localFileIODeviceFactory( const Tomahawk::result_ptr& result );
|
||||
QSharedPointer<QIODevice> httpIODeviceFactory( const Tomahawk::result_ptr& result );
|
||||
|
||||
bool isReady() const { return m_ready; };
|
||||
|
||||
signals:
|
||||
void streamStarted( StreamConnection* );
|
||||
void streamFinished( StreamConnection* );
|
||||
@ -159,6 +161,7 @@ private:
|
||||
int m_port, m_externalPort;
|
||||
QHostAddress m_externalAddress;
|
||||
QString m_externalHostname;
|
||||
bool m_ready;
|
||||
|
||||
// currently active file transfers:
|
||||
QList< StreamConnection* > m_scsessions;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@ -21,31 +21,33 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
class QMovie;
|
||||
class QTimeLine;
|
||||
/**
|
||||
* A small widget that displays an animated loading spinner
|
||||
*/
|
||||
class LoadingSpinner : public QWidget {
|
||||
class DLLEXPORT LoadingSpinner : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
LoadingSpinner( QWidget* parent );
|
||||
virtual ~LoadingSpinner();
|
||||
|
||||
|
||||
virtual QSize sizeHint() const;
|
||||
virtual void paintEvent( QPaintEvent* );
|
||||
virtual void resizeEvent( QResizeEvent* );
|
||||
|
||||
public slots:
|
||||
|
||||
public slots:
|
||||
void fadeIn();
|
||||
void fadeOut();
|
||||
|
||||
|
||||
private slots:
|
||||
void hideFinished();
|
||||
|
||||
|
||||
private:
|
||||
void reposition();
|
||||
|
||||
|
||||
QTimeLine* m_showHide;
|
||||
QMovie* m_anim;
|
||||
};
|
||||
|
@ -51,6 +51,7 @@
|
||||
|
||||
#include "ui_proxydialog.h"
|
||||
#include "ui_stackedsettingsdialog.h"
|
||||
#include <playlist/dynamic/widgets/LoadingSpinner.h>
|
||||
|
||||
static QString
|
||||
md5( const QByteArray& src )
|
||||
@ -66,6 +67,7 @@ SettingsDialog::SettingsDialog( QWidget *parent )
|
||||
, m_rejected( false )
|
||||
, m_sipModel( 0 )
|
||||
, m_resolversModel( 0 )
|
||||
, m_sipSpinner( 0 )
|
||||
{
|
||||
ui->setupUi( this );
|
||||
TomahawkSettings* s = TomahawkSettings::instance();
|
||||
@ -107,6 +109,13 @@ SettingsDialog::SettingsDialog( QWidget *parent )
|
||||
m_sipModel = new SipModel( this );
|
||||
ui->accountsView->setModel( m_sipModel );
|
||||
|
||||
if ( !Servent::instance()->isReady() )
|
||||
{
|
||||
m_sipSpinner = new LoadingSpinner( ui->accountsView );
|
||||
m_sipSpinner->fadeIn();
|
||||
connect( Servent::instance(), SIGNAL( ready() ),m_sipSpinner, SLOT( fadeOut() ) );
|
||||
}
|
||||
|
||||
setupSipButtons();
|
||||
|
||||
ui->staticHostName->setText( s->externalHostname() );
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <QDialog>
|
||||
#include <QModelIndex>
|
||||
|
||||
class LoadingSpinner;
|
||||
class QListWidgetItem;
|
||||
class Ui_StackedSettingsDialog;
|
||||
class SipPluginFactory;
|
||||
@ -112,6 +113,7 @@ private:
|
||||
bool m_rejected;
|
||||
SipModel* m_sipModel;
|
||||
ResolversModel* m_resolversModel;
|
||||
LoadingSpinner* m_sipSpinner;
|
||||
};
|
||||
|
||||
#endif // SETTINGSDIALOG_H
|
||||
|
@ -347,6 +347,12 @@ TomahawkWindow::setupSignals()
|
||||
ui->menuWindow->menuAction()->setVisible( false );
|
||||
#endif
|
||||
|
||||
if ( !Servent::instance()->isReady() )
|
||||
{
|
||||
ui->actionPreferences->setEnabled( false );
|
||||
connect( Servent::instance(), SIGNAL( ready() ), this, SLOT( enablePreferences() ) );
|
||||
}
|
||||
|
||||
// <SipHandler>
|
||||
connect( SipHandler::instance(), SIGNAL( connected( SipPlugin* ) ), SLOT( onSipConnected() ) );
|
||||
connect( SipHandler::instance(), SIGNAL( disconnected( SipPlugin* ) ), SLOT( onSipDisconnected() ) );
|
||||
@ -705,6 +711,12 @@ TomahawkWindow::checkForUpdates()
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
TomahawkWindow::enablePreferences()
|
||||
{
|
||||
ui->actionPreferences->setEnabled( true );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::onSearch( const QString& search )
|
||||
|
@ -89,6 +89,7 @@ private slots:
|
||||
|
||||
void showAboutTomahawk();
|
||||
void checkForUpdates();
|
||||
void enablePreferences();
|
||||
|
||||
void onSipPluginAdded( SipPlugin* p );
|
||||
void onSipPluginRemoved( SipPlugin* p );
|
||||
|
Loading…
x
Reference in New Issue
Block a user