31 from PyQt5.QtCore import QMimeData, QSize, Qt, QCoreApplication, QPoint, QFileInfo, QRect
33 from PyQt5.QtWidgets import QLabel, QApplication, QMessageBox, QAbstractItemView, QMenu, QSizePolicy, QWidget
36 from classes
import updates
37 from classes
import info
38 from classes.logger
import log
39 from classes.settings
import SettingStore
40 from classes.app
import get_app
41 from windows.models.effects_model
import EffectsModel
53 painter = QPainter(self)
54 painter.setRenderHint(QPainter.Antialiasing)
57 painter.fillRect(event.rect(), self.palette().
window())
62 pixSize = self.current_image.size()
63 pixSize.scale(event.rect().
size(), Qt.KeepAspectRatio)
66 scaledPix = self.current_image.scaled(pixSize, Qt.KeepAspectRatio, Qt.SmoothTransformation)
70 painter.drawImage(center, scaledPix)
82 aspectRatio = self.aspect_ratio.ToFloat() * self.pixel_ratio.ToFloat()
83 heightFromWidth = width / aspectRatio
84 widthFromHeight = height * aspectRatio
86 if heightFromWidth <= height:
87 return QRect(0, (height - heightFromWidth) / 2, width, heightFromWidth)
89 return QRect((width - widthFromHeight) / 2.0, 0, widthFromHeight, height)
104 renderer.present.connect(self.
present)
114 QWidget.__init__(self, *args)
117 self.aspect_ratio = openshot.Fraction()
118 self.pixel_ratio = openshot.Fraction()
119 self.aspect_ratio.num = 16
120 self.aspect_ratio.den = 9
121 self.pixel_ratio.num = 1
122 self.pixel_ratio.den = 1
126 p.setColor(QPalette.Window, Qt.black)
127 super().setPalette(p)
128 super().setAttribute(Qt.WA_OpaquePaintEvent)
129 super().setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
132 self.setMouseTracking(
True)
135 self.current_image =
None
def get_app()
Returns the current QApplication instance of OpenShot.