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 
83  QPixmap *LoadScalePixmap(QString filename) MDEPRECATED;
84  QImage *LoadScaleImage(QString filename) MDEPRECATED;
87  MythImage *LoadCacheImage(QString srcfile, QString label,
88  MythPainter *painter,
89  ImageCacheMode cacheMode = kCacheNormal);
90 
91  QString FindThemeDir(const QString &themename, bool doFallback = true);
92  QString FindMenuThemeDir(const QString &menuname);
93  QString GetThemeDir(void);
94  QString GetThemeName(void);
95  QStringList GetThemeSearchPath(void);
96  QString GetMenuThemeDir(void);
97  QList<ThemeInfo> GetThemes(ThemeType type);
98 
99  bool FindThemeFile(QString &filename);
100 
101  QFont GetBigFont(void);
102  QFont GetMediumFont(void);
103  QFont GetSmallFont(void);
104 
105  // event wrappers
106  void DisableScreensaver(void);
107  void RestoreScreensaver(void);
108  // Reset screensaver idle time, for input events that X doesn't see
109  // (e.g., lirc)
110  void ResetScreensaver(void);
111 
112  // actually do it
113  void DoDisableScreensaver(void);
114  void DoRestoreScreensaver(void);
115  void DoResetScreensaver(void);
116 
117  // get the current status
118  bool GetScreensaverEnabled(void);
119  bool GetScreenIsAsleep(void);
120 
121  static void SetX11Display(const QString &display);
122  static QString GetX11Display(void);
123 
124  static QString x11_display;
125 
126  static MythUIHelper *getMythUI(void);
127  static void destroyMythUI(void);
128 
129  void AddCurrentLocation(QString location);
130  QString RemoveCurrentLocation(void);
131  QString GetCurrentLocation(bool fullPath = false, bool mainStackOnly = true);
132 
133  MThreadPool *GetImageThreadPool(void);
134 
135  double GetPixelAspectRatio(void) const;
136  QSize GetBaseSize(void) const;
137 
138  void SetFontStretch(int stretch);
139  int GetFontStretch(void) const;
140 
141  protected:
142  MythUIHelper();
143  ~MythUIHelper();
144 
145  private:
146  void InitializeScreenSettings(void);
147 
148  void ClearOldImageCache(void);
149  void RemoveCacheDir(const QString &dirname);
150  void PruneCacheDir(QString dirname);
151 
153 
155  QStringList m_currentLocation;
156 };
157 
160 
161 #endif
162 
QMutex m_locationLock
Definition: mythuihelper.h:154
ImageCacheMode
Definition: mythuihelper.h:24
const char * filename
Definition: ioapi.h:135
MUI_PUBLIC MythUIHelper * GetMythUI()
MythUIHelperPrivate * d
Definition: mythuihelper.h:152
QStringList m_currentLocation
Definition: mythuihelper.h:155
ThemeType
Definition: themeinfo.h:14
#define MUI_PUBLIC
Definition: mythuiexp.h:9
static QString x11_display
Definition: mythuihelper.h:124
MUI_PUBLIC void DestroyMythUI()
#define MDEPRECATED
Definition: mythexp.h:21