MythTV  0.28pre
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
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 "mthreadpool.h"
10 #include "mythuiexp.h"
11 #include "themeinfo.h"
12 
13 #define DEFAULT_UI_THEME "Terra"
14 #define FALLBACK_UI_THEME "MythCenter-wide"
15 
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 
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 
62  void IncludeInCacheSize(MythImage *im);
63  void ExcludeFromCacheSize(MythImage *im);
64 
65  Settings *qtconfig(void);
66 
67  bool IsScreenSetup(void);
68  bool IsTopScreenInitialized(void);
69 
70  // which the user may have set to be different from the raw screen size
71  void GetScreenSettings(float &wmult, float &hmult);
72  void GetScreenSettings(int &width, float &wmult,
73  int &height, float &hmult);
74  void GetScreenSettings(int &xbase, int &width, float &wmult,
75  int &ybase, int &height, float &hmult);
76 
77  // This returns the raw (drawable) screen size
78  void GetScreenBounds(int &xbase, int &ybase, int &width, int &height);
79 
80  // Parse an X11 style command line (-geometry) string
81  static void ParseGeometryOverride(const QString &geometry);
82  bool IsGeometryOverridden(void);
83 
84  QPixmap *LoadScalePixmap(QString filename, bool fromcache = true) MDEPRECATED;
85  QImage *LoadScaleImage(QString filename, bool fromcache = true) MDEPRECATED;
88  MythImage *LoadCacheImage(QString srcfile, QString label,
89  MythPainter *painter,
90  ImageCacheMode cacheMode = kCacheNormal);
91 
92  void ThemeWidget(QWidget *widget);
93 
94  QString FindThemeDir(const QString &themename);
95  QString FindMenuThemeDir(const QString &menuname);
96  QString GetThemeDir(void);
97  QString GetThemeName(void);
98  QStringList GetThemeSearchPath(void);
99  QString GetMenuThemeDir(void);
100  QList<ThemeInfo> GetThemes(ThemeType type);
101 
102  bool FindThemeFile(QString &filename);
103 
104  QFont GetBigFont(void);
105  QFont GetMediumFont(void);
106  QFont GetSmallFont(void);
107 
108  // event wrappers
109  void DisableScreensaver(void);
110  void RestoreScreensaver(void);
111  // Reset screensaver idle time, for input events that X doesn't see
112  // (e.g., lirc)
113  void ResetScreensaver(void);
114 
115  // actually do it
116  void DoDisableScreensaver(void);
117  void DoRestoreScreensaver(void);
118  void DoResetScreensaver(void);
119 
120  // get the current status
121  bool GetScreensaverEnabled(void);
122  bool GetScreenIsAsleep(void);
123 
124  static void SetX11Display(const QString &display);
125  static QString GetX11Display(void);
126 
127  static QString x11_display;
128 
129  static MythUIHelper *getMythUI(void);
130  static void destroyMythUI(void);
131 
132  void AddCurrentLocation(QString location);
133  QString RemoveCurrentLocation(void);
134  QString GetCurrentLocation(bool fullPath = false, bool mainStackOnly = true);
135 
136  MThreadPool *GetImageThreadPool(void);
137 
138  double GetPixelAspectRatio(void) const;
139  QSize GetBaseSize(void) const;
140 
141  void SetFontStretch(int stretch);
142  int GetFontStretch(void) const;
143 
144  protected:
145  MythUIHelper();
146  ~MythUIHelper();
147 
148  private:
149  void SetPalette(QWidget *widget);
150  void InitializeScreenSettings(void);
151 
152  void ClearOldImageCache(void);
153  void RemoveCacheDir(const QString &dirname);
154 
156 
158  QStringList m_currentLocation;
159 };
160 
161 MUI_PUBLIC MythUIHelper *GetMythUI();
162 MUI_PUBLIC void DestroyMythUI();
163 
164 #endif
165