00001 #ifndef MYTHUIHELPERS_H_
00002 #define MYTHUIHELPERS_H_
00003
00004 #include <QStringList>
00005 #include <QString>
00006 #include <QFont>
00007 #include <QMutex>
00008
00009 #include "mthreadpool.h"
00010 #include "mythuiexp.h"
00011 #include "themeinfo.h"
00012
00013 #define DEFAULT_UI_THEME "Terra"
00014 #define FALLBACK_UI_THEME "MythCenter-wide"
00015
00016 class MythUIHelperPrivate;
00017 class MythPainter;
00018 class MythImage;
00019 class QImage;
00020 class QWidget;
00021 class Settings;
00022 class QPixmap;
00023 class QSize;
00024
00025 typedef enum ImageCacheMode
00026 {
00027 kCacheNormal = 0x0,
00028 kCacheIgnoreDisk = 0x1,
00029 kCacheCheckMemoryOnly = 0x2,
00030 kCacheForceStat = 0x4,
00031 } ImageCacheMode;
00032
00033 struct MUI_PUBLIC MythUIMenuCallbacks
00034 {
00035 void (*exec_program)(const QString &cmd);
00036 void (*exec_program_tv)(const QString &cmd);
00037 void (*configplugin)(const QString &cmd);
00038 void (*plugin)(const QString &cmd);
00039 void (*eject)(void);
00040 };
00041
00042 class MUI_PUBLIC MythUIHelper
00043 {
00044 public:
00045 void Init(MythUIMenuCallbacks &cbs);
00046
00047 MythUIMenuCallbacks *GetMenuCBs(void);
00048
00049 void LoadQtConfig(void);
00050 void UpdateImageCache(void);
00051
00052 MythImage *GetImageFromCache(const QString &url);
00053 MythImage *CacheImage(const QString &url, MythImage *im,
00054 bool nodisk = false);
00055 void RemoveFromCacheByURL(const QString &url);
00056 void RemoveFromCacheByFile(const QString &fname);
00057 bool IsImageInCache(const QString &url);
00058 QString GetThemeCacheDir(void);
00059
00060 void IncludeInCacheSize(MythImage *im);
00061 void ExcludeFromCacheSize(MythImage *im);
00062
00063 Settings *qtconfig(void);
00064
00065 bool IsScreenSetup(void);
00066 bool IsTopScreenInitialized(void);
00067
00068
00069 void GetScreenSettings(float &wmult, float &hmult);
00070 void GetScreenSettings(int &width, float &wmult,
00071 int &height, float &hmult);
00072 void GetScreenSettings(int &xbase, int &width, float &wmult,
00073 int &ybase, int &height, float &hmult);
00074
00075
00076 void GetScreenBounds(int &xbase, int &ybase, int &width, int &height);
00077
00078
00079 static void ParseGeometryOverride(const QString &geometry);
00080 bool IsGeometryOverridden(void);
00081
00082 QPixmap *LoadScalePixmap(QString filename, bool fromcache = true);
00083 QImage *LoadScaleImage(QString filename, bool fromcache = true);
00084 MythImage *LoadCacheImage(QString srcfile, QString label,
00085 MythPainter *painter,
00086 ImageCacheMode cacheMode = kCacheNormal);
00087
00088 void ThemeWidget(QWidget *widget);
00089
00090 QString FindThemeDir(const QString &themename);
00091 QString FindMenuThemeDir(const QString &menuname);
00092 QString GetThemeDir(void);
00093 QString GetThemeName(void);
00094 QStringList GetThemeSearchPath(void);
00095 QString GetMenuThemeDir(void);
00096 QList<ThemeInfo> GetThemes(ThemeType type);
00097
00098 bool FindThemeFile(QString &filename);
00099
00100 QFont GetBigFont(void);
00101 QFont GetMediumFont(void);
00102 QFont GetSmallFont(void);
00103
00104
00105 void DisableScreensaver(void);
00106 void RestoreScreensaver(void);
00107
00108
00109 void ResetScreensaver(void);
00110
00111
00112 void DoDisableScreensaver(void);
00113 void DoRestoreScreensaver(void);
00114 void DoResetScreensaver(void);
00115
00116
00117 bool GetScreensaverEnabled(void);
00118 bool GetScreenIsAsleep(void);
00119
00120 static void SetX11Display(const QString &display);
00121 static QString GetX11Display(void);
00122
00123 static QString x11_display;
00124
00125 static MythUIHelper *getMythUI(void);
00126 static void destroyMythUI(void);
00127
00128 void AddCurrentLocation(QString location);
00129 QString RemoveCurrentLocation(void);
00130 QString GetCurrentLocation(bool fullPath = false, bool mainStackOnly = true);
00131
00132 MThreadPool *GetImageThreadPool(void);
00133
00134 double GetPixelAspectRatio(void) const;
00135 QSize GetBaseSize(void) const;
00136
00137 void SetFontStretch(int stretch);
00138 int GetFontStretch(void) const;
00139
00140 protected:
00141 MythUIHelper();
00142 ~MythUIHelper();
00143
00144 private:
00145 void SetPalette(QWidget *widget);
00146 void InitializeScreenSettings(void);
00147
00148 void ClearOldImageCache(void);
00149 void RemoveCacheDir(const QString &dirname);
00150
00151 MythUIHelperPrivate *d;
00152
00153 QMutex m_locationLock;
00154 QStringList m_currentLocation;
00155 };
00156
00157 MUI_PUBLIC MythUIHelper *GetMythUI();
00158 MUI_PUBLIC void DestroyMythUI();
00159
00160 #endif
00161