def __init__(self, mainWindow, renderThread, pluginConfig=None): QWidget.__init__(self, mainWindow) self.mainWindow = mainWindow self.renderThread = renderThread self.pluginConfig = pluginConfig self.databaseUrl = None if self.pluginConfig: self.maximumSize = util.readConfigInt(self.pluginConfig, "Handwriting maximum field size", HandwritingPage.DEFAULT_MAXIMUM_FIELD_SIZE) self.maximumResults = util.readConfigInt(self.pluginConfig, "Handwriting maximum results", HandwritingPage.DEFAULT_MAXIMUM_RESULTS) self.databaseUrl = util.readConfigString(self.pluginConfig, "Update database url", None) else: self.maximumSize = HandwritingPage.DEFAULT_MAXIMUM_FIELD_SIZE self.maximumResults = HandwritingPage.DEFAULT_MAXIMUM_RESULTS if not self.databaseUrl: self.databaseUrl = unicode('sqlite:///' + util.getLocalData('dictionaries.db')) # set up UI self.setupUi(self) # connect to main window self.connect(self.mainWindow, SIGNAL("settingsChanged()"), self.slotSettingsChanged) self.connect(self.mainWindow, SIGNAL("writeSettings()"), self.writeSettings) self.connect(self.renderThread, SIGNAL("jobFinished"), self.contentRendered) self.handwritingView.setMaximumSize(self.maximumSize) # connect to the widgets self.connect(self.handwritingView, SIGNAL("updated()"), self.strokeInputUpdated) self.connect(self.handwritingResultView, SIGNAL("linkClicked(const QUrl &)"), self.handwritingResultClicked) self.handwritingResultView.page().setLinkDelegationPolicy( QWebPage.DelegateAllLinks) # add connections for clearing stroke input self.connect(self.clearButton, SIGNAL("clicked()"), self.handwritingView.clear) self.connect(self.backButton, SIGNAL("clicked()"), self.handwritingView.remove_last_stroke) self.clearButton.setIcon(KIcon('edit-clear')) self.backButton.setIcon(KIcon('edit-undo')) self.language = None self.characterDomain = None self.initialised = False
def loadVocabulary(self): if self.vocabularyChanged == None: csv = csvImporter = CSVImporter(pluginConfig=self.pluginConfig) fileName = util.getLocalData('eclectus.csv') csv.setFilePath(fileName) entries = csv.read() self.vocabularyModel.insertRows(0, len(entries)) for i, entry in enumerate(entries): self.vocabularyModel.setData(self.vocabularyModel.index(i), entry, Qt.DisplayRole) self.vocabularyChanged = False
def writeSettings(self): if self.pluginConfig: if self.vocabularyChanged: csv = CSVExporter(pluginConfig=self.pluginConfig) fileName = util.getLocalData('eclectus.csv') csv.setFilePath(fileName) csv.setEntries(self.vocabularyModel.getVocabulary()) try: csv.write() self.vocabularyChanged = False except Exception, e: print e.encode(locale.getpreferredencoding())
def __init__(self, mainWindow, renderThread, pluginConfig=None): KDialog.__init__(self, mainWindow) self.renderThread = renderThread self.databaseUrl = None if pluginConfig: self.databaseUrl = util.readConfigString(self.pluginConfig, "Update database url", None) if not self.databaseUrl: self.databaseUrl = unicode('sqlite:///' + util.getLocalData('dictionaries.db')) self.renderThread.setObject(DictionaryInfo, databaseUrl=self.databaseUrl) self.setCaption(i18n("Install/Update Dictionaries")) self.setButtons(KDialog.ButtonCode(KDialog.Close)) self.enableButton(KDialog.Cancel, False) # TODO can we defer the creation of the update widget until the dialog is shown? self.updateWidget = UpdateWidget(mainWindow, renderThread, pluginConfig) self.connect(self.updateWidget, SIGNAL("working(bool)"), self.slotUpdateWorking) self.setMainWidget(self.updateWidget) self.connect(self, SIGNAL("finished()"), self.slotFinish) self.initialised = False self.connect(self.renderThread, SIGNAL("jobFinished"), self.contentRendered) self.connect(self.renderThread, SIGNAL("jobErrorneous"), self.renderingFailed) self.actionCollection = KActionCollection(self) self.setupActions()
def __init__(self, mainWindow, renderThread, pluginConfig=None): QWidget.__init__(self, mainWindow) self.mainWindow = mainWindow self.renderThread = renderThread self.pluginConfig = pluginConfig # set up UI self.setupUi(self) self.radicalView.setPage(util.HandyWebpage(self)) self.databaseUrl = None if self.pluginConfig: self.includeAllRadicals = self.pluginConfig.readEntry( "Radical include all", str(False)) != "False" self.databaseUrl = util.readConfigString(self.pluginConfig, "Update database url", None) else: self.includeAllRadicals = True if not self.databaseUrl: self.databaseUrl = unicode('sqlite:///' + util.getLocalData('dictionaries.db')) self.nonKangxiRadicalButton.setChecked(self.includeAllRadicals) self.radicalOptions.setCurrentIndex(0) self.strokeCountRegex = re.compile(r'\s*(\d+)\s*$') self.radicalIndexRegex = re.compile(r'\s*[#RrIi](\d*)\s*$') self.radicalTableViewScroll = 0 self.currentRadicalIndex = None self.currentSelectedEntry = None self.radicalEntryDict = None self.language = None self.characterDomain = None # connect to main window self.connect(self.mainWindow, SIGNAL("settingsChanged()"), self.slotSettingsChanged) self.connect(self.mainWindow, SIGNAL("writeSettings()"), self.writeSettings) self.connect(self.renderThread, SIGNAL("jobFinished"), self.contentRendered) # connect to the radical table widgets self.connect(self.gotoEdit, SIGNAL("textChanged(const QString &)"), self.gotoEditChanged) self.connect(self.gotoEdit, SIGNAL("returnPressed()"), self.lookupSelectedRadical) self.connect(self.gotoEdit, SIGNAL("clearButtonClicked()"), self.gotoEditCleared) self.connect(self.gotoNextButton, SIGNAL("clicked(bool)"), self.gotoNextClicked) self.connect(self.gotoButton, SIGNAL("clicked(bool)"), lambda x: self.lookupSelectedRadical()) # connect to the character table widgets self.connect(self.toRadicalTableButton, SIGNAL("clicked(bool)"), self.showRadicalTable) self.connect(self.nonKangxiRadicalButton, SIGNAL("clicked(bool)"), self.toggleIncludeAllRadicals) self.connect(self.radicalView.page(), SIGNAL("linkClicked(const QUrl &)"), self.radicalClicked) self.gotoNextButton.setEnabled(False) self.gotoButton.setEnabled(False) self.groupRadicalFormsButton.setVisible(False) # TODO implement functionality self.initialised = False
def __init__(self, mainWindow, renderThread, pluginConfig=None): QWidget.__init__(self, mainWindow) self.mainWindow = mainWindow self.renderThread = renderThread self.pluginConfig = pluginConfig # set up UI self.setupUi(self) self.databaseUrl = None if self.pluginConfig: self.includeSimilar = util.readConfigString(self.pluginConfig, "Component include similar", str(True)) != "False" self.includeVariants = util.readConfigString(self.pluginConfig, "Component include variants", str(True)) != "False" self.databaseUrl = util.readConfigString(self.pluginConfig, "Update database url", None) splitterState = util.readConfigString(self.pluginConfig, "Component splitter", "") self.componentSplitter.restoreState(QByteArray.fromBase64( str(splitterState))) else: self.includeSimilar = True self.includeVariants = True if not self.databaseUrl: self.databaseUrl = unicode('sqlite:///' + util.getLocalData('dictionaries.db')) self.includeSimilarButton.setChecked(self.includeSimilar) self.includeVariantsButton.setChecked(self.includeVariants) self.componentViewScroll = 0 self.selectedComponents = [] self.language = None self.characterDomain = None # connect to main window self.connect(self.mainWindow, SIGNAL("settingsChanged()"), self.slotSettingsChanged) self.connect(self.mainWindow, SIGNAL("writeSettings()"), self.writeSettings) self.connect(self.renderThread, SIGNAL("jobFinished"), self.contentRendered) # connect to the widgets self.connect(self.includeVariantsButton, SIGNAL("clicked(bool)"), self.componentIncludeVariants) self.connect(self.includeSimilarButton, SIGNAL("clicked(bool)"), self.componentIncludeSimilar) self.connect(self.componentView, SIGNAL("linkClicked(const QUrl &)"), self.componentClicked) self.connect(self.componentView, SIGNAL("loadFinished(bool)"), self.componentViewLoaded) self.connect(self.componentResultView, SIGNAL("linkClicked(const QUrl &)"), self.componentResultClicked) self.connect(self.componentEdit, SIGNAL("textChanged(const QString &)"), self.componentEditChanged) self.componentView.page().setLinkDelegationPolicy( QWebPage.DelegateAllLinks) self.componentResultView.page().setLinkDelegationPolicy( QWebPage.DelegateAllLinks) self.initialised = False