diff options
Diffstat (limited to 'src/sq_kipimanager.h')
-rw-r--r-- | src/sq_kipimanager.h | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/src/sq_kipimanager.h b/src/sq_kipimanager.h new file mode 100644 index 0000000..5a47a0c --- /dev/null +++ b/src/sq_kipimanager.h @@ -0,0 +1,121 @@ +/*************************************************************************** + sq_kipimanager.h - description + ------------------- + begin : Feb 5 2007 + copyright : (C) 2007 by Baryshev Dmitry + email : ksquirrel.iv@gmail.com + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + + +#ifndef SQ_KIPIMANAGER_H +#define SQ_KIPIMANAGER_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef Q_MOC_RUN +#define SQ_HAVE_KIPI +#endif // Q_MOC_RUN + +#ifdef SQ_HAVE_KIPI + +#include <tqmap.h> +#include <tqvaluevector.h> + +#include <tdeaction.h> + +#include <libkipi/plugin.h> + +namespace KIPI { class PluginLoader; } + +class TQWidget; + +class TDEPopupMenu; + +/* + * This subclass of TDEActionMenu should know which TDEActions + * are currently plugged in it. + */ +class SQ_ActionMenu : public TDEActionMenu +{ + public: + SQ_ActionMenu(const TQString &text, TQObject *parent = 0, const char *name = 0); + SQ_ActionMenu(const TQString &text, const TQString &icon, TQObject *parent = 0, const char *name = 0); + + /* + * remove() all TDEActions currently plugged. + */ + ~SQ_ActionMenu(); + + /* + * Reimplement insert() to let us remember "ka" + */ + void insert(TDEAction *ka, int index = -1); + + int count() const; + + private: + // Currently plugged TDEActions + TQValueVector<TDEAction *> plugged; +}; + +inline +int SQ_ActionMenu::count() const +{ + return plugged.count(); +} + +/* + * KIPI plugins manager. It loads KIPI plugins and creates popup + * menu with all available actions. + */ +class SQ_KIPIManager : public TQObject +{ + TQ_OBJECT + + + public: + SQ_KIPIManager(TQWidget *_parent, const char *name = 0); + ~SQ_KIPIManager(); + + TDEPopupMenu* popup() const; + + void loadPlugins(); + + private: + void clearMap(); + + private slots: + void slotReplug(); + void slotAboutToShow(); + + private: + typedef TQMap<KIPI::Category, SQ_ActionMenu*> CategoryMap; + + KIPI::PluginLoader *mPluginLoader; + CategoryMap cmenus; + TDEAction *noPlugin; + TQWidget *parent; + TDEPopupMenu *p; + bool loaded; +}; + +inline +TDEPopupMenu* SQ_KIPIManager::popup() const +{ + return p; +} + +#endif + +#endif |