소스 검색

TitleBar show airplane mode icon

cuu 5 년 전
부모
커밋
74e7f8ab69
3개의 변경된 파일20개의 추가작업 그리고 11개의 파일을 삭제
  1. 5 9
      Menu/GameShell/10_Settings/Airplane/__init__.py
  2. 1 0
      sys.py/UI/main_screen.py
  3. 14 2
      sys.py/UI/title_bar.py

+ 5 - 9
Menu/GameShell/10_Settings/Airplane/__init__.py

@@ -88,8 +88,6 @@ class AirplanePage(Page):
 
     _DrawOnce = False
     _Scroller = None
-
-    _InAirPlaneMode = False
     
     def __init__(self):
         Page.__init__(self)
@@ -143,22 +141,20 @@ class AirplanePage(Page):
             self._Scrolled += dis
 
     def ToggleMode(self):
-        print("ToggleMode")
         out = commands.getstatusoutput('rfkill list | grep yes | cut -d " " -f3')
         print out
         if out[1] == "yes":
-            self._InAirPlaneMode = True
-
             self._Screen._MsgBox.SetText("Turning On")
             self._Screen._MsgBox.Draw()
             commands.getstatusoutput("rfkill unblock all")
+            self._Screen._TitleBar._InAirPlaneMode = False
         
         else:
-            self._InAirPlaneMode = False
             self._Screen._MsgBox.SetText("Turning Off")
             self._Screen._MsgBox.Draw()
             commands.getstatusoutput("rfkill block all")
-            
+            self._Screen._TitleBar._InAirPlaneMode = True
+
         
     def OnLoadCb(self):
         self._Scrolled = 0
@@ -166,9 +162,9 @@ class AirplanePage(Page):
         self._DrawOnce = False
         out = commands.getstatusoutput('rfkill list | grep yes | cut -d " " -f3')
         if out[1] == "yes":
-            self._InAirPlaneMode = True
+            self._Screen._TitleBar._InAirPlaneMode = True
         else:
-            self._InAirPlaneMode = False
+            self._Screen._TitleBar._InAirPlaneMode = False
         
         
     def OnReturnBackCb(self):

+ 1 - 0
sys.py/UI/main_screen.py

@@ -136,6 +136,7 @@ class MainScreen(object):
     _IconFont    = fonts["varela15"]
     _SkinManager = None
     
+    
     def __init__(self):
         self._Pages = []
         self._MyPageStack = PageStack()

+ 14 - 2
sys.py/UI/title_bar.py

@@ -3,6 +3,7 @@
 import pygame
 import os
 import sys
+import commands
 
 from datetime import datetime
 
@@ -46,6 +47,7 @@ class TitleBar:
 
     _SkinManager = None
 
+    _InAirPlaneMode = False
     
     def __init__(self):
         self._Icons = {}
@@ -237,7 +239,13 @@ class TitleBar:
         if is_wifi_connected_now():
             print("wifi is connected")
             print( wifi_strength())
-
+        else:
+            out = commands.getstatusoutput('rfkill list | grep yes | cut -d " " -f3')
+            if out[1] == "yes":
+                self._InAirPlaneMode = True
+            else:
+                self._InAirPlaneMode = False
+            
     def ClearCanvas(self):
         self._CanvasHWND.fill( self._SkinManager.GiveColor("TitleBg") )
 
@@ -293,7 +301,11 @@ class TitleBar:
                 self._Icons["wifistatus"].Draw()
                 print("strength error")
         else:
-            self._Icons["wifistatus"]._IconIndex = 0
+            if self._InAirPlaneMode == False:
+                self._Icons["wifistatus"]._IconIndex = 0
+            else:
+                self._Icons["wifistatus"]._IconIndex = 5 ## airplane mode icon
+            
             self._Icons["wifistatus"].NewCoord(start_x+self._icon_width+5,self._icon_height/2+(self._BarHeight-self._icon_height)/2)
             self._Icons["wifistatus"].Draw()