mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
MaskablePixmapWidget: set cursor to PointingHandCursor if clickable
This commit is contained in:
parent
bb214b53f7
commit
18330f0928
|
@ -20,11 +20,22 @@
|
|||
MaskablePixmapWidget::MaskablePixmapWidget(QWidget *parent, QSize size, QString maskName, QColor background)
|
||||
: QWidget(parent)
|
||||
, backgroundColor(background)
|
||||
, clickable(false)
|
||||
{
|
||||
setFixedSize(size);
|
||||
mask = QPixmap(maskName).scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
}
|
||||
|
||||
void MaskablePixmapWidget::setClickable(bool clickable)
|
||||
{
|
||||
this->clickable = clickable;
|
||||
|
||||
if (clickable)
|
||||
setCursor(Qt::PointingHandCursor);
|
||||
else
|
||||
unsetCursor();
|
||||
}
|
||||
|
||||
void MaskablePixmapWidget::setPixmap(const QPixmap &pmap)
|
||||
{
|
||||
pixmap = pmap.scaled(width(), height(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
|
@ -56,5 +67,6 @@ void MaskablePixmapWidget::paintEvent(QPaintEvent *)
|
|||
|
||||
void MaskablePixmapWidget::mousePressEvent(QMouseEvent*)
|
||||
{
|
||||
if(clickable)
|
||||
emit clicked();
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ class MaskablePixmapWidget : public QWidget
|
|||
public:
|
||||
MaskablePixmapWidget(QWidget *parent, QSize size, QString maskName, QColor background = Qt::white);
|
||||
|
||||
void setClickable(bool clickable);
|
||||
void setPixmap(const QPixmap &pmap);
|
||||
QPixmap getPixmap() const;
|
||||
|
||||
|
@ -41,6 +42,7 @@ private:
|
|||
QSize size;
|
||||
QString maskName;
|
||||
QColor backgroundColor;
|
||||
bool clickable;
|
||||
};
|
||||
|
||||
#endif // MASKABLEPIXMAPWIDGET_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user