2015-01-25 11:57:20 +08:00
|
|
|
#include "callconfirmwidget.h"
|
|
|
|
#include "widget.h"
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QDialogButtonBox>
|
2015-01-25 23:46:33 +08:00
|
|
|
#include <QPainter>
|
|
|
|
#include <QPaintEvent>
|
|
|
|
#include <QRect>
|
|
|
|
#include <QPalette>
|
2015-01-25 11:57:20 +08:00
|
|
|
|
|
|
|
CallConfirmWidget::CallConfirmWidget(QWidget *anchor) :
|
2015-01-25 23:46:33 +08:00
|
|
|
QWidget(Widget::getInstance()),
|
|
|
|
rectW{130}, rectH{90},
|
|
|
|
spikeW{30}, spikeH{15},
|
|
|
|
roundedFactor{15}
|
2015-01-25 11:57:20 +08:00
|
|
|
{
|
|
|
|
Widget* w = Widget::getInstance();
|
|
|
|
|
|
|
|
setWindowFlags(Qt::SubWindow);
|
2015-01-25 23:46:33 +08:00
|
|
|
|
|
|
|
QPalette palette;
|
|
|
|
palette.setColor(QPalette::WindowText, Qt::white);
|
|
|
|
setPalette(palette);
|
2015-01-25 11:57:20 +08:00
|
|
|
|
|
|
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
|
|
|
QLabel *callLabel = new QLabel(tr("Incoming call..."), this);
|
2015-01-25 23:46:33 +08:00
|
|
|
callLabel->setAlignment(Qt::AlignHCenter);
|
2015-01-25 11:57:20 +08:00
|
|
|
QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
|
2015-01-25 23:46:33 +08:00
|
|
|
QPushButton *accept = new QPushButton("Accept", this), *reject = new QPushButton("Reject", this);
|
2015-01-25 11:57:20 +08:00
|
|
|
|
|
|
|
buttonBox->addButton(accept, QDialogButtonBox::AcceptRole);
|
|
|
|
buttonBox->addButton(reject, QDialogButtonBox::RejectRole);
|
|
|
|
|
|
|
|
connect(buttonBox, &QDialogButtonBox::accepted, this, &CallConfirmWidget::accepted);
|
|
|
|
connect(buttonBox, &QDialogButtonBox::rejected, this, &CallConfirmWidget::rejected);
|
|
|
|
|
2015-01-25 23:46:33 +08:00
|
|
|
layout->setMargin(12);
|
|
|
|
layout->addSpacing(spikeH);
|
2015-01-25 11:57:20 +08:00
|
|
|
layout->addWidget(callLabel);
|
|
|
|
layout->addWidget(buttonBox);
|
|
|
|
|
2015-01-25 23:46:33 +08:00
|
|
|
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);
|
2015-01-25 11:57:20 +08:00
|
|
|
move(anchor->mapToGlobal({(anchor->width()-width())/2,anchor->height()})-w->mapToGlobal({0,0}));
|
|
|
|
}
|
2015-01-25 23:46:33 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|