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 
25 {
26  kCacheNormal = 0x0,
30 };
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(const QString& url);
62 
63  void IncludeInCacheSize(MythImage *im);
64  void ExcludeFromCacheSize(MythImage *im);
65 
66  bool IsScreenSetup(void);
67  static bool IsTopScreenInitialized(void);
68 
69  void UpdateScreenSettings(void);
70  // which the user may have set to be different from the raw screen size
71  QRect GetScreenSettings(void);
72  void GetScreenSettings(QRect &Rect, float &XFactor, float &YFactor);
73  void GetScreenSettings(float &XFactor, float &YFactor);
74 
75  // Parse an X11 style command line (-geometry) string
76  static void ParseGeometryOverride(const QString &geometry);
77  static bool IsGeometryOverridden(void);
78  static QRect GetGeometryOverride(void);
79 
82  MythImage *LoadCacheImage(QString srcfile, const QString& label,
83  MythPainter *painter,
84  ImageCacheMode cacheMode = kCacheNormal);
85 
86  QString FindThemeDir(const QString &themename, bool doFallback = true);
87  QString FindMenuThemeDir(const QString &menuname);
88  QString GetThemeDir(void);
89  QString GetThemeName(void);
90  QStringList GetThemeSearchPath(void);
91  QString GetMenuThemeDir(void);
92  QList<ThemeInfo> GetThemes(ThemeType type);
93 
94  bool FindThemeFile(QString &path);
95 
96  static QFont GetBigFont(void);
97  static QFont GetMediumFont(void);
98  static QFont GetSmallFont(void);
99 
100  // event wrappers
101  static void DisableScreensaver(void);
102  static void RestoreScreensaver(void);
103  // Reset screensaver idle time, for input events that X doesn't see
104  // (e.g., lirc)
105  static void ResetScreensaver(void);
106 
107  // actually do it
108  void DoDisableScreensaver(void);
109  void DoRestoreScreensaver(void);
110  void DoResetScreensaver(void);
111 
112  // get the current status
113  bool GetScreensaverEnabled(void);
114  bool GetScreenIsAsleep(void);
115 
116  static void SetX11Display(const QString &display);
117  static QString GetX11Display(void);
118 
119  static QString x11_display;
120 
121  static MythUIHelper *getMythUI(void);
122  static void destroyMythUI(void);
123 
124  void AddCurrentLocation(const QString& location);
125  QString RemoveCurrentLocation(void);
126  QString GetCurrentLocation(bool fullPath = false, bool mainStackOnly = true);
127 
128  MThreadPool *GetImageThreadPool(void);
129  QSize GetBaseSize(void) const;
130 
131  void SetFontStretch(int stretch);
132  int GetFontStretch(void) const;
133 
134  protected:
135  MythUIHelper();
136  ~MythUIHelper();
137 
138  private:
139  void InitializeScreenSettings(void);
140 
141  void ClearOldImageCache(void);
142  void RemoveCacheDir(const QString &dirname);
143  static void PruneCacheDir(const QString& dirname);
144 
145  MythUIHelperPrivate *d {nullptr}; // NOLINT(readability-identifier-naming)
146 
148  QStringList m_currentLocation;
149 };
150 
153 
154 #endif
155 
QMutex m_locationLock
Definition: mythuihelper.h:147
ImageCacheMode
Definition: mythuihelper.h:24
MUI_PUBLIC MythUIHelper * GetMythUI()
QStringList m_currentLocation
Definition: mythuihelper.h:148
static const uint16_t * d
ThemeType
Definition: themeinfo.h:14
#define MUI_PUBLIC
Definition: mythuiexp.h:9
static QString x11_display
Definition: mythuihelper.h:119
MUI_PUBLIC void DestroyMythUI()