00001
00024 #ifndef MYTHCONTROLS_H
00025 #define MYTHCONTROLS_H
00026
00027
00028 #include <QList>
00029 #include <QHash>
00030
00031
00032 #include "mythscreentype.h"
00033
00034 #include "keybindings.h"
00035
00036 class MythUIText;
00037 class MythUIButtonList;
00038 class MythUIButton;
00039 class MythUIImage;
00040 class MythDialogBox;
00041
00042 typedef enum { kActionsByContext, kKeysByContext, kContextsByKey, } ViewType;
00043
00049 class MythControls : public MythScreenType
00050 {
00051 Q_OBJECT
00052
00053 public:
00054
00055 MythControls(MythScreenStack *parent, const char *name);
00056 ~MythControls();
00057
00058 bool Create(void);
00059 void customEvent(QEvent*);
00060
00061 typedef enum
00062 {
00063 kContextList,
00064 kKeyList,
00065 kActionList
00066 } ListType;
00067
00068
00069 QString GetCurrentContext(void);
00070 QString GetCurrentAction(void);
00071 QString GetCurrentKey(void);
00072
00073 protected:
00074 void Teardown(void);
00075
00076
00077 bool LoadUI(void);
00078 void LoadData(const QString &hostname);
00079 void ChangeButtonFocus(int direction);
00080 void ChangeView(void);
00081 void SetListContents(MythUIButtonList *uilist,
00082 const QStringList & contents,
00083 bool arrows = false);
00084 void UpdateRightList(void);
00085
00086 void GrabKey(void);
00087 void DeleteKey(void);
00088 void Save(void) { m_bindings->CommitChanges(); }
00089
00090
00091 uint GetCurrentButton(void);
00092
00093
00094 void ResolveConflict(ActionID *conflict, int error_level,
00095 const QString &key);
00096 QString GetTypeDesc(ListType type) const;
00097
00098 private slots:
00099 void LeftSelected(MythUIButtonListItem*);
00100 void RightSelected(MythUIButtonListItem*);
00101 void LeftPressed(MythUIButtonListItem*);
00102 void RightPressed(MythUIButtonListItem*);
00103 void ActionButtonPressed();
00104 void RefreshKeyInformation(void);
00105 void AddKeyToAction(QString key, bool ignoreconflict = false);
00106
00107 private:
00108 void ShowMenu(void);
00109 void Close(void);
00110
00111 ViewType m_currentView;
00112 MythUIButtonList *m_leftList;
00113 MythUIButtonList *m_rightList;
00114 MythUIText *m_description;
00115 MythUIText *m_leftDescription;
00116 MythUIText *m_rightDescription;
00117 QList<MythUIButton*> m_actionButtons;
00118 MythDialogBox *m_menuPopup;
00119
00120 KeyBindings *m_bindings;
00121 QStringList m_sortedContexts;
00122
00123 QHash<QString, QStringList> m_contexts;
00124 ListType m_leftListType;
00125 ListType m_rightListType;
00126 };
00127
00128
00129 #endif