def __call__(self, size): thumbdir = qtapp().config.thumbdir / size try: return self.instances[thumbdir, size] except KeyError: if size == 'small': thumb_size = 110 dir_template = 'gfx/thumbs/dir.png' file_template = 'gfx/thumbs/file.png' error_template = 'gfx/thumbs/error.png' elif size == 'large': thumb_size = 400 dir_template = 'gfx/thumbs/dir-large.png' file_template = 'gfx/thumbs/file-large.png' error_template = 'gfx/thumbs/error-large.png' thumbdir = qtapp().config.thumbdir / size instance = ThumbDB( thumbdir, thumb_size, dir_template, file_template, error_template ) self.instances[thumbdir, size] = instance instance.start() return instance
def make_widget_panel(self, widget): wrapper = type( 'PanelWrapper', (QWidget,), { } )(self) wrapper.setProperty('is_panel_wrapper', 'true') wrapper.widget = widget widget.setParent(wrapper) layout = QVBoxLayout(wrapper) layout.setContentsMargins(0, 0, 0, 0) toolbarwidget = QFrame(wrapper) toolbarwidget.setProperty('is_dockbar_wrapper', 'true') wrapper.toolbar = toolbar = self.make_dockbar(wrapper) toolbar.setProperty('is_dockbar', 'true') sublayout = QHBoxLayout() sublayout.setContentsMargins(0, 0, 0, 0) sublayout.addStretch(1) sublayout.addWidget(toolbar) toolbarwidget.setLayout(sublayout) layout.addWidget(toolbarwidget) layout.addWidget(widget) wrapper.setLayout(layout) wrapper.setStyleSheet(qtapp().styleSheet()) return wrapper
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