add scale image factor to default settings

This commit is contained in:
dries.k
2022-12-04 16:17:47 +01:00
parent 304daee5ff
commit 86fbf003e1
2 changed files with 13 additions and 5 deletions

View File

@@ -19,6 +19,8 @@ DEFAULT_SETTINGS = {
"tray/icon/unread": False, "tray/icon/unread": False,
"watchdog/interval/s": 60, "watchdog/interval/s": 60,
"MessageWidget/image/size": 33, "MessageWidget/image/size": 33,
"MessageWidget/content_image/W_percentage": 1.0,
"MessageWidget/content_image/H_percentage": 0.5,
"MainWindow/label/size": 25, "MainWindow/label/size": 25,
"MainWindow/button/size": 33, "MainWindow/button/size": 33,
"MainWindow/application/icon/size": 40, "MainWindow/application/icon/size": 40,

View File

@@ -108,11 +108,17 @@ class MessageWidget(QtWidgets.QWidget, Ui_Form):
pixmap = QtGui.QPixmap(filename) pixmap = QtGui.QPixmap(filename)
# Make sure the image fits within the listView # Make sure the image fits within the listView
W = self.parent.width() - self.label_image.width() - 50 W = settings.value("MessageWidget/content_image/W_percentage", type=float) * (
if pixmap.width() > W: self.parent.width() - self.label_image.width()
)
H = (
settings.value("MessageWidget/content_image/H_percentage", type=float)
* self.parent.height()
)
if pixmap.width() > W or pixmap.height() > H:
pixmap = pixmap.scaled( pixmap = pixmap.scaled(
W, QtCore.QSize(int(W), int(H)),
int(0.5 * self.parent.height()),
aspectRatioMode=QtCore.Qt.AspectRatioMode.KeepAspectRatio, aspectRatioMode=QtCore.Qt.AspectRatioMode.KeepAspectRatio,
transformMode=QtCore.Qt.TransformationMode.SmoothTransformation, transformMode=QtCore.Qt.TransformationMode.SmoothTransformation,
) )