summaryrefslogtreecommitdiffstats
path: root/abs/core-testing/mythtv/trunk/mythtv-svn/svn_main_menu_popup.patch
blob: 555668369460134d535d3a5c67bf9a4c7623b1b4 (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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
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<DialogCompletionEvent*>(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.
  *