2014-09-26 22:39:29 +08:00
|
|
|
/*
|
2015-06-06 09:40:08 +08:00
|
|
|
Copyright © 2014-2015 by The qTox Project
|
|
|
|
|
2014-09-26 22:39:29 +08:00
|
|
|
This file is part of qTox, a Qt-based graphical interface for Tox.
|
|
|
|
|
2015-06-06 09:40:08 +08:00
|
|
|
qTox is libre software: you can redistribute it and/or modify
|
2014-09-26 22:39:29 +08:00
|
|
|
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.
|
2015-06-06 09:40:08 +08:00
|
|
|
|
|
|
|
qTox is distributed in the hope that it will be useful,
|
2014-09-26 22:39:29 +08:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2015-06-06 09:40:08 +08:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2014-09-26 22:39:29 +08:00
|
|
|
|
2015-06-06 09:40:08 +08:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with qTox. If not, see <http://www.gnu.org/licenses/>.
|
2014-09-26 22:39:29 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MASKABLEPIXMAPWIDGET_H
|
|
|
|
#define MASKABLEPIXMAPWIDGET_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
2015-06-09 02:08:24 +08:00
|
|
|
class MaskablePixmapWidget final : public QWidget
|
2014-09-26 22:39:29 +08:00
|
|
|
{
|
|
|
|
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:
|
2015-06-09 02:08:24 +08:00
|
|
|
virtual void paintEvent(QPaintEvent *) final override;
|
|
|
|
virtual void mousePressEvent(QMouseEvent *) final override;
|
2014-09-26 22:39:29 +08:00
|
|
|
|
|
|
|
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
|