mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-02-25 20:33:20 +01:00
* Fixed a few ScanManager issues.
* Added changed() signal to TomahawkSettings and hooked up ScanManager and SipHandler to it.
This commit is contained in:
parent
35484b0357
commit
795d71213e
@ -12,13 +12,16 @@
|
||||
*/
|
||||
class DLLEXPORT TomahawkSettings : public QSettings
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static TomahawkSettings* instance();
|
||||
|
||||
explicit TomahawkSettings( QObject* parent = 0 );
|
||||
virtual ~TomahawkSettings();
|
||||
|
||||
|
||||
void applyChanges() { emit changed(); }
|
||||
|
||||
/// General settings
|
||||
QString scannerPath() const; /// QDesktopServices::MusicLocation by default
|
||||
void setScannerPath( const QString& path );
|
||||
@ -57,7 +60,7 @@ public:
|
||||
/// Network settings
|
||||
enum ExternalAddressMode { Lan, Upnp };
|
||||
ExternalAddressMode externalAddressMode() const;
|
||||
void setExternalAddressMode(ExternalAddressMode externalAddressMode);
|
||||
void setExternalAddressMode( ExternalAddressMode externalAddressMode );
|
||||
|
||||
bool preferStaticHostPort() const;
|
||||
void setPreferStaticHostPort( bool prefer );
|
||||
@ -135,11 +138,13 @@ public:
|
||||
void setXmppBotPort( const int port );
|
||||
|
||||
/// Script resolver settings
|
||||
|
||||
QStringList scriptResolvers() const;
|
||||
void setScriptResolvers( const QStringList& resolver );
|
||||
void addScriptResolver( const QString& resolver );
|
||||
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
|
||||
private:
|
||||
static TomahawkSettings* s_instance;
|
||||
};
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
MusicScanner::MusicScanner( const QString& dir, quint32 bs )
|
||||
: QObject()
|
||||
, m_dir( dir )
|
||||
@ -30,6 +31,7 @@ MusicScanner::MusicScanner( const QString& dir, quint32 bs )
|
||||
// m_ext2mime.insert( "mp4", "audio/mp4" );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MusicScanner::startScan()
|
||||
{
|
||||
@ -69,13 +71,13 @@ MusicScanner::scan()
|
||||
m_dirLister->moveToThread( m_dirListerThreadController );
|
||||
|
||||
connect( m_dirLister, SIGNAL( fileToScan( QFileInfo ) ),
|
||||
SLOT( scanFile( QFileInfo ) ), Qt::QueuedConnection );
|
||||
SLOT( scanFile( QFileInfo ) ), Qt::QueuedConnection );
|
||||
|
||||
// queued, so will only fire after all dirs have been scanned:
|
||||
connect( m_dirLister, SIGNAL( finished( const QMap<QString, unsigned int>& ) ),
|
||||
SLOT( listerFinished( const QMap<QString, unsigned int>& ) ), Qt::QueuedConnection );
|
||||
SLOT( listerFinished( const QMap<QString, unsigned int>& ) ), Qt::QueuedConnection );
|
||||
|
||||
connect( m_dirLister, SIGNAL( destroyed(QObject*) ), this, SLOT( listerDestroyed(QObject*) ) );
|
||||
connect( m_dirLister, SIGNAL( destroyed( QObject* ) ), SLOT( listerDestroyed( QObject* ) ) );
|
||||
|
||||
m_dirListerThreadController->start();
|
||||
QMetaObject::invokeMethod( m_dirLister, "go" );
|
||||
@ -106,6 +108,7 @@ MusicScanner::listerFinished( const QMap<QString, unsigned int>& newmtimes )
|
||||
qDebug() << s;
|
||||
|
||||
m_dirLister->deleteLater();
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
|
||||
@ -118,6 +121,7 @@ MusicScanner::listerDestroyed( QObject* dirLister )
|
||||
m_dirListerThreadController = 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MusicScanner::commitBatch( const QVariantList& tracks )
|
||||
{
|
||||
|
@ -1,9 +1,11 @@
|
||||
#include "scanmanager.h"
|
||||
#include "musicscanner.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QThread>
|
||||
|
||||
#include "musicscanner.h"
|
||||
#include "tomahawksettings.h"
|
||||
|
||||
ScanManager* ScanManager::s_instance = 0;
|
||||
|
||||
|
||||
@ -20,6 +22,8 @@ ScanManager::ScanManager( QObject* parent )
|
||||
, m_musicScannerThreadController( 0 )
|
||||
{
|
||||
s_instance = this;
|
||||
|
||||
connect( TomahawkSettings::instance(), SIGNAL( changed() ), SLOT( onSettingsChanged() ) );
|
||||
}
|
||||
|
||||
|
||||
@ -32,8 +36,17 @@ ScanManager::~ScanManager()
|
||||
m_scanner = 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ScanManager::runManualScan( const QString &path )
|
||||
ScanManager::onSettingsChanged()
|
||||
{
|
||||
if ( TomahawkSettings::instance()->hasScannerPath() )
|
||||
runManualScan( TomahawkSettings::instance()->scannerPath() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ScanManager::runManualScan( const QString& path )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
if ( !m_musicScannerThreadController && !m_scanner ) //still running if these are not zero
|
||||
@ -41,13 +54,13 @@ ScanManager::runManualScan( const QString &path )
|
||||
m_musicScannerThreadController = new QThread( this );
|
||||
MusicScanner* m_scanner = new MusicScanner( path );
|
||||
m_scanner->moveToThread( m_musicScannerThreadController );
|
||||
connect( m_scanner, SIGNAL( finished() ), m_scanner, SLOT( deleteLater() ) );
|
||||
connect( m_scanner, SIGNAL( destroyed(QObject*) ), this, SLOT( scanDestroyed(QObject*) ) );
|
||||
connect( m_scanner, SIGNAL( destroyed( QObject* ) ), this, SLOT( scannerDestroyed( QObject* ) ) );
|
||||
m_musicScannerThreadController->start( QThread::IdlePriority );
|
||||
QMetaObject::invokeMethod( m_scanner, "startScan" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ScanManager::scannerDestroyed( QObject* scanner )
|
||||
{
|
||||
@ -55,4 +68,5 @@ ScanManager::scannerDestroyed( QObject* scanner )
|
||||
m_scanner = 0;
|
||||
m_musicScannerThreadController->deleteLater();
|
||||
m_musicScannerThreadController = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,17 +10,20 @@ class QThread;
|
||||
|
||||
class ScanManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static ScanManager* instance();
|
||||
|
||||
explicit ScanManager( QObject* parent = 0 );
|
||||
virtual ~ScanManager();
|
||||
|
||||
void runManualScan( const QString &path );
|
||||
void runManualScan( const QString& path );
|
||||
|
||||
private slots:
|
||||
void scannerDestroyed( QObject *scanner );
|
||||
void scannerDestroyed( QObject* scanner );
|
||||
|
||||
void onSettingsChanged();
|
||||
|
||||
private:
|
||||
static ScanManager* s_instance;
|
||||
|
@ -107,52 +107,33 @@ SettingsDialog::~SettingsDialog()
|
||||
{
|
||||
TomahawkSettings* s = TomahawkSettings::instance();
|
||||
|
||||
// if jabber or scan dir changed, reconnect/rescan
|
||||
bool rescan = ui->lineEditMusicPath->text() != s->scannerPath();
|
||||
bool rejabber = false;
|
||||
if ( ui->jabberUsername->text() != s->jabberUsername() ||
|
||||
ui->jabberPassword->text() != s->jabberPassword() ||
|
||||
ui->jabberServer->text() != s->jabberServer() ||
|
||||
(uint)(ui->jabberPort->value()) != s->jabberPort()
|
||||
)
|
||||
{
|
||||
rejabber = true;
|
||||
}
|
||||
|
||||
s->setHttpEnabled( ui->checkBoxHttp->checkState() == Qt::Checked );
|
||||
|
||||
s->setHttpEnabled( ui->checkBoxHttp->checkState() == Qt::Checked );
|
||||
s->setPreferStaticHostPort( ui->checkBoxStaticPreferred->checkState() == Qt::Checked );
|
||||
s->setExternalAddressMode( ui->checkBoxUpnp->checkState() == Qt::Checked ? TomahawkSettings::Upnp : TomahawkSettings::Lan );
|
||||
|
||||
s->setJabberAutoConnect( ui->checkBoxJabberAutoConnect->checkState() == Qt::Checked );
|
||||
s->setJabberUsername( ui->jabberUsername->text() );
|
||||
s->setJabberPassword( ui->jabberPassword->text() );
|
||||
s->setJabberServer( ui->jabberServer->text() );
|
||||
s->setJabberPort( ui->jabberPort->value() );
|
||||
s->setJabberAutoConnect( ui->checkBoxJabberAutoConnect->checkState() == Qt::Checked );
|
||||
s->setJabberUsername( ui->jabberUsername->text() );
|
||||
s->setJabberPassword( ui->jabberPassword->text() );
|
||||
s->setJabberServer( ui->jabberServer->text() );
|
||||
s->setJabberPort( ui->jabberPort->value() );
|
||||
|
||||
s->setExternalHostname( ui->staticHostName->text() );
|
||||
s->setExternalPort( ui->staticPort->value() );
|
||||
s->setExternalHostname( ui->staticHostName->text() );
|
||||
s->setExternalPort( ui->staticPort->value() );
|
||||
|
||||
s->setScannerPath( ui->lineEditMusicPath->text() );
|
||||
s->setScannerPath( ui->lineEditMusicPath->text() );
|
||||
|
||||
s->setScrobblingEnabled( ui->checkBoxEnableLastfm->isChecked() );
|
||||
s->setLastFmUsername( ui->lineEditLastfmUsername->text() );
|
||||
s->setLastFmPassword( ui->lineEditLastfmPassword->text() );
|
||||
s->setScrobblingEnabled( ui->checkBoxEnableLastfm->isChecked() );
|
||||
s->setLastFmUsername( ui->lineEditLastfmUsername->text() );
|
||||
s->setLastFmPassword( ui->lineEditLastfmPassword->text() );
|
||||
|
||||
QStringList resolvers;
|
||||
for( int i = 0; i < ui->scriptList->topLevelItemCount(); i++ ) {
|
||||
for( int i = 0; i < ui->scriptList->topLevelItemCount(); i++ )
|
||||
{
|
||||
resolvers << ui->scriptList->topLevelItem( i )->data( 1, Qt::DisplayRole ).toString();
|
||||
}
|
||||
s->setScriptResolvers( resolvers );
|
||||
|
||||
if( rescan )
|
||||
ScanManager::instance()->runManualScan( s->scannerPath() );
|
||||
|
||||
if( rejabber )
|
||||
{
|
||||
APP->sipHandler()->disconnectPlugins();
|
||||
APP->sipHandler()->connectPlugins();
|
||||
}
|
||||
s->applyChanges();
|
||||
}
|
||||
else
|
||||
qDebug() << "Settings dialog cancelled, NOT saving prefs.";
|
||||
@ -255,8 +236,8 @@ SettingsDialog::onLastFmFinished()
|
||||
qDebug() << "ERROR from last.fm:" << lfm.text();
|
||||
ui->pushButtonTestLastfmLogin->setText( tr( "Failed" ) );
|
||||
ui->pushButtonTestLastfmLogin->setEnabled( true );
|
||||
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->pushButtonTestLastfmLogin->setText( tr( "Success" ) );
|
||||
ui->pushButtonTestLastfmLogin->setEnabled( false );
|
||||
@ -278,6 +259,7 @@ SettingsDialog::onLastFmFinished()
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SettingsDialog::authenticateTwitter()
|
||||
{
|
||||
@ -308,6 +290,7 @@ SettingsDialog::authenticateTwitter()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SettingsDialog::startPostGotTomahawkStatus()
|
||||
{
|
||||
@ -327,6 +310,7 @@ SettingsDialog::startPostGotTomahawkStatus()
|
||||
credVerifier->verify();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SettingsDialog::postGotTomahawkStatusAuthVerifyReply( const QTweetUser &user )
|
||||
{
|
||||
@ -348,6 +332,7 @@ SettingsDialog::postGotTomahawkStatusAuthVerifyReply( const QTweetUser &user )
|
||||
statUpdate->post( QString( "Got Tomahawk? {" ) + Database::instance()->dbid() + QString( "} (" ) + uuid.mid( 1, 8 ) + QString( ")" ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SettingsDialog::postGotTomahawkStatusUpdateReply( const QTweetStatus& status )
|
||||
{
|
||||
@ -356,6 +341,8 @@ SettingsDialog::postGotTomahawkStatusUpdateReply( const QTweetStatus& status )
|
||||
else
|
||||
QMessageBox::information( 0, QString("Tweeted!"), QString("Your tweet has been posted!") );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SettingsDialog::postGotTomahawkStatusUpdateError( QTweetNetBase::ErrorCode code, const QString& errorMsg )
|
||||
{
|
||||
@ -364,6 +351,7 @@ SettingsDialog::postGotTomahawkStatusUpdateError( QTweetNetBase::ErrorCode code,
|
||||
QMessageBox::critical( 0, QString("Tweetin' Error"), QString("There was an error posting your status -- sorry!") );
|
||||
}
|
||||
|
||||
|
||||
ProxyDialog::ProxyDialog( QWidget *parent )
|
||||
: QDialog( parent )
|
||||
, ui( new Ui::ProxyDialog )
|
||||
@ -422,6 +410,7 @@ ProxyDialog::saveSettings()
|
||||
QNetworkProxy::setApplicationProxy( proxy );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SettingsDialog::addScriptResolver()
|
||||
{
|
||||
@ -434,6 +423,7 @@ SettingsDialog::addScriptResolver()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SettingsDialog::removeScriptResolver()
|
||||
{
|
||||
@ -446,6 +436,7 @@ SettingsDialog::removeScriptResolver()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SettingsDialog::scriptSelectionChanged()
|
||||
{
|
||||
|
@ -20,13 +20,13 @@ class ProxyDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ProxyDialog( QWidget *parent = 0 );
|
||||
explicit ProxyDialog( QWidget* parent = 0 );
|
||||
~ProxyDialog() {};
|
||||
|
||||
void saveSettings();
|
||||
|
||||
private:
|
||||
Ui::ProxyDialog *ui;
|
||||
Ui::ProxyDialog* ui;
|
||||
};
|
||||
|
||||
class SettingsDialog : public QDialog
|
||||
@ -34,21 +34,21 @@ class SettingsDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SettingsDialog( QWidget *parent = 0 );
|
||||
explicit SettingsDialog( QWidget* parent = 0 );
|
||||
~SettingsDialog();
|
||||
|
||||
Q_SIGNALS:
|
||||
signals:
|
||||
void settingsChanged();
|
||||
|
||||
protected:
|
||||
void changeEvent( QEvent *e );
|
||||
void changeEvent( QEvent* e );
|
||||
|
||||
private slots:
|
||||
void onRejected();
|
||||
|
||||
void showPathSelector();
|
||||
|
||||
void toggleUpnp( bool preferStaticEnabled );
|
||||
|
||||
void showProxySettings();
|
||||
|
||||
void testLastFmLogin();
|
||||
@ -65,7 +65,7 @@ private slots:
|
||||
void removeScriptResolver();
|
||||
|
||||
private:
|
||||
Ui::SettingsDialog *ui;
|
||||
Ui::SettingsDialog* ui;
|
||||
|
||||
ProxyDialog m_proxySettings;
|
||||
bool m_rejected;
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "database/database.h"
|
||||
#include "network/controlconnection.h"
|
||||
#include "sourcelist.h"
|
||||
#include "tomahawksettings.h"
|
||||
|
||||
|
||||
SipHandler::SipHandler( QObject* parent )
|
||||
@ -16,6 +17,8 @@ SipHandler::SipHandler( QObject* parent )
|
||||
, m_connected( false )
|
||||
{
|
||||
loadPlugins( findPlugins() );
|
||||
|
||||
connect( TomahawkSettings::instance(), SIGNAL( changed() ), SLOT( onSettingsChanged() ) );
|
||||
}
|
||||
|
||||
|
||||
@ -25,6 +28,14 @@ SipHandler::~SipHandler()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SipHandler::onSettingsChanged()
|
||||
{
|
||||
disconnectPlugins();
|
||||
connectPlugins();
|
||||
}
|
||||
|
||||
|
||||
QStringList
|
||||
SipHandler::findPlugins()
|
||||
{
|
||||
@ -122,7 +133,11 @@ SipHandler::connectPlugins( bool startup, const QString &pluginName )
|
||||
if ( pluginName.isEmpty() || ( !pluginName.isEmpty() && sip->name() == pluginName ) )
|
||||
sip->connectPlugin( startup );
|
||||
}
|
||||
m_connected = true;
|
||||
|
||||
if ( pluginName.isEmpty() )
|
||||
{
|
||||
m_connected = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -134,13 +149,15 @@ SipHandler::disconnectPlugins( const QString &pluginName )
|
||||
if ( pluginName.isEmpty() || ( !pluginName.isEmpty() && sip->name() == pluginName ) )
|
||||
sip->disconnectPlugin();
|
||||
}
|
||||
if( pluginName.isEmpty() )
|
||||
|
||||
if ( pluginName.isEmpty() )
|
||||
{
|
||||
SourceList::instance()->removeAllRemote();
|
||||
m_connected = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SipHandler::toggleConnect()
|
||||
{
|
||||
|
@ -34,6 +34,8 @@ private slots:
|
||||
void onPeerOnline( const QString& );
|
||||
void onError( int code, const QString& msg );
|
||||
|
||||
void onSettingsChanged();
|
||||
|
||||
private:
|
||||
QStringList findPlugins();
|
||||
void loadPlugins( const QStringList& paths );
|
||||
|
@ -12,12 +12,14 @@ JabberPlugin::setProxy( QNetworkProxy* proxy )
|
||||
p->setProxy( proxy );
|
||||
}
|
||||
|
||||
|
||||
const QString
|
||||
JabberPlugin::name()
|
||||
{
|
||||
return QString( MYNAME );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
JabberPlugin::connectPlugin( bool startup )
|
||||
{
|
||||
|
@ -31,39 +31,26 @@ public slots:
|
||||
|
||||
void disconnectPlugin()
|
||||
{
|
||||
QMetaObject::invokeMethod( p,
|
||||
"disconnect",
|
||||
Qt::QueuedConnection
|
||||
);
|
||||
if ( p )
|
||||
p->disconnect();
|
||||
}
|
||||
|
||||
void sendMsg( const QString& to, const QString& msg )
|
||||
{
|
||||
QMetaObject::invokeMethod( p,
|
||||
"sendMsg",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(const QString, to),
|
||||
Q_ARG(const QString, msg)
|
||||
);
|
||||
if ( p )
|
||||
p->sendMsg( to, msg );
|
||||
}
|
||||
|
||||
void broadcastMsg( const QString &msg )
|
||||
{
|
||||
QMetaObject::invokeMethod( p,
|
||||
"broadcastMsg",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(const QString, msg)
|
||||
);
|
||||
if ( p )
|
||||
p->broadcastMsg( msg );
|
||||
}
|
||||
|
||||
void addContact( const QString &jid, const QString& msg = QString() )
|
||||
{
|
||||
QMetaObject::invokeMethod( p,
|
||||
"addContact",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(const QString, jid),
|
||||
Q_ARG(const QString, msg)
|
||||
);
|
||||
if ( p )
|
||||
p->addContact( jid, msg );
|
||||
}
|
||||
|
||||
private slots:
|
||||
|
@ -232,9 +232,6 @@ TomahawkWindow::showSettingsDialog()
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
SettingsDialog win;
|
||||
win.exec();
|
||||
|
||||
// settings are written in SettingsDialog destructor, bleh
|
||||
QTimer::singleShot( 0, this, SIGNAL( settingsChanged() ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,9 +34,6 @@ public:
|
||||
|
||||
void setWindowTitle( const QString& title );
|
||||
|
||||
signals:
|
||||
void settingsChanged();
|
||||
|
||||
protected:
|
||||
void changeEvent( QEvent* e );
|
||||
void closeEvent( QCloseEvent* e );
|
||||
|
Loading…
x
Reference in New Issue
Block a user