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:
parent
32bf56c7d9
commit
b13c27202a
|
@ -5,19 +5,30 @@
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QPaintEvent>
|
||||||
|
#include <QRect>
|
||||||
|
#include <QPalette>
|
||||||
|
|
||||||
CallConfirmWidget::CallConfirmWidget(QWidget *anchor) :
|
CallConfirmWidget::CallConfirmWidget(QWidget *anchor) :
|
||||||
QWidget(Widget::getInstance())
|
QWidget(Widget::getInstance()),
|
||||||
|
rectW{130}, rectH{90},
|
||||||
|
spikeW{30}, spikeH{15},
|
||||||
|
roundedFactor{15}
|
||||||
{
|
{
|
||||||
Widget* w = Widget::getInstance();
|
Widget* w = Widget::getInstance();
|
||||||
|
|
||||||
setWindowFlags(Qt::SubWindow);
|
setWindowFlags(Qt::SubWindow);
|
||||||
setAutoFillBackground(true);
|
|
||||||
|
QPalette palette;
|
||||||
|
palette.setColor(QPalette::WindowText, Qt::white);
|
||||||
|
setPalette(palette);
|
||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||||
QLabel *callLabel = new QLabel(tr("Incoming call..."), this);
|
QLabel *callLabel = new QLabel(tr("Incoming call..."), this);
|
||||||
|
callLabel->setAlignment(Qt::AlignHCenter);
|
||||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
|
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(accept, QDialogButtonBox::AcceptRole);
|
||||||
buttonBox->addButton(reject, QDialogButtonBox::RejectRole);
|
buttonBox->addButton(reject, QDialogButtonBox::RejectRole);
|
||||||
|
@ -25,9 +36,26 @@ CallConfirmWidget::CallConfirmWidget(QWidget *anchor) :
|
||||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &CallConfirmWidget::accepted);
|
connect(buttonBox, &QDialogButtonBox::accepted, this, &CallConfirmWidget::accepted);
|
||||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &CallConfirmWidget::rejected);
|
connect(buttonBox, &QDialogButtonBox::rejected, this, &CallConfirmWidget::rejected);
|
||||||
|
|
||||||
|
layout->setMargin(12);
|
||||||
|
layout->addSpacing(spikeH);
|
||||||
layout->addWidget(callLabel);
|
layout->addWidget(callLabel);
|
||||||
layout->addWidget(buttonBox);
|
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}));
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -2,8 +2,11 @@
|
||||||
#define CALLCONFIRMWIDGET_H
|
#define CALLCONFIRMWIDGET_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QRect>
|
||||||
|
#include <QPolygon>
|
||||||
|
#include <QBrush>
|
||||||
|
|
||||||
class QMoveEvent;
|
class QPaintEvent;
|
||||||
|
|
||||||
class CallConfirmWidget : public QWidget
|
class CallConfirmWidget : public QWidget
|
||||||
{
|
{
|
||||||
|
@ -14,6 +17,18 @@ public:
|
||||||
signals:
|
signals:
|
||||||
void accepted();
|
void accepted();
|
||||||
void rejected();
|
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
|
#endif // CALLCONFIRMWIDGET_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user