00001 #ifndef MYTHTHEMEDMENU_H_
00002 #define MYTHTHEMEDMENU_H_
00003
00004 #include "mythscreentype.h"
00005 #include "mythdialogbox.h"
00006 #include "mythuistatetype.h"
00007 #include "mythuibuttonlist.h"
00008 #include "xmlparsebase.h"
00009
00010 class MythMainWindow;
00011 class MythThemedMenuState;
00012
00013 class QKeyEvent;
00014
00015 struct ThemedButton
00016 {
00017 QString type;
00018 QStringList action;
00019 QString text;
00020 QString description;
00021 MythImage *icon;
00022 bool active;
00023 QString password;
00024 };
00025
00026 struct ButtonIcon
00027 {
00028 QString name;
00029 MythImage *icon;
00030 MythImage *activeicon;
00031 QPoint offset;
00032 };
00033
00034
00039 class MUI_PUBLIC MythThemedMenuState : public MythScreenType
00040 {
00041 public:
00042 MythThemedMenuState(MythScreenStack *parent, const QString &name);
00043 ~MythThemedMenuState();
00044
00045 bool Create(void);
00046
00047 void (*m_callback)(void *, QString &);
00048 void *m_callbackdata;
00049
00050 bool m_killable;
00051
00052 bool m_loaded;
00053 MythUIStateType *m_titleState;
00054 MythUIStateType *m_watermarkState;
00055 MythUIButtonList *m_buttonList;
00056 MythUIText *m_descriptionText;
00057
00058 protected:
00059 void CopyFrom(MythUIType*);
00060 };
00061
00063 class MUI_PUBLIC MythThemedMenu : public MythThemedMenuState
00064 {
00065 Q_OBJECT
00066 public:
00067 MythThemedMenu(const QString &cdir, const QString &menufile,
00068 MythScreenStack *parent, const QString &name,
00069 bool allowreorder = false, MythThemedMenuState *state = NULL);
00070 ~MythThemedMenu();
00071
00072 bool foundTheme(void);
00073
00074 void setCallback(void (*lcallback)(void *, QString &), void *data);
00075 void setKillable(void);
00076
00077 QString getSelection(void);
00078
00079 virtual void aboutToShow(void);
00080
00081 void ShowMenu();
00082 void aboutScreen();
00083 MythDialogBox* m_menuPopup;
00084 void customEvent(QEvent *event);
00085 void mediaEvent(MythMediaEvent *event);
00086
00087 protected:
00088 virtual bool keyPressEvent(QKeyEvent *e);
00089
00090 private slots:
00091 void setButtonActive(MythUIButtonListItem* item);
00092 void buttonAction(MythUIButtonListItem* item, bool skipPass = false);
00093
00094 private:
00095 void Init(const QString &menufile);
00096
00097 bool parseMenu(const QString &menuname);
00098 void parseThemeButton(QDomElement &element);
00099
00100 void addButton(const QString &type, const QString &text,
00101 const QString &alttext, const QStringList &action,
00102 const QString &description, const QString &password);
00103
00104 bool handleAction(const QString &action, const QString &password = QString());
00105 bool findDepends(const QString &fileList);
00106 QString findMenuFile(const QString &menuname);
00107
00108 bool checkPinCode(const QString &password_setting);
00109
00110 MythThemedMenu *m_parent;
00111
00112 MythThemedMenuState *m_state;
00113 bool m_allocedstate;
00114
00115 QString m_selection;
00116 bool m_foundtheme;
00117
00118 bool m_ignorekeys;
00119
00120 bool m_wantpop;
00121
00122 QString m_menumode;
00123 };
00124
00125 Q_DECLARE_METATYPE(ThemedButton)
00126
00127 #endif