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 Settings;
22 class QPixmap;
23 class QSize;
24 
25 typedef enum ImageCacheMode
26 {
27  kCacheNormal = 0x0,
32 
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 
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  QString GetCacheDirByUrl(QString url);
63 
64  void IncludeInCacheSize(MythImage *im);
65  void ExcludeFromCacheSize(MythImage *im);
66 
67  Settings *qtconfig(void);
68 
69  bool IsScreenSetup(void);
70  bool IsTopScreenInitialized(void);
71 
72  // which the user may have set to be different from the raw screen size
73  void GetScreenSettings(float &wmult, float &hmult);
74  void GetScreenSettings(int &width, float &wmult,
75  int &height, float &hmult);
76  void GetScreenSettings(int &xbase, int &width, float &wmult,
77  int &ybase, int &height, float &hmult);
78 
79  // This returns the raw (drawable) screen size
80  void GetScreenBounds(int &xbase, int &ybase, int &width, int &height);
81 
82  // Parse an X11 style command line (-geometry) string
83  static void ParseGeometryOverride(const QString &geometry);
84  bool IsGeometryOverridden(void);
85 
86  QPixmap *LoadScalePixmap(QString filename) MDEPRECATED;
87  QImage *LoadScaleImage(QString filename) MDEPRECATED;
90  MythImage *LoadCacheImage(QString srcfile, QString label,
91  MythPainter *painter,
92  ImageCacheMode cacheMode = kCacheNormal);
93 
94  void ThemeWidget(QWidget *widget);
95 
96  QString FindThemeDir(const QString &themename, bool doFallback = true);
97  QString FindMenuThemeDir(const QString &menuname);
98  QString GetThemeDir(void);
99  QString GetThemeName(void);
100  QStringList GetThemeSearchPath(void);
101  QString GetMenuThemeDir(void);
102  QList<ThemeInfo> GetThemes(ThemeType type);
103 
104  bool FindThemeFile(QString &filename);
105 
106  QFont GetBigFont(void);
107  QFont GetMediumFont(void);
108  QFont GetSmallFont(void);
109 
110  // event wrappers
111  void DisableScreensaver(void);
112  void RestoreScreensaver(void);
113  // Reset screensaver idle time, for input events that X doesn't see
114  // (e.g., lirc)
115  void ResetScreensaver(void);
116 
117  // actually do it
118  void DoDisableScreensaver(void);
119  void DoRestoreScreensaver(void);
120  void DoResetScreensaver(void);
121 
122  // get the current status
123  bool GetScreensaverEnabled(void);
124  bool GetScreenIsAsleep(void);
125 
126  static void SetX11Display(const QString &display);
127  static QString GetX11Display(void);
128 
129  static QString x11_display;
130 
131  static MythUIHelper *getMythUI(void);
132  static void destroyMythUI(void);
133 
134  void AddCurrentLocation(QString location);
135  QString RemoveCurrentLocation(void);
136  QString GetCurrentLocation(bool fullPath = false, bool mainStackOnly = true);
137 
138  MThreadPool *GetImageThreadPool(void);
139 
140  double GetPixelAspectRatio(void) const;
141  QSize GetBaseSize(void) const;
142 
143  void SetFontStretch(int stretch);
144  int GetFontStretch(void) const;
145 
146  protected:
147  MythUIHelper();
148  ~MythUIHelper();
149 
150  private:
151  void SetPalette(QWidget *widget);
152  void InitializeScreenSettings(void);
153 
154  void ClearOldImageCache(void);
155  void RemoveCacheDir(const QString &dirname);
156  void PruneCacheDir(QString dirname);
157 
159 
161  QStringList m_currentLocation;
162 };
163 
166 
167 #endif
168 
QMutex m_locationLock
Definition: mythuihelper.h:160
ImageCacheMode
Definition: mythuihelper.h:25
const char * filename
Definition: ioapi.h:135
MUI_PUBLIC MythUIHelper * GetMythUI()
MythUIHelperPrivate * d
Definition: mythuihelper.h:158
QStringList m_currentLocation
Definition: mythuihelper.h:161
class MBASE_PUBLIC Settings MDEPRECATED
ThemeType
Definition: themeinfo.h:14
#define MUI_PUBLIC
Definition: mythuiexp.h:9
static QString x11_display
Definition: mythuihelper.h:129
MUI_PUBLIC void DestroyMythUI()