Ejemplo n.º 1
0
    def __init__(self):
        super(QuickDocPanel, self).__init__(dynamic=True)
        # layouts
        layout = QtWidgets.QHBoxLayout()
        self.setLayout(layout)
        child_layout = QtWidgets.QVBoxLayout()

        # A QTextEdit to show the doc
        self.text_edit = QtWidgets.QTextEdit()
        self.text_edit.setReadOnly(True)
        self.text_edit.setAcceptRichText(True)
        layout.addWidget(self.text_edit)

        # A QPushButton (inside a child layout for a better alignment)
        # to close the panel
        self.bt_close = QtWidgets.QPushButton()
        self.bt_close.setIcon(icons.icon(
            'window-close', ':/pyqode-icons/rc/close.png', 'fa.close'))
        self.bt_close.setIconSize(QtCore.QSize(16, 16))
        self.bt_close.clicked.connect(self.hide)
        child_layout.addWidget(self.bt_close)
        child_layout.addStretch()
        layout.addLayout(child_layout)

        # Action
        self.action_quick_doc = QtWidgets.QAction(
            _('Show documentation'), self)
        self.action_quick_doc.setShortcut('Alt+Q')
        icon = icons.icon(qta_name='fa.book')
        if icon:
            self.action_quick_doc.setIcon(icon)

        self.action_quick_doc.triggered.connect(
            self._on_action_quick_doc_triggered)
Ejemplo n.º 2
0
 def update_actions(self):
     """
     Updates the list of actions.
     """
     self.clear()
     self.recent_files_actions[:] = []
     for file in self.manager.get_recent_files():
         action = QtWidgets.QAction(self)
         action.setText(os.path.split(file)[1])
         action.setToolTip(file)
         action.setStatusTip(file)
         action.setData(file)
         action.setIcon(self.icon_provider.icon(QtCore.QFileInfo(file)))
         action.triggered.connect(self._on_action_triggered)
         self.addAction(action)
         self.recent_files_actions.append(action)
     self.addSeparator()
     action_clear = QtWidgets.QAction('Clear list', self)
     action_clear.triggered.connect(self.clear_recent_files)
     if isinstance(self.clear_icon, QtGui.QIcon):
         action_clear.setIcon(self.clear_icon)
     elif self.clear_icon:
         theme = ''
         if len(self.clear_icon) == 2:
             theme, path = self.clear_icon
         else:
             path = self.clear_icon
         icons.icon(theme, path, 'fa.times-circle')
     self.addAction(action_clear)
Ejemplo n.º 3
0
 def update_actions(self):
     """
     Updates the list of actions.
     """
     self.clear()
     self.recent_files_actions[:] = []
     for file in self.manager.get_recent_files():
         action = QtWidgets.QAction(self)
         action.setText(os.path.split(file)[1])
         action.setToolTip(file)
         action.setStatusTip(file)
         action.setData(file)
         action.setIcon(self.icon_provider.icon(QtCore.QFileInfo(file)))
         action.triggered.connect(self._on_action_triggered)
         self.addAction(action)
         self.recent_files_actions.append(action)
     self.addSeparator()
     action_clear = QtWidgets.QAction(_('Clear list'), self)
     action_clear.triggered.connect(self.clear_recent_files)
     if isinstance(self.clear_icon, QtGui.QIcon):
         action_clear.setIcon(self.clear_icon)
     elif self.clear_icon:
         theme = ''
         if len(self.clear_icon) == 2:
             theme, path = self.clear_icon
         else:
             path = self.clear_icon
         icons.icon(theme, path, 'fa.times-circle')
     self.addAction(action_clear)
 def __init__(self, parent=None):
     super(DlgPreferredEncodingsEditor, self).__init__(parent)
     self.ui = dlg_preferred_encodings_editor_ui.Ui_Dialog()
     self.ui.setupUi(self)
     self._load_preferred()
     self.ui.pushButtonAdd.clicked.connect(self._add)
     self.ui.pushButtonAdd.setIcon(icons.icon(
         'go-next', ':/pyqode-icons/rc/go-next.png', 'fa.arrow-right'))
     self.ui.pushButtonRemove.setIcon(icons.icon(
         'go-previous', ':/pyqode-icons/rc/go-previous.png',
         'fa.arrow-left'))
     self.ui.pushButtonRemove.clicked.connect(self._remove)
Ejemplo n.º 5
0
 def __init__(self, parent=None):
     super(DlgPreferredEncodingsEditor, self).__init__(parent)
     self.ui = dlg_preferred_encodings_editor_ui.Ui_Dialog()
     self.ui.setupUi(self)
     self._load_preferred()
     self.ui.pushButtonAdd.clicked.connect(self._add)
     self.ui.pushButtonAdd.setIcon(
         icons.icon('go-next', ':/pyqode-icons/rc/go-next.png',
                    'fa.arrow-right'))
     self.ui.pushButtonRemove.setIcon(
         icons.icon('go-previous', ':/pyqode-icons/rc/go-previous.png',
                    'fa.arrow-left'))
     self.ui.pushButtonRemove.clicked.connect(self._remove)
Ejemplo n.º 6
0
    def _init_actions(self):
        icon_size = QtCore.QSize(16, 16)

        icon = icons.icon('edit-find', ':/pyqode-icons/rc/edit-find.png',
                          'fa.search')
        self.actionSearch.setIcon(icon)
        self.actionSearch.setShortcut('Ctrl+F')
        self.labelSearch.setPixmap(icon.pixmap(icon_size))

        icon = icons.icon(
            'edit-find-replace', ':/pyqode-icons/rc/edit-find-replace.png',
            'fa.search-plus')
        self.actionActionSearchAndReplace.setShortcut(
            'Ctrl+H')
        self.actionActionSearchAndReplace.setIcon(icon)
        self.labelReplace.setPixmap(icon.pixmap(icon_size))

        icon = icons.icon('go-up', ':/pyqode-icons/rc/go-up.png',
                          'fa.arrow-up')
        self.actionFindPrevious.setShortcut('Shift+F3')
        self.actionFindPrevious.setIcon(icon)
        self.toolButtonPrevious.setIcon(icon)
        self.toolButtonPrevious.setIconSize(icon_size)

        icon = icons.icon('go-down', ':/pyqode-icons/rc/go-down.png',
                          'fa.arrow-down')
        self.actionFindNext.setShortcut('F3')
        self.actionFindNext.setIcon(icon)
        self.toolButtonNext.setIcon(icon)
        self.toolButtonNext.setIconSize(icon_size)

        icon = icons.icon('window-close', ':/pyqode-icons/rc/close.png',
                          'fa.close')
        self.toolButtonClose.setIcon(icon)
        self.toolButtonClose.setIconSize(icon_size)

        self.menu = QtWidgets.QMenu(self.editor)
        self.menu.setTitle(_('Search'))
        self.menu.menuAction().setIcon(self.actionSearch.icon())
        self.menu.addAction(self.actionSearch)
        self.actionSearch.setShortcutContext(QtCore.Qt.WidgetShortcut)
        self.menu.addAction(self.actionActionSearchAndReplace)
        self.actionActionSearchAndReplace.setShortcutContext(
            QtCore.Qt.WidgetShortcut)
        self.menu.addAction(self.actionFindNext)
        self.actionFindNext.setShortcutContext(
            QtCore.Qt.WidgetShortcut)
        self.menu.addAction(self.actionFindPrevious)
        self.actionFindPrevious.setShortcutContext(
            QtCore.Qt.WidgetShortcut)
Ejemplo n.º 7
0
    def _init_actions(self):
        icon_size = QtCore.QSize(16, 16)

        icon = icons.icon('edit-find', ':/pyqode-icons/rc/edit-find.png',
                          'fa.search')
        self.actionSearch.setIcon(icon)
        self.actionSearch.setShortcut('Ctrl+F')
        self.labelSearch.setPixmap(icon.pixmap(icon_size))

        icon = icons.icon(
            'edit-find-replace', ':/pyqode-icons/rc/edit-find-replace.png',
            'fa.search-plus')
        self.actionActionSearchAndReplace.setShortcut(
            'Ctrl+H')
        self.actionActionSearchAndReplace.setIcon(icon)
        self.labelReplace.setPixmap(icon.pixmap(icon_size))

        icon = icons.icon('go-up', ':/pyqode-icons/rc/go-up.png',
                          'fa.arrow-up')
        self.actionFindPrevious.setShortcut('Shift+F3')
        self.actionFindPrevious.setIcon(icon)
        self.toolButtonPrevious.setIcon(icon)
        self.toolButtonPrevious.setIconSize(icon_size)

        icon = icons.icon('go-down', ':/pyqode-icons/rc/go-down.png',
                          'fa.arrow-down')
        self.actionFindNext.setShortcut('F3')
        self.actionFindNext.setIcon(icon)
        self.toolButtonNext.setIcon(icon)
        self.toolButtonNext.setIconSize(icon_size)

        icon = icons.icon('window-close', ':/pyqode-icons/rc/close.png',
                          'fa.close')
        self.toolButtonClose.setIcon(icon)
        self.toolButtonClose.setIconSize(icon_size)

        self.menu = QtWidgets.QMenu(self.editor)
        self.menu.setTitle('Search')
        self.menu.menuAction().setIcon(self.actionSearch.icon())
        self.menu.addAction(self.actionSearch)
        self.actionSearch.setShortcutContext(QtCore.Qt.WidgetShortcut)
        self.menu.addAction(self.actionActionSearchAndReplace)
        self.actionActionSearchAndReplace.setShortcutContext(
            QtCore.Qt.WidgetShortcut)
        self.menu.addAction(self.actionFindNext)
        self.actionFindNext.setShortcutContext(
            QtCore.Qt.WidgetShortcut)
        self.menu.addAction(self.actionFindPrevious)
        self.actionFindPrevious.setShortcutContext(
            QtCore.Qt.WidgetShortcut)
    def _on_changed(self):
        """
        Update the tree items
        """
        self._updating = True
        to_collapse = []
        self.clear()
        if self._editor and self._outline_mode and self._folding_panel:
            items, to_collapse = self.to_tree_widget_items(
                self._outline_mode.definitions, to_collapse=to_collapse)
            if len(items):
                self.addTopLevelItems(items)
                self.expandAll()
                for item in reversed(to_collapse):
                    self.collapseItem(item)
                self._updating = False
                return

        # no data
        root = QtWidgets.QTreeWidgetItem()
        root.setText(0, 'No data')
        root.setIcon(0, icons.icon(
            'dialog-information', ':/pyqode-icons/rc/dialog-info.png',
            'fa.info-circle'))
        self.addTopLevelItem(root)
        self._updating = False
Ejemplo n.º 9
0
 def __init__(self):
     super(CheckerPanel, self).__init__()
     self._previous_line = -1
     self.scrollable = True
     self._job_runner = DelayJobRunner(delay=100)
     self.setMouseTracking(True)
     #: Info icon
     self.info_icon = icons.icon(
         'dialog-info', ':pyqode-icons/rc/dialog-info.png',
         'fa.info-circle', qta_options={'color': '#4040DD'})
     self.warning_icon = icons.icon(
         'dialog-warning', ':pyqode-icons/rc/dialog-warning.png',
         'fa.exclamation-triangle', qta_options={'color': '#DDDD40'})
     self.error_icon = icons.icon(
         'dialog-error', ':pyqode-icons/rc/dialog-error.png',
         'fa.exclamation-circle', qta_options={'color': '#DD4040'})
Ejemplo n.º 10
0
 def __init__(self):
     super(CheckerPanel, self).__init__()
     self._previous_line = -1
     self.scrollable = True
     self._job_runner = DelayJobRunner(delay=100)
     self.setMouseTracking(True)
     #: Info icon
     self.info_icon = icons.icon(
         'dialog-info', ':pyqode-icons/rc/dialog-info.png',
         'fa.info-circle', qta_options={'color': '#4040DD'})
     self.warning_icon = icons.icon(
         'dialog-warning', ':pyqode-icons/rc/dialog-warning.png',
         'fa.exclamation-triangle', qta_options={'color': '#DDDD40'})
     self.error_icon = icons.icon(
         'dialog-error', ':pyqode-icons/rc/dialog-error.png',
         'fa.exclamation-circle', qta_options={'color': '#DD4040'})
Ejemplo n.º 11
0
 def __init__(self):
     super(CommentsMode, self).__init__()
     self.action = QtWidgets.QAction("Comment/Uncomment", self.editor)
     self.action.setShortcut("Ctrl+/")
     icon = icons.icon(qta_name='fa.comment')
     if icon:
         self.action.setIcon(icon)
Ejemplo n.º 12
0
    def _on_changed(self):
        """
        Update the tree items
        """
        self._updating = True
        to_collapse = []
        self.clear()
        if self._editor and self._outline_mode and self._folding_panel:
            items, to_collapse = self.to_tree_widget_items(
                self._outline_mode.definitions, to_collapse=to_collapse)
            if len(items):
                self.addTopLevelItems(items)
                self.expandAll()
                for item in reversed(to_collapse):
                    self.collapseItem(item)
                self._updating = False
                return

        # no data
        root = QtWidgets.QTreeWidgetItem()
        root.setText(0, 'No data')
        root.setIcon(
            0,
            icons.icon('dialog-information',
                       ':/pyqode-icons/rc/dialog-info.png', 'fa.info-circle'))
        self.addTopLevelItem(root)
        self._updating = False
        self.sync()
 def __init__(self):
     super(GoToAssignmentsMode, self).__init__()
     self._definitions = []
     self._goto_requested = False
     self.action_goto = QtWidgets.QAction("Go to assignments", self)
     self.action_goto.setShortcut(self.shortcut)
     self.action_goto.triggered.connect(self.request_goto)
     icon = icons.icon(qta_name='fa.share')
     if icon:
         self.action_goto.setIcon(icon)
     self.word_clicked.connect(self._on_word_clicked)
     self._runner = DelayJobRunner(delay=1)
Ejemplo n.º 14
0
    def _init_actions(self):
        icon_size = QtCore.QSize(16, 16)

        icon = icons.icon("edit-find", ":/pyqode-icons/rc/edit-find.png", "fa.search")
        self.actionSearch.setIcon(icon)
        self.actionSearch.setShortcut("Ctrl+F")
        self.labelSearch.setPixmap(icon.pixmap(icon_size))

        icon = icons.icon("edit-find-replace", ":/pyqode-icons/rc/edit-find-replace.png", "fa.search-plus")
        self.actionActionSearchAndReplace.setShortcut("Ctrl+H")
        self.actionActionSearchAndReplace.setIcon(icon)
        self.labelReplace.setPixmap(icon.pixmap(icon_size))

        icon = icons.icon("go-up", ":/pyqode-icons/rc/go-up.png", "fa.arrow-up")
        self.actionFindPrevious.setShortcut("Shift+F3")
        self.actionFindPrevious.setIcon(icon)
        self.toolButtonPrevious.setIcon(icon)
        self.toolButtonPrevious.setIconSize(icon_size)

        icon = icons.icon("go-down", ":/pyqode-icons/rc/go-down.png", "fa.arrow-down")
        self.actionFindNext.setShortcut("F3")
        self.actionFindNext.setIcon(icon)
        self.toolButtonNext.setIcon(icon)
        self.toolButtonNext.setIconSize(icon_size)

        icon = icons.icon("window-close", ":/pyqode-icons/rc/close.png", "fa.close")
        self.toolButtonClose.setIcon(icon)
        self.toolButtonClose.setIconSize(icon_size)

        self.menu = QtWidgets.QMenu(self.editor)
        self.menu.setTitle("Search")
        self.menu.menuAction().setIcon(self.actionSearch.icon())
        self.menu.addAction(self.actionSearch)
        self.actionSearch.setShortcutContext(QtCore.Qt.WidgetShortcut)
        self.menu.addAction(self.actionActionSearchAndReplace)
        self.actionActionSearchAndReplace.setShortcutContext(QtCore.Qt.WidgetShortcut)
        self.menu.addAction(self.actionFindNext)
        self.actionFindNext.setShortcutContext(QtCore.Qt.WidgetShortcut)
        self.menu.addAction(self.actionFindPrevious)
        self.actionFindPrevious.setShortcutContext(QtCore.Qt.WidgetShortcut)
Ejemplo n.º 15
0
    def __init__(self, parent=None,
                 prompt_text=' Search', button_icon=None):
        super(PromptLineEdit, self).__init__(parent)
        self._margin = self.sizeHint().height() - 2
        self._spacing = 0
        self._prompt_text = prompt_text

        self.button = QtWidgets.QToolButton(self)
        if button_icon is None:
            button_icon = icons.icon(
                'edit-clear', ':/pyqode-icons/rc/clear-left.png',
                'fa.times-circle')
        self.button.setIcon(button_icon)
        self.button.setToolTip("Clear")
        self.button.setStyleSheet(
            "QToolButton { border: none; padding: 5px; }")
        self.button.setCursor(QtCore.Qt.ArrowCursor)
        self.button.setFocusPolicy(QtCore.Qt.NoFocus)
        self.set_button_visible(False)
        self.textChanged.connect(self._on_text_changed)
        self.button.clicked.connect(self.clear)
        self.button.clicked.connect(self.clear_clicked.emit)
Ejemplo n.º 16
0
    def __init__(self, parent=None,
                 prompt_text=_(' Search'), button_icon=None):
        super(PromptLineEdit, self).__init__(parent)
        self._margin = self.sizeHint().height() - 2
        self._spacing = 0
        self._prompt_text = prompt_text

        self.button = QtWidgets.QToolButton(self)
        if button_icon is None:
            button_icon = icons.icon(
                'edit-clear', ':/pyqode-icons/rc/clear-left.png',
                'fa.times-circle')
        self.button.setIcon(button_icon)
        self.button.setToolTip(_("Clear"))
        self.button.setStyleSheet(
            "QToolButton { border: none; padding: 5px; }")
        self.button.setCursor(QtCore.Qt.ArrowCursor)
        self.button.setFocusPolicy(QtCore.Qt.NoFocus)
        self.set_button_visible(False)
        self.textChanged.connect(self._on_text_changed)
        self.button.clicked.connect(self.clear)
        self.button.clicked.connect(self.clear_clicked.emit)
Ejemplo n.º 17
0
 def _init_actions(self, create_standard_actions):
     """ Init context menu action """
     menu_advanced = QtWidgets.QMenu(_('Advanced'))
     self.add_menu(menu_advanced)
     self._sub_menus = {'Advanced': menu_advanced}
     if create_standard_actions:
         # Undo
         action = QtWidgets.QAction(_('Undo'), self)
         action.setShortcut('Ctrl+Z')
         action.setIcon(
             icons.icon('edit-undo', ':/pyqode-icons/rc/edit-undo.png',
                        'fa.undo'))
         action.triggered.connect(self.undo)
         self.undoAvailable.connect(action.setVisible)
         action.setVisible(False)
         self.add_action(action, sub_menu=None)
         self.action_undo = action
         # Redo
         action = QtWidgets.QAction(_('Redo'), self)
         action.setShortcut('Ctrl+Y')
         action.setIcon(
             icons.icon('edit-redo', ':/pyqode-icons/rc/edit-redo.png',
                        'fa.repeat'))
         action.triggered.connect(self.redo)
         self.redoAvailable.connect(action.setVisible)
         action.setVisible(False)
         self.add_action(action, sub_menu=None)
         self.action_redo = action
         # Copy
         action = QtWidgets.QAction(_('Copy'), self)
         action.setShortcut(QtGui.QKeySequence.Copy)
         action.setIcon(
             icons.icon('edit-copy', ':/pyqode-icons/rc/edit-copy.png',
                        'fa.copy'))
         action.triggered.connect(self.copy)
         self.add_action(action, sub_menu=None)
         self.action_copy = action
         # cut
         action = QtWidgets.QAction(_('Cut'), self)
         action.setShortcut(QtGui.QKeySequence.Cut)
         action.setIcon(
             icons.icon('edit-cut', ':/pyqode-icons/rc/edit-cut.png',
                        'fa.cut'))
         action.triggered.connect(self.cut)
         self.add_action(action, sub_menu=None)
         self.action_cut = action
         # paste
         action = QtWidgets.QAction(_('Paste'), self)
         action.setShortcut(QtGui.QKeySequence.Paste)
         action.setIcon(
             icons.icon('edit-paste', ':/pyqode-icons/rc/edit-paste.png',
                        'fa.paste'))
         action.triggered.connect(self.paste)
         self.add_action(action, sub_menu=None)
         self.action_paste = action
     # duplicate line
     action = QtWidgets.QAction(_('Duplicate line'), self)
     action.setShortcut('Ctrl+D')
     action.triggered.connect(self.duplicate_line)
     self.add_action(action, sub_menu=None)
     self.action_duplicate_line = action
     # select all
     action = QtWidgets.QAction(_('Select all'), self)
     action.setShortcut(QtGui.QKeySequence.SelectAll)
     action.triggered.connect(self.selectAll)
     self.action_select_all = action
     self.add_action(self.action_select_all, sub_menu=None)
     self.add_separator(sub_menu=None)
     if create_standard_actions:
         # indent
         action = QtWidgets.QAction(_('Indent'), self)
         action.setShortcut('Tab')
         action.setIcon(
             icons.icon('format-indent-more',
                        ':/pyqode-icons/rc/format-indent-more.png',
                        'fa.indent'))
         action.triggered.connect(self.indent)
         self.add_action(action)
         self.action_indent = action
         # unindent
         action = QtWidgets.QAction(_('Un-indent'), self)
         action.setShortcut('Shift+Tab')
         action.setIcon(
             icons.icon('format-indent-less',
                        ':/pyqode-icons/rc/format-indent-less.png',
                        'fa.dedent'))
         action.triggered.connect(self.un_indent)
         self.add_action(action)
         self.action_un_indent = action
         self.add_separator()
     # goto
     action = QtWidgets.QAction(_('Go to line'), self)
     action.setShortcut('Ctrl+G')
     action.setIcon(
         icons.icon('go-jump', ':/pyqode-icons/rc/goto-line.png',
                    'fa.share'))
     action.triggered.connect(self.goto_line)
     self.add_action(action)
     self.action_goto_line = action
    def init_actions(self):
        # New - submenu
        self.menu_new = self.addMenu("&New")
        self.menu_new.setIcon(icons.icon("document-new", None, "fa.plus"))
        # https://github.com/pyQode/pyqode.core/pull/153
        new_user_actions = self.get_new_user_actions()
        if len(new_user_actions) > 0:
            self.menu_new.addSeparator()
            for user_new_action in new_user_actions:
                self.menu_new.addAction(user_new_action)
        # New file
        self.action_create_file = QtWidgets.QAction("&File", self)
        self.action_create_file.triggered.connect(self._on_create_file_triggered)
        icon_provider = self.tree_view._icon_provider
        self.action_create_file.setIcon(icon_provider.icon(icon_provider.File))
        self.menu_new.addAction(self.action_create_file)
        # New directory
        self.action_create_directory = QtWidgets.QAction("&Directory", self)
        self.action_create_directory.triggered.connect(self._on_create_directory_triggered)
        self.action_create_directory.setIcon(icon_provider.icon(icon_provider.Folder))
        self.menu_new.addAction(self.action_create_directory)
        self.addSeparator()

        # cut
        self.action_cut = QtWidgets.QAction("&Cut", self)
        self.action_cut.setShortcut(QtGui.QKeySequence.Cut)
        self.action_cut.setIcon(icons.icon("edit-cut", ":/pyqode-icons/rc/edit-cut.png", "fa.cut"))
        self.addAction(self.action_cut)
        self.action_cut.triggered.connect(self._on_cut_triggered)
        # copy
        self.action_copy = QtWidgets.QAction("&Copy", self)
        self.action_copy.setShortcut(QtGui.QKeySequence.Copy)
        self.action_copy.setIcon(icons.icon("edit-copy", ":/pyqode-icons/rc/edit-copy.png", "fa.copy"))
        self.addAction(self.action_copy)
        self.action_copy.triggered.connect(self._on_copy_triggered)
        # copy path
        self.action_copy_path = QtWidgets.QAction("&Copy path", self)
        self.action_copy_path.setShortcut("Ctrl+Shift+C")
        self.addAction(self.action_copy_path)
        self.action_copy_path.triggered.connect(self._on_copy_path_triggered)
        # Paste
        self.action_paste = QtWidgets.QAction("&Paste", self)
        self.action_paste.setShortcut(QtGui.QKeySequence.Paste)
        self.action_paste.setIcon(icons.icon("edit-paste", ":/pyqode-icons/rc/edit-paste.png", "fa.paste"))
        self.action_paste.triggered.connect(self._on_paste_triggered)
        self.addAction(self.action_paste)
        self.addSeparator()
        # Rename
        self.action_rename = QtWidgets.QAction("&Rename", self)
        self.action_rename.setShortcut("F2")
        self.action_rename.triggered.connect(self._on_rename_triggered)
        self.action_rename.setIcon(QtGui.QIcon.fromTheme("edit-rename"))
        self.addAction(self.action_rename)
        # Delete
        self.action_delete = QtWidgets.QAction("&Delete", self)
        self.action_delete.setShortcut(QtGui.QKeySequence.Delete)
        self.action_delete.setIcon(icons.icon("edit-delete", ":/pyqode-icons/rc/edit-delete.png", "fa.remove"))
        self.action_delete.triggered.connect(self._on_delete_triggered)
        self.addAction(self.action_delete)
        self.addSeparator()

        system = platform.system()
        if system == "Windows":
            text = "Open in explorer"
        elif system == "Darwin":
            text = "Open in finder"
        else:
            text = "Show in %s" % self.get_linux_file_explorer().capitalize()
        action = self.action_show_in_explorer = self.addAction(text)
        action.setIcon(QtGui.QIcon.fromTheme("system-file-manager"))
        action.triggered.connect(self._on_show_in_explorer_triggered)
Ejemplo n.º 19
0
 def _init_actions(self, create_standard_actions):
     """ Init context menu action """
     menu_advanced = QtWidgets.QMenu(_("Advanced"))
     self.add_menu(menu_advanced)
     self._sub_menus = {"Advanced": menu_advanced}
     if create_standard_actions:
         # Undo
         action = QtWidgets.QAction(_("Undo"), self)
         action.setShortcut("Ctrl+Z")
         action.setIcon(icons.icon("edit-undo", ":/pyqode-icons/rc/edit-undo.png", "fa.undo"))
         action.triggered.connect(self.undo)
         self.undoAvailable.connect(action.setVisible)
         action.setVisible(False)
         self.add_action(action, sub_menu=None)
         self.action_undo = action
         # Redo
         action = QtWidgets.QAction(_("Redo"), self)
         action.setShortcut("Ctrl+Y")
         action.setIcon(icons.icon("edit-redo", ":/pyqode-icons/rc/edit-redo.png", "fa.repeat"))
         action.triggered.connect(self.redo)
         self.redoAvailable.connect(action.setVisible)
         action.setVisible(False)
         self.add_action(action, sub_menu=None)
         self.action_redo = action
         # Copy
         action = QtWidgets.QAction(_("Copy"), self)
         action.setShortcut(QtGui.QKeySequence.Copy)
         action.setIcon(icons.icon("edit-copy", ":/pyqode-icons/rc/edit-copy.png", "fa.copy"))
         action.triggered.connect(self.copy)
         self.add_action(action, sub_menu=None)
         self.action_copy = action
         # cut
         action = QtWidgets.QAction(_("Cut"), self)
         action.setShortcut(QtGui.QKeySequence.Cut)
         action.setIcon(icons.icon("edit-cut", ":/pyqode-icons/rc/edit-cut.png", "fa.cut"))
         action.triggered.connect(self.cut)
         self.add_action(action, sub_menu=None)
         self.action_cut = action
         # paste
         action = QtWidgets.QAction(_("Paste"), self)
         action.setShortcut(QtGui.QKeySequence.Paste)
         action.setIcon(icons.icon("edit-paste", ":/pyqode-icons/rc/edit-paste.png", "fa.paste"))
         action.triggered.connect(self.paste)
         self.add_action(action, sub_menu=None)
         self.action_paste = action
     # duplicate line
     action = QtWidgets.QAction(_("Duplicate line"), self)
     action.setShortcut("Ctrl+D")
     action.triggered.connect(self.duplicate_line)
     self.add_action(action, sub_menu=None)
     self.action_duplicate_line = action
     # select all
     action = QtWidgets.QAction(_("Select all"), self)
     action.setShortcut(QtGui.QKeySequence.SelectAll)
     action.triggered.connect(self.selectAll)
     self.action_select_all = action
     self.add_action(self.action_select_all, sub_menu=None)
     self.add_separator(sub_menu=None)
     if create_standard_actions:
         # indent
         action = QtWidgets.QAction(_("Indent"), self)
         action.setShortcut("Tab")
         action.setIcon(icons.icon("format-indent-more", ":/pyqode-icons/rc/format-indent-more.png", "fa.indent"))
         action.triggered.connect(self.indent)
         self.add_action(action)
         self.action_indent = action
         # unindent
         action = QtWidgets.QAction(_("Un-indent"), self)
         action.setShortcut("Shift+Tab")
         action.setIcon(icons.icon("format-indent-less", ":/pyqode-icons/rc/format-indent-less.png", "fa.dedent"))
         action.triggered.connect(self.un_indent)
         self.add_action(action)
         self.action_un_indent = action
         self.add_separator()
     # goto
     action = QtWidgets.QAction(_("Go to line"), self)
     action.setShortcut("Ctrl+G")
     action.setIcon(icons.icon("go-jump", ":/pyqode-icons/rc/goto-line.png", "fa.share"))
     action.triggered.connect(self.goto_line)
     self.add_action(action)
     self.action_goto_line = action
Ejemplo n.º 20
0
 def _init_actions(self, create_standard_actions):
     """ Init context menu action """
     if create_standard_actions:
         # Undo
         action = QtWidgets.QAction('Undo', self)
         action.setShortcut(QtGui.QKeySequence.Undo)
         action.setIcon(icons.icon(
             'edit-undo', ':/pyqode-icons/rc/edit-undo.png', 'fa.undo'))
         action.triggered.connect(self.undo)
         self.undoAvailable.connect(action.setEnabled)
         self.add_action(action)
         self.action_undo = action
         # Redo
         action = QtWidgets.QAction('Redo', self)
         action.setShortcut(QtGui.QKeySequence.Redo)
         action.setIcon(icons.icon(
             'edit-redo', ':/pyqode-icons/rc/edit-redo.png', 'fa.repeat'))
         action.triggered.connect(self.redo)
         self.redoAvailable.connect(action.setEnabled)
         self.add_action(action)
         self.action_redo = action
         # separator
         self.add_separator()
         # Copy
         action = QtWidgets.QAction('Copy', self)
         action.setShortcut(QtGui.QKeySequence.Copy)
         action.setIcon(icons.icon(
             'edit-copy', ':/pyqode-icons/rc/edit-copy.png', 'fa.copy'))
         action.triggered.connect(self.copy)
         self.copyAvailable.connect(action.setEnabled)
         self.add_action(action)
         self.action_copy = action
         # cut
         action = QtWidgets.QAction('Cut', self)
         action.setShortcut(QtGui.QKeySequence.Cut)
         action.setIcon(icons.icon(
             'edit-cut', ':/pyqode-icons/rc/edit-cut.png', 'fa.cut'))
         action.triggered.connect(self.cut)
         self.copyAvailable.connect(action.setEnabled)
         self.add_action(action)
         self.action_cut = action
         # paste
         action = QtWidgets.QAction('Paste', self)
         action.setShortcut(QtGui.QKeySequence.Paste)
         action.setIcon(icons.icon(
             'edit-paste', ':/pyqode-icons/rc/edit-paste.png',
             'fa.paste'))
         action.triggered.connect(self.paste)
         self.add_action(action)
         self.action_paste = action
     # duplicate line
     action = QtWidgets.QAction('Duplicate line', self)
     action.setShortcut('Ctrl+D')
     action.triggered.connect(self.duplicate_line)
     self.add_action(action)
     self.action_duplicate_line = action
     # select all
     action = QtWidgets.QAction('Select all', self)
     action.setShortcut(QtGui.QKeySequence.SelectAll)
     action.triggered.connect(self.selectAll)
     self.action_select_all = action
     self.addAction(self.action_select_all)
     if create_standard_actions:
         # delete
         action = QtWidgets.QAction('Delete', self)
         action.setShortcut(QtGui.QKeySequence.Delete)
         action.setIcon(icons.icon(
             'edit-delete', ':/pyqode-icons/rc/edit-delete.png',
             'fa.remove'))
         action.triggered.connect(self.delete)
         self.add_action(action)
         self.action_delete = action
         self.add_separator()
         self.add_action(self.action_select_all)
         # separator
         self.add_separator()
         # indent
         action = QtWidgets.QAction('Indent', self)
         action.setShortcut('Tab')
         action.setIcon(icons.icon(
             'format-indent-more',
             ':/pyqode-icons/rc/format-indent-more.png', 'fa.indent'))
         action.triggered.connect(self.indent)
         self.add_action(action)
         self.action_indent = action
         # unindent
         action = QtWidgets.QAction('Un-indent', self)
         action.setShortcut('Shift+Tab')
         action.setIcon(icons.icon(
             'format-indent-less',
             ':/pyqode-icons/rc/format-indent-less.png', 'fa.dedent'))
         action.triggered.connect(self.un_indent)
         self.add_action(action)
         self.action_un_indent = action
         # separator
         self.add_separator()
     # goto
     action = QtWidgets.QAction('Go to line', self)
     action.setShortcut('Ctrl+G')
     action.setIcon(icons.icon(
         'go-jump', ':/pyqode-icons/rc/goto-line.png', 'fa.share'))
     action.triggered.connect(self.goto_line)
     self.add_action(action)
     self.action_goto_line = action
Ejemplo n.º 21
0
    def init_actions(self):
        # New - submenu
        self.menu_new = self.addMenu("&New")
        self.menu_new.setIcon(icons.icon('document-new', None, 'fa.plus'))
        # https://github.com/pyQode/pyqode.core/pull/153
        new_user_actions = self.get_new_user_actions()
        if len(new_user_actions) > 0:
            self.menu_new.addSeparator()
            for user_new_action in new_user_actions:
                self.menu_new.addAction(user_new_action)
        # New file
        self.action_create_file = QtWidgets.QAction(_('&File'), self)
        self.action_create_file.triggered.connect(
            self._on_create_file_triggered)
        icon_provider = self.tree_view._icon_provider
        self.action_create_file.setIcon(icon_provider.icon(icon_provider.File))
        self.menu_new.addAction(self.action_create_file)
        # New directory
        self.action_create_directory = QtWidgets.QAction(_('&Directory'), self)
        self.action_create_directory.triggered.connect(
            self._on_create_directory_triggered)
        self.action_create_directory.setIcon(
            icon_provider.icon(icon_provider.Folder))
        self.menu_new.addAction(self.action_create_directory)
        self.addSeparator()

        # cut
        self.action_cut = QtWidgets.QAction(_('&Cut'), self)
        self.action_cut.setShortcut(QtGui.QKeySequence.Cut)
        self.action_cut.setIcon(
            icons.icon('edit-cut', ':/pyqode-icons/rc/edit-cut.png', 'fa.cut'))
        self.addAction(self.action_cut)
        self.action_cut.triggered.connect(self._on_cut_triggered)
        # copy
        self.action_copy = QtWidgets.QAction(_('&Copy'), self)
        self.action_copy.setShortcut(QtGui.QKeySequence.Copy)
        self.action_copy.setIcon(
            icons.icon('edit-copy', ':/pyqode-icons/rc/edit-copy.png',
                       'fa.copy'))
        self.addAction(self.action_copy)
        self.action_copy.triggered.connect(self._on_copy_triggered)
        # copy path
        self.action_copy_path = QtWidgets.QAction(_('&Copy path'), self)
        self.action_copy_path.setShortcut('Ctrl+Shift+C')
        self.addAction(self.action_copy_path)
        self.action_copy_path.triggered.connect(self._on_copy_path_triggered)
        # Paste
        self.action_paste = QtWidgets.QAction(_('&Paste'), self)
        self.action_paste.setShortcut(QtGui.QKeySequence.Paste)
        self.action_paste.setIcon(
            icons.icon('edit-paste', ':/pyqode-icons/rc/edit-paste.png',
                       'fa.paste'))
        self.action_paste.triggered.connect(self._on_paste_triggered)
        self.addAction(self.action_paste)
        self.addSeparator()
        # Rename
        self.action_rename = QtWidgets.QAction(_('&Rename'), self)
        self.action_rename.setShortcut('F2')
        self.action_rename.triggered.connect(self._on_rename_triggered)
        self.action_rename.setIcon(QtGui.QIcon.fromTheme('edit-rename'))
        self.addAction(self.action_rename)
        # Delete
        self.action_delete = QtWidgets.QAction(_('&Delete'), self)
        self.action_delete.setShortcut(QtGui.QKeySequence.Delete)
        self.action_delete.setIcon(
            icons.icon('edit-delete', ':/pyqode-icons/rc/edit-delete.png',
                       'fa.remove'))
        self.action_delete.triggered.connect(self._on_delete_triggered)
        self.addAction(self.action_delete)
        self.addSeparator()

        text = 'Show in %s' % self.get_file_explorer_name()
        action = self.action_show_in_explorer = self.addAction(text)
        action.setIcon(QtGui.QIcon.fromTheme('system-file-manager'))
        action.triggered.connect(self._on_show_in_explorer_triggered)
        self._action_show_in_explorer = action
Ejemplo n.º 22
0
 def _init_actions(self, create_standard_actions):
     """ Init context menu action """
     menu_advanced = QtWidgets.QMenu(_('Advanced'))
     self.add_menu(menu_advanced)
     self._sub_menus = {
         'Advanced': menu_advanced
     }
     if create_standard_actions:
         # Undo
         action = QtWidgets.QAction(_('Undo'), self)
         action.setShortcut('Ctrl+Z')
         action.setIcon(icons.icon(
             'edit-undo', ':/pyqode-icons/rc/edit-undo.png', 'fa.undo'))
         action.triggered.connect(self.undo)
         self.undoAvailable.connect(action.setVisible)
         action.setVisible(False)
         self.add_action(action, sub_menu=None)
         self.action_undo = action
         # Redo
         action = QtWidgets.QAction(_('Redo'), self)
         action.setShortcut('Ctrl+Y')
         action.setIcon(icons.icon(
             'edit-redo', ':/pyqode-icons/rc/edit-redo.png', 'fa.repeat'))
         action.triggered.connect(self.redo)
         self.redoAvailable.connect(action.setVisible)
         action.setVisible(False)
         self.add_action(action, sub_menu=None)
         self.action_redo = action
         # Copy
         action = QtWidgets.QAction(_('Copy'), self)
         action.setShortcut(QtGui.QKeySequence.Copy)
         action.setIcon(icons.icon(
             'edit-copy', ':/pyqode-icons/rc/edit-copy.png', 'fa.copy'))
         action.triggered.connect(self.copy)
         self.add_action(action, sub_menu=None)
         self.action_copy = action
         # cut
         action = QtWidgets.QAction(_('Cut'), self)
         action.setShortcut(QtGui.QKeySequence.Cut)
         action.setIcon(icons.icon(
             'edit-cut', ':/pyqode-icons/rc/edit-cut.png', 'fa.cut'))
         action.triggered.connect(self.cut)
         self.add_action(action, sub_menu=None)
         self.action_cut = action
         # paste
         action = QtWidgets.QAction(_('Paste'), self)
         action.setShortcut(QtGui.QKeySequence.Paste)
         action.setIcon(icons.icon(
             'edit-paste', ':/pyqode-icons/rc/edit-paste.png',
             'fa.paste'))
         action.triggered.connect(self.paste)
         self.add_action(action, sub_menu=None)
         self.action_paste = action
     # duplicate line
     action = QtWidgets.QAction(_('Duplicate line'), self)
     action.setShortcut('Ctrl+D')
     action.triggered.connect(self.duplicate_line)
     self.add_action(action, sub_menu=None)
     self.action_duplicate_line = action
     # select all
     action = QtWidgets.QAction(_('Select all'), self)
     action.setShortcut(QtGui.QKeySequence.SelectAll)
     action.triggered.connect(self.selectAll)
     self.action_select_all = action
     self.add_action(self.action_select_all, sub_menu=None)
     self.add_separator(sub_menu=None)
     if create_standard_actions:
         # indent
         action = QtWidgets.QAction(_('Indent'), self)
         action.setShortcut('Tab')
         action.setIcon(icons.icon(
             'format-indent-more',
             ':/pyqode-icons/rc/format-indent-more.png', 'fa.indent'))
         action.triggered.connect(self.indent)
         self.add_action(action)
         self.action_indent = action
         # unindent
         action = QtWidgets.QAction(_('Un-indent'), self)
         action.setShortcut('Shift+Tab')
         action.setIcon(icons.icon(
             'format-indent-less',
             ':/pyqode-icons/rc/format-indent-less.png', 'fa.dedent'))
         action.triggered.connect(self.un_indent)
         self.add_action(action)
         self.action_un_indent = action
         self.add_separator()
     # goto
     action = QtWidgets.QAction(_('Go to line'), self)
     action.setShortcut('Ctrl+G')
     action.setIcon(icons.icon(
         'go-jump', ':/pyqode-icons/rc/goto-line.png', 'fa.share'))
     action.triggered.connect(self.goto_line)
     self.add_action(action)
     self.action_goto_line = action
Ejemplo n.º 23
0
    def init_actions(self):
        # New - submenu
        self.menu_new = self.addMenu("&New")
        self.menu_new.setIcon(
            icons.icon('document-new', None, 'fa.plus'))
        # https://github.com/pyQode/pyqode.core/pull/153
        new_user_actions = self.get_new_user_actions()
        if len(new_user_actions) > 0:
            self.menu_new.addSeparator()
            for user_new_action in new_user_actions:
                self.menu_new.addAction(user_new_action)
        # New file
        self.action_create_file = QtWidgets.QAction(_('&File'), self)
        self.action_create_file.triggered.connect(
            self._on_create_file_triggered)
        icon_provider = self.tree_view._icon_provider
        self.action_create_file.setIcon(icon_provider.icon(
            icon_provider.File))
        self.menu_new.addAction(self.action_create_file)
        # New directory
        self.action_create_directory = QtWidgets.QAction(
            _('&Directory'), self)
        self.action_create_directory.triggered.connect(
            self._on_create_directory_triggered)
        self.action_create_directory.setIcon(icon_provider.icon(
            icon_provider.Folder))
        self.menu_new.addAction(self.action_create_directory)
        self.addSeparator()

        # cut
        self.action_cut = QtWidgets.QAction(_('&Cut'), self)
        self.action_cut.setShortcut(QtGui.QKeySequence.Cut)
        self.action_cut.setIcon(icons.icon(
            'edit-cut', ':/pyqode-icons/rc/edit-cut.png', 'fa.cut'))
        self.addAction(self.action_cut)
        self.action_cut.triggered.connect(self._on_cut_triggered)
        # copy
        self.action_copy = QtWidgets.QAction(_('&Copy'), self)
        self.action_copy.setShortcut(QtGui.QKeySequence.Copy)
        self.action_copy.setIcon(icons.icon(
            'edit-copy', ':/pyqode-icons/rc/edit-copy.png', 'fa.copy'))
        self.addAction(self.action_copy)
        self.action_copy.triggered.connect(self._on_copy_triggered)
        # copy path
        self.action_copy_path = QtWidgets.QAction(_('&Copy path'), self)
        self.action_copy_path.setShortcut('Ctrl+Shift+C')
        self.addAction(self.action_copy_path)
        self.action_copy_path.triggered.connect(self._on_copy_path_triggered)
        # Paste
        self.action_paste = QtWidgets.QAction(_('&Paste'), self)
        self.action_paste.setShortcut(QtGui.QKeySequence.Paste)
        self.action_paste.setIcon(icons.icon(
            'edit-paste', ':/pyqode-icons/rc/edit-paste.png', 'fa.paste'))
        self.action_paste.triggered.connect(self._on_paste_triggered)
        self.addAction(self.action_paste)
        self.addSeparator()
        # Rename
        self.action_rename = QtWidgets.QAction(_('&Rename'), self)
        self.action_rename.setShortcut('F2')
        self.action_rename.triggered.connect(self._on_rename_triggered)
        self.action_rename.setIcon(QtGui.QIcon.fromTheme('edit-rename'))
        self.addAction(self.action_rename)
        # Delete
        self.action_delete = QtWidgets.QAction(_('&Delete'), self)
        self.action_delete.setShortcut(QtGui.QKeySequence.Delete)
        self.action_delete.setIcon(icons.icon(
            'edit-delete', ':/pyqode-icons/rc/edit-delete.png', 'fa.remove'))
        self.action_delete.triggered.connect(self._on_delete_triggered)
        self.addAction(self.action_delete)
        self.addSeparator()

        text = 'Show in %s' % self.get_file_explorer_name()
        action = self.action_show_in_explorer = self.addAction(text)
        action.setIcon(QtGui.QIcon.fromTheme('system-file-manager'))
        action.triggered.connect(self._on_show_in_explorer_triggered)
        self._action_show_in_explorer = action