Merge pull request #33 from jaicis/kivyfixes

worked on designing app closing popup
This commit is contained in:
navjotcis 2020-01-20 14:18:52 +05:30 committed by GitHub
commit 1b703dce3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 88 additions and 23 deletions

View File

@ -251,3 +251,64 @@
font_size: '13sp'
color: (1,1,1,1)
halign: 'center'
<AppClosingPopup>:
id: closing_popup
size_hint : (None,None)
height: 1.3*(popup_label.height+ my_add_btn.children[0].height)
width :app.window_size[0] - (app.window_size[0]/10 if app.app_platform == 'android' else app.window_size[0]/4)
background: './images/popup.jpeg'
auto_dismiss: False
separator_height: 0
BoxLayout:
id: myadd_popup_box
size_hint_y: None
spacing:dp(70)
orientation: 'vertical'
BoxLayout:
size_hint_y: None
orientation: 'vertical'
spacing:dp(25)
MDLabel:
id: popup_label
font_style: 'Subtitle2'
theme_text_color: 'Primary'
text: "Bitmessage isn't connected to the network.\n If you quit now, it may cause delivery delays.\n Wait until connected and the synchronisation finishes?"
font_size: '17sp'
halign: 'left'
BoxLayout:
id: my_add_btn
spacing:5
orientation: 'horizontal'
MDRaisedButton:
size_hint: 1.5, None
height: dp(40)
on_press: root.closingAction(self.children[0].text)
on_press: app.stop()
MDLabel:
font_style: 'H6'
text: 'Yes'
font_size: '13sp'
color: (1,1,1,1)
halign: 'center'
MDRaisedButton:
size_hint: 1.5, None
height: dp(40)
on_press: root.closingAction(self.children[0].text)
MDLabel:
font_style: 'H6'
text: 'No'
font_size: '13sp'
color: (1,1,1,1)
halign: 'center'
MDRaisedButton:
size_hint: 1.5, None
height: dp(40)
#on_press: root.dismiss()
on_press: root.closingAction(self.children[0].text)
MDLabel:
font_style: 'H6'
text: 'Cancel'
font_size: '13sp'
color: (1,1,1,1)
halign: 'center'

View File

@ -1313,7 +1313,7 @@ class NavigateApp(MDApp):
kivysignalthread = UIkivySignaler()
kivysignalthread.daemon = True
kivysignalthread.start()
Window.bind(on_keyboard=self.on_key, on_request_close=self.on_request_closee)
Window.bind(on_keyboard=self.on_key, on_request_close=self.on_request_close)
return Builder.load_file(
os.path.join(os.path.dirname(__file__), 'main.kv'))
@ -1622,12 +1622,12 @@ class NavigateApp(MDApp):
def on_start(self):
self.set_message_count()
@staticmethod
def on_stop():
"""On stop methos is used for stoping the runing script"""
print("*******************EXITING FROM APPLICATION*******************")
import shutdown
shutdown.doCleanShutdown()
# @staticmethod
# def on_stop():
# """On stop methos is used for stoping the runing script"""
# print("*******************EXITING FROM APPLICATION*******************")
# import shutdown
# shutdown.doCleanShutdown()
@staticmethod
def current_address_label(current_add_label=None, current_addr=None):
@ -1763,21 +1763,9 @@ class NavigateApp(MDApp):
except Exception:
self.root.ids.sc17.children[0].children[1].active = False
def on_request_closee(self, *args):
box = BoxLayout(orientation='vertical')
box.add_widget(Label(
text=(
"Bitmessage isn't connected to the network.\n"
"If you quit now, it may cause delivery delays.\n"
"Wait until connected and the synchronisation finishes?")))
mybutton = Button(text='Yes', size_hint=(1, 0.50))
box.add_widget(mybutton)
mybutton2 = Button(text='No', size_hint=(1, 0.50))
box.add_widget(mybutton2)
mybutton3 = Button(text='Cancel', size_hint=(1, 0.50))
box.add_widget(mybutton3)
popup = Popup(title="Window close", content=box, size_hint=(None, None), size=(500, 300))
popup.open()
def on_request_close(self, *args):
"""This method is for app closing request"""
AppClosingPopup().open()
return True
@ -2648,3 +2636,19 @@ class NavigationDrawerSubheader(OneLineListItem):
disabled = True
divider = None
theme_text_color = 'Secondary'
class AppClosingPopup(Popup):
"""Class for app closing popup"""
def __init__(self, **kwargs):
super(AppClosingPopup, self).__init__(**kwargs)
def closingAction(self, text):
if text == 'Yes':
print("*******************EXITING FROM APPLICATION*******************")
import shutdown
shutdown.doCleanShutdown()
else:
self.dismiss()
toast(text)