Exemplo n.º 1
0
 def setup_common_actions(self):
     """Setup context menu common actions"""
     self.collapse_all_action = create_action(self,
                                              text=_('Collapse all'),
                                              icon=get_icon('collapse.png'),
                                              triggered=self.collapseAll)
     self.expand_all_action = create_action(self,
                                            text=_('Expand all'),
                                            icon=get_icon('expand.png'),
                                            triggered=self.expandAll)
     self.restore_action = create_action(
         self,
         text=_('Restore'),
         tip=_('Restore original tree layout'),
         icon=get_icon('restore.png'),
         triggered=self.restore)
     self.collapse_selection_action = create_action(
         self,
         text=_('Collapse selection'),
         icon=get_icon('collapse_selection.png'),
         triggered=self.collapse_selection)
     self.expand_selection_action = create_action(
         self,
         text=_('Expand selection'),
         icon=get_icon('expand_selection.png'),
         triggered=self.expand_selection)
     return [
         self.collapse_all_action, self.expand_all_action,
         self.restore_action, None, self.collapse_selection_action,
         self.expand_selection_action
     ]
Exemplo n.º 2
0
 def create_file_new_actions(self, fnames):
     """Return actions for submenu 'New...'"""
     if not fnames:
         return []
     new_file_act = create_action(
         self,
         _("File..."),
         icon='filenew.png',
         triggered=lambda: self.new_file(fnames[-1]))
     new_module_act = create_action(
         self,
         _("Module..."),
         icon='py.png',
         triggered=lambda: self.new_module(fnames[-1]))
     new_folder_act = create_action(
         self,
         _("Folder..."),
         icon='folder_new.png',
         triggered=lambda: self.new_folder(fnames[-1]))
     new_package_act = create_action(
         self,
         _("Package..."),
         icon=get_icon('package_collapsed.png'),
         triggered=lambda: self.new_package(fnames[-1]))
     return [
         new_file_act, new_folder_act, None, new_module_act, new_package_act
     ]
Exemplo n.º 3
0
 def setup_common_actions(self):
     """Setup context menu common actions"""
     self.collapse_all_action = create_action(self,
                                  text=_('Collapse all'),
                                  icon=get_icon('collapse.png'),
                                  triggered=self.collapseAll)
     self.expand_all_action = create_action(self,
                                  text=_('Expand all'),
                                  icon=get_icon('expand.png'),
                                  triggered=self.expandAll)
     self.restore_action = create_action(self,
                                  text=_('Restore'),
                                  tip=_('Restore original tree layout'),
                                  icon=get_icon('restore.png'),
                                  triggered=self.restore)
     self.collapse_selection_action = create_action(self,
                                  text=_('Collapse selection'),
                                  icon=get_icon('collapse_selection.png'),
                                  triggered=self.collapse_selection)
     self.expand_selection_action = create_action(self,
                                  text=_('Expand selection'),
                                  icon=get_icon('expand_selection.png'),
                                  triggered=self.expand_selection)
     return [self.collapse_all_action, self.expand_all_action,
             self.restore_action, None,
             self.collapse_selection_action, self.expand_selection_action]
Exemplo n.º 4
0
 def __init__(self, parent):
     QWebView.__init__(self, parent)
     self.zoom_factor = 1.
     self.zoom_out_action = create_action(self, _("Zoom out"),
                                          icon=get_icon('zoom_out.png'),
                                          triggered=self.zoom_out)
     self.zoom_in_action = create_action(self, _("Zoom in"),
                                         icon=get_icon('zoom_in.png'),
                                         triggered=self.zoom_in)
Exemplo n.º 5
0
 def __init__(self, parent):
     QWebView.__init__(self, parent)
     self.zoom_factor = 1.
     self.zoom_out_action = create_action(self,
                                          _("Zoom out"),
                                          icon=get_icon('zoom_out.png'),
                                          triggered=self.zoom_out)
     self.zoom_in_action = create_action(self,
                                         _("Zoom in"),
                                         icon=get_icon('zoom_in.png'),
                                         triggered=self.zoom_in)
Exemplo n.º 6
0
    def setup_common_actions(self):
        """Setup context menu common actions"""
        # Filters
        filters_action = create_action(
            self, _("Edit filename filters..."), None, get_icon("filter.png"), triggered=self.edit_filter
        )
        # Show all files
        all_action = create_action(self, _("Show all files"), toggled=self.toggle_all)
        all_action.setChecked(self.show_all)
        self.toggle_all(self.show_all)

        return [filters_action, all_action]
Exemplo n.º 7
0
 def get_plugin_actions(self):
     """Return a list of actions related to plugin"""
     history_action = create_action(self, _("History..."),
                                    None, 'history.png',
                                    _("Set history maximum entries"),
                                    triggered=self.change_history_depth)
     font_action = create_action(self, _("&Font..."), None,
                                 'font.png', _("Set shell font style"),
                                 triggered=self.change_font)
     self.wrap_action = create_action(self, _("Wrap lines"),
                                 toggled=self.toggle_wrap_mode)
     self.wrap_action.setChecked( self.get_option('wrap') )
     self.menu_actions = [history_action, font_action, self.wrap_action]
     return self.menu_actions
Exemplo n.º 8
0
    def create_file_manage_actions(self, fnames):
        """Return file management actions"""
        only_files = all([osp.isfile(_fn) for _fn in fnames])
        only_modules = all([
            osp.splitext(_fn)[1] in ('.py', '.pyw', '.ipy') for _fn in fnames
        ])
        only_valid = all(
            [osp.splitext(_fn)[1] in self.valid_types for _fn in fnames])
        run_action = create_action(self,
                                   _("Run"),
                                   icon="run_small.png",
                                   triggered=self.run)
        edit_action = create_action(self,
                                    _("Edit"),
                                    icon="edit.png",
                                    triggered=self.clicked)
        move_action = create_action(self,
                                    _("Move..."),
                                    icon="move.png",
                                    triggered=self.move)
        delete_action = create_action(self,
                                      _("Delete..."),
                                      icon="delete.png",
                                      triggered=self.delete)
        rename_action = create_action(self,
                                      _("Rename..."),
                                      icon="rename.png",
                                      triggered=self.rename)
        open_action = create_action(self, _("Open"), triggered=self.open)

        actions = []
        if only_modules:
            actions.append(run_action)
        if only_valid and only_files:
            actions.append(edit_action)
        else:
            actions.append(open_action)
        actions += [delete_action, rename_action]
        basedir = fixpath(osp.dirname(fnames[0]))
        if all([fixpath(osp.dirname(_fn)) == basedir for _fn in fnames]):
            actions.append(move_action)
        actions += [None]

        # VCS support is quite limited for now, so we are enabling the VCS
        # related actions only when a single file/folder is selected:
        dirname = fnames[0] if osp.isdir(fnames[0]) else osp.dirname(fnames[0])
        if len(fnames) == 1 and vcs.is_vcs_repository(dirname):
            vcs_ci = create_action(self,
                                   _("Commit"),
                                   icon="vcs_commit.png",
                                   triggered=lambda fnames=[dirname]: self.
                                   vcs_command(fnames, tool='commit'))
            vcs_log = create_action(self,
                                    _("Browse repository"),
                                    icon="vcs_browse.png",
                                    triggered=lambda fnames=[dirname]: self.
                                    vcs_command(fnames, tool='browse'))
            actions += [None, vcs_ci, vcs_log]

        return actions
Exemplo n.º 9
0
    def get_plugin_actions(self):
        """Return a list of actions related to plugin"""
        new_project_act = create_action(self, text=_('New project...'),
                                        icon=get_icon('project_expanded.png'),
                                        triggered=self.create_new_project)

        font_action = create_action(self, _("&Font..."),
                                    None, 'font.png', _("Set font style"),
                                    triggered=self.change_font)
        self.treewidget.common_actions += (None, font_action)
        
        self.main.file_menu_actions.insert(1, new_project_act)
        
        return []
Exemplo n.º 10
0
    def __init__(self,
                 parent=None,
                 show_fullpath=True,
                 fullpath_sorting=True,
                 show_all_files=True,
                 show_comments=True):
        QWidget.__init__(self, parent)

        self.treewidget = OutlineExplorerTreeWidget(
            self,
            show_fullpath=show_fullpath,
            fullpath_sorting=fullpath_sorting,
            show_all_files=show_all_files,
            show_comments=show_comments)

        self.visibility_action = create_action(self,
                                               _("Show/hide outline explorer"),
                                               icon='outline_explorer_vis.png',
                                               toggled=self.toggle_visibility)
        self.visibility_action.setChecked(True)

        btn_layout = QHBoxLayout()
        btn_layout.setAlignment(Qt.AlignRight)
        for btn in self.setup_buttons():
            btn_layout.addWidget(btn)

        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.treewidget)
        layout.addLayout(btn_layout)
        self.setLayout(layout)
Exemplo n.º 11
0
 def update_browse_tabs_menu(self):
     """Update browse tabs menu"""
     self.browse_tabs_menu.clear()
     names = []
     dirnames = []
     for index in range(self.count()):
         if self.menu_use_tooltips:
             text = unicode(self.tabToolTip(index))
         else:
             text = unicode(self.tabText(index))
         names.append(text)
         if osp.isfile(text):
             # Testing if tab names are filenames
             dirnames.append(osp.dirname(text))
     offset = None
     
     # If tab names are all filenames, removing common path:
     if len(names) == len(dirnames):
         common = get_common_path(dirnames)
         if common is None:
             offset = None
         else:
             offset = len(common)+1
             if offset <= 3:
                 # Common path is not a path but a drive letter...
                 offset = None
             
     for index, text in enumerate(names):
         tab_action = create_action(self, text[offset:],
                                    icon=self.tabIcon(index),
                                    toggled=lambda state, index=index:
                                            self.setCurrentIndex(index),
                                    tip=self.tabToolTip(index))
         tab_action.setChecked(index == self.currentIndex())
         self.browse_tabs_menu.addAction(tab_action)
Exemplo n.º 12
0
 def setup_context_menu(self):
     """Reimplement PythonShellWidget method"""
     PythonShellWidget.setup_context_menu(self)
     self.help_action = create_action(self, _("Help..."),
                        icon=get_std_icon('DialogHelpButton'),
                        triggered=self.help)
     self.menu.addAction(self.help_action)
Exemplo n.º 13
0
 def get_actions_from_items(self, items):
     """Reimplemented OneColumnTree method"""
     fromcursor_act = create_action(self, text=_('Go to cursor position'),
                     icon=get_icon('fromcursor.png'),
                     triggered=self.go_to_cursor_position)
     fullpath_act = create_action(self, text=_( 'Show absolute path'),
                     toggled=self.toggle_fullpath_mode)
     fullpath_act.setChecked(self.show_fullpath)
     allfiles_act = create_action(self, text=_( 'Show all files'),
                     toggled=self.toggle_show_all_files)
     allfiles_act.setChecked(self.show_all_files)
     comment_act = create_action(self, text=_('Show special comments'),
                     toggled=self.toggle_show_comments)
     comment_act.setChecked(self.show_comments)
     actions = [fullpath_act, allfiles_act, comment_act, fromcursor_act]
     return actions
Exemplo n.º 14
0
    def __init__(self, parent=None, show_fullpath=True, fullpath_sorting=True,
                 show_all_files=True, show_comments=True):
        QWidget.__init__(self, parent)

        self.treewidget = OutlineExplorerTreeWidget(self,
                                            show_fullpath=show_fullpath,
                                            fullpath_sorting=fullpath_sorting,
                                            show_all_files=show_all_files,
                                            show_comments=show_comments)

        self.visibility_action = create_action(self,
                                           _("Show/hide outline explorer"),
                                           icon='outline_explorer_vis.png',
                                           toggled=self.toggle_visibility)
        self.visibility_action.setChecked(True)
        
        btn_layout = QHBoxLayout()
        btn_layout.setAlignment(Qt.AlignRight)
        for btn in self.setup_buttons():
            btn_layout.addWidget(btn)

        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.treewidget)
        layout.addLayout(btn_layout)
        self.setLayout(layout)
Exemplo n.º 15
0
    def setup_common_actions(self):
        """Setup context menu common actions"""
        # Filters
        filters_action = create_action(self,
                                       _("Edit filename filters..."),
                                       None,
                                       get_icon('filter.png'),
                                       triggered=self.edit_filter)
        # Show all files
        all_action = create_action(self,
                                   _("Show all files"),
                                   toggled=self.toggle_all)
        all_action.setChecked(self.show_all)
        self.toggle_all(self.show_all)

        return [filters_action, all_action]
Exemplo n.º 16
0
 def create_folder_manage_actions(self, fnames):
     """Return folder management actions"""
     actions = []
     if os.name == "nt":
         _title = _("Open command prompt here")
     else:
         _title = _("Open terminal here")
     action = create_action(
         self, _title, icon="cmdprompt.png", triggered=lambda fnames=fnames: self.open_terminal(fnames)
     )
     actions.append(action)
     _title = _("Open Python interpreter here")
     action = create_action(
         self, _title, icon="python.png", triggered=lambda fnames=fnames: self.open_interpreter(fnames)
     )
     actions.append(action)
     return actions
Exemplo n.º 17
0
 def get_plugin_actions(self):
     """Return a list of actions related to plugin"""
     # Font
     font_action = create_action(self, _("&Font..."), None, 'font.png',
                                 _("Set font style"),
                                 triggered=self.change_font)
     self.treewidget.common_actions.append(font_action)
     return []
Exemplo n.º 18
0
 def get_options_menu(self):
     self.show_time_action = create_action(self, _("Show elapsed time"),
                                       toggled=self.set_elapsed_time_visible)
     self.show_time_action.setChecked(self.show_elapsed_time)
     actions = [self.show_time_action]
     if self.menu_actions is not None:
         actions += [None]+self.menu_actions
     return actions
Exemplo n.º 19
0
 def setup_context_menu(self):
     """Reimplement PythonShellWidget method"""
     PythonShellWidget.setup_context_menu(self)
     self.help_action = create_action(self,
                                      _("Help..."),
                                      icon=get_std_icon('DialogHelpButton'),
                                      triggered=self.help)
     self.menu.addAction(self.help_action)
Exemplo n.º 20
0
    def __init__(self, parent):
        QTableView.__init__(self, parent)
        self._model = None

        # Setting up actions
        self.date_dayfirst_action = create_action(self, "dayfirst",
            triggered=ft_partial(self.parse_to_type, atype="date", dayfirst=True))
        self.date_monthfirst_action = create_action(self,"monthfirst",
            triggered=ft_partial(self.parse_to_type, atype="date", dayfirst=False))
        self.perc_action = create_action(self, "perc",
            triggered=ft_partial(self.parse_to_type, atype="perc"))
        self.acc_action = create_action(self, "account",
            triggered=ft_partial(self.parse_to_type, atype="account"))
        self.str_action = create_action(self, "unicode",
            triggered=ft_partial(self.parse_to_type, atype="unicode"))
        self.int_action = create_action(self, "int",
            triggered=ft_partial(self.parse_to_type, atype="int"))
        self.float_action = create_action(self,"float",
            triggered=ft_partial(self.parse_to_type, atype="float"))
        
        # Setting up menus
        self.date_menu = QMenu()
        self.date_menu.setTitle("Date")
        add_actions( self.date_menu, (self.date_dayfirst_action,
                                      self.date_monthfirst_action))
        self.parse_menu = QMenu(self)
        self.parse_menu.addMenu(self.date_menu)
        add_actions( self.parse_menu, (self.perc_action, self.acc_action))
        self.parse_menu.setTitle("String to")
        self.opt_menu = QMenu(self)
        self.opt_menu.addMenu(self.parse_menu)
        add_actions( self.opt_menu, (self.str_action, self.int_action,
                                     self.float_action))
Exemplo n.º 21
0
    def get_plugin_actions(self):
        """Return a list of actions related to plugin"""
        new_project_act = create_action(self,
                                        text=_('New project...'),
                                        icon=get_icon('project_expanded.png'),
                                        triggered=self.create_new_project)

        font_action = create_action(self,
                                    _("&Font..."),
                                    None,
                                    'font.png',
                                    _("Set font style"),
                                    triggered=self.change_font)
        self.treewidget.common_actions += (None, font_action)

        self.main.file_menu_actions.insert(1, new_project_act)

        return []
Exemplo n.º 22
0
 def setup_menu(self):
     """Setup context menu"""
     self.copy_action = create_action(self, _( "Copy"),
                                      shortcut=keybinding("Copy"),
                                      icon=get_icon('editcopy.png'),
                                      triggered=self.copy,
                                      context=Qt.WidgetShortcut)
     menu = QMenu(self)
     add_actions(menu, [self.copy_action, ])
     return menu
Exemplo n.º 23
0
 def get_options_menu(self):
     self.show_time_action = create_action(
         self,
         _("Show elapsed time"),
         toggled=self.set_elapsed_time_visible)
     self.show_time_action.setChecked(self.show_elapsed_time)
     actions = [self.show_time_action]
     if self.menu_actions is not None:
         actions += [None] + self.menu_actions
     return actions
Exemplo n.º 24
0
 def get_actions_from_items(self, items):
     """Reimplemented OneColumnTree method"""
     fromcursor_act = create_action(self,
                                    text=_('Go to cursor position'),
                                    icon=get_icon('fromcursor.png'),
                                    triggered=self.go_to_cursor_position)
     fullpath_act = create_action(self,
                                  text=_('Show absolute path'),
                                  toggled=self.toggle_fullpath_mode)
     fullpath_act.setChecked(self.show_fullpath)
     allfiles_act = create_action(self,
                                  text=_('Show all files'),
                                  toggled=self.toggle_show_all_files)
     allfiles_act.setChecked(self.show_all_files)
     comment_act = create_action(self,
                                 text=_('Show special comments'),
                                 toggled=self.toggle_show_comments)
     comment_act.setChecked(self.show_comments)
     actions = [fullpath_act, allfiles_act, comment_act, fromcursor_act]
     return actions
Exemplo n.º 25
0
 def create_file_new_actions(self, fnames):
     """Return actions for submenu 'New...'"""
     if not fnames:
         return []
     new_file_act = create_action(
         self, _("File..."), icon="filenew.png", triggered=lambda: self.new_file(fnames[-1])
     )
     new_module_act = create_action(
         self, _("Module..."), icon="py.png", triggered=lambda: self.new_module(fnames[-1])
     )
     new_folder_act = create_action(
         self, _("Folder..."), icon="folder_new.png", triggered=lambda: self.new_folder(fnames[-1])
     )
     new_package_act = create_action(
         self,
         _("Package..."),
         icon=get_icon("package_collapsed.png"),
         triggered=lambda: self.new_package(fnames[-1]),
     )
     return [new_file_act, new_folder_act, None, new_module_act, new_package_act]
Exemplo n.º 26
0
 def get_plugin_actions(self):
     """Return a list of actions related to plugin"""
     # Font
     font_action = create_action(self,
                                 _("&Font..."),
                                 None,
                                 'font.png',
                                 _("Set font style"),
                                 triggered=self.change_font)
     self.treewidget.common_actions.append(font_action)
     return []
Exemplo n.º 27
0
 def setup_context_menu(self):
     """Reimplements ShellBaseWidget method"""
     ShellBaseWidget.setup_context_menu(self)
     self.copy_without_prompts_action = create_action(self,
                                  _("Copy without prompts"),
                                  icon=get_icon('copywop.png'),
                                  triggered=self.copy_without_prompts)
     clear_line_action = create_action(self, _("Clear line"),
                                  QKeySequence("Shift+Escape"),
                                  icon=get_icon('eraser.png'),
                                  tip=_("Clear line"),
                                  triggered=self.clear_line)
     clear_action = create_action(self, _("Clear shell"),
                                  QKeySequence("Ctrl+L"),
                                  icon=get_icon('clear.png'),
                                  tip=_("Clear shell contents "
                                        "('cls' command)"),
                                  triggered=self.clear_terminal)
     add_actions(self.menu, (self.copy_without_prompts_action,
                 clear_line_action, clear_action))
Exemplo n.º 28
0
 def create_folder_manage_actions(self, fnames):
     """Return folder management actions"""
     actions = []
     if os.name == 'nt':
         _title = _("Open command prompt here")
     else:
         _title = _("Open terminal here")
     action = create_action(
         self,
         _title,
         icon="cmdprompt.png",
         triggered=lambda fnames=fnames: self.open_terminal(fnames))
     actions.append(action)
     _title = _("Open Python interpreter here")
     action = create_action(
         self,
         _title,
         icon="python.png",
         triggered=lambda fnames=fnames: self.open_interpreter(fnames))
     actions.append(action)
     return actions
Exemplo n.º 29
0
 def get_options_menu(self):
     ExternalShellBase.get_options_menu(self)
     self.interact_action = create_action(self, _("Interact"))
     self.interact_action.setCheckable(True)
     self.debug_action = create_action(self, _("Debug"))
     self.debug_action.setCheckable(True)
     self.args_action = create_action(self,
                                      _("Arguments..."),
                                      triggered=self.get_arguments)
     run_settings_menu = QMenu(_("Run settings"), self)
     add_actions(
         run_settings_menu,
         (self.interact_action, self.debug_action, self.args_action))
     self.cwd_button = create_action(
         self,
         _("Working directory"),
         icon=get_std_icon('DirOpenIcon'),
         tip=_("Set current working directory"),
         triggered=self.set_current_working_directory)
     self.env_button = create_action(self,
                                     _("Environment variables"),
                                     icon=get_icon('environ.png'),
                                     triggered=self.show_env)
     self.syspath_button = create_action(self,
                                         _("Show sys.path contents"),
                                         icon=get_icon('syspath.png'),
                                         triggered=self.show_syspath)
     actions = [
         run_settings_menu, self.show_time_action, None, self.cwd_button,
         self.env_button, self.syspath_button
     ]
     if self.menu_actions is not None:
         actions += [None] + self.menu_actions
     return actions
Exemplo n.º 30
0
 def get_options_menu(self):
     ExternalShellBase.get_options_menu(self)
     self.interact_action = create_action(self, _("Interact"))
     self.interact_action.setCheckable(True)
     self.debug_action = create_action(self, _("Debug"))
     self.debug_action.setCheckable(True)
     self.args_action = create_action(self, _("Arguments..."),
                                      triggered=self.get_arguments)
     run_settings_menu = QMenu(_("Run settings"), self)
     add_actions(run_settings_menu,
                 (self.interact_action, self.debug_action, self.args_action))
     self.cwd_button = create_action(self, _("Working directory"),
                             icon=get_std_icon('DirOpenIcon'),
                             tip=_("Set current working directory"),
                             triggered=self.set_current_working_directory)
     self.env_button = create_action(self, _("Environment variables"),
                                     icon=get_icon('environ.png'),
                                     triggered=self.show_env)
     self.syspath_button = create_action(self,
                                         _("Show sys.path contents"),
                                         icon=get_icon('syspath.png'),
                                         triggered=self.show_syspath)
     actions = [run_settings_menu, self.show_time_action, None,
                self.cwd_button, self.env_button, self.syspath_button]
     if self.menu_actions is not None:
         actions += [None]+self.menu_actions
     return actions
Exemplo n.º 31
0
    def __init__(
        self,
        parent=None,
        name_filters=["*.py", "*.pyw"],
        valid_types=(".py", ".pyw"),
        show_all=False,
        show_cd_only=None,
        show_toolbar=True,
        show_icontext=True,
    ):
        QWidget.__init__(self, parent)

        self.treewidget = ExplorerTreeWidget(self, show_cd_only=show_cd_only)
        self.treewidget.setup(name_filters=name_filters, valid_types=valid_types, show_all=show_all)
        self.treewidget.chdir(os.getcwdu())

        toolbar_action = create_action(self, _("Show toolbar"), toggled=self.toggle_toolbar)
        icontext_action = create_action(self, _("Show icons and text"), toggled=self.toggle_icontext)
        self.treewidget.common_actions += [None, toolbar_action, icontext_action]

        # Setup toolbar
        self.toolbar = QToolBar(self)
        self.toolbar.setIconSize(QSize(16, 16))

        self.previous_action = create_action(
            self, text=_("Previous"), icon=get_icon("previous.png"), triggered=self.treewidget.go_to_previous_directory
        )
        self.toolbar.addAction(self.previous_action)
        self.previous_action.setEnabled(False)
        self.connect(self.treewidget, SIGNAL("set_previous_enabled(bool)"), self.previous_action.setEnabled)

        self.next_action = create_action(
            self, text=_("Next"), icon=get_icon("next.png"), triggered=self.treewidget.go_to_next_directory
        )
        self.toolbar.addAction(self.next_action)
        self.next_action.setEnabled(False)
        self.connect(self.treewidget, SIGNAL("set_next_enabled(bool)"), self.next_action.setEnabled)

        parent_action = create_action(
            self, text=_("Parent"), icon=get_icon("up.png"), triggered=self.treewidget.go_to_parent_directory
        )
        self.toolbar.addAction(parent_action)

        options_action = create_action(self, text="", tip=_("Options"), icon=get_icon("tooloptions.png"))
        self.toolbar.addAction(options_action)
        widget = self.toolbar.widgetForAction(options_action)
        widget.setPopupMode(QToolButton.InstantPopup)
        menu = QMenu(self)
        add_actions(menu, self.treewidget.common_actions)
        options_action.setMenu(menu)

        toolbar_action.setChecked(show_toolbar)
        self.toggle_toolbar(show_toolbar)
        icontext_action.setChecked(show_icontext)
        self.toggle_icontext(show_icontext)

        vlayout = QVBoxLayout()
        vlayout.addWidget(self.toolbar)
        vlayout.addWidget(self.treewidget)
        self.setLayout(vlayout)
Exemplo n.º 32
0
 def setup_context_menu(self):
     """Setup shell context menu"""
     self.menu = QMenu(self)
     self.cut_action = create_action(self, _("Cut"),
                                     shortcut=keybinding('Cut'),
                                     icon=get_icon('editcut.png'),
                                     triggered=self.cut)
     self.copy_action = create_action(self, _("Copy"),
                                      shortcut=keybinding('Copy'),
                                      icon=get_icon('editcopy.png'),
                                      triggered=self.copy)
     paste_action = create_action(self, _("Paste"),
                                  shortcut=keybinding('Paste'),
                                  icon=get_icon('editpaste.png'),
                                  triggered=self.paste)
     save_action = create_action(self, _("Save history log..."),
                                 icon=get_icon('filesave.png'),
                                 tip=_("Save current history log (i.e. all "
                                       "inputs and outputs) in a text file"),
                                 triggered=self.save_historylog)
     self.delete_action = create_action(self, _("Delete"),
                                 shortcut=keybinding('Delete'),
                                 icon=get_icon('editdelete.png'),
                                 triggered=self.delete)
     selectall_action = create_action(self, _("Select All"),
                                 shortcut=keybinding('SelectAll'),
                                 icon=get_icon('selectall.png'),
                                 triggered=self.selectAll)
     add_actions(self.menu, (self.cut_action, self.copy_action,
                             paste_action, self.delete_action, None,
                             selectall_action, None, save_action) )
Exemplo n.º 33
0
    def __init__(self, parent):
        QTableView.__init__(self, parent)
        self._model = None

        # Setting up actions
        self.date_dayfirst_action = create_action(self,
                                                  "dayfirst",
                                                  triggered=ft_partial(
                                                      self.parse_to_type,
                                                      atype="date",
                                                      dayfirst=True))
        self.date_monthfirst_action = create_action(self,
                                                    "monthfirst",
                                                    triggered=ft_partial(
                                                        self.parse_to_type,
                                                        atype="date",
                                                        dayfirst=False))
        self.perc_action = create_action(self,
                                         "perc",
                                         triggered=ft_partial(
                                             self.parse_to_type, atype="perc"))
        self.acc_action = create_action(self,
                                        "account",
                                        triggered=ft_partial(
                                            self.parse_to_type,
                                            atype="account"))
        self.str_action = create_action(self,
                                        "unicode",
                                        triggered=ft_partial(
                                            self.parse_to_type,
                                            atype="unicode"))
        self.int_action = create_action(self,
                                        "int",
                                        triggered=ft_partial(
                                            self.parse_to_type, atype="int"))
        self.float_action = create_action(self,
                                          "float",
                                          triggered=ft_partial(
                                              self.parse_to_type,
                                              atype="float"))

        # Setting up menus
        self.date_menu = QMenu()
        self.date_menu.setTitle("Date")
        add_actions(self.date_menu,
                    (self.date_dayfirst_action, self.date_monthfirst_action))
        self.parse_menu = QMenu(self)
        self.parse_menu.addMenu(self.date_menu)
        add_actions(self.parse_menu, (self.perc_action, self.acc_action))
        self.parse_menu.setTitle("String to")
        self.opt_menu = QMenu(self)
        self.opt_menu.addMenu(self.parse_menu)
        add_actions(self.opt_menu,
                    (self.str_action, self.int_action, self.float_action))
Exemplo n.º 34
0
 def setup_menu(self):
     """Setup context menu"""
     self.copy_action = create_action(
         self,
         _("Copy"),
         shortcut=keybinding("Copy"),
         icon=get_icon("editcopy.png"),
         triggered=self.copy,
         context=Qt.WidgetShortcut,
     )
     menu = QMenu(self)
     add_actions(menu, [self.copy_action])
     return menu
Exemplo n.º 35
0
 def setup_context_menu(self):
     """Reimplements ShellBaseWidget method"""
     ShellBaseWidget.setup_context_menu(self)
     self.copy_without_prompts_action = create_action(
         self,
         _("Copy without prompts"),
         icon=get_icon('copywop.png'),
         triggered=self.copy_without_prompts)
     clear_line_action = create_action(self,
                                       _("Clear line"),
                                       QKeySequence("Shift+Escape"),
                                       icon=get_icon('eraser.png'),
                                       tip=_("Clear line"),
                                       triggered=self.clear_line)
     clear_action = create_action(self,
                                  _("Clear shell"),
                                  QKeySequence("Ctrl+L"),
                                  icon=get_icon('clear.png'),
                                  tip=_("Clear shell contents "
                                        "('cls' command)"),
                                  triggered=self.clear_terminal)
     add_actions(self.menu, (self.copy_without_prompts_action,
                             clear_line_action, clear_action))
Exemplo n.º 36
0
 def setup_common_actions(self):
     """Setup context menu common actions"""
     actions = super(ExplorerTreeWidget, self).setup_common_actions()
     if self.show_cd_only is None:
         # Enabling the 'show current directory only' option but do not
         # allow the user to disable it
         self.show_cd_only = True
     else:
         # Show current directory only
         cd_only_action = create_action(self, _("Show current directory only"), toggled=self.toggle_show_cd_only)
         cd_only_action.setChecked(self.show_cd_only)
         self.toggle_show_cd_only(self.show_cd_only)
         actions.append(cd_only_action)
     return actions
Exemplo n.º 37
0
 def setup_common_actions(self):
     """Setup context menu common actions"""
     actions = super(ExplorerTreeWidget, self).setup_common_actions()
     if self.show_cd_only is None:
         # Enabling the 'show current directory only' option but do not
         # allow the user to disable it
         self.show_cd_only = True
     else:
         # Show current directory only
         cd_only_action = create_action(self,
                                        _("Show current directory only"),
                                        toggled=self.toggle_show_cd_only)
         cd_only_action.setChecked(self.show_cd_only)
         self.toggle_show_cd_only(self.show_cd_only)
         actions.append(cd_only_action)
     return actions
Exemplo n.º 38
0
    def create_file_manage_actions(self, fnames):
        """Return file management actions"""
        only_files = all([osp.isfile(_fn) for _fn in fnames])
        only_modules = all([osp.splitext(_fn)[1] in (".py", ".pyw", ".ipy") for _fn in fnames])
        only_valid = all([osp.splitext(_fn)[1] in self.valid_types for _fn in fnames])
        run_action = create_action(self, _("Run"), icon="run_small.png", triggered=self.run)
        edit_action = create_action(self, _("Edit"), icon="edit.png", triggered=self.clicked)
        move_action = create_action(self, _("Move..."), icon="move.png", triggered=self.move)
        delete_action = create_action(self, _("Delete..."), icon="delete.png", triggered=self.delete)
        rename_action = create_action(self, _("Rename..."), icon="rename.png", triggered=self.rename)
        open_action = create_action(self, _("Open"), triggered=self.open)

        actions = []
        if only_modules:
            actions.append(run_action)
        if only_valid and only_files:
            actions.append(edit_action)
        else:
            actions.append(open_action)
        actions += [delete_action, rename_action]
        basedir = fixpath(osp.dirname(fnames[0]))
        if all([fixpath(osp.dirname(_fn)) == basedir for _fn in fnames]):
            actions.append(move_action)
        actions += [None]

        # VCS support is quite limited for now, so we are enabling the VCS
        # related actions only when a single file/folder is selected:
        dirname = fnames[0] if osp.isdir(fnames[0]) else osp.dirname(fnames[0])
        if len(fnames) == 1 and vcs.is_vcs_repository(dirname):
            vcs_ci = create_action(
                self,
                _("Commit"),
                icon="vcs_commit.png",
                triggered=lambda fnames=[dirname]: self.vcs_command(fnames, tool="commit"),
            )
            vcs_log = create_action(
                self,
                _("Browse repository"),
                icon="vcs_browse.png",
                triggered=lambda fnames=[dirname]: self.vcs_command(fnames, tool="browse"),
            )
            actions += [None, vcs_ci, vcs_log]

        return actions
Exemplo n.º 39
0
 def register_plugin(self):
     """Register plugin in Spyder's main window"""
     self.get_pythonpath_callback = self.main.get_spyder_pythonpath
     self.main.add_dockwidget(self)
     self.connect(self, SIGNAL("edit_goto(QString,int,QString)"),
                  self.main.editor.load)
     self.connect(self, SIGNAL('redirect_stdio(bool)'),
                  self.main.redirect_internalshell_stdio)
     self.connect(self.main.workingdirectory,
                  SIGNAL("refresh_findinfiles()"), self.refreshdir)
     
     findinfiles_action = create_action(self, _("&Find in files"),
                                "Ctrl+Shift+F", 'findf.png',
                                triggered=self.findinfiles_callback,
                                tip=_("Search text in multiple files"))        
     
     self.main.search_menu_actions += [None, findinfiles_action]
     self.main.search_toolbar_actions += [None, findinfiles_action]
Exemplo n.º 40
0
    def register_plugin(self):
        """Register plugin in Spyder's main window"""
        self.get_pythonpath_callback = self.main.get_spyder_pythonpath
        self.main.add_dockwidget(self)
        self.connect(self, SIGNAL("edit_goto(QString,int,QString)"),
                     self.main.editor.load)
        self.connect(self, SIGNAL('redirect_stdio(bool)'),
                     self.main.redirect_internalshell_stdio)
        self.connect(self.main.workingdirectory,
                     SIGNAL("refresh_findinfiles()"), self.refreshdir)

        findinfiles_action = create_action(
            self,
            _("&Find in files"),
            "Ctrl+Shift+F",
            'findf.png',
            triggered=self.findinfiles_callback,
            tip=_("Search text in multiple files"))

        self.main.search_menu_actions += [None, findinfiles_action]
        self.main.search_toolbar_actions += [None, findinfiles_action]
Exemplo n.º 41
0
 def setup_context_menu(self):
     """Setup shell context menu"""
     self.menu = QMenu(self)
     self.cut_action = create_action(self,
                                     _("Cut"),
                                     shortcut=keybinding('Cut'),
                                     icon=get_icon('editcut.png'),
                                     triggered=self.cut)
     self.copy_action = create_action(self,
                                      _("Copy"),
                                      shortcut=keybinding('Copy'),
                                      icon=get_icon('editcopy.png'),
                                      triggered=self.copy)
     paste_action = create_action(self,
                                  _("Paste"),
                                  shortcut=keybinding('Paste'),
                                  icon=get_icon('editpaste.png'),
                                  triggered=self.paste)
     save_action = create_action(self,
                                 _("Save history log..."),
                                 icon=get_icon('filesave.png'),
                                 tip=_(
                                     "Save current history log (i.e. all "
                                     "inputs and outputs) in a text file"),
                                 triggered=self.save_historylog)
     self.delete_action = create_action(self,
                                        _("Delete"),
                                        shortcut=keybinding('Delete'),
                                        icon=get_icon('editdelete.png'),
                                        triggered=self.delete)
     selectall_action = create_action(self,
                                      _("Select All"),
                                      shortcut=keybinding('SelectAll'),
                                      icon=get_icon('selectall.png'),
                                      triggered=self.selectAll)
     add_actions(
         self.menu,
         (self.cut_action, self.copy_action, paste_action,
          self.delete_action, None, selectall_action, None, save_action))
Exemplo n.º 42
0
    def setup_toolbar(self, exclude_private, exclude_uppercase,
                      exclude_capitalized, exclude_unsupported, autorefresh):
        """Setup toolbar"""
        self.setup_in_progress = True

        toolbar = []

        refresh_button = create_toolbutton(self,
                                           text=_("Refresh"),
                                           icon=get_icon('reload.png'),
                                           triggered=self.refresh_table)
        self.auto_refresh_button = create_toolbutton(
            self,
            text=_("Refresh periodically"),
            icon=get_icon('auto_reload.png'),
            toggled=self.toggle_auto_refresh)
        self.auto_refresh_button.setChecked(autorefresh)
        load_button = create_toolbutton(self,
                                        text=_("Import data"),
                                        icon=get_icon('fileimport.png'),
                                        triggered=self.import_data)
        self.save_button = create_toolbutton(
            self,
            text=_("Save data"),
            icon=get_icon('filesave.png'),
            triggered=lambda: self.save_data(self.filename))
        self.save_button.setEnabled(False)
        save_as_button = create_toolbutton(self,
                                           text=_("Save data as..."),
                                           icon=get_icon('filesaveas.png'),
                                           triggered=self.save_data)
        toolbar += [
            refresh_button, self.auto_refresh_button, load_button,
            self.save_button, save_as_button
        ]

        self.exclude_private_action = create_action(
            self,
            _("Exclude private references"),
            tip=_("Exclude references which name starts"
                  " with an underscore"),
            toggled=lambda state: self.sig_option_changed.emit(
                'exclude_private', state))
        self.exclude_private_action.setChecked(exclude_private)

        self.exclude_uppercase_action = create_action(
            self,
            _("Exclude all-uppercase references"),
            tip=_("Exclude references which name is uppercase"),
            toggled=lambda state: self.sig_option_changed.emit(
                'exclude_uppercase', state))
        self.exclude_uppercase_action.setChecked(exclude_uppercase)

        self.exclude_capitalized_action = create_action(
            self,
            _("Exclude capitalized references"),
            tip=_("Exclude references which name starts with an "
                  "uppercase character"),
            toggled=lambda state: self.sig_option_changed.emit(
                'exclude_capitalized', state))
        self.exclude_capitalized_action.setChecked(exclude_capitalized)

        self.exclude_unsupported_action = create_action(
            self,
            _("Exclude unsupported data types"),
            tip=_("Exclude references to unsupported data types"
                  " (i.e. which won't be handled/saved correctly)"),
            toggled=lambda state: self.sig_option_changed.emit(
                'exclude_unsupported', state))
        self.exclude_unsupported_action.setChecked(exclude_unsupported)

        options_button = create_toolbutton(self,
                                           text=_("Options"),
                                           icon=get_icon('tooloptions.png'))
        toolbar.append(options_button)
        options_button.setPopupMode(QToolButton.InstantPopup)
        menu = QMenu(self)
        editor = self.editor
        actions = [
            self.exclude_private_action, self.exclude_uppercase_action,
            self.exclude_capitalized_action, self.exclude_unsupported_action,
            None, editor.truncate_action, editor.inplace_action,
            editor.collvalue_action
        ]
        if is_module_installed('numpy'):
            actions.append(editor.minmax_action)
        if not self.is_internal_shell:
            actions.append(editor.remote_editing_action)
        add_actions(menu, actions)
        options_button.setMenu(menu)

        self.setup_in_progress = False

        return toolbar
Exemplo n.º 43
0
    def get_plugin_actions(self):
        """Return a list of actions related to plugin"""
        quit_action = create_action(self, _("&Quit"), icon="exit.png", tip=_("Quit"), triggered=self.quit)
        self.register_shortcut(quit_action, "_", "Quit", "Ctrl+Q")
        run_action = create_action(
            self, _("&Run..."), None, "run_small.png", _("Run a Python script"), triggered=self.run_script
        )
        environ_action = create_action(
            self,
            _("Environment variables..."),
            icon="environ.png",
            tip=_("Show and edit environment variables" " (for current session)"),
            triggered=self.show_env,
        )
        syspath_action = create_action(
            self,
            _("Show sys.path contents..."),
            icon="syspath.png",
            tip=_("Show (read-only) sys.path"),
            triggered=self.show_syspath,
        )
        buffer_action = create_action(
            self, _("Buffer..."), None, tip=_("Set maximum line count"), triggered=self.change_max_line_count
        )
        font_action = create_action(
            self, _("&Font..."), None, "font.png", _("Set shell font style"), triggered=self.change_font
        )
        exteditor_action = create_action(
            self,
            _("External editor path..."),
            None,
            None,
            _("Set external editor executable path"),
            triggered=self.change_exteditor,
        )
        wrap_action = create_action(self, _("Wrap lines"), toggled=self.toggle_wrap_mode)
        wrap_action.setChecked(self.get_option("wrap"))
        calltips_action = create_action(self, _("Balloon tips"), toggled=self.toggle_calltips)
        calltips_action.setChecked(self.get_option("calltips"))
        codecompletion_action = create_action(self, _("Automatic code completion"), toggled=self.toggle_codecompletion)
        codecompletion_action.setChecked(self.get_option("codecompletion/auto"))
        codecompenter_action = create_action(
            self, _("Enter key selects completion"), toggled=self.toggle_codecompletion_enter
        )
        codecompenter_action.setChecked(self.get_option("codecompletion/enter_key"))

        option_menu = QMenu(_("Internal console settings"), self)
        option_menu.setIcon(get_icon("tooloptions.png"))
        add_actions(
            option_menu,
            (
                buffer_action,
                font_action,
                wrap_action,
                calltips_action,
                codecompletion_action,
                codecompenter_action,
                exteditor_action,
            ),
        )

        plugin_actions = [None, run_action, environ_action, syspath_action, option_menu, None, quit_action]

        # Add actions to context menu
        add_actions(self.shell.menu, plugin_actions)

        return plugin_actions
Exemplo n.º 44
0
    def __init__(self, parent):
        SMPluginWidget.__init__(self, parent)
        
        self.internal_shell = None

        # Initialize plugin
        self.initialize_plugin()

        self.no_doc_string = _("No documentation available")
        
        self._last_console_cb = None
        self._last_editor_cb = None

        self.set_default_color_scheme()

        self.plain_text = PlainText(self)
        self.rich_text = RichText(self)
        
        color_scheme = get_color_scheme(self.get_option('color_scheme_name'))
        self.set_plain_text_font(self.get_plugin_font(), color_scheme)
        self.plain_text.editor.toggle_wrap_mode(self.get_option('wrap'))
        
        # Add entries to read-only editor context-menu
        font_action = create_action(self, _("&Font..."), None,
                                    'font.png', _("Set font style"),
                                    triggered=self.change_font)
        self.wrap_action = create_action(self, _("Wrap lines"),
                                         toggled=self.toggle_wrap_mode)
        self.wrap_action.setChecked(self.get_option('wrap'))
        self.plain_text.editor.readonly_menu.addSeparator()
        add_actions(self.plain_text.editor.readonly_menu,
                    (font_action, self.wrap_action))

        self.set_rich_text_font(self.get_plugin_font('rich_text'))
        
        self.shell = None
        
        self.external_console = None
        
        # locked = disable link with Console
        self.locked = False
        self._last_texts = [None, None]
        self._last_rope_data = None
        
        # Object name
        layout_edit = QHBoxLayout()
        layout_edit.setContentsMargins(0, 0, 0, 0)
        txt = _("Source")
        if sys.platform == 'darwin':
            source_label = QLabel("  " + txt)
        else:
            source_label = QLabel(txt)
        layout_edit.addWidget(source_label)
        self.source_combo = QComboBox(self)
        self.source_combo.addItems([_("Console"), _("Editor")])
        self.connect(self.source_combo, SIGNAL('currentIndexChanged(int)'),
                     self.source_changed)
        if not programs.is_module_installed('rope'):
            self.source_combo.hide()
            source_label.hide()
        layout_edit.addWidget(self.source_combo)
        layout_edit.addSpacing(10)
        layout_edit.addWidget(QLabel(_("Object")))
        self.combo = ObjectComboBox(self)
        layout_edit.addWidget(self.combo)
        self.object_edit = QLineEdit(self)
        self.object_edit.setReadOnly(True)
        layout_edit.addWidget(self.object_edit)
        self.combo.setMaxCount(self.get_option('max_history_entries'))
        self.combo.addItems( self.load_history() )
        self.connect(self.combo, SIGNAL("valid(bool)"),
                     lambda valid: self.force_refresh())
        
        # Plain text docstring option
        self.docstring = True
        self.rich_help = sphinxify is not None \
                         and self.get_option('rich_mode', True)
        self.plain_text_action = create_action(self, _("Plain Text"),
                                               toggled=self.toggle_plain_text)
        
        # Source code option
        self.show_source_action = create_action(self, _("Show Source"),
                                                toggled=self.toggle_show_source)
        
        # Rich text option
        self.rich_text_action = create_action(self, _("Rich Text"),
                                         toggled=self.toggle_rich_text)
                        
        # Add the help actions to an exclusive QActionGroup
        help_actions = QActionGroup(self)
        help_actions.setExclusive(True)
        help_actions.addAction(self.plain_text_action)
        help_actions.addAction(self.rich_text_action)
        
        # Automatic import option
        self.auto_import_action = create_action(self, _("Automatic import"),
                                                toggled=self.toggle_auto_import)
        auto_import_state = self.get_option('automatic_import')
        self.auto_import_action.setChecked(auto_import_state)
        
        # Lock checkbox
        self.locked_button = create_toolbutton(self,
                                               triggered=self.toggle_locked)
        layout_edit.addWidget(self.locked_button)
        self._update_lock_icon()
        
        # Option menu
        options_button = create_toolbutton(self, text=_("Options"),
                                           icon=get_icon('tooloptions.png'))
        options_button.setPopupMode(QToolButton.InstantPopup)
        menu = QMenu(self)
        add_actions(menu, [self.rich_text_action, self.plain_text_action,
                           self.show_source_action, None,
                           self.auto_import_action])
        options_button.setMenu(menu)
        layout_edit.addWidget(options_button)

        if self.rich_help:
            self.switch_to_rich_text()
        else:
            self.switch_to_plain_text()
        self.plain_text_action.setChecked(not self.rich_help)
        self.rich_text_action.setChecked(self.rich_help)
        self.rich_text_action.setEnabled(sphinxify is not None)
        self.source_changed()

        # Main layout
        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addLayout(layout_edit)
        layout.addWidget(self.plain_text)
        layout.addWidget(self.rich_text)
        self.setLayout(layout)
        
        # Add worker thread for handling rich text rendering
        if sphinxify is None:
            self._sphinx_thread = None
        else:
            self._sphinx_thread = SphinxThread(text={},
                                  html_text_no_doc=warning(self.no_doc_string),
                                  math_option=self.get_option('math'))
            self.connect(self._sphinx_thread, SIGNAL('html_ready(QString)'), 
                         self._on_sphinx_thread_html_ready)
            self.connect(self._sphinx_thread, SIGNAL('error_msg(QString)'),
                         self._on_sphinx_thread_error_msg)

        self._starting_up = True
Exemplo n.º 45
0
    def setup_toolbar(self, exclude_private, exclude_uppercase,
                      exclude_capitalized, exclude_unsupported, autorefresh):
        """Setup toolbar"""
        self.setup_in_progress = True                          
                          
        toolbar = []

        refresh_button = create_toolbutton(self, text=_("Refresh"),
                                           icon=get_icon('reload.png'),
                                           triggered=self.refresh_table)
        self.auto_refresh_button = create_toolbutton(self,
                                           text=_("Refresh periodically"),
                                           icon=get_icon('auto_reload.png'),
                                           toggled=self.toggle_auto_refresh)
        self.auto_refresh_button.setChecked(autorefresh)
        load_button = create_toolbutton(self, text=_("Import data"),
                                        icon=get_icon('fileimport.png'),
                                        triggered=self.import_data)
        self.save_button = create_toolbutton(self, text=_("Save data"),
                            icon=get_icon('filesave.png'),
                            triggered=lambda: self.save_data(self.filename))
        self.save_button.setEnabled(False)
        save_as_button = create_toolbutton(self,
                                           text=_("Save data as..."),
                                           icon=get_icon('filesaveas.png'),
                                           triggered=self.save_data)
        toolbar += [refresh_button, self.auto_refresh_button, load_button,
                    self.save_button, save_as_button]
        
        self.exclude_private_action = create_action(self,
                _("Exclude private references"),
                tip=_("Exclude references which name starts"
                            " with an underscore"),
                toggled=lambda state:
                self.sig_option_changed.emit('exclude_private', state))
        self.exclude_private_action.setChecked(exclude_private)
        
        self.exclude_uppercase_action = create_action(self,
                _("Exclude all-uppercase references"),
                tip=_("Exclude references which name is uppercase"),
                toggled=lambda state:
                self.sig_option_changed.emit('exclude_uppercase', state))
        self.exclude_uppercase_action.setChecked(exclude_uppercase)
        
        self.exclude_capitalized_action = create_action(self,
                _("Exclude capitalized references"),
                tip=_("Exclude references which name starts with an "
                      "uppercase character"),
                toggled=lambda state:
                self.sig_option_changed.emit('exclude_capitalized', state))
        self.exclude_capitalized_action.setChecked(exclude_capitalized)
        
        self.exclude_unsupported_action = create_action(self,
                _("Exclude unsupported data types"),
                tip=_("Exclude references to unsupported data types"
                            " (i.e. which won't be handled/saved correctly)"),
                toggled=lambda state:
                self.sig_option_changed.emit('exclude_unsupported', state))
        self.exclude_unsupported_action.setChecked(exclude_unsupported)
        
        options_button = create_toolbutton(self, text=_("Options"),
                                           icon=get_icon('tooloptions.png'))
        toolbar.append(options_button)
        options_button.setPopupMode(QToolButton.InstantPopup)
        menu = QMenu(self)
        editor = self.editor
        actions = [self.exclude_private_action, self.exclude_uppercase_action,
                   self.exclude_capitalized_action,
                   self.exclude_unsupported_action, None,
                   editor.truncate_action, editor.inplace_action,
                   editor.collvalue_action]
        if is_module_installed('numpy'):
            actions.append(editor.minmax_action)
        if not self.is_internal_shell:
            actions.append(editor.remote_editing_action)
        add_actions(menu, actions)
        options_button.setMenu(menu)
        
        self.setup_in_progress = False
        
        return toolbar
Exemplo n.º 46
0
    def __init__(self, parent, workdir=None):
        QToolBar.__init__(self, parent)
        SMPluginMixin.__init__(self, parent)

        # Initialize plugin
        self.initialize_plugin()
        
        # Setting default values for editor-related options
        self.get_option('editor/open/browse_scriptdir', True)
        self.get_option('editor/open/browse_workdir', False)
        self.get_option('editor/new/browse_scriptdir', False)
        self.get_option('editor/new/browse_workdir', True)
        self.get_option('editor/open/auto_set_to_basedir', False)
        self.get_option('editor/save/auto_set_to_basedir', False)
        
        self.setWindowTitle(self.get_plugin_title()) # Toolbar title
        self.setObjectName(self.get_plugin_title()) # Used to save Window state
        
        # Previous dir action
        self.history = []
        self.histindex = None
        self.previous_action = create_action(self, "previous", None,
                                     get_icon('previous.png'), _('Back'),
                                     triggered=self.previous_directory)
        self.addAction(self.previous_action)
        
        # Next dir action
        self.history = []
        self.histindex = None
        self.next_action = create_action(self, "next", None,
                                     get_icon('next.png'), _('Next'),
                                     triggered=self.next_directory)
        self.addAction(self.next_action)
        
        # Enable/disable previous/next actions
        self.connect(self, SIGNAL("set_previous_enabled(bool)"),
                     self.previous_action.setEnabled)
        self.connect(self, SIGNAL("set_next_enabled(bool)"),
                     self.next_action.setEnabled)
        
        # Path combo box
        adjust = self.get_option('working_dir_adjusttocontents', False)
        self.pathedit = PathComboBox(self, adjust_to_contents=adjust)
        self.pathedit.setToolTip(_("This is the working directory for newly\n"
                               "opened consoles (Python interpreters and\n"
                               "terminals), for the file explorer, for the\n"
                               "find in files plugin and for new files\n"
                               "created in the editor"))
        self.connect(self.pathedit, SIGNAL("open_dir(QString)"), self.chdir)
        self.pathedit.setMaxCount(self.get_option('working_dir_history', 20))
        wdhistory = self.load_wdhistory( workdir )
        if workdir is None:
            if self.get_option('startup/use_last_directory', True):
                if wdhistory:
                    workdir = wdhistory[0]
                else:
                    workdir = "."
            else:
                workdir = self.get_option('startup/fixed_directory', ".")
                if not osp.isdir(workdir):
                    workdir = "."
        self.chdir(workdir)
        self.pathedit.addItems( wdhistory )
        self.refresh_plugin()
        self.addWidget(self.pathedit)
        
        # Browse action
        browse_action = create_action(self, "browse", None,
                                      get_std_icon('DirOpenIcon'),
                                      _('Browse a working directory'),
                                      triggered=self.select_directory)
        self.addAction(browse_action)
        
        # Set current console working directory action
        setwd_action = create_action(self, icon=get_icon('set_workdir.png'),
                                     text=_("Set as current console's "
                                                  "working directory"),
                                     triggered=self.set_as_current_console_wd)
        self.addAction(setwd_action)
        
        # Parent dir action
        parent_action = create_action(self, "parent", None,
                                      get_icon('up.png'),
                                      _('Change to parent directory'),
                                      triggered=self.parent_directory)
        self.addAction(parent_action)
Exemplo n.º 47
0
    def __init__(self, parent, workdir=None):
        QToolBar.__init__(self, parent)
        SMPluginMixin.__init__(self, parent)

        # Initialize plugin
        self.initialize_plugin()

        # Setting default values for editor-related options
        self.get_option('editor/open/browse_scriptdir', True)
        self.get_option('editor/open/browse_workdir', False)
        self.get_option('editor/new/browse_scriptdir', False)
        self.get_option('editor/new/browse_workdir', True)
        self.get_option('editor/open/auto_set_to_basedir', False)
        self.get_option('editor/save/auto_set_to_basedir', False)

        self.setWindowTitle(self.get_plugin_title())  # Toolbar title
        self.setObjectName(
            self.get_plugin_title())  # Used to save Window state

        # Previous dir action
        self.history = []
        self.histindex = None
        self.previous_action = create_action(self,
                                             "previous",
                                             None,
                                             get_icon('previous.png'),
                                             _('Back'),
                                             triggered=self.previous_directory)
        self.addAction(self.previous_action)

        # Next dir action
        self.history = []
        self.histindex = None
        self.next_action = create_action(self,
                                         "next",
                                         None,
                                         get_icon('next.png'),
                                         _('Next'),
                                         triggered=self.next_directory)
        self.addAction(self.next_action)

        # Enable/disable previous/next actions
        self.connect(self, SIGNAL("set_previous_enabled(bool)"),
                     self.previous_action.setEnabled)
        self.connect(self, SIGNAL("set_next_enabled(bool)"),
                     self.next_action.setEnabled)

        # Path combo box
        adjust = self.get_option('working_dir_adjusttocontents', False)
        self.pathedit = PathComboBox(self, adjust_to_contents=adjust)
        self.pathedit.setToolTip(
            _("This is the working directory for newly\n"
              "opened consoles (Python interpreters and\n"
              "terminals), for the file explorer, for the\n"
              "find in files plugin and for new files\n"
              "created in the editor"))
        self.connect(self.pathedit, SIGNAL("open_dir(QString)"), self.chdir)
        self.pathedit.setMaxCount(self.get_option('working_dir_history', 20))
        wdhistory = self.load_wdhistory(workdir)
        if workdir is None:
            if self.get_option('startup/use_last_directory', True):
                if wdhistory:
                    workdir = wdhistory[0]
                else:
                    workdir = "."
            else:
                workdir = self.get_option('startup/fixed_directory', ".")
                if not osp.isdir(workdir):
                    workdir = "."
        self.chdir(workdir)
        self.pathedit.addItems(wdhistory)
        self.refresh_plugin()
        self.addWidget(self.pathedit)

        # Browse action
        browse_action = create_action(self,
                                      "browse",
                                      None,
                                      get_std_icon('DirOpenIcon'),
                                      _('Browse a working directory'),
                                      triggered=self.select_directory)
        self.addAction(browse_action)

        # Set current console working directory action
        setwd_action = create_action(self,
                                     icon=get_icon('set_workdir.png'),
                                     text=_("Set as current console's "
                                            "working directory"),
                                     triggered=self.set_as_current_console_wd)
        self.addAction(setwd_action)

        # Parent dir action
        parent_action = create_action(self,
                                      "parent",
                                      None,
                                      get_icon('up.png'),
                                      _('Change to parent directory'),
                                      triggered=self.parent_directory)
        self.addAction(parent_action)
Exemplo n.º 48
0
    def __init__(self,
                 parent=None,
                 name_filters=['*.py', '*.pyw'],
                 valid_types=('.py', '.pyw'),
                 show_all=False,
                 show_cd_only=None,
                 show_toolbar=True,
                 show_icontext=True):
        QWidget.__init__(self, parent)

        self.treewidget = ExplorerTreeWidget(self, show_cd_only=show_cd_only)
        self.treewidget.setup(name_filters=name_filters,
                              valid_types=valid_types,
                              show_all=show_all)
        self.treewidget.chdir(os.getcwdu())

        toolbar_action = create_action(self,
                                       _("Show toolbar"),
                                       toggled=self.toggle_toolbar)
        icontext_action = create_action(self,
                                        _("Show icons and text"),
                                        toggled=self.toggle_icontext)
        self.treewidget.common_actions += [
            None, toolbar_action, icontext_action
        ]

        # Setup toolbar
        self.toolbar = QToolBar(self)
        self.toolbar.setIconSize(QSize(16, 16))

        self.previous_action = create_action(
            self,
            text=_("Previous"),
            icon=get_icon('previous.png'),
            triggered=self.treewidget.go_to_previous_directory)
        self.toolbar.addAction(self.previous_action)
        self.previous_action.setEnabled(False)
        self.connect(self.treewidget, SIGNAL("set_previous_enabled(bool)"),
                     self.previous_action.setEnabled)

        self.next_action = create_action(
            self,
            text=_("Next"),
            icon=get_icon('next.png'),
            triggered=self.treewidget.go_to_next_directory)
        self.toolbar.addAction(self.next_action)
        self.next_action.setEnabled(False)
        self.connect(self.treewidget, SIGNAL("set_next_enabled(bool)"),
                     self.next_action.setEnabled)

        parent_action = create_action(
            self,
            text=_("Parent"),
            icon=get_icon('up.png'),
            triggered=self.treewidget.go_to_parent_directory)
        self.toolbar.addAction(parent_action)

        options_action = create_action(self,
                                       text='',
                                       tip=_("Options"),
                                       icon=get_icon('tooloptions.png'))
        self.toolbar.addAction(options_action)
        widget = self.toolbar.widgetForAction(options_action)
        widget.setPopupMode(QToolButton.InstantPopup)
        menu = QMenu(self)
        add_actions(menu, self.treewidget.common_actions)
        options_action.setMenu(menu)

        toolbar_action.setChecked(show_toolbar)
        self.toggle_toolbar(show_toolbar)
        icontext_action.setChecked(show_icontext)
        self.toggle_icontext(show_icontext)

        vlayout = QVBoxLayout()
        vlayout.addWidget(self.toolbar)
        vlayout.addWidget(self.treewidget)
        self.setLayout(vlayout)
Exemplo n.º 49
0
    def __init__(self, parent):
        SMPluginWidget.__init__(self, parent)

        self.internal_shell = None

        # Initialize plugin
        self.initialize_plugin()

        self.no_doc_string = _("No documentation available")

        self._last_console_cb = None
        self._last_editor_cb = None

        self.set_default_color_scheme()

        self.plain_text = PlainText(self)
        self.rich_text = RichText(self)

        color_scheme = get_color_scheme(self.get_option("color_scheme_name"))
        self.set_plain_text_font(self.get_plugin_font(), color_scheme)
        self.plain_text.editor.toggle_wrap_mode(self.get_option("wrap"))

        # Add entries to read-only editor context-menu
        font_action = create_action(
            self, _("&Font..."), None, "font.png", _("Set font style"), triggered=self.change_font
        )
        self.wrap_action = create_action(self, _("Wrap lines"), toggled=self.toggle_wrap_mode)
        self.wrap_action.setChecked(self.get_option("wrap"))
        self.plain_text.editor.readonly_menu.addSeparator()
        add_actions(self.plain_text.editor.readonly_menu, (font_action, self.wrap_action))

        self.set_rich_text_font(self.get_plugin_font("rich_text"))

        self.shell = None

        self.external_console = None

        # locked = disable link with Console
        self.locked = False
        self._last_texts = [None, None]
        self._last_rope_data = None

        # Object name
        layout_edit = QHBoxLayout()
        layout_edit.setContentsMargins(0, 0, 0, 0)
        txt = _("Source")
        if sys.platform == "darwin":
            source_label = QLabel("  " + txt)
        else:
            source_label = QLabel(txt)
        layout_edit.addWidget(source_label)
        self.source_combo = QComboBox(self)
        self.source_combo.addItems([_("Console"), _("Editor")])
        self.connect(self.source_combo, SIGNAL("currentIndexChanged(int)"), self.source_changed)
        if not programs.is_module_installed("rope"):
            self.source_combo.hide()
            source_label.hide()
        layout_edit.addWidget(self.source_combo)
        layout_edit.addSpacing(10)
        layout_edit.addWidget(QLabel(_("Object")))
        self.combo = ObjectComboBox(self)
        layout_edit.addWidget(self.combo)
        self.object_edit = QLineEdit(self)
        self.object_edit.setReadOnly(True)
        layout_edit.addWidget(self.object_edit)
        self.combo.setMaxCount(self.get_option("max_history_entries"))
        self.combo.addItems(self.load_history())
        self.connect(self.combo, SIGNAL("valid(bool)"), lambda valid: self.force_refresh())

        # Plain text docstring option
        self.docstring = True
        self.rich_help = sphinxify is not None and self.get_option("rich_mode", True)
        self.plain_text_action = create_action(self, _("Plain Text"), toggled=self.toggle_plain_text)

        # Source code option
        self.show_source_action = create_action(self, _("Show Source"), toggled=self.toggle_show_source)

        # Rich text option
        self.rich_text_action = create_action(self, _("Rich Text"), toggled=self.toggle_rich_text)

        # Add the help actions to an exclusive QActionGroup
        help_actions = QActionGroup(self)
        help_actions.setExclusive(True)
        help_actions.addAction(self.plain_text_action)
        help_actions.addAction(self.rich_text_action)

        # Automatic import option
        self.auto_import_action = create_action(self, _("Automatic import"), toggled=self.toggle_auto_import)
        auto_import_state = self.get_option("automatic_import")
        self.auto_import_action.setChecked(auto_import_state)

        # Lock checkbox
        self.locked_button = create_toolbutton(self, triggered=self.toggle_locked)
        layout_edit.addWidget(self.locked_button)
        self._update_lock_icon()

        # Option menu
        options_button = create_toolbutton(self, text=_("Options"), icon=get_icon("tooloptions.png"))
        options_button.setPopupMode(QToolButton.InstantPopup)
        menu = QMenu(self)
        add_actions(
            menu,
            [self.rich_text_action, self.plain_text_action, self.show_source_action, None, self.auto_import_action],
        )
        options_button.setMenu(menu)
        layout_edit.addWidget(options_button)

        if self.rich_help:
            self.switch_to_rich_text()
        else:
            self.switch_to_plain_text()
        self.plain_text_action.setChecked(not self.rich_help)
        self.rich_text_action.setChecked(self.rich_help)
        self.rich_text_action.setEnabled(sphinxify is not None)
        self.source_changed()

        # Main layout
        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addLayout(layout_edit)
        layout.addWidget(self.plain_text)
        layout.addWidget(self.rich_text)
        self.setLayout(layout)

        # Add worker thread for handling rich text rendering
        if sphinxify is None:
            self._sphinx_thread = None
        else:
            self._sphinx_thread = SphinxThread(
                text={}, html_text_no_doc=warning(self.no_doc_string), math_option=self.get_option("math")
            )
            self.connect(self._sphinx_thread, SIGNAL("html_ready(QString)"), self._on_sphinx_thread_html_ready)
            self.connect(self._sphinx_thread, SIGNAL("error_msg(QString)"), self._on_sphinx_thread_error_msg)

        self._starting_up = True