def paintEvent(self, event): painter = QtGui.QPainter() painter.begin(self) painter.setRenderHint(QtGui.QPainter.Antialiasing) painter.setBrush(QtCore.Qt.NoBrush) color = common.REMOVE if settings.local_settings.current_mode( ) else common.ADD pen = QtGui.QPen(color) o = common.INDICATOR_WIDTH() * 1.5 pen.setWidth(common.INDICATOR_WIDTH() * 0.66) painter.setPen(pen) painter.setOpacity(self.animation.currentValue()) rect = QtCore.QRect(self.rect()) rect = rect.marginsRemoved(QtCore.QMargins(o, o, o, o)) center = self.rect().center() size = QtCore.QSize(rect.width() - (o), rect.height() - (o)) rect.setSize(size * self.animation.currentValue()) rect.moveCenter(center) c = rect.height() / 2.0 painter.drawRoundedRect(rect, c, c) painter.end()
def paintEvent(self, event): if not self.drop_target: return painter = QtGui.QPainter() painter.begin(self) painter.setRenderHint(QtGui.QPainter.Antialiasing, True) painter.setRenderHint(QtGui.QPainter.SmoothPixmapTransform, True) painter.setPen(QtCore.Qt.NoPen) painter.setBrush(common.SEPARATOR) painter.drawRoundedRect(self.rect(), common.INDICATOR_WIDTH(), common.INDICATOR_WIDTH()) pixmap = images.ImageCache.get_rsc_pixmap( u'slack', common.ADD, self.rect().height() - (common.INDICATOR_WIDTH() * 1.5)) rect = pixmap.rect() rect.moveCenter(self.rect().center()) painter.drawPixmap(rect, pixmap, pixmap.rect()) o = common.INDICATOR_WIDTH() rect = self.rect().marginsRemoved(QtCore.QMargins(o, o, o, o)) painter.setBrush(QtCore.Qt.NoBrush) pen = QtGui.QPen(common.ADD) pen.setWidthF(common.ROW_SEPARATOR() * 2.0) painter.setPen(pen) painter.drawRoundedRect(rect, o, o) painter.end()
def paintEvent(self, event): painter = QtGui.QPainter() painter.begin(self) painter.setPen(QtCore.Qt.NoPen) painter.setBrush(QtGui.QColor(255, 255, 255, 255)) painter.drawRoundedRect(self.rect(), common.INDICATOR_WIDTH(), common.INDICATOR_WIDTH()) painter.end()
def _create_UI(self): if self._frameless is True: o = common.INDICATOR_WIDTH() # offset around the widget else: o = 0 QtWidgets.QVBoxLayout(self) self.layout().setContentsMargins(o, o, o, o) self.layout().setSpacing(0) self.setContextMenuPolicy(QtCore.Qt.NoContextMenu) self.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum) self.headerwidget = HeaderWidget(parent=self) self.stackedwidget = StackedWidget(parent=self) self.bookmarkswidget = BookmarksWidget(parent=self) self.assetswidget = AssetsWidget(parent=self) self.fileswidget = FilesWidget(parent=self) self.favouriteswidget = FavouritesWidget(parent=self) self.stackedwidget.addWidget(self.bookmarkswidget) self.stackedwidget.addWidget(self.assetswidget) self.stackedwidget.addWidget(self.fileswidget) self.stackedwidget.addWidget(self.favouriteswidget) # Setting the tab now before we do any more initialisation idx = settings.local_settings.value(u'widget/mode') idx = 0 if idx is None or False else idx idx = 0 if idx < 0 else idx idx = 3 if idx > 3 else idx self.stackedwidget._setCurrentIndex(idx) self.listcontrolwidget = ListControlWidget(parent=self) if self._frameless: self.layout().addWidget(self.headerwidget) self.layout().addWidget(self.listcontrolwidget) self.layout().addWidget(self.stackedwidget) height = common.MARGIN() + (common.INDICATOR_WIDTH() * 2) row = common_ui.add_row(None, padding=0, height=height, parent=self) row.layout().setSpacing(0) row.layout().setContentsMargins(0, 0, 0, 0) self.statusbar = StatusBar(height, parent=self) self.solo_button = ToggleModeButton(height, parent=self) self.solo_button.message.connect( lambda s: self.statusbar.showMessage(s, 4000)) self.thread_monitor = threads.ThreadMonitor(parent=self) row.layout().addWidget(self.thread_monitor, 0) row.layout().addWidget(self.statusbar, 1) row.layout().addWidget(self.solo_button, 0)
def paintEvent(self, event): painter = QtGui.QPainter() painter.begin(self) font, metrics = common.font_db.secondary_font(common.SMALL_FONT_SIZE()) common.draw_aliased_text( painter, font, self.rect().marginsRemoved( QtCore.QMargins(common.INDICATOR_WIDTH(), 0, common.INDICATOR_WIDTH(), 0)), u' {} '.format(self.currentMessage()), QtCore.Qt.AlignVCenter | QtCore.Qt.AlignLeft, common.TEXT) painter.end()
def paintEvent(self, event): painter = QtGui.QPainter() painter.begin(self) pen = QtGui.QPen(common.SEPARATOR) pen.setWidthF(common.ROW_SEPARATOR()) painter.setPen(pen) painter.setRenderHint(QtGui.QPainter.Antialiasing) painter.setBrush(common.BACKGROUND) o = common.MARGIN() * 0.3 painter.setOpacity(0.95) painter.drawRoundedRect( self.rect().marginsRemoved(QtCore.QMargins(o, o, o, o)), common.INDICATOR_WIDTH(), common.INDICATOR_WIDTH()) painter.end()
def eventFilter(self, widget, event): """Using the custom event filter to paint the background.""" if event.type() == QtCore.QEvent.Paint: painter = QtGui.QPainter() painter.begin(self) font = common.font_db.secondary_font( font_size=common.MEDIUM_FONT_SIZE())[0] painter.setFont(font) painter.setRenderHints(QtGui.QPainter.Antialiasing) o = common.INDICATOR_WIDTH() rect = self.rect().marginsRemoved(QtCore.QMargins(o, o, o, o)) painter.setBrush(QtGui.QColor(250, 250, 250, 255)) painter.setPen(QtCore.Qt.NoPen) painter.drawRoundedRect(rect, o * 2, o * 2) center = rect.center() rect.setWidth(rect.width() - common.MARGIN()) rect.setHeight(rect.height() - common.MARGIN()) rect.moveCenter(center) text = u'Click the plus icon on the top to add a note' text = text if not len(self.todoeditors_widget.items) else u'' common.draw_aliased_text(painter, font, rect, text, QtCore.Qt.AlignCenter, common.SECONDARY_BACKGROUND) painter.end() return False
def __init__(self, path, parent=None): global _viewer_instance _viewer_instance = self super(AlembicView, self).__init__(parent=parent) if not isinstance(path, unicode): raise ValueError( u'Expected <type \'unicode\'>, got {}'.format(type(path))) if not self.parent(): common.set_custom_stylesheet(self) file_info = QtCore.QFileInfo(path) if not file_info.exists(): s = '{} does not exists.'.format(path) common_ui.ErrorBox( u'Error viewing the alembic contents.', s).open() log.error(s) raise RuntimeError(s) self.path = path self.view = AlembicTree(path, parent=self) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setAttribute(QtCore.Qt.WA_NoSystemBackground) self.setAttribute(QtCore.Qt.WA_TranslucentBackground) self.setWindowFlags( QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint ) self._create_UI() self.view.setStyleSheet(u'QTreeView {{padding:{p}px; border-radius: {p}px; border: {s}px solid black;}}'.format( p=common.INDICATOR_WIDTH() * 2, s=common.ROW_SEPARATOR()))
def update_editor(self): """Sets the editor widget's size, position and text contents.""" index = self.parent().selectionModel().currentIndex() if not index.isValid(): self.hide() return rect = self.parent().visualRect(index) rectangles = delegate.get_rectangles( rect, self.parent().inline_icons_count()) description_rect = self.parent().itemDelegate( ).get_description_rect(rectangles, index) # Won't be showing the editor if there's no appropiate description area # provided by the delegate (eg. the bookmark items don't have this) if not description_rect: self.hide() # Let's set the size based on the size provided by the delegate but # center it instead o = common.INDICATOR_WIDTH() * 2.0 rect = description_rect.marginsAdded(QtCore.QMargins(0, o, 0, o)) rect.moveCenter(rectangles[delegate.DataRect].center()) self.setGeometry(rect) # Set the text and select it self.setText(u'{}'.format(index.data(common.DescriptionRole))) self.selectAll()
def __init__(self, parent=None): super(MinimizeButton, self).__init__(u'minimize', (common.REMOVE, common.SECONDARY_TEXT), common.MARGIN() - common.INDICATOR_WIDTH(), description=u'Click to minimize the window...', parent=parent)
def _create_UI(self): QtWidgets.QVBoxLayout(self) o = common.MARGIN() self.layout().setContentsMargins(o, o, o, o) self.layout().setSpacing(common.INDICATOR_WIDTH()) height = common.ROW_HEIGHT() * 0.7 row = common_ui.add_row(None, height=height, padding=None, parent=self) self.channel_button = common_ui.ClickableIconButton( u'slack', (common.TEXT, common.TEXT), height, ) label = common_ui.PaintedLabel(u'Send Message', size=common.LARGE_FONT_SIZE(), parent=row) label.setFixedHeight(height) self.hide_button = common_ui.ClickableIconButton( u'close', (common.REMOVE, common.REMOVE), height, parent=row) row.layout().addWidget(label, 0) row.layout().addStretch(1) row.layout().addWidget(self.channel_button, 0) row.layout().addWidget(self.hide_button, 0) self.message_widget = MessageWidget(self.token, parent=self) self.layout().addSpacing(o * 0.5) self.layout().addWidget(self.message_widget) self.send_button = common_ui.PaintedButton(u'Send', parent=self) self.layout().addSpacing(o) self.layout().addWidget(self.send_button) self.layout().addSpacing(o * 0.5)
def paintEvent(self, event): """Paint event for smooth font display.""" painter = QtGui.QPainter() painter.begin(self) option = QtWidgets.QStyleOption() option.initFrom(self) hover = option.state & QtWidgets.QStyle.State_MouseOver pressed = option.state & QtWidgets.QStyle.State_Sunken focus = option.state & QtWidgets.QStyle.State_HasFocus color = common.TEXT if self.isEnabled() else common.SECONDARY_TEXT color = common.TEXT_SELECTED if hover else color bg_color = common.SECONDARY_TEXT if self.isEnabled( ) else common.SECONDARY_BACKGROUND.darker(110) bg_color = common.TEXT if hover else bg_color bg_color = common.SEPARATOR if pressed else bg_color if focus: pen = QtGui.QPen(common.FAVOURITE) else: pen = QtGui.QPen(bg_color) pen.setWidthF(common.ROW_SEPARATOR()) painter.setRenderHint(QtGui.QPainter.Antialiasing) painter.setBrush(bg_color) painter.setPen(pen) o = common.ROW_SEPARATOR() rect = self.rect().marginsRemoved(QtCore.QMargins(o, o, o, o)) o = common.INDICATOR_WIDTH() * 0.7 painter.drawRoundedRect(rect, o, o) rect = QtCore.QRect(self.rect()) center = rect.center() rect.setWidth(rect.width() - (common.INDICATOR_WIDTH() * 2)) rect.moveCenter(center) common.draw_aliased_text( painter, common.font_db.primary_font(common.MEDIUM_FONT_SIZE())[0], rect, self.text(), QtCore.Qt.AlignCenter, color ) painter.end()
def _create_UI(self): QtWidgets.QHBoxLayout(self) self.layout().setContentsMargins(0, 0, 0, 0) self.layout().setSpacing(0) self.layout().setAlignment(QtCore.Qt.AlignCenter) menu_bar = QtWidgets.QMenuBar(parent=self) self.layout().addWidget(menu_bar) menu_bar.hide() menu = menu_bar.addMenu(common.PRODUCT) action = menu.addAction(u'Quit') action.triggered.connect(self.parent().shutdown) self.layout().addStretch() self.layout().addWidget(MinimizeButton(parent=self)) self.layout().addSpacing(common.INDICATOR_WIDTH() * 2) self.layout().addWidget(CloseButton(parent=self)) self.layout().addSpacing(common.INDICATOR_WIDTH() * 2)
def paintEvent(self, event): painter = QtGui.QPainter() painter.begin(self) painter.setRenderHint(QtGui.QPainter.Antialiasing) pen = QtGui.QPen(common.SEPARATOR) pen.setWidthF(common.ROW_SEPARATOR()) painter.setPen(pen) o = common.MARGIN() rect = self.rect().marginsRemoved(QtCore.QMargins(o, o, o, o)) rect.setHeight(common.ROW_HEIGHT() + (common.MARGIN() * 2)) painter.setBrush(common.SECONDARY_BACKGROUND) painter.setOpacity(0.9) painter.drawRoundedRect( rect, common.INDICATOR_WIDTH(), common.INDICATOR_WIDTH()) painter.end()
def paintEvent(self, event): """Drawing a rounded background help to identify that the widget is in standalone mode.""" painter = QtGui.QPainter() painter.begin(self) painter.setRenderHint(QtGui.QPainter.Antialiasing) painter.setRenderHint(QtGui.QPainter.SmoothPixmapTransform) rect = QtCore.QRect(self.rect()) pen = QtGui.QPen(QtGui.QColor(35, 35, 35, 255)) pen.setWidth(1.0) painter.setPen(pen) painter.setBrush(common.SEPARATOR.darker(110)) if self._frameless is True: o = common.INDICATOR_WIDTH() rect = rect.marginsRemoved(QtCore.QMargins(o, o, o, o)) painter.drawRoundedRect(rect, o * 3, o * 3) else: painter.drawRect(rect) if not self._initialized: font, metrics = common.font_db.primary_font( common.MEDIUM_FONT_SIZE()) rect = QtCore.QRect(self.rect()) align = QtCore.Qt.AlignCenter color = QtGui.QColor(255, 255, 255, 80) pixmaprect = QtCore.QRect(rect) center = pixmaprect.center() s = common.ASSET_ROW_HEIGHT() * 1.5 o = common.MARGIN() pixmaprect.setWidth(s) pixmaprect.setHeight(s) pixmaprect.moveCenter(center) painter.setBrush(QtGui.QColor(0, 0, 0, 20)) pen = QtGui.QPen(QtGui.QColor(0, 0, 0, 20)) painter.setPen(pen) painter.drawRoundedRect( pixmaprect.marginsAdded( QtCore.QMargins(o * 3, o * 3, o * 3, o * 3)), o, o) pixmap = images.ImageCache.get_rsc_pixmap(u'icon_bw', None, s) painter.setOpacity(0.5) painter.drawPixmap(pixmaprect, pixmap, pixmap.rect()) painter.setOpacity(1.0) rect.setTop(pixmaprect.bottom() + (o * 0.5)) rect.setHeight(metrics.height()) common.draw_aliased_text(painter, font, rect, self.init_progress, align, color) painter.end()
def _create_UI(self): QtWidgets.QHBoxLayout(self) self.layout().setContentsMargins(0, 0, 0, 0) self.layout().setSpacing(0) self.layout().setAlignment(QtCore.Qt.AlignCenter) height = common.MARGIN() + (common.INDICATOR_WIDTH() * 3) self.setFixedHeight(height) # Control view/model/button self.bookmarks_button = BookmarksTabButton(parent=self) self.assets_button = AssetsTabButton(parent=self) self.files_button = FilesTabButton(parent=self) self.favourites_button = FavouritesTabButton(parent=self) self.task_folder_view = TaskFolderWidget( parent=self.parent().fileswidget, altparent=self) self.task_folder_view.setHidden(True) self.generate_thumbnails_button = GenerateThumbnailsButton(parent=self) self.filter_button = FilterButton(parent=self) self.collapse_button = CollapseSequenceButton(parent=self) self.archived_button = ToggleArchivedButton(parent=self) self.favourite_button = ToggleFavouriteButton(parent=self) self.slack_button = SlackButton(parent=self) self.simple_mode_button = SimpleModeButton(parent=self) self.layout().addWidget(self.bookmarks_button, 1) self.layout().addWidget(self.assets_button, 1) self.layout().addWidget(self.files_button, 1) self.layout().addWidget(self.favourites_button, 1) self.layout().addStretch() self.layout().addWidget(self.simple_mode_button) self.layout().addSpacing(common.INDICATOR_WIDTH()) self.layout().addWidget(self.generate_thumbnails_button) self.layout().addSpacing(common.INDICATOR_WIDTH()) self.layout().addWidget(self.filter_button) self.layout().addSpacing(common.INDICATOR_WIDTH()) self.layout().addWidget(self.collapse_button) self.layout().addSpacing(common.INDICATOR_WIDTH()) self.layout().addWidget(self.archived_button) self.layout().addSpacing(common.INDICATOR_WIDTH()) self.layout().addWidget(self.favourite_button) self.layout().addSpacing(common.INDICATOR_WIDTH()) self.layout().addWidget(self.slack_button) # self.layout().addSpacing(common.INDICATOR_WIDTH() * 2) self.drop_overlay = SlackDropOverlayWidget(parent=self) self.drop_overlay.setHidden(True)
def __init__(self, parent=None): super(HeaderWidget, self).__init__(parent=parent) self.label = None self.closebutton = None self.move_in_progress = False self.move_start_event_pos = None self.move_start_widget_pos = None self.setFocusPolicy(QtCore.Qt.NoFocus) self.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu) self.setFixedHeight(common.MARGIN() + (common.INDICATOR_WIDTH() * 2)) self._create_UI()
def paintEvent(self, event): painter = QtGui.QPainter() painter.begin(self) o = common.MARGIN() o = 0 rect = self.rect().marginsRemoved(QtCore.QMargins(o, o, o, o)) painter.setBrush(common.SEPARATOR) painter.setPen(QtCore.Qt.NoPen) painter.setOpacity(0.5) painter.drawRoundedRect(rect, common.INDICATOR_WIDTH(), common.INDICATOR_WIDTH()) painter.setOpacity(1.0) painter.setBrush(QtCore.Qt.NoBrush) painter.setPen(common.TEXT) painter.setFont( common.font_db.primary_font(common.MEDIUM_FONT_SIZE())[0]) painter.drawText(rect, QtCore.Qt.AlignCenter, self._text) painter.end()
def __init__(self, pixmap, text, parent=None): super(DragPixmap, self).__init__(parent=parent) self._pixmap = pixmap self._text = text font, metrics = common.font_db.primary_font(common.MEDIUM_FONT_SIZE()) self._text_width = metrics.width(text) width = self._text_width + common.MARGIN() width = common.WIDTH() + common.MARGIN() if width > common.WIDTH( ) else width self.setFixedHeight(pixmap.height()) self.setFixedWidth(pixmap.width() + common.INDICATOR_WIDTH() + width + common.INDICATOR_WIDTH()) self.setAttribute(QtCore.Qt.WA_NoSystemBackground) self.setAttribute(QtCore.Qt.WA_TranslucentBackground) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.Window) self.setAttribute(QtCore.Qt.WA_TransparentForMouseEvents) self.adjustSize()
def paintEvent(self, event): painter = QtGui.QPainter() painter.begin(self) painter.setPen(QtCore.Qt.NoPen) painter.setBrush(common.SECONDARY_BACKGROUND) painter.setOpacity(0.6) painter.drawRoundedRect(self.rect(), 4, 4) painter.setOpacity(1.0) pixmap_rect = QtCore.QRect(0, 0, self.height(), self.height()) painter.drawPixmap(pixmap_rect, self._pixmap, self._pixmap.rect()) width = self._text_width + common.INDICATOR_WIDTH() width = 640 if width > 640 else width rect = QtCore.QRect( self._pixmap.rect().width() + common.INDICATOR_WIDTH(), 0, width, self.height()) common.draw_aliased_text( painter, common.font_db.primary_font(common.MEDIUM_FONT_SIZE())[0], rect, self._text, QtCore.Qt.AlignCenter, common.TEXT_SELECTED) painter.end()
def __init__(self, parent=None): super(TodoEditors, self).__init__(parent=parent) QtWidgets.QVBoxLayout(self) self.layout().setAlignment(QtCore.Qt.AlignTop | QtCore.Qt.AlignHCenter) o = common.MARGIN() * 0.5 self.layout().setContentsMargins(o, o, o, o) self.layout().setSpacing(common.INDICATOR_WIDTH() * 2) self.setAcceptDrops(True) self.separator = Separator(parent=self) self.drop_target_index = -1 self.items = [] self.setFocusPolicy(QtCore.Qt.NoFocus)
def paintEvent(self, event): """Paints the indicator area.""" painter = QtGui.QPainter() painter.begin(self) pen = QtGui.QPen(common.FAVOURITE) pen.setWidth(common.INDICATOR_WIDTH()) painter.setPen(pen) painter.setBrush(common.FAVOURITE) painter.setOpacity(0.35) painter.drawRect(self.rect()) painter.setOpacity(1.0) common.draw_aliased_text( painter, common.font_db.primary_font(common.MEDIUM_FONT_SIZE())[0], self.rect(), u'Drop to add bookmark', QtCore.Qt.AlignCenter, common.FAVOURITE) painter.end()
def add_row(label, parent=None, padding=common.MARGIN(), height=common.ROW_HEIGHT(), cls=None, vertical=False): """Utility method for creating a row widget. Returns: QWidget: row widget. """ if cls: w = cls(parent=parent) else: w = QtWidgets.QWidget(parent=parent) if vertical: QtWidgets.QVBoxLayout(w) else: QtWidgets.QHBoxLayout(w) w.layout().setContentsMargins(0, 0, 0, 0) w.layout().setSpacing(common.INDICATOR_WIDTH()) w.layout().setAlignment(QtCore.Qt.AlignCenter) w.setSizePolicy( QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding, ) if height: w.setFixedHeight(height) w.setAttribute(QtCore.Qt.WA_NoBackground) w.setAttribute(QtCore.Qt.WA_TranslucentBackground) if label: l = PaintedLabel(label, size=common.SMALL_FONT_SIZE(), color=common.SECONDARY_TEXT, parent=parent) l.setFixedWidth(common.MARGIN() * 6.6667) l.setDisabled(True) if padding: w.layout().addSpacing(padding) w.layout().addWidget(l, 0) if parent: parent.layout().addWidget(w, 1) return w
def contextMenuEvent(self, event): """Custom context menu event.""" index = self.indexAt(event.pos()) if not index.isValid(): return width = self.viewport().geometry().width() widget = self.ContextMenu(index, parent=self) rect = self.visualRect(index) offset = self.visualRect(index).height() - common.INDICATOR_WIDTH() widget.move( self.viewport().mapToGlobal(rect.bottomLeft()).x() + offset, self.viewport().mapToGlobal(rect.bottomLeft()).y() + 1, ) widget.setFixedWidth(width - offset) common.move_widget_to_available_geo(widget) self._context_menu_active = True widget.exec_() self._context_menu_active = False
def get_group(parent=None): """Utility method for creating a group widget. Returns: QGroupBox: group widget. """ grp = QtWidgets.QGroupBox(parent=parent) grp.setMinimumWidth(common.WIDTH() * 0.3) grp.setMaximumWidth(common.WIDTH() * 2.0) QtWidgets.QVBoxLayout(grp) grp.setSizePolicy( QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Maximum, ) o = common.INDICATOR_WIDTH() grp.layout().setContentsMargins(o, o, o, o) grp.layout().setSpacing(o) parent.layout().addWidget(grp, 1) return grp
def _create_UI(self): def get_row(vertical=False, parent=None): row = QtWidgets.QWidget(parent=parent) if vertical: QtWidgets.QVBoxLayout(row) else: QtWidgets.QHBoxLayout(row) row.layout().setContentsMargins(0, 0, 0, 0) row.layout().setSpacing(0) row.setSizePolicy( QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding, ) parent.layout().addWidget(row) return row QtWidgets.QHBoxLayout(self) o = 0 self.layout().setContentsMargins(o, o, o, o) self.layout().setSpacing(o) main_row = get_row(parent=self) main_row.layout().setContentsMargins(0, 0, 0, 0) main_row.layout().setSpacing(0) columns = get_row(vertical=True, parent=main_row) columns.layout().setContentsMargins(0, 0, 0, 0) columns.layout().setSpacing(0) short_text_row = get_row(parent=columns) columns.layout().addWidget(short_text_row, 1) long_text_row = get_row(parent=columns) pixmap = images.ImageCache.get_rsc_pixmap( self.icon, self.secondary_color.lighter(150), common.ROW_HEIGHT()) label = QtWidgets.QLabel(parent=self) label.setPixmap(pixmap) label.setSizePolicy( QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding, ) label.setStyleSheet( u'padding: {}px; background-color: rgba({});'.format( common.MEDIUM_FONT_SIZE(), common.rgb(self.primary_color) ) ) main_row.layout().insertWidget(0, label) short_text_row.layout().addWidget(self.short_text_label) self.short_text_label.setStyleSheet( u'padding:{m}px {s}px {m}px {s}px; background-color: rgba({c}); font-size: {s}px;'.format( m=common.MARGIN(), c=common.rgb(self.secondary_color.lighter(125)), s=common.MEDIUM_FONT_SIZE() )) self.short_text_label.setAlignment(QtCore.Qt.AlignLeft) long_text_row.layout().addWidget(self.long_text_label) self.long_text_label.setStyleSheet( u'padding:{m}px;background-color: rgba({c}); font-size:{s}px;'.format( m=common.MARGIN(), c=common.rgb(self.secondary_color), s=common.SMALL_FONT_SIZE() )) self.long_text_label.setAlignment(QtCore.Qt.AlignLeft) buttons_row = get_row(parent=columns) buttons_row.setStyleSheet( u'background-color: rgba({});'.format(common.rgb(self.secondary_color))) self.ok_button = QtWidgets.QPushButton(u'Ok', parent=self) buttons_row.layout().addWidget(self.ok_button) self.ok_button.setStyleSheet( """ QPushButton {{ font-size: {px}px; color: rgba(255,255,255,150); border-radius: {i}px; border: {s}px solid {c}; margin: {i}px; padding: {i}px; background-color: rgba({p}); }} QPushButton:hover {{ color: white; background-color: rgba({pl}); }} QPushButton:pressed {{ color: rgba(255,255,255,150); background-color: rgba({pd}); }} """.format( px=common.SMALL_FONT_SIZE(), i=common.INDICATOR_WIDTH(), s=common.ROW_SEPARATOR(), c=common.rgb(self.secondary_color.lighter(150)), p=common.rgb(self.primary_color), pl=common.rgb(self.primary_color.lighter(120)), pd=common.rgb(self.primary_color.darker(120)) ) )
def paint_name(self, *args): """Paints the name and the number of files available for the given data-key.""" rectangles, painter, option, index, selected, focused, active, archived, favourite, hover, font, metrics, cursor_position = args if not index.data(QtCore.Qt.DisplayRole): return if index.data(common.TodoCountRole): color = common.TEXT_SELECTED if hover else common.TEXT else: color = common.TEXT if hover else common.BACKGROUND_SELECTED color = common.TEXT_SELECTED if selected else color font = common.font_db.primary_font(common.MEDIUM_FONT_SIZE())[0] o = common.MARGIN() rect = QtCore.QRect(option.rect) if selected: pixmap = images.ImageCache.get_rsc_pixmap(u'check', common.ADD, o) _rect = QtCore.QRect(option.rect) _rect.setSize(pixmap.size()) _rect.moveCenter(option.rect.center()) _rect.moveLeft(option.rect.left() + ((o + common.INDICATOR_WIDTH()) * 0.5)) painter.drawPixmap(_rect, pixmap, pixmap.rect()) rect = rect.marginsRemoved(QtCore.QMargins(o * 2, 0, o, 0)) else: rect = rect.marginsRemoved(QtCore.QMargins(o, 0, o, 0)) text = index.data(QtCore.Qt.DisplayRole).upper() width = 0 width = common.draw_aliased_text( painter, font, rect, text, QtCore.Qt.AlignVCenter | QtCore.Qt.AlignLeft, color) rect.setLeft(rect.left() + width) items = [] # Adding an indicator for the number of items in the folder if index.data(common.TodoCountRole): if index.data(common.TodoCountRole) >= 999: text = u'999+ items' else: text = u'{} items'.format(index.data(common.TodoCountRole)) color = common.TEXT_SELECTED if selected else common.FAVOURITE color = common.TEXT_SELECTED if hover else color items.append((text, color)) else: color = common.TEXT if selected else common.BACKGROUND color = common.TEXT if hover else color items.append((u'n/a', color)) if index.data(QtCore.Qt.ToolTipRole): color = common.TEXT_SELECTED if selected else common.TEXT color = common.TEXT_SELECTED if hover else color items.append((index.data(QtCore.Qt.ToolTipRole), color)) for idx, val in enumerate(items): text, color = val if idx == 0: align = QtCore.Qt.AlignVCenter | QtCore.Qt.AlignLeft else: align = QtCore.Qt.AlignVCenter | QtCore.Qt.AlignRight width = common.draw_aliased_text( painter, common.font_db.secondary_font(common.SMALL_FONT_SIZE())[0], rect, u' | ', align, common.SEPARATOR) rect.setLeft(rect.left() + width) width = common.draw_aliased_text( painter, common.font_db.primary_font(common.MEDIUM_FONT_SIZE())[0], rect, text, align, color) rect.setLeft(rect.left() + width)
def get_width(self): o = common.INDICATOR_WIDTH() * 3 font, metrics = common.font_db.primary_font(common.MEDIUM_FONT_SIZE()) return metrics.width(self.text()) + (o * 2)
def _create_UI(self): import bookmarks label = common_ui.PaintedLabel(u'General Preferences', size=common.LARGE_FONT_SIZE(), parent=self) self.layout().addWidget(label) grp = common_ui.get_group(parent=self) row = common_ui.add_row(u'Frameless window', parent=grp) self.frameless_window = QtWidgets.QCheckBox(u'Use frameless window', parent=self) row.layout().addStretch(1) row.layout().addWidget(self.frameless_window) label = common_ui.PaintedLabel(u'(Restart required)', size=common.SMALL_FONT_SIZE(), color=common.TEXT_DISABLED) row.layout().addWidget(label, 0) if common.STANDALONE: row = common_ui.add_row(u'Scale interface', parent=grp) self.ui_scale = QtWidgets.QComboBox(parent=self) self.ui_scale.setFixedHeight(common.ROW_HEIGHT() * 0.66) for s in (u'100%', u'125%', u'150%', u'175%', u'200%'): self.ui_scale.addItem(s) idx = self.ui_scale.count() - 1 data = int(s.strip(u'%')) * 0.01 self.ui_scale.setItemData(idx, data, role=QtCore.Qt.UserRole) data = QtCore.QSize(1, common.ROW_HEIGHT() * 0.66) self.ui_scale.setItemData(idx, data, role=QtCore.Qt.SizeHintRole) row.layout().addWidget(self.ui_scale, 1) label = common_ui.PaintedLabel(u'(Restart required)', size=common.SMALL_FONT_SIZE(), color=common.TEXT_DISABLED) row.layout().addWidget(label, 0) ############################## row = common_ui.add_row(u'Update', parent=grp) self.check_updates = common_ui.PaintedButton(u'Check for Updates', parent=row) self.show_help = common_ui.PaintedButton(u'Help', parent=row) row.layout().addWidget(self.check_updates) row.layout().addWidget(self.show_help) row.layout().addStretch(1.0) ####################################################### row = common_ui.add_row(None, parent=self) label = common_ui.PaintedLabel(u'Shotgun RV', size=common.LARGE_FONT_SIZE(), parent=row) row.layout().addWidget(label) row.layout().addStretch(1) grp = common_ui.get_group(parent=self) row = common_ui.add_row(u'Path to RV', parent=grp) self.rv_path = common_ui.add_line_edit(u'eg. c:/rv/bin/rv.exe', parent=row) row.layout().addWidget(self.rv_path, 1) button = common_ui.PaintedButton(u'Pick') button.clicked.connect(self.pick_rv) row.layout().addWidget(button) button = common_ui.PaintedButton(u'Reveal') button.clicked.connect(lambda: common.reveal(self.rv_path.text())) row.layout().addWidget(button) text = \ u'You can use {} to push footage to Shotgun RV \ (<span style="color:rgba({});">CTRL+P)</span>. Select the RV executable for this to work.' .format( common.PRODUCT, common.rgb(common.ADD)) common_ui.add_description(text, label=u'Hint', parent=grp) ####################################################### label = common_ui.PaintedLabel(u'Shortcuts', size=common.LARGE_FONT_SIZE(), parent=self) self.layout().addWidget(label) grp = common_ui.get_group(parent=self) label = QtWidgets.QLabel(parent=self) s = u'<table width="100%">' def r(): return unicode('<tr>\ <td align="center" style="background-color:rgba(0,0,0,80);padding:{pad}px;">\ <span style="color:rgba({ADD});">{shortcut}</span>\ </td>\ <td align="left" style="background-color:rgba(0,0,0,30);padding:{pad}px;">\ <span style="color:rgba({TEXT});">{description}</span>\ </td>\ </tr>') for shortcut, description in ( (u'Ctrl+N', u'Open new {} instance'.format(common.PRODUCT)), (u'Enter', u'Activate item'), (u'Space', u'Preview thumbnail'), (u'Arrow Up/Down', u'Navigate list'), (u'Ctrl+R', u'Reload'), (u'Ctrl+F', u'Edit filter'), (u'Ctrl+O', u'Reveal in file manager'), (u'Ctrl+C', u'Copy path'), (u'Ctrl+Shift+C', u'Copy path (alt)'), (u'Ctrl+S', u'Save/remove favourite'), (u'Ctrl+A', u'Archive/enable'), (u'Ctrl+T', u'Show Notes & Todos'), (u'Ctrl+H', u'Hide buttons'), (u'Ctrl+M', u'Toggle thumbnail loading'), (u'Ctrl+Shift+A', u'Show/Hide archived items'), (u'Ctrl+Shift+F', u'Show favourites only/Show all'), (u'Tab', u'Edit item description'), (u'Shift+Tab', u'Edit item description'), (u'Alt+Left', u'Show previous tab'), (u'Alt+Right', u'Show next tab'), (u'Ctrl+1', u'Show bookmarks'), (u'Ctrl+2', u'Show assets'), (u'Ctrl+3', u'Show files'), (u'Ctrl+4', u'Show favourites'), (u'Ctrl+Plus', u'Increase row height'), (u'Ctrl+Minus', u'Decrease row height'), (u'Ctrl+0', u'Reset row height'), ): s += r().format( shortcut=shortcut, description=description, pad=int(common.INDICATOR_WIDTH() * 1.5), ADD=common.rgb(common.ADD), TEXT=common.rgb(common.SECONDARY_TEXT), ) s += u'</table>' label.setText(s) label.setWordWrap(True) grp.layout().addWidget(label) label = common_ui.PaintedLabel(u'About {}'.format(common.PRODUCT), size=common.LARGE_FONT_SIZE(), parent=grp) self.layout().addWidget(label) grp = common_ui.get_group(parent=self) o = common.MARGIN() grp.layout().setContentsMargins(o, o, o, o) # row = common_ui.add_row(u'Version', parent=grp, height=None) s = u'\n'.join(bookmarks.get_info()) common_ui.add_description(s, label=None, parent=grp) self.layout().addStretch(1)
def _create_UI(self): o = common.INDICATOR_WIDTH() self.setMinimumWidth(common.WIDTH() * 0.5) height = common.ROW_HEIGHT() * 0.8 widget = QtWidgets.QWidget(parent=self) QtWidgets.QVBoxLayout(widget) widget.layout().setAlignment(QtCore.Qt.AlignCenter) widget.layout().setContentsMargins(0, 0, 0, 0) widget.layout().setSpacing(o * 2) self.setWidget(widget) # Main group grpA = common_ui.get_group(parent=widget) # GROUP grp = common_ui.get_group(parent=grpA) numvalidator = QtGui.QRegExpValidator(parent=self) numvalidator.setRegExp(QtCore.QRegExp(ur'[0-9]+[\.]?[0-9]*')) textvalidator = QtGui.QRegExpValidator(parent=self) textvalidator.setRegExp(QtCore.QRegExp(ur'[a-zA-Z0-9]+')) # ROW1 self.rectangles_widget = RectanglesWidget(parent=self) grp.layout().addWidget(self.rectangles_widget, 1) # ROW row = common_ui.add_row(u'Resolution', parent=grp, height=height) self.width_editor = common_ui.LineEdit(parent=self) self.width_editor.setPlaceholderText(u'Width...') self.width_editor.setValidator(numvalidator) row.layout().addWidget(self.width_editor, 0) self.height_editor = common_ui.LineEdit(parent=self) self.height_editor.setPlaceholderText(u'Height...') self.height_editor.setValidator(numvalidator) row.layout().addWidget(self.height_editor, 0) # ROW row = common_ui.add_row(u'Frame rate', parent=grp, height=height) self.framerate_editor = common_ui.LineEdit(parent=self) self.framerate_editor.setPlaceholderText(u'Frame rate...') self.framerate_editor.setValidator(numvalidator) row.layout().addWidget(self.framerate_editor, 0) # ******************************************** grp = common_ui.get_group(parent=grpA) row = common_ui.add_row(u'Bookmark Prefix', parent=grp, height=height) self.prefix_editor = common_ui.LineEdit(parent=self) self.prefix_editor.setPlaceholderText(u'Prefix (eg. \'MYJOB\')...') self.prefix_editor.setValidator(textvalidator) self.suggest_prefix_button = common_ui.PaintedButton(u'Suggest') self.suggest_prefix_button.setFixedHeight(height * 0.7) row.layout().addWidget(self.prefix_editor, 0) row.layout().addWidget(self.suggest_prefix_button, 0) # ******************************************** grp = common_ui.get_group(parent=grpA) row = common_ui.add_row(u'Start Frame', parent=grp, height=height) self.startframe_editor = common_ui.LineEdit(parent=self) self.startframe_editor.setPlaceholderText(u'Start Frame...') self.startframe_editor.setValidator(numvalidator) row.layout().addWidget(self.startframe_editor, 0) row = common_ui.add_row(u'Duration', parent=grp, height=height) self.duration_editor = common_ui.LineEdit(parent=self) self.duration_editor.setPlaceholderText(u'Duration...') self.duration_editor.setValidator(numvalidator) row.layout().addWidget(self.duration_editor, 0) # ******************************************** grp = common_ui.get_group(parent=widget) row = common_ui.add_row(u'Asset Identifier', parent=grp) self.identifier_editor = common_ui.LineEdit(parent=row) self.identifier_editor.setPlaceholderText( u'Asset identifier, eg. \'workspace.mel\'') row.layout().addWidget(self.identifier_editor, 0) text = u'Only folders containing this file will be treated as assets.<br>\ Using the default Maya Workspace the identifier normally is \ <span style="text-decoration: underline;">workspace.mel</span>, but \ any other file can be used as long it is present in the root of \ the asset.<br>If not set, all folders inside the Bookmark \ will be read as assets.'.format(common.PRODUCT) common_ui.add_description(text, label='Hint', parent=grp) # ******************************************** grpA = common_ui.get_group(parent=widget) # Slack API token label = common_ui.PaintedLabel(u'Slack Settings', size=common.MEDIUM_FONT_SIZE() * 1.2) grpA.layout().addWidget(label, 0) grpA.layout().addSpacing(o * 2) grp = common_ui.get_group(parent=grpA) row = common_ui.add_row(u'Slack API Token', parent=grp, height=height) self.slacktoken_editor = common_ui.LineEdit(parent=self) self.slacktoken_editor.setPlaceholderText( u'xoxb-01234567890-0123456...') button = common_ui.PaintedButton(u'Test Token') button.setFixedHeight(height * 0.7) button.clicked.connect(self.test_slack_token) row.layout().addWidget(self.slacktoken_editor, 0) row.layout().addWidget(button) text = u'{p} can send messages to team-members using Slack.<br><br>\ To get started, create a new app and install it for your workspace. \ Paste the generated <span style="{h}">OAuth</span> token, usually starting with "xoxb-0123..." above.<br> \ See <a href="http://api.slack.com/apps">http://api.slack.com/apps</a> for more information.<br><br> \ The Slack app needs to have the <span style="{h}">users:read</span> and \ <span style="{h}">chat:write</span> scopes enabled. To send messages to channels \ the bot is not part of, add <span style="{h}">chat:write.public</span>. \ Scopes <span style="{h}">channels:read</span> and <span style="{h}">groups:read</span> are needed to list available \ Slack Channels.<br><br>'.format(p=common.PRODUCT, h='color: rgba({});'.format( common.rgb(common.ADD))) common_ui.add_description(text, label=u'Slack API Hint', parent=grp) # ******************************************** self.widget().layout().addStretch(1)