1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-01-18 06:48:23 +01:00

Show discreet JobStatusItem for incoming tracks.

This commit is contained in:
Teo Mrnjavac 2013-04-19 22:52:12 +02:00
parent 14fb8a8533
commit 0800aa6ac7
4 changed files with 120 additions and 6 deletions

View File

@ -40,6 +40,7 @@ set( libGuiSources
jobview/LatchedStatusItem.cpp
jobview/ErrorStatusMessage.cpp
jobview/IndexingJobItem.cpp
jobview/InboxJobItem.cpp
infobar/InfoBar.cpp

View File

@ -26,7 +26,7 @@
#include "playlist/InboxModel.h"
#include "jobview/JobStatusView.h"
#include "jobview/JobStatusModel.h"
#include "jobview/ErrorStatusMessage.h"
#include "jobview/InboxJobItem.h"
DatabaseCommand_ShareTrack::DatabaseCommand_ShareTrack( QObject* parent )
: DatabaseCommand_SocialAction( parent )
@ -106,12 +106,9 @@ DatabaseCommand_ShareTrack::postCommitHook()
Q_ARG( const Tomahawk::query_ptr&, m_query ),
Q_ARG( int, 0 ) /*row*/ );
//TODO: replace with a proper JobStatusItem
QString friendlyName = source()->friendlyName();
if( ViewManager::instance()->currentPage() != ViewManager::instance()->inboxWidget() )
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( tr( "%1 recommended %2 by %3" )
.arg( source()->friendlyName() )
.arg( m_query->track() )
.arg( m_query->artist() ) ) );
JobStatusView::instance()->model()->addJob( new InboxJobItem( friendlyName, m_query ) );
}

View File

@ -0,0 +1,65 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
* Copyright 2012, Jeff Mitchell <jeff@tomahawk-player.org>
* Copyright 2013, Teo Mrnjavac <teo@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "InboxJobItem.h"
#include "Query.h"
#include "utils/TomahawkUtilsGui.h"
#include "utils/Logger.h"
#include "audio/AudioEngine.h"
#include <QTimer>
InboxJobItem::InboxJobItem( const QString& sender,
const Tomahawk::query_ptr& query,
QObject* parent )
: JobStatusItem()
, m_query( query )
, m_sender( sender )
{
m_timer = new QTimer( this );
m_timer->setInterval( 8000 );
m_timer->setSingleShot( true );
connect( m_timer, SIGNAL( timeout() ), this, SIGNAL( finished() ) );
m_timer->start();
}
InboxJobItem::~InboxJobItem()
{}
QString
InboxJobItem::mainText() const
{
return tr( "%1 sent you %2 by %3." )
.arg( m_sender )
.arg( m_query->track() )
.arg( m_query->artist() );
}
QPixmap
InboxJobItem::icon() const
{
return TomahawkUtils::defaultPixmap( TomahawkUtils::Inbox, TomahawkUtils::Original, QSize( 64, 64 ) );
}

View File

@ -0,0 +1,51 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
* Copyright 2012, Jeff Mitchell <jeff@tomahawk-player.org>
* Copyright 2013, Teo Mrnjavac <teo@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef INBOXJOBITEM_H
#define INBOXJOBITEM_H
#include "DllMacro.h"
#include "jobview/JobStatusView.h"
#include "jobview/JobStatusItem.h"
class DLLEXPORT InboxJobItem : public JobStatusItem
{
Q_OBJECT
public:
explicit InboxJobItem( const QString& sender, const Tomahawk::query_ptr& query, QObject* parent = 0 );
virtual ~InboxJobItem();
virtual QString rightColumnText() const { return QString(); }
virtual QString mainText() const;
virtual QPixmap icon() const;
virtual QString type() const { return "inboxjob"; }
bool allowMultiLine() const { return true; }
private:
Tomahawk::query_ptr m_query;
QString m_sender;
QTimer* m_timer;
static QPixmap* s_pixmap;
};
#endif // INBOXJOBITEM_H