コード例 #1
0
    def __init__(self, controller, *args, **kwargs):
        self.controller = controller
        self.current_layout = None
        self.default_keyboard_layout = None
        self.default_keyboard_variant = None

        try:
            from PyQt5 import uic
            from PyQt5.QtWidgets import QVBoxLayout
            from ubiquity.frontend.kde_components.Keyboard import Keyboard

            self.page = uic.loadUi(
                '/usr/share/ubiquity/qt/stepKeyboardConf.ui')
            self.keyboardDisplay = Keyboard(self.page.keyboard_frame)
            self.page.keyboard_frame.setLayout(QVBoxLayout())
            self.page.keyboard_frame.layout().addWidget(self.keyboardDisplay)
            # use activated instead of changed because we only want to act
            # when the user changes the selection not when we are populating
            # the combo box
            self.page.keyboard_layout_combobox.activated.connect(
                self.on_keyboard_layout_selected)
            self.page.keyboard_variant_combobox.activated.connect(
                self.on_keyboard_variant_selected)
        except Exception as e:
            self.debug('Could not create keyboard page: %s', e)
            self.page = None
        self.plugin_widgets = self.page
コード例 #2
0
    def __init__(self, controller, *args, **kwargs):
        self.controller = controller
        self.current_layout = None
        self.default_keyboard_layout = None
        self.default_keyboard_variant = None

        try:
            from PyQt4 import uic
            from PyQt4.QtGui import QVBoxLayout
            from ubiquity.frontend.kde_components.Keyboard import Keyboard

            self.page = uic.loadUi(
                '/usr/share/ubiquity/qt/stepKeyboardConf.ui')
            self.keyboardDisplay = Keyboard(self.page.keyboard_frame)
            self.page.keyboard_frame.setLayout(QVBoxLayout())
            self.page.keyboard_frame.layout().addWidget(self.keyboardDisplay)
            # use activated instead of changed because we only want to act
            # when the user changes the selection not when we are populating
            # the combo box
            self.page.keyboard_layout_combobox.activated.connect(
                self.on_keyboard_layout_selected)
            self.page.keyboard_variant_combobox.activated.connect(
                self.on_keyboard_variant_selected)
        except Exception as e:
            self.debug('Could not create keyboard page: %s', e)
            self.page = None
        self.plugin_widgets = self.page
コード例 #3
0
class PageKde(plugin.PluginUI):
    plugin_breadcrumb = 'ubiquity/text/breadcrumb_keyboard'

    def __init__(self, controller, *args, **kwargs):
        self.controller = controller
        self.current_layout = None
        self.default_keyboard_layout = None
        self.default_keyboard_variant = None

        try:
            from PyQt4 import uic
            from PyQt4.QtGui import QVBoxLayout
            from ubiquity.frontend.kde_components.Keyboard import Keyboard

            self.page = uic.loadUi(
                '/usr/share/ubiquity/qt/stepKeyboardConf.ui')
            self.keyboardDisplay = Keyboard(self.page.keyboard_frame)
            self.page.keyboard_frame.setLayout(QVBoxLayout())
            self.page.keyboard_frame.layout().addWidget(self.keyboardDisplay)
            # use activated instead of changed because we only want to act
            # when the user changes the selection not when we are populating
            # the combo box
            self.page.keyboard_layout_combobox.activated.connect(
                self.on_keyboard_layout_selected)
            self.page.keyboard_variant_combobox.activated.connect(
                self.on_keyboard_variant_selected)
        except Exception as e:
            self.debug('Could not create keyboard page: %s', e)
            self.page = None
        self.plugin_widgets = self.page

    @plugin.only_this_page
    def on_keyboard_layout_selected(self, *args):
        layout = self.get_keyboard()
        l = self.controller.dbfilter.get_locale()
        if layout is not None:
            #skip updating keyboard if not using display
            if self.keyboardDisplay:
                ly = keyboard_names.layout_id(l, misc.utf8(layout))
                self.keyboardDisplay.setLayout(ly)

                #no variants, force update by setting none
                #if not keyboard_names.has_variants(l, ly):
                #    self.keyboardDisplay.setVariant(None)

            self.current_layout = layout
            self.controller.dbfilter.change_layout(layout)

    @plugin.only_this_page
    def on_keyboard_variant_selected(self, *args):
        layout = self.get_keyboard()
        variant = self.get_keyboard_variant()

        if self.keyboardDisplay:
            var = None
            l = self.controller.dbfilter.get_locale()
            ly = keyboard_names.layout_id(l, layout)
            if variant:
                try:
                    var = keyboard_names.variant_id(l, ly, misc.utf8(variant))
                except KeyError:
                    var = None

            self.keyboardDisplay.setVariant(var)

        if layout is not None and variant is not None:
            self.controller.dbfilter.apply_keyboard(layout, variant)

    def set_keyboard_choices(self, choices):
        self.page.keyboard_layout_combobox.clear()
        for choice in sorted(choices):
            self.page.keyboard_layout_combobox.addItem(misc.utf8(choice))

        if self.current_layout is not None:
            self.set_keyboard(self.current_layout)

    @plugin.only_this_page
    def set_keyboard(self, layout):
        index = self.page.keyboard_layout_combobox.findText(misc.utf8(layout))

        if index > -1:
            self.page.keyboard_layout_combobox.setCurrentIndex(index)

        if self.keyboardDisplay:
            l = self.controller.dbfilter.get_locale()
            ly = keyboard_names.layout_id(l, misc.utf8(layout))
            self.keyboardDisplay.setLayout(ly)

    def get_keyboard(self):
        if self.page.keyboard_layout_combobox.currentIndex() < 0:
            return None

        return str(self.page.keyboard_layout_combobox.currentText())

    def set_keyboard_variant_choices(self, choices):
        self.page.keyboard_variant_combobox.clear()
        for choice in sorted(choices):
            self.page.keyboard_variant_combobox.addItem(misc.utf8(choice))

    @plugin.only_this_page
    def set_keyboard_variant(self, variant):
        index = self.page.keyboard_variant_combobox.findText(
            misc.utf8(variant))

        if index > -1:
            self.page.keyboard_variant_combobox.setCurrentIndex(index)

        if self.keyboardDisplay:
            l = self.controller.dbfilter.get_locale()
            layout = keyboard_names.layout_id(l, self.get_keyboard())
            if variant:
                try:
                    var = keyboard_names.variant_id(
                        l, layout, misc.utf8(variant))
                except KeyError:
                    var = None

            self.keyboardDisplay.setVariant(var)

    def get_keyboard_variant(self):
        if self.page.keyboard_variant_combobox.currentIndex() < 0:
            return None

        return str(self.page.keyboard_variant_combobox.currentText())
コード例 #4
0
class PageKde(plugin.PluginUI):
    plugin_breadcrumb = 'ubiquity/text/breadcrumb_keyboard'

    def __init__(self, controller, *args, **kwargs):
        self.controller = controller
        self.current_layout = None
        self.default_keyboard_layout = None
        self.default_keyboard_variant = None

        try:
            from PyQt5 import uic
            from PyQt5.QtWidgets import QVBoxLayout
            from ubiquity.frontend.kde_components.Keyboard import Keyboard

            self.page = uic.loadUi(
                '/usr/share/ubiquity/qt/stepKeyboardConf.ui')
            self.keyboardDisplay = Keyboard(self.page.keyboard_frame)
            self.page.keyboard_frame.setLayout(QVBoxLayout())
            self.page.keyboard_frame.layout().addWidget(self.keyboardDisplay)
            # use activated instead of changed because we only want to act
            # when the user changes the selection not when we are populating
            # the combo box
            self.page.keyboard_layout_combobox.activated.connect(
                self.on_keyboard_layout_selected)
            self.page.keyboard_variant_combobox.activated.connect(
                self.on_keyboard_variant_selected)
        except Exception as e:
            self.debug('Could not create keyboard page: %s', e)
            self.page = None
        self.plugin_widgets = self.page

    @plugin.only_this_page
    def on_keyboard_layout_selected(self, *args):
        layout = self.get_keyboard()
        lang = self.controller.dbfilter.get_locale()
        if layout is not None:
            # skip updating keyboard if not using display
            if self.keyboardDisplay:
                try:
                    ly = keyboard_names.layout_id(lang, misc.utf8(layout))
                except KeyError:
                    ly = keyboard_names.layout_id('C', misc.utf8(layout))
                self.keyboardDisplay.setLayout(ly)

                # no variants, force update by setting none
                # if not keyboard_names.has_variants(l, ly):
                #    self.keyboardDisplay.setVariant(None)

                self.current_layout = layout
                self.controller.dbfilter.change_layout(layout)

    @plugin.only_this_page
    def on_keyboard_variant_selected(self, *args):
        layout = self.get_keyboard()
        variant = self.get_keyboard_variant()

        if self.keyboardDisplay:
            var = None
            lang = self.controller.dbfilter.get_locale()
            try:
                ly = keyboard_names.layout_id(lang, layout)
            except KeyError:
                ly = keyboard_names.layout_id('C', layout)
            if variant:
                try:
                    var = keyboard_names.variant_id(lang, ly,
                                                    misc.utf8(variant))
                except KeyError:
                    var = None

            self.keyboardDisplay.setVariant(var)

        if layout is not None and variant is not None:
            self.controller.dbfilter.apply_keyboard(layout, variant)

    def set_keyboard_choices(self, choices):
        self.page.keyboard_layout_combobox.clear()
        for choice in sorted(choices):
            self.page.keyboard_layout_combobox.addItem(misc.utf8(choice))

        if self.current_layout is not None:
            self.set_keyboard(self.current_layout)

    @plugin.only_this_page
    def set_keyboard(self, layout):
        index = self.page.keyboard_layout_combobox.findText(misc.utf8(layout))

        if index > -1:
            self.page.keyboard_layout_combobox.setCurrentIndex(index)

        if self.keyboardDisplay:
            lang = self.controller.dbfilter.get_locale()
            try:
                ly = keyboard_names.layout_id(lang, misc.utf8(layout))
            except KeyError:
                ly = keyboard_names.layout_id('C', misc.utf8(layout))
            self.keyboardDisplay.setLayout(ly)

    def get_keyboard(self):
        if self.page.keyboard_layout_combobox.currentIndex() < 0:
            return None

        return str(self.page.keyboard_layout_combobox.currentText())

    def set_keyboard_variant_choices(self, choices):
        self.page.keyboard_variant_combobox.clear()
        for choice in sorted(choices):
            self.page.keyboard_variant_combobox.addItem(misc.utf8(choice))

    @plugin.only_this_page
    def set_keyboard_variant(self, variant):
        index = self.page.keyboard_variant_combobox.findText(
            misc.utf8(variant))

        if index > -1:
            self.page.keyboard_variant_combobox.setCurrentIndex(index)

        if self.keyboardDisplay:
            lang = self.controller.dbfilter.get_locale()
            try:
                layout = keyboard_names.layout_id(lang, self.get_keyboard())
            except KeyError:
                layout = keyboard_names.layout_id('C', self.get_keyboard())
            if variant:
                try:
                    var = keyboard_names.variant_id(lang, layout,
                                                    misc.utf8(variant))
                except KeyError:
                    var = None

            self.keyboardDisplay.setVariant(var)

    def get_keyboard_variant(self):
        if self.page.keyboard_variant_combobox.currentIndex() < 0:
            return None

        return str(self.page.keyboard_variant_combobox.currentText())