mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-05 08:32:42 +02:00
Pimple SipStatusMessage
This commit is contained in:
parent
eeab7332ad
commit
ad68b7fb04
@ -1,6 +1,7 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2013, Dominik Schmidt <domme@tomahawk-player.org>
|
||||
* Copyright 2013, Uwe L. Korn <uwelk@xhochy.com>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -16,30 +17,32 @@
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "SipStatusMessage.h"
|
||||
#include "SipStatusMessage_p.h"
|
||||
#include "utils/TomahawkUtilsGui.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QTimer>
|
||||
|
||||
QHash< SipStatusMessage::SipStatusMessageType, QPixmap > SipStatusMessagePrivate::s_typesPixmaps = QHash< SipStatusMessage::SipStatusMessageType, QPixmap >();
|
||||
|
||||
SipStatusMessage::SipStatusMessage( SipStatusMessageType statusMessageType, const QString& contactId, const QString& message )
|
||||
: m_contactId( contactId )
|
||||
, m_statusMessageType( statusMessageType )
|
||||
, m_message( message )
|
||||
: d_ptr( new SipStatusMessagePrivate( this, statusMessageType, contactId, message ) )
|
||||
{
|
||||
Q_D( SipStatusMessage );
|
||||
|
||||
// make this temporary for now, as soon as i know how: add ack button
|
||||
m_timer = new QTimer( this );
|
||||
m_timer->setInterval( 8 * 1000 );
|
||||
m_timer->setSingleShot( true );
|
||||
d->timer = new QTimer( this );
|
||||
d->timer->setInterval( 8 * 1000 );
|
||||
d->timer->setSingleShot( true );
|
||||
|
||||
connect( m_timer, SIGNAL( timeout() ), this, SIGNAL( finished() ) );
|
||||
m_timer->start();
|
||||
connect( d->timer, SIGNAL( timeout() ), this, SIGNAL( finished() ) );
|
||||
d->timer->start();
|
||||
|
||||
if( s_typesPixmaps.value( m_statusMessageType ).isNull() )
|
||||
if( SipStatusMessagePrivate::s_typesPixmaps.value( d->statusMessageType ).isNull() )
|
||||
{
|
||||
TomahawkUtils::ImageType imageType;
|
||||
switch( m_statusMessageType )
|
||||
switch( d->statusMessageType )
|
||||
{
|
||||
case SipLoginFailure:
|
||||
case SipInviteFailure:
|
||||
@ -51,7 +54,7 @@ SipStatusMessage::SipStatusMessage( SipStatusMessageType statusMessageType, cons
|
||||
default:
|
||||
imageType = TomahawkUtils::AddContact;
|
||||
}
|
||||
s_typesPixmaps.insert( m_statusMessageType, TomahawkUtils::defaultPixmap( imageType, TomahawkUtils::Original, QSize( 64, 64 ) ) );
|
||||
SipStatusMessagePrivate::s_typesPixmaps.insert( d->statusMessageType, TomahawkUtils::defaultPixmap( imageType, TomahawkUtils::Original, QSize( 64, 64 ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,15 +62,19 @@ SipStatusMessage::SipStatusMessage( SipStatusMessageType statusMessageType, cons
|
||||
QPixmap
|
||||
SipStatusMessage::icon() const
|
||||
{
|
||||
return s_typesPixmaps.value( m_statusMessageType );
|
||||
Q_D( const SipStatusMessage );
|
||||
|
||||
return SipStatusMessagePrivate::s_typesPixmaps.value( d->statusMessageType );
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
SipStatusMessage::mainText() const
|
||||
{
|
||||
Q_D( const SipStatusMessage );
|
||||
|
||||
QString text;
|
||||
switch( m_statusMessageType )
|
||||
switch( d->statusMessageType )
|
||||
{
|
||||
case SipInviteFailure:
|
||||
text = "Could not invite %1. Please check his/her id!";
|
||||
@ -94,9 +101,9 @@ SipStatusMessage::mainText() const
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
|
||||
text = text.arg( m_contactId );
|
||||
text = text.arg( d->contactId );
|
||||
if(text.contains( "%2") )
|
||||
text = text.arg( m_message );
|
||||
text = text.arg( d->message );
|
||||
|
||||
return text;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2013, Dominik Schmidt <domme@tomahawk-player.org>
|
||||
* Copyright 2013, Uwe L. Korn <uwelk@xhochy.com>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -23,9 +24,8 @@
|
||||
#include "DllMacro.h"
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QHash>
|
||||
|
||||
class QTimer;
|
||||
class SipStatusMessagePrivate;
|
||||
|
||||
class DLLEXPORT SipStatusMessage : public JobStatusItem
|
||||
{
|
||||
@ -49,13 +49,8 @@ public:
|
||||
|
||||
bool allowMultiLine() const { return true; }
|
||||
private:
|
||||
QString m_contactId;
|
||||
SipStatusMessageType m_statusMessageType;
|
||||
QString m_message;
|
||||
|
||||
QHash< SipStatusMessageType, QPixmap > s_typesPixmaps;
|
||||
|
||||
QTimer* m_timer;
|
||||
Q_DECLARE_PRIVATE( SipStatusMessage )
|
||||
SipStatusMessagePrivate* d_ptr;
|
||||
};
|
||||
|
||||
#endif // SIPSTATUSMESSAGE_H
|
||||
|
54
src/libtomahawk/sip/SipStatusMessage_p.h
Normal file
54
src/libtomahawk/sip/SipStatusMessage_p.h
Normal file
@ -0,0 +1,54 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2013, Dominik Schmidt <domme@tomahawk-player.org>
|
||||
* Copyright 2013, Uwe L. Korn <uwelk@xhochy.com>
|
||||
*
|
||||
* 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 SIPSTATUSMESSAGE_P_H
|
||||
#define SIPSTATUSMESSAGE_P_H
|
||||
|
||||
#include "SipStatusMessage.h"
|
||||
|
||||
#include <QHash>
|
||||
|
||||
class QTimer;
|
||||
|
||||
class SipStatusMessagePrivate
|
||||
{
|
||||
public:
|
||||
SipStatusMessagePrivate( SipStatusMessage* q, SipStatusMessage::SipStatusMessageType _statusMessageType, const QString& _contactId, const QString& _message )
|
||||
: q_ptr ( q )
|
||||
, contactId( _contactId )
|
||||
, statusMessageType( _statusMessageType )
|
||||
, message( _message )
|
||||
|
||||
{
|
||||
}
|
||||
SipStatusMessage* q_ptr;
|
||||
Q_DECLARE_PUBLIC ( SipStatusMessage )
|
||||
|
||||
private:
|
||||
QString contactId;
|
||||
SipStatusMessage::SipStatusMessageType statusMessageType;
|
||||
QString message;
|
||||
|
||||
static QHash< SipStatusMessage::SipStatusMessageType, QPixmap > s_typesPixmaps;
|
||||
|
||||
QTimer* timer;
|
||||
};
|
||||
|
||||
|
||||
#endif // SIPSTATUSMESSAGE_P_H
|
Loading…
x
Reference in New Issue
Block a user