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)
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 = {}
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