KTextAddons

emoticontexteditaction.cpp
1/*
2 SPDX-FileCopyrightText: 2012-2024 Laurent Montel <montel@kde.org>
3 based on code from kopete
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7#include "emoticontexteditaction.h"
8#include "emoticontexteditselector.h"
9
10#include <KLocalizedString>
11#include <QIcon>
12#include <QMenu>
13
14#include <QWidgetAction>
15
16using namespace TextEmoticonsWidgets;
17
18class EmoticonTextEditAction::EmoticonTextEditActionPrivate
19{
20public:
21 EmoticonTextEditActionPrivate()
22 : emoticonMenu(new QMenu())
23 {
24 selector = new EmoticonTextEditSelector(emoticonMenu);
25 auto action = new QWidgetAction(emoticonMenu);
26 action->setDefaultWidget(selector);
27 emoticonMenu->addAction(action);
29 }
30
31 ~EmoticonTextEditActionPrivate()
32 {
33 delete emoticonMenu;
34 }
35
36 void setCustomEmojiSupport(bool b);
37 [[nodiscard]] bool customEmojiSupport() const;
38
39 QMenu *const emoticonMenu;
40 EmoticonTextEditSelector *selector = nullptr;
41};
42
43void EmoticonTextEditAction::EmoticonTextEditActionPrivate::setCustomEmojiSupport(bool b)
44{
45 selector->setCustomEmojiSupport(b);
46}
47
48bool EmoticonTextEditAction::EmoticonTextEditActionPrivate::customEmojiSupport() const
49{
50 return selector->customEmojiSupport();
51}
52
53EmoticonTextEditAction::EmoticonTextEditAction(QObject *parent)
54 : KActionMenu(i18n("Add Smiley"), parent)
55 , d(new EmoticonTextEditActionPrivate)
56{
57 delete menu();
58 setMenu(d->emoticonMenu);
59 setIcon(QIcon::fromTheme(QStringLiteral("face-smile")));
60 setPopupMode(QToolButton::InstantPopup);
62}
63
64EmoticonTextEditAction::~EmoticonTextEditAction() = default;
65
67{
68 d->setCustomEmojiSupport(b);
69}
70
72{
73 return d->customEmojiSupport();
74}
75
76#include "moc_emoticontexteditaction.cpp"
bool customEmojiSupport() const
Return whether the custom emoji category is enabled.
void setCustomEmojiSupport(bool b)
Set whether the custom emoji category should be shown.
void insertEmoticon(const QString &)
This signal is emitted each time the user selects an emoji.
void loadEmoticons()
Do all the magic of creating an TextEmoticonsCore::UnicodeEmoticonManager and loading the categories ...
void setCustomEmojiSupport(bool b)
Set whether the custom emoji category should be shown.
void insertEmoji(const QString &character)
This signal is emitted each time the user selects an emoji.
QString i18n(const char *text, const TYPE &arg...)
QIcon fromTheme(const QString &name)
QAction * addAction(const QIcon &icon, const QString &text, Functor functor, const QKeySequence &shortcut)
void aboutToShow()
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * parent() const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QWidgetAction(QObject *parent)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:19:49 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.