mirror of
https://github.com/clockworkpi/launcher.git
synced 2025-12-12 17:58:50 +01:00
Merge pull request #5 from cuu/master
fix bug in compare git versions and main_screen's MsgBox
This commit is contained in:
commit
3bb88eb892
@ -21,6 +21,7 @@ from UI.download import Download
|
|||||||
from UI.download_process_page import DownloadProcessPage
|
from UI.download_process_page import DownloadProcessPage
|
||||||
|
|
||||||
from libs.roundrects import aa_round_rect
|
from libs.roundrects import aa_round_rect
|
||||||
|
from libs.DBUS import is_wifi_connected_now
|
||||||
|
|
||||||
import config
|
import config
|
||||||
|
|
||||||
@ -285,6 +286,8 @@ class UpdatePage(Page):
|
|||||||
cur_dir = os.getcwd()
|
cur_dir = os.getcwd()
|
||||||
os.chdir("/home/cpi/apps/launcher")
|
os.chdir("/home/cpi/apps/launcher")
|
||||||
current_git_version = get_git_revision_short_hash()
|
current_git_version = get_git_revision_short_hash()
|
||||||
|
current_git_version = current_git_version.strip("\n")
|
||||||
|
current_git_version = current_git_version.strip("\t")
|
||||||
os.chdir(cur_dir)
|
os.chdir(cur_dir)
|
||||||
if current_git_version != json_["gitversion"]:
|
if current_git_version != json_["gitversion"]:
|
||||||
self._ConfirmPage._URL = None
|
self._ConfirmPage._URL = None
|
||||||
@ -302,7 +305,7 @@ class UpdatePage(Page):
|
|||||||
self._Screen._MsgBox.SetText("Out of update")
|
self._Screen._MsgBox.SetText("Out of update")
|
||||||
self._Screen._MsgBox.Draw()
|
self._Screen._MsgBox.Draw()
|
||||||
self._Screen.SwapAndShow()
|
self._Screen.SwapAndShow()
|
||||||
pygame.time.delay(600)
|
pygame.time.delay(765)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
@ -324,12 +327,18 @@ class UpdatePage(Page):
|
|||||||
self._Screen.SwapAndShow()
|
self._Screen.SwapAndShow()
|
||||||
|
|
||||||
if event.key == CurKeys["X"]:
|
if event.key == CurKeys["X"]:
|
||||||
if self.CheckUpdate() == True:
|
if is_wifi_connected_now():
|
||||||
self._Screen.Draw()
|
if self.CheckUpdate() == True:
|
||||||
self._Screen.SwapAndShow()
|
self._Screen.Draw()
|
||||||
|
self._Screen.SwapAndShow()
|
||||||
|
else:
|
||||||
|
self._Screen.Draw()
|
||||||
|
self._Screen._MsgBox.SetText("Checking update failed")
|
||||||
|
self._Screen._MsgBox.Draw()
|
||||||
|
self._Screen.SwapAndShow()
|
||||||
else:
|
else:
|
||||||
self._Screen.Draw()
|
self._Screen.Draw()
|
||||||
self._Screen._MsgBox.SetText("Checking update failed")
|
self._Screen._MsgBox.SetText("Please Check your Wi-Fi connection")
|
||||||
self._Screen._MsgBox.Draw()
|
self._Screen._MsgBox.Draw()
|
||||||
self._Screen.SwapAndShow()
|
self._Screen.SwapAndShow()
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,8 @@ from UI.util_funcs import midRect
|
|||||||
from UI.keys_def import CurKeys
|
from UI.keys_def import CurKeys
|
||||||
from UI.icon_item import IconItem
|
from UI.icon_item import IconItem
|
||||||
|
|
||||||
|
from libs.roundrects import aa_round_rect
|
||||||
|
|
||||||
from textarea import Textarea
|
from textarea import Textarea
|
||||||
from text_item import TextItem
|
from text_item import TextItem
|
||||||
from icons import preload
|
from icons import preload
|
||||||
@ -43,14 +45,15 @@ class KeyboardSelector(PageSelector):
|
|||||||
|
|
||||||
x = self._Parent._SecsKeys[sec_idx][row_idx][idx]._PosX
|
x = self._Parent._SecsKeys[sec_idx][row_idx][idx]._PosX
|
||||||
y = self._Parent._SecsKeys[sec_idx][row_idx][idx]._PosY
|
y = self._Parent._SecsKeys[sec_idx][row_idx][idx]._PosY
|
||||||
w = self._Parent._SecsKeys[sec_idx][row_idx][idx]._Width
|
w = self._Parent._SecsKeys[sec_idx][row_idx][idx]._Width+6
|
||||||
h = self._Parent._SecsKeys[sec_idx][row_idx][idx]._Height
|
h = self._Parent._SecsKeys[sec_idx][row_idx][idx]._Height+1
|
||||||
|
|
||||||
rect = midRect(x,y,w,h,self._Parent._Width,self._Parent._Height)
|
rect = midRect(x,y,w,h,self._Parent._Width,self._Parent._Height)
|
||||||
if rect.width <=0 or rect.height <= 0 :
|
if rect.width <=0 or rect.height <= 0 :
|
||||||
return
|
return
|
||||||
|
|
||||||
pygame.draw.rect(self._Parent._CanvasHWND,(0,0,0),rect,1)
|
aa_round_rect(self._Parent._CanvasHWND,rect, (126,206,244),4,1,(255,255,255))
|
||||||
|
# pygame.draw.rect(self._Parent._CanvasHWND,(0,0,0),rect,1)
|
||||||
|
|
||||||
class Keyboard(Page):
|
class Keyboard(Page):
|
||||||
_PosX = 0
|
_PosX = 0
|
||||||
@ -328,6 +331,7 @@ class Keyboard(Page):
|
|||||||
|
|
||||||
def Draw(self):
|
def Draw(self):
|
||||||
self.ClearCanvas()
|
self.ClearCanvas()
|
||||||
|
self._Ps.Draw()
|
||||||
for i in range(0,self._SectionNumbers):
|
for i in range(0,self._SectionNumbers):
|
||||||
for j in self._SecsKeys[i]:
|
for j in self._SecsKeys[i]:
|
||||||
for u in j:
|
for u in j:
|
||||||
@ -335,6 +339,5 @@ class Keyboard(Page):
|
|||||||
|
|
||||||
|
|
||||||
self._Textarea.Draw()
|
self._Textarea.Draw()
|
||||||
self._Ps.Draw()
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -32,7 +32,7 @@ class RomSoConfirmPage(ConfirmPage):
|
|||||||
f = open(config.Battery)
|
f = open(config.Battery)
|
||||||
except IOError:
|
except IOError:
|
||||||
print( "RomSoConfirmPage open %s failed" % config.Battery)
|
print( "RomSoConfirmPage open %s failed" % config.Battery)
|
||||||
return 0
|
return 6
|
||||||
else:
|
else:
|
||||||
with f:
|
with f:
|
||||||
bat_uevent = {}
|
bat_uevent = {}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ from page import Page,PageStack
|
|||||||
from title_bar import TitleBar
|
from title_bar import TitleBar
|
||||||
from foot_bar import FootBar
|
from foot_bar import FootBar
|
||||||
from constants import Width,Height,bg_color
|
from constants import Width,Height,bg_color
|
||||||
from util_funcs import FileExists,ReplaceSuffix,ReadTheFileContent,CmdClean,MakeExecutable
|
from util_funcs import midRect,FileExists,ReplaceSuffix,ReadTheFileContent,CmdClean,MakeExecutable
|
||||||
from fonts import fonts
|
from fonts import fonts
|
||||||
from keys_def import CurKeys
|
from keys_def import CurKeys
|
||||||
from label import Label
|
from label import Label
|
||||||
@ -29,19 +29,69 @@ from Emulator import MyEmulator
|
|||||||
class MessageBox(Label):
|
class MessageBox(Label):
|
||||||
_Parent = None
|
_Parent = None
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def Init(self,text,font_obj,color=pygame.Color(83,83,83)):
|
||||||
|
self._Color = color
|
||||||
|
self._FontObj = font_obj
|
||||||
|
self._Text = text
|
||||||
|
|
||||||
|
self._Width = 0
|
||||||
|
self._Height = 0
|
||||||
|
self._CanvasHWND = pygame.Surface( ( int(self._Parent._Width),int(self._Parent._Height)))
|
||||||
|
self._HWND = self._Parent._CanvasHWND
|
||||||
|
|
||||||
|
def SetText(self,text):
|
||||||
|
self._Text = text
|
||||||
|
|
||||||
def Draw(self):
|
def Draw(self):
|
||||||
my_text = self._FontObj.render( self._Text,True,self._Color)
|
|
||||||
w = my_text.get_width()
|
|
||||||
h = my_text.get_height()
|
|
||||||
x = (self._Parent._Width - w)/2
|
|
||||||
y = (self._Parent._Height - h)/2
|
|
||||||
|
|
||||||
padding = 10
|
self._CanvasHWND.fill( (255,255,255))
|
||||||
pygame.draw.rect(self._CanvasHWND,(255,255,255),(x-padding,y-padding, w+padding*2,h+padding*2))
|
|
||||||
|
|
||||||
pygame.draw.rect(self._CanvasHWND,(0,0,0),(x-padding,y-padding, w+padding*2,h+padding*2),1)
|
words = self._Text.split(' ')
|
||||||
|
space = self._FontObj.size(' ')[0]
|
||||||
|
max_width = self._Parent._Width-40
|
||||||
|
x ,y = (0,0)
|
||||||
|
row_total_width = 0
|
||||||
|
lines = 0
|
||||||
|
|
||||||
self._CanvasHWND.blit(my_text,(x,y,w,h))
|
for word in words:
|
||||||
|
word_surface = self._FontObj.render(word, True, self._Color)
|
||||||
|
word_width = word_surface.get_width()
|
||||||
|
word_height = word_surface.get_height()
|
||||||
|
row_total_width += word_width
|
||||||
|
if lines == 0:
|
||||||
|
lines += word_height
|
||||||
|
if row_total_width+space >= max_width:
|
||||||
|
x = 0 # Reset the x.
|
||||||
|
y += word_height # Start on new row.
|
||||||
|
row_total_width = 0
|
||||||
|
|
||||||
|
lines += word_height
|
||||||
|
|
||||||
|
self._CanvasHWND.blit(word_surface, (x, y))
|
||||||
|
x += word_width + space
|
||||||
|
if x > self._Width:
|
||||||
|
self._Width = x
|
||||||
|
|
||||||
|
if lines >= (self._Parent._Height - 40):
|
||||||
|
break
|
||||||
|
|
||||||
|
self._Height = lines
|
||||||
|
|
||||||
|
padding = 5
|
||||||
|
x = (self._Parent._Width - self._Width)/2
|
||||||
|
y = (self._Parent._Height - self._Height)/2
|
||||||
|
print("x %d y %d w %d h %d" %(x,y,self._Width,self._Height ))
|
||||||
|
|
||||||
|
pygame.draw.rect(self._HWND,(255,255,255),(x-padding,y-padding, self._Width+padding*2,self._Height+padding*2))
|
||||||
|
|
||||||
|
if self._HWND != None:
|
||||||
|
rect = midRect(self._Parent._Width/2,self._Parent._Height/2,self._Width,self._Height,Width,Height)
|
||||||
|
self._HWND.blit(self._CanvasHWND,rect,(0,0,self._Width,self._Height))
|
||||||
|
|
||||||
|
pygame.draw.rect(self._HWND,(0,0,0),(x-padding,y-padding, self._Width+padding*2,self._Height+padding*2),1)
|
||||||
|
|
||||||
|
|
||||||
python_package_flag = "__init__.py"
|
python_package_flag = "__init__.py"
|
||||||
@ -74,7 +124,6 @@ class MainScreen(object):
|
|||||||
self._CanvasHWND = pygame.Surface((self._Width,self._Height))
|
self._CanvasHWND = pygame.Surface((self._Width,self._Height))
|
||||||
self._MsgBox= MessageBox()
|
self._MsgBox= MessageBox()
|
||||||
self._MsgBox._Parent= self
|
self._MsgBox._Parent= self
|
||||||
self._MsgBox.SetCanvasHWND(self._CanvasHWND)
|
|
||||||
self._MsgBox.Init(" ", self._MsgBoxFont)
|
self._MsgBox.Init(" ", self._MsgBoxFont)
|
||||||
|
|
||||||
def FartherPages(self):
|
def FartherPages(self):
|
||||||
|
|||||||
@ -38,7 +38,7 @@ class MultiLabel: ##Multi Line Label
|
|||||||
def SetText(self,text):
|
def SetText(self,text):
|
||||||
self._Text = text
|
self._Text = text
|
||||||
|
|
||||||
self.blit_text(text)
|
self.blit_text(self._CanvasHWND,self._Text,(self._PosX,self._PosY),self._FontObj)
|
||||||
|
|
||||||
def Width(self):
|
def Width(self):
|
||||||
return self._Width
|
return self._Width
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user