This commit is contained in:
yumoqing 2020-01-09 17:52:02 +08:00
parent c493ab6a0f
commit e51ef48a30
10 changed files with 76 additions and 41 deletions

View File

@ -409,7 +409,7 @@ class Blocks:
desc, parenturl = self.getUrlData(opts,parenturl)
if not isinstance(desc,dict):
print("getUrlData() return error data",opts,parenturl)
alert(str(dict) + 'format error')
# alert(str(desc) + 'format error',title='widgetBuild()')
return None
desc = self.valueExpr(desc)
desc['parenturl'] = parenturl

View File

@ -37,30 +37,24 @@ def signal_handler(signal, frame):
signal.signal(signal.SIGINT, signal_handler)
class BlocksApp(App):
def build(self):
x = PageContainer()
config = getConfig()
self.config = config
self.userinfo = {}
self.title = 'Test Title'
self.blocks = Blocks()
config = getConfig()
self.config = config
self.workers = Workers(maxworkers=config.maxworkers or 80)
Window.bind(on_request_close=self.on_close)
self.workers.start()
self.hc = HttpClient()
WindowBase.softinput_mode='below_target'
x = PageContainer()
Clock.schedule_once(self.build1)
print('build() called......')
return x
def setUserInfo(self,uinfo):
d = {}
d['userid'] = uinfo['userid']
d['password'] = uinfo.get('password','')
d['authcode'] = uinfo.get('authcode','')
self.userinfo = d
def on_start(self):
print('on_start() called ...')

View File

@ -204,7 +204,7 @@ class Form(BoxLayout):
self.options = options
BoxLayout.__init__(self, orientation='vertical')
self.widget_ids = {}
self.cols = self.options_cols = self.options['cols']
self.cols = self.options_cols = self.options.get('cols',1)
if isHandHold() and Window.width < Window.height:
self.cols = 1
self.inputwidth = Window.width / self.cols
@ -217,8 +217,11 @@ class Form(BoxLayout):
if self.initflag:
return
self.toolbar = Toolbar(ancestor=self,**self.options.get('toolbar',defaultToolbar()))
self.fsc = VResponsiveLayout(cols=self.cols,
box_width=self.inputwidth)
self.fsc = VResponsiveLayout(
self.inputwidth,
self.cols
)
print('box_width=%d,cols=%d' % (self.inputwidth, self.cols))
self.add_widget(self.toolbar)
self.add_widget(self.fsc)
self.register_event_type('on_submit')

View File

@ -1,7 +1,27 @@
from kivy.app import App
from kivy.core.window import Window
from kivy.uix.popup import Popup
from appPublic.Singleton import SingletonDecorator
from appPublic.registerfunction import RegisterFunction
from appPublic.rsa import RSA
# from .form import Form
class ServerInfo:
def __init__(self):
self.rsaEngine = RSA()
config = getConfig()
url = '%s%s' % (config.uihome, config.publickey_url)
hc = App.get_running_app().hc
d = hc.get(url)
self.publickey = self.rsaEngine. publickeyFromText(d)
def encode(self,uinfo):
if uinfo['authmethod'] == 'password':
authinfo = '%s::%s::%s' % (uinfo['authmethod'], uinfo['userid'], uinfo['password'])
txt = self.serverinfo.encode(authinfo)
x = self.rsaEngine.encode(self.publickey, txt)
return x
return None
logformdesc = {
"widgettype":"Form",
@ -39,39 +59,45 @@ logformdesc = {
@SingletonDecorator
class LoginForm(Popup):
def __init__(self):
super().__init__()
super().__init__(size_hint=(0.8,0.8))
app = App.get_running_app()
print('here ..1............')
self.content = app.blocks.widgetBuild(logformdesc)
# self.content.bind(on_submit=setipUserInfo)
print('here ..2............',self.content)
self.title = 'login'
self.blockCalls = []
self.open_status = False
print('here ..3............')
self.content.bind(on_submit=self.on_submit)
def needlogin(self, url,method,params,headers,callback=None,errback=None):
self.blockCalls.append([url, method, params,headers,callback,errback])
if self.open_status:
return
self.open_status = True
self.content.bind(on_cancel=self.on_submit)
print('here ..4............')
self.open()
def recall(self):
app = App.get_running_app()
for url, method, params, headers,callback, errback in self.blockCalls:
app.hc(url, method=pethod,params=params,headers=headers,
callback=callback,errback=errback)
def close(self):
self.open_status = False
self.dismiss()
def on_submit(self,o,v):
self.dismiss()
def on_cancel(self,o,v):
self.dismiss()
def setupUserInfo(userinfo):
def setupUserInfo(obj, userinfo):
app = App.get_running_app()
app.setUserInfo(userinfo)
lf = LoginForm()
lf.recall()
if not hasattr(app, 'serverinfo'):
app.serverinfo = ServerInfo()
if userinfo.get('password',False):
userinfo['authmethod'] = 'password'
authinfo = app.serverinfo.encode(userinfo)
headers = {
"authorization":authinfo
}
login_url = '%s%s' % (app.config.uihome, app.config.login_url)
app.hc.get(login_url,headers=headers)
rf = RegisterFunction()
rf.register('setupUserInfo',setupUserInfo)

View File

@ -53,7 +53,9 @@ class PageContainer(FloatLayout):
return
w = self.pageWidgets[-1]
try:
w.beforeDestroy()
print(' ******* del last widget begin******')
del w
print(' ******* del last widget end ******')
except:
pass
self.pageWidgets = self.pageWidgets[:-1]

View File

@ -14,6 +14,7 @@ class VResponsiveLayout(ScrollView):
self.box_cols = cols
super(VResponsiveLayout, self).__init__(**kw)
self.options = kw
print('VResponsiveLayout():cols=',self.org_cols,'box_width=',self.box_width)
self._inner = GridLayout(cols=self.org_cols, padding=2,
spacing=2,size_hint=(1,None))
super(VResponsiveLayout,self).add_widget(self._inner)

View File

@ -123,7 +123,7 @@ class HttpClient:
return cb(None,resp)
except NeedLogin as e:
lf = LoginForm()
lf.needlogin(url,method,params,files,headers,callback,errback)
lf.open()
return None
except Exception as e:
if errback is not None:

View File

@ -101,7 +101,7 @@ class Toolbar(GridLayout):
opt.img_size = self.opts.img_size
opt.text_size = self.opts.text_size
purl = None
if ancestor:
if ancestor and hasattr(ancestor, 'parenturl'):
purl = ancestor.parenturl
opt.img_src = absurl(opt.img_src,purl)
tool = Tool(ancestor=ancestor, **opt)

View File

@ -49,7 +49,7 @@ class VPlayer(FloatLayout):
can_changevolume=True
):
super().__init__()
self.allow_screensaver = False
Window.allow_screensaver = False
print(self,vfile)
self._video = Video(allow_stretch=True,pos_hint={'x': 0, 'y': 0},size_hint=(1,1))
self.add_widget(self._video)
@ -92,6 +92,16 @@ class VPlayer(FloatLayout):
self._video.bind(on_touch_down=self.show_hide_menu)
self.register_event_type('on_playend')
def __del__(self):
print('********** delete VPlayer instance ********')
self._video.state = 'stop'
if self.update_task:
self.update_task.cancel()
self.update_task = None
Window.allow_screensaver = True
del self._video
self._video = None
def play(self,o=None,v=None):
if self.curplay >= 0:
self._video.source = self.playlist[self.curplay]
@ -168,11 +178,7 @@ class VPlayer(FloatLayout):
def beforeDestroy(self):
try:
self.pause()
if self.update_task:
self.update_task.cancel()
self.update_task = None
del self._video
del self
except Exception as e:
print_exc()

View File

@ -9,6 +9,9 @@
},
"font_name":"normal",
"uihome":"http://www.bsppo.com:10080",
"i18n_url":"/public/i18n",
"publickey_url":"/public/publickey",
"login_url":"/public/publickey",
"udws":[
"/udw/udws.uidesc"
],