MythTV  0.28pre
mythuihelper.h
Go to the documentation of this file.
1 #ifndef MYTHUIHELPERS_H_
2 #define MYTHUIHELPERS_H_
3 
4 #include <QStringList>
5 #include <QString>
6 #include <QFont>
7 #include <QMutex>
8 
9 #include "mythuiexp.h"
10 #include "themeinfo.h"
11 
12 #define DEFAULT_UI_THEME "MythCenter"
13 #define FALLBACK_UI_THEME "Terra"
14 
16 class MThreadPool;
17 class MythPainter;
18 class MythImage;
19 class QImage;
20 class QWidget;
21 class Settings;
22 class QPixmap;
23 class QSize;
24 
25 typedef enum ImageCacheMode
26 {
27  kCacheNormal = 0x0,
32 
33 struct MUI_PUBLIC MythUIMenuCallbacks
34 {
35  void (*exec_program)(const QString &cmd);
36  void (*exec_program_tv)(const QString &cmd);
37  void (*configplugin)(const QString &cmd);
38  void (*plugin)(const QString &cmd);
39  void (*eject)(void);
40 };
41 
42 class MUI_PUBLIC MythUIHelper
43 {
44  public:
45  void Init(MythUIMenuCallbacks &cbs);
46  void Init(void);
47 
48  MythUIMenuCallbacks *GetMenuCBs(void);
49 
50  void LoadQtConfig(void);
51  void UpdateImageCache(void);
52 
55  MythImage *GetImageFromCache(const QString &url);
56  MythImage *CacheImage(const QString &url, MythImage *im,
57  bool nodisk = false);
58  void RemoveFromCacheByURL(const QString &url);
59  void RemoveFromCacheByFile(const QString &fname);
60  bool IsImageInCache(const QString &url);
61  QString GetThemeCacheDir(void);
62 
63  void IncludeInCacheSize(MythImage *im);
64  void ExcludeFromCacheSize(MythImage *im);
65 
66  Settings *qtconfig(void);
67 
68  bool IsScreenSetup(void);
69  bool IsTopScreenInitialized(void);
70 
71  // which the user may have set to be different from the raw screen size
72  void GetScreenSettings(float &wmult, float &hmult);
73  void GetScreenSettings(int &width, float &wmult,
74  int &height, float &hmult);
75  void GetScreenSettings(int &xbase, int &width, float &wmult,
76  int &ybase, int &height, float &hmult);
77 
78  // This returns the raw (drawable) screen size
79  void GetScreenBounds(int &xbase, int &ybase, int &width, int &height);
80 
81  // Parse an X11 style command line (-geometry) string
82  static void ParseGeometryOverride(const QString &geometry);
83  bool IsGeometryOverridden(void);
84 
85  QPixmap *LoadScalePixmap(QString filename, bool fromcache = true) MDEPRECATED;
86  QImage *LoadScaleImage(QString filename, bool fromcache = true) MDEPRECATED;
89  MythImage *LoadCacheImage(QString srcfile, QString label,
90  MythPainter *painter,
91  ImageCacheMode cacheMode = kCacheNormal);
92 
93  void ThemeWidget(QWidget *widget);
94 
95  QString FindThemeDir(const QString &themename, bool doFallback = true);
96  QString FindMenuThemeDir(const QString &menuname);
97  QString GetThemeDir(void);
98  QString GetThemeName(void);
99  QStringList GetThemeSearchPath(void);
100  QString GetMenuThemeDir(void);
101  QList<ThemeInfo> GetThemes(ThemeType type);
102 
103  bool FindThemeFile(QString &filename);
104 
105  QFont GetBigFont(void);
106  QFont GetMediumFont(void);
107  QFont GetSmallFont(void);
108 
109  // event wrappers
110  void DisableScreensaver(void);
111  void RestoreScreensaver(void);
112  // Reset screensaver idle time, for input events that X doesn't see
113  // (e.g., lirc)
114  void ResetScreensaver(void);
115 
116  // actually do it
117  void DoDisableScreensaver(void);
118  void DoRestoreScreensaver(void);
119  void DoResetScreensaver(void);
120 
121  // get the current status
122  bool GetScreensaverEnabled(void);
123  bool GetScreenIsAsleep(void);
124 
125  static void SetX11Display(const QString &display);
126  static QString GetX11Display(void);
127 
128  static QString x11_display;
129 
130  static MythUIHelper *getMythUI(void);
131  static void destroyMythUI(void);
132 
133  void AddCurrentLocation(QString location);
134  QString RemoveCurrentLocation(void);
135  QString GetCurrentLocation(bool fullPath = false, bool mainStackOnly = true);
136 
137  MThreadPool *GetImageThreadPool(void);
138 
139  double GetPixelAspectRatio(void) const;
140  QSize GetBaseSize(void) const;
141 
142  void SetFontStretch(int stretch);
143  int GetFontStretch(void) const;
144 
145  protected:
146  MythUIHelper();
147  ~MythUIHelper();
148 
149  private:
150  void SetPalette(QWidget *widget);
151  void InitializeScreenSettings(void);
152 
153  void ClearOldImageCache(void);
154  void RemoveCacheDir(const QString &dirname);
155 
157 
159  QStringList m_currentLocation;
160 };
161 
162 MUI_PUBLIC MythUIHelper *GetMythUI();
163 MUI_PUBLIC void DestroyMythUI();
164 
165 #endif
166 
QMutex m_locationLock
Definition: mythuihelper.h:158
ImageCacheMode
Definition: mythuihelper.h:25
const char * filename
Definition: ioapi.h:135
__u32 type
Definition: videodev2.h:1038
MUI_PUBLIC MythUIHelper * GetMythUI()
MythUIHelperPrivate * d
Definition: mythuihelper.h:156
QStringList m_currentLocation
Definition: mythuihelper.h:159
class MBASE_PUBLIC Settings MDEPRECATED
ThemeType
Definition: themeinfo.h:14
__u32 width
Definition: videodev2.h:1038
static QString x11_display
Definition: mythuihelper.h:128
__u32 height
Definition: videodev2.h:1039
MUI_PUBLIC void DestroyMythUI()