diff --git a/buttons.py b/buttons.py index c8b87b1..947b58a 100644 --- a/buttons.py +++ b/buttons.py @@ -322,7 +322,7 @@ class EmoteButton(QtGui.QLabel): if self.pixmap().isNull(): buttonImg = QtGui.QPixmap(self.path + '_off.png') painter.setOpacity(0.5) - if buttonImg and not buttonImg.isNull() and not buttonImg.width() == 40: + if not buttonImg.width() == 40: painter.drawPixmap(0, 0, buttonImg.scaled(40, 40, QtCore.Qt.IgnoreAspectRatio, QtCore.Qt.SmoothTransformation)) else: painter.drawPixmap(0, 0, buttonImg) diff --git a/gameview.py b/gameview.py index 3d96bf5..9bf480b 100644 --- a/gameview.py +++ b/gameview.py @@ -478,7 +478,7 @@ class AOCharMovie(QtGui.QLabel): return QtCore.Qt.KeepAspectRatio def getScaledImage(self, f_img): - if f_img and not f_img.isNull(): + if not f_img.isNull(): transform = self.getTransform(f_img.size().height() > self.size().height()) aspect = self.getAspect(f_img.size()) return f_img.scaled(self.size(), aspect, transform) @@ -489,8 +489,6 @@ class AOCharMovie(QtGui.QLabel): f_img = self.getScaledImage(self.mMovie.currentImage().mirrored(self.mFlipped, False)) fPixmap = QtGui.QPixmap.fromImage(f_img) - if not fPixmap or fPixmap.isNull(): - return self.setPixmap(fPixmap) if self.mMovie.frameCount() - 1 == nFrame and self.playOnce: @@ -516,8 +514,6 @@ class AOCharMovie(QtGui.QLabel): f_img = self.getScaledImage(self.pillowFrames[self.pillowFrame][0].mirrored(self.mFlipped, False)) fPixmap = QtGui.QPixmap.fromImage(f_img) - if not fPixmap or fPixmap.isNull(): - return self.setPixmap(fPixmap) @QtCore.pyqtSlot() @@ -649,13 +645,11 @@ class AOMovie(QtGui.QLabel): if not self.pillowFrames: return f_img = self.pillowFrames[self.pillowFrame][0] - if not f_img or f_img.isNull(): - return - - if (f_img.size().width() != self.size().width() or f_img.size().height() != self.size().height()): + if not f_img.isNull() and (f_img.size().width() != self.size().width() or f_img.size().height() != self.size().height()): f_img = f_img.scaled(self.size().width(), self.size().height(), QtCore.Qt.KeepAspectRatioByExpanding, QtCore.Qt.FastTransformation) - self.pillowLabel.setPixmap(QtGui.QPixmap.fromImage(f_img)) + fPixmap = QtGui.QPixmap.fromImage(f_img) + self.pillowLabel.setPixmap(fPixmap) class ZoomLines(QtGui.QLabel): def __init__(self, parent): @@ -703,7 +697,7 @@ class WTCEView(QtGui.QLabel): return img = self.movie.currentImage() pixmap = QtGui.QPixmap.fromImage(img) - if pixmap and not pixmap.isNull(): + if not pixmap.isNull(): self.setPixmap(pixmap.scaled(self.size().width(), self.size().height(), QtCore.Qt.KeepAspectRatioByExpanding, QtCore.Qt.FastTransformation)) if self.movie.currentFrameNumber() == self.movie.frameCount() - 1: self.finalframeTimer.start(self.movie.nextFrameDelay()) @@ -1857,8 +1851,7 @@ class GUI(QtGui.QWidget): else: self.chatboxWidth = self.chatbox.width() self.chatboxHeight = self.chatbox.height() - if chatboxPixmap and not chatboxPixmap.isNull(): - self.chatbox.setPixmap(chatboxPixmap.scaled(self.chatboxWidth, self.chatboxHeight, QtCore.Qt.KeepAspectRatioByExpanding, QtCore.Qt.FastTransformation)) + self.chatbox.setPixmap(chatboxPixmap.scaled(self.chatboxWidth, self.chatboxHeight, QtCore.Qt.KeepAspectRatioByExpanding, QtCore.Qt.FastTransformation)) # Theme background courtroomBackground = AO2XPpath + "ao2xp_themes/" + theme + '/courtroombackground.png' @@ -2334,17 +2327,13 @@ class GUI(QtGui.QWidget): def setEvidenceImage(self, guiobj, image, scale=False): if exists(BASE_PATH + 'evidence/' + image): img = QtGui.QPixmap(BASE_PATH + "evidence/%s" % image) - if not img or img.isNull(): - return - if scale: + if not img.isNull() and scale: guiobj.setPixmap(img.scaled(140, 140, QtCore.Qt.KeepAspectRatioByExpanding, QtCore.Qt.FastTransformation)) else: guiobj.setPixmap(img) else: img = QtGui.QPixmap(AO2XPpath + 'themes/default/evidence_selected.png') - if not img or img.isNull(): - return - if scale: + if not img.isNull() and scale: guiobj.setPixmap(img.scaled(140, 140, QtCore.Qt.KeepAspectRatioByExpanding, QtCore.Qt.FastTransformation)) else: guiobj.setPixmap(img) @@ -2558,17 +2547,14 @@ class GUI(QtGui.QWidget): else: image = QtGui.QPixmap(BASE_PATH + 'characters/' + self.charName + '/emotions/button' + str(nRealEmote + 1) + '_off.png') - self.emoteButtons[nEmote].show() - self.emoteButtons[nEmote].setToolTip(self.charEmotes[nEmote + self.currentEmotePage * self.maxEmotesOnPage][0]) - - if not image or image.isNull(): - return - - if not image.width() == 40: + if not image.isNull() and not image.width() == 40: self.emoteButtons[nEmote].setPixmap(image.scaled(40, 40, QtCore.Qt.IgnoreAspectRatio, QtCore.Qt.SmoothTransformation)) else: self.emoteButtons[nEmote].setPixmap(image) + self.emoteButtons[nEmote].show() + self.emoteButtons[nEmote].setToolTip(self.charEmotes[nEmote + self.currentEmotePage * self.maxEmotesOnPage][0]) + def iniSwapIndexChange(self, ind): self.iniSwapIndex = ind @@ -2901,10 +2887,7 @@ class GUI(QtGui.QWidget): else: image = QtGui.QPixmap(BASE_PATH + 'characters/' + self.charName + '/emotions/button' + str(button.emoteid + self.currentEmotePage * self.maxEmotesOnPage + 1) + '_off.png') - if not image or image.isNull(): - return - - if not image.width() == 40: + if not image.isNull() and not image.width() == 40: button.setPixmap(image.scaled(40, 40, QtCore.Qt.IgnoreAspectRatio, QtCore.Qt.SmoothTransformation)) else: button.setPixmap(image) @@ -3208,9 +3191,8 @@ class GUI(QtGui.QWidget): if bgimg.size().width() != self.viewport.width() or bgimg.size().height() != self.viewport.height(): if "bench" in bgfile[0]: _scale = self.viewport.height() / float(bgimg.size().height()) - if bgimg and not bgimg.isNull(): - setattr(self, bgfile[0], QtGui.QPixmap.fromImage(bgimg.scaled(bgimg.size().width() * _scale, bgimg.size().height() * _scale, QtCore.Qt.KeepAspectRatioByExpanding, QtCore.Qt.FastTransformation))) - elif bgimg and not bgimg.isNull(): + setattr(self, bgfile[0], QtGui.QPixmap.fromImage(bgimg.scaled(bgimg.size().width() * _scale, bgimg.size().height() * _scale, QtCore.Qt.KeepAspectRatioByExpanding, QtCore.Qt.FastTransformation))) + else: setattr(self, bgfile[0], QtGui.QPixmap.fromImage(bgimg.scaled(self.viewport.width(), self.viewport.height(), QtCore.Qt.KeepAspectRatioByExpanding, QtCore.Qt.FastTransformation))) else: setattr(self, bgfile[0], QtGui.QPixmap.fromImage(bgimg)) @@ -3222,18 +3204,16 @@ class GUI(QtGui.QWidget): if self.slideAvailable: slide = QtGui.QPixmap(court) - slideWidth = slide.width() * 2 + slide_width = slide.width() * 2 - self.slideBg.resize(slideWidth, self.viewport.height()) - if slide and not slide.isNull(): - self.slideBg.setPixmap(slide.scaled(slide.width() * 2, self.viewport.height(), QtCore.Qt.KeepAspectRatioByExpanding, QtCore.Qt.FastTransformation)) + self.slideBg.resize(slide_width, self.viewport.height()) + self.slideBg.setPixmap(slide.scaled(slide.width() * 2, self.viewport.height(), QtCore.Qt.KeepAspectRatioByExpanding, QtCore.Qt.FastTransformation)) courtOverlay = BASE_PATH + 'background/' + bg + '/courtOverlay.png' if exists(courtOverlay): slideOverlay = QtGui.QPixmap(courtOverlay) - self.slideOverlay.resize(slideWidth, self.viewport.height()) - if slideOverlay and not slideOverlay.isNull(): - self.slideOverlay.setPixmap(slideOverlay.scaled(slide.width() * 2, self.viewport.height(), QtCore.Qt.KeepAspectRatioByExpanding, QtCore.Qt.FastTransformation)) + self.slideOverlay.resize(slide_width, self.viewport.height()) + self.slideOverlay.setPixmap(slideOverlay.scaled(slide.width() * 2, self.viewport.height(), QtCore.Qt.KeepAspectRatioByExpanding, QtCore.Qt.FastTransformation)) self.slideHasOverlay = True else: self.slideHasOverlay = False