• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

kopete/kopete

  • sources
  • kde-4.14
  • kdenetwork
  • kopete
  • kopete
kopeteaccountstatusbaricon.cpp
Go to the documentation of this file.
1 /*
2  kopeteaccountstatusbaricon.cpp - Kopete Account StatusBar Dock Icon
3 
4  Copyright (c) 2008 by Roman Jarosz <kedgedev@centrum.cz>
5  Kopete (c) 2008 by the Kopete developers <kopete-devel@kde.org>
6 
7  *************************************************************************
8  * *
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. *
13  * *
14  *************************************************************************
15 */
16 
17 #include "kopeteaccountstatusbaricon.h"
18 
19 #include <QtGui/QToolTip>
20 #include <QtGui/QMouseEvent>
21 #include <QtGui/QMovie>
22 
23 #include <KMenu>
24 #include <KActionMenu>
25 #include <KGlobal>
26 #include <KDebug>
27 
28 #include <kopeteaccount.h>
29 #include <kopetecontact.h>
30 #include <kopetestatusrootaction.h>
31 
32 KopeteAccountStatusBarIcon::KopeteAccountStatusBarIcon( Kopete::Account *account, QWidget *parent )
33 : QLabel( parent ), mAccount(account), mMovie(0)
34 {
35  setFixedSize ( 16, 16 );
36  setCursor(QCursor(Qt::PointingHandCursor));
37 
38  connect( account, SIGNAL(colorChanged(QColor)), this, SLOT(statusIconChanged()) );
39  connect( account->myself(), SIGNAL(onlineStatusChanged(Kopete::Contact*,Kopete::OnlineStatus,Kopete::OnlineStatus)),
40  this, SLOT(statusIconChanged()) );
41 
42  statusIconChanged();
43 }
44 
45 KopeteAccountStatusBarIcon::~KopeteAccountStatusBarIcon()
46 {
47  if ( mMovie )
48  {
49  mMovie->stop();
50  delete mMovie;
51  }
52 }
53 
54 void KopeteAccountStatusBarIcon::mousePressEvent( QMouseEvent *event )
55 {
56  KActionMenu *actionMenu = new KActionMenu( mAccount->accountId(), mAccount );
57  if ( !mAccount->hasCustomStatusMenu() )
58  Kopete::StatusRootAction::createAccountStatusActions( mAccount, actionMenu );
59 
60  mAccount->fillActionMenu( actionMenu );
61 
62  actionMenu->menu()->exec( QPoint( event->globalX(), event->globalY() ) );
63  delete actionMenu;
64 }
65 
66 void KopeteAccountStatusBarIcon::statusIconChanged()
67 {
68  Kopete::Contact* myself = mAccount->myself();
69 
70  if ( mMovie )
71  {
72  mMovie->stop();
73  delete mMovie;
74  mMovie = 0;
75  }
76 
77  if ( myself->onlineStatus().status() == Kopete::OnlineStatus::Connecting && !myself->onlineStatus().overlayIcons().isEmpty() )
78  mMovie = KIconLoader::global()->loadMovie( myself->onlineStatus().overlayIcons().first(), KIconLoader::Small );
79 
80  if ( !mMovie )
81  {
82  setPixmap( myself->onlineStatus().iconFor( myself->account() ).pixmap( 16, 16 ) );
83  }
84  else
85  {
86  mMovie->setCacheMode( QMovie::CacheAll );
87  setMovie( mMovie );
88  mMovie->start();
89  }
90 }
91 
92 bool KopeteAccountStatusBarIcon::event( QEvent *event )
93 {
94  if ( event->type() == QEvent::ToolTip )
95  {
96  QHelpEvent *helpEvent = static_cast<QHelpEvent*>(event);
97  QToolTip::showText( helpEvent->globalPos(), mAccount->myself()->toolTip() );
98  }
99 
100  return QLabel::event( event );
101 }
102 
103 #include "kopeteaccountstatusbaricon.moc"
QEvent
QWidget
KopeteAccountStatusBarIcon::~KopeteAccountStatusBarIcon
virtual ~KopeteAccountStatusBarIcon()
Definition: kopeteaccountstatusbaricon.cpp:45
QEvent::type
Type type() const
QWidget::setCursor
void setCursor(const QCursor &)
QMovie::stop
void stop()
QLabel::setPixmap
void setPixmap(const QPixmap &)
QPoint
QMouseEvent
QToolTip::showText
void showText(const QPoint &pos, const QString &text, QWidget *w)
QLabel::event
virtual bool event(QEvent *e)
kopetestatusrootaction.h
QLabel::setMovie
void setMovie(QMovie *movie)
QHelpEvent::globalPos
const QPoint & globalPos() const
KopeteAccountStatusBarIcon::KopeteAccountStatusBarIcon
KopeteAccountStatusBarIcon(Kopete::Account *account, QWidget *parent)
Create a statusbar icon.
Definition: kopeteaccountstatusbaricon.cpp:32
Kopete::StatusRootAction::createAccountStatusActions
static void createAccountStatusActions(Account *account, KActionMenu *parent, QAction *before=0)
insert "setStatus" actions from the given account to the specified actionMenu.
Definition: kopetestatusrootaction.cpp:80
QColor
kopeteaccountstatusbaricon.h
KopeteAccountStatusBarIcon::event
virtual bool event(QEvent *event)
Definition: kopeteaccountstatusbaricon.cpp:92
QWidget::setFixedSize
void setFixedSize(const QSize &s)
QMovie::setCacheMode
void setCacheMode(CacheMode mode)
KopeteAccountStatusBarIcon::mousePressEvent
virtual void mousePressEvent(QMouseEvent *me)
Definition: kopeteaccountstatusbaricon.cpp:54
KActionMenu
QMouseEvent::globalX
int globalX() const
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QLabel
QHelpEvent
QCursor
QMovie::start
void start()
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:29:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kopete/kopete

Skip menu "kopete/kopete"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal