00001 #include "scheduledrecording.h"
00002 #include "sr_root.h"
00003 #include "mythcontext.h"
00004 #include "sr_dialog.h"
00005
00006 RecOptDialog::RecOptDialog(ScheduledRecording* sr, MythMainWindow *parent, const char *name)
00007 : MythDialog(parent, name), listMenu(this, "listMenu")
00008 {
00009 schedRec = sr;
00010 program = sr->getProgramInfo();
00011
00012
00013 theme = new XMLParse();
00014 theme->SetWMult(wmult);
00015 theme->SetHMult(hmult);
00016
00017 if (!theme->LoadTheme(xmldata, "recording_options"))
00018 {
00019
00020 MythPopupBox::showOkPopup(gContext->GetMainWindow(), tr("Missing Element"),
00021 tr("The theme you are using does not contain a 'recording_options' "
00022 "element. Please contact the theme creator and ask if they could "
00023 "please update it.<br><br>The next screen will be empty. "
00024 "Press EXIT to return to the menu."));
00025 return;
00026 }
00027
00028 LoadWindow(xmldata);
00029
00030 listMenu.init(theme, "selector", "menu_list", listRect);
00031
00032 rootGroup = sr->getRootGroup();
00033 rootGroup->setParentList(&listMenu);
00034 listMenu.setCurGroup(rootGroup);
00035
00036 setNoErase();
00037 allowEvents = true;
00038 allowUpdates = true;
00039 updateBackground();
00040 }
00041
00042 RecOptDialog::~RecOptDialog()
00043 {
00044 if (theme)
00045 delete theme;
00046 }
00047
00048 void RecOptDialog::constructList(void)
00049 {
00050
00051
00052 }
00053
00054
00055 void RecOptDialog::LoadWindow(QDomElement &element)
00056 {
00057 QString name;
00058 int context;
00059 QRect area;
00060
00061 for (QDomNode child = element.firstChild(); !child.isNull(); child = child.nextSibling())
00062 {
00063 QDomElement e = child.toElement();
00064
00065 if (!e.isNull())
00066 {
00067 if (e.tagName() == "font")
00068 theme->parseFont(e);
00069 else if (e.tagName() == "container")
00070 {
00071 theme->parseContainer(e, name, context, area);
00072 if (name.lower() == "program_info")
00073 infoRect = area;
00074 else if (name == "selector")
00075 listRect = area;
00076 }
00077 else
00078 {
00079 MythPopupBox::showOkPopup(gContext->GetMainWindow(), tr("Unknown Element"),
00080 QString(tr("The theme you are using contains an "
00081 "unknown element ('%1'). It will be ignored")).arg(e.tagName()));
00082 }
00083 }
00084 }
00085 }
00086
00087 void RecOptDialog::paintEvent(QPaintEvent *e)
00088 {
00089 if (!allowUpdates)
00090 {
00091 updateAll = true;
00092 return;
00093 }
00094
00095 QRect r = e->rect();
00096 QPainter p(this);
00097
00098 if (updateAll || r.intersects(infoRect))
00099 updateInfo(&p);
00100
00101 listMenu.paintEvent(r, &p, updateAll);
00102
00103
00104 }
00105
00106 void RecOptDialog::keyPressEvent(QKeyEvent *e)
00107 {
00108 if (!allowEvents)
00109 return;
00110
00111 allowEvents = false;
00112 bool handled = false;
00113
00114 QStringList actions;
00115 gContext->GetMainWindow()->TranslateKeyPress("TV Frontend", e, actions);
00116
00117
00118 for (unsigned int i = 0; i < actions.size() && !handled; i++)
00119 {
00120 QString action = actions[i];
00121 handled = true;
00122 if (action == "ESCAPE")
00123 {
00124 if (!listMenu.goBack())
00125 done(MythDialog::Rejected );
00126 }
00127 else if (!listMenu.getLocked())
00128 {
00129 if (action == "UP")
00130 listMenu.cursorUp(false);
00131 else if (action == "DOWN")
00132 listMenu.cursorDown(false);
00133 else if (action == "PAGEUP")
00134 listMenu.cursorUp(true);
00135 else if (action == "PAGEDOWN")
00136 listMenu.cursorDown(true);
00137 else if (action == "SELECT")
00138 listMenu.select();
00139 else if (action == "LEFT")
00140 listMenu.cursorLeft(false);
00141 else if (action == "RIGHT")
00142 listMenu.cursorRight(false);
00143 else if (action == "PAGELEFT")
00144 listMenu.cursorLeft(true);
00145 else if (action == "PAGERIGHT")
00146 listMenu.cursorRight(true);
00147 else
00148 handled = false;
00149 }
00150 }
00151
00152 if (!handled)
00153 MythDialog::keyPressEvent(e);
00154
00155 allowEvents = true;
00156 }
00157
00158 void RecOptDialog::updateInfo(QPainter *p)
00159 {
00160
00161 LayerSet *container = theme->GetSet("program_info");
00162
00163 if (container)
00164 {
00165
00166 if (infoMap.isEmpty())
00167 {
00168 if (schedRec)
00169 schedRec->ToMap(infoMap);
00170 else
00171
00172 return;
00173 }
00174
00175 QRect pr = infoRect;
00176 QPixmap pix(pr.size());
00177 pix.fill(this, pr.topLeft());
00178 QPainter tmp(&pix);
00179
00180
00181 container->ClearAllText();
00182 container->SetText(infoMap);
00183
00184 container->Draw(&tmp, 4, 0);
00185 container->Draw(&tmp, 5, 0);
00186 container->Draw(&tmp, 6, 0);
00187 container->Draw(&tmp, 7, 0);
00188 container->Draw(&tmp, 8, 0);
00189
00190 tmp.end();
00191 p->drawPixmap(pr.topLeft(), pix);
00192 }
00193
00194
00195 }
00196
00197
00198 void RecOptDialog::updateBackground(void)
00199 {
00200 QPixmap bground(size());
00201 bground.fill(this, 0, 0);
00202
00203 QPainter tmp(&bground);
00204
00205 LayerSet *container = theme->GetSet("background");
00206 container->Draw(&tmp, 0, 0);
00207
00208 tmp.end();
00209 myBackground = bground;
00210
00211 setPaletteBackgroundPixmap(myBackground);
00212 }