File indexing completed on 2024-03-24 15:43:44

0001 //
0002 // C++ Interface: cMenuManager
0003 //
0004 // Description: Menu manager.
0005 //
0006 /*
0007 Copyright 2006-2011 Tomas Mecir <kmuddy@kmuddy.com>
0008 
0009 This program is free software; you can redistribute it and/or
0010 modify it under the terms of the GNU General Public License as
0011 published by the Free Software Foundation; either version 2 of 
0012 the License, or (at your option) any later version.
0013 
0014 This program is distributed in the hope that it will be useful,
0015 but WITHOUT ANY WARRANTY; without even the implied warranty of
0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017 GNU General Public License for more details.
0018 
0019 You should have received a copy of the GNU General Public License
0020 along with this program.  If not, see <http://www.gnu.org/licenses/>.
0021 */
0022 
0023 #ifndef CMENUMANAGER_H
0024 #define CMENUMANAGER_H
0025 
0026 #include <cactionbase.h>
0027 #include <kmuddy_export.h>
0028 
0029 struct cMenuManagerPrivate;
0030 
0031 class QMenu;
0032 class QAction;
0033 class QMenuBar;
0034 
0035 /**
0036 Menu manager. It manages the menubar, allowing plug-ins to insert items into the menu.
0037 
0038 @author Tomas Mecir
0039 */
0040 class KMUDDY_EXPORT cMenuManager : public cActionBase
0041 {
0042 public:
0043   static cMenuManager *self ();
0044   ~cMenuManager () override;
0045 
0046   /** assign a menubar to the object. It can't work without having one. */
0047   void setMenuBar (QMenuBar *menuBar);
0048 
0049   /** create a position for menus */
0050   void addMenuPosition (const QString &name);
0051   /** create a position for menu items */
0052   void addItemPosition (const QString &name, QMenu *menu);
0053   
0054   /** add a new menu */
0055   void addMenu (QMenu *menu, const QString &label, const QString &position);
0056   /** remove an existing menu */
0057   void removeMenu (QMenu *menu);
0058   
0059   /** plug an action to a given position */
0060   void plug (QAction *action, QString position);
0061   /** unplug an action */
0062   void unplug (QAction *action);
0063 
0064 protected:
0065   cMenuManager ();
0066   
0067   static cMenuManager *_self;
0068   
0069   cMenuManagerPrivate *d;
0070 };
0071 
0072 #endif