summaryrefslogtreecommitdiffstats
path: root/abs/mv-core/myth/release-fixes/mythtv-release-fixes/myththemedmenu.cpp.patch
blob: f5baccd4fda5fa08eb3a4f054158959557318405 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
--- 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<DialogCompletionEvent*>(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;
+    }
+}