move setting of keyboard to server side
This commit is contained in:
parent
744e53b76b
commit
449de0f374
|
@ -19,9 +19,6 @@ import logging
|
|||
from subiquity.client.controller import SubiquityTuiController
|
||||
from subiquity.client.keyboard import KeyboardList
|
||||
from subiquity.common.types import KeyboardSetting
|
||||
from subiquity.common.keyboard import (
|
||||
set_keyboard,
|
||||
)
|
||||
from subiquity.ui.views import KeyboardView
|
||||
|
||||
log = logging.getLogger('subiquity.client.controllers.keyboard')
|
||||
|
@ -55,15 +52,12 @@ class KeyboardController(SubiquityTuiController):
|
|||
view = KeyboardView(self, initial_setting)
|
||||
return view
|
||||
|
||||
def run_answers(self):
|
||||
async def run_answers(self):
|
||||
if 'layout' in self.answers:
|
||||
layout = self.answers['layout']
|
||||
variant = self.answers.get('variant', '')
|
||||
self.done(KeyboardSetting(layout=layout, variant=variant), True)
|
||||
|
||||
async def set_keyboard(self, setting):
|
||||
await set_keyboard(self.app.root, setting, self.opts.dry_run)
|
||||
self.done(setting, False)
|
||||
await self.apply(KeyboardSetting(layout=layout, variant=variant))
|
||||
self.done()
|
||||
|
||||
async def get_step(self, index):
|
||||
return await self.endpoint.steps.GET(index)
|
||||
|
@ -72,12 +66,11 @@ class KeyboardController(SubiquityTuiController):
|
|||
return await self.endpoint.needs_toggle.GET(
|
||||
layout_code=setting.layout, variant_code=setting.variant)
|
||||
|
||||
def done(self, setting, apply):
|
||||
log.debug("KeyboardController.done %s next_screen", setting)
|
||||
if apply:
|
||||
self.app.aio_loop.create_task(self.set_keyboard(setting))
|
||||
else:
|
||||
self.app.next_screen(self.endpoint.POST(setting))
|
||||
async def apply(self, setting):
|
||||
await self.endpoint.POST(setting)
|
||||
|
||||
def done(self):
|
||||
self.app.next_screen()
|
||||
|
||||
def cancel(self):
|
||||
self.app.prev_screen()
|
||||
|
|
|
@ -159,6 +159,9 @@ class KeyboardController(SubiquityController):
|
|||
new = latinizable(data.layout, data.variant)
|
||||
if new is not None:
|
||||
data = KeyboardSetting(new[0], new[1], data.toggle)
|
||||
if data != self.model.setting:
|
||||
await set_keyboard(
|
||||
self.app.root, data, self.opts.dry_run)
|
||||
self.model.setting = data
|
||||
self.configured()
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@ from subiquitycore.ui.form import (
|
|||
Form,
|
||||
)
|
||||
from subiquitycore.ui.selector import Selector, Option
|
||||
from subiquitycore.ui.spinner import Spinner
|
||||
from subiquitycore.ui.stretchy import (
|
||||
Stretchy,
|
||||
)
|
||||
|
@ -275,22 +274,6 @@ class Detector:
|
|||
self.keyboard_view.show_overlay(self.overlay)
|
||||
|
||||
|
||||
class ApplyingConfig(WidgetWrap):
|
||||
def __init__(self, aio_loop):
|
||||
spinner = Spinner(aio_loop, style='dots')
|
||||
spinner.start()
|
||||
text = _("Applying config")
|
||||
# | text |
|
||||
# 12 34
|
||||
self.width = len(text) + 4
|
||||
super().__init__(
|
||||
LineBox(
|
||||
Pile([
|
||||
('pack', Text(' ' + text)),
|
||||
('pack', spinner),
|
||||
])))
|
||||
|
||||
|
||||
toggle_text = _("""\
|
||||
You will need a way to toggle the keyboard between the national layout and \
|
||||
the standard Latin layout.
|
||||
|
@ -440,13 +423,13 @@ class KeyboardView(BaseView):
|
|||
setting = KeyboardSetting(layout=layout.code, variant=variant.code)
|
||||
self.controller.app.aio_loop.create_task(self._check_toggle(setting))
|
||||
|
||||
async def _apply(self, setting):
|
||||
await self.controller.app.wait_with_text_dialog(
|
||||
self.controller.apply(setting), _("Applying config"))
|
||||
self.controller.done()
|
||||
|
||||
def really_done(self, setting):
|
||||
apply = False
|
||||
if setting != self.initial_setting:
|
||||
apply = True
|
||||
ac = ApplyingConfig(self.controller.app.aio_loop)
|
||||
self.show_overlay(ac, width=ac.width, min_width=None)
|
||||
self.controller.done(setting, apply=apply)
|
||||
self.controller.app.aio_loop.create_task(self._apply(setting))
|
||||
|
||||
def cancel(self, result=None):
|
||||
self.controller.cancel()
|
||||
|
|
Loading…
Reference in New Issue