91f82fd6d3
* Tweaked search string based on new comic vine search behavior Placated Beaufitul Soup by passing the parser * First cut at porting to Python 3 and PyQt5 * remove debug print * tweaked progress dialog handling for issues on ubuntu gui * Handle bad key more gracefullu * More integration of unrarlib into settings and rest of app * Better handling of "personal" unrar lib setting * PEP 440-compliant version string * Tuned linux rar help strings * Got setup working again * Attempts to build unrar on install * Some minimal desktop integration on various platforms * Fix wrong shortfile * More setup.py enhancements * Use proper temp file * Added comment block at top * Comment out desktop integration attempt for now * Updated some links and info * Fixed the html a bit * Repaired some images that caused libpng to complain * update readme re: py3qt5 branch changes * another note * #108 feat: try to simplify windows build using only pip and python3 * #108 feat: fix python location on appveyor (try 1) * #108 feat: use venv (try 2) * #108 feat: use venv (try 3) * #108 feat: update to latest pyinstaller develop branch * #108 feat: update to latest pyinstaller develop branch (again) * #108: add ssl libraries for windows packaging * #108: refresh env in win build to pick the right mingw * #108: change order of win build script operations * #113: fix subprocess usage in pyinstaller package * bump version
94 lines
3.2 KiB
Python
94 lines
3.2 KiB
Python
"""A PyQT4 widget to display a popup image"""
|
|
|
|
# Copyright 2012-2014 Anthony Beville
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
#import sys
|
|
#import os
|
|
|
|
from PyQt5 import QtCore, QtGui, QtWidgets, uic
|
|
|
|
from .settings import ComicTaggerSettings
|
|
|
|
|
|
class ImagePopup(QtWidgets.QDialog):
|
|
|
|
def __init__(self, parent, image_pixmap):
|
|
super(ImagePopup, self).__init__(parent)
|
|
|
|
uic.loadUi(ComicTaggerSettings.getUIFile('imagepopup.ui'), self)
|
|
|
|
QtWidgets.QApplication.setOverrideCursor(
|
|
QtGui.QCursor(QtCore.Qt.WaitCursor))
|
|
|
|
# self.setWindowModality(QtCore.Qt.WindowModal)
|
|
self.setWindowFlags(QtCore.Qt.Popup)
|
|
self.setWindowState(QtCore.Qt.WindowFullScreen)
|
|
|
|
self.imagePixmap = image_pixmap
|
|
|
|
screen_size = QtWidgets.QDesktopWidget().screenGeometry()
|
|
self.resize(screen_size.width(), screen_size.height())
|
|
self.move(0, 0)
|
|
|
|
# This is a total hack. Uses a snapshot of the desktop, and overlays a
|
|
# translucent screen over it. Probably can do it better by setting opacity of a
|
|
# widget
|
|
screen = QtWidgets.QApplication.primaryScreen()
|
|
self.desktopBg = screen.grabWindow(
|
|
QtWidgets.QApplication.desktop().winId(),
|
|
0,
|
|
0,
|
|
screen_size.width(),
|
|
screen_size.height())
|
|
bg = QtGui.QPixmap(ComicTaggerSettings.getGraphic('popup_bg.png'))
|
|
self.clientBgPixmap = bg.scaled(
|
|
screen_size.width(), screen_size.height())
|
|
self.setMask(self.clientBgPixmap.mask())
|
|
|
|
self.applyImagePixmap()
|
|
self.showFullScreen()
|
|
self.raise_()
|
|
QtWidgets.QApplication.restoreOverrideCursor()
|
|
|
|
def paintEvent(self, event):
|
|
self.painter = QtGui.QPainter(self)
|
|
self.painter.setRenderHint(QtGui.QPainter.Antialiasing)
|
|
self.painter.drawPixmap(0, 0, self.desktopBg)
|
|
self.painter.drawPixmap(0, 0, self.clientBgPixmap)
|
|
self.painter.end()
|
|
|
|
def applyImagePixmap(self):
|
|
win_h = self.height()
|
|
win_w = self.width()
|
|
|
|
if self.imagePixmap.width(
|
|
) > win_w or self.imagePixmap.height() > win_h:
|
|
# scale the pixmap to fit in the frame
|
|
display_pixmap = self.imagePixmap.scaled(
|
|
win_w, win_h, QtCore.Qt.KeepAspectRatio)
|
|
self.lblImage.setPixmap(display_pixmap)
|
|
else:
|
|
display_pixmap = self.imagePixmap
|
|
self.lblImage.setPixmap(display_pixmap)
|
|
|
|
# move and resize the label to be centered in the fame
|
|
img_w = display_pixmap.width()
|
|
img_h = display_pixmap.height()
|
|
self.lblImage.resize(img_w, img_h)
|
|
self.lblImage.move((win_w - img_w) / 2, (win_h - img_h) / 2)
|
|
|
|
def mousePressEvent(self, event):
|
|
self.close()
|