def updateAction( self ): """ Updates the action to edit based on the current item. """ item = self.uiActionTREE.currentItem() if ( item ): action = item.action() else: action = QAction() self.uiShortcutTXT.setText(action.shortcut().toString())
def clear(self, autoBuild=True): """ Clears the actions for this widget. """ for action in self._actionGroup.actions(): self._actionGroup.removeAction(action) action = QAction('', self) action.setObjectName('place_holder') self._actionGroup.addAction(action) if autoBuild: self.rebuild()
def _addDatasetAction(self, dataset): """ Adds an action for the inputed dataset to the toolbar :param dataset | <XChartDataset> """ # create the toolbar action action = QAction(dataset.name(), self) action.setIcon(XColorIcon(dataset.color())) action.setCheckable(True) action.setChecked(True) action.setData(wrapVariant(dataset)) action.toggled.connect(self.toggleDataset) self.uiDatasetTBAR.addAction(action)
def addAction( self, action ): """ Adds the inputed action to this widget's action group. This will auto-\ create a new group if no group is already defined. :param action | <QAction> || <str> :return <QAction> """ if not isinstance(action, QAction): action_name = nativestring(action) action = QAction(action_name, self) action.setObjectName(action_name) action.setCheckable(True) if ( not self._actionGroup ): self._actionGroup = QActionGroup(self) action.setChecked(True) self._actionGroup.addAction(action) self.reset() return action
def __init__(self, parent=None): super(XRichTextEdit, self).__init__(parent) # load the user interface projexui.loadUi(__file__, self) # define custom properties # set default properties self.setFocusProxy(self.uiEditTXT) self.uiFindWGT.setTextEdit(self.uiEditTXT) self.uiFindWGT.hide() self.editor().setTabStopWidth(16) self.editor().document().setIndentWidth(24) self.editor().installEventFilter(self) self.editor().setRichTextEditEnabled(True) # create the font picker widget self._fontPickerWidget = XFontPickerWidget(self) self.uiFontBTN.setDefaultAnchor(XPopupWidget.Anchor.TopLeft) self.uiFontBTN.setCentralWidget(self._fontPickerWidget) popup = self.uiFontBTN.popupWidget() popup.setResizable(False) popup.setShowTitleBar(False) self._fontPickerWidget.accepted.connect(popup.accept) # generate actions for this editor based on the toolbar buttons self._actions = {} for mapping in (('bold', self.uiBoldBTN, 'Ctrl+B'), ('italic', self.uiItalicBTN, 'Ctrl+I'), ('underline', self.uiUnderlineBTN, 'Ctrl+U'), ('strikeOut', self.uiStrikeoutBTN, ''), ('unordered', self.uiUnorderedBTN, ''), ('ordered', self.uiOrderedBTN, ''), ('table', self.uiTableBTN, ''), ('align_left', self.uiAlignLeftBTN, ''), ('align_right', self.uiAlignRightBTN, ''), ('align_center', self.uiAlignCenterBTN, ''), ('align_justify', self.uiAlignJustifyBTN, ''), ('font_color', self.uiFontColorBTN, ''), ('bg_color', self.uiBackgroundColorBTN, '')): name, btn, shortcut = mapping act = QAction(self) act.setObjectName(name) act.setToolTip(btn.toolTip()) act.setIcon(btn.icon()) act.setShortcut(QKeySequence(shortcut)) act.setCheckable(btn.isCheckable()) act.setChecked(btn.isChecked()) act.setShortcutContext(Qt.WidgetWithChildrenShortcut) btn.setDefaultAction(act) self._actions[name] = act self.addAction(act) # create the action groupings popup.resetRequested.connect(self.updateFontPicker) popup.aboutToShow.connect(self.updateFontPicker) popup.accepted.connect(self.assignFont) align_group = QActionGroup(self) align_group.addAction(self._actions['align_left']) align_group.addAction(self._actions['align_right']) align_group.addAction(self._actions['align_center']) align_group.addAction(self._actions['align_justify']) align_group.triggered.connect(self.assignAlignment) self._actions['align_left'].setChecked(True) # create connections self._actions['bold'].toggled.connect(self.setFontBold) self._actions['italic'].toggled.connect(self.setFontItalic) self._actions['underline'].toggled.connect(self.setFontUnderline) self._actions['strikeOut'].toggled.connect(self.setFontStrikeOut) self._actions['ordered'].triggered.connect(self.insertOrderedList) self._actions['unordered'].triggered.connect(self.insertUnorderedList) self._actions['table'].triggered.connect(self.insertTable) self._actions['font_color'].triggered.connect(self.pickTextColor) self._actions['bg_color'].triggered.connect( self.pickTextBackgroundColor) # link signals from the editor to the system for signal in ('copyAvailable', 'currentCharFormatChanged', 'cursorPositionChanged', 'redoAvailable', 'selectionChanged', 'textChanged', 'undoAvailable'): from_ = getattr(self.uiEditTXT, signal) to_ = getattr(self, signal) from_.connect(to_) self.cursorPositionChanged.connect(self.refreshAlignmentUi) self.currentCharFormatChanged.connect(self.refreshUi)
class XFindWidget(QWidget): """ """ __designer_icon__ = resources.find('img/search.png') def __init__( self, parent = None ): super(XFindWidget, self).__init__( parent ) # define custom properties self._textEdit = None self._webView = None self._lastCursor = QTextCursor() self._lastText = '' self._closeButton = QToolButton(self) self._closeButton.setIcon(QIcon(resources.find('img/close.png'))) self._closeButton.setAutoRaise(True) self._closeButton.setToolTip('Hide the Find Field.') self._searchEdit = XLineEdit(self) self._searchEdit.setHint('search for...') self._previousButton = QToolButton(self) self._previousButton.setIcon(QIcon(resources.find('img/back.png'))) self._previousButton.setAutoRaise(True) self._previousButton.setToolTip('Find Previous') self._nextButton = QToolButton(self) self._nextButton.setIcon(QIcon(resources.find('img/forward.png'))) self._nextButton.setAutoRaise(True) self._nextButton.setToolTip('Find Next') self._caseSensitiveCheckbox = QCheckBox(self) self._caseSensitiveCheckbox.setText('Case Sensitive') self._wholeWordsCheckbox = QCheckBox(self) self._wholeWordsCheckbox.setText('Whole Words Only') self._regexCheckbox = QCheckBox(self) self._regexCheckbox.setText('Use Regex') self._findAction = QAction(self) self._findAction.setText('Find...') self._findAction.setIcon(QIcon(resources.find('img/search.png'))) self._findAction.setToolTip('Find in Text') self._findAction.setShortcut(QKeySequence('Ctrl+F')) self._findAction.setShortcutContext(Qt.WidgetWithChildrenShortcut) # layout the widgets layout = QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget( self._closeButton ) layout.addWidget( self._searchEdit ) layout.addWidget( self._previousButton ) layout.addWidget( self._nextButton ) layout.addWidget( self._caseSensitiveCheckbox ) layout.addWidget( self._wholeWordsCheckbox ) layout.addWidget( self._regexCheckbox ) self.setLayout(layout) # create connections self._findAction.triggered.connect( self.show ) self._searchEdit.textChanged.connect( self.findNext ) self._closeButton.clicked.connect( self.hide ) self._previousButton.clicked.connect( self.findPrev ) self._nextButton.clicked.connect( self.findNext ) self._caseSensitiveCheckbox.clicked.connect( self.findNext ) self._wholeWordsCheckbox.clicked.connect( self.findNext ) self._searchEdit.returnPressed.connect( self.findNext ) self._regexCheckbox.clicked.connect( self.findNext ) def find( self, flags = 0 ): """ Looks throught the text document based on the current criteria. The \ inputed flags will be merged with the generated search flags. :param flags | <QTextDocument.FindFlag> :return <bool> | success """ # check against the web and text views if ( not (self._textEdit or self._webView) ): fg = QColor('darkRed') bg = QColor('red').lighter(180) palette = self.palette() palette.setColor(palette.Text, fg) palette.setColor(palette.Base, bg) self._searchEdit.setPalette(palette) self._searchEdit.setToolTip( 'No Text Edit is linked.' ) return False if ( self._caseSensitiveCheckbox.isChecked() ): flags |= QTextDocument.FindCaseSensitively if ( self._textEdit and self._wholeWordsCheckbox.isChecked() ): flags |= QTextDocument.FindWholeWords terms = self._searchEdit.text() if ( terms != self._lastText ): self._lastCursor = QTextCursor() if ( self._regexCheckbox.isChecked() ): terms = QRegExp(terms) palette = self.palette() # search on a text edit if ( self._textEdit ): cursor = self._textEdit.document().find(terms, self._lastCursor, QTextDocument.FindFlags(flags)) found = not cursor.isNull() self._lastCursor = cursor self._textEdit.setTextCursor(cursor) elif ( QWebPage ): flags = QWebPage.FindFlags(flags) flags |= QWebPage.FindWrapsAroundDocument found = self._webView.findText(terms, flags) self._lastText = self._searchEdit.text() if ( not terms or found ): fg = palette.color(palette.Text) bg = palette.color(palette.Base) else: fg = QColor('darkRed') bg = QColor('red').lighter(180) palette.setColor(palette.Text, fg) palette.setColor(palette.Base, bg) self._searchEdit.setPalette(palette) return found def findNext( self ): """ Looks for the search terms that come up next based on the criteria. :return <bool> | success """ return self.find() def findPrev( self ): """ Looks for the search terms that come up last based on the criteria. :return <bool> | success """ return self.find(QTextDocument.FindBackward) def setTextEdit( self, textEdit ): """ Sets the text edit that this find widget will use to search. :param textEdit | <QTextEdit> """ if ( self._textEdit ): self._textEdit.removeAction(self._findAction) self._textEdit = textEdit if ( textEdit ): textEdit.addAction(self._findAction) def setWebView( self, webView ): """ Sets the web view edit that this find widget will use to search. :param webView | <QWebView> """ if ( self._webView ): self._webView.removeAction(self._findAction) self._webView = webView if ( webView ): webView.addAction(self._findAction) def show( self ): """ Sets this widget visible and then makes the find field have focus. """ super(XFindWidget, self).show() self._searchEdit.setFocus() def textEdit( self ): """ Returns the text edit linked with this find widget. :return <QTextEdit> """ return self._textEdit def webView( self ): """ Returns the text edit linked with this find widget. :return <QWebView> """ return self._webView
def __init__( self, parent = None ): super(XFindWidget, self).__init__( parent ) # define custom properties self._textEdit = None self._webView = None self._lastCursor = QTextCursor() self._lastText = '' self._closeButton = QToolButton(self) self._closeButton.setIcon(QIcon(resources.find('img/close.png'))) self._closeButton.setAutoRaise(True) self._closeButton.setToolTip('Hide the Find Field.') self._searchEdit = XLineEdit(self) self._searchEdit.setHint('search for...') self._previousButton = QToolButton(self) self._previousButton.setIcon(QIcon(resources.find('img/back.png'))) self._previousButton.setAutoRaise(True) self._previousButton.setToolTip('Find Previous') self._nextButton = QToolButton(self) self._nextButton.setIcon(QIcon(resources.find('img/forward.png'))) self._nextButton.setAutoRaise(True) self._nextButton.setToolTip('Find Next') self._caseSensitiveCheckbox = QCheckBox(self) self._caseSensitiveCheckbox.setText('Case Sensitive') self._wholeWordsCheckbox = QCheckBox(self) self._wholeWordsCheckbox.setText('Whole Words Only') self._regexCheckbox = QCheckBox(self) self._regexCheckbox.setText('Use Regex') self._findAction = QAction(self) self._findAction.setText('Find...') self._findAction.setIcon(QIcon(resources.find('img/search.png'))) self._findAction.setToolTip('Find in Text') self._findAction.setShortcut(QKeySequence('Ctrl+F')) self._findAction.setShortcutContext(Qt.WidgetWithChildrenShortcut) # layout the widgets layout = QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget( self._closeButton ) layout.addWidget( self._searchEdit ) layout.addWidget( self._previousButton ) layout.addWidget( self._nextButton ) layout.addWidget( self._caseSensitiveCheckbox ) layout.addWidget( self._wholeWordsCheckbox ) layout.addWidget( self._regexCheckbox ) self.setLayout(layout) # create connections self._findAction.triggered.connect( self.show ) self._searchEdit.textChanged.connect( self.findNext ) self._closeButton.clicked.connect( self.hide ) self._previousButton.clicked.connect( self.findPrev ) self._nextButton.clicked.connect( self.findNext ) self._caseSensitiveCheckbox.clicked.connect( self.findNext ) self._wholeWordsCheckbox.clicked.connect( self.findNext ) self._searchEdit.returnPressed.connect( self.findNext ) self._regexCheckbox.clicked.connect( self.findNext )
def __init__(self, parent=None): super(XChart, self).__init__(parent) # load the interface projexui.loadUi(__file__, self) # define custom properties self._renderer = None self._chartTitle = '' self._axes = [] self._datasets = [] self._horizontalAxis = None self._verticalAxis = None self._showDatasetToolbar = True self._showTypeButton = True self._dataChanged = False self._showGrid = True self._showRows = True self._showColumns = True self._showXAxis = True self._showYAxis = True # set default properties self.uiChartVIEW.setScene(XChartScene(self)) self.uiXAxisVIEW.setScene(XChartScene(self)) self.uiYAxisVIEW.setScene(XChartScene(self)) self.uiChartVIEW.setAlignment(Qt.AlignTop | Qt.AlignLeft) self.uiXAxisVIEW.setAlignment(Qt.AlignTop | Qt.AlignLeft) self.uiYAxisVIEW.setAlignment(Qt.AlignTop | Qt.AlignLeft) self.uiDatasetTBAR.setFixedHeight(32) self.uiXAxisVIEW.hide() self.uiYAxisVIEW.hide() self.setAutoFillBackground(True) self.setBackgroundRole(QPalette.Base) self.setStyleSheet(STYLE) self.uiChartVIEW.setMouseTracking(True) self.uiDatasetTBAR.setStyleSheet(TOOLBAR_STYLE) # load renderers for renderer in XChartRenderer.plugins(): act = QAction('%s Chart' % renderer, self) ico = 'img/chart/%s.png' % renderer.lower() act.setIcon(QIcon(resources.find(ico))) self.uiTypeBTN.addAction(act) # assign the default renderer if not self.uiTypeBTN.defaultAction(): self._renderer = XChartRenderer.plugin(renderer) self.uiTypeBTN.setDefaultAction(act) # create connections chart_hbar = self.uiChartVIEW.horizontalScrollBar() chart_vbar = self.uiChartVIEW.verticalScrollBar() x_bar = self.uiXAxisVIEW.horizontalScrollBar() y_bar = self.uiYAxisVIEW.verticalScrollBar() chart_hbar.valueChanged.connect(self.syncScrollbars) chart_hbar.rangeChanged.connect(self.syncScrollbars) y_bar.valueChanged.connect(self.syncScrollbars) y_bar.rangeChanged.connect(self.syncScrollbars) self.uiTypeBTN.triggered.connect(self.assignRenderer)
def __init__(self, parent=None): super(XChart, self).__init__(parent) # load the interface projexui.loadUi(__file__, self) # define custom properties self._renderer = None self._chartTitle = "" self._axes = [] self._datasets = [] self._horizontalAxis = None self._verticalAxis = None self._showDatasetToolbar = True self._showTypeButton = True self._dataChanged = False self._showGrid = True self._showRows = True self._showColumns = True self._showXAxis = True self._showYAxis = True # set default properties self.uiChartVIEW.setScene(XChartScene(self)) self.uiXAxisVIEW.setScene(XChartScene(self)) self.uiYAxisVIEW.setScene(XChartScene(self)) self.uiChartVIEW.setAlignment(Qt.AlignTop | Qt.AlignLeft) self.uiXAxisVIEW.setAlignment(Qt.AlignTop | Qt.AlignLeft) self.uiYAxisVIEW.setAlignment(Qt.AlignTop | Qt.AlignLeft) self.uiDatasetTBAR.setFixedHeight(32) self.uiXAxisVIEW.hide() self.uiYAxisVIEW.hide() self.setAutoFillBackground(True) self.setBackgroundRole(QPalette.Base) self.setStyleSheet(STYLE) self.uiChartVIEW.setMouseTracking(True) self.uiDatasetTBAR.setStyleSheet(TOOLBAR_STYLE) # load renderers for renderer in XChartRenderer.plugins(): act = QAction("%s Chart" % renderer, self) ico = "img/chart/%s.png" % renderer.lower() act.setIcon(QIcon(resources.find(ico))) self.uiTypeBTN.addAction(act) # assign the default renderer if not self.uiTypeBTN.defaultAction(): self._renderer = XChartRenderer.plugin(renderer) self.uiTypeBTN.setDefaultAction(act) # create connections chart_hbar = self.uiChartVIEW.horizontalScrollBar() chart_vbar = self.uiChartVIEW.verticalScrollBar() x_bar = self.uiXAxisVIEW.horizontalScrollBar() y_bar = self.uiYAxisVIEW.verticalScrollBar() chart_hbar.valueChanged.connect(self.syncScrollbars) chart_hbar.rangeChanged.connect(self.syncScrollbars) y_bar.valueChanged.connect(self.syncScrollbars) y_bar.rangeChanged.connect(self.syncScrollbars) self.uiTypeBTN.triggered.connect(self.assignRenderer)
def setupActions(self): viewWidget = self.viewWidget() self.addSection('Views') self._pluginMenu = XViewPluginMenu(self.viewWidget()) self._pluginMenu.setTitle('Switch View') self.addMenu(self._pluginMenu) self._pluginMenu.triggered.disconnect(self._pluginMenu.addView) self._pluginMenu.setIcon(QIcon(resources.find('img/view/switch.png'))) self._pluginMenu.triggered.connect(self.swapTabType) # create view grouping options self._groupingMenu = self.addMenu('Set Group') icon = QIcon(resources.find('img/view/group.png')) self._groupingMenu.setIcon(icon) act = self._groupingMenu.addAction('No Grouping') act.setData(wrapVariant(0)) act.setCheckable(True) self._groupingMenu.addSeparator() self._groupingGroup.addAction(act) for i in range(1, 6): act = self._groupingMenu.addAction('Group %i' % i) act.setData(wrapVariant(i)) act.setCheckable(True) self._groupingGroup.addAction(act) self._groupingMenu.triggered.connect(self.assignGroup) self.setTitle('Tabs') self.addSection('Tabs') act = self.addAction('Rename Tab') act.setIcon(QIcon(resources.find('img/edit.png'))) act.triggered.connect(self.renamePanel) act = self.addAction('Detach Tab') act.setIcon(QIcon(resources.find('img/view/detach.png'))) act.triggered.connect(self.detachPanel) act = self.addAction('Detach Tab (as a Copy)') act.setIcon(QIcon(resources.find('img/view/detach_copy.png'))) act.triggered.connect(self.detachPanelCopy) act = self.addAction('Close Tab') act.setIcon(QIcon(resources.find('img/view/tab_remove.png'))) act.triggered.connect(self.closeView) self.addSeparator() act = self.addAction('Hide Tabs when Locked') act.triggered[bool].connect(self.setHideTabsWhenLocked) act.setCheckable(True) self._hideAction = act self.addSection('Panels') act = self.addAction('Split Panel Left/Right') act.setIcon(QIcon(resources.find('img/view/split_horizontal.png'))) act.triggered.connect(self.splitHorizontal) split_adv = QAction(self) split_adv.setIcon(QIcon(resources.find('img/advanced.png'))) split_adv.setToolTip('Specify number of columns for split') split_adv.triggered.connect(self.splitHorizontalAdvanced) self.setAdvancedAction(act, split_adv) act = self.addAction('Split Panel Top/Bottom') act.setIcon(QIcon(resources.find('img/view/split_vertical.png'))) act.triggered.connect(self.splitVertical) split_adv = QAction(self) split_adv.setIcon(QIcon(resources.find('img/advanced.png'))) split_adv.setToolTip('Specify number of rows for split') split_adv.triggered.connect(self.splitVerticalAdvanced) self.setAdvancedAction(act, split_adv)
def __init__(self, parent=None): super(XRichTextEdit, self).__init__(parent) # load the user interface projexui.loadUi(__file__, self) # define custom properties # set default properties self.setFocusProxy(self.uiEditTXT) self.uiFindWGT.setTextEdit(self.uiEditTXT) self.uiFindWGT.hide() self.editor().setTabStopWidth(16) self.editor().document().setIndentWidth(24) self.editor().installEventFilter(self) self.editor().setRichTextEditEnabled(True) # create the font picker widget self._fontPickerWidget = XFontPickerWidget(self) self.uiFontBTN.setDefaultAnchor(XPopupWidget.Anchor.TopLeft) self.uiFontBTN.setCentralWidget(self._fontPickerWidget) popup = self.uiFontBTN.popupWidget() popup.setResizable(False) popup.setShowTitleBar(False) self._fontPickerWidget.accepted.connect(popup.accept) # generate actions for this editor based on the toolbar buttons self._actions = {} for mapping in ( ("bold", self.uiBoldBTN, "Ctrl+B"), ("italic", self.uiItalicBTN, "Ctrl+I"), ("underline", self.uiUnderlineBTN, "Ctrl+U"), ("strikeOut", self.uiStrikeoutBTN, ""), ("unordered", self.uiUnorderedBTN, ""), ("ordered", self.uiOrderedBTN, ""), ("table", self.uiTableBTN, ""), ("align_left", self.uiAlignLeftBTN, ""), ("align_right", self.uiAlignRightBTN, ""), ("align_center", self.uiAlignCenterBTN, ""), ("align_justify", self.uiAlignJustifyBTN, ""), ("font_color", self.uiFontColorBTN, ""), ("bg_color", self.uiBackgroundColorBTN, ""), ): name, btn, shortcut = mapping act = QAction(self) act.setObjectName(name) act.setToolTip(btn.toolTip()) act.setIcon(btn.icon()) act.setShortcut(QKeySequence(shortcut)) act.setCheckable(btn.isCheckable()) act.setChecked(btn.isChecked()) act.setShortcutContext(Qt.WidgetWithChildrenShortcut) btn.setDefaultAction(act) self._actions[name] = act self.addAction(act) # create the action groupings popup.resetRequested.connect(self.updateFontPicker) popup.aboutToShow.connect(self.updateFontPicker) popup.accepted.connect(self.assignFont) align_group = QActionGroup(self) align_group.addAction(self._actions["align_left"]) align_group.addAction(self._actions["align_right"]) align_group.addAction(self._actions["align_center"]) align_group.addAction(self._actions["align_justify"]) align_group.triggered.connect(self.assignAlignment) self._actions["align_left"].setChecked(True) # create connections self._actions["bold"].toggled.connect(self.setFontBold) self._actions["italic"].toggled.connect(self.setFontItalic) self._actions["underline"].toggled.connect(self.setFontUnderline) self._actions["strikeOut"].toggled.connect(self.setFontStrikeOut) self._actions["ordered"].triggered.connect(self.insertOrderedList) self._actions["unordered"].triggered.connect(self.insertUnorderedList) self._actions["table"].triggered.connect(self.insertTable) self._actions["font_color"].triggered.connect(self.pickTextColor) self._actions["bg_color"].triggered.connect(self.pickTextBackgroundColor) # link signals from the editor to the system for signal in ( "copyAvailable", "currentCharFormatChanged", "cursorPositionChanged", "redoAvailable", "selectionChanged", "textChanged", "undoAvailable", ): from_ = getattr(self.uiEditTXT, signal) to_ = getattr(self, signal) from_.connect(to_) self.cursorPositionChanged.connect(self.refreshAlignmentUi) self.currentCharFormatChanged.connect(self.refreshUi)
def setupActions(self): # initialize the menu viewWidget = self.viewWidget() self.setTitle('Panel Options') self.addSection('Panels') act = self.addAction('Split Panel Left/Right') act.setIcon(QIcon(resources.find('img/view/split_horizontal.png'))) act.triggered.connect(self.splitHorizontal) split_adv = QAction(self) split_adv.setIcon(QIcon(resources.find('img/advanced.png'))) split_adv.setToolTip('Specify number of columns for split') split_adv.triggered.connect(self.splitHorizontalAdvanced) self.setAdvancedAction(act, split_adv) act = self.addAction('Split Panel Top/Bottom') act.setIcon(QIcon(resources.find('img/view/split_vertical.png'))) act.triggered.connect(self.splitVertical) split_adv = QAction(self) split_adv.setIcon(QIcon(resources.find('img/advanced.png'))) split_adv.setToolTip('Specify number of rows for split') split_adv.triggered.connect(self.splitVerticalAdvanced) self.setAdvancedAction(act, split_adv) self.addSeparator() menu = self.addMenu('Add...') menu.setIcon(QIcon(resources.find('img/view/add.png'))) act = menu.addAction('Row Above') act.setIcon(QIcon(resources.find('img/view/up.png'))) act = menu.addAction('Row Below') act.setIcon(QIcon(resources.find('img/view/down.png'))) menu.addSeparator() act = menu.addAction('Column Left') act.setIcon(QIcon(resources.find('img/view/left.png'))) act = menu.addAction('Column Right') act.setIcon(QIcon(resources.find('img/view/right.png'))) menu.triggered.connect(self.addPanel) # create pane options menu menu = self.addMenu('Move...') menu.setIcon(QIcon(resources.find('img/view/switch.png'))) act = menu.addAction('Row Up') act.setIcon(QIcon(resources.find('img/view/up.png'))) act = menu.addAction('Row Down') act.setIcon(QIcon(resources.find('img/view/down.png'))) menu.addSeparator() act = menu.addAction('Column Left') act.setIcon(QIcon(resources.find('img/view/left.png'))) act = menu.addAction('Column Right') act.setIcon(QIcon(resources.find('img/view/right.png'))) menu.triggered.connect(self.switchPanels) self.addSeparator() act = self.addAction('Close Section (All Tabs)') act.setIcon(QIcon(resources.find('img/view/close.png'))) act.triggered.connect(self.closePanel)
def addAction(self, action, checked=None, autoBuild=True): """ Adds the inputed action to this widget's action group. This will auto-\ create a new group if no group is already defined. :param action | <QAction> || <str> :return <QAction> """ # clear the holder actions = self._actionGroup.actions() if actions and actions[0].objectName() == 'place_holder': self._actionGroup.removeAction(actions[0]) actions[0].deleteLater() # create an action from the name if not isinstance(action, QAction): action_name = nativestring(action) action = QAction(action_name, self) action.setObjectName(action_name) action.setCheckable(self.isCheckable()) # auto-check the first option if checked or (not self._actionGroup.actions() and checked is None): action.setChecked(True) elif self.isCheckable(): action.setCheckable(True) if not self.currentAction(): action.setChecked(True) self._actionGroup.addAction(action) if autoBuild: self.rebuild() return action
def setupActions(self): # initialize the menu viewWidget = self.viewWidget() self.setTitle('Panel Options') self.addSection('Panels') act = self.addAction('Split Panel Left/Right') act.setIcon(QIcon(resources.find('img/view/split_horizontal.png'))) act.triggered.connect(self.splitHorizontal) split_adv = QAction(self) split_adv.setIcon(QIcon(resources.find('img/advanced.png'))) split_adv.setToolTip('Specify number of columns for split') split_adv.triggered.connect(self.splitHorizontalAdvanced) self.setAdvancedAction(act, split_adv) act = self.addAction('Split Panel Top/Bottom') act.setIcon(QIcon(resources.find('img/view/split_vertical.png'))) act.triggered.connect(self.splitVertical) split_adv = QAction(self) split_adv.setIcon(QIcon(resources.find('img/advanced.png'))) split_adv.setToolTip('Specify number of rows for split') split_adv.triggered.connect(self.splitVerticalAdvanced) self.setAdvancedAction(act, split_adv) self.addSeparator() menu = self.addMenu('Add...') menu.setIcon(QIcon(resources.find('img/view/add.png'))) act = menu.addAction('Row Above') act.setIcon(QIcon(resources.find('img/view/up.png'))) act = menu.addAction('Row Below') act.setIcon(QIcon(resources.find('img/view/down.png'))) menu.addSeparator() act = menu.addAction('Column Left') act.setIcon(QIcon(resources.find('img/view/left.png'))) act = menu.addAction('Column Right') act.setIcon(QIcon(resources.find('img/view/right.png'))) menu.triggered.connect(self.addPanel) # create pane options menu menu = self.addMenu('Move...') menu.setIcon(QIcon(resources.find('img/view/switch.png'))) act = menu.addAction('Row Up') act.setIcon(QIcon(resources.find('img/view/up.png'))) act = menu.addAction('Row Down') act.setIcon(QIcon(resources.find('img/view/down.png'))) menu.addSeparator() act = menu.addAction('Column Left') act.setIcon(QIcon(resources.find('img/view/left.png'))) act = menu.addAction('Column Right') act.setIcon(QIcon(resources.find('img/view/right.png'))) menu.triggered.connect(self.switchPanels) self.addSeparator() act = self.addAction('Close Section (All Tabs)') act.setIcon(QIcon(resources.find('img/view/close.png'))) act.triggered.connect( self.closePanel )
def setupActions(self): viewWidget = self.viewWidget() self.addSection('Views') self._pluginMenu = XViewPluginMenu(self.viewWidget()) self._pluginMenu.setTitle('Switch View') self.addMenu(self._pluginMenu) self._pluginMenu.triggered.disconnect(self._pluginMenu.addView) self._pluginMenu.setIcon(QIcon(resources.find('img/view/switch.png'))) self._pluginMenu.triggered.connect(self.swapTabType) # create view grouping options self._groupingMenu = self.addMenu('Set Group') icon = QIcon(resources.find('img/view/group.png')) self._groupingMenu.setIcon(icon) act = self._groupingMenu.addAction('No Grouping') act.setData(wrapVariant(0)) act.setCheckable(True) self._groupingMenu.addSeparator() self._groupingGroup.addAction(act) for i in range(1, 6): act = self._groupingMenu.addAction('Group %i' % i) act.setData(wrapVariant(i)) act.setCheckable(True) self._groupingGroup.addAction(act) self._groupingMenu.triggered.connect(self.assignGroup) self.setTitle('Tabs') self.addSection('Tabs') act = self.addAction('Rename Tab') act.setIcon(QIcon(resources.find('img/edit.png'))) act.triggered.connect( self.renamePanel ) act = self.addAction('Detach Tab') act.setIcon(QIcon(resources.find('img/view/detach.png'))) act.triggered.connect( self.detachPanel ) act = self.addAction('Detach Tab (as a Copy)') act.setIcon(QIcon(resources.find('img/view/detach_copy.png'))) act.triggered.connect( self.detachPanelCopy ) act = self.addAction('Close Tab') act.setIcon(QIcon(resources.find('img/view/tab_remove.png'))) act.triggered.connect( self.closeView ) self.addSeparator() act = self.addAction('Hide Tabs when Locked') act.triggered[bool].connect(self.setHideTabsWhenLocked) act.setCheckable(True) self._hideAction = act self.addSection('Panels') act = self.addAction('Split Panel Left/Right') act.setIcon(QIcon(resources.find('img/view/split_horizontal.png'))) act.triggered.connect(self.splitHorizontal) split_adv = QAction(self) split_adv.setIcon(QIcon(resources.find('img/advanced.png'))) split_adv.setToolTip('Specify number of columns for split') split_adv.triggered.connect(self.splitHorizontalAdvanced) self.setAdvancedAction(act, split_adv) act = self.addAction('Split Panel Top/Bottom') act.setIcon(QIcon(resources.find('img/view/split_vertical.png'))) act.triggered.connect(self.splitVertical) split_adv = QAction(self) split_adv.setIcon(QIcon(resources.find('img/advanced.png'))) split_adv.setToolTip('Specify number of rows for split') split_adv.triggered.connect(self.splitVerticalAdvanced) self.setAdvancedAction(act, split_adv)