00001 #include "myththemebase.h"
00002 #include "mythuiimage.h"
00003 #include "mythmainwindow.h"
00004 #include "mythscreentype.h"
00005 #include "xmlparsebase.h"
00006 #include "mythfontproperties.h"
00007 #include "mythfontmanager.h"
00008
00009 #include "mythdirs.h"
00010 #include "oldsettings.h"
00011 #include "mythuihelper.h"
00012
00013 class MythThemeBasePrivate
00014 {
00015 public:
00016 MythScreenStack *background;
00017 MythScreenType *backgroundscreen;
00018
00019 MythUIImage *backimg;
00020 };
00021
00022
00023 MythThemeBase::MythThemeBase()
00024 {
00025 d = new MythThemeBasePrivate();
00026
00027 Init();
00028 }
00029
00030 MythThemeBase::~MythThemeBase()
00031 {
00032 GetGlobalFontMap()->Clear();
00033 XMLParseBase::ClearGlobalObjectStore();
00034 GetGlobalFontManager()->ReleaseFonts("UI");
00035 GetGlobalFontManager()->ReleaseFonts("Shared");
00036 delete d;
00037 }
00038
00039 void MythThemeBase::Reload(void)
00040 {
00041 MythMainWindow *mainWindow = GetMythMainWindow();
00042 QRect uiSize = mainWindow->GetUIScreenRect();
00043
00044 GetGlobalFontMap()->Clear();
00045 XMLParseBase::ClearGlobalObjectStore();
00046 GetGlobalFontManager()->ReleaseFonts("UI");
00047 GetGlobalFontManager()->LoadFonts(GetMythUI()->GetThemeDir(), "UI");
00048 XMLParseBase::LoadBaseTheme();
00049
00050 d->background->PopScreen(false, true);
00051
00052 d->backgroundscreen = new MythScreenType(d->background, "backgroundscreen");
00053
00054 if (!XMLParseBase::CopyWindowFromBase("backgroundwindow",
00055 d->backgroundscreen))
00056 {
00057 QString backgroundname = GetMythUI()->qtconfig()->GetSetting("BackgroundPixmap"
00058 );
00059 backgroundname = GetMythUI()->GetThemeDir() + backgroundname;
00060
00061 d->backimg = new MythUIImage(backgroundname, d->backgroundscreen,
00062 "backimg");
00063 d->backimg->SetPosition(mainWindow->NormPoint(QPoint(0, 0)));
00064 d->backimg->SetSize(uiSize.width(), uiSize.height());
00065 d->backimg->Load();
00066 }
00067
00068 d->background->AddScreen(d->backgroundscreen, false);
00069 }
00070
00071 void MythThemeBase::Init(void)
00072 {
00073 MythMainWindow *mainWindow = GetMythMainWindow();
00074 QRect uiSize = mainWindow->GetUIScreenRect();
00075
00076 d->background = new MythScreenStack(mainWindow, "background");
00077 d->background->DisableEffects();
00078
00079 GetGlobalFontManager()->LoadFonts(GetFontsDir(), "Shared");
00080 GetGlobalFontManager()->LoadFonts(GetMythUI()->GetThemeDir(), "UI");
00081 XMLParseBase::LoadBaseTheme();
00082 d->backgroundscreen = new MythScreenType(d->background, "backgroundscreen");
00083
00084 if (!XMLParseBase::CopyWindowFromBase("backgroundwindow",
00085 d->backgroundscreen))
00086 {
00087 QString backgroundname = GetMythUI()->qtconfig()->GetSetting("BackgroundPixmap"
00088 );
00089 backgroundname = GetMythUI()->GetThemeDir() + backgroundname;
00090
00091 d->backimg = new MythUIImage(backgroundname, d->backgroundscreen,
00092 "backimg");
00093 d->backimg->SetPosition(mainWindow->NormPoint(QPoint(0, 0)));
00094 d->backimg->SetSize(uiSize.width(), uiSize.height());
00095 d->backimg->Load();
00096 }
00097
00098 d->background->AddScreen(d->backgroundscreen, false);
00099
00100 new MythScreenStack(mainWindow, "main stack", true);
00101
00102 new MythScreenStack(mainWindow, "popup stack");
00103 }
00104