1 /* 2 * %kadu copyright begin% 3 * Copyright 2010, 2011 Piotr Galiszewski (piotr.galiszewski@kadu.im) 4 * Copyright 2010 Wojciech Treter (juzefwt@gmail.com) 5 * Copyright 2011, 2014 Bartosz Brachaczek (b.brachaczek@gmail.com) 6 * Copyright 2009, 2010, 2011 Rafał Przemysław Malinowski (rafal.przemyslaw.malinowski@gmail.com) 7 * %kadu copyright end% 8 * 9 * This program is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU General Public License as 11 * published by the Free Software Foundation; either version 2 of 12 * the License, or (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program. If not, see <http://www.gnu.org/licenses/>. 21 */ 22 23 #pragma once 24 25 #include "configuration/configuration-aware-object.h" 26 #include "icons/kadu-icon.h" 27 #include "exports.h" 28 29 #include <QtCore/QMultiMap> 30 #include <QtCore/QPointer> 31 #include <QtWidgets/QAction> 32 #include <injeqt/injeqt.h> 33 34 class ActionContext; 35 class ActionDescription; 36 class Buddy; 37 class BuddySet; 38 class Chat; 39 class Contact; 40 class ContactSet; 41 class IconsManager; 42 class MainWindow; 43 class StatusContainer; 44 45 /** 46 * @addtogroup Actions 47 * @{ 48 */ 49 50 /** 51 * @class Action 52 * @author Rafał 'Vogel' Malinowski 53 * @short QAction extension for Kadu. 54 * 55 * This class is a QAction extendsion for Kadu. It contains additional methods for reveiving data about 56 * contacts, buddies, chats and status containers for current action invocation. It also has methods 57 * for using KaduIcons as icons instead of standard QIcons. 58 */ 59 class KADUAPI Action : public QAction 60 { 61 Q_OBJECT 62 63 public: 64 /** 65 * @author Rafał 'Vogel' Malinowski 66 * @short Creates new Action instance based on ActionDescription with given ActionContext. 67 * @param description description of this action 68 * @param context data source of this action 69 * @param parent parent of this action 70 * 71 * This method creates new instance of Action class. Action is based on description provided as 72 * ActionDescription class (it stored shortcuts, icons, titles and many more information). This 73 * instance of Action will use provided ActionContext instance to get information about Kadu 74 * object like contacts, buddies, chats and status containers that are required to properly 75 * execute each action invocation. 76 * 77 * Provided ActionDescription and ActionContext must not be null. 78 */ 79 Action(ActionDescription *description, ActionContext *context, QObject *parent); 80 virtual ~Action(); 81 82 /** 83 * @author Rafał 'Vogel' Malinowski 84 * @short Returns ActionContext instance for current invocation. 85 * 86 * Returns ActionContext instance for current invocation. Never returns null. 87 */ 88 ActionContext *context(); 89 90 public slots: 91 /** 92 * @author Rafał 'Vogel' Malinowski 93 * @short Calls EnableCallback method from ActionDescription to check if this action should be enabled or not. 94 * 95 * Calls EnableCallback method from ActionDescription to check if this action should be enabled or not. If 96 * EnableCallback from ActionDescription is not available, this action will remain enabled. 97 */ 98 void checkState(); 99 100 /** 101 * @author Rafał 'Vogel' Malinowski 102 * @short Resets icon from ActionDescription. 103 * 104 * Resets icon from ActionDescription. Call this slot when icon set was updated. 105 */ 106 void updateIcon(); 107 108 /** 109 * @author Rafał 'Vogel' Malinowski 110 * @short Sets new icon for this instance of Action. 111 * @param icon new icon 112 * 113 * Sets new icon for this instance of Action. Used for example by StatusChange actions. 114 */ 115 void setIcon(const KaduIcon &icon); 116 117 signals: 118 /** 119 * @author Rafał 'Vogel' Malinowski 120 * @short Emited from destructor. 121 * 122 * Emited from destructor. Use with great care. 123 */ 124 void aboutToBeDestroyed(Action *action); 125 126 /** 127 * @author Rafał 'Vogel' Malinowski 128 * @short Emited every time action has changed (status, title, icon). 129 * @param QAction this instance 130 * 131 * Emited every time action has changed (status, title, icon). 132 */ 133 void changed(QAction *action); 134 135 /** 136 * @author Rafał 'Vogel' Malinowski 137 * @short Emited every time action is hovered. 138 * @param QAction this instance 139 * 140 * Emited every time action is hovered. 141 */ 142 void hovered(QAction *action); 143 144 /** 145 * @author Rafał 'Vogel' Malinowski 146 * @short Emited every time action is toggled. 147 * @param QAction this instance 148 * @param checked true if action is toggled 149 * 150 * Emited every time action is toggled. 151 */ 152 void toggled(QAction *action, bool checked); 153 154 /** 155 * @author Rafał 'Vogel' Malinowski 156 * @short Emited every time action is triggered. 157 * @param QAction this instance 158 * @param checked true if action is toggled 159 * 160 * Emited every time action is triggered. ActionDescription class uses this to call its own virtual 161 * protected method. 162 */ 163 void triggered(QAction *action, bool checked = false); 164 165 private: 166 QPointer<IconsManager> m_iconsManager; 167 168 ActionDescription *Description; 169 ActionContext *Context; 170 171 private slots: 172 INJEQT_SET void setIconsManager(IconsManager *iconsManager); 173 INJEQT_INIT void init(); 174 175 void changedSlot(); 176 void hoveredSlot(); 177 void triggeredSlot(bool checked); 178 179 }; 180 181 void disableEmptyContacts(Action *action); 182 void disableNoChat(Action *action); 183 184 /** 185 * @} 186 */ 187