Example #1
0
 def addressWidget(self):
     row = QtWidgets.QHBoxLayout()
     row.addWidget(self.navigationToolBar)
     row.addWidget(self.addressEdit, 1)
     row.addWidget(self.optionToolBar)
     row.setContentsMargins(4, 5, 4, 2)
     ret = QtWidgets.QWidget()
     ret.setLayout(row)
     return ret
Example #2
0
    def _createUi(self, q):
        self.userTab = _prefs.UserTab()
        self.textTab = _prefs.TextTab()
        self.ttsTab = _prefs.TtsTab()
        self.ocrTab = _prefs.OcrTab()
        #self.srTab = _prefs.SrTab()
        self.gameTab = _prefs.GameTab()
        self.shortcutsTab = _prefs.ShortcutsTab()
        self.uiTab = _prefs.UiTab()
        self.recordingsTab = _prefs.RecordingsTab()
        self.i18nTab = _prefs.I18nTab()
        self.engineTab = _prefs.EngineTab()
        self.internetTab = _prefs.InternetTab()
        self.featureTab = _prefs.FeatureTab()
        #self.pluginTab = _prefs.PluginTab()

        self.translationTab = _prefs.TranslationTab()
        self.machineTranslationTab = _prefs.MachineTranslationTab()
        self.dictionaryTranslationTab = _prefs.DictionaryTranslationTab()
        self.romanTranslationTab = _prefs.RomanTranslationTab()
        self.chineseTranslationTab = _prefs.ChineseTranslationTab()
        #self.translationScriptTab = _prefs.TranslationScriptTab()

        self.termTab = _prefs.TermTab()

        self.downloadsTab = _prefs.DownloadsTab()
        self.dictionaryDownloadsTab = _prefs.DictionaryDownloadsTab()
        self.launcherDownloadsTab = _prefs.LauncherDownloadsTab()
        self.fontDownloadsTab = _prefs.FontDownloadsTab()

        self.libraryTab = _prefs.LibraryTab()
        self.localeLibraryTab = _prefs.LocaleLibraryTab()
        self.translatorLibraryTab = _prefs.TranslatorLibraryTab()
        self.dictionaryLibraryTab = _prefs.DictionaryLibraryTab()
        self.ttsLibraryTab = _prefs.TtsLibraryTab()
        self.ocrLibraryTab = _prefs.OcrLibraryTab()

        #for t in self.itertabs():
        #  t.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
        #                  QtWidgets.QSizePolicy.Expanding)

        container = QtWidgets.QScrollArea()  # widget container
        container.setWidgetResizable(True)  # false by default
        container.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        container.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        #container.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        #container.setAlignment(Qt.AlignTop | Qt.AlignHCenter)

        self.controller = skmvc.SkWidgetTreeController(
            parent=q,
            container=container,
            data={
                'display':
                tr_("Preferences"),
                'children': [
                    {
                        'widget': self.userTab,
                        'user': self._indexWidget(self.userTab),
                        'decoration': rc.icon('pref-user'),
                        'display': tr_("Account"),
                        'toolTip': my.tr("User account"),
                    },
                    {
                        'widget': self.engineTab,
                        'user': self._indexWidget(self.engineTab),
                        #'display': u"%s (α)" % mytr_("Embedded"),
                        'display': mytr_("Embedded"),
                        'decoration': rc.icon('pref-config'),
                        'toolTip': my.tr("Embedded subtitles"),
                    },
                    {
                        'widget':
                        self.downloadsTab,
                        'user':
                        self._indexWidget(self.downloadsTab),
                        'decoration':
                        rc.icon('pref-download'),
                        'display':
                        tr_("Downloads"),
                        'toolTip':
                        my.tr("Download additional resources"),
                        'children': [
                            {
                                'widget':
                                self.launcherDownloadsTab,
                                'user':
                                self._indexWidget(self.launcherDownloadsTab),
                                'decoration':
                                rc.icon('pref-locale'),
                                'display':
                                tr_("Launch"),
                                'toolTip':
                                my.tr("Locale changers"),
                            },
                            {
                                'widget':
                                self.dictionaryDownloadsTab,
                                'user':
                                self._indexWidget(self.dictionaryDownloadsTab),
                                'decoration':
                                rc.icon('pref-dict'),
                                'display':
                                tr_("Dictionaries"),
                                'toolTip':
                                my.tr("Manage dictionaries"),
                            },
                            {
                                'widget': self.fontDownloadsTab,
                                'user':
                                self._indexWidget(self.fontDownloadsTab),
                                'decoration': rc.icon('pref-font'),
                                'display': tr_("Fonts"),
                                'toolTip': my.tr("Manage fonts"),
                            },
                        ]
                    },
                    {
                        'widget':
                        self.libraryTab,
                        'user':
                        self._indexWidget(self.libraryTab),
                        'decoration':
                        rc.icon('pref-library'),
                        'display':
                        tr_("Locations"),
                        'toolTip':
                        my.tr("Locations of external libraries"),
                        'children': [
                            {
                                'widget':
                                self.localeLibraryTab,
                                'user':
                                self._indexWidget(self.localeLibraryTab),
                                'decoration':
                                rc.icon('pref-locale'),
                                'display':
                                tr_("Launch"),
                                'toolTip':
                                my.tr("Locations of external locale changers"),
                            },
                            {
                                'widget':
                                self.translatorLibraryTab,
                                'user':
                                self._indexWidget(self.translatorLibraryTab),
                                'decoration':
                                rc.icon('pref-tr-path'),
                                'display':
                                tr_("Translators"),
                                'toolTip':
                                my.tr("Locations of external translators"),
                            },
                            {
                                'widget':
                                self.dictionaryLibraryTab,
                                'user':
                                self._indexWidget(self.dictionaryLibraryTab),
                                'decoration':
                                rc.icon('pref-dict'),
                                'display':
                                tr_("Dictionaries"),
                                'toolTip':
                                my.tr("Locations of external dictionary"),
                            },
                            {
                                'widget': self.ttsLibraryTab,
                                'user': self._indexWidget(self.ttsLibraryTab),
                                'decoration': rc.icon('pref-tts-path'),
                                'display': mytr_("TTS"),
                                'toolTip': my.tr("Locations of external TTS"),
                            },
                            {
                                'widget':
                                self.ocrLibraryTab,
                                'user':
                                self._indexWidget(self.ocrLibraryTab),
                                'decoration':
                                rc.icon('pref-ocr-path'),
                                'display':
                                mytr_("OCR"),
                                'toolTip':
                                my.tr("Locations of external OCR libraries"),
                            },
                        ]
                    },
                    {
                        'widget':
                        self.translationTab,
                        'user':
                        self._indexWidget(self.translationTab),
                        'decoration':
                        rc.icon('pref-tr'),
                        'display':
                        tr_("Translation"),
                        'toolTip':
                        my.tr("Machine translators"),
                        'children': [
                            {
                                'widget':
                                self.machineTranslationTab,
                                'user':
                                self._indexWidget(self.machineTranslationTab),
                                'decoration':
                                rc.icon('pref-tr-path'),
                                'display':
                                tr_("Translators"),
                                'toolTip':
                                my.tr("Preferred machine translators"),
                            },
                            {
                                'widget':
                                self.dictionaryTranslationTab,
                                'user':
                                self._indexWidget(
                                    self.dictionaryTranslationTab),
                                'decoration':
                                rc.icon('pref-dict'),
                                'display':
                                tr_("Dictionaries"),
                                'toolTip':
                                my.tr("Preferred look-up dictionaries"),
                            },
                            {
                                'widget':
                                self.romanTranslationTab,
                                'user':
                                self._indexWidget(self.romanTranslationTab),
                                'decoration':
                                rc.icon('pref-roman'),
                                'display':
                                mytr_("C/K Ruby"),
                                'toolTip':
                                my.
                                tr("Romanization of texts in Chinese and Korean"
                                   ),
                            },
                            {
                                'widget':
                                self.chineseTranslationTab,
                                'user':
                                self._indexWidget(self.chineseTranslationTab),
                                'decoration':
                                rc.icon('pref-zh'),
                                'display':
                                tr_("Chinese"),
                                'toolTip':
                                my.tr("Preferred Chinese variant"),
                            },
                            #{ 'widget': self.translationScriptTab,
                            #  'user': self._indexWidget(self.translationScriptTab),
                            #  'decoration': rc.icon('pref-script'),
                            #  'display': tr_("Scripts"),
                            #  'toolTip': my.tr("Translation replacement scripts"),
                            #},
                        ]
                    },
                    {
                        'widget': self.ttsTab,
                        'user': self._indexWidget(self.ttsTab),
                        'decoration': rc.icon('pref-tts'),
                        'display': mytr_("Text-To-Speech"),
                        'toolTip': mytr_("Text-To-Speech") + " (TTS)",
                    },
                    #{ 'widget': self.srTab,
                    #  'user': self._indexWidget(self.srTab),
                    #  'decoration': rc.icon('pref-sr'),
                    #  'display': u"%s (α)" % mytr_("ASR"),
                    #  'toolTip': mytr_("Automatic speech recognition") + " (ASR)",
                    #},
                    {
                        'widget':
                        self.ocrTab,
                        'user':
                        self._indexWidget(self.ocrTab),
                        'decoration':
                        rc.icon('pref-ocr'),
                        'display':
                        u"%s (α)" % mytr_("OCR"),
                        'toolTip':
                        mytr_("Optical character recognition") + " (OCR)",
                    },
                    {
                        'widget': self.textTab,
                        'user': self._indexWidget(self.textTab),
                        'display': tr_("Font"),
                        'decoration': rc.icon('pref-text'),
                        'toolTip': my.tr("Text rendering"),
                    },
                    {
                        'widget': self.gameTab,
                        'user': self._indexWidget(self.gameTab),
                        'decoration': rc.icon('pref-app'),
                        'display': tr_("Launch"),
                        'toolTip': my.tr("Game launch settings"),
                    },
                    {
                        'widget': self.shortcutsTab,
                        'user': self._indexWidget(self.shortcutsTab),
                        'decoration': rc.icon('pref-shortcuts'),
                        'display': mytr_("Shortcuts"),
                        'toolTip': my.tr("Mouse and keyboard shortcuts"),
                    },
                    {
                        'widget': self.recordingsTab,
                        'user': self._indexWidget(self.recordingsTab),
                        'decoration': rc.icon('pref-rec'),
                        'display': mytr_("Recordings"),
                        'toolTip': my.tr("Game recordings"),
                    },
                    {
                        'widget': self.uiTab,
                        'user': self._indexWidget(self.uiTab),
                        'decoration': rc.icon('pref-ui'),
                        'display': tr_("UI"),
                        'toolTip': my.tr("UI Theme"),
                    },
                    {
                        'widget': self.i18nTab,
                        'user': self._indexWidget(self.i18nTab),
                        'display': tr_("i18n"),
                        'decoration': rc.icon('pref-i18n'),
                        'toolTip': tr_("International"),
                    },
                    {
                        'widget': self.termTab,
                        'user': self._indexWidget(self.termTab),
                        'decoration': rc.icon('pref-share'),
                        'display': mytr_("Shared Dictionary"),
                        'toolTip': mytr_("Shared Dictionary"),
                    },
                    {
                        'widget': self.internetTab,
                        'user': self._indexWidget(self.internetTab),
                        'decoration': rc.icon('pref-internet'),
                        'display': tr_("Internet"),
                        'toolTip': my.tr("Internet options"),
                    },
                    {
                        'widget': self.featureTab,
                        'user': self._indexWidget(self.featureTab),
                        'decoration': rc.icon('pref-feature'),
                        'display': tr_("Features"),
                        'toolTip': my.tr("Application features"),
                    },
                ],
            })
        self.controller.treeView().setHeaderHidden(True)
        self.controller.treeView().expandAll()

        left = QtWidgets.QWidget()
        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(self.controller.treeView())
        row = QtWidgets.QHBoxLayout()
        row.addWidget(self.controller.filterEdit())
        row.addWidget(self.controller.countLabel())
        layout.addLayout(row)
        left.setLayout(layout)
        q.addWidget(left)

        skqss.class_(self.controller.treeView(), 'texture')

        right = self.controller.widgetView()
        #right.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
        #                    QtWidgets.QSizePolicy.Expanding)
        q.addWidget(right)

        self.controller.currentIndexChanged.connect(self._refreshCurrentWidget)

        w = self.controller.filterEdit()
        w.setToolTip("%s (%s, %s, Ctrl+F)" %
                     (tr_("Search"), tr_("case-insensitive"),
                      tr_("regular expression")))
        shortcut('ctrl+f', w.setFocus, parent=q)
Example #3
0
 def __init__(self, widget=None, parent=None):
     super(SkTitlelessDockWidget, self).__init__(parent)
     self.setTitleBarWidget(QtWidgets.QWidget())
     #self.setContentsMargins(0, 0, 0, 0)
     if widget:
         self.setWidget(widget)