2014-09-26 22:39:29 +08:00
|
|
|
/*
|
|
|
|
This file is part of qTox, a Qt-based graphical interface for Tox.
|
|
|
|
|
|
|
|
This program is libre software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the COPYING file for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MASKABLEPIXMAPWIDGET_H
|
|
|
|
#define MASKABLEPIXMAPWIDGET_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
class MaskablePixmapWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-10-01 02:10:42 +08:00
|
|
|
MaskablePixmapWidget(QWidget *parent, QSize size, QString maskName = QString());
|
2015-05-10 04:35:58 +08:00
|
|
|
~MaskablePixmapWidget();
|
2014-09-30 02:18:03 +08:00
|
|
|
void autopickBackground();
|
2014-09-28 00:00:13 +08:00
|
|
|
void setClickable(bool clickable);
|
2014-10-01 02:10:42 +08:00
|
|
|
void setPixmap(const QPixmap &pmap, QColor background);
|
2014-09-26 22:39:29 +08:00
|
|
|
void setPixmap(const QPixmap &pmap);
|
|
|
|
QPixmap getPixmap() const;
|
2015-01-26 21:09:19 +08:00
|
|
|
void setSize(QSize size);
|
2014-09-26 22:39:29 +08:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void clicked();
|
|
|
|
|
|
|
|
protected:
|
2014-09-27 21:39:17 +08:00
|
|
|
virtual void paintEvent(QPaintEvent *);
|
2014-09-26 22:39:29 +08:00
|
|
|
virtual void mousePressEvent(QMouseEvent *);
|
|
|
|
|
|
|
|
private:
|
2015-01-26 21:09:19 +08:00
|
|
|
QPixmap pixmap, mask, unscaled; // a lot of memory...
|
|
|
|
QPixmap* renderTarget = nullptr; // pointer to dynamically call the constructor
|
2014-09-26 22:39:29 +08:00
|
|
|
QSize size;
|
|
|
|
QString maskName;
|
2014-09-27 23:41:17 +08:00
|
|
|
QColor backgroundColor;
|
2015-01-26 21:09:19 +08:00
|
|
|
bool clickable, manualColor = false;
|
2014-09-26 22:39:29 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MASKABLEPIXMAPWIDGET_H
|