Dismiss modal by clicking on the overlay
This commit is contained in:
parent
9521efab7e
commit
8beef5e61f
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <QGraphicsOpacityEffect>
|
#include <QGraphicsOpacityEffect>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
#include <QMouseEvent>
|
||||||
#include <QPaintEvent>
|
#include <QPaintEvent>
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
|
|
||||||
@ -39,8 +40,11 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event) override;
|
void paintEvent(QPaintEvent *event) override;
|
||||||
void keyPressEvent(QKeyEvent *event) override;
|
void keyPressEvent(QKeyEvent *event) override;
|
||||||
|
void mousePressEvent(QMouseEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QWidget *content_;
|
||||||
|
|
||||||
int duration_;
|
int duration_;
|
||||||
QColor color_;
|
QColor color_;
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
OverlayModal::OverlayModal(QWidget *parent, QWidget *content)
|
OverlayModal::OverlayModal(QWidget *parent, QWidget *content)
|
||||||
: OverlayWidget(parent)
|
: OverlayWidget(parent)
|
||||||
|
, content_{content}
|
||||||
, duration_{500}
|
, duration_{500}
|
||||||
, color_{QColor(55, 55, 55)}
|
, color_{QColor(55, 55, 55)}
|
||||||
{
|
{
|
||||||
@ -60,6 +61,13 @@ OverlayModal::paintEvent(QPaintEvent *event)
|
|||||||
painter.fillRect(rect(), color_);
|
painter.fillRect(rect(), color_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
OverlayModal::mousePressEvent(QMouseEvent *e)
|
||||||
|
{
|
||||||
|
if (content_ && !content_->geometry().contains(e->pos()))
|
||||||
|
fadeOut();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
OverlayModal::fadeIn()
|
OverlayModal::fadeIn()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user