mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
* Moved --demo stuff to Source class.
This commit is contained in:
@@ -98,9 +98,6 @@ public:
|
||||
virtual void activate();
|
||||
virtual bool loadUrl( const QString& url );
|
||||
|
||||
// because QApplication::arguments() is expensive
|
||||
bool scrubFriendlyName() const { return m_scrubFriendlyName; }
|
||||
|
||||
public slots:
|
||||
void instanceStarted( KDSingleApplicationGuard::Instance );
|
||||
|
||||
|
@@ -27,6 +27,8 @@
|
||||
#include "database/databasecommand_logplayback.h"
|
||||
#include "database/database.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
@@ -40,6 +42,8 @@ Source::Source( int id, const QString& username )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << id << username;
|
||||
|
||||
m_scrubFriendlyName = qApp->arguments().contains( "--demo" );
|
||||
|
||||
if ( id == 0 )
|
||||
{
|
||||
m_isLocal = true;
|
||||
@@ -98,8 +102,8 @@ Source::friendlyName() const
|
||||
return m_username;
|
||||
|
||||
//TODO: this is a terrible assumption, help me clean this up, mighty muesli!
|
||||
if ( m_friendlyname.contains( "@conference.") )
|
||||
return QString(m_friendlyname).remove( 0, m_friendlyname.lastIndexOf( "/" )+1 ).append(" via MUC");
|
||||
if ( m_friendlyname.contains( "@conference." ) )
|
||||
return QString( m_friendlyname ).remove( 0, m_friendlyname.lastIndexOf( "/" ) + 1 ).append( " via MUC" );
|
||||
|
||||
if ( m_friendlyname.contains( "/tomahawk" ) )
|
||||
return m_friendlyname.left( m_friendlyname.indexOf( "/tomahawk" ) );
|
||||
@@ -108,6 +112,15 @@ Source::friendlyName() const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Source::setFriendlyName( const QString& fname )
|
||||
{
|
||||
m_friendlyname = fname;
|
||||
if ( m_scrubFriendlyName )
|
||||
m_friendlyname = m_friendlyname.split( "@" ).first();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Source::addCollection( const collection_ptr& c )
|
||||
{
|
||||
@@ -164,7 +177,7 @@ Source::dbLoaded( unsigned int id, const QString& fname )
|
||||
qDebug() << Q_FUNC_INFO << id << fname;
|
||||
|
||||
m_id = id;
|
||||
m_friendlyname = fname;
|
||||
setFriendlyName( fname );
|
||||
|
||||
emit syncedWithDatabase();
|
||||
}
|
||||
@@ -225,10 +238,7 @@ Source::onStateChanged( DBSyncConnection::State newstate, DBSyncConnection::Stat
|
||||
unsigned int
|
||||
Source::trackCount() const
|
||||
{
|
||||
if ( m_stats.contains( "numfiles" ) )
|
||||
return m_stats.value( "numfiles" ).toUInt();
|
||||
else
|
||||
return 0;
|
||||
return m_stats.value( "numfiles" ).toUInt();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -53,7 +53,7 @@ public:
|
||||
|
||||
QString userName() const { return m_username; }
|
||||
QString friendlyName() const;
|
||||
void setFriendlyName( const QString& fname ) { m_friendlyname = fname; }
|
||||
void setFriendlyName( const QString& fname );
|
||||
|
||||
collection_ptr collection() const;
|
||||
void addCollection( const Tomahawk::collection_ptr& c );
|
||||
@@ -111,6 +111,7 @@ private:
|
||||
QList< QSharedPointer<Collection> > m_collections;
|
||||
QVariantMap m_stats;
|
||||
QString m_lastOpGuid;
|
||||
bool m_scrubFriendlyName;
|
||||
|
||||
Tomahawk::query_ptr m_currentTrack;
|
||||
QString m_textStatus;
|
||||
|
@@ -47,12 +47,7 @@ SourceTreeItem::SourceTreeItem( const source_ptr& source, QObject* parent )
|
||||
if( source.isNull() )
|
||||
name = tr( "Super Collection" );
|
||||
else
|
||||
{
|
||||
if( TomahawkApp::instance()->scrubFriendlyName() && source->friendlyName().contains( '@' ) )
|
||||
name = source->friendlyName().left( source->friendlyName().indexOf( '@' ) );
|
||||
else
|
||||
name = source->friendlyName();
|
||||
}
|
||||
name = source->friendlyName();
|
||||
|
||||
QStandardItem* item = new QStandardItem( name );
|
||||
item->setIcon( QIcon( RESPATH "images/user-avatar.png" ) );
|
||||
|
@@ -540,7 +540,7 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
||||
QString tracks;
|
||||
int figWidth = 0;
|
||||
|
||||
if ( status )
|
||||
if ( status && sti && !sti->source().isNull() )
|
||||
{
|
||||
tracks = QString::number( sti->source()->trackCount() );
|
||||
figWidth = painter->fontMetrics().width( tracks );
|
||||
|
@@ -150,7 +150,6 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
|
||||
, m_sipHandler( 0 )
|
||||
, m_servent( 0 )
|
||||
, m_shortcutHandler( 0 )
|
||||
, m_scrubFriendlyName( false )
|
||||
, m_mainwindow( 0 )
|
||||
{
|
||||
qDebug() << "TomahawkApp thread:" << this->thread();
|
||||
@@ -193,7 +192,6 @@ TomahawkApp::init()
|
||||
qDebug() << "Init Echonest Factory.";
|
||||
GeneratorFactory::registerFactory( "echonest", new EchonestFactory );
|
||||
|
||||
m_scrubFriendlyName = arguments().contains( "--demo" );
|
||||
// Register shortcut handler for this platform
|
||||
#ifdef Q_WS_MAC
|
||||
m_shortcutHandler = new MacShortcutHandler( this );
|
||||
|
Reference in New Issue
Block a user