add scale image factor to default settings
This commit is contained in:
@@ -19,6 +19,8 @@ DEFAULT_SETTINGS = {
|
||||
"tray/icon/unread": False,
|
||||
"watchdog/interval/s": 60,
|
||||
"MessageWidget/image/size": 33,
|
||||
"MessageWidget/content_image/W_percentage": 1.0,
|
||||
"MessageWidget/content_image/H_percentage": 0.5,
|
||||
"MainWindow/label/size": 25,
|
||||
"MainWindow/button/size": 33,
|
||||
"MainWindow/application/icon/size": 40,
|
||||
|
||||
@@ -108,11 +108,17 @@ class MessageWidget(QtWidgets.QWidget, Ui_Form):
|
||||
pixmap = QtGui.QPixmap(filename)
|
||||
|
||||
# Make sure the image fits within the listView
|
||||
W = self.parent.width() - self.label_image.width() - 50
|
||||
if pixmap.width() > W:
|
||||
W = settings.value("MessageWidget/content_image/W_percentage", type=float) * (
|
||||
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(
|
||||
W,
|
||||
int(0.5 * self.parent.height()),
|
||||
QtCore.QSize(int(W), int(H)),
|
||||
aspectRatioMode=QtCore.Qt.AspectRatioMode.KeepAspectRatio,
|
||||
transformMode=QtCore.Qt.TransformationMode.SmoothTransformation,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user