Exemple #1
0
 def on_treeview_language_cursor_changed(self, treeview):
     selected = treeview.get_selection()
     if selected:
         (ls, iter) = selected.get_selected()
         if iter:
             current_language, sorted_choices, display_map = i18n.get_languages()
             language = ls.get_value(iter, 0)
             language_code = display_map[language][1]
             self.set_language(language_code)
Exemple #2
0
 def on_treeview_language_cursor_changed(self, treeview):
     selected = treeview.get_selection()
     if selected:
         (ls, iter) = selected.get_selected()
         if iter:
             current_language, sorted_choices, display_map = i18n.get_languages(self.language_list)
             language = ls.get_value(iter, 0)
             language_code = display_map[language][1]
             self.set_language(language_code)
Exemple #3
0
    def set_languages_list(self):
        liststore_language = Gtk.ListStore(str)

        render = Gtk.CellRendererText()
        col_languages = Gtk.TreeViewColumn(_("Languages"), render, text=0)
        self.treeview_language.set_model(liststore_language)
        self.treeview_language.append_column(col_languages)

        current_language, sorted_choices, display_map = i18n.get_languages()

        for lang in sorted_choices:
            liststore_language.append([lang])
Exemple #4
0
    def __init__(self):
        QScrollArea.__init__(self)
        self.vbox = QVBoxLayout()

        self.tab = QHBoxLayout()
        widget = QWidget()
        widget.setLayout(self.tab)
        self.file_path = os.path.join(get_user_settings_dir(), "lang.inp")

        title_label = QLabel()
        title_label.setWordWrap(True)
        title_label.setOpenExternalLinks(True)
        title_label.setText(
            latex_to_html(
                "<font size=5><b>Select the language you would like use gpvdm to use.</b><br><br> If a translation to your language does not exist or could be improved, then please consider joining the <a href=\"https://gpvdm.com/translation.html\">gpvdm translation project</a>.  I would like gpvdm translated into as many langauges as possible to improve access to high quality solar cell simulation tools for all.</font>"
            ))

        self.vbox.addWidget(title_label)
        self.vbox.addWidget(widget)

        description = QLabel()
        description.setText(latex_to_html("Default language:"))

        self.lang_box = QComboBox()

        self.lang_box.addItem("auto")

        self.lang_box.setFixedSize(300, 25)

        self.tab.addWidget(description)
        self.tab.addWidget(self.lang_box)

        spacer = QWidget()
        spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.vbox.addWidget(spacer)
        self.setLayout(self.vbox)

        langs = get_languages()
        if langs == False:
            return

        for i in range(0, len(langs)):
            self.lang_box.addItem(langs[i])

        token = inp_get_token_value(self.file_path, "#lang")
        all_items = [
            self.lang_box.itemText(i) for i in range(self.lang_box.count())
        ]
        for i in range(0, len(all_items)):
            if all_items[i] == token:
                self.lang_box.setCurrentIndex(i)

        self.lang_box.currentIndexChanged.connect(self.callback_edit)
Exemple #5
0
    def store_values(self):
        selected = self.treeview_language.get_selection()

        (ls, iter) = selected.get_selected()
        language = ls.get_value(iter,0)

        current_language, sorted_choices, display_map = i18n.get_languages(self.language_list)

        self.settings.set("language_name", display_map[language][0])
        self.settings.set("language_code", display_map[language][1])
        
        return True
Exemple #6
0
    def store_values(self):
        selected = self.treeview_language.get_selection()

        (ls, iter) = selected.get_selected()
        language = ls.get_value(iter,0)

        current_language, sorted_choices, display_map = i18n.get_languages(self.language_list)

        self.settings.set("language_name", display_map[language][0])
        self.settings.set("language_code", display_map[language][1])
        
        return True
Exemple #7
0
    def set_languages_list(self):
        liststore_language = Gtk.ListStore(str)

        render = Gtk.CellRendererText()
        col_languages = Gtk.TreeViewColumn(_("Languages"), render, text=0)
        self.treeview_language.set_model(liststore_language)
        self.treeview_language.append_column(col_languages)

        current_language, sorted_choices, display_map = i18n.get_languages(self.language_list)
        current_language = self.langcode_to_lang(display_map)
        for lang in sorted_choices:
            liststore_language.append([lang])
            if current_language == lang:
                self.select_default_row(self.treeview_language, current_language)
Exemple #8
0
    def store_values(self):
        selected = self.treeview_language.get_selection()

        (ls, iter) = selected.get_selected()
        language = ls.get_value(iter, 0)

        current_language, sorted_choices, display_map = i18n.get_languages()

        installer_settings["language_name"] = display_map[language][0]
        installer_settings["language_code"] = display_map[language][1]

        logging.debug("language_name is " + installer_settings["language_name"])
        logging.debug("language_code is " + installer_settings["language_code"])
        print("language_name is " + installer_settings["language_name"])
        print("language_code is " + installer_settings["language_code"])
Exemple #9
0
 def test_get_language_malformed(self):
     # Should be te-ST;q=1.0
     i18n.request.headers = {'Accept-Language': 'te-ST; q=1.0'}
     self.assertEqual(i18n.get_languages(), ['en-US', 'en_US'])
Exemple #10
0
 def test_get_language_malformed(self):
     # Should be te-ST;q=1.0
     i18n.request.headers = {'Accept-Language': 'te-ST; q=1.0'}
     self.assertEqual(i18n.get_languages(), ['en-US', 'en_US'])
Exemple #11
0
 def test_01_get_languages(self):
     languages = i18n.get_languages()
     print(languages)
     assert len(languages) > 1
Exemple #12
0
 def test_get_language_malformed2(self):
     i18n.request.headers = {'Accept-Language': 'LOL;!!!,,;,'}
     self.assertEqual(i18n.get_languages(), ['en-US', 'en_US'])
Exemple #13
0
 def test_get_language_single(self):
     i18n.request.headers = {'Accept-Language': 'te-ST'}
     self.assertEqual(i18n.get_languages(), ['te-ST', 'en-US', 'en_US'])
Exemple #14
0
 def test_get_language_many(self):
     # Example from the w3c spec :)
     i18n.request.headers = {'Accept-Language': 'da, en-gb;q=0.8, en;q=0.7'}
     self.assertEqual(i18n.get_languages(),
                      ['da', 'en-gb', 'en', 'en-US', 'en_US'])
Exemple #15
0
 def test_get_language_none(self):
     i18n.request.headers = {}
     self.assertEqual(i18n.get_languages(), ['en-US', 'en_US'])
Exemple #16
0
 def test_get_language_malformed2(self):
     i18n.request.headers = {'Accept-Language': 'LOL;!!!,,;,'}
     self.assertEqual(i18n.get_languages(), ['en-US', 'en_US'])
Exemple #17
0
 def test_get_language_none(self):
     i18n.request.headers = {}
     self.assertEqual(i18n.get_languages(), ['en-US', 'en_US'])
Exemple #18
0
 def test_get_language_single(self):
     i18n.request.headers = {'Accept-Language': 'te-ST'}
     self.assertEqual(i18n.get_languages(), ['te-ST', 'en-US', 'en_US'])
Exemple #19
0
 def test_get_language_many(self):
     # Example from the w3c spec :)
     i18n.request.headers = {'Accept-Language': 'da, en-gb;q=0.8, en;q=0.7'}
     self.assertEqual(i18n.get_languages(),
                      ['da', 'en-gb', 'en', 'en-US', 'en_US'])
Exemple #20
0
 def test_01_get_languages(self):
     languages = i18n.get_languages()
     print(languages)
     assert len(languages) > 1
Exemple #21
0
    def initWindow(self):
        # set skin for utils_ui
        utils_ui.setSkin(self.config["skin"])
        # menu layout
        self.settingsButton = QPushButton()
        self.skinButton = QPushButton("")
        self.languageCombobox = ButtonCombbox(icon="fa.language",
                                              btnClass="smallBtn2")
        self.languages = i18n.get_languages()
        for locale in self.languages:
            self.languageCombobox.addItem(self.languages[locale])
        self.aboutButton = QPushButton()
        self.functionalButton = QPushButton()
        self.encodingCombobox = ComboBox()
        self.supportedEncoding = parameters.encodings
        for encoding in self.supportedEncoding:
            self.encodingCombobox.addItem(encoding)
        self.settingsButton.setProperty("class", "menuItem1")
        self.skinButton.setProperty("class", "menuItem2")
        self.aboutButton.setProperty("class", "menuItem3")
        self.functionalButton.setProperty("class", "menuItem4")
        self.settingsButton.setObjectName("menuItem")
        self.skinButton.setObjectName("menuItem")
        self.aboutButton.setObjectName("menuItem")
        self.functionalButton.setObjectName("menuItem")
        # plugins slector
        self.pluginsSelector = ButtonCombbox(icon="fa.plus",
                                             btnClass="smallBtn2")
        self.pluginsSelector.addItem(self.loadPluginStr)
        self.pluginsSelector.activated.connect(self.onPluginSelectorChanged)

        # title bar
        title = parameters.appName + " v" + version.__version__
        iconPath = self.DataPath + "/" + parameters.appIcon
        log.i("icon path: " + iconPath)
        self.titleBar = TitleBar(self,
                                 icon=iconPath,
                                 title=title,
                                 brothers=[],
                                 widgets=[[self.skinButton, self.aboutButton],
                                          []])
        CustomTitleBarWindowMixin.__init__(self,
                                           titleBar=self.titleBar,
                                           init=True)

        # root layout
        self.frameWidget = QWidget()
        self.frameWidget.setMouseTracking(True)
        self.frameWidget.setLayout(self.rootLayout)
        self.setCentralWidget(self.frameWidget)
        # tab widgets
        self.tabWidget = QTabWidget()
        self.tabWidget.setTabsClosable(True)
        # tab left menu
        tabConerWidget = QWidget()
        tabConerLayout = QHBoxLayout()
        tabConerLayout.setSpacing(0)
        tabConerLayout.setContentsMargins(0, 0, 0, 0)
        tabConerWidget.setLayout(tabConerLayout)
        tabConerLayout.addWidget(self.settingsButton)
        # tab right menu
        tabConerWidgetRight = QWidget()
        tabConerLayoutRight = QHBoxLayout()
        tabConerLayoutRight.setSpacing(0)
        tabConerLayoutRight.setContentsMargins(0, 0, 0, 0)
        tabConerWidgetRight.setLayout(tabConerLayoutRight)
        tabConerLayoutRight.addWidget(self.pluginsSelector)
        tabConerLayoutRight.addWidget(self.languageCombobox)
        tabConerLayoutRight.addWidget(self.encodingCombobox)
        tabConerLayoutRight.addWidget(self.functionalButton)
        self.tabWidget.setCornerWidget(tabConerWidget, Qt.TopLeftCorner)
        self.tabWidget.setCornerWidget(tabConerWidgetRight, Qt.TopRightCorner)
        self.contentLayout = QVBoxLayout()
        self.contentWidget.setLayout(self.contentLayout)
        self.contentLayout.setContentsMargins(10, 0, 10, 10)
        self.contentLayout.addWidget(self.tabWidget)

        if sys.platform == 'darwin':
            self.macOsAddDockMenu()

        self.resize(850, 500)
        self.MoveToCenter()
        self.show()