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
00008 #include "mythcontext.h"
00009 #include "oldsettings.h"
00010
00011 class MythThemeBasePrivate
00012 {
00013 public:
00014 MythScreenStack *background;
00015 MythScreenType *backgroundscreen;
00016
00017 MythUIImage *backimg;
00018 };
00019
00020
00021 MythThemeBase::MythThemeBase()
00022 {
00023 d = new MythThemeBasePrivate();
00024
00025 Init();
00026 }
00027
00028 MythThemeBase::~MythThemeBase()
00029 {
00030 delete d;
00031 }
00032
00033 void MythThemeBase::Reload(void)
00034 {
00035 MythMainWindow *mainWindow = GetMythMainWindow();
00036 QRect uiSize = mainWindow->GetUIScreenRect();
00037
00038 GetGlobalFontMap()->Clear();
00039 XMLParseBase::ClearGlobalObjectStore();
00040 XMLParseBase::LoadBaseTheme();
00041
00042 d->background->PopScreen();
00043
00044 d->backgroundscreen = new MythScreenType(d->background, "backgroundscreen");
00045
00046 if (!XMLParseBase::CopyWindowFromBase("backgroundwindow",
00047 d->backgroundscreen))
00048 {
00049 QString backgroundname = gContext->qtconfig()->GetSetting("BackgroundPixmap"
00050 );
00051 backgroundname = gContext->GetThemeDir() + backgroundname;
00052
00053 d->backimg = new MythUIImage(backgroundname, d->backgroundscreen,
00054 "backimg");
00055 d->backimg->SetPosition(mainWindow->NormPoint(QPoint(0, 0)));
00056 d->backimg->SetSize(uiSize.width(), uiSize.height());
00057 d->backimg->Load();
00058 }
00059
00060 d->background->AddScreen(d->backgroundscreen, false);
00061 }
00062
00063 void MythThemeBase::Init(void)
00064 {
00065 MythMainWindow *mainWindow = GetMythMainWindow();
00066 QRect uiSize = mainWindow->GetUIScreenRect();
00067
00068 d->background = new MythScreenStack(mainWindow, "background");
00069 d->background->DisableEffects();
00070
00071 XMLParseBase::LoadBaseTheme();
00072 d->backgroundscreen = new MythScreenType(d->background, "backgroundscreen");
00073
00074 if (!XMLParseBase::CopyWindowFromBase("backgroundwindow",
00075 d->backgroundscreen))
00076 {
00077 QString backgroundname = gContext->qtconfig()->GetSetting("BackgroundPixmap"
00078 );
00079 backgroundname = gContext->GetThemeDir() + backgroundname;
00080
00081 d->backimg = new MythUIImage(backgroundname, d->backgroundscreen,
00082 "backimg");
00083 d->backimg->SetPosition(mainWindow->NormPoint(QPoint(0, 0)));
00084 d->backimg->SetSize(uiSize.width(), uiSize.height());
00085 d->backimg->Load();
00086 }
00087
00088 d->background->AddScreen(d->backgroundscreen, false);
00089
00090 new MythScreenStack(mainWindow, "main stack", true);
00091 }
00092