summaryrefslogtreecommitdiffstats
path: root/abs/core/mythtv/stable-30/mythtv/addEnableDisableAutoShutdownToSystemMenu.patch
blob: b14e2e0805b41ff010dbbf45468928da3f507ebf (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
diff --git a/mythtv/libs/libmythui/myththemedmenu.cpp b/mythtv/libs/libmythui/myththemedmenu.cpp
index ed2e54c..77aaf73 100644
--- a/mythtv/libs/libmythui/myththemedmenu.cpp
+++ b/mythtv/libs/libmythui/myththemedmenu.cpp
@@ -308,6 +308,8 @@ void MythThemedMenu::ShowMenu()
         return;
 
     int override_menu = GetMythDB()->GetNumSetting("OverrideExitMenu");
+    int MythShutdownLock = GetMythDB()->GetNumSetting("MythShutdownLock");
+    int idleTimeoutSecs = GetMythDB()->GetNumSetting("idleTimeoutSecs");
     QString label = tr("System Menu");
     MythScreenStack* mainStack = GetMythMainWindow()->GetMainStack();
     m_menuPopup = new MythDialogBox(label, mainStack, "menuPopup");
@@ -325,6 +327,21 @@ void MythThemedMenu::ShowMenu()
     if (override_menu != 7)
         m_menuPopup->AddButton(tr("Exit application"), QVariant("exit"));
 
+    // don't offer to enable/disable auto shutdown if auto shutdown is disabled
+    if (idleTimeoutSecs != 0)
+    {
+        if (MythShutdownLock == 0)
+        {
+            m_menuPopup->AddButton(tr("Disable Auto Shutdown"),
+                                    QVariant("lockShutdown"));
+        }
+        else
+        {
+            m_menuPopup->AddButton(tr("Enable Auto Shutdown"),
+                                    QVariant("unlockShutdown"));
+        }
+    }
+
     switch (override_menu)
     {
         case 2:
@@ -416,6 +433,14 @@ void MythThemedMenu::customEvent(QEvent *event)
                 QString arg("exiting_app");
                 m_state->m_callback(m_state->m_callbackdata, arg);
             }
+            else if (action == "lockShutdown")
+            {
+                GetMythDB()->SaveSettingOnHost("MythShutdownLock", "1", NULL);
+            }
+            else if (action == "unlockShutdown")
+            {
+                GetMythDB()->SaveSettingOnHost("MythShutdownLock", "0", NULL);
+            }
         }
         else if (resultid == "password")
         {