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