Dismiss modal by clicking on the overlay

pull/1/head
Konstantinos Sideris 7 years ago
parent 9521efab7e
commit 8beef5e61f
  1. 4
      include/ui/OverlayModal.h
  2. 8
      src/ui/OverlayModal.cc

@ -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()
{

Loading…
Cancel
Save