def closeEvent(self, event): """ Éste médoto es llamado automáticamente por Qt cuando se cierra la aplicación, guarda algunas configuraciones como posición y tamaño de la ventana, archivos, etc. """ DEBUG("Exiting...") editor_container = Edis.get_component("principal") if editor_container.check_files_not_saved() and \ settings.get_setting('general/confirm-exit'): files_not_saved = editor_container.files_not_saved() dialog = unsaved_files.DialogSaveFiles( files_not_saved, editor_container, self) dialog.exec_() if dialog.ignorado(): event.ignore() if settings.get_setting('window/store-size'): if self.isMaximized(): settings.set_setting('window/show-maximized', True) else: settings.set_setting('window/show-maximized', False) settings.set_setting('window/size', self.size()) settings.set_setting('window/position', self.pos()) opened_files = editor_container.opened_files() settings.set_setting('general/files', opened_files) settings.set_setting('general/recents-files', editor_container.get_recents_files()) projects = editor_container.get_open_projects() settings.set_setting('general/projects', projects)
def keyPressEvent(self, event): super(Editor, self).keyPressEvent(event) key = event.key() # Borra indicador de palabra if key == Qt.Key_Escape: self.clear_indicators(Editor.WORD_INDICATOR) return # Completado de comillas if key == Qt.Key_Apostrophe: if settings.get_setting('editor/complete-single-quote'): self._complete_quote(event) return if key == Qt.Key_QuoteDbl: if settings.get_setting('editor/complete-double-quote'): self._complete_quote(event) return # Completado de llaves if key == Qt.Key_BraceLeft: if settings.get_setting('editor/complete-brace'): self._complete_key(event) if key in (Qt.Key_BracketLeft, Qt.Key_ParenLeft, Qt.Key_BracketRight, Qt.Key_ParenRight): self._complete_brace(event)
def closeEvent(self, event): """ Éste médoto es llamado automáticamente por Qt cuando se cierra la aplicación, guarda algunas configuraciones como posición y tamaño de la ventana, archivos, etc. """ DEBUG("Exiting...") editor_container = Edis.get_component("principal") if editor_container.check_files_not_saved() and settings.get_setting("general/confirm-exit"): files_not_saved = editor_container.files_not_saved() dialog = unsaved_files.DialogSaveFiles(files_not_saved, editor_container, self) dialog.exec_() if dialog.ignorado(): event.ignore() if settings.get_setting("window/store-size"): if self.isMaximized(): settings.set_setting("window/show-maximized", True) else: settings.set_setting("window/show-maximized", False) settings.set_setting("window/size", self.size()) settings.set_setting("window/position", self.pos()) opened_files = editor_container.opened_files() settings.set_setting("general/files", opened_files) settings.set_setting("general/recents-files", editor_container.get_recents_files()) projects = editor_container.get_open_projects() settings.set_setting("general/projects", projects)
def update_margin(self): """ Actualiza el ancho del márgen de línea """ if settings.get_setting('editor/show-margin'): self.setEdgeMode(QsciScintilla.EdgeLine) ancho = settings.get_setting('editor/width-margin') self.setEdgeColumn(ancho) self.setEdgeColor(QColor(self.scheme['Margin'])) else: self.setEdgeMode(QsciScintilla.EdgeNone)
def _load_ui(self, window): """ Carga el componente principal (Editor Container), componentes laterales y la salida del compilador. """ editor_container = Edis.get_component("principal") # Lateral tab_container = Edis.get_component("tab_container") lateral_widgets = ["symbols", "project", "explorer"] for widget in lateral_widgets: method = getattr(tab_container, "load_%s_widget" % widget) obj = Edis.get_lateral(widget) method(obj) self.addDockWidget(Qt.LeftDockWidgetArea, tab_container) output_widget = Edis.get_component("output") output_widget.hide() window.addDockWidget(Qt.BottomDockWidgetArea, output_widget) if settings.get_setting('general/show-start-page'): editor_container.add_start_page() # Conexiones editor_container.savedFile['QString'].connect(self._show_status) editor_container.fileChanged['QString'].connect(self._change_title) editor_container.editor_widget.allFilesClosed.connect(self._all_closed) output_widget.goToLine[int].connect(editor_container.go_to_line) return editor_container
def run_program(self, sources): """ Ejecuta el binario generado por el compilador """ path = os.path.dirname(sources[0]) self.execution_process.setWorkingDirectory(path) # Path ejecutable path_exe = os.path.join(path, self.exe) if not settings.IS_LINUX: path_exe += '.exe' # Si no existe se termina el proceso if not self._check_file_exists(path_exe): text = output_compiler.Item( self.tr("El archivo no existe: {0}").format(path_exe)) text.setForeground(Qt.red) self.output.addItem(text) return # Texto en la salida text = output_compiler.Item( self.tr("Ejecutando... {0}").format(path_exe)) self.output.addItem(text) if settings.IS_LINUX: # Run ! terminal = settings.get_setting('terminal') arguments = [os.path.join(paths.PATH, "tools", "run_script.sh %s" % path_exe)] self.execution_process.start(terminal, ['-e'] + arguments) else: pauser = os.path.join(paths.PATH, "tools", "pauser", "system_pause.exe") process = [pauser] + ["\"%s\"" % path_exe] Popen(process, creationflags=CREATE_NEW_CONSOLE)
def _change_border_tab_position(self, area): current_theme = settings.get_setting("window/style-sheet") if current_theme != 'Edark': return position = "left" if area == 1 else "right" border = "{border-%s: 3px solid #204A87}" % position self.tabs.setStyleSheet("QTabBar::tab:selected %s" % border)
def _load_ui(self, window): """ Carga el componente principal (Editor Container), componentes laterales y la salida del compilador. """ editor_container = Edis.get_component("principal") # Lateral tab_container = Edis.get_component("tab_container") lateral_widgets = ["symbols", "project", "explorer"] for widget in lateral_widgets: method = getattr(tab_container, "load_%s_widget" % widget) obj = Edis.get_lateral(widget) method(obj) self.addDockWidget(Qt.LeftDockWidgetArea, tab_container) output_widget = Edis.get_component("output") output_widget.hide() window.addDockWidget(Qt.BottomDockWidgetArea, output_widget) if settings.get_setting("general/show-start-page"): editor_container.add_start_page() # Conexiones editor_container.savedFile["QString"].connect(self._show_status) editor_container.fileChanged["QString"].connect(self._change_title) editor_container.editor_widget.allFilesClosed.connect(self._all_closed) output_widget.goToLine[int].connect(editor_container.go_to_line) return editor_container
def run_program(self, sources): """ Ejecuta el binario generado por el compilador """ path = os.path.dirname(sources[0]) self.execution_process.setWorkingDirectory(path) # Path ejecutable path_exe = os.path.join(path, self.exe) if not settings.IS_LINUX: path_exe += '.exe' # Si no existe se termina el proceso if not self._check_file_exists(path_exe): text = output_compiler.Item( self.tr("El archivo no existe: {0}").format(path_exe)) text.setForeground(Qt.red) self.output.addItem(text) return # Texto en la salida text = output_compiler.Item( self.tr("Ejecutando... {0}").format(path_exe)) self.output.addItem(text) if settings.IS_LINUX: # Run ! terminal = settings.get_setting('terminal') arguments = [ os.path.join(paths.PATH, "tools", "run_script.sh %s" % path_exe) ] self.execution_process.start(terminal, ['-e'] + arguments) else: pauser = os.path.join(paths.PATH, "tools", "pauser", "system_pause.exe") process = [pauser] + ["\"%s\"" % path_exe] Popen(process, creationflags=CREATE_NEW_CONSOLE)
def update_sidebar(self): """ Ajusta el ancho del sidebar """ fmetrics = QFontMetrics(self._font) lines = str(self.lines()) + '0' line_number = settings.get_setting('editor/show-line-number') width = fmetrics.width(lines) if line_number else 0 self.setMarginWidth(0, width)
def active_code_completion(self, enabled=True): if self.api is not None and enabled: return if enabled: self.api = QsciAPIs(self._lexer) if settings.get_setting('editor/completion-keywords'): for keyword in keywords.keywords: self.api.add(keyword) self.api.prepare() source = QsciScintilla.AcsAPIs if settings.get_setting('editor/completion-document'): source = QsciScintilla.AcsAll elif settings.get_setting('editor/completion-document'): source = QsciScintilla.AcsDocument else: source = QsciScintilla.AcsNone threshold = settings.get_setting('editor/completion-threshold') self.setAutoCompletionThreshold(threshold) self.setAutoCompletionSource(source) cs = settings.get_setting('editor/completion-cs') self.setAutoCompletionCaseSensitivity(cs) repl_word = settings.get_setting('editor/completion-replace-word') self.setAutoCompletionReplaceWord(repl_word) show_single = settings.get_setting('editor/completion-single') use_single = 2 if show_single else 0 self.setAutoCompletionUseSingle(use_single) else: self.api = None self.setAutoCompletionSource(0)
def add_start_page(self): """ Agrega la página de inicio al stack """ if settings.get_setting('general/show-start-page'): _start_page = start_page.StartPage() self.stack.insertWidget(0, _start_page) self.stack.setCurrentIndex(0) else: self.editor_widget.combo.setVisible(False)
def _add_marker_modified(self): """ Agrega el marcador cuando el texto cambia """ if not settings.get_setting('editor/mark-change'): return nline, _ = self.getCursorPosition() if self.markersAtLine(nline): self.markerDelete(nline) self.markerAdd(nline, Editor.MARKER_MODIFIED)
def __init__(self): QMainWindow.__init__(self) # Esto para tener widgets laterales en full height, window = QMainWindow(self) self.setWindowTitle("{" + ui.__edis__ + "}") self.setMinimumSize(750, 500) # Se cargan las dimensiones de la ventana if settings.get_setting("window/show-maximized"): self.setWindowState(Qt.WindowMaximized) else: size = settings.get_setting("window/size") position = settings.get_setting("window/position") self.resize(size) self.move(position) # Toolbars self.toolbar = QToolBar(self) self.toolbar.setObjectName("toolbar") toggle_action = self.toolbar.toggleViewAction() toggle_action.setText(self.tr("Toolbar")) self.toolbar.setIconSize(QSize(24, 24)) self.toolbar.setToolButtonStyle(Qt.ToolButtonIconOnly) self.addToolBar(Qt.RightToolBarArea, self.toolbar) Edis.load_component("toolbar", self.toolbar) # Animated property self.setDockOptions(QMainWindow.AnimatedDocks) # Menú menu_bar = self.menuBar() self.setup_menu(menu_bar) # Barra de estado self.status_bar = Edis.get_component("status_bar") self.setStatusBar(self.status_bar) # Widget central central = self._load_ui(window) window.setCentralWidget(central) window.setWindowFlags(Qt.Widget) self.setCentralWidget(window) Edis.load_component("edis", self) # Comprobar nueva versión if settings.get_setting("general/check-updates"): self.noti = system_tray.NotificacionActualizacion() self.noti.show()
def __init__(self): QMainWindow.__init__(self) # Esto para tener widgets laterales en full height, window = QMainWindow(self) self.setWindowTitle('{' + ui.__edis__ + '}') self.setMinimumSize(750, 500) # Se cargan las dimensiones de la ventana if settings.get_setting('window/show-maximized'): self.setWindowState(Qt.WindowMaximized) else: size = settings.get_setting('window/size') position = settings.get_setting('window/position') self.resize(size) self.move(position) # Toolbars self.toolbar = QToolBar(self) self.toolbar.setObjectName("toolbar") toggle_action = self.toolbar.toggleViewAction() toggle_action.setText(self.tr("Toolbar")) self.toolbar.setIconSize(QSize(24, 24)) self.toolbar.setToolButtonStyle(Qt.ToolButtonIconOnly) self.addToolBar(Qt.RightToolBarArea, self.toolbar) Edis.load_component("toolbar", self.toolbar) # Animated property self.setDockOptions(QMainWindow.AnimatedDocks) # Menú menu_bar = self.menuBar() self.setup_menu(menu_bar) # Barra de estado self.status_bar = Edis.get_component("status_bar") self.setStatusBar(self.status_bar) # Widget central central = self._load_ui(window) window.setCentralWidget(central) window.setWindowFlags(Qt.Widget) self.setCentralWidget(window) Edis.load_component("edis", self) # Comprobar nueva versión if settings.get_setting('general/check-updates'): self.noti = system_tray.NotificacionActualizacion() self.noti.show()
def load_highlighter(self): """ Método público: carga el resaltado de sintáxis """ scheme = editor_scheme.get_scheme( settings.get_setting('editor/scheme')) self.setDefaultPaper(QColor(scheme['BackgroundEditor'])) self.setPaper(self.defaultPaper(0)) self.setColor(QColor(scheme['Color'])) types = dir(self) for _type in types: if _type in scheme: atr = getattr(self, _type) self.setColor(QColor(scheme[_type]), atr)
def update_options(self): """ Actualiza las opciones del editor """ if settings.get_setting('editor/show-tabs-spaces'): self.setWhitespaceVisibility(self.WsVisible) else: self.setWhitespaceVisibility(self.WsInvisible) self.setIndentationGuides(settings.get_setting('editor/show-guides')) if settings.get_setting('editor/wrap-mode'): self.setWrapMode(self.WrapWord) else: self.setWrapMode(self.WrapNone) self.send("sci_setcaretstyle", settings.get_setting('editor/cursor')) self.setCaretWidth(settings.get_setting('editor/caret-width')) self.setAutoIndent(settings.get_setting('editor/indent')) self.send("sci_setcaretperiod", settings.get_setting('editor/cursor-period')) current_line = settings.get_setting('editor/show-caret-line') self.send("sci_setcaretlinevisible", current_line) self.setEolVisibility(settings.get_setting('editor/eof'))
def __init__(self): super(CompletionSection, self).__init__() EditorConfiguration.install_widget(self.tr("Autocompletado"), self) container = QVBoxLayout(self) group_complete = QGroupBox(self.tr("Completar:")) box = QGridLayout(group_complete) box.setContentsMargins(20, 5, 20, 5) self.check_bracket = QCheckBox(self.tr("Corchetes []")) box.addWidget(self.check_bracket, 0, 0) self.check_paren = QCheckBox(self.tr("Paréntesis ()")) box.addWidget(self.check_paren, 0, 1) self.check_key = QCheckBox(self.tr("Llaves {}")) box.addWidget(self.check_key, 1, 0) self.check_quote = QCheckBox(self.tr("Comillas Dobles \" \"")) box.addWidget(self.check_quote, 1, 1) self.check_single_quote = QCheckBox(self.tr("Comillas Simples ' '")) box.addWidget(self.check_single_quote, 2, 0) group_completion = QGroupBox(self.tr("Completado de Código:")) box = QGridLayout(group_completion) box.setContentsMargins(20, 5, 20, 5) self.check_completion = QCheckBox(self.tr("Activar Completado")) box.addWidget(self.check_completion, 0, 0) self.check_document = QCheckBox(self.tr("Basado en el código")) box.addWidget(self.check_document, 0, 1) self.check_keywords = QCheckBox(self.tr("Palabras Claves")) box.addWidget(self.check_keywords, 1, 0) self.check_cs = QCheckBox( self.tr("Sensitivo a mayúsculas y minúsculas")) box.addWidget(self.check_cs, 1, 1) self.check_replace_word = QCheckBox(self.tr("Reemplazar Palabra")) box.addWidget(self.check_replace_word, 2, 0) self.check_show_single = QCheckBox(self.tr("Mostrar Simple")) box.addWidget(self.check_show_single, 2, 1) hbox = QHBoxLayout() hbox.addWidget( QLabel(self.tr("Número de caractéres para mostrar lista:"))) self.spin_threshold = QSpinBox() self.spin_threshold.setMinimum(1) self.spin_threshold.setFixedWidth(100) hbox.addWidget(self.spin_threshold) box.addLayout(hbox, 3, 0, Qt.AlignLeft) # Agrupo al contenedor principal container.addWidget(group_complete) container.addWidget(group_completion) container.addItem( QSpacerItem(0, 10, QSizePolicy.Expanding, QSizePolicy.Expanding)) self._state_change(self.check_completion.isChecked()) # Conexiones self.check_completion.stateChanged[int].connect(self._state_change) # Configuration self.check_key.setChecked( settings.get_setting('editor/complete-brace')) self.check_bracket.setChecked("[" in settings.BRACES) self.check_paren.setChecked("(" in settings.BRACES) self.check_quote.setChecked('""' in settings.QUOTES) #settings.get_setting('editor/complete-double-quote')) self.check_single_quote.setChecked("''" in settings.QUOTES) #settings.get_setting('editor/complete-single-quote')) self.check_completion.setChecked( settings.get_setting('editor/completion')) self.spin_threshold.setValue( settings.get_setting('editor/completion-threshold')) self.check_keywords.setChecked( settings.get_setting('editor/completion-keywords')) self.check_document.setChecked( settings.get_setting('editor/completion-document')) self.check_cs.setChecked(settings.get_setting('editor/completion-cs')) self.check_replace_word.setChecked( settings.get_setting('editor/completion-replace-word')) self.check_show_single.setChecked( settings.get_setting('editor/completion-single'))
def _load_font(self): font = settings.get_setting('editor/font') self.combo_font.setCurrentFont(QFont(font))
def __init__(self): super(DisplaySection, self).__init__() EditorConfiguration.install_widget(self.tr("Visualización"), self) container = QVBoxLayout(self) # Text wrapping group_wrapping = QGroupBox(self.tr("Ajuste de Texto:")) box = QGridLayout(group_wrapping) self.check_wrap = QCheckBox(self.tr("Activar ajuste de texto")) box.addWidget(self.check_wrap, 0, 0) self.check_margin = QCheckBox(self.tr("Mostrar márgen derecho:")) box.addWidget(self.check_margin, 1, 0) self.slider_margin = QSlider(Qt.Horizontal) self.slider_margin.setMaximum(180) self.slider_margin.setFixedWidth(350) box.addWidget(self.slider_margin, 1, 1, Qt.AlignLeft) lcd_margin = QLCDNumber() lcd_margin.setSegmentStyle(QLCDNumber.Flat) box.addWidget(lcd_margin, 1, 2, Qt.AlignLeft) box.setAlignment(Qt.AlignLeft) container.addWidget(group_wrapping) # Add group # Extras: line number, markers, whitespace, etc group_extras = QGroupBox(self.tr("Visualización:")) box = QGridLayout(group_extras) self.check_line_numbers = QCheckBox( self.tr("Mostrar números de líneas")) box.addWidget(self.check_line_numbers, 0, 0) self.check_current_line = QCheckBox(self.tr("Resaltar línea actual")) box.addWidget(self.check_current_line, 0, 1) self.check_mark_change = QCheckBox(self.tr("Marcar línea modificada")) box.addWidget(self.check_mark_change, 1, 0) self.check_match_brace = QCheckBox(self.tr("Resaltar [], {}, (), <>")) box.addWidget(self.check_match_brace, 1, 1) self.check_whitespace = QCheckBox( self.tr("Mostrar espacios en blanco")) box.addWidget(self.check_whitespace, 2, 0) self.check_guides = QCheckBox(self.tr("Mostrar guías de indentación")) box.addWidget(self.check_guides, 2, 1) self.check_eof = QCheckBox(self.tr("Mostrar EOF")) box.addWidget(self.check_eof, 3, 0) container.addWidget(group_extras) # Add group # Spacer container.addItem( QSpacerItem(0, 10, QSizePolicy.Expanding, QSizePolicy.Expanding)) # Connections self.slider_margin.valueChanged[int].connect(lcd_margin.display) # Configuration self.check_wrap.setChecked(settings.get_setting('editor/wrap-mode')) self.check_line_numbers.setChecked( settings.get_setting('editor/show-line-number')) self.check_mark_change.setChecked( settings.get_setting('editor/mark-change')) self.check_match_brace.setChecked( settings.get_setting('editor/match-brace')) self.check_current_line.setChecked( settings.get_setting('editor/show-caret-line')) self.check_eof.setChecked(settings.get_setting('editor/eof')) self.check_margin.setChecked( settings.get_setting('editor/show-margin')) self.slider_margin.setValue( settings.get_setting('editor/width-margin')) self.check_whitespace.setChecked( settings.get_setting('editor/show-tabs-spaces')) self.check_guides.setChecked( settings.get_setting('editor/show-guides'))
def __init__(self, obj_file): super(Editor, self).__init__() self.obj_file = obj_file # Asociación con el objeto EdisFile self._font = None # Configuración use_tabs = settings.get_setting('editor/usetabs') self.setIndentationsUseTabs(use_tabs) self.setAutoIndent(settings.get_setting('editor/indent')) self.setBackspaceUnindents(True) # Quita el scrollbar self.send("sci_sethscrollbar", 0) # Configuración de indicadores self.send("sci_indicsetstyle", Editor.WORD_INDICATOR, "indic_box") self.send("sci_indicsetfore", Editor.WORD_INDICATOR, QColor("#FF0000")) self.send("sci_indicsetstyle", Editor.WARNING_INDICATOR, "indic_squiggle") self.send("sci_indicsetfore", Editor.WARNING_INDICATOR, QColor("#0000FF")) # Scheme self.scheme = editor_scheme.get_scheme( settings.get_setting('editor/scheme')) # Folding self.setFolding(QsciScintilla.PlainFoldStyle) # en márgen 2 self.setMarginWidth(3, 5) # 5px de espacios en márgen 3 self.send("sci_markersetfore", QsciScintilla.SC_MARKNUM_FOLDER, QColor(self.scheme['FoldMarkerFore'])) self.send("sci_markersetback", QsciScintilla.SC_MARKNUM_FOLDER, QColor(self.scheme['FoldMarkerBack'])) self.setFoldMarginColors(QColor(self.scheme['FoldMarginBack']), QColor(self.scheme['FoldMarginFore'])) # Marcadores self.markerDefine(QsciScintilla.SC_MARK_LEFTRECT, Editor.MARKER_MODIFIED) self.setMarkerBackgroundColor(QColor(226, 255, 141), Editor.MARKER_MODIFIED) self.markerDefine(QsciScintilla.SC_MARK_LEFTRECT, Editor.MARKER_SAVED) self.setMarkerBackgroundColor(QColor(55, 142, 103), Editor.MARKER_SAVED) # Actualiza flags (espacios en blanco, cursor, sidebar, etc) self.update_options() # Lexer self._lexer = lexer.Lexer() self.setLexer(self._lexer) # Autocompletado self.api = None if settings.get_setting('editor/completion'): self.active_code_completion() # Indentación self._indentation = settings.get_setting('editor/width-indent') self.send("sci_settabwidth", self._indentation) # Minimapa self.minimap = None if settings.get_setting('editor/minimap'): self.minimap = minimap.Minimap(self) self.connect(self, SIGNAL("textChanged()"), self.minimap.update_code) # Thread que busca palabras self.search_thread = editor_helpers.SearchThread() self.connect(self.search_thread, SIGNAL("foundWords(PyQt_PyObject)"), self.mark_words) # Analizador de estilo de código self.checker = None if settings.get_setting('editor/style-checker'): self.load_checker() # Fuente font = settings.get_setting('editor/font') font_size = settings.get_setting('editor/size-font') self.load_font(font, font_size) self.setMarginsBackgroundColor(QColor(self.scheme['SidebarBack'])) self.setMarginsForegroundColor(QColor(self.scheme['SidebarFore'])) # Línea actual self.send("sci_setcaretlinevisible", settings.get_setting('editor/show-caret-line')) self.send("sci_setcaretlineback", QColor(self.scheme['CaretLineBack'])) self.send("sci_setcaretfore", QColor(self.scheme['CaretLineFore'])) self.send("sci_setcaretlinebackalpha", self.scheme['CaretLineAlpha']) # Cursor caret_period = settings.get_setting('editor/cursor-period') self.send("sci_setcaretperiod", caret_period) # Márgen if settings.get_setting('editor/show-margin'): self.update_margin() # Brace matching self.setBraceMatching(int(settings.get_setting('editor/match-brace'))) self.setMatchedBraceBackgroundColor( QColor(self.scheme['MatchedBraceBack'])) self.setMatchedBraceForegroundColor( QColor(self.scheme['MatchedBraceFore'])) self.setUnmatchedBraceBackgroundColor( QColor(self.scheme['UnmatchedBraceBack'])) self.setUnmatchedBraceForegroundColor( QColor(self.scheme['UnmatchedBraceFore'])) # Selecciones Múltiples self.send("sci_setadditionalcaretfore", QColor(157, 64, 40)) self.send("sci_setadditionalcaretsblink", 1) self.send("sci_setadditionalselalpha", 100) self.send("sci_setmultipleselection", 1) self.send("sci_setadditionalselectiontyping", 1) # Conexiones self.connect(self, SIGNAL("linesChanged()"), self.update_sidebar) self.connect(self, SIGNAL("textChanged()"), self._add_marker_modified)
def set_brace_matching(self): match_brace = int(settings.get_setting('editor/match-brace')) self.setBraceMatching(match_brace)
def show_line_numbers(self): line_number = settings.get_setting('editor/show-line-number') self.setMarginLineNumbers(0, line_number) self.update_sidebar()
def run_edis(app): """ Se carga la interfáz """ DEBUG("Running Edis...") qsettings = QSettings(paths.CONFIGURACION, QSettings.IniFormat) # Ícono app.setWindowIcon(QIcon(":image/edis")) # Lenguaje local = QLocale.system().name() DEBUG("Loading language...") language = settings.get_setting('general/language') if language: edis_translator = QTranslator() edis_translator.load(os.path.join(paths.PATH, "extras", "i18n", language)) app.installTranslator(edis_translator) # Qt translator qtranslator = QTranslator() qtranslator.load("qt_" + local, QLibraryInfo.location( QLibraryInfo.TranslationsPath)) app.installTranslator(qtranslator) pixmap = QPixmap(":image/splash") # Splash screen show_splash = False if settings.get_setting('general/show-splash'): DEBUG("Showing splash...") splash = QSplashScreen(pixmap, Qt.WindowStaysOnTopHint) splash.setMask(pixmap.mask()) splash.show() app.processEvents() show_splash = True # Style Sheet style = settings.get_setting('window/style-sheet') path_style = None style_sheet = None if style == 'Edark': path_style = os.path.join(paths.PATH, 'extras', 'theme', 'edark.qss') elif style != 'Default': path_style = os.path.join(paths.EDIS, style + '.qss') if path_style is not None: with open(path_style, mode='r') as f: style_sheet = f.read() app.setStyleSheet(style_sheet) # Fuente en Tooltips QToolTip.setFont(QFont(settings.DEFAULT_FONT, 9)) # GUI if show_splash: alignment = Qt.AlignBottom | Qt.AlignLeft splash.showMessage("Loading UI...", alignment, Qt.white) DEBUG("Loading GUI...") edis = Edis() edis.show() # Archivos de última sesión files, recents_files, projects = [], [], [] projects = qsettings.value('general/projects') #FIXME: if projects is None: projects = [] if settings.get_setting('general/load-files'): DEBUG("Loading files and projects...") if show_splash: splash.showMessage("Loading files...", alignment, Qt.white) files = qsettings.value('general/files') if files is None: files = [] # Archivos recientes recents_files = qsettings.value('general/recents-files') if recents_files is None: recents_files = [] # Archivos desde línea de comandos files += cmd_parser.parse() edis.load_files_and_projects(files, recents_files, projects) if show_splash: splash.finish(edis) DEBUG("Edis is Ready!") sys.exit(app.exec_())
def show_tabs_and_spaces(self): weditor = self.get_active_editor() if weditor is not None: tabs_spaces = settings.get_setting('editor/show-tabs-spaces') settings.set_setting('editor/show-tabs-spaces', not tabs_spaces) weditor.update_options()
def __init__(self): super(GeneralSection, self).__init__() container = QVBoxLayout(self) # Inicio group_on_start = QGroupBox(self.tr("Al Iniciar:")) box = QVBoxLayout(group_on_start) box.setContentsMargins(20, 5, 20, 5) self.check_splash = QCheckBox(self.tr("Mostrar Splash")) self.check_splash.setChecked( settings.get_setting('general/show-splash')) box.addWidget(self.check_splash) self.check_on_start = QCheckBox(self.tr("Mostrar Página de Inicio")) show_start_page = settings.get_setting('general/show-start-page') self.check_on_start.setChecked(show_start_page) box.addWidget(self.check_on_start) self.check_load_files = QCheckBox( self.tr("Cargar archivos desde la " "última sesión")) load_files = settings.get_setting('general/load-files') self.check_load_files.setChecked(load_files) box.addWidget(self.check_load_files) container.addWidget(group_on_start) # Al salir group_on_exit = QGroupBox(self.tr("Al Salir:")) box = QVBoxLayout(group_on_exit) box.setContentsMargins(20, 5, 20, 5) self.check_on_exit = QCheckBox(self.tr("Confirmar Salida")) self.check_on_exit.setChecked( settings.get_setting('general/confirm-exit')) box.addWidget(self.check_on_exit) self.check_geometry = QCheckBox( self.tr("Guardar posición y tamaño de la ventana")) self.check_geometry.setChecked( settings.get_setting('window/store-size')) box.addWidget(self.check_geometry) container.addWidget(group_on_exit) # Notificaciones group_notifications = QGroupBox(self.tr("Notificaciones:")) box = QVBoxLayout(group_notifications) box.setContentsMargins(20, 5, 20, 5) self.check_updates = QCheckBox(self.tr("Buscar Actualizaciones")) self.check_updates.setChecked( settings.get_setting('general/check-updates')) box.addWidget(self.check_updates) container.addWidget(group_notifications) # Sistema if settings.IS_LINUX: group_terminal = QGroupBox(self.tr("Sistema:")) box = QHBoxLayout(group_terminal) box.addWidget(QLabel(self.tr("Ejecutar programa con:"))) self.line_terminal = QLineEdit() self.line_terminal.setAlignment(Qt.AlignLeft) self.line_terminal.setFixedWidth(300) self.line_terminal.setText(settings.get_setting('terminal')) box.addWidget(self.line_terminal, 1, Qt.AlignLeft) container.addWidget(group_terminal) # User Interface group_ui = QGroupBox(self.tr("Interfáz de Usuario:")) box = QGridLayout(group_ui) box.setContentsMargins(20, 5, 20, 5) box.addWidget(QLabel(self.tr("Tema:")), 0, 0) self.combo_theme = QComboBox() self.combo_theme.setFixedWidth(200) self._update_combo() index = self.combo_theme.findText( settings.get_setting('window/style-sheet')) self.combo_theme.setCurrentIndex(index) box.addWidget(self.combo_theme, 0, 1) self.combo_lang = QComboBox() self.combo_lang.setFixedWidth(200) box.addWidget(QLabel(self.tr("Idioma:")), 1, 0) box.addWidget(self.combo_lang, 1, 1) langs = os.listdir(os.path.join(paths.PATH, "extras", "i18n")) self.combo_lang.addItems(["Spanish"] + [lang[:-3] for lang in langs]) lang = settings.get_setting('general/language') index = 0 if not lang else self.combo_lang.findText(lang) self.combo_lang.setCurrentIndex(index) container.addWidget(group_ui) box.setAlignment(Qt.AlignLeft) # Reestablecer group_restart = QGroupBox(self.tr("Reestablecer:")) box = QHBoxLayout(group_restart) box.setContentsMargins(20, 5, 20, 5) btn_restart = QPushButton(self.tr("Reiniciar configuraciones")) btn_restart.setObjectName("custom") box.addWidget(btn_restart) box.addStretch(1) container.addWidget(group_restart) container.addItem( QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding)) # Conexiones btn_restart.clicked.connect(self._restart_configurations) self.combo_theme.currentIndexChanged[int].connect( self._change_style_sheet) # Install EnvironmentConfiguration.install_widget(self.tr("General"), self)
def __init__(self): super(GeneralSection, self).__init__() main_container = QVBoxLayout(self) # Tabs and indentation group_indentation = QGroupBox(self.tr("Indentación y Tabs:")) box = QGridLayout(group_indentation) box.setContentsMargins(20, 5, 20, 5) box.addWidget(QLabel(self.tr("Política:")), 0, 0) self.combo_tabs = QComboBox() self.combo_tabs.setFixedWidth(350) self.combo_tabs.addItems([ self.tr("Solo Espacios"), self.tr("Solo Tabulaciones"), ]) box.addWidget(self.combo_tabs, 0, 1) self.combo_tabs.setCurrentIndex( int(settings.get_setting('editor/usetabs'))) # Auto indent self.check_autoindent = QCheckBox(self.tr("Indentación Automática")) box.addWidget(self.check_autoindent, 1, 0) box.setAlignment(Qt.AlignLeft) self.check_autoindent.setChecked(settings.get_setting('editor/indent')) # Minimap group_minimap = QGroupBox(self.tr("Minimapa:")) box = QGridLayout(group_minimap) box.setContentsMargins(20, 5, 20, 5) self.check_minimap = QCheckBox( self.tr("Activar Minimapa (requiere reiniciar el Editor)")) self.check_minimap.setChecked(settings.get_setting('editor/minimap')) box.addWidget(self.check_minimap, 0, 0) #self.check_minimap_animation = QCheckBox(self.tr("Enable animation")) #self.check_minimap_animation.setChecked( #settings.get_setting('editor/minimap-animation')) #box.addWidget(self.check_minimap_animation, 1, 0) #box.addWidget(QLabel(self.tr("Size Area:")), 2, 0) #self.spin_area_minimap = QSpinBox() #self.spin_area_minimap.setFixedWidth(350) #box.addWidget(self.spin_area_minimap, 2, 1) box.setAlignment(Qt.AlignLeft) # Cursor group_caret = QGroupBox(self.tr("Cursor:")) box = QGridLayout(group_caret) box.setContentsMargins(20, 5, 20, 5) box.setAlignment(Qt.AlignLeft) # Type box.addWidget(QLabel(self.tr("Tipo:")), 0, 0) self.combo_caret = QComboBox() self.combo_caret.setFixedWidth(300) caret_types = [ self.tr('Invisible'), self.tr('Línea'), self.tr('Bloque') ] self.combo_caret.addItems(caret_types) index = settings.get_setting('editor/cursor') self.combo_caret.setCurrentIndex(index) box.addWidget(self.combo_caret, 0, 1) # Width box.addWidget(QLabel(self.tr("Ancho:")), 1, 0) self.spin_caret_width = QSpinBox() self.spin_caret_width.setFixedWidth(300) if index != 1: self.spin_caret_width.setEnabled(False) self.spin_caret_width.setRange(1, 3) self.spin_caret_width.setValue( settings.get_setting('editor/caret-width')) box.addWidget(self.spin_caret_width, 1, 1, Qt.AlignLeft) # Period box.addWidget(QLabel(self.tr("Período (ms):")), 2, 0) self.slider_caret_period = QSlider(Qt.Horizontal) self.slider_caret_period.setMaximum(500) self.slider_caret_period.setFixedWidth(300) box.addWidget(self.slider_caret_period, 2, 1, Qt.AlignLeft) lcd_caret = QLCDNumber() lcd_caret.setSegmentStyle(QLCDNumber.Flat) box.addWidget(lcd_caret, 2, 3) # Font group_typo = QGroupBox(self.tr("Fuente:")) box = QGridLayout(group_typo) box.setContentsMargins(20, 5, 20, 5) box.addWidget(QLabel(self.tr("Familia:")), 0, 0) self.combo_font = QFontComboBox() self.combo_font.setFixedWidth(350) box.addWidget(self.combo_font, 0, 1) self._load_font() box.addWidget(QLabel(self.tr("Tamaño:")), 1, 0) self.spin_size_font = QSpinBox() self.spin_size_font.setValue(settings.get_setting('editor/size-font')) self.spin_size_font.setFixedWidth(350) box.addWidget(self.spin_size_font, 1, 1) box.setAlignment(Qt.AlignLeft) # Scheme group_scheme = QGroupBox(self.tr("Tema:")) box = QVBoxLayout(group_scheme) box.setContentsMargins(20, 5, 20, 5) self.combo_scheme = QComboBox() self.combo_scheme.setFixedWidth(350) self.combo_scheme.addItems(['Dark Edis', 'White Edis']) scheme = settings.get_setting('editor/scheme') index = 0 if scheme != 'dark': index = 1 self.combo_scheme.setCurrentIndex(index) box.addWidget(self.combo_scheme) box.addWidget(QLabel(self.tr("Requiere reiniciar Edis"))) ## Agrupación main_container.addWidget(group_indentation) main_container.addWidget(group_minimap) main_container.addWidget(group_caret) main_container.addWidget(group_typo) main_container.addWidget(group_scheme) main_container.addItem(QSpacerItem(0, 10, QSizePolicy.Expanding, QSizePolicy.Expanding)) EditorConfiguration.install_widget(self.tr("General"), self) # Conexiones self.combo_scheme.currentIndexChanged['const QString&'].connect( self._change_scheme) self.combo_caret.currentIndexChanged[int].connect( self._caret_type_changed) self.slider_caret_period.valueChanged[int].connect( lcd_caret.display) self.slider_caret_period.setValue( settings.get_setting('editor/cursor-period'))
def __init__(self): super(CompletionSection, self).__init__() EditorConfiguration.install_widget(self.tr("Autocompletado"), self) container = QVBoxLayout(self) group_complete = QGroupBox(self.tr("Completar:")) box = QGridLayout(group_complete) box.setContentsMargins(20, 5, 20, 5) self.check_bracket = QCheckBox(self.tr("Corchetes []")) box.addWidget(self.check_bracket, 0, 0) self.check_paren = QCheckBox(self.tr("Paréntesis ()")) box.addWidget(self.check_paren, 0, 1) self.check_key = QCheckBox(self.tr("Llaves {}")) box.addWidget(self.check_key, 1, 0) self.check_quote = QCheckBox(self.tr("Comillas Dobles \" \"")) box.addWidget(self.check_quote, 1, 1) self.check_single_quote = QCheckBox(self.tr("Comillas Simples ' '")) box.addWidget(self.check_single_quote, 2, 0) group_completion = QGroupBox(self.tr("Completado de Código:")) box = QGridLayout(group_completion) box.setContentsMargins(20, 5, 20, 5) self.check_completion = QCheckBox(self.tr("Activar Completado")) box.addWidget(self.check_completion, 0, 0) self.check_document = QCheckBox(self.tr("Basado en el código")) box.addWidget(self.check_document, 0, 1) self.check_keywords = QCheckBox(self.tr("Palabras Claves")) box.addWidget(self.check_keywords, 1, 0) self.check_cs = QCheckBox( self.tr("Sensitivo a mayúsculas y minúsculas")) box.addWidget(self.check_cs, 1, 1) self.check_replace_word = QCheckBox(self.tr("Reemplazar Palabra")) box.addWidget(self.check_replace_word, 2, 0) self.check_show_single = QCheckBox(self.tr("Mostrar Simple")) box.addWidget(self.check_show_single, 2, 1) hbox = QHBoxLayout() hbox.addWidget(QLabel( self.tr("Número de caractéres para mostrar lista:"))) self.spin_threshold = QSpinBox() self.spin_threshold.setMinimum(1) self.spin_threshold.setFixedWidth(100) hbox.addWidget(self.spin_threshold) box.addLayout(hbox, 3, 0, Qt.AlignLeft) # Agrupo al contenedor principal container.addWidget(group_complete) container.addWidget(group_completion) container.addItem(QSpacerItem(0, 10, QSizePolicy.Expanding, QSizePolicy.Expanding)) self._state_change(self.check_completion.isChecked()) # Conexiones self.check_completion.stateChanged[int].connect(self._state_change) # Configuration self.check_key.setChecked( settings.get_setting('editor/complete-brace')) self.check_bracket.setChecked("[" in settings.BRACES) self.check_paren.setChecked("(" in settings.BRACES) self.check_quote.setChecked('""' in settings.QUOTES) #settings.get_setting('editor/complete-double-quote')) self.check_single_quote.setChecked("''" in settings.QUOTES) #settings.get_setting('editor/complete-single-quote')) self.check_completion.setChecked( settings.get_setting('editor/completion')) self.spin_threshold.setValue( settings.get_setting('editor/completion-threshold')) self.check_keywords.setChecked( settings.get_setting('editor/completion-keywords')) self.check_document.setChecked( settings.get_setting('editor/completion-document')) self.check_cs.setChecked( settings.get_setting('editor/completion-cs')) self.check_replace_word.setChecked( settings.get_setting('editor/completion-replace-word')) self.check_show_single.setChecked( settings.get_setting('editor/completion-single'))
def __init__(self): super(DisplaySection, self).__init__() EditorConfiguration.install_widget(self.tr("Visualización"), self) container = QVBoxLayout(self) # Text wrapping group_wrapping = QGroupBox(self.tr("Ajuste de Texto:")) box = QGridLayout(group_wrapping) self.check_wrap = QCheckBox(self.tr("Activar ajuste de texto")) box.addWidget(self.check_wrap, 0, 0) self.check_margin = QCheckBox(self.tr("Mostrar márgen derecho:")) box.addWidget(self.check_margin, 1, 0) self.slider_margin = QSlider(Qt.Horizontal) self.slider_margin.setMaximum(180) self.slider_margin.setFixedWidth(350) box.addWidget(self.slider_margin, 1, 1, Qt.AlignLeft) lcd_margin = QLCDNumber() lcd_margin.setSegmentStyle(QLCDNumber.Flat) box.addWidget(lcd_margin, 1, 2, Qt.AlignLeft) box.setAlignment(Qt.AlignLeft) container.addWidget(group_wrapping) # Add group # Extras: line number, markers, whitespace, etc group_extras = QGroupBox(self.tr("Visualización:")) box = QGridLayout(group_extras) self.check_line_numbers = QCheckBox( self.tr("Mostrar números de líneas")) box.addWidget(self.check_line_numbers, 0, 0) self.check_current_line = QCheckBox(self.tr("Resaltar línea actual")) box.addWidget(self.check_current_line, 0, 1) self.check_mark_change = QCheckBox(self.tr("Marcar línea modificada")) box.addWidget(self.check_mark_change, 1, 0) self.check_match_brace = QCheckBox( self.tr("Resaltar [], {}, (), <>")) box.addWidget(self.check_match_brace, 1, 1) self.check_whitespace = QCheckBox( self.tr("Mostrar espacios en blanco")) box.addWidget(self.check_whitespace, 2, 0) self.check_guides = QCheckBox(self.tr("Mostrar guías de indentación")) box.addWidget(self.check_guides, 2, 1) self.check_eof = QCheckBox(self.tr("Mostrar EOF")) box.addWidget(self.check_eof, 3, 0) container.addWidget(group_extras) # Add group # Spacer container.addItem(QSpacerItem(0, 10, QSizePolicy.Expanding, QSizePolicy.Expanding)) # Connections self.slider_margin.valueChanged[int].connect(lcd_margin.display) # Configuration self.check_wrap.setChecked( settings.get_setting('editor/wrap-mode')) self.check_line_numbers.setChecked( settings.get_setting('editor/show-line-number')) self.check_mark_change.setChecked( settings.get_setting('editor/mark-change')) self.check_match_brace.setChecked( settings.get_setting('editor/match-brace')) self.check_current_line.setChecked( settings.get_setting('editor/show-caret-line')) self.check_eof.setChecked( settings.get_setting('editor/eof')) self.check_margin.setChecked( settings.get_setting('editor/show-margin')) self.slider_margin.setValue(settings.get_setting('editor/width-margin')) self.check_whitespace.setChecked( settings.get_setting('editor/show-tabs-spaces')) self.check_guides.setChecked( settings.get_setting('editor/show-guides'))
def __init__(self): super(GeneralSection, self).__init__() main_container = QVBoxLayout(self) # Tabs and indentation group_indentation = QGroupBox(self.tr("Indentación y Tabs:")) box = QGridLayout(group_indentation) box.setContentsMargins(20, 5, 20, 5) box.addWidget(QLabel(self.tr("Política:")), 0, 0) self.combo_tabs = QComboBox() self.combo_tabs.setFixedWidth(350) self.combo_tabs.addItems([ self.tr("Solo Espacios"), self.tr("Solo Tabulaciones"), ]) box.addWidget(self.combo_tabs, 0, 1) self.combo_tabs.setCurrentIndex( int(settings.get_setting('editor/usetabs'))) # Auto indent self.check_autoindent = QCheckBox(self.tr("Indentación Automática")) box.addWidget(self.check_autoindent, 1, 0) box.setAlignment(Qt.AlignLeft) self.check_autoindent.setChecked(settings.get_setting('editor/indent')) # Minimap group_minimap = QGroupBox(self.tr("Minimapa:")) box = QGridLayout(group_minimap) box.setContentsMargins(20, 5, 20, 5) self.check_minimap = QCheckBox( self.tr("Activar Minimapa (requiere reiniciar el Editor)")) self.check_minimap.setChecked(settings.get_setting('editor/minimap')) box.addWidget(self.check_minimap, 0, 0) #self.check_minimap_animation = QCheckBox(self.tr("Enable animation")) #self.check_minimap_animation.setChecked( #settings.get_setting('editor/minimap-animation')) #box.addWidget(self.check_minimap_animation, 1, 0) #box.addWidget(QLabel(self.tr("Size Area:")), 2, 0) #self.spin_area_minimap = QSpinBox() #self.spin_area_minimap.setFixedWidth(350) #box.addWidget(self.spin_area_minimap, 2, 1) box.setAlignment(Qt.AlignLeft) # Cursor group_caret = QGroupBox(self.tr("Cursor:")) box = QGridLayout(group_caret) box.setContentsMargins(20, 5, 20, 5) box.setAlignment(Qt.AlignLeft) # Type box.addWidget(QLabel(self.tr("Tipo:")), 0, 0) self.combo_caret = QComboBox() self.combo_caret.setFixedWidth(300) caret_types = [ self.tr('Invisible'), self.tr('Línea'), self.tr('Bloque') ] self.combo_caret.addItems(caret_types) index = settings.get_setting('editor/cursor') self.combo_caret.setCurrentIndex(index) box.addWidget(self.combo_caret, 0, 1) # Width box.addWidget(QLabel(self.tr("Ancho:")), 1, 0) self.spin_caret_width = QSpinBox() self.spin_caret_width.setFixedWidth(300) if index != 1: self.spin_caret_width.setEnabled(False) self.spin_caret_width.setRange(1, 3) self.spin_caret_width.setValue( settings.get_setting('editor/caret-width')) box.addWidget(self.spin_caret_width, 1, 1, Qt.AlignLeft) # Period box.addWidget(QLabel(self.tr("Período (ms):")), 2, 0) self.slider_caret_period = QSlider(Qt.Horizontal) self.slider_caret_period.setMaximum(500) self.slider_caret_period.setFixedWidth(300) box.addWidget(self.slider_caret_period, 2, 1, Qt.AlignLeft) lcd_caret = QLCDNumber() lcd_caret.setSegmentStyle(QLCDNumber.Flat) box.addWidget(lcd_caret, 2, 3) # Font group_typo = QGroupBox(self.tr("Fuente:")) box = QGridLayout(group_typo) box.setContentsMargins(20, 5, 20, 5) box.addWidget(QLabel(self.tr("Familia:")), 0, 0) self.combo_font = QFontComboBox() self.combo_font.setFixedWidth(350) box.addWidget(self.combo_font, 0, 1) self._load_font() box.addWidget(QLabel(self.tr("Tamaño:")), 1, 0) self.spin_size_font = QSpinBox() self.spin_size_font.setValue(settings.get_setting('editor/size-font')) self.spin_size_font.setFixedWidth(350) box.addWidget(self.spin_size_font, 1, 1) box.setAlignment(Qt.AlignLeft) # Scheme group_scheme = QGroupBox(self.tr("Tema:")) box = QVBoxLayout(group_scheme) box.setContentsMargins(20, 5, 20, 5) self.combo_scheme = QComboBox() self.combo_scheme.setFixedWidth(350) self.combo_scheme.addItems(['Dark Edis', 'White Edis']) scheme = settings.get_setting('editor/scheme') index = 0 if scheme != 'dark': index = 1 self.combo_scheme.setCurrentIndex(index) box.addWidget(self.combo_scheme) box.addWidget(QLabel(self.tr("Requiere reiniciar Edis"))) ## Agrupación main_container.addWidget(group_indentation) main_container.addWidget(group_minimap) main_container.addWidget(group_caret) main_container.addWidget(group_typo) main_container.addWidget(group_scheme) main_container.addItem( QSpacerItem(0, 10, QSizePolicy.Expanding, QSizePolicy.Expanding)) EditorConfiguration.install_widget(self.tr("General"), self) # Conexiones self.combo_scheme.currentIndexChanged['const QString&'].connect( self._change_scheme) self.combo_caret.currentIndexChanged[int].connect( self._caret_type_changed) self.slider_caret_period.valueChanged[int].connect(lcd_caret.display) self.slider_caret_period.setValue( settings.get_setting('editor/cursor-period'))
def show_indentation_guides(self): weditor = self.get_active_editor() if weditor is not None: guides = settings.get_setting('editor/show-guides') settings.set_setting('editor/show-guides', not guides) weditor.update_options()
def update_indentation(self): ancho = settings.get_setting('editor/width-indent') self.send("sci_settabwidth", ancho) self._indentation = ancho
def run_edis(app): """ Se carga la interfáz """ DEBUG("Running Edis...") qsettings = QSettings(paths.CONFIGURACION, QSettings.IniFormat) # Ícono app.setWindowIcon(QIcon(":image/edis")) # Lenguaje local = QLocale.system().name() DEBUG("Loading language...") language = settings.get_setting('general/language') if language: edis_translator = QTranslator() edis_translator.load( os.path.join(paths.PATH, "extras", "i18n", language)) app.installTranslator(edis_translator) # Qt translator qtranslator = QTranslator() qtranslator.load("qt_" + local, QLibraryInfo.location(QLibraryInfo.TranslationsPath)) app.installTranslator(qtranslator) pixmap = QPixmap(":image/splash") # Splash screen show_splash = False if settings.get_setting('general/show-splash'): DEBUG("Showing splash...") splash = QSplashScreen(pixmap, Qt.WindowStaysOnTopHint) splash.setMask(pixmap.mask()) splash.show() app.processEvents() show_splash = True # Style Sheet style = settings.get_setting('window/style-sheet') path_style = None style_sheet = None if style == 'Edark': path_style = os.path.join(paths.PATH, 'extras', 'theme', 'edark.qss') elif style != 'Default': path_style = os.path.join(paths.EDIS, style + '.qss') if path_style is not None: with open(path_style, mode='r') as f: style_sheet = f.read() app.setStyleSheet(style_sheet) # Fuente en Tooltips QToolTip.setFont(QFont(settings.DEFAULT_FONT, 9)) # GUI if show_splash: alignment = Qt.AlignBottom | Qt.AlignLeft splash.showMessage("Loading UI...", alignment, Qt.white) DEBUG("Loading GUI...") edis = Edis() edis.show() # Archivos de última sesión files, recents_files, projects = [], [], [] projects = qsettings.value('general/projects') #FIXME: if projects is None: projects = [] if settings.get_setting('general/load-files'): DEBUG("Loading files and projects...") if show_splash: splash.showMessage("Loading files...", alignment, Qt.white) files = qsettings.value('general/files') if files is None: files = [] # Archivos recientes recents_files = qsettings.value('general/recents-files') if recents_files is None: recents_files = [] # Archivos desde línea de comandos files += cmd_parser.parse() edis.load_files_and_projects(files, recents_files, projects) if show_splash: splash.finish(edis) DEBUG("Edis is Ready!") sys.exit(app.exec_())
def __init__(self, obj_file): super(Editor, self).__init__() self.obj_file = obj_file # Asociación con el objeto EdisFile self._font = None # Configuración use_tabs = settings.get_setting('editor/usetabs') self.setIndentationsUseTabs(use_tabs) self.setAutoIndent(settings.get_setting('editor/indent')) self.setBackspaceUnindents(True) # Quita el scrollbar self.send("sci_sethscrollbar", 0) # Configuración de indicadores self.send("sci_indicsetstyle", Editor.WORD_INDICATOR, "indic_box") self.send("sci_indicsetfore", Editor.WORD_INDICATOR, QColor("#FF0000")) self.send("sci_indicsetstyle", Editor.WARNING_INDICATOR, "indic_squiggle") self.send("sci_indicsetfore", Editor.WARNING_INDICATOR, QColor("#0000FF")) # Scheme self.scheme = editor_scheme.get_scheme( settings.get_setting('editor/scheme')) # Folding self.setFolding(QsciScintilla.PlainFoldStyle) # en márgen 2 self.setMarginWidth(3, 5) # 5px de espacios en márgen 3 self.send("sci_markersetfore", QsciScintilla.SC_MARKNUM_FOLDER, QColor(self.scheme['FoldMarkerFore'])) self.send("sci_markersetback", QsciScintilla.SC_MARKNUM_FOLDER, QColor(self.scheme['FoldMarkerBack'])) self.setFoldMarginColors(QColor(self.scheme['FoldMarginBack']), QColor(self.scheme['FoldMarginFore'])) # Marcadores self.markerDefine(QsciScintilla.SC_MARK_LEFTRECT, Editor.MARKER_MODIFIED) self.setMarkerBackgroundColor( QColor(226, 255, 141), Editor.MARKER_MODIFIED) self.markerDefine(QsciScintilla.SC_MARK_LEFTRECT, Editor.MARKER_SAVED) self.setMarkerBackgroundColor(QColor(55, 142, 103), Editor.MARKER_SAVED) # Actualiza flags (espacios en blanco, cursor, sidebar, etc) self.update_options() # Lexer self._lexer = lexer.Lexer() self.setLexer(self._lexer) # Autocompletado self.api = None if settings.get_setting('editor/completion'): self.active_code_completion() # Indentación self._indentation = settings.get_setting('editor/width-indent') self.send("sci_settabwidth", self._indentation) # Minimapa self.minimap = None if settings.get_setting('editor/minimap'): self.minimap = minimap.Minimap(self) self.connect(self, SIGNAL("textChanged()"), self.minimap.update_code) # Thread que busca palabras self.search_thread = editor_helpers.SearchThread() self.connect(self.search_thread, SIGNAL("foundWords(PyQt_PyObject)"), self.mark_words) # Analizador de estilo de código self.checker = None if settings.get_setting('editor/style-checker'): self.load_checker() # Fuente font = settings.get_setting('editor/font') font_size = settings.get_setting('editor/size-font') self.load_font(font, font_size) self.setMarginsBackgroundColor(QColor(self.scheme['SidebarBack'])) self.setMarginsForegroundColor(QColor(self.scheme['SidebarFore'])) # Línea actual self.send("sci_setcaretlinevisible", settings.get_setting('editor/show-caret-line')) self.send("sci_setcaretlineback", QColor(self.scheme['CaretLineBack'])) self.send("sci_setcaretfore", QColor(self.scheme['CaretLineFore'])) self.send("sci_setcaretlinebackalpha", self.scheme['CaretLineAlpha']) # Cursor caret_period = settings.get_setting('editor/cursor-period') self.send("sci_setcaretperiod", caret_period) # Márgen if settings.get_setting('editor/show-margin'): self.update_margin() # Brace matching self.setBraceMatching(int(settings.get_setting('editor/match-brace'))) self.setMatchedBraceBackgroundColor(QColor( self.scheme['MatchedBraceBack'])) self.setMatchedBraceForegroundColor(QColor( self.scheme['MatchedBraceFore'])) self.setUnmatchedBraceBackgroundColor(QColor( self.scheme['UnmatchedBraceBack'])) self.setUnmatchedBraceForegroundColor(QColor( self.scheme['UnmatchedBraceFore'])) # Selecciones Múltiples self.send("sci_setadditionalcaretfore", QColor(157, 64, 40)) self.send("sci_setadditionalcaretsblink", 1) self.send("sci_setadditionalselalpha", 100) self.send("sci_setmultipleselection", 1) self.send("sci_setadditionalselectiontyping", 1) # Conexiones self.connect(self, SIGNAL("linesChanged()"), self.update_sidebar) self.connect(self, SIGNAL("textChanged()"), self._add_marker_modified)
def __init__(self): super(GeneralSection, self).__init__() container = QVBoxLayout(self) # Inicio group_on_start = QGroupBox(self.tr("Al Iniciar:")) box = QVBoxLayout(group_on_start) box.setContentsMargins(20, 5, 20, 5) self.check_splash = QCheckBox(self.tr("Mostrar Splash")) self.check_splash.setChecked( settings.get_setting('general/show-splash')) box.addWidget(self.check_splash) self.check_on_start = QCheckBox(self.tr("Mostrar Página de Inicio")) show_start_page = settings.get_setting('general/show-start-page') self.check_on_start.setChecked(show_start_page) box.addWidget(self.check_on_start) self.check_load_files = QCheckBox(self.tr("Cargar archivos desde la " "última sesión")) load_files = settings.get_setting('general/load-files') self.check_load_files.setChecked(load_files) box.addWidget(self.check_load_files) container.addWidget(group_on_start) # Al salir group_on_exit = QGroupBox(self.tr("Al Salir:")) box = QVBoxLayout(group_on_exit) box.setContentsMargins(20, 5, 20, 5) self.check_on_exit = QCheckBox(self.tr("Confirmar Salida")) self.check_on_exit.setChecked( settings.get_setting('general/confirm-exit')) box.addWidget(self.check_on_exit) self.check_geometry = QCheckBox(self.tr( "Guardar posición y tamaño de la ventana")) self.check_geometry.setChecked( settings.get_setting('window/store-size')) box.addWidget(self.check_geometry) container.addWidget(group_on_exit) # Notificaciones group_notifications = QGroupBox(self.tr("Notificaciones:")) box = QVBoxLayout(group_notifications) box.setContentsMargins(20, 5, 20, 5) self.check_updates = QCheckBox(self.tr("Buscar Actualizaciones")) self.check_updates.setChecked( settings.get_setting('general/check-updates')) box.addWidget(self.check_updates) container.addWidget(group_notifications) # Sistema if settings.IS_LINUX: group_terminal = QGroupBox(self.tr("Sistema:")) box = QHBoxLayout(group_terminal) box.addWidget(QLabel(self.tr("Ejecutar programa con:"))) self.line_terminal = QLineEdit() self.line_terminal.setAlignment(Qt.AlignLeft) self.line_terminal.setFixedWidth(300) self.line_terminal.setText(settings.get_setting('terminal')) box.addWidget(self.line_terminal, 1, Qt.AlignLeft) container.addWidget(group_terminal) # User Interface group_ui = QGroupBox(self.tr("Interfáz de Usuario:")) box = QGridLayout(group_ui) box.setContentsMargins(20, 5, 20, 5) box.addWidget(QLabel(self.tr("Tema:")), 0, 0) self.combo_theme = QComboBox() self.combo_theme.setFixedWidth(200) self._update_combo() index = self.combo_theme.findText( settings.get_setting('window/style-sheet')) self.combo_theme.setCurrentIndex(index) box.addWidget(self.combo_theme, 0, 1) self.combo_lang = QComboBox() self.combo_lang.setFixedWidth(200) box.addWidget(QLabel(self.tr("Idioma:")), 1, 0) box.addWidget(self.combo_lang, 1, 1) langs = os.listdir(os.path.join(paths.PATH, "extras", "i18n")) self.combo_lang.addItems(["Spanish"] + [lang[:-3] for lang in langs]) lang = settings.get_setting('general/language') index = 0 if not lang else self.combo_lang.findText(lang) self.combo_lang.setCurrentIndex(index) container.addWidget(group_ui) box.setAlignment(Qt.AlignLeft) # Reestablecer group_restart = QGroupBox(self.tr("Reestablecer:")) box = QHBoxLayout(group_restart) box.setContentsMargins(20, 5, 20, 5) btn_restart = QPushButton(self.tr("Reiniciar configuraciones")) btn_restart.setObjectName("custom") box.addWidget(btn_restart) box.addStretch(1) container.addWidget(group_restart) container.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding)) # Conexiones btn_restart.clicked.connect(self._restart_configurations) self.combo_theme.currentIndexChanged[int].connect( self._change_style_sheet) # Install EnvironmentConfiguration.install_widget(self.tr("General"), self)