class PageProjectProperties(QWizardPage): def __init__(self): QWizardPage.__init__(self) self.setTitle('New Project Data') self.setSubTitle( 'Complete the following fields to create the Project Structure') g_box = QGridLayout(self) #Names of the blanks to complete self.lbl_Name = QLabel('New Project Name:') self.lbl_Place = QLabel('Project Location:') self.lbl_Folder = QLabel('Projet Folder:') self.lbl_Description = QLabel('Project Description:') self.lbl_License = QLabel('Project License:') g_box.addWidget(self.lbl_Name, 0, 0, Qt.AlignRight) g_box.addWidget(self.lbl_Place, 1, 0, Qt.AlignRight) g_box.addWidget(self.lbl_Folder, 2, 0, Qt.AlignRight) g_box.addWidget(self.lbl_Description, 3, 0, Qt.AlignTop) g_box.addWidget(self.lbl_License, 4, 0, Qt.AlignRight) #Blanks on de right of the grid self.txtName = QLineEdit() self.registerField('projectName*', self.txtName) #Here comes a LineEdit and a PushButton in a HBoxLayout h_Place = QHBoxLayout() self.txtPlace = QLineEdit() self.txtPlace.setReadOnly(True) self.registerField('place*', self.txtPlace) self.btnExamine = QPushButton('Examine...') h_Place.addWidget(self.txtPlace) h_Place.addWidget(self.btnExamine) #Now lets continue with the rest self.txtFolder = QLineEdit() self.txtDescription = QPlainTextEdit() self.cboLicense = QComboBox() self.cboLicense.setFixedWidth(250) self.cboLicense.addItem('Apache License 2.0') self.cboLicense.addItem('Artistic License/GPL') self.cboLicense.addItem('Eclipse Public License 1.0') self.cboLicense.addItem('GNU General Public License v2') self.cboLicense.addItem('GNU General Public License v3') self.cboLicense.addItem('GNU Lesser General Public License') self.cboLicense.addItem('MIT License') self.cboLicense.addItem('Mozilla Public License 1.1') self.cboLicense.addItem('New BSD License') self.cboLicense.addItem('Other Open Source') self.cboLicense.addItem('Other') self.cboLicense.setCurrentIndex(4) g_box.addWidget(self.txtName, 0, 1) g_box.addLayout(h_Place, 1, 1) g_box.addWidget(self.txtFolder, 2, 1) g_box.addWidget(self.txtDescription, 3, 1) g_box.addWidget(self.cboLicense, 4, 1) #Signal self.connect(self.btnExamine, SIGNAL('clicked()'), self.load_folder) def load_folder(self): self.txtPlace.setText( str(QFileDialog.getExistingDirectory(self, 'New Project Folder')))
class PageProjectProperties(QWizardPage): def __init__(self): QWizardPage.__init__(self) self.setTitle('New Project Data') self.setSubTitle('Complete the following fields to create the Project Structure') g_box = QGridLayout(self) #Names of the blanks to complete self.lbl_Name = QLabel('New Project Name:') self.lbl_Place = QLabel('Project Location:') self.lbl_Folder = QLabel('Projet Folder:') self.lbl_Description = QLabel('Project Description:') self.lbl_License = QLabel('Project License:') g_box.addWidget(self.lbl_Name, 0, 0,Qt.AlignRight) g_box.addWidget(self.lbl_Place, 1, 0,Qt.AlignRight) g_box.addWidget(self.lbl_Folder, 2, 0,Qt.AlignRight) g_box.addWidget(self.lbl_Description, 3, 0,Qt.AlignTop) g_box.addWidget(self.lbl_License, 4, 0,Qt.AlignRight) #Blanks on de right of the grid self.txtName = QLineEdit() self.registerField('projectName*', self.txtName) #Here comes a LineEdit and a PushButton in a HBoxLayout h_Place = QHBoxLayout() self.txtPlace = QLineEdit() self.txtPlace.setReadOnly(True) self.registerField('place*', self.txtPlace) self.btnExamine = QPushButton('Examine...') h_Place.addWidget(self.txtPlace) h_Place.addWidget(self.btnExamine) #Now lets continue with the rest self.txtFolder = QLineEdit() self.txtDescription = QPlainTextEdit() self.cboLicense = QComboBox() self.cboLicense.setFixedWidth(250) self.cboLicense.addItem('Apache License 2.0') self.cboLicense.addItem('Artistic License/GPL') self.cboLicense.addItem('Eclipse Public License 1.0') self.cboLicense.addItem('GNU General Public License v2') self.cboLicense.addItem('GNU General Public License v3') self.cboLicense.addItem('GNU Lesser General Public License') self.cboLicense.addItem('MIT License') self.cboLicense.addItem('Mozilla Public License 1.1') self.cboLicense.addItem('New BSD License') self.cboLicense.addItem('Other Open Source') self.cboLicense.addItem('Other') self.cboLicense.setCurrentIndex(4) g_box.addWidget(self.txtName, 0,1) g_box.addLayout(h_Place, 1, 1) g_box.addWidget(self.txtFolder, 2,1) g_box.addWidget(self.txtDescription, 3,1) g_box.addWidget(self.cboLicense, 4,1) #Signal self.connect(self.btnExamine, SIGNAL('clicked()'), self.load_folder) def load_folder(self): self.txtPlace.setText(str(QFileDialog.getExistingDirectory(self, 'New Project Folder')))
def add_combo_box( self, choicesL, index_init=0, name='cycle_desc', advance_n=True, fulldesc='Select Engine Cycle', text_align='right', text_font=ARIAL_10, col=0, width=100, parent=None, layout=None): # if parent is input, add widget to parent if parent is None: parent = self if layout is None: NRow = parent.get_next_row_number(advance_n) lbl = QLabel(" %s "%fulldesc, parent) combo_box = QComboBox(parent) lbl.setFont( text_font ) combo_box.setFont( text_font ) self.objectD['%s_combo_box'%name] = combo_box for choice in choicesL: combo_box.addItem(choice) combo_box.setCurrentIndex(index_init) if layout is None: parent.grid.addWidget(lbl, NRow, col) else: layout.addWidget( lbl ) hbox = QHBoxLayout() hbox.addWidget(combo_box) hbox.addStretch(1) widget = QWidget() widget.setLayout(hbox) if layout is None: parent.grid.addWidget(widget, NRow, col+1) if text_align=='right': parent.grid.setAlignment(lbl, Qt.AlignRight ) else: layout.addWidget( widget ) combo_box.setFixedWidth( width ) combo_box.activated[str].connect( lambda: self.combo_box_changed( '%s_combo_box'%name ) ) self.input_widget_by_nameD[name] = (combo_box, 'combo_box')
class GeneralSection(QWidget): 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 _update_combo(self): self.combo_theme.addItems(['Default', 'Edark']) list_dir = os.listdir(paths.EDIS) list_styles = [i.split('.')[0]for i in list_dir if os.path.splitext(i)[-1] == '.qss'] self.combo_theme.insertItems(2, list_styles) def _change_style_sheet(self, index): style_sheet = None path = None if index == 1: path = os.path.join(paths.PATH, "extras", "theme", "edark.qss") elif index != 0: style = self.combo_styles.currentText() + '.qss' path = os.path.join(paths.EDIS, style) if path is not None: with open(path, mode='r') as f: style_sheet = f.read() QApplication.instance().setStyleSheet(style_sheet) def _restart_configurations(self): flags = QMessageBox.Cancel flags |= QMessageBox.Yes result = QMessageBox.question(self, self.tr("Advertencia!"), self.tr("Está seguro que quiere " "reestablecer las " "configuraciones?"), flags) if result == QMessageBox.Cancel: return elif result == QMessageBox.Yes: QSettings(paths.CONFIGURACION, QSettings.IniFormat).clear() dialog_preferences = Edis.get_component("preferences") dialog_preferences.close() def save(self): settings.set_setting('general/show-splash', self.check_splash.isChecked()) show_start_page = self.check_on_start.isChecked() settings.set_setting('general/show-start-page', show_start_page) settings.set_setting('ventana/store-size', self.check_geometry.isChecked()) settings.set_setting('general/confirm-exit', self.check_on_exit.isChecked()) settings.set_setting('general/check-updates', self.check_updates.isChecked()) load_files = self.check_load_files.isChecked() settings.set_setting('general/load-files', load_files) lang = self.combo_lang.currentText() settings.set_setting('general/language', lang) if settings.IS_LINUX: settings.set_setting('terminal', self.line_terminal.text())
class PageProjectProperties(QWizardPage): def __init__(self): QWizardPage.__init__(self) self.setTitle(self.tr("New Project Data")) self.setSubTitle(self.tr( "Complete the following fields to create the Project Structure")) gbox = QGridLayout(self) #Names of the fields to complete self.lblName = QLabel(self.tr("New Project Name (*):")) self.lblPlace = QLabel(self.tr("Project Location (*):")) self.lblDescription = QLabel(self.tr("Project Description:")) self.lblLicense = QLabel(self.tr("Project License:")) self.lblVenvFolder = QLabel(self.tr("Virtualenv Folder:")) gbox.addWidget(self.lblName, 0, 0, Qt.AlignRight) gbox.addWidget(self.lblPlace, 1, 0, Qt.AlignRight) gbox.addWidget(self.lblDescription, 2, 0, Qt.AlignTop) gbox.addWidget(self.lblLicense, 3, 0, Qt.AlignRight) gbox.addWidget(self.lblVenvFolder, 4, 0, Qt.AlignRight) #Fields on de right of the grid #Name self.txtName = QLineEdit() #Location hPlace = QHBoxLayout() self.txtPlace = QLineEdit() self.txtPlace.setReadOnly(True) self.btnExamine = QPushButton(self.tr("Examine...")) hPlace.addWidget(self.txtPlace) hPlace.addWidget(self.btnExamine) #Virtualenv vPlace = QHBoxLayout() self.vtxtPlace = QLineEdit() self.vtxtPlace.setReadOnly(True) self.vbtnExamine = QPushButton(self.tr("Examine...")) vPlace.addWidget(self.vtxtPlace) vPlace.addWidget(self.vbtnExamine) #Project Description self.txtDescription = QPlainTextEdit() #Project License self.cboLicense = QComboBox() self.cboLicense.setFixedWidth(250) self.cboLicense.addItem('Apache License 2.0') self.cboLicense.addItem('Artistic License/GPL') self.cboLicense.addItem('Eclipse Public License 1.0') self.cboLicense.addItem('GNU General Public License v2') self.cboLicense.addItem('GNU General Public License v3') self.cboLicense.addItem('GNU Lesser General Public License') self.cboLicense.addItem('MIT License') self.cboLicense.addItem('Mozilla Public License 1.1') self.cboLicense.addItem('New BSD License') self.cboLicense.addItem('Other Open Source') self.cboLicense.addItem('Other') self.cboLicense.setCurrentIndex(4) #Add to Grid gbox.addWidget(self.txtName, 0, 1) gbox.addLayout(hPlace, 1, 1) gbox.addWidget(self.txtDescription, 2, 1) gbox.addWidget(self.cboLicense, 3, 1) gbox.addLayout(vPlace, 4, 1) #Signal self.connect(self.btnExamine, SIGNAL('clicked()'), self.load_folder) self.connect(self.vbtnExamine, SIGNAL('clicked()'), self.load_folder_venv) self.connect(self.txtName, SIGNAL('textChanged(const QString&)'), lambda: self.emit(SIGNAL("completeChanged()"))) def isComplete(self): name = unicode(self.txtName.text()).strip() place = unicode(self.txtPlace.text()).strip() return (len(name) > 0) and (len(place) > 0) def load_folder(self): self.txtPlace.setText(unicode(QFileDialog.getExistingDirectory( self, self.tr("New Project Folder")))) self.emit(SIGNAL("completeChanged()")) def load_folder_venv(self): self.vtxtPlace.setText(unicode(QFileDialog.getExistingDirectory( self, self.tr("Select Virtualenv Folder"))))
class PageProjectProperties(QWizardPage): def __init__(self): QWizardPage.__init__(self) self.setTitle(self.tr("New Project Data")) self.setSubTitle(self.tr( "Complete the following fields to create the Project Structure")) gbox = QGridLayout(self) #Names of the fields to complete self.lblName = QLabel(self.tr("New Project Name (*):")) self.lblPlace = QLabel(self.tr("Project Location (*):")) self.lblDescription = QLabel(self.tr("Project Description:")) self.lblLicense = QLabel(self.tr("Project License:")) self.lblVenvFolder = QLabel(self.tr("Virtualenv Folder:")) gbox.addWidget(self.lblName, 0, 0, Qt.AlignRight) gbox.addWidget(self.lblPlace, 1, 0, Qt.AlignRight) gbox.addWidget(self.lblDescription, 2, 0, Qt.AlignTop) gbox.addWidget(self.lblLicense, 3, 0, Qt.AlignRight) gbox.addWidget(self.lblVenvFolder, 4, 0, Qt.AlignRight) #Fields on de right of the grid #Name self.txtName = QLineEdit() #Location hPlace = QHBoxLayout() self.txtPlace = QLineEdit() self.txtPlace.setReadOnly(True) self.btnExamine = QPushButton(self.tr("Browse...")) hPlace.addWidget(self.txtPlace) hPlace.addWidget(self.btnExamine) #Virtualenv vPlace = QHBoxLayout() self.vtxtPlace = QLineEdit() self._dir_completer = QCompleter() self._dir_completer.setModel(QDirModel(self._dir_completer)) self.vtxtPlace.setCompleter(self._dir_completer) self.vbtnExamine = QPushButton(self.tr("Browse...")) vPlace.addWidget(self.vtxtPlace) vPlace.addWidget(self.vbtnExamine) #Project Description self.txtDescription = QPlainTextEdit() #Project License self.cboLicense = QComboBox() self.cboLicense.setFixedWidth(250) self.cboLicense.addItem('Apache License 2.0') self.cboLicense.addItem('Artistic License/GPL') self.cboLicense.addItem('Eclipse Public License 1.0') self.cboLicense.addItem('GNU General Public License v2') self.cboLicense.addItem('GNU General Public License v3') self.cboLicense.addItem('GNU Lesser General Public License') self.cboLicense.addItem('MIT License') self.cboLicense.addItem('Mozilla Public License 1.1') self.cboLicense.addItem('Mozilla Public License 2.0') self.cboLicense.addItem('New BSD License') self.cboLicense.addItem('Other Open Source') self.cboLicense.addItem('Other') self.cboLicense.setCurrentIndex(4) #Add to Grid gbox.addWidget(self.txtName, 0, 1) gbox.addLayout(hPlace, 1, 1) gbox.addWidget(self.txtDescription, 2, 1) gbox.addWidget(self.cboLicense, 3, 1) gbox.addLayout(vPlace, 4, 1) #Signal self.connect(self.btnExamine, SIGNAL('clicked()'), self.load_folder) self.connect(self.vbtnExamine, SIGNAL('clicked()'), self.load_folder_venv) self.connect(self.txtName, SIGNAL('textChanged(const QString&)'), lambda: self.emit(SIGNAL("completeChanged()"))) def isComplete(self): name = self.txtName.text().strip() place = self.txtPlace.text().strip() return (len(name) > 0) and (len(place) > 0) def load_folder(self): self.txtPlace.setText(QFileDialog.getExistingDirectory( self, self.tr("New Project Folder"))) self.emit(SIGNAL("completeChanged()")) def load_folder_venv(self): self.vtxtPlace.setText(QFileDialog.getExistingDirectory( self, self.tr("Select Virtualenv Folder")))
class Window(QMainWindow): def __init__(self,parent = None): QMainWindow.__init__(self,parent) self.resize(1024,768) self.setWindowTitle("Sabel") self.setWindowIcon(Icons.sabel) self.centralwidget = QWidget(self) self.horizontalLayout = QHBoxLayout(self.centralwidget) self.horizontalLayout.setMargin(0) self.cmdList = config.cmds() self.paramList = config.params() '''A.Editor TabWidget''' '''This parent is for findbar and vertical layout''' self.editorLayoutWidget = QWidget(self) self.editorLayoutWidget.setMinimumWidth(800) self.tabWidget = EditorTab(self) self.editorLayout = QVBoxLayout(self.editorLayoutWidget) self.editorLayout.setMargin(0) self.editorLayout.addWidget(self.tabWidget) "0.Style Layout" self.styleLayoutWidget = QFrame() self.styleLayoutWidget.setFrameShape(QFrame.StyledPanel) self.styleLayout = QHBoxLayout(self.styleLayoutWidget) self.styleTest = QPushButton(self.styleLayoutWidget) self.styleTest.setText("Change Styles") self.styleTest.clicked.connect(self.changeStyleSheet) self.popWidget = Popup(self.styleLayoutWidget) self.styleLayout.addWidget(self.styleTest) self.styleLayout.addWidget(self.popWidget) self.styleLayout.setMargin(0) self.editorLayout.addWidget(self.styleLayoutWidget) self.styleLayoutWidget.hide() "1.Find Layout" self.findLayoutWidget = QFrame() self.findLayoutWidget.setFrameShape(QFrame.StyledPanel) self.findLayout = QHBoxLayout(self.findLayoutWidget) self.lineEdit = QLineEdit(self.findLayoutWidget) self.lineEdit_2 = QLineEdit(self.findLayoutWidget) self.findClose = QPushButton(self.findLayoutWidget) self.findClose.setIcon(Icons.close_view) self.findClose.setFlat(True) self.findClose.clicked.connect(self.findBarShow) self.find = QPushButton(self.findLayoutWidget) self.find.setText("Find") self.find.clicked.connect(self.findCurrentText) self.replacefind = QPushButton(self.findLayoutWidget) self.replacefind.setText("Replace/Find") self.replacefind.clicked.connect(self.replaceFindText) self.replace = QPushButton(self.findLayoutWidget) self.replace.setText("Replace") self.replace.clicked.connect(self.replaceCurrentText) self.replaceAll = QPushButton(self.findLayoutWidget) self.replaceAll.setText("Replace All") self.replaceAll.clicked.connect(self.replaceAllText) self.caseSensitive = QToolButton(self.findLayoutWidget) self.caseSensitive.setIcon(Icons.font) self.caseSensitive.setCheckable(True) self.wholeWord = QToolButton(self.findLayoutWidget) self.wholeWord.setText("ww") self.wholeWord.setCheckable(True) self.regex = QToolButton(self.findLayoutWidget) self.regex.setText("re") self.regex.setCheckable(True) self.backward = QToolButton(self.findLayoutWidget) self.backward.setText("bk") self.backward.setCheckable(True) self.backward.setDisabled(True) self.findLayout.addWidget(self.findClose) self.findLayout.addWidget(self.find) self.findLayout.addWidget(self.lineEdit) self.findLayout.addWidget(self.lineEdit_2) self.findLayout.addWidget(self.caseSensitive) self.findLayout.addWidget(self.wholeWord) self.findLayout.addWidget(self.regex) self.findLayout.addWidget(self.backward) self.findLayout.addWidget(self.replacefind) self.findLayout.addWidget(self.replace) self.findLayout.addWidget(self.replaceAll) self.findLayout.setMargin(0) self.findLayoutWidget.setMaximumHeight(25) self.editorLayout.addWidget(self.findLayoutWidget) self.findLayoutWidget.hide() '''B.Designer''' '''This parent is for widgetsbar and design layout''' self.designerLayoutWidget = QWidget(self) self.designerLayoutWidget.setMinimumWidth(800) self.designerWidget = Screen(self) self.designerLayoutWidget.hide() self.designerLayout = QVBoxLayout(self.designerLayoutWidget) self.designerLayout.setMargin(0) self.designerLayout.addWidget(self.designerWidget) '''C.Level Editor''' '''This parent is for spritesheets and level layout''' self.levelLayoutWidget = QWidget(self) self.levelLayoutWidget.setMinimumWidth(800) self.levelWidget = Level(self) self.levelLayoutWidget.hide() self.levelLayout = QVBoxLayout(self.levelLayoutWidget) self.levelLayout.setMargin(0) self.levelLayout.addWidget(self.levelWidget) '''D.Explorer TabWidget''' self.explorerTabWidget = TreeTab(self) #self.explorerTabWidget.setMaximumWidth(200) '''1.Project Tree''' self.tab_5 = QWidget() #self.tab_5.setMaximumWidth(200) self.VerticalLayout_2 = QVBoxLayout(self.tab_5)#QHBoxLayout(self.tab_5) self.VerticalLayout_2.setMargin(0) self.treeWidget = ProjectTree(self.tab_5) #self.treeWidget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) #self.treeWidget.horizontalScrollBar().show() self.VerticalLayout_2.addWidget(self.treeWidget) '''2.Outline Tree''' self.tab_2 = QWidget() #self.tab_2.setMaximumWidth(200) self.VerticalLayout_3 = QVBoxLayout(self.tab_2) self.VerticalLayout_3.setMargin(0) self.outlineWidget = OutlineTree(self.tab_2) self.outlineWidget.itemDoubleClicked.connect(self.gotoLine) self.VerticalLayout_3.addWidget(self.outlineWidget) '''E.Output TabWidget''' self.outputTabWidget = OutputTab(self) self.tabWidget.currentChanged.connect(self.fileChanged) self.explorerTabWidget.currentChanged.connect(self.closeExplorer) self.outputTabWidget.currentChanged.connect(self.closeConsole) self.tabWidget.setTabsClosable(True) self.tabWidget.setTabShape(0) '''1.Output layout''' #must check self.tab_6 = QWidget() self.horizontalLayout_2 = QVBoxLayout(self.tab_6) self.horizontalLayout_2.setMargin(0) self.textEdit = QTextEdit() self.inputLayout = QHBoxLayout() self.inputLayout.setMargin(0) self.fileButton = QPushButton() self.fileButton.setText("File") self.fileButton.clicked.connect(self.getFile) self.runButton = QPushButton() self.runButton.setFlat(True) self.runButton.setIcon(Icons.go) self.combo = QComboBox() self.combo.setFixedWidth(100) self.comboAdd = QPushButton() self.comboAdd.setIcon(Icons.add) self.comboAdd.setFlat(True) self.comboAdd.clicked.connect(self.addCmd) self.comboDel = QPushButton() self.comboDel.setIcon(Icons.close_view) self.comboDel.setFlat(True) self.comboDel.clicked.connect(self.delCmd) self.combo2 = QComboBox() self.combo2.setFixedWidth(500) self.combo2Add = QPushButton() self.combo2Add.setIcon(Icons.add) self.combo2Add.setFlat(True) self.combo2Add.clicked.connect(self.addParam) self.combo2Del = QPushButton() self.combo2Del.setIcon(Icons.close_view) self.combo2Del.setFlat(True) self.combo2Del.clicked.connect(self.delParam) if(self.checkHasValue(self.cmdList)): for cmd in self.cmdList: self.combo.addItem(cmd) else: self.cmdList = [] if(self.checkHasValue(self.paramList)): for param in self.paramList: self.combo2.addItem(param) else: self.paramList = [] self.horizontalLayout_2.addWidget(self.textEdit) self.inputLayout.addWidget(QLabel("<b>Command:</b>")) self.inputLayout.addWidget(self.combo) self.inputLayout.addWidget(self.comboAdd) self.inputLayout.addWidget(self.comboDel) self.inputLayout.addWidget(QLabel("<b>Parameters:</b>")) self.inputLayout.addWidget(self.combo2) self.inputLayout.addWidget(self.combo2Add) self.inputLayout.addWidget(self.combo2Del) self.inputLayout.addWidget(self.fileButton) self.inputLayout.addWidget(self.runButton) self.horizontalLayout_2.addLayout(self.inputLayout) '''2.Error Layout''' self.tab_7 = QWidget() self.horizontalLayout_4 = QHBoxLayout(self.tab_7) self.horizontalLayout_4.setMargin(0) self.errorTree = ErrorTree(self.tab_7) self.errorTree.itemDoubleClicked.connect(self.errorLine) self.horizontalLayout_4.addWidget(self.errorTree) '''TabWidgets tabs''' #self.designerWidget.addTab(QWidget(self),"") #self.designerWidget.setTabIcon(0,Icons.close_view) #self.levelWidget.addTab(QWidget(self),"") #self.levelWidget.setTabIcon(0,Icons.close_view) self.explorerTabWidget.addTab(self.tab_5,"Projects") self.explorerTabWidget.addTab(self.tab_2,"Outline") self.explorerTabWidget.addTab(QWidget(self),"") self.explorerTabWidget.setTabIcon(0,Icons.cprj) self.explorerTabWidget.setTabIcon(1,Icons.envvar) self.explorerTabWidget.setTabIcon(2,Icons.close_view) self.outputTabWidget.addTab(self.tab_7,"Error") self.outputTabWidget.addTab(self.tab_6,"Output") self.outputTabWidget.addTab(QWidget(self),"") self.outputTabWidget.setTabIcon(0,Icons.error) self.outputTabWidget.setTabIcon(1,Icons.console_view) self.outputTabWidget.setTabIcon(2,Icons.close_view) '''Splitters''' self.split1 = QSplitter(Qt.Horizontal) self.split1.addWidget(self.explorerTabWidget) self.split1.addWidget(self.editorLayoutWidget) self.split1.addWidget(self.designerLayoutWidget) self.split1.addWidget(self.levelLayoutWidget) #self.split1.addWidget(self.tab_5) self.split2 = QSplitter(Qt.Vertical) self.split2.addWidget(self.split1) self.split2.addWidget(self.outputTabWidget) self.horizontalLayout.addWidget(self.split2) '''Status Bar''' self.statusbar = QStatusBar(self) self.aboutButton = QPushButton(self) self.aboutButton.setFlat(True) self.aboutButton.setIcon(Icons.anchor) self.aboutButton.clicked.connect(self.about) self.expButton = QPushButton(self) self.expButton.setFlat(True) self.expButton.setIcon(Icons.prj) self.expButton.clicked.connect(self.exp) self.cmdButton = QPushButton(self) self.cmdButton.setFlat(True) self.cmdButton.setIcon(Icons.console_view) self.cmdButton.clicked.connect(self.cmd) self.cmdButton.setShortcut('Ctrl+D') self.imgButton = QPushButton(self) self.imgButton.setFlat(True) self.imgButton.setIcon(Icons.color_palette) self.imgButton.clicked.connect(self.design) self.imgButton.setShortcut('Ctrl+I') self.findButton = QPushButton(self) self.findButton.setFlat(True) self.findButton.setIcon(Icons.find) self.findButton.setShortcut("Ctrl+F") self.findButton.clicked.connect(self.findBarShow) ''' self.zoominButton = QPushButton(self) self.zoominButton.setFlat(True) self.zoominButton.setIcon(Icons.zoomplus) self.zoominButton.clicked.connect(self.zoomin) self.zoomoutButton = QPushButton(self) self.zoomoutButton.setFlat(True) self.zoomoutButton.setIcon(Icons.zoomminus) self.zoomoutButton.clicked.connect(self.zoomout) ''' '''Status Text,Line Text, Progress Bar and Stop Button''' self.statusText = QLabel("Writable") #self.statusText.setAlignment(Qt.AlignCenter) self.statusText.setFixedWidth(200) self.lineText = QLabel("") self.lineText.setFixedWidth(50) self.progressbar = QProgressBar() self.progressbar.setMinimum(0) self.progressbar.setMaximum(100) self.stopButton = QPushButton(self) self.stopButton.setFlat(True) self.stopButton.setIcon(Icons.stop) self.stopButton.clicked.connect(self.forceStop) self.progressbar.hide() self.stopButton.hide() self.temp = False self.progress = False self.counter = 0 '''Adding all widgets to Status Bar''' self.statusbar.addWidget(self.aboutButton) self.statusbar.addWidget(self.expButton) self.statusbar.addWidget(self.cmdButton) self.statusbar.addWidget(self.imgButton) self.statusbar.addWidget(self.findButton) #self.statusbar.addWidget(QWidget(self)) #self.statusbar.addWidget(self.zoominButton) #self.statusbar.addWidget(self.zoomoutButton) self.statusbar.addWidget(self.statusText) self.statusbar.addWidget(self.lineText) self.statusbar.addWidget(self.progressbar) self.statusbar.addWidget(self.stopButton) #self.statusbar.setFixedHeight(18) ''''Initializing Coloring Style''' self.initEditorStyle() self.initStyleSheet() '''Adding Cental Widget and Status Bar''' self.setCentralWidget(self.centralwidget) self.setStatusBar(self.statusbar) self.textEdit.setReadOnly(True) def initStyleSheet(self): import stylesheet self.setStyleSheet(stylesheet.mainstyl) self.tabWidget.tabBar().setStyleSheet(stylesheet.stletabb) self.explorerTabWidget.tabBar().setStyleSheet(stylesheet.stletabb) self.outputTabWidget.tabBar().setStyleSheet(stylesheet.stletabb) self.popWidget.setStyleSheet(stylesheet.popbg) self.popWidget.hide() ''' This is for changing the palette/window colors to Theme ''' def initEditorStyle(self): pass #editStyle = config.readStyle() #print editStyle #pal = QPalette(self.explorerTabWidget.palette()) #print pal.color(QPalette.Base).name() #print pal.color(QPalette.Window).name() #pal.setColor(QPalette.Base,self.colorStyle.paper) #pal.setColor(QPalette.Text,self.colorStyle.color) #self.explorerTabWidget.setPalette(pal) #self.outputTabWidget.setPalette(pal) ''' This is only for testing dont know if it works for builds ''' def changeStyleSheet(self): ''' Dynamically load the changed stylesheet.py and load the modules and change the style at runtime saves countless deploys ''' import imp foo = imp.load_source('stletabb', workDir+"/stylesheet.py") #print foo.stletabb #self.setStyleSheet(stylesheet.mainstyl) self.tabWidget.tabBar().setStyleSheet(foo.stletabb) self.popWidget.setStyleSheet(foo.popbg) if(self.popWidget.isHidden()): self.popWidget.showPopup() def build_project(self): #current_file = self.files[self.tabWidget.currentIndex()] prj = self.treeWidget.getProject() if(prj != None): self.treeWidget.build(prj) def run_project(self): #current_file = self.files[self.tabWidget.currentIndex()] prj = self.treeWidget.getProject()#current_file) if(prj != None): self.treeWidget.run(prj) def forceStop(self): self.ant.kill() self.progressStop() def kill(self): self.deleteLater() #-----------------------------------------------------------------------------------# # Menu Actions Functions # #-----------------------------------------------------------------------------------# def run(self): if(config.mode() == 0): self.sq.run() elif(config.mode() == 1): self.adb.run() elif(config.mode() == 2): self.ios.run() elif(config.mode() == 3): self.c.run() def setMode(self, action): if(action.text() == "Squ"): config.setMode(0) self.toolBar.action_Build.setEnabled(False) self.toolBar.action_Run.setEnabled(False) elif(action.text() == "Emo"): config.setMode(1) self.toolBar.action_Build.setEnabled(True) self.toolBar.action_Run.setEnabled(True) elif(action.text() == "Android"): config.setMode(2) self.toolBar.action_Build.setEnabled(True) self.toolBar.action_Run.setEnabled(True) elif(action.text() == "ios"): config.setMode(3) self.toolBar.action_Build.setEnabled(False) self.toolBar.action_Run.setEnabled(False) def openCommand(self): text, ok = QInputDialog.getText(self, 'Run Command', 'Command:') cmd = str(text) if ok and cmd != "": import subprocess subprocess.Popen(cmd) def about(self): form = DialogAbout(self) def todo(self): form = DialogTodo(self) form.show() def help(self): QMessageBox.about(self,"Help","This is about all The Help that i can Give you now") def full(self): if not self.isFull: self.setWindowState(Qt.WindowFullScreen) self.isFull = True else: self.setWindowState(Qt.WindowMaximized) self.isFull = False def android(self): form = DialogAndroid(self) form.show() def antt(self): form = DialogAnt(self) form.show() def squirrel(self): form = DialogSquirrel(self) form.show() def findBarShow(self): if(self.findLayoutWidget.isHidden()): self.findLayoutWidget.show() else: self.findLayoutWidget.hide() def exp(self): if(self.explorerTabWidget.isHidden()): self.explorerTabWidget.show() else: self.explorerTabWidget.hide() def cmd(self): if(self.outputTabWidget.isHidden()): self.outputTabWidget.show() else: self.outputTabWidget.hide() def editor(self): if(self.editorLayoutWidget.isHidden()): self.editorLayoutWidget.show() self.levelLayoutWidget.hide() self.designerLayoutWidget.hide() def design(self): if(self.designerLayoutWidget.isHidden()): self.designerLayoutWidget.show() self.editorLayoutWidget.hide() self.levelLayoutWidget.hide() else: self.designerLayoutWidget.hide() self.editorLayoutWidget.show() def level(self): if(self.levelLayoutWidget.isHidden()): self.levelLayoutWidget.show() self.editorLayoutWidget.hide() self.designerLayoutWidget.hide() else: self.levelLayoutWidget.hide() self.editorLayoutWidget.show() def closeDesigner(self,no): pass ''' if(no == self.tiler.closeIndex()): if(self.tiler.isHidden()): self.tiler.show() else: self.tiler.setCurrentIndex(1) self.tiler.hide() ''' '''The current Changed idx of outputTabWidget is passed to this a param''' def closeConsole(self,no = 2): if(no == 2): if(self.outputTabWidget.isHidden()): self.outputTabWidget.show() else: self.outputTabWidget.setCurrentIndex(1) self.outputTabWidget.hide() def popOutput(self): if(self.outputTabWidget.isHidden()): self.outputTabWidget.show() self.outputTabWidget.setCurrentIndex(1) def popError(self): if(self.outputTabWidget.isHidden()): self.outputTabWidget.show() self.outputTabWidget.setCurrentIndex(0) '''The current Changed idx of explorerTabWidget is passed to this a param''' def closeExplorer(self,no = 2): if(no == 2): if(self.explorerTabWidget.isHidden()): self.explorerTabWidget.show() else: self.explorerTabWidget.setCurrentIndex(0) self.explorerTabWidget.hide() elif(no == 1): self.fileChanged(no) ''' This is to refresh the outline widget''' def fileChanged(self,no): if(self.explorerTabWidget.currentIndex() == 1): edt = self.tabWidget.widget(self.tabWidget.currentIndex()) source = edt.text() self.outlineWidget.parseText(source) def statusSaving(self): self.statusText.setText("Saving") def statusParsing(self): self.statusText.setText("Parsing") def statusWriting(self): self.statusText.setText("Writable") def statusRunning(self): self.statusText.setText("Running") def statusStopping(self): self.statusText.setText("Stopping") def statusCommand(self): self.statusText.setText("Command") def statusBuilding(self): self.statusText.setText("Building") def statusInstalling(self): self.statusText.setText("Installing") def statusCleaning(self): self.statusText.setText("Cleaning") def statusCreating(self): self.statusText.setText("Creating") def progressStart(self): self.progress == True self.temp == True if(self.progressbar.isHidden()): self.progressbar.show() if(self.stopButton.isHidden()): self.stopButton.show() self.progressbar.setValue(1) def progressStop(self): self.progress == False self.temp == False self.progressbar.setValue(100) if not(self.progressbar.isHidden()): self.progressbar.hide() if not(self.stopButton.isHidden()): self.stopButton.hide() def progressUpdate(self): if(self.progress): if(self.temp): self.counter += 1 self.progressbar.setValue(self.counter) if(self.counter == 100): self.temp = False else: self.counter -= 1 self.progressbar.setValue(self.counter) if(self.counter == 0): self.temp = True #-----------------------------------------------------------------------------------# # Editor Functions # #-----------------------------------------------------------------------------------# '''Search and Replace Functions''' def findCurrentText(self): edt = self.tabWidget.widget(self.tabWidget.currentIndex()) edt.findText(self.lineEdit.text(),self.regex.isChecked(),self.caseSensitive.isChecked(),self.wholeWord.isChecked(),self.backward.isChecked()) def replaceCurrentText(self): edt = self.tabWidget.widget(self.tabWidget.currentIndex()) edt.replaceText(self.lineEdit_2.text()) def replaceFindText(self): edt = self.tabWidget.widget(self.tabWidget.currentIndex()) edt.replaceText(self.lineEdit_2.text()) self.findCurrentText() def replaceAllText(self): edt = self.tabWidget.widget(self.tabWidget.currentIndex()) while(edt.findText(self.lineEdit.text(),self.regex.isChecked(),self.caseSensitive.isChecked(),self.wholeWord.isChecked(),self.backward.isChecked())): edt.replaceText(self.lineEdit_2.text()) def errorLine(self,error): index = self.tabWidget.currentIndex() edt = self.tabWidget.widget(index) '''To prevent File item double clicking''' if(error.isFile() == False): edt.setLine(error.line) '''Font Functions''' def zoomin(self): pass #for i in range(len(self.files)): # self.tabWidget.widget(i).zoomin() def zoomout(self): pass #for i in range(len(self.files)): # self.tabWidget.widget(i).zoomout() ''' Must implement Lexer ''' def setLexer(self, action): pass #print action.text() def setApi(self, action): #print action.text() for i in range(len(self.files)): #not QString self.tabWidget.widget(i).setApi(str(action.text())) def setFont(self,font): config.setFontName(str(font.family())) for i in range(len(self.files)): self.tabWidget.widget(i).setNewFont(font) def setFontSize(self,idx): fontSize = idx+1 config.setFontSize(fontSize) for i in range(len(self.files)): self.tabWidget.widget(i).setFontSize() def gotoLine(self,item): edt = self.tabWidget.widget(self.tabWidget.currentIndex()) edt.setLine(item.line) def updateLine(self,no,col): self.lineText.setText(str(no)+" : "+str(col)) def setMargin(self): mar = config.margin() if(mar == 0): config.setMargin(1) for i in range(len(self.files)): self.tabWidget.widget(i).setMargin(1) else: config.setMargin(0) for i in range(len(self.files)): self.tabWidget.widget(i).setMargin(0) ''' Toggle ''' def setIndent(self): indent = config.indent() if(indent == 0): config.setIndent(1) for i in range(len(self.files)): self.tabWidget.widget(i).setIndent(1) else: config.setIndent(0) for i in range(len(self.files)): self.tabWidget.widget(i).setIndent(0) ''' Toggle ''' def setWhiteSpace(self): white = config.whiteSpace() if(white == 0): config.setWhiteSpace(1) for i in range(len(self.files)): self.tabWidget.widget(i).setWhitespaceVisibility(True) else: config.setWhiteSpace(0) for i in range(len(self.files)): self.tabWidget.widget(i).setWhitespaceVisibility(False) ''' Toggle ''' def setEndLine(self): for i in range(len(self.files)): edt = self.tabWidget.widget(i) edt.setEolVisibility(not edt.eolVisibility()) def setEncoding(self, action): if(action.text() == "Ascii"): config.setAscii() for i in range(len(self.files)): self.tabWidget.widget(i).setUtf8(False) elif(action.text() == "Unicode"): config.setUnicode() for i in range(len(self.files)): self.tabWidget.widget(i).setUtf8(True) def setThreshold(self,val): config.setThresh(val) for i in range(len(self.files)): #print i self.tabWidget.widget(i).setThreshold(val) def setTabWidth(self,val): config.setTabWidth(val) for i in range(len(self.files)): #print i self.tabWidget.widget(i).setTabWidth(val) '''style Functions''' #-----------------------------------------------------------------------------------# # Command Functions # #-----------------------------------------------------------------------------------# def getFile(self): self.browsedialog = DialogBrowse(self) self.browsedialog.tree.itemDoubleClicked.connect(self.getName) self.browsedialog.show() def getName(self,item): if(item.isFile()): self.browsedialog.accept() fname = item.getPath() if not (fname == ""): index = self.combo2.currentIndex() text = str(self.combo2.itemText(index))+" "+fname self.combo2.setItemText(index,text) self.paramList.pop(index) self.paramList.insert(index,text) config.setParam(self.paramList) def addCmd(self,index): text, ok = QInputDialog.getText(self, 'Add Command', 'Command:') if(ok): if(str(text) != ''): cmd = str(text).upper() self.cmdList.append(cmd) #print self.cmdList self.combo.addItem(cmd) config.setCmd(self.cmdList) config.setParam(self.paramList) def delCmd(self): index = self.combo.currentIndex() self.combo.removeItem(index) self.cmdList.pop(index) #print self.cmdList config.setCmd(self.cmdList) def addParam(self,index): text, ok = QInputDialog.getText(self, 'Add Parameters', 'Params:') if(ok): if(str(text) != ''): param = str(text) self.paramList.append(param) self.combo2.addItem(param) config.setParam(self.paramList) def delParam(self): index = self.combo2.currentIndex() self.combo2.removeItem(index) self.paramList.pop(index) config.setParam(self.paramList) def checkHasValue(self,list): if(list != None and len(list) != 0): return True else: return False
class GeneralSection(QWidget): """ Clase Configuracion Editor """ 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 _change_scheme(self, theme): theme = theme.split()[0].lower() editor_container = Edis.get_component("principal") editor = editor_container.get_active_editor() if editor is not None: # Restyle pass def _caret_type_changed(self, index): self.spin_caret_width.setEnabled(bool(index)) def _load_font(self): font = settings.get_setting('editor/font') self.combo_font.setCurrentFont(QFont(font)) def save(self): """ Guarda las configuraciones del Editor. """ use_tabs = bool(self.combo_tabs.currentIndex()) settings.set_setting('editor/usetabs', use_tabs) auto_indent = self.check_autoindent.isChecked() settings.set_setting('editor/indent', auto_indent) settings.set_setting('editor/minimap', self.check_minimap.isChecked()) #settings.set_setting('editor/minimap-animation', #self.check_minimap_animation.isChecked()) font = self.combo_font.currentFont().family() settings.set_setting('editor/font', font) font_size = self.spin_size_font.value() settings.set_setting('editor/size-font', font_size) scheme = self.combo_scheme.currentText().split()[0].lower() settings.set_setting('editor/scheme', scheme) settings.set_setting('editor/cursor', self.combo_caret.currentIndex()) settings.set_setting('editor/caret-width', self.spin_caret_width.value()) settings.set_setting('editor/cursor-period', self.slider_caret_period.value()) editor_container = Edis.get_component("principal") editor = editor_container.get_active_editor() if editor is not None: editor.setIndentationsUseTabs(use_tabs) editor.load_font(font, font_size)
class GeneralSection(QWidget): """ Clase Configuracion Editor """ 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 _change_scheme(self, theme): theme = theme.split()[0].lower() editor_container = Edis.get_component("principal") editor = editor_container.get_active_editor() if editor is not None: # Restyle pass def _caret_type_changed(self, index): self.spin_caret_width.setEnabled(bool(index)) def _load_font(self): font = settings.get_setting('editor/font') self.combo_font.setCurrentFont(QFont(font)) def save(self): """ Guarda las configuraciones del Editor. """ use_tabs = bool(self.combo_tabs.currentIndex()) settings.set_setting('editor/usetabs', use_tabs) auto_indent = self.check_autoindent.isChecked() settings.set_setting('editor/indent', auto_indent) settings.set_setting('editor/minimap', self.check_minimap.isChecked()) #settings.set_setting('editor/minimap-animation', #self.check_minimap_animation.isChecked()) font = self.combo_font.currentFont().family() settings.set_setting('editor/font', font) font_size = self.spin_size_font.value() settings.set_setting('editor/size-font', font_size) scheme = self.combo_scheme.currentText().split()[0].lower() settings.set_setting('editor/scheme', scheme) settings.set_setting('editor/cursor', self.combo_caret.currentIndex()) settings.set_setting('editor/caret-width', self.spin_caret_width.value()) settings.set_setting('editor/cursor-period', self.slider_caret_period.value()) editor_container = Edis.get_component("principal") editor = editor_container.get_active_editor() if editor is not None: editor.setIndentationsUseTabs(use_tabs) editor.load_font(font, font_size)
class NetWidget(QWidget): def __init__(self,parent = None): super(NetWidget,self).__init__(parent) self.setStyleSheet("font-size : 16px")#设置整体的字体大小 self.auto = False self.pro = QProcess(self) # self.tipDlg = TipDialog() # self.tipDlg.setModal(True)#引入tipdlg,并且将这个窗口设置为最前端窗口,且后面窗口无法操作 #初始化comBox控件,并且为其添加选项 self.comBox = QComboBox() self.comBox.setFixedWidth(120) self.comBox.insertItem(0, self.tr("ping")) self.comBox.insertItem(1, self.tr("ifconfig")) self.comBox.insertItem(2, self.tr("display")) #self.comBox.insertItem(3, self.tr("traceroute")) self.comBox.insertItem(4, self.tr("top")) self.connect(self.comBox, SIGNAL('activated(QString)'),self.onActivated)#设置combBox为活动的,与函数关联 """ #初始话控件设置 #lineEdit,固定长度 #runButton,显示字符串,信号量 #pingLabel,当前显示字符 #textBrower """ self.lineEdit = QLineEdit() self.lineEdit.setContextMenuPolicy(Qt.NoContextMenu) self.lineEdit.setFixedWidth(250) self.runButton = QPushButton(self.tr("Run")) self.runButton.setStyleSheet("background: rgb(7,87,198); color: white; width: 70px; height: 20px;font-size : 16px;") self.connect(self.runButton, SIGNAL("clicked()"),self.runButton_clicked) self.pingLabel = QLabel()#初始话,之后在函数操作中会改变 self.pingLabel.setText(self.tr("Tip:please input the IP address of pinging,then get the result with clicking the button")) self.textBrowser = QTextBrowser() """ #布局一上,横向布局 #将comBox,lineEdit,runButton添加到布局中 #设置前面空为20和后面空为280 """ hLayout1 = QHBoxLayout() hLayout1.addSpacing(20) hLayout1.addWidget(self.comBox) hLayout1.addWidget(self.lineEdit) hLayout1.addWidget(self.runButton) #hLayout1.addStretch() hLayout1.addSpacing(280) #布局二中,横向布局 #将pingLabel添加到布局中,并且诶设置前面的空白为20 hLayout2 = QHBoxLayout() hLayout2.addSpacing(20) hLayout2.addWidget(self.pingLabel) #布局三下 #将textBrower添加爱到布局中,并且设置前面空白为20,后面空白为60,控件的大小自适应 hLayout3 = QHBoxLayout() hLayout3.addSpacing(20) hLayout3.addWidget(self.textBrowser) hLayout3.addSpacing(60) #主题布局总,纵向布局 #将之上的三个布局添加到总布局中,并且设置布局间空间为20,最下面的空白为40 mainLayout = QVBoxLayout() mainLayout.addSpacing(20) mainLayout.addLayout(hLayout1) mainLayout.addSpacing(20) mainLayout.addLayout(hLayout2) mainLayout.addSpacing(20) mainLayout.addLayout(hLayout3) mainLayout.addSpacing(40) self.setLayout(mainLayout) self.thread = MyThread() self.connect(self.thread,SIGNAL("getoutput"),self.append) def append(self,actionType): self.textBrowser.clear() self.textBrowser.append(actionType) #cursor = QTextCursor() #self.runButton.setText(self.tr("Stop")) cursor = self.textBrowser.textCursor() cursor.movePosition(QTextCursor.Start) self.textBrowser.setTextCursor(cursor) #changeLabel = QLabel() def onActivated(self): language = StoreInfoParser.instance().getLanguage() m_pTranslator = QTranslator() exePath = "./" if language == "chinese": QmName = "zh_CN.qm" else: QmName = "en_US.qm" if(m_pTranslator.load(QmName, exePath)): QCoreApplication.instance().installTranslator(m_pTranslator) """#comBox的相应函数,随着comBox中字符串的改变,分别控制pingLabel的显示,以及lineEdit和textBrower的显示清除和可用状态 #如果comBox当前的字符串文字为ping #pingLabel的文字设置为"提示:请在文本框中输入要ping的目标地址,然后点击执行获取结果",保持当前大小 #lineEdit中内容清除,设置为不可用 #textBrower清空""" if(self.comBox.currentText() == "Ping" or self.comBox.currentText() == "ping"): self.pingLabel.setText(self.tr("Tip:please input the IP address of pinging,then get the result with clicking the button")) self.pingLabel.adjustSize() self.lineEdit.clear() self.lineEdit.setDisabled(False) self.textBrowser.clear() #如果comBox当前的字符串文字为ifconfig #类上所说 elif(self.comBox.currentText() == "ifconfig"): self.pingLabel.setText(self.tr("Tip:get the net information")) self.pingLabel.adjustSize() self.lineEdit.clear() self.lineEdit.setEnabled(False) self.textBrowser.clear() #如果comBox当前的字符串文字为display elif(self.comBox.currentText() == "display"): self.pingLabel.setText(self.tr("Tip:get the resolution information")) self.pingLabel.adjustSize() self.lineEdit.clear() self.lineEdit.setEnabled(False) self.textBrowser.clear() elif(self.comBox.currentText() == "top"): self.pingLabel.setText(self.tr("Tip:run tom command")) self.pingLabel.adjustSize() self.lineEdit.setEnabled(False) self.lineEdit.clear() self.textBrowser.clear() #按钮的响应函数 def runButton_clicked(self): language = StoreInfoParser.instance().getLanguage() m_pTranslator = QTranslator() exePath = "./" if language == "chinese": QmName = "zh_CN.qm" else: QmName = "en_US.qm" if(m_pTranslator.load(QmName, exePath)): QCoreApplication.instance().installTranslator(m_pTranslator) #self.pro = QProcess(self)#外部程序使用声明 desktop = QApplication.desktop()#获得桌面 self.textBrowser.clear()#清除 cmdstr = QString() center = QString() goal = QString() #comBox当前text为ping if (self.comBox.currentText() == "Ping" or self.comBox.currentText() == "ping"): if (self.runButton.text() == self.tr("Run")) : center = self.lineEdit.text().trimmed() if not center: InfoHintDialog(self.tr("please input the IP address")).exec_() # self.tipDlg.setTip(self.tr("请输入ping地址!!!")) # self.tipDlg.show() # self.tipDlg.move((desktop.width()-self.tipDlg.width())/2,(desktop.height()-self.tipDlg.height())/2) self.runButton.setText(self.tr("Run")) else: self.comBox.setDisabled(True) self.pro = QProcess(self) self.runButton.setText(self.tr("stop ping")) cmdstr = "ping " +center self.textBrowser.clear() self.textBrowser.append(self.tr(" ping ")+center+self.tr(" result:")) else: self.comBox.setDisabled(False) self.runButton.setText(self.tr("Run")) self.pro.close() elif(self.comBox.currentText() == "ifconfig"): self.pro = QProcess(self) self.lineEdit.clear() self.lineEdit.setEnabled(False) self.textBrowser.clear() cmdstr = "ifconfig" # #如果comBox当前为traceroute # elif(self.comBox.currentText() == "traceroute"): # goal = self.lineEdit.text() # if (self.runButton.text() == u"执行"): # if( goal.isEmpty() or goal.isNull() ): # InfoHintDialog(u'请输入tracer地址:').exec_() # # self.tipDlg.setTip(self.tr("请输入tracer地址:")) # # self.tipDlg.show() # # self.tipDlg.move((desktop.width()-self.tipDlg.width())/2,(desktop.height()-self.tipDlg.height())/2) # # # #QMessageBox.information(self,self.tr("错误"),self.tr("请输入traceroute的目标地址")) # #return # else: # self.proc = QProcess(self) # #self.textBrowser.clear() # cmdstrc = "traceroute -n "+ goal # self.proc.start(cmdstrc) # self.connect(self.proc, SIGNAL("readyReadStandardOutput()"),self.readR) # self.connect(self.proc, SIGNAL("readyReadStandardError()"),self.readErrorR) # if self.proc.waitForStarted(10) == True: # self.comBox.setDisabled(True) # self.runButton.setText(self.tr("停止执行")) # else: # self.runButton.setText(self.tr("执行")) # self.comBox.setDisabled(False) # self.proc.close() # #如果comBox当前为display elif (self.comBox.currentText() == "display"): self.pro = QProcess(self) cmdstr = "../lib/ccr_jytcapi display" self.textBrowser.clear() #如果当前命令cmdstr不为空,则 elif (self.comBox.currentText() == "top"): if self.runButton.text() == self.tr("Run") : self.thread.start() self.comBox.setDisabled(True) self.runButton.setText(self.tr("stop top")) else: self.textBrowser.clear() self.thread.auto = False #self.thread.destroyed() self.comBox.setDisabled(False) self.runButton.setText(self.tr("Run")) if (cmdstr != ""): self.pro.start(cmdstr)#开启执行命令 self.connect(self.pro, SIGNAL("readyReadStandardOutput()"),self.read)#读取执行正常输出槽函数 self.connect(self.pro, SIGNAL("readyReadStandardError()"),self.readError)#执行异常槽函数 #读取控制台输出 def read(self): res = QString.fromLocal8Bit(self.pro.readAllStandardOutput()) self.textBrowser.append(res)#添加到text框 #读取错误 def readError(self): res = QString.fromLocal8Bit(self.pro.readAllStandardError()) self.textBrowser.append(res) def readR(self): res = QString.fromLocal8Bit(self.proc.readAllStandardOutput()) #self.textBrowser.clear() self.textBrowser.append(res) def readErrorR(self): res = QString.fromLocal8Bit(self.proc.readAllStandardError()) self.textBrowser.append(res) def updateWindow(self): if self.pro.isOpen(): self.pro.close() self.thread.auto = False self.comBox.setDisabled(False) self.comBox.setCurrentIndex(0) self.runButton.setText((self.tr("Run"))) self.pingLabel.setText(self.tr("Tip:please input the IP address of pinging,then get the result with clicking the button")) self.textBrowser.clear()
class GeneralSection(QWidget): 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 _update_combo(self): self.combo_theme.addItems(['Default', 'Edark']) list_dir = os.listdir(paths.EDIS) list_styles = [ i.split('.')[0] for i in list_dir if os.path.splitext(i)[-1] == '.qss' ] self.combo_theme.insertItems(2, list_styles) def _change_style_sheet(self, index): style_sheet = None path = None if index == 1: path = os.path.join(paths.PATH, "extras", "theme", "edark.qss") elif index != 0: style = self.combo_styles.currentText() + '.qss' path = os.path.join(paths.EDIS, style) if path is not None: with open(path, mode='r') as f: style_sheet = f.read() QApplication.instance().setStyleSheet(style_sheet) def _restart_configurations(self): flags = QMessageBox.Cancel flags |= QMessageBox.Yes result = QMessageBox.question( self, self.tr("Advertencia!"), self.tr("Está seguro que quiere " "reestablecer las " "configuraciones?"), flags) if result == QMessageBox.Cancel: return elif result == QMessageBox.Yes: QSettings(paths.CONFIGURACION, QSettings.IniFormat).clear() dialog_preferences = Edis.get_component("preferences") dialog_preferences.close() def save(self): settings.set_setting('general/show-splash', self.check_splash.isChecked()) show_start_page = self.check_on_start.isChecked() settings.set_setting('general/show-start-page', show_start_page) settings.set_setting('ventana/store-size', self.check_geometry.isChecked()) settings.set_setting('general/confirm-exit', self.check_on_exit.isChecked()) settings.set_setting('general/check-updates', self.check_updates.isChecked()) load_files = self.check_load_files.isChecked() settings.set_setting('general/load-files', load_files) lang = self.combo_lang.currentText() settings.set_setting('general/language', lang) if settings.IS_LINUX: settings.set_setting('terminal', self.line_terminal.text())