--- libs/libmythui/myththemedmenu.cpp.orig 2008-01-31 15:26:38.000000000 +0000 +++ libs/libmythui/myththemedmenu.cpp 2008-02-07 22:24:27.000000000 +0000 @@ -2102,6 +2102,10 @@ } lastbutton = NULL; } + else if (action == "MENU") + { + parent->doMenu(); + } else if (action == "EJECT") { myth_eject(); @@ -2482,6 +2486,8 @@ if (d->foundtheme) d->parseMenu(menufile); + + m_menuPopup = NULL; } MythThemedMenu::~MythThemedMenu(void) @@ -2592,3 +2598,102 @@ MythScreenType::aboutToShow(); d->updateLCD(); } +void MythThemedMenu::doMenu() +{ + int allowsd = gContext->GetNumSetting("AllowQuitShutdown"); + if (m_menuPopup) + return; + QString label = "System Menu"; + MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); + m_menuPopup = new MythDialogBox(label, mainStack, "menuPopup"); + if (m_menuPopup->Create()) + mainStack->AddScreen(m_menuPopup); + + + if ( allowsd != 0 && allowsd !=4 ) + { + m_menuPopup->SetReturnEvent(this,"popmenu_exit"); + m_menuPopup->AddButton("Shutdown"); + m_menuPopup->AddButton("Reboot"); + m_menuPopup->AddButton("About"); + m_menuPopup->AddButton("Cancel"); + } + else + { + m_menuPopup->SetReturnEvent(this,"popmenu_noexit"); + m_menuPopup->AddButton("About"); + m_menuPopup->AddButton("Cancel"); + } +} + +void MythThemedMenu::aboutScreen() +{ +{ + extern const char *myth_source_version; + extern const char *myth_source_path; + QString distro_line; + distro_line=""; + + QFile file("/etc/os_myth_release"); + if ( file.open(IO_ReadOnly | IO_Translate) ) + { + QTextStream t( &file ); // use a text stream + distro_line = t.readLine(); + file.close(); + } + + QString label = ""; + label.append(QObject::tr("Revision: ") + myth_source_version + " \n Branch:" + myth_source_path + "\n" + distro_line ); + + MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); + m_menuPopup = new MythDialogBox(label, mainStack, "About"); + if (m_menuPopup->Create()) + mainStack->AddScreen(m_menuPopup); + + m_menuPopup->SetReturnEvent(this,"About"); + m_menuPopup->AddButton("OK!"); + } +} + +void MythThemedMenu::customEvent(QCustomEvent *event) +{ + if (event->type() == kMythDialogBoxCompletionEventType) + { + DialogCompletionEvent *dce = + dynamic_cast(event); + + QString resultid= dce->GetId(); + int buttonnum = dce->GetResult(); + if (resultid == "popmenu_exit") + { + if (buttonnum == 0) + { + QString halt_cmd = gContext->GetSetting("HaltCommand", + "sudo /sbin/halt -p"); + if (!halt_cmd.isEmpty()) + system(halt_cmd.ascii()); + } + + if (buttonnum == 1) + { + QString reboot_cmd = gContext->GetSetting("RebootCommand", + "sudo /sbin/reboot"); + if (!reboot_cmd.isEmpty()) + system(reboot_cmd.ascii()); + } + + if (buttonnum == 2) + { + aboutScreen(); + } + } + + if (resultid == "popmenu_noexit") + { + if (buttonnum == 0) + aboutScreen(); + } + + m_menuPopup = NULL; + } +}