1 /*
2 Copyright (c) 2012 Montel Laurent <montel@kde.org>
3 based on code from kopete
4
5 This library is free software; you can redistribute it and/or modify it
6 under the terms of the GNU Library General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or (at your
8 option) any later version.
9
10 This library is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 02110-1301, USA.
19 */
20 #include "emoticon-text-edit-action.h"
21 #include "emoticon-text-edit-selector.h"
22 #include "chat-window.h"
23
24 #include <KLocalizedString>
25
26
27 #include <QMenu>
28 #include <QWidgetAction>
29
30 class EmoticonTextEditAction::EmoticonTextEditActionPrivate
31 {
32 public:
EmoticonTextEditActionPrivate(ChatWindow * chatWindow)33 EmoticonTextEditActionPrivate( ChatWindow *chatWindow ) {
34 emoticonMenu = new QMenu();
35 selector = new EmoticonTextEditSelector( chatWindow , emoticonMenu );
36 QWidgetAction *action = new QWidgetAction( emoticonMenu );
37 action->setDefaultWidget( selector );
38 emoticonMenu->addAction( action );
39 connect( emoticonMenu, SIGNAL(aboutToShow()), selector, SLOT(slotCreateEmoticonList()) );
40
41 }
~EmoticonTextEditActionPrivate()42 ~EmoticonTextEditActionPrivate() {
43 delete emoticonMenu;
44 }
45
46 QMenu *emoticonMenu;
47 EmoticonTextEditSelector *selector;
48 };
49
EmoticonTextEditAction(ChatWindow * chatWindow)50 EmoticonTextEditAction::EmoticonTextEditAction( ChatWindow * chatWindow )
51 : KActionMenu( i18n( "Add Smiley" ), chatWindow ), d( new EmoticonTextEditActionPrivate( chatWindow ) )
52 {
53 setMenu( d->emoticonMenu );
54 setIcon( QIcon::fromTheme( QStringLiteral( "face-smile" ) ) );
55 setDelayed( false );
56 connect( d->selector, SIGNAL(itemSelected(QString)),
57 this, SIGNAL(emoticonActivated(QString)) );
58
59 }
60
~EmoticonTextEditAction()61 EmoticonTextEditAction::~EmoticonTextEditAction()
62 {
63 delete d;
64 }
65