def contentRendered(self, id, classObject, method, args, param, content): if classObject == CharacterDB: if method == 'filterDomainCharacters': chars = content # render page if chars: charLinks = [] for char in chars: charLinks.append( '<a class="character" href="#lookup(%s)">%s</a>' \ % (encodeBase64(char), char)) html = '<span class="character">%s</span>' \ % ' '.join(charLinks) else: html = '<span class="meta">%s</span>' % unicode( i18n('No results for the selected character domain')) self.handwritingResultView.setHtml( '<html><head><title>Results</title>' \ + '<link rel="StyleSheet" href="%s" type="text/css" />' \ % ('file://' + util.getData('style.css')) + '</head>' \ + '<body>%s</body>' % html \ + '</html>')
def doJob(self, id, method, content): if method == 'getComponentSearchTable': self.componentView.setHtml('<html><head><title>Components</title>' \ + '<link rel="StyleSheet" href="file://%s" type="text/css" />' \ % util.getData('style.css') + '</head>' \ + '<body>%s</body>' % content \ + '</html>') elif method == 'getComponentSearchResult': htmlCode, count = content self.componentResultView.setHtml( '<html><head><title>Results</title>' \ + '<link rel="StyleSheet" href="file://%s" type="text/css" />' \ % util.getData('style.css') + '</head>' \ + '<body>%s</body>' % htmlCode \ + '</html>') self.componentResultLabel.setText(i18n("%1 Results:", count))
def contentRendered(self, id, classObject, method, args, param, content): if classObject == RadicalView and method == 'getRadicalTable': htmlCode, self.radicalEntryDict = content self.radicalView.setHtml('<html><head><title>Radicals</title>' \ + '<link rel="StyleSheet" href="file://%s" type="text/css" />' \ % util.getData('style.css') + '</head>' \ + '<body>%s</body>' % htmlCode \ + '</html>') self.radicalView.page().mainFrame().evaluateJavaScript( self.CLICKABLE_ROW_JAVASCRIPT) elif classObject == RadicalView \ and method == 'getCharacterForRadical': self.radicalView.setHtml('<html><head><title>Results</title>' \ + '<link rel="StyleSheet" href="file://%s" type="text/css" />' \ % util.getData('style.css') + '</head>' \ + '<body>%s</body>' % content \ + '</html>')
def run(): appName = "eclectus" catalog = "eclectusqt" programName = ki18n("Eclectus") version = eclectusqt.__version__ description = ki18n("Han character dictionary") license = KAboutData.License_GPL_V3 copyright = ki18n("(c) 2008-2009 Christoph Burgmer") text = ki18n( "Eclectus is a small Han character dictionary for learners.") homePage = eclectusqt.__url__ bugEmail = "*****@*****.**" bugAddress = "http://code.google.com/p/eclectus/issues/list" aboutData = KAboutData(appName, catalog, programName, version, description, license, copyright, text, homePage, bugEmail) aboutData.addAuthor(ki18n("Christoph Burgmer"), ki18n("Developer"), "*****@*****.**", "http://cburgmer.nfshost.com/") aboutData.setCustomAuthorText(ki18n("Please use %1 to report bugs.")\ .subs(bugAddress), ki18n('Please use %1 to report bugs.')\ .subs('<a href="%s">%s</a>' % (bugAddress, bugAddress))) aboutData.addCredit(KLocalizedString(), ki18n("Arrr, Eclectus sits on the shoulders of some fine pirates:")) aboutData.addCredit(ki18n("Jim Breen and contributors"), ki18n("EDICT"), '', 'http://www.csse.monash.edu.au/~jwb/j_edict.html') aboutData.addCredit(ki18n("Paul Denisowski and current contributors"), ki18n("CEDICT"), '', 'http://www.mdbg.net/chindict/chindict.php') aboutData.addCredit(ki18n("HanDeDict team"), ki18n("HanDeDict"), '', 'http://www.chinaboard.de/chinesisch_deutsch.php') aboutData.addCredit(ki18n("Tomoe developers"), ki18n("Tomoe handwriting recognition"), '*****@*****.**', 'http://tomoe.sourceforge.jp') aboutData.addCredit(ki18n("Mathieu Blondel and the Tegaki contributors"), ki18n("Tegaki handwriting recognition"), u'mathieu ÂT mblondel DÔT org'.encode('utf8'), 'http://tegaki.sourceforge.net') aboutData.addCredit(ki18n("Unicode Consortium and contributors"), ki18n("Unihan database"), '', 'http://unicode.org/charts/unihan.html') aboutData.addCredit(ki18n("Commons Stroke Order Project"), ki18n("Stroke order pictures"), '', 'http://commons.wikimedia.org/wiki/Commons:Stroke_Order_Project') aboutData.addCredit(ki18n("Tim Eyre, Ulrich Apel and the Wadoku Project"), ki18n("Kanji stroke order font"), '', 'http://sites.google.com/site/nihilistorguk/') aboutData.addCredit( ki18n("Yue Tan, Wei Gao, Vion Nicolas and the Shtooka Project"), ki18n("Pronunciation examples for Mandarin"), '', 'http://shtooka.net') # find logo file, don't directly use util.getData(), KApplication not # created yet aboutLogoFile = u'/usr/share/kde4/apps/eclectus/eclectus_about.png' if not os.path.exists(aboutLogoFile): modulePath = os.path.dirname(os.path.abspath(__file__)) aboutLogoFile = os.path.join(modulePath, 'data', 'eclectus_about.png') if not os.path.exists(aboutLogoFile): aboutLogoFile = util.getData('eclectus_about.png') if aboutLogoFile: aboutData.setProgramLogo(QVariant(QImage(aboutLogoFile))) KCmdLineArgs.init(sys.argv, aboutData) # create applicaton global g_app g_app = KApplication() # TODO how to access local .mo file? #base = os.path.dirname(os.path.abspath(__file__)) #localeDir = os.path.join(base, "locale") #print localeDir #if os.path.exists(localeDir): #print KGlobal.dirs().addResourceDir('locale', localeDir + '/', True) #print KGlobal.dirs().findResource('locale', 'de/LC_MESSAGES/eclectusqt.mo') # read config file and make global global GeneralConfig global DictionaryConfig global PluginConfig config = KConfig() GeneralConfig = KConfigGroup(config, "General") DictionaryConfig = KConfigGroup(config, "Dictionary") PluginConfig = KConfigGroup(config, "Plugin") # create main window MainWindow().show() # react to CTRL+C on the command line signal.signal(signal.SIGINT, signal.SIG_DFL) g_app.exec_()