2 kopeteaccountstatusbaricon.cpp - Kopete Account StatusBar Dock Icon
4 Copyright (c) 2008 by Roman Jarosz <kedgedev@centrum.cz>
5 Kopete (c) 2008 by the Kopete developers <kopete-devel@kde.org>
7 *************************************************************************
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
14 *************************************************************************
17 #include "kopeteaccountstatusbaricon.h"
19 #include <QtGui/QToolTip>
20 #include <QtGui/QMouseEvent>
21 #include <QtGui/QMovie>
24 #include <KActionMenu>
28 #include <kopeteaccount.h>
29 #include <kopetecontact.h>
30 #include <kopetestatusrootaction.h>
32 KopeteAccountStatusBarIcon::KopeteAccountStatusBarIcon( Kopete::Account
*account
, QWidget
*parent
)
33 : QLabel( parent
), mAccount(account
), mMovie(0)
35 setFixedSize ( 16, 16 );
36 setCursor(QCursor(Qt::PointingHandCursor
));
38 connect( account
, SIGNAL(colorChanged(const QColor
&)), this, SLOT(statusIconChanged()) );
39 connect( account
->myself(), SIGNAL(onlineStatusChanged(Kopete::Contact
*, const Kopete::OnlineStatus
&, const Kopete::OnlineStatus
&)),
40 this, SLOT(statusIconChanged()) );
45 KopeteAccountStatusBarIcon::~KopeteAccountStatusBarIcon()
54 void KopeteAccountStatusBarIcon::mousePressEvent( QMouseEvent
*event
)
56 KActionMenu
*actionMenu
= new KActionMenu( mAccount
->accountId(), mAccount
);
57 if ( !mAccount
->hasCustomStatusMenu() )
58 Kopete::StatusRootAction::createAccountStatusActions( mAccount
, actionMenu
);
60 mAccount
->fillActionMenu( actionMenu
);
62 actionMenu
->menu()->exec( QPoint( event
->globalX(), event
->globalY() ) );
66 void KopeteAccountStatusBarIcon::statusIconChanged()
68 Kopete::Contact
* myself
= mAccount
->myself();
77 if ( myself
->onlineStatus().status() == Kopete::OnlineStatus::Connecting
&& !myself
->onlineStatus().overlayIcons().isEmpty() )
78 mMovie
= KIconLoader::global()->loadMovie( myself
->onlineStatus().overlayIcons().first(), KIconLoader::Small
);
82 setPixmap( myself
->onlineStatus().iconFor( myself
->account() ).pixmap( 16, 16 ) );
86 mMovie
->setCacheMode( QMovie::CacheAll
);
92 bool KopeteAccountStatusBarIcon::event( QEvent
*event
)
94 if ( event
->type() == QEvent::ToolTip
)
96 QHelpEvent
*helpEvent
= static_cast<QHelpEvent
*>(event
);
97 QToolTip::showText( helpEvent
->globalPos(), mAccount
->myself()->toolTip() );
100 return QLabel::event( event
);
103 #include "kopeteaccountstatusbaricon.moc"