1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
qTox/src/widget/callconfirmwidget.h
Tux3 / Mlkj / !Lev.uXFMLA ac2700fdeb
Fix rounding for non-square CallConfirmWidget
Thanks to @krepa098
2015-01-26 18:29:13 +01:00

46 lines
1.1 KiB
C++

#ifndef CALLCONFIRMWIDGET_H
#define CALLCONFIRMWIDGET_H
#include <QWidget>
#include <QRect>
#include <QPolygon>
#include <QBrush>
class QPaintEvent;
class QShowEvent;
/// This is a widget with dialog buttons to accept/reject a call
/// It tracks the position of another widget called the anchor
/// and looks like a bubble at the bottom of that widget.
class CallConfirmWidget : public QWidget
{
Q_OBJECT
public:
explicit CallConfirmWidget(const QWidget *Anchor);
signals:
void accepted();
void rejected();
protected:
virtual void paintEvent(QPaintEvent* event) override;
virtual void showEvent(QShowEvent * event) override;
protected slots:
void reposition(); ///< Recalculate our positions to track the anchor
private:
const QWidget* anchor; ///< The widget we're going to be tracking
QRect mainRect;
QPolygon spikePoly;
QBrush brush;
const int rectW, rectH;
const int spikeW, spikeH;
const int roundedFactor; ///< By how much are the corners of the main rect rounded
const qreal rectRatio; ///< Used to correct the rounding factors on non-square rects
};
#endif // CALLCONFIRMWIDGET_H