1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Stylized CallConfirmedWidget, placeholder buttons

This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2015-01-25 16:46:33 +01:00
parent 32bf56c7d9
commit b13c27202a
2 changed files with 48 additions and 5 deletions

View File

@ -5,19 +5,30 @@
#include <QLabel>
#include <QPushButton>
#include <QDialogButtonBox>
#include <QPainter>
#include <QPaintEvent>
#include <QRect>
#include <QPalette>
CallConfirmWidget::CallConfirmWidget(QWidget *anchor) :
QWidget(Widget::getInstance())
QWidget(Widget::getInstance()),
rectW{130}, rectH{90},
spikeW{30}, spikeH{15},
roundedFactor{15}
{
Widget* w = Widget::getInstance();
setWindowFlags(Qt::SubWindow);
setAutoFillBackground(true);
QPalette palette;
palette.setColor(QPalette::WindowText, Qt::white);
setPalette(palette);
QVBoxLayout *layout = new QVBoxLayout(this);
QLabel *callLabel = new QLabel(tr("Incoming call..."), this);
callLabel->setAlignment(Qt::AlignHCenter);
QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
QPushButton *accept = new QPushButton("Y", this), *reject = new QPushButton("N", this);
QPushButton *accept = new QPushButton("Accept", this), *reject = new QPushButton("Reject", this);
buttonBox->addButton(accept, QDialogButtonBox::AcceptRole);
buttonBox->addButton(reject, QDialogButtonBox::RejectRole);
@ -25,9 +36,26 @@ CallConfirmWidget::CallConfirmWidget(QWidget *anchor) :
connect(buttonBox, &QDialogButtonBox::accepted, this, &CallConfirmWidget::accepted);
connect(buttonBox, &QDialogButtonBox::rejected, this, &CallConfirmWidget::rejected);
layout->setMargin(12);
layout->addSpacing(spikeH);
layout->addWidget(callLabel);
layout->addWidget(buttonBox);
setFixedSize(150,90);
mainRect = {0,spikeH,rectW,rectH};
brush = QBrush(QColor(65,65,65));
spikePoly = QPolygon({{(rectW-spikeW)/2,spikeH},{rectW/2,0},{(rectW+spikeW)/2,spikeH}});
setFixedSize(rectW,rectH+spikeH);
move(anchor->mapToGlobal({(anchor->width()-width())/2,anchor->height()})-w->mapToGlobal({0,0}));
}
void CallConfirmWidget::paintEvent(QPaintEvent*)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.setBrush(brush);
painter.setPen(Qt::NoPen);
painter.drawRoundRect(mainRect, roundedFactor, roundedFactor);
painter.drawPolygon(spikePoly);
}

View File

@ -2,8 +2,11 @@
#define CALLCONFIRMWIDGET_H
#include <QWidget>
#include <QRect>
#include <QPolygon>
#include <QBrush>
class QMoveEvent;
class QPaintEvent;
class CallConfirmWidget : public QWidget
{
@ -14,6 +17,18 @@ public:
signals:
void accepted();
void rejected();
protected:
virtual void paintEvent(QPaintEvent* event) override;
private:
QRect mainRect;
QPolygon spikePoly;
QBrush brush;
const int rectW, rectH;
const int spikeW, spikeH;
const int roundedFactor;
};
#endif // CALLCONFIRMWIDGET_H