Skip to content
Snippets Groups Projects
Commit 8beef5e6 authored by Konstantinos Sideris's avatar Konstantinos Sideris
Browse files

Dismiss modal by clicking on the overlay

parent 9521efab
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,7 @@
#include <QGraphicsOpacityEffect>
#include <QKeyEvent>
#include <QMouseEvent>
#include <QPaintEvent>
#include <QPropertyAnimation>
......@@ -39,8 +40,11 @@ public:
protected:
void paintEvent(QPaintEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
private:
QWidget *content_;
int duration_;
QColor color_;
......
......@@ -22,6 +22,7 @@
OverlayModal::OverlayModal(QWidget *parent, QWidget *content)
: OverlayWidget(parent)
, content_{content}
, duration_{500}
, color_{QColor(55, 55, 55)}
{
......@@ -60,6 +61,13 @@ OverlayModal::paintEvent(QPaintEvent *event)
painter.fillRect(rect(), color_);
}
void
OverlayModal::mousePressEvent(QMouseEvent *e)
{
if (content_ && !content_->geometry().contains(e->pos()))
fadeOut();
}
void
OverlayModal::fadeIn()
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment