def onSendClick(self): for provider in self.providerpluginlist: if(provider.getObjectname() == self.ui.providerList.selectedItems()[0].text()): sms = provider if self.ui.smstext.toPlainText() != "": if self.ui.phonenr.text() != "": self.getLogin() try: sms.setConfig(self.config) except Exception: self.onConfigClick() return sms.clearNrs() for nr in re.findall("(\+\d*)", self.ui.phonenr.text()): sms.addNr(nr) sms.setText(self.ui.smstext.toPlainText()) savenr = self.ui.phonenr.text() try: sms.execute() # self.notification.setText(i18n("Wurde erfolgreich an <i>%1</i> geschickt!").arg(savenr )) # self.notification.setTitle("Erfolg!") # self.notification.sendEvent() KMessageBox.information(None, i18n("SMS sendet successfully to " + savenr + ". Service: "+sms.getProvidername()), i18n("Success!")) except Exception, error: KMessageBox.error(None, i18n(error.message), i18n("Sendproblems")) self.ui.phonenr.clear() self.ui.smstext.clear() else: KMessageBox.error(None, i18n("Please fill in a phonenr"), i18n("Please fill in a phonenr"))
def pkgChanges(self, mode): if mode == "install": items = self.ui.listViewLanguagesInst.selectedItems() else: items = self.ui.listViewLanguagesUninst.selectedItems() if len(items) == 1: elm = items[0] li = self._localeinfo.listviewStrToLangInfoMap[unicode(elm.text())] langPkg = li.languagePkgList["languagePack"] if langPkg.available: if (mode == "install") and (not langPkg.installed): langPkg.doChange = self.ui.checkBoxTr.isChecked() elif (mode == "uninstall") and langPkg.installed: langPkg.doChange = True try: self._cache.tryChangeDetails(li) for langPkg in li.languagePkgList.values(): langPkg.doChange = False except ExceptionPkgCacheBroken: s = _("Software database is broken") t = _("It is impossible to install or remove any software. " "Please use the package manager \"Adept\" or run " "\"sudo apt-get install -f\" in a terminal to fix " "this issue at first.") KMessageBox.error(self, t, s) sys.exit(1) (to_inst, to_rm) = self._cache.getChangesList() if len(to_inst) == len(to_rm) == 0: return # first install self.setCursor(Qt.WaitCursor) self.setEnabled(False) self.run_pkg_manager(to_inst,to_rm) self.setCursor(Qt.ArrowCursor) self.setEnabled(True) # kdmscript = "/etc/init.d/kdm" # if os.path.exists("/var/run/kdm.pid") and os.path.exists(kdmscript): # subprocess.call(["invoke-rc.d","kdm","reload"]) #self.run_pkg_manager(to_inst, to_rm) if self.returncode == 0: if (mode == "install"): KMessageBox.information( self, _("All selected components have now been installed for %s. Select them from Country/Region & Language.") % unicode(items[0].text()), _("Language Installed") ) elif (mode == "uninstall"): KMessageBox.information( self, _("Translations and support have now been uninstalled for %s.") % unicode(items[0].text()), _("Language Uninstalled") ) # Resync the cache to match packageManager changes, then update views self._cache.open(None) self.updateLanguagesList() self.updateSystemDefaultListbox() if mode == "install": self.checkInstallableComponents() else: KMessageBox.sorry(self, _("Failed to set system language."), _("Language Not Set")) self._cache.clear() # undo all selections
def finished(self, *args): '''Install completed''' text = _('Installation is complete. You may now reboot your computer with this USB thumb drive inserted to boot Ubuntu.') self.__backend.cleanup() self.progress_bar.hide() KMessageBox.information(self.__mainWindow,text) sys.exit(0)
def show_script_error(self): """ Show the last script error (if any) """ if self.service.scriptRunner.error != '': KMessageBox.information(None, self.service.scriptRunner.error, i18n("View Script Error Details")) self.service.scriptRunner.error = '' else: KMessageBox.information(None, i18n("No error information available"), i18n("View Script Error Details"))
def deleteBackup(self): global backupInstance boxresult = KMessageBox.questionYesNo(None, "Really delete backup '" + self.backupList.currentText() + "'?") if boxresult == KMessageBox.Yes: resulttype, result = backupInstance.deleteBackup( str(self.backupList.currentText()) ) if result != "ERROR": KMessageBox.information(None, self.backupList.currentText() + ' deleted.') self.backupList.removeItem(self.backupList.currentIndex()) else: KMessageBox.error(None, result[0]['message'])
def success(self): '''Install completed''' self.__backend.unmount() self.progress_bar.hide() text = _('The installation is complete. You may now reboot your ' 'computer with this device inserted to try or install ' 'Ubuntu.') KMessageBox.information(self.__mainWindow, text) sys.exit(0)
def addBackup(self): global backupInstance, config text, result = QtGui.QInputDialog.getText(self, 'Add Backup', 'Backup Name:') if result: resulttype, result = backupInstance.addBackup( str(text), config.workstation_id, config.workstation_name ) if resulttype != "ERROR": KMessageBox.information(None, text + ' added.') self.backupList.addItem(text) else: messagetext = result[0]['message'] if messagetext == "": messagetext = result[0]['label'] KMessageBox.error(None, messagetext)
def installOkularPartRC(self): import frescobaldi_app.install frescobaldi_app.install.installOkularPartRC() config("").writeEntry("configure okularpart", True) KMessageBox.information( self, i18n( "The Okular PDF preview has been reconfigured.\n\n" "If you already opened the PDF preview, " "restart Frescobaldi for the new settings to take effect." ), )
def changeLanguage(self, lang): """ Change the LilyPond pitch name language in our document to lang. This is a bit hairy because LilyPond has a new syntax for this since 2.14, \language "name", while the old \include "name.ly" still is supported as well. """ newSyntax = (self.doc.lilyPondVersion() or lilyPondVersion()) >= (2, 13, 38) text, start = self.doc.selectionOrDocument() try: changes, includeCommandChanged = ly.tools.translate(text, lang, start) except ly.QuarterToneAlterationNotAvailable: KMessageBox.sorry( self.doc.app.mainwin, i18n( "Can't perform the requested translation.\n\n" "The music contains quarter-tone alterations, but " 'those are not available in the pitch language "%1".', lang, ), ) return # Apply the changes. with self.doc.editContext(): changes.applyToCursor(EditCursor(self.doc.doc)) if not start and not includeCommandChanged: if newSyntax: self.addLineToTop('\\language "{0}"'.format(lang)) else: self.addLineToTop('\\include "{0}.ly"'.format(lang)) if start and not includeCommandChanged: KMessageBox.information( self.doc.app.mainwin, "<p>{0}</p>" '<p><tt>\\include "{1}.ly"</tt> {2}</p>' '<p><tt>\\language "{1}"</tt> {3}</p>'.format( i18n( "The pitch language of the selected text has been " "updated, but you need to manually add the following " "command to your document:" ), lang, i18n("(for LilyPond below 2.14), or"), i18n("(for LilyPond 2.14 and higher.)"), ), i18n("Pitch Name Language"), )
def __kdeInformation(parent, title, text, buttons = QMessageBox.Ok, defaultButton = QMessageBox.NoButton): """ Function to show a modal information message box. @param parent parent widget of the message box @param title caption of the message box @param text text to be shown by the message box @param buttons flags indicating which buttons to show (QMessageBox.StandardButtons) @param defaultButton flag indicating the default button (QMessageBox.StandardButton) @return button pressed by the user (QMessageBox.StandardButton, always QMessageBox.NoButton) """ KMessageBox.information(parent, text, title) return QMessageBox.NoButton
def __init__(self, args): self.getLogin() self.providerPluginManager = PluginManager("providerplugins","providerplugins", providerplugins.Provider.Provider) aboutData = KAboutData ( "Wrapper", "blubb", ki18n("Wrapper for kontact"), "sdaf", ki18n("Displays a KMessageBox popup"), KAboutData.License_GPL, ki18n("(c) 2010"), ki18n("This is a wrapper for kontact to access the multimobileservice"), "http://puzzle.ch", "*****@*****.**" ) KCmdLineArgs.init(sys.argv, aboutData) cmdoptions = KCmdLineOptions() cmdoptions.add("nr <speed>", ki18n("The phone nr")) cmdoptions.add("smsfile <file>", ki18n("The smsfile")) cmdoptions.add("smstext <text>", ki18n("The smstext")) cmdoptions.add("plugin <string>", ki18n("The pluginname")) KCmdLineArgs.addCmdLineOptions(cmdoptions) app = KApplication() lineargs = KCmdLineArgs.parsedArgs() plugin = self.getRightPlugin(lineargs.getOption("plugin")) plugin.addNr(lineargs.getOption("nr")) if lineargs.getOption("smsfile") != "": plugin.setText(self.file2String(lineargs.getOption("smsfile"))) elif lineargs.getOption("smstext") != "": plugin.setText(lineargs.getOption("smstext")) else: KMessageBox.error(None, i18n("No text defined.."), i18n("Text undefined")) raise RuntimeError("No text defined!") plugin.setConfig(self.config) try: plugin.execute() KMessageBox.information(None, i18n("Your SMS was sendet successfull to "+lineargs.getOption("nr")+" with Plugin "+plugin.getObjectname()), i18n("Success")) except Exception, e: KMessageBox.error(None, i18n(e), i18n("Error"))
def convertLy(mainwin): """ Run the current document through convert-ly. """ doc = mainwin.currentDocument() text = doc.text() docVersion = ly.version.getVersion(text) lilyVersion = ly.version.LilyPondInstance(lilyPondCommand()).version() if not docVersion: KMessageBox.sorry(mainwin, i18n( "Can't determine the LilyPond version of the current document." " Please add a \\version statement with the correct version.")) elif not lilyVersion: KMessageBox.sorry(mainwin, i18n( "Can't determine the version of LilyPond. " "Please check your LilyPond installation.")) elif docVersion >= lilyVersion: KMessageBox.information(mainwin, i18n( "This LilyPond document is already up-to-date.")) else: # Ok, let's run convert-ly. # We add the from-version. Only in that case convert-ly wants to # read from stdin. try: out, err = Popen( (convertLyCommand(), "-f", str(docVersion), "-"), stdin=PIPE, stdout=PIPE, stderr=PIPE ).communicate(text.encode('utf8')) if out: doc.setText("{0}\n\n%{{\n{1}\n%}}\n".format(out.decode('utf8'), err.decode('utf8'))) KMessageBox.information(mainwin, i18n( "The document has been processed with convert-ly. You'll find " "the messages of convert-ly in a comment block at the end. " "You still may have to edit some parts manually.")) else: msg = "<br><br>" + err.decode('utf8').replace('\n', '<br>') KMessageBox.information(mainwin, i18n( "The document has been processed with convert-ly, but " "remained unchanged. This is the message given by " "convert-ly: %1", msg)) except OSError as e: msg = unicode(e) KMessageBox.error(mainwin, i18n("Could not start convert-ly: %1", msg))
def onSystemLanguageApply(self): (lang, code) = self.getSystemLanguage() self.writeSysLanguageSetting(code) self.writeSysLangSetting(code) self.updateInputMethods(code) KMessageBox.information(self, _("Default system Language now set to %s.") % lang, _("Language Set"))
ui = self.ui connectionName = unicode(ui.lineProfileName.text()) connections = self.iface.connections(self.lastEditedPackage) if (self.isEditBox) or (not connectionName in connections): try: self.iface.updateConnection(self.lastEditedPackage, connectionName, self.collectDataFromUI()) except Exception, e: KMessageBox.error(self.baseWidget, unicode(e)) ui.lineProfileName.setFocus() return else: KMessageBox.information( self.baseWidget, i18n("There is already a profile named '%1'.", connectionName)) return if self.lastEditedData: # Profile name has been changed, delete old profile if not self.lastEditedData["name"] == connectionName: self.iface.deleteConnection(self.lastEditedPackage, self.lastEditedData["name"]) # Profile state was up if self.lastEditedData.has_key("state"): if self.lastEditedData["state"].startswith("up"): self.iface.connect(self.lastEditedPackage, connectionName) self.hideEditBox() def collectDataFromUI(self):
def msg(self, msg): KMessageBox.information(self.parent(), msg, "Kpgpruleshelper")
self.lastEditedInfo = None def applyChanges(self): ui = self.ui connectionName = unicode(ui.lineProfileName.text()) connections = self.iface.connections(self.lastEditedPackage) if (self.isEditBox) or (not connectionName in connections): try: self.iface.updateConnection(self.lastEditedPackage, connectionName, self.collectDataFromUI()) except Exception, e: KMessageBox.error(self.baseWidget, unicode(e)) ui.lineProfileName.setFocus() return else: KMessageBox.information(self.baseWidget, i18n("There is already a profile named '%1'.", connectionName)) return if self.lastEditedData: # Profile name has been changed, delete old profile if not self.lastEditedData["name"] == connectionName: self.iface.deleteConnection(self.lastEditedPackage, self.lastEditedData["name"]) # Profile state was up if self.lastEditedData.has_key("state"): if self.lastEditedData["state"].startswith("up"): self.iface.connect(self.lastEditedPackage, connectionName) self.hideEditBox() def collectDataFromUI(self): ui = self.ui data = {}