mirror of
https://github.com/YACReader/yacreader
synced 2025-07-18 13:04:28 -04:00
Add what's new dialog
This commit is contained in:
39
custom_widgets/rounded_corners_dialog.cpp
Normal file
39
custom_widgets/rounded_corners_dialog.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
#include "rounded_corners_dialog.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
YACReader::RoundedCornersDialog::RoundedCornersDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
}
|
||||
|
||||
void YACReader::RoundedCornersDialog::paintEvent(QPaintEvent *)
|
||||
{
|
||||
qreal radius = 36.0; // desired radius in absolute pixels
|
||||
qreal borderWidth = 0.0;
|
||||
|
||||
if (!(windowFlags() & Qt::FramelessWindowHint) && !testAttribute(Qt::WA_TranslucentBackground))
|
||||
return; // nothing to do
|
||||
|
||||
QPainter p(this);
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
// Paint thyself.
|
||||
QRectF rect(QPointF(0, 0), size());
|
||||
// Check for a border size.
|
||||
qreal penWidth = borderWidth;
|
||||
p.setPen(Qt::NoPen);
|
||||
|
||||
// Set the brush from palette role.
|
||||
p.setBrush(palette().brush(backgroundRole()));
|
||||
// Got radius? Otherwise draw a quicker rect.
|
||||
if (radius > 0.0)
|
||||
p.drawRoundedRect(rect, radius, radius, Qt::AbsoluteSize);
|
||||
else
|
||||
p.drawRect(rect);
|
||||
|
||||
// C'est finí
|
||||
p.end();
|
||||
}
|
Reference in New Issue
Block a user