Merge pull request #246 from CanonicalLtd/mwhudson/better-progress-bar
change the progress bar to show x / y rather than a %age
This commit is contained in:
commit
34ea885217
|
@ -171,7 +171,7 @@ class IdentityController(BaseController):
|
|||
excerpt = "Enter an email address from your account in the store."
|
||||
footer = ""
|
||||
self.ui.set_header(title, excerpt)
|
||||
self.ui.set_footer(footer, 40)
|
||||
self.ui.set_footer(footer)
|
||||
self.ui.set_body(IdentityView(self.model, self, self.opts, self.loop))
|
||||
device_owner = get_device_owner()
|
||||
if device_owner is not None:
|
||||
|
|
|
@ -67,21 +67,21 @@ class FilesystemController(BaseController):
|
|||
title = _("Filesystem setup")
|
||||
footer = (_("Choose guided or manual partitioning"))
|
||||
self.ui.set_header(title)
|
||||
self.ui.set_footer(footer, 30)
|
||||
self.ui.set_footer(footer)
|
||||
self.ui.set_body(GuidedFilesystemView(self.model, self))
|
||||
|
||||
def manual(self):
|
||||
title = _("Filesystem setup")
|
||||
footer = (_("Select available disks to format and mount"))
|
||||
self.ui.set_header(title)
|
||||
self.ui.set_footer(footer, 30)
|
||||
self.ui.set_footer(footer)
|
||||
self.ui.set_body(FilesystemView(self.model, self))
|
||||
|
||||
def guided(self):
|
||||
title = _("Filesystem setup")
|
||||
footer = (_("Choose the installation target"))
|
||||
self.ui.set_header(title)
|
||||
self.ui.set_footer(footer, 30)
|
||||
self.ui.set_footer(footer)
|
||||
self.ui.set_body(GuidedDiskSelectionView(self.model, self))
|
||||
|
||||
def reset(self):
|
||||
|
@ -97,7 +97,7 @@ class FilesystemController(BaseController):
|
|||
footer = (_("Error while installing Ubuntu"))
|
||||
error_msg = _("Failed to obtain write permissions to /tmp")
|
||||
self.ui.set_header(title)
|
||||
self.ui.set_footer(footer, 30)
|
||||
self.ui.set_footer(footer)
|
||||
self.ui.set_body(ErrorView(self.signal, error_msg))
|
||||
|
||||
def finish(self):
|
||||
|
@ -383,7 +383,7 @@ class FilesystemController(BaseController):
|
|||
log.debug('calling DiskInfoView()')
|
||||
disk_info_view = DiskInfoView(self.model, self, disk, result)
|
||||
footer = _('Select next or previous disks with n and p')
|
||||
self.ui.set_footer(footer, 30)
|
||||
self.ui.set_footer(footer)
|
||||
self.ui.set_body(disk_info_view)
|
||||
|
||||
def is_uefi(self):
|
||||
|
|
|
@ -37,7 +37,7 @@ class IdentityController(BaseController):
|
|||
excerpt = _("Enter the username and password (or ssh identity) you will use to log in to the system.")
|
||||
footer = ""
|
||||
self.ui.set_header(title, excerpt)
|
||||
self.ui.set_footer(footer, 40)
|
||||
self.ui.set_footer(footer)
|
||||
self.ui.set_body(IdentityView(self.model, self, self.opts))
|
||||
|
||||
def cancel(self):
|
||||
|
|
|
@ -50,7 +50,7 @@ class InstallpathController(BaseController):
|
|||
"navigate options")
|
||||
|
||||
self.ui.set_header(title, excerpt)
|
||||
self.ui.set_footer(footer, 10)
|
||||
self.ui.set_footer(footer)
|
||||
self.ui.set_body(InstallpathView(self.model, self.signal))
|
||||
|
||||
default = installpath
|
||||
|
|
|
@ -80,7 +80,7 @@ class InstallProgressController(BaseController):
|
|||
log.debug('curtin_error')
|
||||
title = _('An error occurred during installation')
|
||||
self.ui.set_header(title, _('Please report this error in Launchpad'))
|
||||
self.ui.set_footer(_("An error has occurred."), 100)
|
||||
self.ui.set_footer(_("An error has occurred."))
|
||||
if self.progress_view is not None:
|
||||
self.progress_view.set_status(('info_error', "An error has occurred"))
|
||||
self.progress_view.show_complete()
|
||||
|
@ -210,8 +210,9 @@ class InstallProgressController(BaseController):
|
|||
return
|
||||
log.debug('After curtin postinstall OK')
|
||||
self.install_state = InstallState.DONE_POSTINSTALL
|
||||
self.ui.progress_current += 1
|
||||
self.ui.set_header(_("Installation complete!"), "")
|
||||
self.ui.set_footer("", 100)
|
||||
self.ui.set_footer("")
|
||||
self.progress_view.set_status(_("Finished install!"))
|
||||
self.progress_view.show_complete()
|
||||
|
||||
|
@ -274,7 +275,7 @@ class InstallProgressController(BaseController):
|
|||
excerpt = _("Please wait for the installation to finish.")
|
||||
footer = _("Thank you for using Ubuntu!")
|
||||
self.ui.set_header(title, excerpt)
|
||||
self.ui.set_footer(footer, 90)
|
||||
self.ui.set_footer(footer)
|
||||
self.progress_view = ProgressView(self.model, self)
|
||||
if self.install_state < 0:
|
||||
self.curtin_error()
|
||||
|
|
|
@ -33,3 +33,7 @@ class Subiquity(Application):
|
|||
"Identity",
|
||||
"InstallProgress",
|
||||
]
|
||||
|
||||
def __init__(self, ui, opts):
|
||||
super().__init__(ui, opts)
|
||||
self.common['ui'].progress_completion += 1
|
||||
|
|
|
@ -19,7 +19,7 @@ Welcome provides user with language selection
|
|||
|
||||
"""
|
||||
import logging
|
||||
from urwid import BoxAdapter, Text, connect_signal
|
||||
from urwid import BoxAdapter, Text
|
||||
from subiquitycore.ui.lists import SimpleList
|
||||
from subiquitycore.ui.buttons import menu_btn
|
||||
from subiquitycore.ui.container import ListBox
|
||||
|
|
|
@ -350,7 +350,7 @@ class NetworkController(BaseController):
|
|||
"updates.")
|
||||
footer = _("Select an interface to configure it or select Done to continue")
|
||||
self.ui.set_header(title, excerpt)
|
||||
self.ui.set_footer(footer, 20)
|
||||
self.ui.set_footer(footer)
|
||||
self.ui.set_body(NetworkView(self.model, self))
|
||||
|
||||
@property
|
||||
|
|
|
@ -103,6 +103,7 @@ class Application:
|
|||
"loop": None,
|
||||
"pool": futures.ThreadPoolExecutor(1),
|
||||
}
|
||||
ui.progress_completion = len(self.controllers)
|
||||
self.common['controllers'] = dict.fromkeys(self.controllers)
|
||||
self.controller_index = -1
|
||||
|
||||
|
@ -128,6 +129,7 @@ class Application:
|
|||
self.controller_index += 1
|
||||
if self.controller_index >= len(self.controllers):
|
||||
self.exit()
|
||||
self.common['ui'].progress_current += 1
|
||||
controller_name = self.controllers[self.controller_index]
|
||||
log.debug("moving to screen %s", controller_name)
|
||||
next_controller = self.common['controllers'][controller_name]
|
||||
|
@ -139,6 +141,7 @@ class Application:
|
|||
self.controller_index -= 1
|
||||
if self.controller_index >= len(self.controllers):
|
||||
self.exit()
|
||||
self.common['ui'].progress_current -= 1
|
||||
controller_name = self.controllers[self.controller_index]
|
||||
next_controller = self.common['controllers'][controller_name]
|
||||
next_controller.default()
|
||||
|
@ -179,7 +182,7 @@ class Application:
|
|||
try:
|
||||
self.common['loop'].set_alarm_in(0.05, self.next_screen)
|
||||
controllers_mod = __import__('%s.controllers' % self.project, None, None, [''])
|
||||
for k in self.common['controllers']:
|
||||
for k in self.controllers:
|
||||
log.debug("Importing controller: {}".format(k))
|
||||
klass = getattr(controllers_mod, k+"Controller")
|
||||
self.common['controllers'][k] = klass(self.common)
|
||||
|
|
|
@ -46,6 +46,11 @@ class Header(WidgetWrap):
|
|||
super().__init__(w)
|
||||
|
||||
|
||||
class StepsProgressBar(ProgressBar):
|
||||
|
||||
def get_text(self):
|
||||
return "{} / {}".format(self.current, self.done)
|
||||
|
||||
class Footer(WidgetWrap):
|
||||
""" Footer widget
|
||||
|
||||
|
@ -53,18 +58,17 @@ class Footer(WidgetWrap):
|
|||
|
||||
"""
|
||||
|
||||
def __init__(self, message="", completion=0):
|
||||
def __init__(self, message, current, complete):
|
||||
message_widget = Padding.center_79(Text(message))
|
||||
progress_bar = Padding.center_60(
|
||||
ProgressBar(normal='progress_incomplete',
|
||||
complete='progress_complete',
|
||||
current=completion, done=100))
|
||||
StepsProgressBar(normal='progress_incomplete',
|
||||
complete='progress_complete',
|
||||
current=current, done=complete))
|
||||
status = [
|
||||
progress_bar,
|
||||
Padding.line_break(""),
|
||||
message_widget,
|
||||
]
|
||||
if completion > 0:
|
||||
status.insert(0, progress_bar)
|
||||
super().__init__(Color.frame_footer(Pile(status)))
|
||||
|
||||
|
||||
|
|
|
@ -25,11 +25,13 @@ log = logging.getLogger('subiquitycore.ui.frame')
|
|||
|
||||
class SubiquityUI(WidgetWrap):
|
||||
|
||||
def __init__(self, header=None, body=None, footer=None):
|
||||
self.header = header if header else Header()
|
||||
self.body = body if body else Body()
|
||||
self.footer = footer if footer else Footer()
|
||||
def __init__(self):
|
||||
self.header = Header()
|
||||
self.body = Body()
|
||||
self.footer = Footer("", 0, 0)
|
||||
self.frame = Frame(self.body, header=self.header, footer=self.footer)
|
||||
self.progress_current = 0
|
||||
self.progress_completion = 0
|
||||
super().__init__(self.frame)
|
||||
|
||||
def keypress(self, size, key):
|
||||
|
@ -38,8 +40,8 @@ class SubiquityUI(WidgetWrap):
|
|||
def set_header(self, title=None, excerpt=None):
|
||||
self.frame.header = Header(title, excerpt)
|
||||
|
||||
def set_footer(self, message, completion=0):
|
||||
self.frame.footer = Footer(message, completion)
|
||||
def set_footer(self, message):
|
||||
self.frame.footer = Footer(message, self.progress_current, self.progress_completion)
|
||||
|
||||
def set_body(self, widget):
|
||||
self.frame.body = widget
|
||||
|
|
Loading…
Reference in New Issue