qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
callconfirmwidget.h
Go to the documentation of this file.
1 /*
2  Copyright © 2015-2019 by The qTox Project Contributors
3 
4  This file is part of qTox, a Qt-based graphical interface for Tox.
5 
6  qTox is libre software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  qTox is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with qTox. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 
21 #pragma once
22 
23 #include <QBrush>
24 #include <QPolygon>
25 #include <QRect>
26 #include <QWidget>
27 
28 class QPaintEvent;
29 class QShowEvent;
30 
31 class CallConfirmWidget final : public QWidget
32 {
33  Q_OBJECT
34 public:
35  explicit CallConfirmWidget(const QWidget* anchor);
36 
37 signals:
38  void accepted();
39  void rejected();
40 
41 public slots:
42  void reposition();
43 
44 protected:
45  void paintEvent(QPaintEvent* event) final;
46  void showEvent(QShowEvent* event) final;
47  void hideEvent(QHideEvent* event) final;
48  bool eventFilter(QObject*, QEvent* event) final;
49 
50 private:
51  const QWidget* anchor;
52 
53  QRect mainRect;
54  QPolygon spikePoly;
55  QBrush brush;
56 
57  const int rectW, rectH;
58  const int spikeW, spikeH;
59  const int roundedFactor;
60  const qreal rectRatio;
61 };
CallConfirmWidget
This is a widget with dialog buttons to accept/reject a call.
Definition: callconfirmwidget.h:31
CallConfirmWidget::rejected
void rejected()
CallConfirmWidget::rectRatio
const qreal rectRatio
Used to correct the rounding factors on non-square rects.
Definition: callconfirmwidget.h:60
CallConfirmWidget::accepted
void accepted()
CallConfirmWidget::paintEvent
void paintEvent(QPaintEvent *event) final
Definition: callconfirmwidget.cpp:144
CallConfirmWidget::showEvent
void showEvent(QShowEvent *event) final
Definition: callconfirmwidget.cpp:155
CallConfirmWidget::CallConfirmWidget
CallConfirmWidget(const QWidget *anchor)
Definition: callconfirmwidget.cpp:53
CallConfirmWidget::rectH
const int rectH
Definition: callconfirmwidget.h:57
CallConfirmWidget::reposition
void reposition()
Recalculate our positions to track the anchor.
Definition: callconfirmwidget.cpp:116
CallConfirmWidget::spikePoly
QPolygon spikePoly
Definition: callconfirmwidget.h:54
CallConfirmWidget::mainRect
QRect mainRect
Definition: callconfirmwidget.h:53
CallConfirmWidget::spikeW
const int spikeW
Definition: callconfirmwidget.h:58
CallConfirmWidget::anchor
const QWidget * anchor
The widget we're going to be tracking.
Definition: callconfirmwidget.h:51
CallConfirmWidget::spikeH
const int spikeH
Definition: callconfirmwidget.h:58
CallConfirmWidget::rectW
const int rectW
Definition: callconfirmwidget.h:57
CallConfirmWidget::brush
QBrush brush
Definition: callconfirmwidget.h:55
CallConfirmWidget::roundedFactor
const int roundedFactor
By how much are the corners of the main rect rounded.
Definition: callconfirmwidget.h:59
CallConfirmWidget::hideEvent
void hideEvent(QHideEvent *event) final
Definition: callconfirmwidget.cpp:166
CallConfirmWidget::eventFilter
bool eventFilter(QObject *, QEvent *event) final
Definition: callconfirmwidget.cpp:174