• 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
  • chatwindow
kopeteemoticonaction.cpp
Go to the documentation of this file.
1 /*
2  kopeteemoticonaction.cpp
3 
4  KAction to show the emoticon selector
5 
6  Copyright (c) 2002 by Stefan Gehn <metz AT gehn.net>
7  Copyright (c) 2003 by Martijn Klingens <klingens@kde.org>
8 
9  Kopete (c) 2002-2003 by the Kopete developers <kopete-devel@kde.org>
10 
11  *************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  *************************************************************************
19 */
20 
21 #include "kopeteemoticonaction.h"
22 
23 #include <math.h>
24 
25 #include <kdebug.h>
26 #include <klocale.h>
27 #include <kmenubar.h>
28 #include <kmenu.h>
29 #include <ktoolbar.h>
30 #include <kauthorized.h>
31 #include <kicon.h>
32 #include <kemoticons.h>
33 
34 #include "emoticonselector.h"
35 #include "kopeteemoticons.h"
36 
37 class KopeteEmoticonAction::KopeteEmoticonActionPrivate
38 {
39 public:
40  KopeteEmoticonActionPrivate()
41  {
42  m_popup = new KMenu(0L);
43  emoticonSelector = new EmoticonSelector( m_popup );
44  emoticonSelector->setObjectName( QLatin1String("KopeteEmoticonActionPrivate::emoticonSelector") );
45 //FIXME do it the kde4 way
46 // m_popup->insertItem( static_cast<QObject*>(emoticonSelector) );
47  // TODO: Maybe connect to kopeteprefs and redo list only on config changes
48  QWidgetAction *act = new QWidgetAction(m_popup);
49  act->setDefaultWidget(emoticonSelector);
50  m_popup->addAction(act);
51  connect( m_popup, SIGNAL(aboutToShow()), emoticonSelector, SLOT(prepareList()) );
52  }
53 
54  ~KopeteEmoticonActionPrivate()
55  {
56  delete m_popup;
57  m_popup = 0;
58  }
59 
60  KMenu *m_popup;
61  EmoticonSelector *emoticonSelector;
62 };
63 
64 KopeteEmoticonAction::KopeteEmoticonAction( QObject* parent )
65  : KActionMenu( i18n( "Add Smiley" ), parent )
66 {
67  d = new KopeteEmoticonActionPrivate;
68 
69  // Try to load the icon for our current emoticon theme, when it fails
70  // fall back to our own default
71  QString icon;
72  QHash<QString, QStringList> emoticonsMap = Kopete::Emoticons::self()->theme().emoticonsMap();
73  for( QHash<QString, QStringList>::const_iterator it = emoticonsMap.constBegin();
74  it != emoticonsMap.constEnd(); ++it )
75  {
76  if( ( *it ).contains( ":)" ) || ( *it ).contains( ":-)" ) )
77  {
78  icon = it.key();
79  break;
80  }
81  }
82 
83 
84  setMenu( d->m_popup );
85 
86  if ( icon.isNull() )
87  setIcon( KIcon("emoticon") );
88  else
89  setIcon( KIcon( icon ) );
90 
91  setShortcutConfigurable( false );
92  connect( d->emoticonSelector, SIGNAL(itemSelected(QString)),
93  this, SIGNAL(activated(QString)) );
94 }
95 
96 KopeteEmoticonAction::~KopeteEmoticonAction()
97 {
98 // kDebug(14010) << "KopeteEmoticonAction::~KopeteEmoticonAction()";
99  delete d;
100  d = 0;
101 }
102 
103 #include "kopeteemoticonaction.moc"
104 
105 // vim: set noet ts=4 sts=4 sw=4:
106 
QString::isNull
bool isNull() const
KopeteEmoticonAction::~KopeteEmoticonAction
virtual ~KopeteEmoticonAction()
Definition: kopeteemoticonaction.cpp:96
QWidgetAction
QHash::constEnd
const_iterator constEnd() const
QHash
QObject
emoticonselector.h
QString
QHash::const_iterator
KopeteEmoticonAction::activated
void activated(const QString &item)
QHash::constBegin
const_iterator constBegin() const
KActionMenu
QLatin1String
QWidgetAction::setDefaultWidget
void setDefaultWidget(QWidget *widget)
KopeteEmoticonAction::KopeteEmoticonAction
KopeteEmoticonAction(QObject *parent)
Definition: kopeteemoticonaction.cpp:64
EmoticonSelector
Definition: emoticonselector.h:50
kopeteemoticonaction.h
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