def setup_ui(self): """Load all the components of the ui during the install process.""" vbox = QVBoxLayout(self) vbox.setContentsMargins(0, 0, 0, 0) vbox.setSpacing(0) self.__toolbar = QToolBar() self.__toolbar.setObjectName('custom') hbox = QHBoxLayout() vbox.addLayout(hbox) self.stack = StackedWidget() vbox.addWidget(self.stack) self._console = console_widget.ConsoleWidget() self._runWidget = run_widget.RunWidget() self._web = web_render.WebRender() self._findInFilesWidget = find_in_files.FindInFilesWidget( self.parent()) # Not Configurable Shortcuts shortEscMisc = QShortcut(QKeySequence(Qt.Key_Escape), self) self.connect(shortEscMisc, SIGNAL("activated()"), self.hide) #Toolbar hbox.addWidget(self.__toolbar) self.add_to_stack(self._console, ":img/console", translations.TR_CONSOLE) self.add_to_stack(self._runWidget, ":img/play", translations.TR_OUTPUT) self.add_to_stack(self._web, ":img/web", translations.TR_WEB_PREVIEW) self.add_to_stack(self._findInFilesWidget, ":img/find", translations.TR_FIND_IN_FILES) #Last Element in the Stacked widget self._results = results.Results(self) self.stack.addWidget(self._results) self.__toolbar.addSeparator() hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding)) btn_close = QPushButton( self.style().standardIcon(QStyle.SP_DialogCloseButton), '') btn_close.setIconSize(QSize(24, 24)) btn_close.setObjectName('navigation_button') btn_close.setToolTip('F4: ' + translations.TR_ALL_VISIBILITY) hbox.addWidget(btn_close) self.connect(btn_close, SIGNAL('clicked()'), self.hide)
def setup_ui(self): self._stack = QStackedWidget() self.__current_widget = None self.__last_index = -1 self.__buttons = [] main_layout = QHBoxLayout(self) main_layout.setContentsMargins(0, 0, 0, 0) main_layout.setSpacing(0) # toolbar = StyledBar() tool_layout = QVBoxLayout() tool_layout.setContentsMargins(0, 0, 0, 0) tool_layout.setSpacing(0) self._run_widget = run_widget.RunWidget() main_layout.addLayout(tool_layout) self._tool_stack = QStackedWidget() # self._tool_stack.setMaximumHeight(22) self._tool_stack.setMaximumWidth(22) tool_layout.addWidget(self._tool_stack) # FIXME: poner en stack # clear_btn = QToolButton() # clear_btn.setIcon(QIcon(self.style().standardIcon(QStyle.SP_LineEditClearButton))) # clear_btn.clicked.connect(self._run_widget.output.clear) # tool_layout.addWidget(clear_btn) # tool_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding)) # tool_layout.addWidget(close_button) # main_layout.addWidget(toolbar) main_layout.addWidget(self._stack) # Widgets # errors_tree = IDE.get_service('errors_tree') from ninja_ide.gui.tools_dock import find_in_files self.widgets = [ self._run_widget, console_widget.ConsoleWidget(), find_in_files.FindInFilesWidget(), # errors_tree ] # Intall widgets number = 1 for wi in self.widgets: if wi is None: continue btn = ToolButton(number, wi.display_name()) btn.setCheckable(True) # Action # action = QAction(wi.display_name(), self) # action.triggered.connect(self._triggered) number += 1 self.__buttons.append(btn) self._buttons_widget.layout().addWidget(btn) self._stack.addWidget(wi) btn.clicked.connect(self._button_triggered) # Toolbar buttons container = ui_tools.StyledBar(self._tool_stack) container.setProperty('border', True) tool_buttons_layout = QVBoxLayout() tool_buttons_layout.setContentsMargins(0, 0, 0, 0) tool_buttons_layout.setSpacing(0) for b in wi.button_widgets(): tool_buttons_layout.addWidget(b) tool_buttons_layout.addStretch(5) container.setLayout(tool_buttons_layout) self._tool_stack.addWidget(container) self._buttons_widget.layout().addItem( QSpacerItem(0, 0, QSizePolicy.Expanding)) self.__current_widget = self._stack.currentWidget() self.set_current_index(0)
def setup_ui(self): """Load all the components of the ui during the install process.""" vbox = QVBoxLayout(self) vbox.setContentsMargins(0, 0, 0, 0) vbox.setSpacing(0) self.__toolbar = QToolBar() self.__toolbar.setObjectName('custom') hbox = QHBoxLayout() vbox.addLayout(hbox) self.stack = StackedWidget() vbox.addWidget(self.stack) self._console = console_widget.ConsoleWidget() self.stack.addWidget(self._console) self._runWidget = run_widget.RunWidget() self.stack.addWidget(self._runWidget) self._web = web_render.WebRender() self.stack.addWidget(self._web) self._findInFilesWidget = find_in_files.FindInFilesWidget( self.parent()) self.stack.addWidget(self._findInFilesWidget) #Last Element in the Stacked widget self._results = results.Results(self) self.stack.addWidget(self._results) self._btnConsole = QPushButton(QIcon(":img/console"), '') self._btnConsole.setToolTip(self.tr("Console")) self._btnRun = QPushButton(QIcon(":img/play"), '') self._btnRun.setToolTip(self.tr("Output")) self._btnWeb = QPushButton(QIcon(":img/web"), '') self._btnWeb.setToolTip(self.tr("Web Preview")) self._btnFind = QPushButton(QIcon(":img/find"), '') self._btnFind.setToolTip(self.tr("Find in Files")) #Toolbar hbox.addWidget(self.__toolbar) self.__toolbar.addWidget(self._btnConsole) self.__toolbar.addWidget(self._btnRun) self.__toolbar.addWidget(self._btnWeb) self.__toolbar.addWidget(self._btnFind) self.__toolbar.addSeparator() hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding)) btn_close = QPushButton( self.style().standardIcon(QStyle.SP_DialogCloseButton), '') btn_close.setObjectName('navigation_button') btn_close.setToolTip(self.tr('F4: Show/Hide')) hbox.addWidget(btn_close) # Not Configurable Shortcuts shortEscMisc = QShortcut(QKeySequence(Qt.Key_Escape), self) self.connect(shortEscMisc, SIGNAL("activated()"), self.hide) self.connect(self._btnConsole, SIGNAL("clicked()"), lambda: self._item_changed(0)) self.connect(self._btnRun, SIGNAL("clicked()"), lambda: self._item_changed(1)) self.connect(self._btnWeb, SIGNAL("clicked()"), lambda: self._item_changed(2)) self.connect(self._btnFind, SIGNAL("clicked()"), lambda: self._item_changed(3)) self.connect(btn_close, SIGNAL('clicked()'), self.hide)