@@ -28,8 +28,12 @@ VideoSelector::VideoSelector(MythScreenStack *parent, QList<ArchiveItem *> *arch
2828 :MythScreenType(parent, " VideoSelector" )
2929{
3030 m_archiveList = archiveList;
31- m_currentParentalLevel = 1 ;
31+ m_currentParentalLevel = ParentalLevel::plNone ;
3232 m_videoList = NULL ;
33+
34+ m_parentalLevelChecker = new ParentalLevelChangeChecker ();
35+ connect (m_parentalLevelChecker, SIGNAL (SigResultReady (bool , ParentalLevel::Level)),
36+ this , SLOT (parentalLevelChanged (bool , ParentalLevel::Level)));
3337}
3438
3539VideoSelector::~VideoSelector (void )
@@ -40,6 +44,8 @@ VideoSelector::~VideoSelector(void)
4044 while (!m_selectedList.isEmpty ())
4145 delete m_selectedList.takeFirst ();
4246 m_selectedList.clear ();
47+
48+ delete m_parentalLevelChecker;
4349}
4450
4551bool VideoSelector::Create (void )
@@ -86,6 +92,8 @@ bool VideoSelector::Create(void)
8692
8793 SetFocusWidget (m_videoButtonList);
8894
95+ setParentalLevel (ParentalLevel::plLowest);
96+
8997 updateSelectedList ();
9098 updateVideoList ();
9199
@@ -112,19 +120,19 @@ bool VideoSelector::keyPressEvent(QKeyEvent *event)
112120 }
113121 else if (action == " 1" )
114122 {
115- setParentalLevel (1 );
123+ setParentalLevel (ParentalLevel::plLowest );
116124 }
117125 else if (action == " 2" )
118126 {
119- setParentalLevel (2 );
127+ setParentalLevel (ParentalLevel::plLow );
120128 }
121129 else if (action == " 3" )
122130 {
123- setParentalLevel (3 );
131+ setParentalLevel (ParentalLevel::plMedium );
124132 }
125133 else if (action == " 4" )
126134 {
127- setParentalLevel (4 );
135+ setParentalLevel (ParentalLevel::plHigh );
128136 }
129137 else
130138 handled = false ;
@@ -521,79 +529,20 @@ void VideoSelector::updateSelectedList()
521529 }
522530}
523531
524- void VideoSelector::setParentalLevel (int which_level )
532+ void VideoSelector::setParentalLevel (ParentalLevel::Level level )
525533{
526- if (which_level < 1 )
527- which_level = 1 ;
528-
529- if (which_level > 4 )
530- which_level = 4 ;
531-
532- if ((which_level > m_currentParentalLevel) && !checkParentPassword ())
533- which_level = m_currentParentalLevel;
534-
535-
536- if (m_currentParentalLevel != which_level)
537- {
538- m_currentParentalLevel = which_level;
539- updateVideoList ();
540- m_plText->SetText (QString::number (which_level));
541- }
534+ m_parentalLevelChecker->Check (m_currentParentalLevel, level);
542535}
543536
544- bool VideoSelector::checkParentPassword ( )
537+ void VideoSelector::parentalLevelChanged ( bool passwordValid, ParentalLevel::Level newLevel )
545538{
546- QDateTime curr_time = QDateTime::currentDateTime ();
547- QString last_time_stamp = gCoreContext ->GetSetting (" VideoPasswordTime" );
548- QString password = gCoreContext ->GetSetting (" VideoAdminPassword" );
549- if (password.length () < 1 )
539+ if (passwordValid)
550540 {
551- return true ;
552- }
553-
554- // See if we recently (and succesfully) asked for a password
555- if (last_time_stamp.length () < 1 )
556- {
557- // Probably first time used
558- }
559- else
560- {
561- QDateTime last_time = QDateTime::fromString (last_time_stamp,
562- Qt::TextDate);
563- if (last_time.secsTo (curr_time) < 120 )
564- {
565- // Two minute window
566- last_time_stamp = curr_time.toString (Qt::TextDate);
567- gCoreContext ->SetSetting (" VideoPasswordTime" , last_time_stamp);
568- gCoreContext ->SaveSetting (" VideoPasswordTime" , last_time_stamp);
569- return true ;
570- }
571- }
572-
573- // See if there is a password set
574- if (password.length () > 0 )
575- {
576- bool ok = false ;
577- MythPasswordDialog *pwd = new MythPasswordDialog (tr (" Parental Pin:" ),
578- &ok,
579- password,
580- GetMythMainWindow ());
581- pwd->exec ();
582- pwd->deleteLater ();
583- if (ok)
584- {
585- // All is good
586- last_time_stamp = curr_time.toString (Qt::TextDate);
587- gCoreContext ->SetSetting (" VideoPasswordTime" , last_time_stamp);
588- gCoreContext ->SaveSetting (" VideoPasswordTime" , last_time_stamp);
589- return true ;
590- }
541+ m_currentParentalLevel = newLevel;
542+ updateVideoList ();
543+ m_plText->SetText (QString::number (newLevel));
591544 }
592545 else
593- {
594- return true ;
595- }
596-
597- return false ;
546+ ShowOkPopup (tr (" You need to enter a valid password for this parental level" ));
598547}
599548
0 commit comments