]> git.vomp.tv Git - vompclient.git/blob - vrecordingmenu.cc
Switch over to updateView rather than show, EPG tweaks
[vompclient.git] / vrecordingmenu.cc
1 /*
2     Copyright 2004-2005 Chris Tallon
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21 #include "vrecordingmenu.h"
22
23 VRecordingMenu::VRecordingMenu()
24 {
25   rec = NULL;
26
27   create(200, 140);
28   if (Video::getInstance()->getFormat() == Video::PAL)
29   {
30     setScreenPos(260, 190);
31   }
32   else
33   {
34     setScreenPos(250, 160);
35   }
36
37
38   setBackgroundColour(Colour::VIEWBACKGROUND);
39   setTitleBarOn(1);
40   setBorderOn(1);
41   setTitleText(tr("Programme menu"));
42   setTitleBarColour(Colour::TITLEBARBACKGROUND);
43
44   sl.setSurface(surface);
45   sl.setSurfaceOffset(10, 30 + 5);
46   sl.setDimensions(area.w - 20, area.h - 30 - 15);
47   sl.addOption(tr("Play"), 1);
48   sl.addOption(tr("Resume"), 0);
49   sl.addOption(tr("Summary"), 0);
50   sl.addOption(tr("Delete"), 0);
51 }
52
53 VRecordingMenu::~VRecordingMenu()
54 {
55 }
56
57 void VRecordingMenu::setParent(VRecordingList* tvRecList)
58 {
59   vRecList = tvRecList;
60 }
61
62 void VRecordingMenu::setRecording(Recording* trec)
63 {
64   rec = trec;
65 }
66
67 void VRecordingMenu::draw()
68 {
69   View::draw();
70   sl.draw();
71 }
72
73 int VRecordingMenu::handleCommand(int command)
74 {
75   switch(command)
76   {
77     case Remote::DF_UP:
78     case Remote::UP:
79     {
80       sl.up();
81       sl.draw();
82       ViewMan::getInstance()->updateView(this);
83       return 2;
84     }
85     case Remote::DF_DOWN:
86     case Remote::DOWN:
87     {
88       sl.down();
89       sl.draw();
90       ViewMan::getInstance()->updateView(this);
91       return 2;
92     }
93     case Remote::OK:
94     {
95       if (sl.getCurrentOption() == 0)
96       {
97         Message* m = new Message();
98         m->from = this;
99         m->to = vRecList;
100         m->message = Message::PLAY_SELECTED_RECORDING;
101         ViewMan::getInstance()->postMessage(m);
102         return 4;
103       }
104
105       if (sl.getCurrentOption() == 1)
106       {
107         Message* m = new Message();
108         m->from = this;
109         m->to = vRecList;
110         m->message = Message::RESUME_SELECTED_RECORDING;
111         ViewMan::getInstance()->postMessage(m);
112         return 4;
113       }
114
115       if (sl.getCurrentOption() == 2)
116       {
117         char* summary = VDR::getInstance()->getRecordingSummary(rec->fileName);
118
119         VInfo* vi = new VInfo();
120         vi->setTitleText(tr("Programme summary"));
121         vi->setBorderOn(1);
122         vi->setExitable();
123         if (summary) vi->setMainText(summary);
124         else vi->setMainText(tr("Summary unavailable"));
125         if (Video::getInstance()->getFormat() == Video::PAL)
126         {
127           vi->setScreenPos(120, 130);
128         }
129         else
130         {
131           vi->setScreenPos(110, 90);
132         }
133         vi->create(490, 300);
134         vi->draw();
135         ViewMan::getInstance()->add(vi);
136         ViewMan::getInstance()->updateView(vi);
137
138         if (summary) delete[] summary;
139
140         return 2;
141       }
142       else if (sl.getCurrentOption() == 3)
143       {
144         VQuestion* v = new VQuestion();
145         v->create(260, 180);
146         v->setParent(this);
147         v->setBackgroundColour(Colour::VIEWBACKGROUND);
148         v->setTitleBarColour(Colour::DANGER);
149         v->setTitleBarOn(1);
150         v->setBorderOn(1);
151         v->setTitleText(tr("Delete recording"));
152         v->setMainText(tr("Are you sure you want to delete this recording?"));
153         v->setDefault(VQuestion::NO);
154         if (Video::getInstance()->getFormat() == Video::PAL)
155         {
156           v->setScreenPos(230, 160);
157         }
158         else
159         {
160           v->setScreenPos(220, 140);
161         }
162
163         v->draw();
164         ViewMan::getInstance()->add(v);
165         ViewMan::getInstance()->updateView(v);
166         return 2;
167       }
168     }
169     case Remote::BACK:
170     {
171       return 4;
172     }
173   }
174   // stop command getting to any more views
175   return 1;
176 }
177
178 void VRecordingMenu::processMessage(Message* m)
179 {
180   if (m->message == Message::QUESTION_YES)
181   {
182     if (sl.getCurrentOption() == 3)
183     {
184       Message* m2 = new Message();
185       m2->from = this;
186       m2->to = ViewMan::getInstance();
187       m2->message = Message::CLOSE_ME;
188       ViewMan::getInstance()->postMessage(m2);
189
190       m2 = new Message();
191       m2->from = this;
192       m2->to = vRecList;
193       m2->message = Message::DELETE_SELECTED_RECORDING;
194       ViewMan::getInstance()->postMessage(m2);
195     }
196   }
197 }