| 2601 | void MythThemedMenu::doMenu() |
| 2602 | { |
| 2603 | int allowsd = gContext->GetNumSetting("AllowQuitShutdown"); |
| 2604 | if (m_menuPopup) |
| 2605 | return; |
| 2606 | QString label = "System Menu"; |
| 2607 | MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); |
| 2608 | m_menuPopup = new MythDialogBox(label, mainStack, "menuPopup"); |
| 2609 | if (m_menuPopup->Create()) |
| 2610 | mainStack->AddScreen(m_menuPopup); |
| 2611 | |
| 2612 | |
| 2613 | if ( allowsd != 0 && allowsd !=4 ) |
| 2614 | { |
| 2615 | m_menuPopup->SetReturnEvent(this,"popmenu_exit"); |
| 2616 | m_menuPopup->AddButton("Shutdown"); |
| 2617 | m_menuPopup->AddButton("Reboot"); |
| 2618 | m_menuPopup->AddButton("About"); |
| 2619 | m_menuPopup->AddButton("Cancel"); |
| 2620 | } |
| 2621 | else |
| 2622 | { |
| 2623 | m_menuPopup->SetReturnEvent(this,"popmenu_noexit"); |
| 2624 | m_menuPopup->AddButton("About"); |
| 2625 | m_menuPopup->AddButton("Cancel"); |
| 2626 | } |
| 2627 | } |
| 2628 | |
| 2629 | void MythThemedMenu::aboutScreen() |
| 2630 | { |
| 2631 | { |
| 2632 | extern const char *myth_source_version; |
| 2633 | extern const char *myth_source_path; |
| 2634 | QString distro_line; |
| 2635 | distro_line=""; |
| 2636 | |
| 2637 | QFile file("/etc/os_myth_release"); |
| 2638 | if ( file.open(IO_ReadOnly | IO_Translate) ) |
| 2639 | { |
| 2640 | QTextStream t( &file ); // use a text stream |
| 2641 | distro_line = t.readLine(); |
| 2642 | file.close(); |
| 2643 | } |
| 2644 | |
| 2645 | QString label = "About MythTV \n \n "; |
| 2646 | label.append(QObject::tr("Revision: ") + myth_source_version + " \n Branch:" + myth_source_path + "\n" + distro_line ); |
| 2647 | |
| 2648 | MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); |
| 2649 | m_menuPopup = new MythDialogBox(label, mainStack, "About"); |
| 2650 | if (m_menuPopup->Create()) |
| 2651 | mainStack->AddScreen(m_menuPopup); |
| 2652 | |
| 2653 | m_menuPopup->SetReturnEvent(this,"About"); |
| 2654 | m_menuPopup->AddButton("OK!"); |
| 2655 | } |
| 2656 | } |
| 2657 | |
| 2658 | void MythThemedMenu::customEvent(QCustomEvent *event) |
| 2659 | { |
| 2660 | if (event->type() == kMythDialogBoxCompletionEventType) |
| 2661 | { |
| 2662 | DialogCompletionEvent *dce = |
| 2663 | dynamic_cast<DialogCompletionEvent*>(event); |
| 2664 | |
| 2665 | QString resultid= dce->GetId(); |
| 2666 | int buttonnum = dce->GetResult(); |
| 2667 | if (resultid == "popmenu_exit") |
| 2668 | { |
| 2669 | if (buttonnum == 0) |
| 2670 | { |
| 2671 | QString halt_cmd = gContext->GetSetting("HaltCommand", |
| 2672 | "sudo /sbin/halt -p"); |
| 2673 | if (!halt_cmd.isEmpty()) |
| 2674 | system(halt_cmd.ascii()); |
| 2675 | } |
| 2676 | |
| 2677 | if (buttonnum == 1) |
| 2678 | { |
| 2679 | QString reboot_cmd = gContext->GetSetting("RebootCommand", |
| 2680 | "sudo /sbin/reboot"); |
| 2681 | if (!reboot_cmd.isEmpty()) |
| 2682 | system(reboot_cmd.ascii()); |
| 2683 | } |
| 2684 | |
| 2685 | if (buttonnum == 2) |
| 2686 | { |
| 2687 | aboutScreen(); |
| 2688 | } |
| 2689 | } |
| 2690 | |
| 2691 | if (resultid == "popmenu_noexit") |
| 2692 | { |
| 2693 | if (buttonnum == 0) |
| 2694 | aboutScreen(); |
| 2695 | } |
| 2696 | |
| 2697 | m_menuPopup = NULL; |
| 2698 | } |
| 2699 | } |