def paintEvent(self, event=None): painter = QStylePainter() painter.begin(self) painter.setOpacity(0.4) painter.setBrush(Qt.green) painter.drawRect(self.rect()) self.setGeometry(self.box[0], self.box[1], self.box[2]-self.box[0], self.box[3]-self.box[1])
def paintEvent(self, event: QPaintEvent) -> None: """ Render the custom widget """ painter = QStylePainter() painter.begin(self) x = 0 y = 0 width = self.width() rect = self.rect() # type: QRect palette = QPalette() backgroundColor = palette.base().color() if (self.display_type == DestinationDisplayType.usage_only and QSplitter().lineWidth()): pen = painter.pen() painter.setPen(backgroundColor) painter.drawLine(rect.topLeft(), rect.topRight()) painter.setPen(self.midPen) painter.drawLine(rect.bottomLeft(), rect.bottomRight()) painter.drawLine(rect.topLeft(), rect.bottomLeft()) if (self.container_vertical_scrollbar_visible is None or not self.container_vertical_scrollbar_visible): painter.drawLine(rect.topRight(), rect.bottomRight()) painter.setPen(pen) w = QSplitter().lineWidth() rect.adjust(w, w, -w, -w) painter.fillRect(rect, backgroundColor) if self.storage_space is None: painter.end() return highlight_menu = self.mouse_pos == DestinationDisplayMousePos.menu if self.display_type != DestinationDisplayType.usage_only: # Render the folder icon, folder name, and the menu icon self.deviceDisplay.paint_header( painter=painter, x=x, y=y, width=width, display_name=self.display_name, icon=self.icon, highlight_menu=highlight_menu, ) y = y + self.deviceDisplay.dc.device_name_height if self.display_type != DestinationDisplayType.folder_only: # Render the projected storage space if self.display_type == DestinationDisplayType.usage_only: y += self.deviceDisplay.dc.padding photos_size_to_download, videos_size_to_download = adjusted_download_size( photos_size_to_download=self.photos_size_to_download, videos_size_to_download=self.videos_size_to_download, os_stat_device=self.os_stat_device, downloading_to=self._downloading_to, ) details = make_body_details( bytes_total=self.storage_space.bytes_total, bytes_free=self.storage_space.bytes_free, files_to_display=self.files_to_display, marked=self.marked, photos_size_to_download=photos_size_to_download, videos_size_to_download=videos_size_to_download, ) self.deviceDisplay.paint_body(painter=painter, x=x, y=y, width=width, details=details) painter.end()
def paintEvent(self, event: QPaintEvent) -> None: """ Render the custom widget """ painter = QStylePainter() painter.begin(self) x = 0 y = 0 width = self.width() rect = self.rect() # type: QRect if self.display_type == DestinationDisplayType.usage_only and QSplitter( ).lineWidth(): # Draw a frame if that's what the style requires option = QStyleOptionFrame() option.initFrom(self) painter.drawPrimitive(QStyle.PE_Frame, option) w = QSplitter().lineWidth() rect.adjust(w, w, -w, -w) palette = QPalette() backgroundColor = palette.base().color() painter.fillRect(rect, backgroundColor) if self.storage_space is None: painter.end() return highlight_menu = self.mouse_pos == DestinationDisplayMousePos.menu if self.display_type != DestinationDisplayType.usage_only: # Render the folder icon, folder name, and the menu icon self.deviceDisplay.paint_header(painter=painter, x=x, y=y, width=width, display_name=self.display_name, icon=self.icon, highlight_menu=highlight_menu) y = y + self.deviceDisplay.device_name_height if self.display_type != DestinationDisplayType.folder_only: # Render the projected storage space if self.display_type == DestinationDisplayType.usage_only: y += self.deviceDisplay.padding photos_size_to_download, videos_size_to_download = adjusted_download_size( photos_size_to_download=self.photos_size_to_download, videos_size_to_download=self.videos_size_to_download, os_stat_device=self.os_stat_device, downloading_to=self._downloading_to) details = make_body_details( bytes_total=self.storage_space.bytes_total, bytes_free=self.storage_space.bytes_free, files_to_display=self.files_to_display, marked=self.marked, photos_size_to_download=photos_size_to_download, videos_size_to_download=videos_size_to_download) self.deviceDisplay.paint_body(painter=painter, x=x, y=y, width=width, details=details) painter.end()