1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 06:07:37 +02:00

Merge remote branch 'origin/master' into dynamic

This commit is contained in:
Leo Franchi
2011-01-23 00:42:03 -05:00
26 changed files with 345 additions and 71 deletions

View File

@@ -40,8 +40,6 @@ namespace Tomahawk
#ifndef TOMAHAWK_HEADLESS #ifndef TOMAHAWK_HEADLESS
class TomahawkWindow; class TomahawkWindow;
class PlaylistManager;
#include <QStackedWidget>
#endif #endif
@@ -85,6 +83,7 @@ private:
QList<Tomahawk::collection_ptr> m_collections; QList<Tomahawk::collection_ptr> m_collections;
QList<TomahawkPlugin*> m_plugins; QList<TomahawkPlugin*> m_plugins;
Database* m_database;
AudioEngine* m_audioEngine; AudioEngine* m_audioEngine;
SipHandler* m_sipHandler; SipHandler* m_sipHandler;
Servent* m_servent; Servent* m_servent;

View File

@@ -127,6 +127,7 @@ set( libSources
widgets/newplaylistwidget.cpp widgets/newplaylistwidget.cpp
widgets/welcomewidget.cpp widgets/welcomewidget.cpp
widgets/overlaywidget.cpp
widgets/infowidgets/sourceinfowidget.cpp widgets/infowidgets/sourceinfowidget.cpp
) )
@@ -246,6 +247,7 @@ set( libHeaders
widgets/newplaylistwidget.h widgets/newplaylistwidget.h
widgets/welcomewidget.h widgets/welcomewidget.h
widgets/overlaywidget.h
widgets/infowidgets/sourceinfowidget.h widgets/infowidgets/sourceinfowidget.h
) )

View File

@@ -69,8 +69,6 @@ DatabaseCommand_Resolve::exec( DatabaseImpl* lib )
QList< int > tracks = lib->searchTable( "track", trackname, 10 ); QList< int > tracks = lib->searchTable( "track", trackname, 10 );
QList< int > albums = lib->searchTable( "album", albumname, 10 ); QList< int > albums = lib->searchTable( "album", albumname, 10 );
//qDebug() << "searchTable calls duration:" << timer.elapsed() << "ms";
if( artists.length() == 0 || tracks.length() == 0 ) if( artists.length() == 0 || tracks.length() == 0 )
{ {
//qDebug() << "No candidates found in first pass, aborting resolve" << artistname << trackname; //qDebug() << "No candidates found in first pass, aborting resolve" << artistname << trackname;
@@ -145,7 +143,7 @@ DatabaseCommand_Resolve::exec( DatabaseImpl* lib )
{ {
//qDebug() << "Skipping result for offline sourceid:" << files_query.value( 13 ).toUInt(); //qDebug() << "Skipping result for offline sourceid:" << files_query.value( 13 ).toUInt();
// will happen for valid sources which are offline (and thus not in the sourcelist) // will happen for valid sources which are offline (and thus not in the sourcelist)
return; continue;
} }
m.insert( "url", QString( "servent://%1\t%2" ).arg( s->userName() ).arg( url_str ) ); m.insert( "url", QString( "servent://%1\t%2" ).arg( s->userName() ).arg( url_str ) );

View File

@@ -18,6 +18,7 @@
#include "sourcelist.h" #include "sourcelist.h"
#include "portfwdthread.h" #include "portfwdthread.h"
#include "tomahawksettings.h"
using namespace Tomahawk; using namespace Tomahawk;
@@ -82,30 +83,38 @@ Servent::startListening( QHostAddress ha, bool upnp, int port )
} }
// --lanhack means to advertise your LAN IP over jabber as if it were externallyVisible // --lanhack means to advertise your LAN IP over jabber as if it were externallyVisible
if( qApp->arguments().contains( "--lanhack" ) ) switch( TomahawkSettings::instance()->externalAddressMode() )
{ {
QList<QHostAddress> ifs = QNetworkInterface::allAddresses(); case TomahawkSettings::Lan:
foreach( QHostAddress ha, ifs ) foreach( QHostAddress ha, QNetworkInterface::allAddresses() )
{ {
if( ha.toString() == "127.0.0.1" ) continue; if( ha.toString() == "127.0.0.1" ) continue;
if( ha.toString().contains( ":" ) ) continue; //ipv6 if( ha.toString().contains( ":" ) ) continue; //ipv6
m_externalAddress = ha; m_externalAddress = ha;
m_externalPort = m_port; m_externalPort = m_port;
qDebug() << "LANHACK: set external address to lan address" << ha.toString(); qDebug() << "LANHACK: set external address to lan address" << ha.toString();
break;
}
break; break;
}
} case TomahawkSettings::DynDns:
else if( upnp ) qDebug() << "External address mode set to dyndns...";
{ m_externalHostname = TomahawkSettings::instance()->externalHostname();
// TODO check if we have a public/internet IP on this machine directly m_externalPort = TomahawkSettings::instance()->externalPort();
m_portfwd = new PortFwdThread( m_port ); qDebug() << m_externalHostname << m_externalPort;
connect( m_portfwd, SIGNAL( externalAddressDetected( QHostAddress, unsigned int ) ), break;
SLOT( setExternalAddress( QHostAddress, unsigned int ) ) );
} case TomahawkSettings::Upnp:
else // TODO check if we have a public/internet IP on this machine directly
{ qDebug() << "External address mode set to upnp....";
emit ready(); m_portfwd = new PortFwdThread( m_port );
connect( m_portfwd, SIGNAL( externalAddressDetected( QHostAddress, unsigned int ) ),
SLOT( setExternalAddress( QHostAddress, unsigned int ) ) );
break;
default:
emit ready();
} }
return true; return true;

View File

@@ -4,7 +4,7 @@
// port for servent to listen on // port for servent to listen on
#define DEFAULT_LISTEN_PORT 50210 #define DEFAULT_LISTEN_PORT 50210
// time before new connection terminates if no auth received // time before new connection terminates if no auth received
#define AUTH_TIMEOUT 15000 #define AUTH_TIMEOUT 180000
#include <QObject> #include <QObject>
#include <QTcpServer> #include <QTcpServer>
@@ -90,8 +90,8 @@ public:
void connectToPeer( const QString& ha, int port, const QString &key, Connection* conn ); void connectToPeer( const QString& ha, int port, const QString &key, Connection* conn );
void reverseOfferRequest( ControlConnection* orig_conn, const QString& key, const QString& theirkey ); void reverseOfferRequest( ControlConnection* orig_conn, const QString& key, const QString& theirkey );
bool visibleExternally() const { return m_externalPort > 0 && !m_externalAddress.isNull(); } bool visibleExternally() const { return !m_externalHostname.isNull() || (m_externalPort > 0 && !m_externalAddress.isNull()); }
QHostAddress externalAddress() const { return m_externalAddress; } QString externalAddress() const { return !m_externalHostname.isNull() ? m_externalHostname : m_externalAddress.toString(); }
int externalPort() const { return m_externalPort; } int externalPort() const { return m_externalPort; }
QSharedPointer<QIODevice> remoteIODeviceFactory( const Tomahawk::result_ptr& ); QSharedPointer<QIODevice> remoteIODeviceFactory( const Tomahawk::result_ptr& );
@@ -142,6 +142,7 @@ private:
QMap< QString, QPointer<Connection> > m_offers; QMap< QString, QPointer<Connection> > m_offers;
int m_port, m_externalPort; int m_port, m_externalPort;
QHostAddress m_externalAddress; QHostAddress m_externalAddress;
QString m_externalHostname;
// currently active file transfers: // currently active file transfers:
QList< FileTransferConnection* > m_ftsessions; QList< FileTransferConnection* > m_ftsessions;

View File

@@ -2,8 +2,10 @@
#include <QDebug> #include <QDebug>
#include <QDragEnterEvent> #include <QDragEnterEvent>
#include <QPainter>
#include "playlist/collectionproxymodel.h" #include "playlist/collectionproxymodel.h"
#include "widgets/overlaywidget.h"
using namespace Tomahawk; using namespace Tomahawk;
@@ -69,3 +71,17 @@ CollectionView::onCustomContextMenu( const QPoint& pos )
m_itemMenu.exec( mapToGlobal( pos ) ); m_itemMenu.exec( mapToGlobal( pos ) );
} }
void
CollectionView::paintEvent( QPaintEvent* event )
{
TrackView::paintEvent( event );
QPainter painter( viewport() );
if ( !model()->trackCount() )
{
overlay()->setText( tr( "This collection is empty." ) );
overlay()->paint( &painter );
}
}

View File

@@ -20,6 +20,7 @@ private slots:
protected: protected:
virtual void dragEnterEvent( QDragEnterEvent* event ); virtual void dragEnterEvent( QDragEnterEvent* event );
void paintEvent( QPaintEvent* event );
private: private:
void setupMenus(); void setupMenus();

View File

@@ -2,8 +2,10 @@
#include <QDebug> #include <QDebug>
#include <QKeyEvent> #include <QKeyEvent>
#include <QPainter>
#include "playlist/playlistproxymodel.h" #include "playlist/playlistproxymodel.h"
#include "widgets/overlaywidget.h"
using namespace Tomahawk; using namespace Tomahawk;
@@ -105,3 +107,17 @@ PlaylistView::deleteItems()
{ {
proxyModel()->removeIndexes( selectedIndexes() ); proxyModel()->removeIndexes( selectedIndexes() );
} }
void
PlaylistView::paintEvent( QPaintEvent* event )
{
TrackView::paintEvent( event );
QPainter painter( viewport() );
if ( !model()->trackCount() )
{
overlay()->setText( tr( "This playlist is currently empty. Add some tracks to it and enjoy the music!" ) );
overlay()->paint( &painter );
}
}

View File

@@ -19,6 +19,7 @@ public:
protected: protected:
void keyPressEvent( QKeyEvent* event ); void keyPressEvent( QKeyEvent* event );
void paintEvent( QPaintEvent* event );
private slots: private slots:
void onCustomContextMenu( const QPoint& pos ); void onCustomContextMenu( const QPoint& pos );

View File

@@ -30,6 +30,7 @@ public:
virtual Tomahawk::result_ptr siblingItem( int itemsAway ); virtual Tomahawk::result_ptr siblingItem( int itemsAway );
virtual QString filter() const { return filterRegExp().pattern(); }
virtual void setFilter( const QString& pattern ); virtual void setFilter( const QString& pattern );
virtual PlaylistInterface::RepeatMode repeatMode() const { return m_repeatMode; } virtual PlaylistInterface::RepeatMode repeatMode() const { return m_repeatMode; }

View File

@@ -7,6 +7,7 @@
#include "audio/audioengine.h" #include "audio/audioengine.h"
#include "utils/tomahawkutils.h" #include "utils/tomahawkutils.h"
#include "widgets/overlaywidget.h"
#include "trackheader.h" #include "trackheader.h"
#include "playlistmanager.h" #include "playlistmanager.h"
@@ -23,6 +24,7 @@ TrackView::TrackView( QWidget* parent )
, m_proxyModel( 0 ) , m_proxyModel( 0 )
, m_delegate( 0 ) , m_delegate( 0 )
, m_header( new TrackHeader( this ) ) , m_header( new TrackHeader( this ) )
, m_overlay( new OverlayWidget( this ) )
, m_resizing( false ) , m_resizing( false )
{ {
setSortingEnabled( false ); setSortingEnabled( false );
@@ -54,6 +56,8 @@ TrackView::TrackView( QWidget* parent )
TrackView::~TrackView() TrackView::~TrackView()
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
delete m_overlay;
} }
@@ -245,11 +249,18 @@ void
TrackView::paintEvent( QPaintEvent* event ) TrackView::paintEvent( QPaintEvent* event )
{ {
QTreeView::paintEvent( event ); QTreeView::paintEvent( event );
QPainter painter( viewport() );
if ( !proxyModel()->filter().isEmpty() && !proxyModel()->trackCount() &&
model()->trackCount() )
{
m_overlay->setText( tr( "Sorry, your filter '%1' did not match any results." ).arg( proxyModel()->filter() ) );
m_overlay->paint( &painter );
}
if ( m_dragging ) if ( m_dragging )
{ {
// draw drop indicator // draw drop indicator
QPainter painter( viewport() );
{ {
// draw indicator for inserting items // draw indicator for inserting items
QBrush blendedBrush = viewOptions().palette.brush( QPalette::Normal, QPalette::Highlight ); QBrush blendedBrush = viewOptions().palette.brush( QPalette::Normal, QPalette::Highlight );

View File

@@ -12,6 +12,7 @@ class PlaylistInterface;
class TrackHeader; class TrackHeader;
class TrackModel; class TrackModel;
class TrackProxyModel; class TrackProxyModel;
class OverlayWidget;
class DLLEXPORT TrackView : public QTreeView class DLLEXPORT TrackView : public QTreeView
{ {
@@ -23,10 +24,11 @@ public:
void setProxyModel( TrackProxyModel* model ); void setProxyModel( TrackProxyModel* model );
TrackModel* model() { return m_model; } TrackModel* model() const { return m_model; }
TrackProxyModel* proxyModel() { return m_proxyModel; } TrackProxyModel* proxyModel() const { return m_proxyModel; }
PlaylistItemDelegate* delegate() { return m_delegate; } PlaylistItemDelegate* delegate() const { return m_delegate; }
TrackHeader* header() { return m_header; } TrackHeader* header() const { return m_header; }
OverlayWidget* overlay() const { return m_overlay; }
void setModel( TrackModel* model ); void setModel( TrackModel* model );
@@ -61,6 +63,7 @@ private:
TrackProxyModel* m_proxyModel; TrackProxyModel* m_proxyModel;
PlaylistItemDelegate* m_delegate; PlaylistItemDelegate* m_delegate;
TrackHeader* m_header; TrackHeader* m_header;
OverlayWidget* m_overlay;
bool m_resizing; bool m_resizing;
bool m_dragging; bool m_dragging;

View File

@@ -297,17 +297,41 @@ TomahawkSettings::setJabberPassword( const QString& pw )
} }
bool TomahawkSettings::ExternalAddressMode
TomahawkSettings::upnpEnabled() const TomahawkSettings::externalAddressMode() const
{ {
return value( "network/upnp", true ).toBool(); return (TomahawkSettings::ExternalAddressMode) value( "network/external-address-mode", TomahawkSettings::Upnp ).toInt();
} }
void void
TomahawkSettings::setUPnPEnabled( bool enable ) TomahawkSettings::setExternalAddressMode( ExternalAddressMode externalAddressMode )
{ {
setValue( "network/upnp", enable ); setValue( "network/external-address-mode", externalAddressMode );
}
QString
TomahawkSettings::externalHostname() const
{
return value( "network/external-hostname" ).toString();
}
void
TomahawkSettings::setExternalHostname(const QString& externalHostname)
{
setValue( "network/external-hostname", externalHostname );
}
int
TomahawkSettings::externalPort() const
{
return value( "network/external-port" ).toInt();
}
void
TomahawkSettings::setExternalPort(int externalPort)
{
setValue( "network/external-port", externalPort);
} }
@@ -328,14 +352,14 @@ TomahawkSettings::setLastFmPassword( const QString& password )
QByteArray QByteArray
TomahawkSettings::lastFmSessionKey() const TomahawkSettings::lastFmSessionKey() const
{ {
return value( "lastfm/sessionkey" ).toByteArray(); return value( "lastfm/session" ).toByteArray();
} }
void void
TomahawkSettings::setLastFmSessionKey( const QByteArray& key ) TomahawkSettings::setLastFmSessionKey( const QByteArray& key )
{ {
setValue( "lastfm/sessionkey", key ); setValue( "lastfm/session", key );
} }

View File

@@ -55,11 +55,18 @@ public:
void setJabberPort( int port ); void setJabberPort( int port );
/// Network settings /// Network settings
enum ExternalAddressMode { Lan, DynDns, Upnp };
ExternalAddressMode externalAddressMode() const;
void setExternalAddressMode(ExternalAddressMode externalAddressMode);
bool httpEnabled() const; /// true by default bool httpEnabled() const; /// true by default
void setHttpEnabled( bool enable ); void setHttpEnabled( bool enable );
bool upnpEnabled() const; /// true by default QString externalHostname() const;
void setUPnPEnabled( bool enable ); void setExternalHostname( const QString& externalHostname );
int externalPort() const;
void setExternalPort( int externalPort );
QString proxyHost() const; QString proxyHost() const;
void setProxyHost( const QString &host ); void setProxyHost( const QString &host );

View File

@@ -11,6 +11,8 @@
#include "database/databasecommand_alltracks.h" #include "database/databasecommand_alltracks.h"
#include "database/databasecommand_allalbums.h" #include "database/databasecommand_allalbums.h"
#include "widgets/overlaywidget.h"
SourceInfoWidget::SourceInfoWidget( const Tomahawk::source_ptr& source, QWidget* parent ) SourceInfoWidget::SourceInfoWidget( const Tomahawk::source_ptr& source, QWidget* parent )
: QWidget( parent ) : QWidget( parent )
@@ -19,6 +21,7 @@ SourceInfoWidget::SourceInfoWidget( const Tomahawk::source_ptr& source, QWidget*
ui->setupUi( this ); ui->setupUi( this );
ui->sourceLabel->setText( source->friendlyName() ); ui->sourceLabel->setText( source->friendlyName() );
ui->historyView->overlay()->setEnabled( false );
m_recentCollectionModel = new CollectionFlatModel( ui->recentCollectionView ); m_recentCollectionModel = new CollectionFlatModel( ui->recentCollectionView );
ui->recentCollectionView->setModel( m_recentCollectionModel ); ui->recentCollectionView->setModel( m_recentCollectionModel );

View File

@@ -9,6 +9,8 @@
#include "playlist/playlistmanager.h" #include "playlist/playlistmanager.h"
#include "playlist/playlistmodel.h" #include "playlist/playlistmodel.h"
#include "widgets/overlaywidget.h"
#include "pipeline.h" #include "pipeline.h"
#include "utils/xspfloader.h" #include "utils/xspfloader.h"
@@ -23,17 +25,20 @@ NewPlaylistWidget::NewPlaylistWidget( QWidget* parent )
{ {
ui->setupUi( this ); ui->setupUi( this );
QPushButton* saveButton = new QPushButton( tr( "&Create Playlist" ) ); m_saveButton = new QPushButton( tr( "&Create Playlist" ) );
saveButton->setDefault( true ); m_saveButton->setDefault( true );
m_saveButton->setEnabled( false );
ui->buttonBox->addButton( saveButton, QDialogButtonBox::AcceptRole ); ui->buttonBox->addButton( m_saveButton, QDialogButtonBox::AcceptRole );
connect( ui->tagEdit, SIGNAL( textChanged( QString ) ), SLOT( tagChanged() ) ); connect( ui->titleEdit, SIGNAL( textChanged( QString ) ), SLOT( onTitleChanged( QString ) ) );
connect( ui->tagEdit, SIGNAL( textChanged( QString ) ), SLOT( onTagChanged() ) );
connect( ui->buttonBox, SIGNAL( accepted() ), SLOT( savePlaylist() ) ); connect( ui->buttonBox, SIGNAL( accepted() ), SLOT( savePlaylist() ) );
connect( ui->buttonBox, SIGNAL( rejected() ), SLOT( cancel() ) ); connect( ui->buttonBox, SIGNAL( rejected() ), SLOT( cancel() ) );
m_suggestionsModel = new PlaylistModel( ui->suggestionsView ); m_suggestionsModel = new PlaylistModel( ui->suggestionsView );
ui->suggestionsView->setModel( m_suggestionsModel ); ui->suggestionsView->setModel( m_suggestionsModel );
ui->suggestionsView->overlay()->setEnabled( false );
connect( &m_filterTimer, SIGNAL( timeout() ), SLOT( updateSuggestions() ) ); connect( &m_filterTimer, SIGNAL( timeout() ), SLOT( updateSuggestions() ) );
} }
@@ -62,7 +67,14 @@ NewPlaylistWidget::changeEvent( QEvent* e )
void void
NewPlaylistWidget::tagChanged() NewPlaylistWidget::onTitleChanged( const QString& title )
{
m_saveButton->setEnabled( !title.isEmpty() );
}
void
NewPlaylistWidget::onTagChanged()
{ {
m_tag = ui->tagEdit->text(); m_tag = ui->tagEdit->text();

View File

@@ -10,6 +10,7 @@
#include "dllmacro.h" #include "dllmacro.h"
class QPushButton;
class PlaylistModel; class PlaylistModel;
namespace Ui namespace Ui
@@ -32,7 +33,9 @@ signals:
void destroyed( QWidget* widget ); void destroyed( QWidget* widget );
private slots: private slots:
void tagChanged(); void onTitleChanged( const QString& title );
void onTagChanged();
void updateSuggestions(); void updateSuggestions();
void suggestionsFound(); void suggestionsFound();
@@ -47,6 +50,7 @@ private:
QTimer m_filterTimer; QTimer m_filterTimer;
QString m_tag; QString m_tag;
QPushButton* m_saveButton;
}; };
#endif // NEWPLAYLISTWIDGET_H #endif // NEWPLAYLISTWIDGET_H

View File

@@ -0,0 +1,115 @@
#include "overlaywidget.h"
#include <QDebug>
#include <QPainter>
#include <QPropertyAnimation>
#define CORNER_ROUNDNESS 32.0
#define FADEIN_DURATION 500
#define FONT_SIZE 18
#define OPACITY 0.80
OverlayWidget::OverlayWidget( QAbstractItemView* parent )
: QWidget() // this is on purpose!
, m_parent( parent )
{
resize( 380, 220 );
setAttribute( Qt::WA_TranslucentBackground, true );
}
OverlayWidget::~OverlayWidget()
{
}
void
OverlayWidget::setOpacity( qreal opacity )
{
m_opacity = opacity;
m_parent->reset();
}
void
OverlayWidget::setText( const QString& text )
{
if ( text == m_text )
return;
if ( isEnabled() )
{
QPropertyAnimation* animation = new QPropertyAnimation( this, "opacity" );
animation->setDuration( FADEIN_DURATION );
animation->setStartValue( 0.00 );
animation->setEndValue( OPACITY );
animation->start();
}
else
m_opacity = OPACITY;
m_text = text;
m_pixmap = QPixmap();
}
QPixmap
OverlayWidget::pixmap()
{
if ( m_pixmap.isNull() )
{
QPixmap p( contentsRect().size() );
p.fill( Qt::transparent );
render( &p );
m_pixmap = p;
}
return m_pixmap;
}
void
OverlayWidget::paint( QPainter* painter )
{
if ( !isEnabled() )
return;
pixmap(); // cache the image
QRect center( QPoint( ( painter->viewport().width() - m_pixmap.width() ) / 2,
( painter->viewport().height() - m_pixmap.height() ) / 2 ), m_pixmap.size() );
painter->save();
painter->setOpacity( m_opacity );
painter->drawPixmap( center, m_pixmap );
painter->restore();
}
void
OverlayWidget::paintEvent( QPaintEvent* event )
{
QPainter p( this );
QRect r = contentsRect();
p.setBackgroundMode( Qt::TransparentMode );
p.setRenderHint( QPainter::Antialiasing );
p.setPen( palette().shadow().color() );
p.setBrush( palette().shadow() );
p.drawRoundedRect( r, CORNER_ROUNDNESS, CORNER_ROUNDNESS );
QTextOption to( Qt::AlignCenter );
to.setWrapMode( QTextOption::WrapAtWordBoundaryOrAnywhere );
QFont f( font() );
f.setPixelSize( FONT_SIZE );
f.setBold( true );
p.setFont( f );
p.setPen( palette().light().color() );
p.drawText( r.adjusted( 16, 16, -16, -16 ), text(), to );
}

View File

@@ -0,0 +1,40 @@
#ifndef OVERLAYWIDGET_H
#define OVERLAYWIDGET_H
#include <QWidget>
#include <QAbstractItemView>
#include "dllmacro.h"
class DLLEXPORT OverlayWidget : public QWidget
{
Q_OBJECT
Q_PROPERTY( qreal opacity READ opacity WRITE setOpacity )
public:
OverlayWidget( QAbstractItemView* parent );
~OverlayWidget();
QPixmap pixmap();
qreal opacity() const { return m_opacity; }
void setOpacity( qreal opacity );
QString text() const { return m_text; }
void setText( const QString& text );
void paint( QPainter* painter );
protected:
// void changeEvent( QEvent* e );
void paintEvent( QPaintEvent* event );
private:
QString m_text;
QPixmap m_pixmap;
qreal m_opacity;
QAbstractItemView* m_parent;
};
#endif // WELCOMEWIDGET_H

View File

@@ -6,6 +6,8 @@
#include "playlist/playlistmanager.h" #include "playlist/playlistmanager.h"
#include "playlist/playlistmodel.h" #include "playlist/playlistmodel.h"
#include "widgets/overlaywidget.h"
#include "sourcelist.h" #include "sourcelist.h"
#include "tomahawksettings.h" #include "tomahawksettings.h"
@@ -19,7 +21,9 @@ WelcomeWidget::WelcomeWidget( QWidget* parent )
, ui( new Ui::WelcomeWidget ) , ui( new Ui::WelcomeWidget )
{ {
ui->setupUi( this ); ui->setupUi( this );
ui->playlistWidget->setItemDelegate( new PlaylistDelegate() ); ui->playlistWidget->setItemDelegate( new PlaylistDelegate() );
ui->tracksView->overlay()->setEnabled( false );
m_tracksModel = new PlaylistModel( ui->tracksView ); m_tracksModel = new PlaylistModel( ui->tracksView );
ui->tracksView->setModel( m_tracksModel ); ui->tracksView->setModel( m_tracksModel );

View File

@@ -28,8 +28,16 @@ Scrobbler::Scrobbler( QObject* parent )
, m_reachedScrobblePoint( false ) , m_reachedScrobblePoint( false )
, m_authJob( 0 ) , m_authJob( 0 )
{ {
lastfm::ws::ApiKey = "2aa1089093868876bba20b0482b9cef9"; /*
lastfm::ws::SharedSecret = "a7085ef81d7b46fe6ffe11c15b85902f"; Your API Key is 7194b85b6d1f424fe1668173a78c0c4a
Your secret is ba80f1df6d27ae63e9cb1d33ccf2052f
*/
// Flush session key cache
TomahawkSettings::instance()->setLastFmSessionKey( QByteArray() );
lastfm::ws::ApiKey = "7194b85b6d1f424fe1668173a78c0c4a";
lastfm::ws::SharedSecret = "ba80f1df6d27ae63e9cb1d33ccf2052f";
lastfm::ws::Username = TomahawkSettings::instance()->lastFmUsername(); lastfm::ws::Username = TomahawkSettings::instance()->lastFmUsername();
m_pw = TomahawkSettings::instance()->lastFmPassword(); m_pw = TomahawkSettings::instance()->lastFmPassword();
@@ -192,7 +200,7 @@ Scrobbler::onAuthenticated()
TomahawkSettings::instance()->setLastFmSessionKey( lastfm::ws::SessionKey.toLatin1() ); TomahawkSettings::instance()->setLastFmSessionKey( lastfm::ws::SessionKey.toLatin1() );
if( TomahawkSettings::instance()->scrobblingEnabled() ) if( TomahawkSettings::instance()->scrobblingEnabled() )
m_scrobbler = new lastfm::Audioscrobbler( "tst" ); m_scrobbler = new lastfm::Audioscrobbler( "thk" );
} }
} }
else else
@@ -223,7 +231,7 @@ Scrobbler::createScrobbler()
{ {
lastfm::ws::SessionKey = TomahawkSettings::instance()->lastFmSessionKey(); lastfm::ws::SessionKey = TomahawkSettings::instance()->lastFmSessionKey();
m_scrobbler = new lastfm::Audioscrobbler( "tst" ); m_scrobbler = new lastfm::Audioscrobbler( "thk" );
m_scrobbler->moveToThread( thread() ); m_scrobbler->moveToThread( thread() );
} }
} }

View File

@@ -33,7 +33,7 @@ public slots:
void onAuthenticated(); void onAuthenticated();
private: private:
void scrobble( ); void scrobble();
void createScrobbler(); void createScrobbler();
lastfm::MutableTrack m_track; lastfm::MutableTrack m_track;

View File

@@ -39,7 +39,7 @@ SettingsDialog::SettingsDialog( QWidget *parent )
TomahawkSettings* s = TomahawkSettings::instance(); TomahawkSettings* s = TomahawkSettings::instance();
ui->checkBoxHttp->setChecked( s->httpEnabled() ); ui->checkBoxHttp->setChecked( s->httpEnabled() );
ui->checkBoxUpnp->setChecked( s->upnpEnabled() ); ui->checkBoxUpnp->setChecked( s->externalAddressMode() == TomahawkSettings::Upnp );
// JABBER // JABBER
ui->checkBoxJabberAutoConnect->setChecked( s->jabberAutoConnect() ); ui->checkBoxJabberAutoConnect->setChecked( s->jabberAutoConnect() );
@@ -99,7 +99,7 @@ SettingsDialog::~SettingsDialog()
} }
s->setHttpEnabled( ui->checkBoxHttp->checkState() == Qt::Checked ); s->setHttpEnabled( ui->checkBoxHttp->checkState() == Qt::Checked );
s->setUPnPEnabled( ui->checkBoxUpnp->checkState() == Qt::Checked ); s->setExternalAddressMode(ui->checkBoxUpnp->checkState() == Qt::Checked ? TomahawkSettings::Upnp : TomahawkSettings::Lan);
s->setJabberAutoConnect( ui->checkBoxJabberAutoConnect->checkState() == Qt::Checked ); s->setJabberAutoConnect( ui->checkBoxJabberAutoConnect->checkState() == Qt::Checked );
s->setJabberUsername( ui->jabberUsername->text() ); s->setJabberUsername( ui->jabberUsername->text() );
@@ -201,9 +201,9 @@ SettingsDialog::testLastFmLogin()
{ {
#ifndef NO_LIBLASTFM #ifndef NO_LIBLASTFM
ui->pushButtonTestLastfmLogin->setEnabled( false ); ui->pushButtonTestLastfmLogin->setEnabled( false );
ui->pushButtonTestLastfmLogin->setText( "Testing..." ); ui->pushButtonTestLastfmLogin->setText( "Testing..." );
QString authToken = md5( ( ui->lineEditLastfmUsername->text() + md5( ui->lineEditLastfmPassword->text().toUtf8() ) ).toUtf8() ); QString authToken = md5( ( ui->lineEditLastfmUsername->text() + md5( ui->lineEditLastfmPassword->text().toUtf8() ) ).toUtf8() );
// now authenticate w/ last.fm and get our session key // now authenticate w/ last.fm and get our session key
QMap<QString, QString> query; QMap<QString, QString> query;

View File

@@ -129,7 +129,7 @@ SipHandler::onPeerOnline( const QString& jid )
Servent::instance()->registerOffer( key, conn ); Servent::instance()->registerOffer( key, conn );
m["visible"] = true; m["visible"] = true;
m["ip"] = Servent::instance()->externalAddress().toString(); m["ip"] = Servent::instance()->externalAddress();
m["port"] = Servent::instance()->externalPort(); m["port"] = Servent::instance()->externalPort();
m["key"] = key; m["key"] = key;
m["uniqname"] = nodeid; m["uniqname"] = nodeid;
@@ -181,7 +181,7 @@ SipHandler::onMessage( const QString& from, const QString& msg )
if ( m.value( "visible" ).toBool() ) if ( m.value( "visible" ).toBool() )
{ {
if( !Servent::instance()->visibleExternally() || if( !Servent::instance()->visibleExternally() ||
Servent::instance()->externalAddress().toString() <= m.value( "ip" ).toString() ) Servent::instance()->externalAddress() <= m.value( "ip" ).toString() )
{ {
qDebug() << "Initiate connection to" << from; qDebug() << "Initiate connection to" << from;
Servent::instance()->connectToPeer( m.value( "ip" ).toString(), Servent::instance()->connectToPeer( m.value( "ip" ).toString(),

View File

@@ -105,10 +105,11 @@ SourceTreeView::setupMenus()
if ( readonly ) if ( readonly )
{ {
m_deletePlaylistAction->setEnabled( !readonly ); m_deletePlaylistAction->setEnabled( !readonly );
m_renamePlaylistAction->setEnabled( !readonly );
} }
connect( m_renamePlaylistAction, SIGNAL( triggered() ), SLOT( renamePlaylist() ) );
connect( m_loadPlaylistAction, SIGNAL( triggered() ), SLOT( loadPlaylist() ) ); connect( m_loadPlaylistAction, SIGNAL( triggered() ), SLOT( loadPlaylist() ) );
connect( m_renamePlaylistAction, SIGNAL( triggered() ), SLOT( renamePlaylist() ) );
connect( m_deletePlaylistAction, SIGNAL( triggered() ), SLOT( deletePlaylist() ) ); connect( m_deletePlaylistAction, SIGNAL( triggered() ), SLOT( deletePlaylist() ) );
} }
@@ -141,7 +142,6 @@ SourceTreeView::onItemActivated( const QModelIndex& index )
qDebug() << "SourceTreeItem toggled:" << item->source()->userName(); qDebug() << "SourceTreeItem toggled:" << item->source()->userName();
PlaylistManager::instance()->show( item->source()->collection() ); PlaylistManager::instance()->show( item->source()->collection() );
// APP->playlistManager()->show( item->source() );
} }
} }
} }

View File

@@ -116,15 +116,11 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
setWindowIcon( QIcon( RESPATH "icons/tomahawk-icon-128x128.png" ) ); setWindowIcon( QIcon( RESPATH "icons/tomahawk-icon-128x128.png" ) );
#endif #endif
#ifndef NO_LIBLASTFM
m_scrobbler = 0;
#endif
qDebug() << "TomahawkApp thread:" << this->thread(); qDebug() << "TomahawkApp thread:" << this->thread();
setOrganizationName( "Tomahawk" ); setOrganizationName( "Tomahawk" );
setOrganizationDomain( "tomahawk.org" ); setOrganizationDomain( "tomahawk.org" );
setApplicationName( "Player" ); setApplicationName( "Player" );
setApplicationVersion( "1.0" ); // FIXME: last.fm "tst" auth requires 1.0 version according to docs, will change when we get our own identifier setApplicationVersion( "0.0.0" );
registerMetaTypes(); registerMetaTypes();
setupLogfile(); setupLogfile();
@@ -163,7 +159,8 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
#endif #endif
// Set up proxy // Set up proxy
if( TomahawkSettings::instance()->proxyType() != QNetworkProxy::NoProxy && !TomahawkSettings::instance()->proxyHost().isEmpty() ) if( TomahawkSettings::instance()->proxyType() != QNetworkProxy::NoProxy &&
!TomahawkSettings::instance()->proxyHost().isEmpty() )
{ {
qDebug() << "Setting proxy to saved values"; qDebug() << "Setting proxy to saved values";
TomahawkUtils::setProxy( new QNetworkProxy( static_cast<QNetworkProxy::ProxyType>(TomahawkSettings::instance()->proxyType()), TomahawkSettings::instance()->proxyHost(), TomahawkSettings::instance()->proxyPort(), TomahawkSettings::instance()->proxyUsername(), TomahawkSettings::instance()->proxyPassword() ) ); TomahawkUtils::setProxy( new QNetworkProxy( static_cast<QNetworkProxy::ProxyType>(TomahawkSettings::instance()->proxyType()), TomahawkSettings::instance()->proxyHost(), TomahawkSettings::instance()->proxyPort(), TomahawkSettings::instance()->proxyUsername(), TomahawkSettings::instance()->proxyPassword() ) );
@@ -217,6 +214,8 @@ TomahawkApp::~TomahawkApp()
delete m_mainwindow; delete m_mainwindow;
delete m_audioEngine; delete m_audioEngine;
#endif #endif
delete m_database;
} }
@@ -296,7 +295,7 @@ TomahawkApp::setupDatabase()
} }
qDebug() << "Using database:" << dbpath; qDebug() << "Using database:" << dbpath;
new Database( dbpath, this ); m_database = new Database( dbpath, this );
Pipeline::instance()->databaseReady(); Pipeline::instance()->databaseReady();
} }
@@ -405,7 +404,7 @@ TomahawkApp::setupSIP()
m_xmppBot = new XMPPBot( this ); m_xmppBot = new XMPPBot( this );
m_sipHandler->connect(); m_sipHandler->connect();
// m_sipHandler->setProxy( m_proxy ); // m_sipHandler->setProxy( *TomahawkUtils::proxy() );
} }
} }