From 4c8475e5ba0d5a1fa774ebabcddc4aad5b4a5618 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Thu, 11 Oct 2012 14:11:05 +0200 Subject: [PATCH] Neutrino: rework COnOffNotifier and use it if possible, ported from tuxbox cvs Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/7b06b3fd3888143a2b878af5e141e0383a955807 Author: Jacek Jendrzej Date: 2012-10-11 (Thu, 11 Oct 2012) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/miscsettings_menu.cpp | 6 ++++-- src/gui/miscsettings_menu.h | 2 +- src/gui/moviebrowser.cpp | 3 ++- src/gui/nfs.cpp | 34 ++++------------------------- src/gui/osd_setup.h | 11 ---------- src/system/setting_helpers.cpp | 39 +++++++++------------------------- src/system/setting_helpers.h | 20 ++++++----------- 7 files changed, 28 insertions(+), 87 deletions(-) diff --git a/src/gui/miscsettings_menu.cpp b/src/gui/miscsettings_menu.cpp index bc05e028c..409d0ddd4 100644 --- a/src/gui/miscsettings_menu.cpp +++ b/src/gui/miscsettings_menu.cpp @@ -281,8 +281,10 @@ void CMiscMenue::showMiscSettingsMenuEnergy(CMenuWidget *ms_energy) CStringInput * miscSettings_shutdown_count = new CStringInput(LOCALE_MISCSETTINGS_SHUTDOWN_COUNT, g_settings.shutdown_count, 3, LOCALE_MISCSETTINGS_SHUTDOWN_COUNT_HINT1, LOCALE_MISCSETTINGS_SHUTDOWN_COUNT_HINT2, "0123456789 "); CMenuForwarder *m2 = new CMenuDForwarder(LOCALE_MISCSETTINGS_SHUTDOWN_COUNT, !g_settings.shutdown_real, g_settings.shutdown_count, miscSettings_shutdown_count); m2->setHint("", LOCALE_MENU_HINT_SHUTDOWN_COUNT); - - miscNotifier = new CMiscNotifier( m1, m2 ); + + miscNotifier = new COnOffNotifier(1); + miscNotifier->addItem(m1); + miscNotifier->addItem(m2); CMenuOptionChooser * mc = new CMenuOptionChooser(LOCALE_MISCSETTINGS_SHUTDOWN_REAL, &g_settings.shutdown_real, OPTIONS_OFF1_ON0_OPTIONS, OPTIONS_OFF1_ON0_OPTION_COUNT, true, miscNotifier); mc->setHint("", LOCALE_MENU_HINT_SHUTDOWN_REAL); diff --git a/src/gui/miscsettings_menu.h b/src/gui/miscsettings_menu.h index 84e4e72b5..b05d0c68a 100644 --- a/src/gui/miscsettings_menu.h +++ b/src/gui/miscsettings_menu.h @@ -40,7 +40,7 @@ class CMiscMenue : public CMenuTarget private: CFanControlNotifier *fanNotifier; CSectionsdConfigNotifier* sectionsdConfigNotifier; - CMiscNotifier* miscNotifier; + COnOffNotifier* miscNotifier; int width; diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index b7fa267e8..b651122ee 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -2977,7 +2977,8 @@ bool CMovieBrowser::showMenu(MI_MOVIE_INFO* /*movie_info*/) { dirInput[i] = new CFileChooser(&m_settings.storageDir[i]); forwarder[i] = new CMenuForwarder(LOCALE_MOVIEBROWSER_DIR, m_settings.storageDirUsed[i], m_settings.storageDir[i], dirInput[i]); - notifier[i] = new COnOffNotifier(forwarder[i]); + notifier[i] = new COnOffNotifier(); + notifier[i]->addItem(forwarder[i]); chooser[i] = new CMenuOptionChooser(LOCALE_MOVIEBROWSER_USE_DIR , &m_settings.storageDirUsed[i] , MESSAGEBOX_YES_NO_OPTIONS, MESSAGEBOX_YES_NO_OPTIONS_COUNT, true,notifier[i]); optionsMenuDir.addItem(chooser[i] ); optionsMenuDir.addItem(forwarder[i] ); diff --git a/src/gui/nfs.cpp b/src/gui/nfs.cpp index eacc03661..2916475f7 100644 --- a/src/gui/nfs.cpp +++ b/src/gui/nfs.cpp @@ -51,37 +51,9 @@ #include #include #include - +#include #include -class CNFSMountGuiNotifier : public CChangeObserver -{ -private: - CMenuForwarder *m_opt1,*m_opt2, *m_user, *m_pass; - int *m_type; -public: - CNFSMountGuiNotifier( CMenuForwarder* a3, CMenuForwarder* a4 , int* type) - { - m_user = a3; - m_pass = a4; - m_type = type; - } - bool changeNotify(const neutrino_locale_t /*OptionName*/, void *) - { - if(*m_type == (int)CFSMounter::NFS) - { - m_user->setActive (false); - m_pass->setActive (false); - } - else - { - m_user->setActive (true); - m_pass->setActive (true); - } - return true; - } -}; - CNFSMountGui::CNFSMountGui() { // FIXME #warning move probing from exec() to fsmounter @@ -266,7 +238,9 @@ int CNFSMountGui::menuEntry(int nr) CMenuForwarder * macInput_fwd = new CMenuForwarder(LOCALE_RECORDINGMENU_SERVER_MAC, true, g_settings.network_nfs_mac[nr], &macInput); CMenuForwarder *mountnow_fwd = new CMenuForwarder(LOCALE_NFS_MOUNTNOW, true, NULL, this, cmd); mountnow_fwd->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true); - CNFSMountGuiNotifier notifier(username_fwd, password_fwd, type); + COnOffNotifier notifier(CFSMounter::NFS); + notifier.addItem(username_fwd); + notifier.addItem(password_fwd); mountMenuEntryW.addItem(new CMenuOptionChooser(LOCALE_NFS_TYPE, type, NFS_TYPE_OPTIONS, NFS_TYPE_OPTION_COUNT, typeEnabled, ¬ifier)); mountMenuEntryW.addItem(new CMenuForwarder(LOCALE_NFS_IP , true, g_settings.network_nfs_ip[nr], &ipInput )); diff --git a/src/gui/osd_setup.h b/src/gui/osd_setup.h index 99db7df0f..e62f6f793 100644 --- a/src/gui/osd_setup.h +++ b/src/gui/osd_setup.h @@ -90,15 +90,4 @@ class COsdSetup : public CMenuTarget, public CChangeObserver int showContextChanlistMenu(); }; - -class COsdSetupChannelLogoNotifier : public CChangeObserver -{ - private: - CMenuForwarder* toDisable1; - CMenuOptionChooser* toDisable2; - public: - COsdSetupChannelLogoNotifier( CMenuForwarder*, CMenuOptionChooser* ); - bool changeNotify(const neutrino_locale_t, void * Data); -}; - #endif diff --git a/src/system/setting_helpers.cpp b/src/system/setting_helpers.cpp index 677b696f9..b93cbb0d1 100644 --- a/src/system/setting_helpers.cpp +++ b/src/system/setting_helpers.cpp @@ -88,43 +88,24 @@ extern cDemux *pcrDemux; extern "C" int pinghost( const char *hostname ); -// gui/moviebrowser.cpp -COnOffNotifier::COnOffNotifier( CMenuItem* a1,CMenuItem* a2,CMenuItem* a3,CMenuItem* a4,CMenuItem* a5) +COnOffNotifier::COnOffNotifier(int OffValue) { - number = 0; - if(a1 != NULL){ toDisable[0] =a1;number++;}; - if(a2 != NULL){ toDisable[1] =a2;number++;}; - if(a3 != NULL){ toDisable[2] =a3;number++;}; - if(a4 != NULL){ toDisable[3] =a4;number++;}; - if(a5 != NULL){ toDisable[4] =a5;number++;}; + offValue = OffValue; } bool COnOffNotifier::changeNotify(const neutrino_locale_t, void *Data) { - if(*(int*)(Data) == 0) - { - for (int i=0; isetActive(false); - } - else - { - for (int i=0; isetActive(true); - } - return false; + bool active = (*(int*)(Data) != offValue); + + for (std::vector::iterator it = toDisable.begin(); it != toDisable.end(); it++) + (*it)->setActive(active); + + return false; } -//used in gui/miscsettings_menu.cpp -CMiscNotifier::CMiscNotifier( CMenuItem* i1, CMenuItem* i2) +void COnOffNotifier::addItem(CMenuItem* menuItem) { - toDisable[0]=i1; - toDisable[1]=i2; -} -bool CMiscNotifier::changeNotify(const neutrino_locale_t, void *) -{ - toDisable[0]->setActive(!g_settings.shutdown_real); - toDisable[1]->setActive(!g_settings.shutdown_real); - return false; + toDisable.push_back(menuItem); } bool CSectionsdConfigNotifier::changeNotify(const neutrino_locale_t, void *) diff --git a/src/system/setting_helpers.h b/src/system/setting_helpers.h index a8eda16bc..22d0b27c9 100644 --- a/src/system/setting_helpers.h +++ b/src/system/setting_helpers.h @@ -55,22 +55,16 @@ class CGenericMenuActivate }; class COnOffNotifier : public CChangeObserver -{ - private: - int number; - CMenuItem* toDisable[5]; - public: - COnOffNotifier (CMenuItem* a1,CMenuItem* a2 = NULL,CMenuItem* a3 = NULL,CMenuItem* a4 = NULL,CMenuItem* a5 = NULL); - bool changeNotify(const neutrino_locale_t, void *Data); -}; - -class CMiscNotifier : public CChangeObserver { private: - CMenuItem* toDisable[2]; + int offValue; + std::vector toDisable; + public: - CMiscNotifier( CMenuItem*, CMenuItem* ); - bool changeNotify(const neutrino_locale_t, void *); + COnOffNotifier(int OffValue = 0); + bool changeNotify(const neutrino_locale_t, void *Data); + + void addItem(CMenuItem* menuItem); }; class CSectionsdConfigNotifier : public CChangeObserver