def find_text(self, from_cursor, is_fw): if (self.f_text == None): return ed = self.currentWidget() if not ed: return text = self.f_text opt = self.f_opt if (from_cursor): if (is_fw): (line, inx) = (-1, -1) else: (line, inx) = ed.ev.getCursorPosition() if (ed.ev.hasSelectedText()): inx = inx - 1 if ed.ev.findFirst(text, opt['re'], opt['cs'], opt['wo'], False, is_fw, line, inx): return True if not DialogManager.show_yes_no('End of document reached. Continue from beginning?'): return False if (is_fw): (line, inx) = (0, 0) else: (line, inx) = (ed.ev.lines(), 0) if ed.ev.findFirst(text, opt['re'], opt['cs'], opt['wo'], False, is_fw, line, inx): return DialogManager.show_msg_dialog("Could not find " + "'" + text + "'")
def locatefile(self): """ Calls a class to open a file dialogue allowing the user to choose a text file. """ dm = DialogManager() print "Opening file chooser ..." file = dm.choosefile("Choose Raw File") return file
def open_in_external_editor(self, cmd): if not cmd: DialogManager.show_msg_dialog('Please configure external editor') return (f, l) = self.get_current_file_line() if not f: return cmd = cmd.replace('%F', f).replace('%L', str(l)) if not QProcess.startDetached(cmd): DialogManager.show_msg_dialog('Failed to start: ' + cmd)
def close_list_common(self, type): inx_list = self.tab_list(self.currentIndex(), type) if len(inx_list) == 0: return if self.has_modified_file(inx_list): msg = 'Closing all %s.\nSave changes ?' % type if DialogManager.show_yes_no(msg): self.save_tab_list() self.remove_tab_list(inx_list) else: msg = 'Close all %s ?' % type if not DialogManager.show_yes_no(msg): return self.remove_tab_list(inx_list)
def codemark_del_all_cb(self): if not self.cm_mgr.count(): return if not DialogManager.show_yes_no('Delete all codemarks ?'): return for f, l in reversed(self.cm_mgr.codemarks()): self.codemark_delete(f, l)
def close_list_common(self, type): inx_list = self.tab_list(self.currentIndex(), type) if len(inx_list) == 0: return if not DialogManager.show_yes_no('Close all %s ?' % type): return self.remove_tab_list(inx_list)
def proj_open_cb(self): proj_path = DialogManager.show_project_open_dialog(self.recent_projects) if proj_path != None: if backend.proj_is_open(): self.proj_close_cb() self.proj_open(proj_path)
def file_restart_cb(self): if not DialogManager.show_yes_no('Restart ?'): return hint = self.edit_book.get_file_line_list() if backend.proj_is_open(): self.proj_close_cb() QApplication.quit() os.environ['SEASCOPE_RESTART_HINT'] = '%s' % str(hint) QProcess.startDetached(sys.executable, QApplication.arguments(), self.seascope_start_dir);
def goto_line_cb(self): ed = self.currentWidget() if not ed: return (None, None) (line, inx) = ed.ev.getCursorPosition() #return (line + 1, ed.ev.lines()) line = DialogManager.show_goto_line_dialog(line + 1, ed.ev.lines()) if (line == None): return ed.ev.goto_line(line)
def file_restart_cb(self): if not DialogManager.show_yes_no('Restart ?'): return hint = self.edit_book.get_file_line_list() if backend.proj_is_open(): self.proj_close_cb() QApplication.quit() os.environ['SEASCOPE_RESTART_HINT'] = '%s' % str(hint) QProcess.startDetached(sys.executable, QApplication.arguments(), self.seascope_start_dir)
def onMessageRec(uid, txt): d = DialogManager.getDialogById("_vk" + str(uid), sendfunction=sendf, typefunction=sendTypingStatus) d.pubScore = 0.84 isPriv = not (str(uid).count("2000000") > 0) if (not isPriv): isPriv = (txt.count("Курису") + txt.count("Макис") + txt.lower().count("ассистент") + txt.count("Амадей") + txt.count("Амадеус") + txt.count("Куристина") > 0) print(isPriv) d.getAnswer(txt.replace("<br>", ""), "", isPrivate=isPriv)
def find_cb(self): ed = self.currentWidget() if not ed: return res = DialogManager.show_find_dialog(self.get_current_word()) if (res == None): return (text, opt) = res if (text == None): return self.f_text = text self.f_opt = opt self.find_text(opt['cursor'], opt['fw'])
def file_preferences_cb(self): ev_font = QFont() ev_font.fromString(self.edit_book.ev_font) res = DialogManager.show_preferences_dialog(self.app_style, self.edit_ext_cmd, ev_font, self.exit_dont_ask, self.eb_is_show_line) (self.app_style, self.app_font, self.edit_ext_cmd, ev_font, self.exit_dont_ask, self.eb_is_show_line) = res if self.edit_ext_cmd != None: self.edit_ext_cmd = str(self.edit_ext_cmd).strip() if (self.edit_ext_cmd == None or self.edit_ext_cmd == ''): self.edit_ext_cmd = 'x-terminal-emulator -e vim %F +%L' self.edit_book.change_ev_font(ev_font.toString()) self.code_ctx_view.change_ev_font(ev_font.toString()) self.edit_book.show_line_number_pref(self.eb_is_show_line) self.app_write_config()
def file_preferences_cb(self): ev_font = QFont() ev_font.fromString(self.edit_book.ev_font) res = DialogManager.show_preferences_dialog(self.app_style, self.edit_ext_cmd, ev_font, self.exit_dont_ask, self.inner_editing, self.eb_is_show_line) (self.app_style, self.app_font, self.edit_ext_cmd, ev_font, self.exit_dont_ask, self.inner_editing_conf, self.eb_is_show_line) = res if self.edit_ext_cmd != None: self.edit_ext_cmd = str(self.edit_ext_cmd).strip() if (self.edit_ext_cmd == None or self.edit_ext_cmd == ''): self.edit_ext_cmd = 'x-terminal-emulator -e vim %F +%L' self.edit_book.change_ev_font(ev_font.toString()) self.code_ctx_view.change_ev_font(ev_font.toString()) self.edit_book.show_line_number_pref(self.eb_is_show_line) self.app_write_config()
def closeEvent(self, ev): if not self.exit_dont_ask and backend.proj_is_open(): ret = DialogManager.show_yes_no_dontask('Close project and quit?') if ret == 1: ev.ignore() return if ret == 2: self.exit_dont_ask = True self.edit_book.close_all_cb() self.app_write_config() if backend.proj_is_open(): self.app_gui_state_save(backend.proj_dir()) ev.accept()
def closeEvent(self, ev): if not self.exit_dont_ask and backend.proj_is_open(): ret = DialogManager.show_yes_no_dontask('Close project and quit?') if ret == 1: ev.ignore() return if ret == 2: self.exit_dont_ask = True # extra proc for editing enabled if self.inner_editing: self.edit_book.close_all_cb() self.app_write_config() if backend.proj_is_open(): self.app_gui_state_save(backend.proj_dir()) ev.accept()
def proj_new_cb(self): if backend.proj_is_open(): if not DialogManager.show_proj_close(): return self.proj_close_cb() dlg = BackendChooserDialog() bname = dlg.run_dialog() if bname == None: return proj_args = ProjectUi.show_settings_ui(bname, None) if not proj_args: return if not backend.proj_new(bname, proj_args): return # XXX FIXIT self.qui.do_rebuild() self.proj_new_or_open()
def filter_cb(self): filtered = False cmd_sel = self.cmd_items[self.last_minx.column()] res = DialogManager.show_filter_dialog(self.cmd_items, cmd_sel) if res == None: return (filter_text, is_regex, is_negate, is_ignorecase, cmd_sel) = res cmd_idx = self.cmd_items.index(cmd_sel) if cmd_idx == -1: return for inx in range(self.topLevelItemCount()): item = self.topLevelItem(inx) text = item.column_val(cmd_idx) if (text == None): continue matched = False if (is_regex): if (is_ignorecase): if (re.search(filter_text, text, re.I) != None): matched = True else: if (re.search(filter_text, text) != None): matched = True else: if (is_ignorecase): if (text.upper().find(filter_text.upper()) != -1): matched = True else: if (text.find(filter_text) != -1): matched = True if (is_negate): matched = not matched if not matched: item.setHidden(True) filtered = True if filtered: self.mark_tab_filtered(True)
def filter_cb(self): filtered = False cmd_sel = self.cmd_items[self.last_minx.column()] res = DialogManager.show_filter_dialog(self.cmd_items,cmd_sel) if res == None: return (filter_text, is_regex, is_negate, is_ignorecase, cmd_sel) = res cmd_idx = self.cmd_items.index(cmd_sel) if cmd_idx == -1: return for inx in range(self.topLevelItemCount()): item = self.topLevelItem(inx) text = item.column_val(cmd_idx) if (text == None): continue matched = False if (is_regex): if (is_ignorecase): if (re.search(filter_text, text, re.I) != None): matched = True else: if (re.search(filter_text, text) != None): matched = True else: if (is_ignorecase): if (text.upper().find(filter_text.upper()) != -1): matched = True else: if (text.find(filter_text) != -1): matched = True if (is_negate): matched = not matched if not matched: self.setItemHidden(item, True) filtered = True if filtered: self.mark_tab_filtered(True)
def close_cb(self, inx): page = self.widget(self.currentIndex()) if page.ev.isModified(): if DialogManager.show_yes_no("Do you want to save file ?"): self.save_current_page() self.removeTab(inx)
def close_all_cb(self): if DialogManager.show_yes_no("Close all query results ?"): self.clear() self.h_page = None
def help_about_cb(self): DialogManager.show_about_dialog()
def hotplugKurisu(): dm.kurisu = dm.GetAnswerFromFile("data/kurisu.preprocessed") sendMsg(205176061, "Выполнено")
"А как же я?", "А про меня забыли?", "Мне скучно(", "Хэй!/pauseМеня не существует что ли?!" ]): sendSticker(i) sendMsg(i, t) return True lastrec = "" while True: j = [] try: j = getUpdates(offset) except KeyboardInterrupt: dm.updateLocalDials() sys.exit(0) except Exception as e: print(e) sys.stdout.write(ttt() + "Get!\r") for i in j: try: msg_id = i['update_id'] if (seen.count(msg_id) > 0): continue else: seen.append(msg_id) offset = msg_id + 1 print(ttt() + "len(j)=" + str(len(j))) txt = "" isPrivate = True try: isPrivate = (i['message']['chat']['type'] == 'private')
#!/usr/bin/env python3 import DialogManager as dm from logStub import logD import sys logD("Loaded!") #Простейший способ вызвать диалог в терминале def sendfun(msg,ident): if(len(msg)<3):msg=msg+" " sys.stdout.write('\r\033[1;33mKurisu\033[0m: '+msg+'\n') def typfun(ident): sys.stdout.write("typing...") d=dm.Dialog(sendfunction=sendfun,typefunction=typfun) while(True): try: usermsg=input("\n\033[1;33mYou\033[0m: ") d.getAnswer(usermsg) except KeyboardInterrupt: print("Exit") sys.exit(0)
def __init__(self, mainWindow, debugMode=False): QtCore.QObject.__init__(self) # Prints angry debug messages, if activated self.debugMode = debugMode # Register mainWindow object self.mainWindow = mainWindow # Create/initialize other objects self.fileManager = FileManager() self.executionManager = ExecutionManager(self) self.buildManager = BuildManager(self) self.dialogManager = DialogManager(self.mainWindow) # Connect signals from newFileDialog and saveAsDialog to controller methods self.dialogManager.newFileDialog.accepted.connect( self.on_new_file_accepted) self.dialogManager.saveAsDialog.accepted.connect( self.on_save_As_file_accepted) # Connect find replace dialog button(s) to there handler method(s) self.dialogManager.findReplaceDialog.close_button.clicked.connect( self.dialogManager.findReplaceDialog.hide) self.dialogManager.findReplaceDialog.replace_all_button.clicked.connect( self.on_replace_all_button) self.dialogManager.findReplaceDialog.replace_button.clicked.connect( self.on_replace_button) self.dialogManager.findReplaceDialog.find_button.clicked.connect( self.on_find_button) # Connect goto line dialog buttons(s) to appropriate handler method(s) self.dialogManager.gotoLineDialog.accepted.connect( self.on_actionGoto_line_accepted) # Overriding standard exit behavior hideous hack? self.mainWindow.closeEvent = self.on_exit # Link UI elements to functions for item in self.mainWindow.findChildren( QtGui.QAction): # Menubar action elements try: itemName = str(item.objectName()) if itemName != "": function = self.__getattribute__("on_" + itemName) item.triggered.connect(function) except AttributeError: if (debugMode): print "Controller should have a member function called '%s', but doesn't!" % ( "on_" + itemName) for item in self.mainWindow.findChildren( QtGui.QPushButton): # Buttons elements try: itemName = str(item.objectName()) if itemName != "": function = self.__getattribute__("on_" + itemName) item.clicked.connect(function) except AttributeError: if (debugMode): print "Controller should have a member function called '%s', but doesn't!" % ( "on_" + itemName) inputTextBox = self.mainWindow.findChild(QtGui.QLineEdit, 'stdinTextBox') inputTextBox.returnPressed.connect(self.enter) self.disableProjectControls()