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