99 QGridLayout , QLabel , QSizePolicy ,
1010)
1111
12+ from models .log import get_logger
1213from models .widgets import CropLabel
1314from models .workers import CoverUploadWorker
1415
@@ -22,6 +23,7 @@ def __init__(self, parent_window: "StreamConfigPanel", *args, **kwargs):
2223 self .setWindowTitle ("直播封面选框" )
2324 self .setFixedSize (660 , 560 )
2425 self .setAttribute (Qt .WidgetAttribute .WA_DeleteOnClose , True )
26+ self ._logger = get_logger (self .__class__ .__name__ )
2527
2628 self .label = CropLabel ((16 , 9 ), self )
2729
@@ -59,6 +61,7 @@ def load_image(self):
5961 self , "选择图片" , "" ,
6062 "Images (*.jfif;*.pjpeg;*.jpeg;*.pjp;*.jpg;*.png)"
6163 )
64+ self ._logger .info (f"load image: { path } " )
6265 if not path :
6366 return
6467 self .label .setPixmap (toqpixmap (path ))
@@ -74,12 +77,11 @@ def save_crop(self):
7477 return
7578 self .btn_upload .setText ("封面上传中..." )
7679 self .btn_upload .setEnabled (False )
77- pixmap = pixmap .copy (rect )
78- if pixmap .size ().width () > 704 or pixmap .size ().height () > 396 :
79- pixmap = pixmap .scaled (
80- 704 , 396 , Qt .AspectRatioMode .IgnoreAspectRatio ,
81- Qt .TransformationMode .SmoothTransformation
82- )
80+ pixmap = pixmap .copy (rect ).scaled (
81+ 704 , 396 , Qt .AspectRatioMode .IgnoreAspectRatio ,
82+ Qt .TransformationMode .SmoothTransformation
83+ )
84+ self ._logger .info (f"image scale to 704x396" )
8385 ba = QByteArray ()
8486 buf = QBuffer (ba )
8587 buf .open (QIODevice .OpenModeFlag .WriteOnly )
0 commit comments