]> git.vomp.tv Git - vompclient.git/blob - vrecordingmenu.cc
Channel schedules in live banner
[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   if (Video::getInstance()->getFormat() == Video::PAL)
28   {
29     setScreenPos(260, 190);
30   }
31   else
32   {
33     setScreenPos(250, 160);
34   }
35
36   setDimensions(200, 140);
37
38   setBackgroundColour(Colour::VIEWBACKGROUND);
39   setTitleBarOn(1);
40   setBorderOn(1);
41   setTitleText("Programme menu");
42   setTitleBarColour(Colour::TITLEBARBACKGROUND);
43
44   sl.setScreenPos(screenX + 10, screenY + 30 + 5);
45   sl.setDimensions(width - 20, height - 30 - 15);
46   sl.addOption("Play", 1);
47   sl.addOption("Resume", 0);
48   sl.addOption("Summary", 0);
49   sl.addOption("Delete", 0);
50 }
51
52 VRecordingMenu::~VRecordingMenu()
53 {
54 }
55
56 void VRecordingMenu::setParent(VRecordingList* tvRecList)
57 {
58   vRecList = tvRecList;
59 }
60
61 void VRecordingMenu::setRecording(Recording* trec)
62 {
63   rec = trec;
64 }
65
66 void VRecordingMenu::draw()
67 {
68   View::draw();
69   sl.draw();
70 }
71
72 int VRecordingMenu::handleCommand(int command)
73 {
74   switch(command)
75   {
76     case Remote::DF_UP:
77     case Remote::UP:
78     {
79       sl.up();
80       sl.draw();
81       show();
82       return 2;
83     }
84     case Remote::DF_DOWN:
85     case Remote::DOWN:
86     {
87       sl.down();
88       sl.draw();
89       show();
90       return 2;
91     }
92     case Remote::OK:
93     {
94       if (sl.getCurrentOption() == 0)
95       {
96         Message* m = new Message();
97         m->from = this;
98         m->to = vRecList;
99         m->message = Message::PLAY_SELECTED_RECORDING;
100         ViewMan::getInstance()->postMessage(m);
101         return 4;
102       }
103
104       if (sl.getCurrentOption() == 1)
105       {
106         Message* m = new Message();
107         m->from = this;
108         m->to = vRecList;
109         m->message = Message::RESUME_SELECTED_RECORDING;
110         ViewMan::getInstance()->postMessage(m);
111         return 4;
112       }
113
114       if (sl.getCurrentOption() == 2)
115       {
116         char* summary = VDR::getInstance()->getRecordingSummary(rec->fileName);
117
118         VInfo* vi = new VInfo();
119         vi->setTitleText("Programme summary");
120         vi->setBorderOn(1);
121         vi->setExitable();
122         if (summary) vi->setMainText(summary);
123         else vi->setMainText("Summary unavailable");
124         if (Video::getInstance()->getFormat() == Video::PAL)
125         {
126           vi->setScreenPos(120, 130);
127         }
128         else
129         {
130           vi->setScreenPos(110, 90);
131         }
132         vi->setDimensions(490, 300);
133
134         ViewMan::getInstance()->addNoLock(vi);
135         vi->draw();
136         vi->show();
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->setParent(this);
146         v->setBackgroundColour(Colour::VIEWBACKGROUND);
147         v->setTitleBarColour(Colour::DANGER);
148         v->setTitleBarOn(1);
149         v->setBorderOn(1);
150         v->setTitleText("Delete recording");
151         v->setMainText("Are you sure you want to delete this recording?");
152         v->setDefault(VQuestion::NO);
153         if (Video::getInstance()->getFormat() == Video::PAL)
154         {
155           v->setScreenPos(230, 160);
156         }
157         else
158         {
159           v->setScreenPos(220, 140);
160         }
161         v->setDimensions(260, 180);
162
163         ViewMan::getInstance()->addNoLock(v);
164         v->draw();
165         v->show();
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* m = new Message();
185       m->from = this;
186       m->to = ViewMan::getInstance();
187       m->message = Message::CLOSE_ME;
188       ViewMan::getInstance()->postMessage(m);
189
190       m = new Message();
191       m->from = this;
192       m->to = vRecList;
193       m->message = Message::DELETE_SELECTED_RECORDING;
194       ViewMan::getInstance()->postMessage(m);
195     }
196   }
197 }