コード例 #1
0
ファイル: fl_widgets.py プロジェクト: m00n/filelegend
    def make_dockbar(self, widget):
        action_new_fw = create_action(self,
            text=u'New panel',
            icon=u'gfx/splitview.png',
            triggered=self.new_panel
        )

        action_close = create_action(self,
            text=u'Close',
            icon=u'gfx/cancel.png',
            triggered=partial(self.close_panel, widget)
        )

        action_link_panel = create_action(self,
            text=u'Link panel',
            icon=u'gfx/link.png',
            checkable=True,
            triggered=partial(self.link_panel_action, widget)
        )

        toolbar = QToolBar(widget)

        for action, name  in zip([action_new_fw,
                                  action_link_panel, action_close],
                                 ['action_new_fw',
                                  'action_link_panel', 'action_close']):
            toolbar.addAction(action)
            setattr(widget, name, action)

        toolbar.setIconSize(QSize(12, 12))

        return toolbar
コード例 #2
0
ファイル: filewidget.py プロジェクト: m00n/filelegend
    def __init__(self, parent, directory):
        QTreeView.__init__(self, parent)
        FileWidgetBase.__init__(self, directory)

        self.setIconSize(QSize(24, 24))
        self.setSortingEnabled(True)
        self.setUniformRowHeights(True)
        self.setAlternatingRowColors(True)
        self.setSelectionBehavior(self.SelectRows)
        self.setSelectionMode(self.ExtendedSelection)
        self.setVerticalScrollMode(self.ScrollPerPixel)

        self.setDragEnabled(True)
        self.setAcceptDrops(True)
        self.setRootIsDecorated(False)

        header = self.header()
        header.setMovable(True)

        header.installEventFilter(
            PyEventFilter(
                self,
                header,
                QContextMenuEvent,
                self.on_header_contextmenu
            )
        )

        self.action_hide_columns = create_action(self,
            text=u"Show columns",
            checkable=True,
            checked=True,
            toggled=self.header().setVisible
        )

        self.action_fit_columns = create_action(self,
            text=u"Fit columns to contents",
            triggered=partial(
                self.header().resizeSections,
                QHeaderView.ResizeToContents,
            ),
            shortcut="Ctrl+p",
            shortcut_context=Qt.WidgetShortcut,
        )

        self.action_auto_resize = create_action(self,
            text=u"Fit columns to contents automatically",
            checkable=True,
            checked=True,
        )

        self.column_actions = {}
        self.column_menu = QMenu(self)
コード例 #3
0
ファイル: main_window.py プロジェクト: m00n/filelegend
        def make_button(**action_args):
            button = QToolButton()
            button.setDefaultAction(create_action(self,
                **action_args
            ))

            return button
コード例 #4
0
ファイル: fl_widgets.py プロジェクト: m00n/filelegend
    def __init__(self, parent, initial_path):
        QTabWidget.__init__(self, parent)
        TabDragDropMixin.__init__(self)

        self.setTabPosition(self.South)
        self.setMovable(True)
        self.setTabsClosable(True)
        self.setMouseTracking(True)

        button = QToolButton(self)
        button.setIcon(QIcon('gfx/newtab.png'))
        button.clicked.connect(self.new_tab)

        self.setCornerWidget(button)

        self.initial_path = initial_path

        self.action_hide_tabbar = create_action(self,
            text="Show tabbar",
            checkable=True,
            checked=True,
            triggered=self.toggle_tabbar
        )

        self.action_shorten_tabnames = create_action(self,
            text="Shorten tab captions",
            checkable=True,
            checked=True,
            triggered=self.toggle_shorten_tabnames
        )

        self.action_set_tabwidth = create_action(self,
            text="Set tabwidth",
            triggered=self.set_tabwidth
        )

        self.tab_width = 150
        self.shorten_tabnames = True

        self.buddy = None
        self.remove_buddy = None
        self.linked_filewidget = None

        self.tabCloseRequested.connect(self.close_tab)
コード例 #5
0
ファイル: main_window.py プロジェクト: m00n/filelegend
    def setup_navigation_buttons(self):
        def make_button(**action_args):
            button = QToolButton()
            button.setDefaultAction(create_action(self,
                **action_args
            ))

            return button

        back_button = make_button(
            text="Back",
            icon=icon('back.png'),
            triggered=lambda: self.active_filewidget.set_path(
                self.active_filewidget.path_history.prev_item(),
            )
        )

        forward_button = make_button(
            text="Forward",
            icon=icon('next.png'),
            triggered=lambda: self.active_filewidget.set_path(
                self.active_filewidget.path_history.next_item(),
            )
        )

        up_button = QToolButton()
        up_button.setDefaultAction(create_action(self,
            text="Go to parent directory",
            icon=icon('up2.png'),
            triggered=lambda: self.active_filewidget.set_path(
                self.active_filewidget.directory.path.parent
            )
        ))

        history_button = make_button(
            text=u"",
            icon=icon('menu-arrow.png')
        )
        history_button.setArrowType(Qt.NoArrow)
        button_menu = QMenu(history_button)
        button_menu.aboutToShow.connect(
            partial(self.build_history_menu, button_menu)
        )
        history_button.setPopupMode(QToolButton.InstantPopup)
        history_button.setMenu(button_menu)

        refresh_button = make_button(
            text="Refresh",
            icon=icon('reload.png'),
            triggered=lambda: self.active_filewidget.currentWidget() \
                                                    .action_refresh.emit()
        )

        for widget in (back_button, forward_button, up_button,
                       history_button, refresh_button):
            self.addWidget(widget)
コード例 #6
0
ファイル: fl_widgets.py プロジェクト: m00n/filelegend
    def mouseReleaseEvent(self, event):
        def edit_tabtext():
            text, ok = QInputDialog.getText(self,
                "Enter name",
                "Enter new tab name",
                QLineEdit.Normal,
                self.tabText(index)
            )

            if ok:
                self.setTabText(index, text)

        def set_tabicon():
            filename = QFileDialog.getOpenFileName(self,
                "Choose tabicon",
                path(u'~').expand(),
                "Images (*.png *.gif *.jpg *.xpm)",
            )

            if filename:
                self.setTabIcon(index, QIcon(filename))


        index = self.tabBar().tabAt(event.pos())
        if index > -1:
            action_edit_name = create_action(self,
                text="Change tab title",
                triggered=edit_tabtext
            )
            action_set_icon = create_action(self,
                text="Change tab icon",
                triggered=set_tabicon
            )

            menu = QMenu(self)
            menu.addAction(action_edit_name)
            menu.addAction(action_set_icon)

            menu.popup(self.mapToGlobal(event.pos()))

        return QTabWidget.mouseReleaseEvent(self, event)
コード例 #7
0
ファイル: main_window.py プロジェクト: m00n/filelegend
 def build_history_menu(self, menu):
     menu.clear()
     path_history = self.main_window.active_filewidget.path_history
     for i, filename in enumerate(path_history):
         menu.addAction(create_action(self,
             text=filename.name,
             checkable=True,
             checked=bool(path_history.pos == i),
             triggered=partial(
                 self.active_filewidget.set_path,
                 filename,
                 True,
             )
         ))
コード例 #8
0
ファイル: main_window.py プロジェクト: m00n/filelegend
    def build_view_menu(self, menu):
        menu.clear()
        action_group = QActionGroup(menu)
        view_actions = self.active_filewidget.view_actions.iteritems()
        for view_name, view_action in view_actions:
            action = create_action(menu,
                text=view_action.text(),
                icon=view_action.icon(),
                checkable=True,
                triggered=partial(self._view_clicked, view_name),
            )
            if view_name == self.active_filewidget.current_widget_name:
                action.setChecked(True)

            action_group.addAction(action)
            menu.addAction(action)
コード例 #9
0
ファイル: filewidget.py プロジェクト: m00n/filelegend
    def make_column_menu(self):
        self.column_menu.clear()

        for index, column in self.model().columns.iteritems():
            action = self.column_actions[index] = create_action(self,
                text=column,
                checkable=True,
                checked=True,
                triggered=lambda c, i=index: self.setColumnHidden(i, not c)
            )
            self.column_menu.addAction(action)

        self.column_menu.addSeparator()
        self.column_menu.addAction(self.action_hide_columns)
        self.column_menu.addSeparator()
        self.column_menu.addAction(self.action_auto_resize)
        self.column_menu.addAction(self.action_fit_columns)
コード例 #10
0
ファイル: filewidget.py プロジェクト: m00n/filelegend
    def create_view_action(self, widget_name, **kwds):
        """
        Create view-action for widget_name
        The triggered param is created automatically
        """

        if "triggered" not in kwds:
            kwds["triggered"] = partial(self.show_widget, widget_name)

        kwds['shortcut_context'] = Qt.WidgetWithChildrenShortcut
        kwds['checkable'] = True

        self.view_actions[widget_name] = action = create_action(self, **kwds)

        self.action_group.addAction(action)
        self.addAction(action)

        return action
コード例 #11
0
ファイル: appselect.py プロジェクト: m00n/filelegend
    def create_qaction(self, action_parent, **action_args):
        kwds = {
            'text': self.name,
            'icon': self.icon_path,
            'triggered': partial(self.run, qtapp())
        }
        kwds.update(action_args)
        key = frozenset(kwds.items())

        try:
            return self._qactions[key]
        except KeyError:
            self._qactions[key] = action = create_action(
                action_parent,
                text=self.name,
                icon=self.icon_path,
                triggered=partial(self.run, qtapp())
            )

            return action
コード例 #12
0
ファイル: filewidget.py プロジェクト: m00n/filelegend
    def get_sort_actions(self):
        def sort(idx):
            self.model().sort(idx)
            try:
                self.sortByColumn(idx, Qt.AscendingOrder)
            except AttributeError:
                pass

        if self.sort_actions:
            return self.sort_actions

        for index, colname in sorted(self.model().columns.iteritems()):
            action = create_action(self,
                text="Sort by '%s'" % colname,
                triggered=lambda _, i=index: sort(i)
            )

            self.sort_actions.append(action)

        return self.sort_actions
コード例 #13
0
ファイル: fl_widgets.py プロジェクト: m00n/filelegend
    def mouseReleaseEvent(self, event):
        def duplicate_tab_cb():
            self.new_tab(self.currentWidget().filewidget.directory.path)

        if event.button() == Qt.RightButton:
            mouse_pos = QPoint(event.pos().x(), 10)
            tab_index = self.tabBar().tabAt(mouse_pos)
            print tab_index

            menu = QMenu(self)
            menu.addAction(self.action_set_tabwidth)
            menu.addAction(self.action_shorten_tabnames)

            if tab_index > -1:
                menu.addSeparator()
                menu.addAction(create_action(self,
                    text="Duplicate tab",
                    triggered=duplicate_tab_cb
                ))

            menu.popup(self.mapToGlobal(event.pos()))
コード例 #14
0
ファイル: fl_widgets.py プロジェクト: m00n/filelegend
    def __init__(self, parent, initial_path):
                 #filewidget_factory=MultiFileWidget):
        QWidget.__init__(self, parent)

        self.directory = Directory(path(initial_path))
        print ">>>", initial_path

        self.path_combo = QComboBox(self)

        self.path_combo.setEditable(True)
        self.path_combo.lineEdit() \
                       .returnPressed \
                       .connect(self.pathcombo_return_pressed)

        self.filter_combo = QComboBox(self)
        self.filter_combo.setEditable(True)
        self.filter_combo.lineEdit() \
                         .returnPressed \
                         .connect(self.filtercombo_return_pressed)

        self.free_space_label = QLabel(self)
        self.free_space_label.setProperty('is_status', True)

        self.filewidget = MultiFileWidget(self, self.directory)
        self.filewidget.currentChanged.connect(self.view_widget_changed)

        for widget in self.filewidget.widgets:
            self.connect_filewidget_events(widget)

        self.filewidget.newWidget.connect(self.connect_filewidget_events)

        self.selection_status_label = DropLabel(self, self.mime_data_dropped)
        self.selection_status_label.setProperty('is_status', True)

        self.jump_button = QToolButton(self)
        self.jump_button.setIcon(icon('jump.png'))
        self.jump_button.clicked.connect(
            self.jump_menu_requested
        )

        layout = QVBoxLayout()
        layout.setSpacing(5)

        path_combo_layout = QHBoxLayout()
        path_combo_layout.setContentsMargins(0, 0, 0, 0)

        path_combo_layout.addWidget(self.path_combo)
        path_combo_layout.addWidget(self.jump_button)

        layout.addLayout(path_combo_layout)

        for widget in [self.filter_combo,
                       self.free_space_label,
                       self.filewidget,
                       self.selection_status_label]:

            layout.addWidget(widget)

        self.setLayout(layout)

        self.filewidget_dir_changed(initial_path)

        self.action_hide_jump = create_action(self,
            text="Show jump button",
            checkable=True,
            checked=False,
            triggered=self.jump_button.setVisible
        )

        self.action_hide_path = create_action(self,
            text="Show current path",
            checkable=True,
            checked=True,
            triggered=self.path_combo.setVisible
        )
        self.action_hide_path.triggered.connect(
            self.action_hide_jump.triggered.emit
        )

        self.action_hide_filter = create_action(self,
            text="Show filter",
            checkable=True,
            checked=True,
            triggered=self.filter_combo.setVisible
        )

        self.action_hide_selection_status = create_action(self,
            text="Show selection status",
            checkable=True,
            checked=True,
            triggered=self.selection_status_label.setVisible
        )

        self._last_filters = {}
コード例 #15
0
ファイル: picview.py プロジェクト: m00n/filelegend
    def __init__(self, parent, files, start_filename=None):
        QGraphicsView.__init__(self, parent)

        self.setMouseTracking(True)
        self.setRenderHints(QPainter.Antialiasing |
                            #QPainter.SmoothPixmapTransform|
                            QPainter.HighQualityAntialiasing)

        self.files = files

        if start_filename:
            self.index = files.index(start_filename)
        else:
            self.index = 0

        toolbar = self.toolbar = QToolBar(self)
        self.toolbar.show()

        self.toolbar.addAction(create_action(self,
            text="Leave fullscreen",
            icon=icon('window-close.png'),
            triggered=self.close # XXX need testing
        ))

        self.toolbar.addSeparator()

        self.toolbar.addAction(create_action(self,
            text="Previous",
            icon=icon('back.png'),
            triggered=self.previousPicture,
        ))

        self.toolbar.addAction(create_action(self,
            text="Next",
            icon=icon('next.png'),
            triggered=self.nextPicture,
        ))

        self.toolbar.addSeparator()

        self.toolbar.addAction(create_action(self,
            text="Zoom out",
            icon=icon('zoom-out.png'),
            triggered=lambda: self.actionScale(1 / 1.2),
        ))
        self.toolbar.addAction(create_action(self,
            text="Zoom in",
            icon=icon('zoom-in.png'),
            triggered=lambda: self.actionScale(1.2)
        ))
        self.toolbar.addAction(create_action(self,
            text="Fit",
            icon=icon('zoom-best-fit.png'),
            triggered=self.fit
        ))
        self.toolbar.addAction(create_action(self,
            text="1:1",
            icon=icon('zoom-original.png'),
            triggered=self.actionReset,
        ))
        self.toolbar.addSeparator()

        self.resolution_label = QLabel(toolbar)
        self.resolution_label.setAlignment(Qt.AlignVCenter)
        self.toolbar.addWidget(self.resolution_label)

        #self._move_toolbar()

        self.scene = QGraphicsScene()
        self.scene.setBackgroundBrush(Qt.black)

        self.picture = self.picture_item = None
        self.showPicture()

        self.setScene(self.scene)

        self.timer = QTimer(self)
        self.timer.timeout.connect(self.hideToolbar)

        self.toolbar_toggled = False
        self.fit_to_window = True
コード例 #16
0
ファイル: filewidget.py プロジェクト: m00n/filelegend
    def __init__(self, directory):
        TypeAHeadMixin.__init__(self)

        self.menu = None
        self.directory = directory
        self.buddies = {}
        self.sort_actions = []

        self._last_selected = {}

        self.doubleClicked.connect(self.on_item_doubleclick)
        self.setEditTriggers(self.EditKeyPressed)

        self.action_rethumb = create_action(self,
            text="Refresh thumbnail",
            triggered=self.rethumb_action
        )

        self.action_customthumb = create_action(self,
            text="Set custom thumbnail",
            triggered=self.custom_thumb_action
        )

        self.action_nothumb = create_action(self,
            text="Remove thumbnail",
            triggered=self.nothumb_action
        )

        self.action_refresh = create_action(self,
            text="Refresh",
            icon='gfx/reload.png',
            shortcut="F5",
            shortcut_context=Qt.WidgetShortcut,
            triggered=lambda: self.model().changeDirectory()
        )

        self.action_rename = create_action(self,
            text="Rename",
            triggered=self.edit_wrapper
        )

        self.action_delete = create_action(self,
            text="Delete",
            shortcut="Del",
            shortcut_context=Qt.WidgetShortcut,
            triggered=self.delete_action
        )

        self.action_mkdir = create_action(self,
            text="Mkdir",
            shortcut="Ins",
            shortcut_context=Qt.WidgetShortcut,
            triggered=self.mkdir_action
        )

        self.addActions([
            self.action_rethumb,
            self.action_refresh,
            self.action_delete,
            self.action_mkdir,
        ])