From b761aa39565aef167aaf74e35bb8d35afd696740 Mon Sep 17 00:00:00 2001 From: billypom on debian Date: Wed, 26 Mar 2025 15:08:32 -0400 Subject: [PATCH] QGraphicsView remove ui properties, in favor of definitions in custom class --- components/AlbumArtGraphicsView.py | 8 ++++++ ui.py | 18 ++---------- ui.ui | 44 ++---------------------------- 3 files changed, 12 insertions(+), 58 deletions(-) diff --git a/components/AlbumArtGraphicsView.py b/components/AlbumArtGraphicsView.py index 20abe4c..280ef82 100644 --- a/components/AlbumArtGraphicsView.py +++ b/components/AlbumArtGraphicsView.py @@ -2,6 +2,7 @@ import os import tempfile from logging import debug from PyQt5.QtWidgets import ( + QAbstractScrollArea, QGraphicsPixmapItem, QGraphicsScene, QGraphicsView, @@ -30,6 +31,13 @@ class AlbumArtGraphicsView(QGraphicsView): super().__init__(parent) self.setAcceptDrops(True) self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) + self.setMinimumSize(200, 200) + self.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff) + self.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff) + self.setSizeAdjustPolicy(QAbstractScrollArea.SizeAdjustPolicy.AdjustIgnored) + self.setInteractive(False) + self.setResizeAnchor(QGraphicsView.ViewportAnchor.AnchorViewCenter) + self.setViewportUpdateMode(QGraphicsView.ViewportUpdateMode.FullViewportUpdate) self.album_art_scene: QGraphicsScene = QGraphicsScene() self.customContextMenuRequested.connect(self.showContextMenu) diff --git a/ui.py b/ui.py index 490675b..d3955ae 100644 --- a/ui.py +++ b/ui.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'ui.ui' # -# Created by: PyQt5 UI code generator 5.15.11 +# Created by: PyQt5 UI code generator 5.15.10 # # WARNING: Any manual changes made to this file will be lost when pyuic5 is # run again. Do not edit this file unless you know what you are doing. @@ -30,20 +30,6 @@ class Ui_MainWindow(object): self.vlayoutAlbumArt.setSizeConstraint(QtWidgets.QLayout.SetFixedSize) self.vlayoutAlbumArt.setObjectName("vlayoutAlbumArt") self.albumGraphicsView = AlbumArtGraphicsView(self.centralwidget) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.albumGraphicsView.sizePolicy().hasHeightForWidth()) - self.albumGraphicsView.setSizePolicy(sizePolicy) - self.albumGraphicsView.setMinimumSize(QtCore.QSize(200, 200)) - self.albumGraphicsView.setMaximumSize(QtCore.QSize(16777215, 16777215)) - self.albumGraphicsView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) - self.albumGraphicsView.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) - self.albumGraphicsView.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) - self.albumGraphicsView.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustIgnored) - self.albumGraphicsView.setInteractive(False) - self.albumGraphicsView.setResizeAnchor(QtWidgets.QGraphicsView.AnchorViewCenter) - self.albumGraphicsView.setViewportUpdateMode(QtWidgets.QGraphicsView.FullViewportUpdate) self.albumGraphicsView.setObjectName("albumGraphicsView") self.vlayoutAlbumArt.addWidget(self.albumGraphicsView) self.hLayoutHead.addLayout(self.vlayoutAlbumArt) @@ -208,7 +194,7 @@ class Ui_MainWindow(object): self.verticalLayout_3.setStretch(0, 20) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) - self.menubar.setGeometry(QtCore.QRect(0, 0, 1152, 21)) + self.menubar.setGeometry(QtCore.QRect(0, 0, 1152, 41)) self.menubar.setObjectName("menubar") self.menuFile = QtWidgets.QMenu(self.menubar) self.menuFile.setObjectName("menuFile") diff --git a/ui.ui b/ui.ui index 400cd41..ed5aaf2 100644 --- a/ui.ui +++ b/ui.ui @@ -34,47 +34,7 @@ QLayout::SetFixedSize - - - - 0 - 0 - - - - - 200 - 200 - - - - - 16777215 - 16777215 - - - - Qt::CustomContextMenu - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - QAbstractScrollArea::AdjustIgnored - - - false - - - QGraphicsView::AnchorViewCenter - - - QGraphicsView::FullViewportUpdate - - + @@ -373,7 +333,7 @@ 0 0 1152 - 21 + 41