Index: libs/libmythui/myththemedmenu.h =================================================================== --- libs/libmythui/myththemedmenu.h (revision 19291) +++ libs/libmythui/myththemedmenu.h (working copy) @@ -2,6 +2,7 @@ #define MYTHTHEMEDMENU_H_ #include "mythscreentype.h" +#include "mythdialogbox.h" #include "mythuistatetype.h" #include "mythuibuttonlist.h" #include "xmlparsebase.h" @@ -77,6 +78,11 @@ void ReloadExitKey(void); virtual void aboutToShow(void); + void doMenu(); + void aboutScreen(); + MythDialogBox *m_menuPopup; + void customEvent(QEvent *event); + protected: virtual bool keyPressEvent(QKeyEvent *e); Index: libs/libmythui/myththemedmenu.cpp =================================================================== --- libs/libmythui/myththemedmenu.cpp (revision 19291) +++ libs/libmythui/myththemedmenu.cpp (working copy) @@ -32,6 +32,7 @@ m_callbackdata = NULL; m_killable = false; + } MythThemedMenuState::~MythThemedMenuState() @@ -95,7 +96,7 @@ m_exitModifier = -1; m_menumode = ""; m_buttonList = NULL; - + m_menuPopup = NULL; if (!m_state) { m_state = new MythThemedMenuState(parent, "themedmenustate"); @@ -271,6 +272,10 @@ m_wantpop = true; } } + else if (action == "MENU") + { + doMenu(); + } else handled = false; } @@ -292,6 +297,154 @@ updateLCD(); } +void MythThemedMenu::doMenu() +{ + + if (m_menuPopup) + return; + int allowsd = GetMythDB()->GetNumSetting("AllowQuitShutdown"); + int override_menu = GetMythDB()->GetNumSetting("OverRideExitMenu"); + QString label = "System Menu"; + MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); + m_menuPopup = new MythDialogBox(label, mainStack, "menuPopup"); + if (m_menuPopup->Create()) + mainStack->AddScreen(m_menuPopup); + if ( override_menu == 0 ) + { + if ( allowsd != 0 && allowsd !=4 ) + { + m_menuPopup->SetReturnEvent(this,"popmenu_exit"); + m_menuPopup->AddButton("Shutdown"); + m_menuPopup->AddButton("Reboot"); + } + else + { + m_menuPopup->SetReturnEvent(this,"popmenu_noexit"); + } + } + if ( override_menu == 5 ) + { // reboot + m_menuPopup->SetReturnEvent(this,"popmenu_reboot"); + m_menuPopup->AddButton("Reboot"); + } + else if ( override_menu == 2 || override_menu == 4 ) + { // shutdown + m_menuPopup->SetReturnEvent(this,"popmenu_shutdown"); + m_menuPopup->AddButton("Shutdown"); + } + else if ( override_menu == 3 || override_menu == 6 ) + { // both + m_menuPopup->SetReturnEvent(this,"popmenu_exit"); + m_menuPopup->AddButton("Shutdown"); + m_menuPopup->AddButton("Reboot"); + } + 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(QFile::ReadOnly)) + { + 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(QEvent *event) +{ + if (event->type() == kMythDialogBoxCompletionEventType) + { + DialogCompletionEvent *dce = + dynamic_cast(event); + QString resultid= dce->GetId(); + int buttonnum = dce->GetResult(); + QString halt_cmd=GetMythDB()->GetSetting("HaltCommand"); + QString reboot_cmd=GetMythDB()->GetSetting("RebootCommand"); + + if (resultid == "popmenu_exit") + { + if (buttonnum == 0) + { + if (!halt_cmd.isEmpty() ) + system(halt_cmd.toAscii()); + } + + if (buttonnum == 1) + { + if (!reboot_cmd.isEmpty() ) + system(reboot_cmd.toAscii()); + } + + if (buttonnum == 2) + { + aboutScreen(); + } + } + + if (resultid == "popmenu_noexit") + { + if (buttonnum == 0) + aboutScreen(); + } + + if (resultid == "popmenu_reboot") + { + if (buttonnum == 0) + { + if (!reboot_cmd.isEmpty() ) + system(reboot_cmd.toAscii()); + } + + if (buttonnum == 1) + { + aboutScreen(); + } + } + + if (resultid == "popmenu_shutdown") + { + if (buttonnum == 0) + { + if (!halt_cmd.isEmpty() ) + system(halt_cmd.toAscii()); + } + + if (buttonnum == 1) + { + aboutScreen(); + } + } + + m_menuPopup = NULL; + } +} + /** \brief Parses the element's tags and set the ThemeButton's type, * text, depends, and action, then adds the button. *