From d49b95fc4753a6d7472d43423debec8453f6983c Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Thu, 20 Jun 2019 21:32:01 +0200 Subject: [PATCH] moviebrowser: clean up showMenu(), directory options menu outsourced Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/8d01af22a5d53728a0a50bb1ae5831edd0ec3704 Author: Thilo Graf Date: 2019-06-20 (Thu, 20 Jun 2019) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/moviebrowser/mb.cpp | 68 +++++++++++++++++++------------------ src/gui/moviebrowser/mb.h | 2 ++ 2 files changed, 37 insertions(+), 33 deletions(-) diff --git a/src/gui/moviebrowser/mb.cpp b/src/gui/moviebrowser/mb.cpp index 15c008ecd..716dcb28a 100644 --- a/src/gui/moviebrowser/mb.cpp +++ b/src/gui/moviebrowser/mb.cpp @@ -3604,47 +3604,49 @@ void CMovieBrowser::initParentalMenu(CMenuWidget *ParentalMenu) ParentalMenu->addItem(new CMenuOptionChooser(LOCALE_MOVIEBROWSER_MENU_PARENTAL_LOCK_RATE_HEAD, (int*)(&m_settings.parentalLockAge), MESSAGEBOX_PARENTAL_LOCKAGE_OPTIONS, MESSAGEBOX_PARENTAL_LOCKAGE_OPTION_COUNT, true)); } +void CMovieBrowser::initOptionsDirMenu(CMenuWidget *OptionsMenuDir, std::vector& v_notifiers) +{ + OptionsMenuDir->addIntroItems(LOCALE_MOVIEBROWSER_MENU_DIRECTORIES_HEAD); + OptionsMenuDir->addItem(new CMenuOptionChooser(LOCALE_MOVIEBROWSER_USE_REC_DIR, (int*)(&m_settings.store.storageDirRecUsed), MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true)); + OptionsMenuDir->addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_DIR, false, g_settings.network_nfs_recordingdir)); + + OptionsMenuDir->addItem(new CMenuOptionChooser(LOCALE_MOVIEBROWSER_USE_MOVIE_DIR, (int*)(&m_settings.store.storageDirMovieUsed), MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true)); + OptionsMenuDir->addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_DIR, false, g_settings.network_nfs_moviedir)); + OptionsMenuDir->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_MOVIEBROWSER_DIRECTORIES_ADDITIONAL)); + + for (int i = 0; i < MB_MAX_DIRS ; i++) + { + CFileChooser *dirInput = new CFileChooser(&m_settings.store.storageDir[i]); + CMenuForwarder *forwarder = new CMenuDForwarder(LOCALE_MOVIEBROWSER_DIR, m_settings.store.storageDirUsed[i], m_settings.store.storageDir[i], dirInput); + + v_notifiers.push_back(new COnOffNotifier()); + v_notifiers[i]->addItem(forwarder); + CMenuOptionChooser *chooser = new CMenuOptionChooser(LOCALE_MOVIEBROWSER_USE_DIR, &m_settings.store.storageDirUsed[i], MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true, v_notifiers[i]); + OptionsMenuDir->addItem(chooser); + + OptionsMenuDir->addItem(forwarder); + + if (i != (MB_MAX_DIRS - 1)) + OptionsMenuDir->addItem(GenericMenuSeparator); + } +} + bool CMovieBrowser::showMenu(bool calledExternally) { /* first clear screen */ framebuffer->paintBackground(); - int i; - /********************************************************************/ - /** directory menu ******************************************************/ + // directory menu CDirMenu dirMenu(&m_dir); - /********************************************************************/ - /** options menu **************************************************/ - // init parental lock menu CMenuWidget parentalMenu(LOCALE_MOVIEBROWSER_HEAD, NEUTRINO_ICON_MOVIEPLAYER); initParentalMenu(&parentalMenu); - /********************************************************************/ - /** optionsVerzeichnisse **************************************************/ + // init options menu for directories CMenuWidget optionsMenuDir(LOCALE_MOVIEBROWSER_HEAD, NEUTRINO_ICON_MOVIEPLAYER); - optionsMenuDir.addIntroItems(LOCALE_MOVIEBROWSER_MENU_DIRECTORIES_HEAD); - optionsMenuDir.addItem(new CMenuOptionChooser(LOCALE_MOVIEBROWSER_USE_REC_DIR, (int*)(&m_settings.store.storageDirRecUsed), MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true)); - optionsMenuDir.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_DIR, false, g_settings.network_nfs_recordingdir)); - - optionsMenuDir.addItem(new CMenuOptionChooser(LOCALE_MOVIEBROWSER_USE_MOVIE_DIR, (int*)(&m_settings.store.storageDirMovieUsed), MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true)); - optionsMenuDir.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_DIR, false, g_settings.network_nfs_moviedir)); - optionsMenuDir.addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_MOVIEBROWSER_DIRECTORIES_ADDITIONAL)); - - COnOffNotifier* notifier[MB_MAX_DIRS]; - for (i = 0; i < MB_MAX_DIRS ; i++) - { - CFileChooser *dirInput = new CFileChooser(&m_settings.store.storageDir[i]); - CMenuForwarder *forwarder = new CMenuDForwarder(LOCALE_MOVIEBROWSER_DIR, m_settings.store.storageDirUsed[i], m_settings.store.storageDir[i], dirInput); - notifier[i] = new COnOffNotifier(); - notifier[i]->addItem(forwarder); - CMenuOptionChooser *chooser = new CMenuOptionChooser(LOCALE_MOVIEBROWSER_USE_DIR, &m_settings.store.storageDirUsed[i], MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true,notifier[i]); - optionsMenuDir.addItem(chooser); - optionsMenuDir.addItem(forwarder); - if (i != (MB_MAX_DIRS - 1)) - optionsMenuDir.addItem(GenericMenuSeparator); - } + std::vector notifiers; + initOptionsDirMenu(&optionsMenuDir, notifiers); /********************************************************************/ /** optionsMenuBrowser **************************************************/ @@ -3680,7 +3682,7 @@ bool CMovieBrowser::showMenu(bool calledExternally) optionsMenuBrowser.addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_MOVIEBROWSER_BROWSER_ROW_HEAD)); optionsMenuBrowser.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_BROWSER_ROW_NR, true, browserRowNrIntInput.getValue(), &browserRowNrIntInput)); optionsMenuBrowser.addItem(GenericMenuSeparator); - for (i = 0; i < MB_MAX_ROWS; i++) + for (int i = 0; i < MB_MAX_ROWS; i++) { CIntInput* browserRowWidthIntInput = new CIntInput(LOCALE_MOVIEBROWSER_BROWSER_ROW_WIDTH,(int *)&m_settings.browserRowWidth[i], 3, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); optionsMenuBrowser.addItem(new CMenuOptionChooser(LOCALE_MOVIEBROWSER_BROWSER_ROW_ITEM, (int*)(&m_settings.browserRowItem[i]), MESSAGEBOX_BROWSER_ROW_ITEM, MESSAGEBOX_BROWSER_ROW_ITEM_COUNT, true, NULL, CRCInput::convertDigitToKey(i+1), NULL, true, true)); @@ -3756,7 +3758,7 @@ bool CMovieBrowser::showMenu(bool calledExternally) m_settings.browserRowNr = MB_MAX_ROWS; if (m_settings.browserRowNr < 1) m_settings.browserRowNr = 1; - for (i = 0; i < m_settings.browserRowNr; i++) + for (int i = 0; i < m_settings.browserRowNr; i++) { if (m_settings.browserRowWidth[i] > 100) m_settings.browserRowWidth[i] = 100; @@ -3794,8 +3796,8 @@ bool CMovieBrowser::showMenu(bool calledExternally) } else saveSettings(&m_settings); - for (i = 0; i < MB_MAX_DIRS; i++) - delete notifier[i]; + for (size_t i = 0; i < notifiers.size(); i++) + delete notifiers[i]; delete nfs; diff --git a/src/gui/moviebrowser/mb.h b/src/gui/moviebrowser/mb.h index 90fd9e230..873b7676b 100644 --- a/src/gui/moviebrowser/mb.h +++ b/src/gui/moviebrowser/mb.h @@ -57,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -351,6 +352,7 @@ class CMovieBrowser : public CMenuTarget, public CProgressSignals void initSeriesMenu(CMenuWidget *SeriesMenu, MI_MOVIE_INFO* movie_info); void initUpdateMovieInfoMenu(CMenuWidget *MovieInfoMenuUpdate); void initParentalMenu(CMenuWidget *ParentalMenu); + void initOptionsDirMenu(CMenuWidget *OptionsMenuDir, std::vector& v_notifiers); int showMovieInfoMenu(MI_MOVIE_INFO* movie_info); // P2 int showMovieCutMenu(); // P2 int showStartPosSelectionMenu(void); // P2