]> git.vomp.tv Git - vompclient.git/blob - vrecordingmenu.cc
New GUI code
[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       show();
83       return 2;
84     }
85     case Remote::DF_DOWN:
86     case Remote::DOWN:
87     {
88       sl.down();
89       sl.draw();
90       show();
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
135         ViewMan::getInstance()->addNoLock(vi);
136         vi->draw();
137         vi->show();
138
139         if (summary) delete[] summary;
140
141         return 2;
142       }
143       else if (sl.getCurrentOption() == 3)
144       {
145         VQuestion* v = new VQuestion();
146         v->create(260, 180);
147         v->setParent(this);
148         v->setBackgroundColour(Colour::VIEWBACKGROUND);
149         v->setTitleBarColour(Colour::DANGER);
150         v->setTitleBarOn(1);
151         v->setBorderOn(1);
152         v->setTitleText(tr("Delete recording"));
153         v->setMainText(tr("Are you sure you want to delete this recording?"));
154         v->setDefault(VQuestion::NO);
155         if (Video::getInstance()->getFormat() == Video::PAL)
156         {
157           v->setScreenPos(230, 160);
158         }
159         else
160         {
161           v->setScreenPos(220, 140);
162         }
163
164         ViewMan::getInstance()->addNoLock(v);
165         v->draw();
166         v->show();
167         return 2;
168       }
169     }
170     case Remote::BACK:
171     {
172       return 4;
173     }
174   }
175   // stop command getting to any more views
176   return 1;
177 }
178
179 void VRecordingMenu::processMessage(Message* m)
180 {
181   if (m->message == Message::QUESTION_YES)
182   {
183     if (sl.getCurrentOption() == 3)
184     {
185       Message* m = new Message();
186       m->from = this;
187       m->to = ViewMan::getInstance();
188       m->message = Message::CLOSE_ME;
189       ViewMan::getInstance()->postMessage(m);
190
191       m = new Message();
192       m->from = this;
193       m->to = vRecList;
194       m->message = Message::DELETE_SELECTED_RECORDING;
195       ViewMan::getInstance()->postMessage(m);
196     }
197   }
198 }