Ticket #4571: myththemedmenu.cpp.patch

File myththemedmenu.cpp.patch, 2.1 KB (added by james.meyer@…, 16 years ago)
  • libs/libmythui/myththemedmenu.cpp

    old new  
    21022102            }
    21032103            lastbutton = NULL;
    21042104        }
     2105        else if (action == "MENU")
     2106        {
     2107            parent->doMenu();
     2108        }
    21052109        else if (action == "EJECT")
    21062110        {
    21072111            myth_eject();
     
    24822486
    24832487    if (d->foundtheme)
    24842488        d->parseMenu(menufile);
     2489
     2490    m_menuPopup = NULL;
    24852491}
    24862492
    24872493MythThemedMenu::~MythThemedMenu(void)
     
    25922598    MythScreenType::aboutToShow();
    25932599    d->updateLCD();
    25942600}
     2601void MythThemedMenu::doMenu()
     2602{
     2603    int allowsd = gContext->GetNumSetting("AllowQuitShutdown");
     2604
     2605    if ( allowsd != 0 && allowsd !=4  )
     2606    {
     2607        if (m_menuPopup)
     2608            return;
     2609        QString label = "System Menu";
     2610        MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();
     2611        m_menuPopup = new MythDialogBox(label, mainStack, "menuPopup");
     2612        if (m_menuPopup->Create())
     2613            mainStack->AddScreen(m_menuPopup);
     2614
     2615        m_menuPopup->SetReturnEvent(this,"popmenu");
     2616        m_menuPopup->AddButton("Shutdown");
     2617        m_menuPopup->AddButton("Reboot");
     2618        m_menuPopup->AddButton("Cancel");
     2619    }
     2620}
     2621
     2622void MythThemedMenu::customEvent(QCustomEvent *event)
     2623{
     2624    if (event->type() == kMythDialogBoxCompletionEventType)
     2625    {
     2626        DialogCompletionEvent *dce =
     2627                dynamic_cast<DialogCompletionEvent*>(event);
     2628
     2629        QString resultid= dce->GetId();
     2630        int buttonnum  = dce->GetResult();
     2631
     2632        if (buttonnum == 0)
     2633        {
     2634            QString halt_cmd = gContext->GetSetting("HaltCommand",
     2635                    "sudo /sbin/halt -p");
     2636            if (!halt_cmd.isEmpty())
     2637                system(halt_cmd.ascii());
     2638        }
     2639
     2640        if (buttonnum == 1)
     2641        {
     2642            QString reboot_cmd = gContext->GetSetting("RebootCommand",
     2643                    "sudo /sbin/reboot");
     2644            if (!reboot_cmd.isEmpty())
     2645                system(reboot_cmd.ascii());
     2646        }
     2647
     2648        m_menuPopup = NULL;
     2649    }
     2650}