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.controller import SubiquityTuiController
|
||||||
from subiquity.client.keyboard import KeyboardList
|
from subiquity.client.keyboard import KeyboardList
|
||||||
from subiquity.common.types import KeyboardSetting
|
from subiquity.common.types import KeyboardSetting
|
||||||
from subiquity.common.keyboard import (
|
|
||||||
set_keyboard,
|
|
||||||
)
|
|
||||||
from subiquity.ui.views import KeyboardView
|
from subiquity.ui.views import KeyboardView
|
||||||
|
|
||||||
log = logging.getLogger('subiquity.client.controllers.keyboard')
|
log = logging.getLogger('subiquity.client.controllers.keyboard')
|
||||||
|
@ -55,15 +52,12 @@ class KeyboardController(SubiquityTuiController):
|
||||||
view = KeyboardView(self, initial_setting)
|
view = KeyboardView(self, initial_setting)
|
||||||
return view
|
return view
|
||||||
|
|
||||||
def run_answers(self):
|
async def run_answers(self):
|
||||||
if 'layout' in self.answers:
|
if 'layout' in self.answers:
|
||||||
layout = self.answers['layout']
|
layout = self.answers['layout']
|
||||||
variant = self.answers.get('variant', '')
|
variant = self.answers.get('variant', '')
|
||||||
self.done(KeyboardSetting(layout=layout, variant=variant), True)
|
await self.apply(KeyboardSetting(layout=layout, variant=variant))
|
||||||
|
self.done()
|
||||||
async def set_keyboard(self, setting):
|
|
||||||
await set_keyboard(self.app.root, setting, self.opts.dry_run)
|
|
||||||
self.done(setting, False)
|
|
||||||
|
|
||||||
async def get_step(self, index):
|
async def get_step(self, index):
|
||||||
return await self.endpoint.steps.GET(index)
|
return await self.endpoint.steps.GET(index)
|
||||||
|
@ -72,12 +66,11 @@ class KeyboardController(SubiquityTuiController):
|
||||||
return await self.endpoint.needs_toggle.GET(
|
return await self.endpoint.needs_toggle.GET(
|
||||||
layout_code=setting.layout, variant_code=setting.variant)
|
layout_code=setting.layout, variant_code=setting.variant)
|
||||||
|
|
||||||
def done(self, setting, apply):
|
async def apply(self, setting):
|
||||||
log.debug("KeyboardController.done %s next_screen", setting)
|
await self.endpoint.POST(setting)
|
||||||
if apply:
|
|
||||||
self.app.aio_loop.create_task(self.set_keyboard(setting))
|
def done(self):
|
||||||
else:
|
self.app.next_screen()
|
||||||
self.app.next_screen(self.endpoint.POST(setting))
|
|
||||||
|
|
||||||
def cancel(self):
|
def cancel(self):
|
||||||
self.app.prev_screen()
|
self.app.prev_screen()
|
||||||
|
|
|
@ -159,6 +159,9 @@ class KeyboardController(SubiquityController):
|
||||||
new = latinizable(data.layout, data.variant)
|
new = latinizable(data.layout, data.variant)
|
||||||
if new is not None:
|
if new is not None:
|
||||||
data = KeyboardSetting(new[0], new[1], data.toggle)
|
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.model.setting = data
|
||||||
self.configured()
|
self.configured()
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,6 @@ from subiquitycore.ui.form import (
|
||||||
Form,
|
Form,
|
||||||
)
|
)
|
||||||
from subiquitycore.ui.selector import Selector, Option
|
from subiquitycore.ui.selector import Selector, Option
|
||||||
from subiquitycore.ui.spinner import Spinner
|
|
||||||
from subiquitycore.ui.stretchy import (
|
from subiquitycore.ui.stretchy import (
|
||||||
Stretchy,
|
Stretchy,
|
||||||
)
|
)
|
||||||
|
@ -275,22 +274,6 @@ class Detector:
|
||||||
self.keyboard_view.show_overlay(self.overlay)
|
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 = _("""\
|
toggle_text = _("""\
|
||||||
You will need a way to toggle the keyboard between the national layout and \
|
You will need a way to toggle the keyboard between the national layout and \
|
||||||
the standard Latin layout.
|
the standard Latin layout.
|
||||||
|
@ -440,13 +423,13 @@ class KeyboardView(BaseView):
|
||||||
setting = KeyboardSetting(layout=layout.code, variant=variant.code)
|
setting = KeyboardSetting(layout=layout.code, variant=variant.code)
|
||||||
self.controller.app.aio_loop.create_task(self._check_toggle(setting))
|
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):
|
def really_done(self, setting):
|
||||||
apply = False
|
self.controller.app.aio_loop.create_task(self._apply(setting))
|
||||||
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)
|
|
||||||
|
|
||||||
def cancel(self, result=None):
|
def cancel(self, result=None):
|
||||||
self.controller.cancel()
|
self.controller.cancel()
|
||||||
|
|
Loading…
Reference in New Issue