mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Transparency effect for eject button.
This commit is contained in:
parent
336dfaac4a
commit
37658f07c6
@ -278,10 +278,29 @@ class LocationView(QListView):
|
|||||||
|
|
||||||
class EjectButton(QAbstractButton):
|
class EjectButton(QAbstractButton):
|
||||||
|
|
||||||
|
def __init__(self, parent):
|
||||||
|
QAbstractButton.__init__(self, parent)
|
||||||
|
self.mouse_over = False
|
||||||
|
|
||||||
|
def enterEvent(self, event):
|
||||||
|
self.mouse_over = True
|
||||||
|
|
||||||
|
def leaveEvent(self, event):
|
||||||
|
self.mouse_over = False
|
||||||
|
|
||||||
def paintEvent(self, event):
|
def paintEvent(self, event):
|
||||||
painter = QPainter(self)
|
painter = QPainter(self)
|
||||||
painter.setClipRect(event.rect());
|
painter.setClipRect(event.rect())
|
||||||
painter.drawPixmap(0, 0, QPixmap(':/images/eject').scaledToHeight(event.rect().height(), Qt.SmoothTransformation))
|
image = QPixmap(':/images/eject').scaledToHeight(event.rect().height(),
|
||||||
|
Qt.SmoothTransformation)
|
||||||
|
|
||||||
|
if not self.mouse_over:
|
||||||
|
alpha_mask = QPixmap(image.width(), image.height())
|
||||||
|
color = QColor(128, 128, 128)
|
||||||
|
alpha_mask.fill(color)
|
||||||
|
image.setAlphaChannel(alpha_mask)
|
||||||
|
|
||||||
|
painter.drawPixmap(0, 0, image)
|
||||||
|
|
||||||
|
|
||||||
class DetailView(QDialog, Ui_Dialog):
|
class DetailView(QDialog, Ui_Dialog):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user