From 491b0c0b7fc6ebc229e5933348dc10f3324000ea Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Thu, 28 Dec 2006 18:42:43 +0000 Subject: [PATCH] Minor cleanup changes --- command.cc | 20 ++++++++++++++++ message.h | 2 ++ viewman.cc | 16 +++++++++---- voptions.cc | 4 +--- voptions.h | 4 ++-- voptionsmenu.cc | 6 +++-- voptionsmenu.h | 1 - vrecmove.cc | 2 +- vrecmove.h | 4 ++-- vrecordinglist.cc | 1 - vtimerlist.cc | 21 ++++++++++------- vtimerlist.h | 4 ++-- vwelcome.cc | 60 +++++++++++++++-------------------------------- vwelcome.h | 7 ------ 14 files changed, 77 insertions(+), 75 deletions(-) diff --git a/command.cc b/command.cc index 3aa3672..1ab1417 100644 --- a/command.cc +++ b/command.cc @@ -363,6 +363,26 @@ void Command::processMessage(Message* m) handleCommand(m->parameter); break; } + case Message::CHANGE_LANGUAGE: + { + viewman->removeAll(); + viewman->updateView(wallpaper); + I18n::initialize(); + VWelcome* vw = new VWelcome(); + vw->draw(); + viewman->add(vw); + viewman->updateView(vw); + break; + } + case Message::LAST_VIEW_CLOSE: + { +// VWelcome* vw = new VWelcome(); +// vw->draw(); +// viewman->add(vw); +// viewman->updateView(vw); + + break; + } } } else diff --git a/message.h b/message.h index a323b23..146c899 100644 --- a/message.h +++ b/message.h @@ -69,6 +69,8 @@ class Message const static ULONG CHILD_CLOSE = 24; const static ULONG MOUSE_MOVE = 25; const static ULONG MOUSE_LBDOWN = 26; + const static ULONG CHANGE_LANGUAGE = 27; + const static ULONG LAST_VIEW_CLOSE = 28; }; #endif diff --git a/viewman.cc b/viewman.cc index 0a15620..c3e03a6 100644 --- a/viewman.cc +++ b/viewman.cc @@ -19,6 +19,7 @@ */ #include "viewman.h" +#include "command.h" ViewMan* ViewMan::instance = NULL; @@ -111,6 +112,15 @@ int ViewMan::removeView(View* toDelete) // Delete the view delete toDelete; + // If there is only the wallpaper left signal command + if (numViews == 1) + { + Message* m = new Message(); + m->to = Command::getInstance(); + m->message = Message::LAST_VIEW_CLOSE; + Command::getInstance()->postMessageNoLock(m); + } + return 1; } @@ -391,10 +401,6 @@ int ViewMan::handleCommand(UCHAR command) retVal2 = 2; } -// Log::getInstance()->log("ViewMan", Log::DEBUG, "out of handlecommand code, now on to messages"); - -// processMessageQueue(); - return retVal2; } @@ -416,7 +422,7 @@ void ViewMan::processMessage(Message* m) /* Handle mouse events*/ // They come in with m->to = NULL? and just need to be delivered to top view? - if (numViews && ((m->message == Message::MOUSE_MOVE) || (m->message == Message::MOUSE_LBDOWN))) + if ((numViews > 1) && ((m->message == Message::MOUSE_MOVE) || (m->message == Message::MOUSE_LBDOWN))) { views[numViews-1]->processMessage(m); return; diff --git a/voptions.cc b/voptions.cc index 719f56a..cd27c36 100644 --- a/voptions.cc +++ b/voptions.cc @@ -20,7 +20,7 @@ #include "voptions.h" -VOptions::VOptions(View* tparent, const char* title, const OPTIONDATA* toptionData, const int tnumOptions) +VOptions::VOptions(void* tparent, const char* title, const OPTIONDATA* toptionData, const int tnumOptions) { viewman = ViewMan::getInstance(); @@ -281,10 +281,8 @@ void VOptions::doSave() m->to = parent; m->parameter = (ULONG)optionChanges; Command::getInstance()->postMessageNoLock(m); - } - void VOptions::processMessage(Message* m) { if (m->message == Message::MOUSE_MOVE) diff --git a/voptions.h b/voptions.h index 897b945..9aec6b7 100644 --- a/voptions.h +++ b/voptions.h @@ -49,7 +49,7 @@ typedef struct class VOptions : public View { public: - VOptions(View* tparent, const char* title, const OPTIONDATA* toptionData, const int tnumOptions); + VOptions(void* tparent, const char* title, const OPTIONDATA* toptionData, const int tnumOptions); ~VOptions(); int handleCommand(int command); @@ -66,7 +66,7 @@ class VOptions : public View VDR* vdr; int* optionsAtStart; ViewMan* viewman; - View* parent; + void* parent; }; #endif diff --git a/voptionsmenu.cc b/voptionsmenu.cc index aeea3e6..d5d90df 100644 --- a/voptionsmenu.cc +++ b/voptionsmenu.cc @@ -217,8 +217,10 @@ void VOptionsMenu::doApplyChanges(map* changedOptions) } case 2: { - I18n::initialize(); - VWelcome::getInstance()->redrawLang(); + Message* m = new Message(); + m->message = Message::CHANGE_LANGUAGE; + m->to = Command::getInstance(); + Command::getInstance()->postMessageNoLock(m); break; } case 3: diff --git a/voptionsmenu.h b/voptionsmenu.h index f8cf20e..7c29315 100644 --- a/voptionsmenu.h +++ b/voptionsmenu.h @@ -31,7 +31,6 @@ #include "video.h" #include "wbutton.h" #include "i18n.h" -#include "vwelcome.h" #include "voptions.h" class VOptionsMenu : public View diff --git a/vrecmove.cc b/vrecmove.cc index cfb7bc1..8f41080 100644 --- a/vrecmove.cc +++ b/vrecmove.cc @@ -53,7 +53,7 @@ VRecMove::~VRecMove() { } -void VRecMove::setParent(View* tparent) +void VRecMove::setParent(void* tparent) { parent = tparent; } diff --git a/vrecmove.h b/vrecmove.h index 183a21a..58d4a82 100644 --- a/vrecmove.h +++ b/vrecmove.h @@ -43,14 +43,14 @@ class VRecMove : public View public: VRecMove(RecMan* recman); ~VRecMove(); - void setParent(View* parent); + void setParent(void* parent); int handleCommand(int command); void draw(); void processMessage(Message* m); private: - View* parent; + void* parent; RecMan* recman; WSelectList sl; void addDirs(Directory* dir, char* prefix); diff --git a/vrecordinglist.cc b/vrecordinglist.cc index 3829d35..8c821fd 100644 --- a/vrecordinglist.cc +++ b/vrecordinglist.cc @@ -484,4 +484,3 @@ bool VRecordingList::load() return success; } - diff --git a/vtimerlist.cc b/vtimerlist.cc index d616ccc..cccf503 100644 --- a/vtimerlist.cc +++ b/vtimerlist.cc @@ -20,9 +20,9 @@ #include "vtimerlist.h" -VTimerList::VTimerList(RecTimerList* trtl) +VTimerList::VTimerList() { - recTimerList = trtl; + recTimerList = NULL; clockRegion.x = 420; clockRegion.y = 0; @@ -81,11 +81,6 @@ VTimerList::VTimerList(RecTimerList* trtl) drawTextRJ("[ok] = edit", 560, 385, Colour::LIGHTTEXT); - - insertData(); - sl.draw(); - drawShowing(); - drawIndicators(); drawClock(); } @@ -104,8 +99,12 @@ VTimerList::~VTimerList() } } -void VTimerList::insertData() +bool VTimerList::load() { + recTimerList = VDR::getInstance()->getRecTimersList(); + + if (!recTimerList) return false; + char strA[300]; char strB[300]; @@ -129,6 +128,12 @@ void VTimerList::insertData() sl.addOption(strB, (ULONG)recTimer, first); first = 0; } + + sl.draw(); + drawShowing(); + drawIndicators(); + ViewMan::getInstance()->updateView(this); + return true; } void VTimerList::drawClock() diff --git a/vtimerlist.h b/vtimerlist.h index f988f79..2a25168 100644 --- a/vtimerlist.h +++ b/vtimerlist.h @@ -40,19 +40,19 @@ class VTimerList : public View, public TimerReceiver { public: - VTimerList(RecTimerList* rtl); + VTimerList(); ~VTimerList(); int handleCommand(int command); void timercall(int clientReference); void processMessage(Message* m); + bool load(); private: RecTimerList* recTimerList; WSelectList sl; - void insertData(); void drawClock(); void drawShowing(); void drawData(); diff --git a/vwelcome.cc b/vwelcome.cc index 573b6ca..8ba5d74 100644 --- a/vwelcome.cc +++ b/vwelcome.cc @@ -20,12 +20,8 @@ #include "vwelcome.h" -VWelcome* VWelcome::instance = NULL; - VWelcome::VWelcome() { - instance = this; - viewman = ViewMan::getInstance(); clockRegion.x = 400; @@ -51,26 +47,6 @@ VWelcome::VWelcome() sl.setSurfaceOffset(20, 40); sl.setDimensions(170, 140); - jpeg.setSurface(surface); - jpeg.setSurfaceOffset(240, 60); - - setup(); -} - -VWelcome::~VWelcome() -{ - instance = NULL; - Timers::getInstance()->cancelTimer(this, 1); -} - -VWelcome* VWelcome::getInstance() -{ - return instance; -} - -void VWelcome::setup() -{ - sl.clear(); setTitleText(tr("Welcome")); sl.addOption(tr("1. Live TV"), 1, 1); sl.addOption(tr("2. Radio"), 2, 0); @@ -78,6 +54,14 @@ void VWelcome::setup() sl.addOption(tr("4. Timers"), 4, 0); sl.addOption(tr("5. Options"), 5, 0); sl.addOption(tr("6. Reboot"), 6, 0); + + jpeg.setSurface(surface); + jpeg.setSurfaceOffset(240, 60); +} + +VWelcome::~VWelcome() +{ + Timers::getInstance()->cancelTimer(this, 1); } void VWelcome::draw() @@ -205,8 +189,14 @@ int VWelcome::handleCommand(int command) return 2; } #endif - } + // Test +// case Remote::BACK: +// { +// return 4; +// } + + } return 1; } @@ -263,16 +253,11 @@ void VWelcome::doRecordingsList() void VWelcome::doTimersList() { - RecTimerList* recTimerList = VDR::getInstance()->getRecTimersList(); - - if (recTimerList) - { - VTimerList* vtl = new VTimerList(recTimerList); + VTimerList* vtl = new VTimerList(); + viewman->add(vtl); + viewman->updateView(vtl); - viewman->add(vtl); - viewman->updateView(vtl); - } - else + if (!vtl->load()) { Command::getInstance()->connectionLost(); } @@ -286,13 +271,6 @@ void VWelcome::doOptions() viewman->updateView(voptionsmenu); } -void VWelcome::redrawLang() -{ - Log::getInstance()->log("VWelcome", Log::DEBUG, "Got redraw lang message"); - setup(); - draw(); -} - void VWelcome::processMessage(Message* m) { if (m->message == Message::MOUSE_MOVE) diff --git a/vwelcome.h b/vwelcome.h index d2fce20..258c047 100644 --- a/vwelcome.h +++ b/vwelcome.h @@ -41,25 +41,18 @@ #include "i18n.h" #include "timers.h" -// FIXME - take out singleton when broadcast messages exist - class VWelcome : public View, public TimerReceiver { public: VWelcome(); ~VWelcome(); - static VWelcome* getInstance(); - void setup(); int handleCommand(int command); void processMessage(Message* m); void draw(); void timercall(int clientReference); - void redrawLang(); private: - static VWelcome* instance; - WSelectList sl; WJpeg jpeg; -- 2.39.5