def selectionChanged(self): current = self.listView.currentItem() win = None if hasattr(current, 'suite'): print 'suite is', current.suite if not self._suites: KMessageBox.information(self, "No suites are present.") else: win = TraitMainWindow(self, current.suite) elif hasattr(current, 'profiles'): win = ProfileMainWindow(self) elif hasattr(current, 'families'): self.slotManageFamilies() elif hasattr(current, 'machines'): win = MachineMainWindow(self) elif hasattr(current, 'dtype'): print 'differ', current.dtype win = DifferWindow(self, current.dtype) elif hasattr(current, 'etype'): win = EnvironmentWindow(self, current.etype) elif hasattr(current, 'installer'): #win = InstallerMainWin(self) KMessageBox.information(self, 'Not Implemented') elif hasattr(current, 'clients'): win = ClientsMainWindow(self) elif hasattr(current, 'folder'): # nothing important selected, do nothing pass else: KMessageBox.error(self, 'something bad happened in the list selection') if win is not None: win.show() self._all_my_children.append(win)
def add_weblink_entries(self, site='', url=''): #we start at row #5 column 1 for lbl column 2 for entry num_entries = len(self.weblink_url_entries) # we need to add 1 on lbl_num because the entries can be appended # until instantiated lbl_num = num_entries + 1 site_lbl = QLabel('<b>site %d</b>' % lbl_num, self) site_entry = KLineEdit(site, self) self.weblink_site_entries.append(site_entry) url_lbl = QLabel('<b>url %d</b>' % lbl_num, self) url_entry = KLineEdit(url, self) self.weblink_url_entries.append(url_entry) if len(self.weblink_site_entries) != len(self.weblink_url_entries): KMessageBox.error(self, 'entries mismatch, something really bad happened.') import sys sys.exit(1) # we need a little math here to figure out the rows # for the widgets # num_entries should now be 1 greater than above num_entries = len(self.weblink_url_entries) site_row = 2*num_entries + 3 url_row = 2*num_entries + 4 # add weblink widgets to the grid top = self.grid.AlignTop self.grid.addWidget(site_entry, site_row, 1) self.grid.addWidget(site_lbl, site_row, 2) self.grid.addWidget(url_entry, url_row, 1) self.grid.addWidget(url_lbl, url_row, 2) # we have to call .show() explicitly on the widgets # as the rest of the widgets are already visible # when show was called on the dialog # show() automatically calls show() on all children for widget in [site_lbl, site_entry, url_lbl, url_entry]: widget.show()
def selectGame(self, name, called_externally=True): if called_externally: # if this method is called from dcop, name will be # a QString, so we make it python string name = str(name) if name not in self.game_names: KMessageBox.error(self, '%s is not a valid game name.' % name) else: if self.name_title_view is 'name': # this is the easy part # the 0 in the second arg means column item = self.listView.findItem(name, 0) else: # we're using titles, so we have to get it title = self.game_titles[name] item = self.listView.findItem(title, 0) # here True means select, False means unselect self.listView.setSelected(item, True) # calling setSelected will emit the selection changed signal # which will result in this method being called again, although # internally this time. self._make_listitem_visible(item) else: # we only change the textView for internal calls self.textView.set_game_info(name)
def setSource(self, url): action, context, ident = split_url(url) if action == 'show': print 'unimpletmented' elif action == 'edit': if context == 'traits': win = TraitAssigner(self.parent(), ident) self.connect(win, SIGNAL('okClicked()'), self.resetView) win.show() elif context == 'variables': self.doc.profile.edit_variables() self.resetView() elif context == 'families': win = FamilyAssigner(self.parent(), ident) self.connect(win, SIGNAL('okClicked()'), self.resetView) win.show() else: KMessageBox.error(self, 'bad edit action %s' % url) elif action == 'change': if context == 'suite': self.emit(PYSIGNAL('changeSuite'), (ident,)) print 'changeSuite emitted' else: KMessageBox.error(self, 'bad change action %s' % url) else: KMessageBox.information(self, 'called %s' % url)
def monitor(self, fileName): """Start monitoring a file.""" try: tailer = Tail(fileName) except: KMessageBox.error(self, str(i18n("Cannot open file for monitoring:\n%s")) % fileName, makeCaption("Error")) return mon = Monitor(self.tab, tailer) base = os.path.basename(fileName) self.monitors.append(mon) self.tab.addTab(mon, base) self.tab.showPage(mon) self.tab.setTabToolTip(mon, fileName) self.currentPage = mon self.setCaption(makeCaption(base)) self.displayStatus(False, str(i18n("Monitoring %s")) % fileName) self.connect(self.timer, SIGNAL("timeout()"), mon.follow) self.saveFileList() self.connect(mon, SIGNAL("copyAvailable(bool)"), self.onCopyAvailable) self.closeAction.setEnabled(True) self.copyAction.setEnabled(False) self.clearAction.setEnabled(True) self.selectAllAction.setEnabled(True) self.addBookmarkAction.setEnabled(True) self.findAction.setEnabled(True) self.findNextAction.setEnabled(True) self.findPrevAction.setEnabled(True)
def setupBusses(self): try: self.sysBus = dbus.SystemBus() self.sesBus = dbus.SessionBus() except dbus.DBusException: KMessageBox.error(None, i18n("Unable to connect to DBus."), i18n("DBus Error")) return False return True
def setSource(self, url): action, context, ident = split_url(url) if action == 'edit': config = self.family.getVariablesConfig(self.family.current) newconfig = config.edit() config.update(newconfig) self.set_family(ident) else: KMessageBox.error(self, 'action %s unimpletmented' % url)
def slotOkClicked(self): value = str(self.attributeEntry.text()) try: self.handler.set_attribute(self.attribute, value) except OperationalError, inst: if 'violates foreign key constraint' in inst.message: KMessageBox.error(self, '%s is not a valid %s' % (value, self.attribute)) else: raise OperationalError(inst)
def monitor(self, fileName): try: tailer = Tail(fileName) except: KMessageBox.error(self, str(i18n("Cannot open file for monitoring:\n%s")) % fileName, i18n("Error - lovi")) return self.tab.addTab(Monitor(tailer), os.path.basename(fileName))
def _perform_edit_action(self, context, ident): if context == "Variables": self.doc.mtype.edit_variables() elif context == "Scripts": self.doc.mtype.edit_script(ident) elif context == "machine_type": KMessageBox.information(self, "Editing of machine types is unimplemented") else: msg = "edit context %s id %s is unsupported" % (context, ident) KMessageBox.error(self, msg)
def comarError(self, exception): if "urlopen error" in exception.message or "Socket Error" in exception.message: KMessageBox.error(None, i18n("Network error. Please check your network connections and try again."), i18n("COMAR Error")) elif "Access denied" in exception.message: message = i18n("You are not authorized for this operation.") KMessageBox.sorry(None, message, i18n("Error")) else: KMessageBox.error(None, QString.fromUtf8(str(exception)), i18n("COMAR Error")) self.errHandler()
def _perform_edit_action(self, context, ident): if context == 'Variables': self.doc.mtype.edit_variables() elif context == 'Scripts': self.doc.mtype.edit_script(ident) elif context == 'machine_type': KMessageBox.information(self, 'Editing of machine types is unimplemented') else: msg = 'edit context %s id %s is unsupported' % (context, ident) KMessageBox.error(self, msg)
def monitor(self, fileName): try: tailer = Tail(fileName) except: KMessageBox.error( self, str(i18n("Cannot open file for monitoring:\n%s")) % fileName, i18n("Error - lovi")) return self.tab.addTab(Monitor(tailer), os.path.basename(fileName))
def _launchdosbox_common(self, game, launch_game=True): if game is None: game = self.listView.currentItem().game if self.app.game_fileshandler.get_game_status(game): if launch_game: self.app.dosbox.run_game(game) else: self.app.dosbox.launch_dosbox_prompt(game) else: title = self.game_titles[game] KMessageBox.error(self, '%s is unavailable' % title)
def slotNewGame(self): if self.new_game_dir_dialog is None: main_dosbox_path = self.myconfig.get('dosbox', 'main_dosbox_path') dlg = KDirSelectDialog(main_dosbox_path, 0, self) dlg.connect(dlg, SIGNAL('okClicked()'), self.new_game_path_selected) dlg.connect(dlg, SIGNAL('cancelClicked()'), self.destroy_new_game_dir_dlg) dlg.connect(dlg, SIGNAL('closeClicked()'), self.destroy_new_game_dir_dlg) dlg.show() self.new_game_dir_dialog = dlg else: KMessageBox.error(self, opendlg_errormsg)
def _select_import_export_directory(self, action): if self._import_export_dirsel_dialog is None: default_db_path = path(self.app.cfg.get('database', 'default_path')).expand() win = KDirSelectDialog(default_db_path, False , self) win.connect(win, SIGNAL('okClicked()'), self._import_export_directory_selected) self._connect_destroy_dialog(win) win.db_action = action win.show() self._import_export_dirsel_dialog = win else: KMessageBox.error(self, 'This dialog is already open, or bug in code.')
def select_launch_command(self): if self.select_launch_command_dlg is None: file_filter = "*.exe *.bat *.com|Dos Executables\n*|All Files" dlg = KFileDialog(self.fullpath, file_filter, self, 'select_launch_command_dlg', True) dlg.connect(dlg, SIGNAL('okClicked()'), self.launch_command_selected) dlg.connect(dlg, SIGNAL('cancelClicked()'), self.destroy_select_launch_command_dlg) dlg.connect(dlg, SIGNAL('closeClicked()'), self.destroy_select_launch_command_dlg) dlg.show() self.select_launch_command_dlg = dlg else: # we shouldn't need this with a modal dialog KMessageBox.error(self, opendlg_errormsg)
def _import_export_directory_selected(self): win = self._import_export_dirsel_dialog if win is None: raise RuntimeError , "There is no import/export dialog" url = win.url() fullpath = str(url.path()) action = win.db_action if action == 'import': KMessageBox.information(self, "%s trait not implemented yet" % action) elif action == 'export': KMessageBox.information(self, "%s trait not implemented yet" % action) else: KMessageBox.error(self, "action %s is not supported" % action)
def _select_import_export_directory(self, action): if self._import_export_dirsel_dialog is None: default_db_path = path(self.app.cfg.get('database', 'default_path')).expand() win = KDirSelectDialog(default_db_path, False, self) win.connect(win, SIGNAL('okClicked()'), self._import_export_directory_selected) self._connect_destroy_dialog(win) win.db_action = action win.show() self._import_export_dirsel_dialog = win else: KMessageBox.error(self, 'This dialog is already open, or bug in code.')
def exceptionHandler(self, exception=None): exception = exception or self.lastError if "urlopen error" in str(exception) or "Socket Error" in str(exception): KMessageBox.error(None, i18n("Network error. Please check your network connections and try again or check your repository addresses."), i18n("COMAR Error")) elif "Access denied" in str(exception): message = i18n("You are not authorized for this operation.") KMessageBox.sorry(None, message, i18n("Error")) elif "PYCURL ERROR" in str(exception): message = i18n("Please check your network connection or repository addresses.") KMessageBox.sorry(None, message, i18n("Error")) else: KMessageBox.error(None, QString.fromUtf8(str(exception)), i18n("COMAR Error")) self.errHandler()
def _import_export_directory_selected(self): win = self._import_export_dirsel_dialog if win is None: raise RuntimeError, "There is no import/export dialog" url = win.url() fullpath = str(url.path()) action = win.db_action if action == 'import': KMessageBox.information(self, "%s trait not implemented yet" % action) elif action == 'export': KMessageBox.information(self, "%s trait not implemented yet" % action) else: KMessageBox.error(self, "action %s is not supported" % action)
def create_trouble(self): dlg = self.dialogs['new-trouble'] title = str(dlg.titleEdit.text()) data = str(dlg.dataEdit.text()) if data and title: self.manager.create_ticket(title, data) self.refreshlistView() elif title: KMessageBox.error(self, "just a title won't do.") self.slotNew(title=title) elif data: KMessageBox.error(self, "You also need a title.") self.slotNew(data=data) else: KMessageBox.information(self, 'Nothing Done.')
def _perform_url_action(self, url): parsed = myurl.parse(str(url)) print parsed action, atype, ident = parsed if ident.isdigit(): ident = int(ident) if ident != self.current_entity.entityid: msg = "ident != current_entity.entityid, %d, %d" \ % (ident, self.current_entity.entityid) raise RuntimeError, msg if action == 'edit': dlg = MainEntityDialog(self.dialog_parent, dtype='update', entity=self.current_entity) dlg.show() elif action == 'delete': print 'delete selected' elif action == 'addtag': dlg = AddTagsDialog(self.dialog_parent, self.current_entity) dlg.show() elif action == 'deltag': dlg = RemoveTagsDialog(self.dialog_parent, self.current_entity) dlg.show() elif action == 'play': print "play", ident kaffeine = Kaffeine() entity = self.current_entity filename = str(entity.extfields['local-filename'].value) filehandler = self.app.filehandler dpath = filehandler.main_path / 'downloads' fullpath = dpath / filename url = 'file://%s' % fullpath kaffeine.openURL(url) elif action == 'download': print "download", ident entity = self.current_entity #print "entity url", entity.url if entity.url is None: url = "http://youtube.com/watch?v=%s" % entity.extfields['youtubeid'].value else: url = entity.url url = Url(url) print "url is", url self.app.urlhandler.handle_youtube_url(url) else: KMessageBox.error(self.dialog_parent, 'Unknown action: %s' % action)
def select_title_screenshot(self, name): #raise StandardError, 'select_title_screenshot has a few problems.' if self.select_title_screenshot_dlg is None: file_filter = "*.png|PNG Images\n*|All Files" path = self.app.dosbox.get_capture_path(name) dlg = KFileDialog(path, file_filter, self.dialog_parent, 'select_title_screenshot_dlg', True) dlg.connect(dlg, SIGNAL('okClicked()'), self.title_screenshot_selected) dlg.connect(dlg, SIGNAL('cancelClicked()'), self.destroy_select_title_screenshot_dlg) dlg.connect(dlg, SIGNAL('closeClicked()'), self.destroy_select_title_screenshot_dlg) dlg.game_name = name dlg.show() self.select_title_screenshot_dlg = dlg else: # we shouldn't need this with a modal dialog KMessageBox.error(self.dialog_parent, opendlg_errormsg)
def setSource(self, url): action, context, id = str(url).split('.') if context == 'contact': if action == 'new': dlg = ContactDialog(self, self.db) dlg.connect(dlg, SIGNAL('okClicked()'), self.insertContact) dlg.clientid = self.doc.current self.dialogs['new-contact'] = dlg elif context == 'location': if action == 'new': dlg = LocationDialog(self, self.db) dlg.connect(dlg, SIGNAL('okClicked()'), self.insertLocation) dlg.clientid = self.doc.current self.dialogs['new-location'] = dlg else: KMessageBox.error(self, 'bad call %s' % url)
def insertNewRecord(self): dialog = self._dialog context = dialog.context data = dialog.getRecordData() if context == "Disks": self.doc.mtype.add_disk(data["diskname"], data["device"]) elif context == "Families": self.doc.mtype.append_family(data["family"]) elif context == "Variables": self.doc.mtype.append_variable(data["trait"], data["name"], data["value"]) elif context == "machine_type": self.doc.mtype.add_new_type(data["name"]) else: KMessageBox.error(self, "Error handling context %s" % context) self._dialog = None self.resetView()
def insertNewRecord(self): dialog = self._dialog context = dialog.context data = dialog.getRecordData() if context == 'Disks': self.doc.mtype.add_disk(data['diskname'], data['device']) elif context == 'Families': self.doc.mtype.append_family(data['family']) elif context == 'Variables': self.doc.mtype.append_variable(data['trait'], data['name'], data['value']) elif context == 'machine_type': self.doc.mtype.add_new_type(data['name']) else: KMessageBox.error(self, 'Error handling context %s' % context) self._dialog = None self.resetView()
def setSource(self, url): action, context, ident = split_url(url) if action == 'new': handler = self.doc.diskconfig dialog = NewDiskConfigDialog(self, handler) dialog.show() dialog.connect(dialog, SIGNAL('okClicked()'), self.parent().resetView) self._dialog = dialog elif action == 'edit': self.doc.diskconfig.edit_diskconfig(ident) self.parent().resetView() elif action == 'delete': self.doc.diskconfig.delete(ident) self.parent().resetView() else: msg = "unsupported action: %s" % action KMessageBox.error(self, msg)
def setSource(self, url): action, context, ident = split_url(url) if action == 'new': if context == 'machine': handler = self.doc.machine dialog = NewMachineDialog(self, handler) dialog.show() self._dialog = dialog else: KMessageBox.error(self, '%s not supported' % url) elif action == 'edit': if context == 'machine': handler = self.doc.machine dialog = EditMachineDIalog(self, handler, ident) dialog.show() self._dialog = dialog print 'edit machine', dialog.machine else: KMessageBox.error(self, '%s not supported' % url)
def setSource(self, url): action, context, ident = split_url(url) if action == "new": if context == "machine": handler = self.doc.machine dialog = NewMachineDialog(self, handler) dialog.show() self._dialog = dialog else: KMessageBox.error(self, "%s not supported" % url) elif action == "edit": if context == "machine": handler = self.doc.machine dialog = EditMachineDIalog(self, handler, ident) dialog.show() self._dialog = dialog print "edit machine", dialog.machine else: KMessageBox.error(self, "%s not supported" % url)
def _perform_delete_action(self, context, ident): if context == 'Families': self.doc.mtype.delete_family(ident) self.resetView() elif context == 'Variables': self.doc.mtype.edit_variables() elif context == 'Scripts': ans = KMessageBox.questionYesNo(self, "really delete this script?") if ans == KMessageBox.Yes: self.doc.mtype.delete_script(ident) elif context == 'Modules': msg = 'Deleting modules is not supported.' KMessageBox.information(self, msg) elif context == 'machine_type': msg = "Can't delete machine types yet." KMessageBox.information(self, msg) else: msg = 'Problem with delete - context %s id %s' % (context, ident) KMessageBox.error(self, msg)
def _perform_delete_action(self, context, ident): if context == "Families": self.doc.mtype.delete_family(ident) self.resetView() elif context == "Variables": self.doc.mtype.edit_variables() elif context == "Scripts": ans = KMessageBox.questionYesNo(self, "really delete this script?") if ans == KMessageBox.Yes: self.doc.mtype.delete_script(ident) elif context == "Modules": msg = "Deleting modules is not supported." KMessageBox.information(self, msg) elif context == "machine_type": msg = "Can't delete machine types yet." KMessageBox.information(self, msg) else: msg = "Problem with delete - context %s id %s" % (context, ident) KMessageBox.error(self, msg)
def add_new_game(self): dlg = self.add_new_game_dlg gamedata = dlg.get_gamedata_from_entries() name = gamedata['name'] fullpath = dlg.fullpath dlg.close() ### ugly section -- testing now -- cleanup later self.app.processEvents() filehandler = self.app.game_fileshandler filehandler._report_add_to_installed_archive = self._report_add_to_installed_archive self._add_to_installed_archive_progress = BaseProgressDialog(self) dlg = self._add_to_installed_archive_progress dlg.resize(400, 200) dlg.total = None dlg.show() ##### end of ugly section try: self.add_new_game_common(gamedata, fullpath) except ExistsError, inst: print 'here we are', inst KMessageBox.error(self, '%s already exists' % inst.args)
def setSource(self, url): action, context, ident = split_url(url) fields = [] dialog_message = 'We need a message here' if context == 'Disks': fields = ['diskname', 'device'] dialog_message = 'Add a new disk.' elif context == 'Families': fields = ['family'] dialog_message = 'Add a new family.' elif context == 'Variables': fields = ['trait', 'name', 'value'] dialog_message = 'Add a new variable.' elif context == 'machine_type': fields = ['name'] dialog_message = 'Add a new machine type.' if action == 'new': if context == 'Scripts': dialog = NewMTScriptDialog(self) dialog.connect(dialog, SIGNAL('okClicked()'), self.insertNewScript) self._dialog = dialog elif fields: dialog = BaseRecordDialog(self, fields) dialog.context = context dialog.connect(dialog, SIGNAL('okClicked()'), self.insertNewRecord) dialog.frame.setText(dialog_message) self._dialog = dialog else: KMessageBox.error(self, 'problem with %s' % url) elif action == 'edit': self._perform_edit_action(context, ident) elif action == 'delete': self._perform_delete_action(context, ident) else: msg = 'Problem with action in url %s' % url KMessageBox.error(self, msg) if self._dialog is not None: self._dialog.connect(self._dialog, SIGNAL('cancelClicked()'), self._destroy_dialog) self._dialog.show() self.resetView()
def setSource(self, url): action, context, ident = split_url(url) if action == 'edit': if context == 'variables': config = self.family.getVariablesConfig(self.family.current) newconfig = config.edit() config.update(newconfig) self.set_family(ident) elif context == 'parents': dialog = FamilyParentAssigner(self, ident) dialog.connect(dialog, SIGNAL('okClicked()'), self.resetView) dialog.show() else: KMessageBox.error(self, 'unable to edit %s for family' % context) elif action == 'delete': if context == 'family': #KMessageBox.information(self, 'delete family %s is unimplemented' % ident) msg = "Really delete family %s" % ident answer = KMessageBox.questionYesNo(self, msg) if answer == KMessageBox.Yes: self.family.delete_family(ident) msg = "family %s deleted" % ident KMessageBox.information(self, msg) self.parent().parent().refreshListView() self.setText('') else: KMessageBox.error(self, 'unable to delete %s for family' % context) else: KMessageBox.error(self, 'action %s unimpletmented' % url)
def setSource(self, url): action, context, ident = split_url(url) fields = [] dialog_message = "We need a message here" if context == "Disks": fields = ["diskname", "device"] dialog_message = "Add a new disk." elif context == "Families": fields = ["family"] dialog_message = "Add a new family." elif context == "Variables": fields = ["trait", "name", "value"] dialog_message = "Add a new variable." elif context == "machine_type": fields = ["name"] dialog_message = "Add a new machine type." if action == "new": if context == "Scripts": dialog = NewMTScriptDialog(self) dialog.connect(dialog, SIGNAL("okClicked()"), self.insertNewScript) self._dialog = dialog elif fields: dialog = BaseRecordDialog(self, fields) dialog.context = context dialog.connect(dialog, SIGNAL("okClicked()"), self.insertNewRecord) dialog.frame.setText(dialog_message) self._dialog = dialog else: KMessageBox.error(self, "problem with %s" % url) elif action == "edit": self._perform_edit_action(context, ident) elif action == "delete": self._perform_delete_action(context, ident) else: msg = "Problem with action in url %s" % url KMessageBox.error(self, msg) if self._dialog is not None: self._dialog.connect(self._dialog, SIGNAL("cancelClicked()"), self._destroy_dialog) self._dialog.show() self.resetView()
def insertNewProfile(self): win = self._dialog profile = win.getRecordData()["name"] profile_list = self.profile.get_profile_list() if profile not in profile_list: skeleton = self.cfg.get("management_gui", "template_profile") if skeleton in profile_list: self.profile.copy_profile(skeleton, profile) self.refreshListView() else: dlg = BaseRecordDialog(win, ["suite"]) dlg.frame.text_label.setText("Select a suite for this profile") dlg.connect(dlg, SIGNAL("okClicked()"), self.insertNewProfilewithSuite) dlg.show() dlg.profile = profile win.suite_dialog = dlg KMessageBox.information(self, "need to select suite here") # need to determine if skeleton exists KMessageBox.information(self, "make profile %s" % profile) else: KMessageBox.error(self, "Profile %s already exists." % profile)
def insertNewProfile(self): win = self._dialog profile = win.getRecordData()['name'] profile_list = self.profile.get_profile_list() if profile not in profile_list: skeleton = self.cfg.get('management_gui', 'template_profile') if skeleton in profile_list: self.profile.copy_profile(skeleton, profile) self.refreshListView() else: dlg = BaseRecordDialog(win, ['suite']) dlg.frame.text_label.setText('Select a suite for this profile') dlg.connect(dlg, SIGNAL('okClicked()'), self.insertNewProfilewithSuite) dlg.show() dlg.profile = profile win.suite_dialog = dlg KMessageBox.information(self, 'need to select suite here') # need to determine if skeleton exists KMessageBox.information(self, 'make profile %s' % profile) else: KMessageBox.error(self, 'Profile %s already exists.' % profile)
def new_game_path_selected(self): # url is a KURL url = self.new_game_dir_dialog.url() # since the url should be file://path/to/game # we only want the /path/to/game fullpath = str(url.path()) # here we set the name of the game to the base # directory of the path. This is probably not a good # idea in the long run, and I'll change this behaviour one day. name = os.path.basename(fullpath) if name not in self.game_names: print name, fullpath, self.game_names if self.add_new_game_dlg is None: dlg = AddNewGameDialog(self, fullpath) dlg.connect(dlg, SIGNAL('okClicked()'), self.add_new_game) dlg.connect(dlg, SIGNAL('cancelClicked()'), self.destroy_add_new_game_dlg) dlg.connect(dlg, SIGNAL('closeClicked()'), self.destroy_add_new_game_dlg) dlg.show() self.add_new_game_dlg = dlg else: KMessageBox.error(self, '%s already exists.' % name) self.new_game_dir_dialog = None
class BaseMachineAttributeDialog(BaseMachineDialog): def __init__(self, parent, handler, attribute): BaseMachineDialog.__init__(self, parent, handler) self.attributeLbl = QLabel(self.frame) self.attributeLbl.setText(attribute) self.attributeEntry = KLineEdit(self.frame) self.vbox.addWidget(self.attributeLbl) self.vbox.addWidget(self.attributeEntry) self.attribute = attribute def slotOkClicked(self): value = str(self.attributeEntry.text()) try: self.handler.set_attribute(self.attribute, value) except OperationalError, inst: if 'violates foreign key constraint' in inst.message: KMessageBox.error(self, '%s is not a valid %s' % (value, self.attribute)) else: raise OperationalError(inst) except NoSuchKernelError, inst: KMessageBox.error("There's no such kernel: %s" % value)
def setSource(self, url): action, context, ident = split_url(url) if action == 'show': print 'unimpletmented' elif action == 'edit': if context == 'traits': win = TraitAssigner(self.parent(), ident) self.connect(win, SIGNAL('okClicked()'), self.resetView) win.show() elif context == 'variables': self.doc.profile.edit_variables() self.resetView() elif context == 'families': win = FamilyAssigner(self.parent(), ident) self.connect(win, SIGNAL('okClicked()'), self.resetView) win.show() else: KMessageBox.error(self, 'bad edit action %s' % url) elif action == 'change': if context == 'suite': self.emit(PYSIGNAL('changeSuite'), (ident, )) print 'changeSuite emitted' else: KMessageBox.error(self, 'bad change action %s' % url) elif action == 'delete': if context == 'profile': msg = "Really delete profile %s" % ident answer = KMessageBox.questionYesNo(self, msg) if answer == KMessageBox.Yes: #msg = "we're supposed to delete this profile, but can't yet" self.doc.profile.delete_profile(ident) msg = "profile %s deleted" % ident KMessageBox.information(self, msg) mainwin = self.parent().parent() mainwin.refreshListView() mainwin.resetProfileObject() self.setText('') else: KMessageBox.error(self, "Don't know how to delete %s" % context) else: KMessageBox.information(self, 'called %s' % url)
def _import_export_directory_selected(self): win = self._import_export_dirsel_dialog if win is None: raise RuntimeError, 'There is no import export dialog' self._import_export_dirsel_dialog = None url = win.url() fullpath = str(url.path()) action = win.db_action print 'selected fullpath', fullpath print 'action is', win.db_action win.close() #self.app.processEvents() dbm = DatabaseManager(self.app.conn) if action == 'import': #dbm.restore(fullpath) win = ImportDbProgressDialog(self) importer = dbm.importer importer.report_total_apt_sources = win.aptsrc_progress.setTotalSteps #importer.report_aptsrc_imported = win.aptsrc_progress.step_progress importer.report_importing_aptsrc = win.aptsrc_progress.start_step importer.report_aptsrc_imported = win.aptsrc_progress.finish_step aptsrc = importer.aptsrc aptsrc.report_total_packages = win.package_progress.setTotalSteps aptsrc.report_package_inserted = win.package_progress.step_progress importer.report_total_suites = win.suite_progess.setTotalSteps importer.report_importing_suite = win.suite_progess.start_step importer.report_suite_imported = win.suite_progess.finish_step #importer.report_total_traits = win.trait_progress.setTotalSteps importer.report_total_traits = win.report_total_traits importer.report_trait_imported = win.trait_progress.step_progress importer.report_total_families = win.family_progress.setTotalSteps importer.report_family_imported = win.family_progress.step_progress importer.report_total_profiles = win.profile_progress.setTotalSteps importer.report_profile_imported = win.profile_progress.step_progress win.show() dbm.import_all(fullpath) self.app.processEvents() win.close() KMessageBox.information(self, 'Database Imported') elif action == 'export': #dbm.backup(fullpath) win = ExportDbProgressDialog(self) exporter = dbm.exporter exporter.report_total_suites = win.suite_progess.setTotalSteps exporter.report_exporting_suite = win.suite_progess.start_step exporter.report_suite_exported = win.suite_progess.finish_step exporter.report_total_traits = win.trait_progress.setTotalSteps exporter.report_trait_exported = win.trait_progress.step_progress #exporter.report_all_traits_exported = win.trait_progress.progressbar.reset exporter.report_start_exporting_traits = win.trait_progress.progressbar.reset exporter.report_total_profiles = win.profile_progress.setTotalSteps exporter.report_profile_exported = win.profile_progress.step_progress family = exporter.family family.report_total_families = win.family_progress.setTotalSteps family.report_family_exported = win.family_progress.step_progress win.show() self.app.processEvents() dbm.export_all(fullpath) self.app.processEvents() win.close() else: KMessageBox.error(self, 'action %s not supported' % action)
def setSource(self, url): KMessageBox.error(self, 'setSource unsupported now %s' % url)
def slotManageSuite(self, wid=-1): print 'in slotManageSuite suite is', wid #TraitMainWindow(self.app, self, current.suite) KMessageBox.error(self, 'Managing suites unimplemented')