From 706cf4d8e5784c9078953a4c789fd51c13b690fa Mon Sep 17 00:00:00 2001 From: louis Date: Thu, 18 Jul 2013 17:59:59 +0200 Subject: [PATCH] added possibility to choose folder for instant recording --- HISTORY | 2 ++ config.c | 4 ++- config.h | 1 + po/de_DE.po | 11 +++++++- recmanager.c | 7 ++++- recmanager.h | 2 +- recmenuitem.h | 2 ++ recmenumanager.c | 19 ++++++++++++-- recmenumanager.h | 1 + recmenus.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++- setup.c | 3 ++- 11 files changed, 112 insertions(+), 8 deletions(-) diff --git a/HISTORY b/HISTORY index 6e1152f..3da6bd0 100644 --- a/HISTORY +++ b/HISTORY @@ -52,3 +52,5 @@ VDR Plugin 'tvguide' Revision History - changed channel jump logic - red button also available in detail view - page scrolling with keys left and right in detail view +- added possibility to choose folder for instant recording, possible + folders are read from VDRs folders list diff --git a/config.c b/config.c index 384d724..5fb64bc 100644 --- a/config.c +++ b/config.c @@ -60,6 +60,7 @@ cTvguideConfig::cTvguideConfig() { numAdditionalEPGPictures = 9; epgImageWidthLarge = 525; epgImageHeightLarge = 400; + recMenuAskFolder = 0; fontIndex = 0; fontNameDefault = "VDRSymbols Sans:Book"; FontButtonDelta = 0; @@ -287,7 +288,8 @@ bool cTvguideConfig::SetupParse(const char *Name, const char *Value) { else if (strcmp(Name, "displayChannelName") == 0) displayChannelName = atoi(Value); else if (strcmp(Name, "channelHeaderWidthPercent") == 0) channelHeaderWidthPercent = atoi(Value); else if (strcmp(Name, "channelHeaderHeightPercent") == 0) channelHeaderHeightPercent = atoi(Value); - else if (strcmp(Name, "footerHeight") == 0) footerHeight = atoi(Value); + else if (strcmp(Name, "footerHeight") == 0) footerHeight = atoi(Value); + else if (strcmp(Name, "recMenuAskFolder") == 0) recMenuAskFolder = atoi(Value); else if (strcmp(Name, "fontIndex") == 0) fontIndex = atoi(Value); else if (strcmp(Name, "FontButtonDelta") == 0) FontButtonDelta = atoi(Value); else if (strcmp(Name, "FontDetailViewDelta") == 0) FontDetailViewDelta = atoi(Value); diff --git a/config.h b/config.h index b5d9e35..82cc5fa 100644 --- a/config.h +++ b/config.h @@ -64,6 +64,7 @@ class cTvguideConfig { int epgImageHeightLarge; cString epgImagePath; cString iconPath; + int recMenuAskFolder; int fontIndex; const char *fontNameDefault; int FontButtonDelta; diff --git a/po/de_DE.po b/po/de_DE.po index 02c3e9a..51ee192 100755 --- a/po/de_DE.po +++ b/po/de_DE.po @@ -3,7 +3,7 @@ msgid "" msgstr "" "Project-Id-Version: vdr-tvguide 0.0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-07-12 16:08+0200\n" +"POT-Creation-Date: 2013-07-18 17:18+0200\n" "PO-Revision-Date: 2012-08-25 17:49+0200\n" "Last-Translator: Horst\n" "Language-Team: \n" @@ -90,6 +90,12 @@ msgstr "In Aufnahmen suchen" msgid "Check for Timer Conflicts" msgstr "Auf Timerkoflikte prüfen" +msgid "Set Folder for" +msgstr "Verzeichnis festlegen für" + +msgid "root video folder" +msgstr "Video Hauptverzeichnis" + msgid "Timer created" msgstr "Timer angelegt" @@ -429,6 +435,9 @@ msgstr "Sehr großer Sprung (Tasten 4 / 6) in Stunden" msgid "Time Format (12h/24h)" msgstr "Zeitformat (12h/24h)" +msgid "Use folders for instant records" +msgstr "Bei Sofortaufnahmen Verzeichnisse benutzen" + msgid "Display Reruns in detailed EPG View" msgstr "Wiederholungen in der detailierten EPG Ansicht anzeigen" diff --git a/recmanager.c b/recmanager.c index 215a425..f744520 100644 --- a/recmanager.c +++ b/recmanager.c @@ -30,10 +30,15 @@ void cRecManager::SetEPGSearchPlugin(void) { } } -cTimer *cRecManager::createTimer(const cEvent *event) { +cTimer *cRecManager::createTimer(const cEvent *event, std::string path) { cTimer *timer = new cTimer(event); Timers.Add(timer); Timers.SetModified(); + if (path.size() > 0) { + std::replace(path.begin(), path.end(), '/', '~'); + cString newFileName = cString::sprintf("%s~%s", path.c_str(), timer->File()); + timer->SetFile(*newFileName); + } isyslog("timer %s added (active)", *timer->ToDescr()); return timer; } diff --git a/recmanager.h b/recmanager.h index 0b010c4..36eb0db 100644 --- a/recmanager.h +++ b/recmanager.h @@ -30,7 +30,7 @@ public: cRecManager (void); void SetEPGSearchPlugin(void); bool EpgSearchAvailable(void) {return epgSearchAvailable;}; - cTimer *createTimer(const cEvent *event); + cTimer *createTimer(const cEvent *event, std::string path); void DeleteTimer(const cEvent *event); void DeleteTimer(int timerID); void SaveTimer(cTimer *timer, cRecMenu *menu); diff --git a/recmenuitem.h b/recmenuitem.h index 780eac9..1091a6b 100644 --- a/recmenuitem.h +++ b/recmenuitem.h @@ -10,6 +10,7 @@ enum eRecMenuState { rmsContinue, rmsClose, rmsInstantRecord, + rmsInstantRecordFolder, rmsIgnoreTimerConflict, rmsDeleteTimerConflictMenu, rmsEditTimerConflictMenu, @@ -101,6 +102,7 @@ public: int GetWidth(void); void SetPixmaps(void); void Draw(void); + cString GetStringValue(void) { return text; }; eRecMenuState ProcessKey(eKeys Key); }; diff --git a/recmenumanager.c b/recmenumanager.c index cd34c12..3d4f089 100644 --- a/recmenumanager.c +++ b/recmenumanager.c @@ -7,6 +7,7 @@ cRecMenuManager::cRecMenuManager(void) { recManager = new cRecManager(); recManager->SetEPGSearchPlugin(); instantRecord = false; + folderChoosen = false; currentConflict = -1; templateID = -1; timer = NULL; @@ -27,6 +28,7 @@ void cRecMenuManager::Start(const cEvent *event) { active = true; activeMenuBuffer = NULL; instantRecord = false; + folderChoosen = false; currentConflict = -1; templateID = -1; timer = NULL; @@ -76,13 +78,26 @@ eOSState cRecMenuManager::StateMachine(eRecMenuState nextState) { //Creating timer for active Event //if no conflict, confirm and exit instantRecord = true; + cString folder = ""; + if (folderChoosen) { + int activeItem = activeMenu->GetActive(false); + if (activeItem > 0) + folder = activeMenu->GetStringValue(activeItem); + } delete activeMenu; - cTimer *timer = recManager->createTimer(event); + cTimer *timer = recManager->createTimer(event, *folder); if (!displayTimerConflict(timer)) { activeMenu = new cRecMenuConfirmTimer(event); activeMenu->Display(); } break; } + case rmsInstantRecordFolder: + //Asking for Folder + folderChoosen = true; + delete activeMenu; + activeMenu = new cRecMenuAskFolder(event); + activeMenu->Display(); + break; case rmsIgnoreTimerConflict: //Confirming created Timer if (instantRecord) { @@ -385,7 +400,7 @@ eOSState cRecMenuManager::StateMachine(eRecMenuState nextState) { break;} case rmsSearchRecord: { const cEvent *ev = activeMenu->GetEventValue(activeMenu->GetActive(false)); - cTimer *timer = recManager->createTimer(ev); + cTimer *timer = recManager->createTimer(ev, ""); activeMenuBuffer = activeMenu; activeMenuBuffer->Hide(); activeMenu = new cRecMenuSearchConfirmTimer(ev); diff --git a/recmenumanager.h b/recmenumanager.h index cc9ac2c..6dce22e 100644 --- a/recmenumanager.h +++ b/recmenumanager.h @@ -12,6 +12,7 @@ private: std::vector conflictList; std::vector epgSearchTemplates; bool instantRecord; + bool folderChoosen; int currentConflict; int templateID; bool searchWithOptions; diff --git a/recmenus.c b/recmenus.c index 4d667d0..ef3279a 100644 --- a/recmenus.c +++ b/recmenus.c @@ -5,7 +5,10 @@ class cRecMenuMain : public cRecMenu { public: cRecMenuMain(bool epgSearchAvailable, bool timerActive, bool switchTimerActive) { if (!timerActive) { - AddMenuItem(new cRecMenuItemButton(tr("Instant Record"), rmsInstantRecord, true)); + eRecMenuState action = (tvguideConfig.recMenuAskFolder) + ?rmsInstantRecordFolder + :rmsInstantRecord; + AddMenuItem(new cRecMenuItemButton(tr("Instant Record"), action, true)); } else { AddMenuItem(new cRecMenuItemButton(tr("Delete Timer"), rmsDeleteTimer, true)); AddMenuItem(new cRecMenuItemButton(tr("Edit Timer"), rmsEditTimer, false)); @@ -37,6 +40,69 @@ public: virtual ~cRecMenuMain(void) {}; }; +// --- cRecMenuAskFolder --------------------------------------------------------- +class cRecMenuAskFolder: public cRecMenu { +private: + std::vector folders; + void readFolders(cList *rootFolders, cString path) { + cList *foldersLevel = NULL; + if (rootFolders) { + foldersLevel = rootFolders; + } else { + foldersLevel = &Folders; + } + for (cNestedItem *folder = foldersLevel->First(); folder; folder = foldersLevel->Next(folder)) { + cString strFolder = cString::sprintf("%s%s", *path, folder->Text()); + folders.push_back(strFolder); + cList *subItems = folder->SubItems(); + if (subItems) { + cString newPath = cString::sprintf("%s%s/", *path, folder->Text()); + readFolders(subItems, newPath); + } + } + } +public: + cRecMenuAskFolder(const cEvent *event) { + SetWidthPercent(80); + cString message = tr("Set Folder for"); + cString headerText = cString::sprintf("%s\n\"%s\"", *message, event->Title()); + cRecMenuItemInfo *infoItem = new cRecMenuItemInfo(*headerText); + infoItem->CalculateHeight(width - 2 * border); + SetHeader(infoItem); + + AddMenuItemScroll(new cRecMenuItemButton(tr("root video folder"), rmsInstantRecord, true, false)); + + readFolders(NULL, ""); + int numFolders = folders.size(); + for (int i=0; i < numFolders; i++) { + AddMenuItemScroll(new cRecMenuItemButton(*folders[i], rmsInstantRecord, false, false)); + if (!CheckHeight()) + break; + } + + CalculateHeight(); + CreatePixmap(); + Arrange(); + }; + cRecMenuItem *GetMenuItem(int number) { + if (number == 0) { + cRecMenuItem *result = new cRecMenuItemButton(tr("root video folder"), rmsInstantRecord, false, false); + return result; + } else if ((number > 0) && (number < folders.size()+1)) { + cRecMenuItem *result = new cRecMenuItemButton(*folders[number-1], rmsInstantRecord, false, false); + return result; + } + return NULL; + }; + + int GetTotalNumMenuItems(void) { + return folders.size()+1; + }; + + virtual ~cRecMenuAskFolder(void) {}; +}; + + // --- cRecMenuConfirmTimer --------------------------------------------------------- class cRecMenuConfirmTimer: public cRecMenu { public: diff --git a/setup.c b/setup.c index 2309f45..2197a6e 100644 --- a/setup.c +++ b/setup.c @@ -82,6 +82,7 @@ void cTvguideSetup::Store(void) { SetupStore("channelHeaderWidthPercent", tvguideConfig.channelHeaderWidthPercent); SetupStore("channelHeaderHeightPercent", tvguideConfig.channelHeaderHeightPercent); SetupStore("footerHeight", tvguideConfig.footerHeight); + SetupStore("recMenuAskFolder", tvguideConfig.recMenuAskFolder); SetupStore("fontIndex", tvguideConfig.fontIndex); SetupStore("FontButtonDelta", tvguideConfig.FontButtonDelta); SetupStore("FontDetailViewDelta", tvguideConfig.FontDetailViewDelta); @@ -167,7 +168,7 @@ void cMenuSetupGeneral::Set(void) { Add(new cMenuEditIntItem(tr("Big Step (Keys 1 / 3) in hours"), &tmpTvguideConfig->bigStepHours, 1, 12)); Add(new cMenuEditIntItem(tr("Huge Step (Keys 4 / 6) in hours"), &tmpTvguideConfig->hugeStepHours, 13, 48)); Add(new cMenuEditStraItem(tr("Time Format (12h/24h)"), &tmpTvguideConfig->timeFormat, 2, timeFormatItems)); - + Add(new cMenuEditBoolItem(tr("Use folders for instant records"), &tmpTvguideConfig->recMenuAskFolder)); Add(new cMenuEditBoolItem(tr("Display Reruns in detailed EPG View"), &tmpTvguideConfig->displayRerunsDetailEPGView)); if (tmpTvguideConfig->displayRerunsDetailEPGView) { Add(new cMenuEditIntItem(cString::sprintf("%s%s", indent, tr("Number of reruns to display")), &tmpTvguideConfig->numReruns, 1, 10));