1 /* 2 * Copyright 2007, 2008 Dawid Stawiarski (neeo@kadu.net) 3 * Copyright 2010 Bartosz Brachaczek (b.brachaczek@gmail.com) 4 * Copyright 2004, 2005, 2006, 2007 Marcin Ślusarz (joi@kadu.net) 5 * Copyright 2002, 2003, 2004, 2006 Adrian Smarzewski (adrian@kadu.net) 6 * Copyright 2003, 2004 Tomasz Chiliński (chilek@chilan.com) 7 * Copyright 2007, 2008, 2009, 2010 Rafał Malinowski (rafal.przemyslaw.malinowski@gmail.com) 8 * Copyright 2004, 2008 Michał Podsiadlik (michal@kadu.net) 9 * Copyright 2008, 2009 Piotr Galiszewski (piotrgaliszewski@gmail.com) 10 * Copyright 2003, 2005 Paweł Płuciennik (pawel_p@kadu.net) 11 * Copyright 2003, 2004 Dariusz Jagodzik (mast3r@kadu.net) 12 * %kadu copyright begin% 13 * Copyright 2014 Bartosz Brachaczek (b.brachaczek@gmail.com) 14 * Copyright 2012, 2013, 2014 Rafał Przemysław Malinowski (rafal.przemyslaw.malinowski@gmail.com) 15 * %kadu copyright end% 16 * 17 * This program is free software; you can redistribute it and/or 18 * modify it under the terms of the GNU General Public License as 19 * published by the Free Software Foundation; either version 2 of 20 * the License, or (at your option) any later version. 21 * 22 * This program is distributed in the hope that it will be useful, 23 * but WITHOUT ANY WARRANTY; without even the implied warranty of 24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 * GNU General Public License for more details. 26 * 27 * You should have received a copy of the GNU General Public License 28 * along with this program. If not, see <http://www.gnu.org/licenses/>. 29 */ 30 31 #ifndef EMOTICON_SELECTOR_H 32 #define EMOTICON_SELECTOR_H 33 34 #include <QtWidgets/QScrollArea> 35 36 #include "expander/emoticon-path-provider.h" 37 38 #include "emoticon.h" 39 40 /** 41 * @addtogroup Emoticons 42 * @{ 43 */ 44 45 /** 46 * @class EmoticonSelector 47 * @short Widget displaying grid of EmoticonSelectorButton for provided list of emoticons. 48 */ 49 class EmoticonSelector : public QScrollArea 50 { 51 Q_OBJECT 52 53 QScopedPointer<EmoticonPathProvider> PathProvider; 54 55 void addEmoticonButtons(const QVector<Emoticon> &emoticons, QWidget *mainwidget); 56 void calculatePositionAndSize(const QWidget *activatingWidget, const QWidget *mainwidget); 57 58 private slots: 59 void emoticonClickedSlot(const Emoticon &emoticon); 60 61 protected: 62 virtual bool event(QEvent *e); 63 virtual void keyPressEvent(QKeyEvent *e); 64 65 public: 66 /** 67 * @short Create new EmoticonSelector widget. 68 * @param emoticons emoticons to display 69 * @param pathProvider EmoticonPathProvider used to get image file name for emoticon for popup widget 70 * @param parent parent widget 71 * 72 * This object gets ownership of pathProvider pointer. 73 */ 74 explicit EmoticonSelector(const QVector<Emoticon> &emoticons, EmoticonPathProvider *pathProvider, QWidget *parent = nullptr); 75 virtual ~EmoticonSelector(); 76 77 signals: 78 /** 79 * @short Signal emited when emoticon is clicked. 80 * @param emoticon clicked emoticon 81 */ 82 void emoticonClicked(const Emoticon &emoticon); 83 84 /** 85 * @short Signal emited when emoticon is clicked. 86 * @param emoticon clicked emoticon's trigger text 87 */ 88 void emoticonClicked(const QString &emoticon); 89 90 }; 91 92 /** 93 * @} 94 */ 95 96 #endif // EMOTICON_SELECTOR_H 97