Пример #1
0
    def __init__(self):
        QWidget.__init__(self)
        self.ui = Ui_KeyboardWidget()
        self.ui.setupUi(self)

        index = 0  # comboBox.addItem doesn't increase the currentIndex
        self.default_layout_index = None
        locales = sorted([(country, data)
                          for country, data in yali.localedata.locales.items()
                          ])
        for country, data in locales:
            if data["xkbvariant"]:
                i = 0
                for variant in data["xkbvariant"]:
                    _d = dict(data)
                    _d["xkbvariant"] = variant[0]
                    _d["name"] = variant[1]
                    _d["consolekeymap"] = data["consolekeymap"][i]
                    self.ui.keyboard_list.addItem(_d["name"], QVariant(_d))
                    i += 1
            else:
                self.ui.keyboard_list.addItem(data["name"], QVariant(data))
            if ctx.consts.lang == country:
                if ctx.consts.lang == "tr":
                    self.default_layout_index = index + 1
                else:
                    self.default_layout_index = index
            index += 1

        self.ui.keyboard_list.setCurrentIndex(self.default_layout_index)

        self.connect(self.ui.keyboard_list, SIGNAL("currentIndexChanged(int)"),
                     self.slotLayoutChanged)
Пример #2
0
class Widget(QWidget, ScreenWidget):
    name = "keyboardSetup"

    def __init__(self):
        QWidget.__init__(self)
        self.ui = Ui_KeyboardWidget()
        self.ui.setupUi(self)

        index = 0 # comboBox.addItem doesn't increase the currentIndex
        self.default_layout_index = None
        locales = sorted([(country, data) for country, data in yali.localedata.locales.items()])
        for country, data in locales:
            if data["xkbvariant"]:
                i = 0
                for variant in data["xkbvariant"]:
                    _d = dict(data)
                    _d["xkbvariant"] = variant[0]
                    _d["name"] = variant[1]
                    _d["consolekeymap"] = data["consolekeymap"][i]
                    self.ui.keyboard_list.addItem(_d["name"], QVariant(_d))
                    i += 1
            else:
                self.ui.keyboard_list.addItem(data["name"], QVariant(data))
            if ctx.consts.lang == country:
                if ctx.consts.lang == "tr":
                    self.default_layout_index = index + 1
                else:
                    self.default_layout_index = index
            index += 1


        self.ui.keyboard_list.setCurrentIndex(self.default_layout_index)

        self.connect(self.ui.keyboard_list, SIGNAL("currentIndexChanged(int)"),
                self.slotLayoutChanged)

    def shown(self):
        self.slotLayoutChanged()

    def slotLayoutChanged(self):
        index = self.ui.keyboard_list.currentIndex()
        keymap = self.ui.keyboard_list.itemData(index).toMap()
        # Gökmen's converter
        keymap = dict(map(lambda x: (str(x[0]), unicode(x[1].toString())), keymap.iteritems()))
        ctx.installData.keyData = keymap
        ctx.interface.informationWindow.hide()
        if "," in keymap["xkblayout"]:
            message = _("Use Alt-Shift to toggle between alternative keyboard layouts")
            ctx.interface.informationWindow.update(message, type="warning")
        else:
            ctx.interface.informationWindow.hide()

        yali.util.setKeymap(keymap["xkblayout"], keymap["xkbvariant"])

    def execute(self):
        ctx.interface.informationWindow.hide()
        ctx.logger.debug("Selected keymap is : %s" % ctx.installData.keyData["name"])
        return True
Пример #3
0
class Widget(QtGui.QWidget, ScreenWidget):
    title = _("Choose a Keyboard Layout")
    icon = "iconKeyboard"
    help = _("""
<font size="+2">Keyboard Layout</font>
<font size="+1">
<p>
A keyboard layout is a description of how keys are placed on a keyboard. There are different keyboard layouts in use throughout the world. The one you will want to use, generally depends on the country you live in or the language you use.
</p>
<p>
This screen lets you select the keyboard layout you want to use on Pardus. You can test the selected layout by typing something in the given textbox.
</p>
</font>
""")

    def __init__(self, *args):
        QtGui.QWidget.__init__(self,None)
        self.ui = Ui_KeyboardWidget()
        self.ui.setupUi(self)

        defaultitem = None
        for country,data in yali.localedata.locales.items():
            if data["xkbvariant"]:
                i = 0
                for variant in data["xkbvariant"]:
                    _d = dict(data)
                    _d["xkbvariant"] = variant[0]
                    _d["name"] = variant[1]
                    _d["consolekeymap"] = data["consolekeymap"][i]
                    ki = KeyboardItem(self.ui.keyboard_list, _d)
                    i+=1
            else:
                ki = KeyboardItem(self.ui.keyboard_list, data)
            if ctx.consts.lang == country and not defaultitem:
                defaultitem = ki

        self.ui.keyboard_list.sortItems(Qt.AscendingOrder)
        self.ui.keyboard_list.setCurrentItem(defaultitem)
        self.slotLayoutChanged(defaultitem)

        self.connect(self.ui.keyboard_list, SIGNAL("currentItemChanged(QListWidgetItem*, QListWidgetItem*)"),
                self.slotLayoutChanged)

    def slotLayoutChanged(self, i, y=None):
        try:
            if not i==y:
                ctx.yali.setKeymap(i.getData())
        except:
            pass

    def execute(self):
        ctx.debugger.log("Selected keymap is : %s" % ctx.installData.keyData["name"] )
        return True
Пример #4
0
class Widget(QtGui.QWidget, ScreenWidget):
    title = _("Choose a Keyboard Layout")
    icon = "input-keyboard"
    help = _("""A keyboard layout is a description of how keys are placed on a keyboard. There are different keyboard layouts in use throughout the world. The one you will want to use, generally depends on the country you live in or the language you use.
This screen lets you select the keyboard layout you want to use on Pardus. You can test the selected layout by typing something in the given textbox.
""")

    def __init__(self, *args):
        QtGui.QWidget.__init__(self,None)
        self.ui = Ui_KeyboardWidget()
        self.ui.setupUi(self)

        index = 0 # comboBox.addItem doesn't increase the currentIndex
        self.defaultLayoutIndex = None
        for country,data in yali.localedata.locales.items():
            if data["xkbvariant"]:
                i = 0
                for variant in data["xkbvariant"]:
                    _d = dict(data)
                    _d["xkbvariant"] = variant[0]
                    _d["name"] = variant[1]
                    _d["consolekeymap"] = data["consolekeymap"][i]
                    self.ui.keyboard_list.addItem(_d["name"], QVariant(data))
                    i+=1
            else:
                self.ui.keyboard_list.addItem(data["name"], QVariant(data))
            if ctx.consts.lang == country:
                if ctx.consts.lang == "tr":
                    self.defaultLayoutIndex = index + 1
                else:
                    self.defaultLayoutIndex = index
            index += 1


        self.ui.keyboard_list.setCurrentIndex(self.defaultLayoutIndex)
        self.slotLayoutChanged()

        self.connect(self.ui.keyboard_list, SIGNAL("currentIndexChanged(int)"),
                self.slotLayoutChanged)

    def slotLayoutChanged(self):
        index = self.ui.keyboard_list.currentIndex()
        keymap = self.ui.keyboard_list.itemData(index).toMap()
        # Gökmen's converter
        keymap = dict(map(lambda x: (str(x[0]), unicode(x[1].toString())), keymap.iteritems()))
        ctx.installData.keyData = keymap
        yali.localeutils.setKeymap(keymap["xkblayout"], keymap["xkbvariant"])

    def execute(self):
        ctx.logger.debug("Selected keymap is : %s" % ctx.installData.keyData["name"] )
        return True
Пример #5
0
    def __init__(self, *args):
        QtGui.QWidget.__init__(self,None)
        self.ui = Ui_KeyboardWidget()
        self.ui.setupUi(self)

        defaultitem = None
        for country,data in yali.localedata.locales.items():
            if data["xkbvariant"]:
                i = 0
                for variant in data["xkbvariant"]:
                    _d = dict(data)
                    _d["xkbvariant"] = variant[0]
                    _d["name"] = variant[1]
                    _d["consolekeymap"] = data["consolekeymap"][i]
                    ki = KeyboardItem(self.ui.keyboard_list, _d)
                    i+=1
            else:
                ki = KeyboardItem(self.ui.keyboard_list, data)
            if ctx.consts.lang == country and not defaultitem:
                defaultitem = ki

        self.ui.keyboard_list.sortItems(Qt.AscendingOrder)
        self.ui.keyboard_list.setCurrentItem(defaultitem)
        self.slotLayoutChanged(defaultitem)

        self.connect(self.ui.keyboard_list, SIGNAL("currentItemChanged(QListWidgetItem*, QListWidgetItem*)"),
                self.slotLayoutChanged)
Пример #6
0
    def __init__(self, *args):
        QtGui.QWidget.__init__(self,None)
        self.ui = Ui_KeyboardWidget()
        self.ui.setupUi(self)

        index = 0 # comboBox.addItem doesn't increase the currentIndex
        self.defaultLayoutIndex = None
        for country,data in yali.localedata.locales.items():
            if data["xkbvariant"]:
                i = 0
                for variant in data["xkbvariant"]:
                    _d = dict(data)
                    _d["xkbvariant"] = variant[0]
                    _d["name"] = variant[1]
                    _d["consolekeymap"] = data["consolekeymap"][i]
                    self.ui.keyboard_list.addItem(_d["name"], QVariant(data))
                    i+=1
            else:
                self.ui.keyboard_list.addItem(data["name"], QVariant(data))
            if ctx.consts.lang == country:
                if ctx.consts.lang == "tr":
                    self.defaultLayoutIndex = index + 1
                else:
                    self.defaultLayoutIndex = index
            index += 1


        self.ui.keyboard_list.setCurrentIndex(self.defaultLayoutIndex)
        self.slotLayoutChanged()

        self.connect(self.ui.keyboard_list, SIGNAL("currentIndexChanged(int)"),
                self.slotLayoutChanged)
Пример #7
0
    def __init__(self):
        QWidget.__init__(self)
        self.ui = Ui_KeyboardWidget()
        self.ui.setupUi(self)

        index = 0 # comboBox.addItem doesn't increase the currentIndex
        self.default_layout_index = None
        locales = sorted([(country, data) for country, data in yali.localedata.locales.items()])
        for country, data in locales:
            if data["xkbvariant"]:
                i = 0
                for variant in data["xkbvariant"]:
                    _d = dict(data)
                    _d["xkbvariant"] = variant[0]
                    _d["name"] = variant[1]
                    _d["consolekeymap"] = data["consolekeymap"][i]
                    self.ui.keyboard_list.addItem(_d["name"], QVariant(_d))
                    i += 1
            else:
                self.ui.keyboard_list.addItem(data["name"], QVariant(data))
            if ctx.consts.lang == country:
                if ctx.consts.lang == "tr":
                    self.default_layout_index = index + 1
                else:
                    self.default_layout_index = index
            index += 1


        self.ui.keyboard_list.setCurrentIndex(self.default_layout_index)

        self.ui.keyboard_list.currentIndexChanged[int].connect(self.slotLayoutChanged)
Пример #8
0
class Widget(QWidget, ScreenWidget):
    name = "keyboardSetup"

    def __init__(self):
        QWidget.__init__(self)
        self.ui = Ui_KeyboardWidget()
        self.ui.setupUi(self)

        index = 0  # comboBox.addItem doesn't increase the currentIndex
        self.default_layout_index = None
        locales = sorted([(country, data)
                          for country, data in yali.localedata.locales.items()
                          ])
        for country, data in locales:
            if data["xkbvariant"]:
                i = 0
                for variant in data["xkbvariant"]:
                    _d = dict(data)
                    _d["xkbvariant"] = variant[0]
                    _d["name"] = variant[1]
                    _d["consolekeymap"] = data["consolekeymap"][i]
                    self.ui.keyboard_list.addItem(_d["name"], QVariant(_d))
                    i += 1
            else:
                self.ui.keyboard_list.addItem(data["name"], QVariant(data))
            if ctx.lang == country:
                if ctx.lang == "tr":
                    self.default_layout_index = index + 1
                else:
                    self.default_layout_index = index
            index += 1

        self.ui.keyboard_list.setCurrentIndex(self.default_layout_index)

        self.ui.keyboard_list.currentIndexChanged[int].connect(
            self.slotLayoutChanged)

        ctx.mainScreen.currentLanguageChanged.connect(self.retranslateUi)
        ctx.mainScreen.currentLanguageChanged.connect(self.changeCountry)

    def changeCountry(self):
        countries = sorted(
            [country for country in yali.localedata.locales.keys()])

        index = countries.index(ctx.lang.split("_")[0])

        if ctx.lang == "tr":
            self.default_layout_index = index + 1
        else:
            self.default_layout_index = index

        self.ui.keyboard_list.setCurrentIndex(self.default_layout_index)

    def shown(self):
        self.slotLayoutChanged()

    def slotLayoutChanged(self):
        index = self.ui.keyboard_list.currentIndex()
        keymap = self.ui.keyboard_list.itemData(index)  #.toMap()
        # Gökmen's converter
        # keymap = dict(map(lambda x: (str(x[0]), unicode(x[1])), keymap.iteritems()))
        keymap = dict(map(lambda x: (str(x[0]), x[1]), keymap.iteritems()))
        ctx.installData.keyData = keymap
        ctx.interface.informationWindow.hide()
        if "," in keymap["xkblayout"]:
            message = _(
                "General",
                "Use Alt-Shift to toggle between alternative keyboard layouts")
            ctx.interface.informationWindow.update(message, type="warning")
        else:
            ctx.interface.informationWindow.hide()

        yali.util.setKeymap(keymap["xkblayout"], keymap["xkbvariant"])

    def execute(self):
        ctx.interface.informationWindow.hide()
        ctx.logger.debug("Selected keymap is : %s" %
                         ctx.installData.keyData["name"])
        return True

    def retranslateUi(self):
        self.ui.retranslateUi(self)

        for i in range(self.ui.keyboard_list.count()):
            self.ui.keyboard_list.setItemText(
                i, _("General",
                     self.ui.keyboard_list.itemData(i)["name"]))