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 MythUIHelper *getMythUI(void);
117  static void destroyMythUI(void);
118 
119  void AddCurrentLocation(const QString& location);
120  QString RemoveCurrentLocation(void);
121  QString GetCurrentLocation(bool fullPath = false, bool mainStackOnly = true);
122 
123  MThreadPool *GetImageThreadPool(void);
124  QSize GetBaseSize(void) const;
125 
126  void SetFontStretch(int stretch);
127  int GetFontStretch(void) const;
128 
129  protected:
130  MythUIHelper();
131  ~MythUIHelper();
132 
133  private:
135 
136  void ClearOldImageCache(void);
137  void RemoveCacheDir(const QString &dirname);
138  static void PruneCacheDir(const QString& dirname);
139 
140  MythUIHelperPrivate *d {nullptr}; // NOLINT(readability-identifier-naming)
141 
143  QStringList m_currentLocation;
144 };
145 
148 
149 #endif
150 
MUI_PUBLIC
#define MUI_PUBLIC
Definition: mythuiexp.h:9
MythUIHelper::m_currentLocation
QStringList m_currentLocation
Definition: mythuihelper.h:143
d
static const uint16_t * d
Definition: iso6937tables.cpp:1025
MythUIHelper::m_locationLock
QMutex m_locationLock
Definition: mythuihelper.h:142
themeinfo.h
kCacheForceStat
@ kCacheForceStat
Definition: mythuihelper.h:29
kCacheIgnoreDisk
@ kCacheIgnoreDisk
Definition: mythuihelper.h:27
DestroyMythUI
MUI_PUBLIC void DestroyMythUI()
Definition: mythuihelper.cpp:86
ThemeType
ThemeType
Definition: themeinfo.h:14
MythUIHelper::InitializeScreenSettings
void InitializeScreenSettings(void)
MThreadPool
Definition: mthreadpool.h:18
GetMythUI
MUI_PUBLIC MythUIHelper * GetMythUI()
Definition: mythuihelper.cpp:81
MythPainter
Definition: mythpainter.h:33
MythImage
Definition: mythimage.h:37
MythUIHelperPrivate
Definition: mythuihelper.cpp:92
MythUIHelper
Definition: mythuihelper.h:42
ImageCacheMode
ImageCacheMode
Definition: mythuihelper.h:25
mythuiexp.h
kCacheCheckMemoryOnly
@ kCacheCheckMemoryOnly
Definition: mythuihelper.h:28
kCacheNormal
@ kCacheNormal
Definition: mythuihelper.h:26
MythUIMenuCallbacks
Definition: mythuihelper.h:33