Don't dismiss the loading overlay by clicking

This commit is contained in:
Konstantinos Sideris 2018-01-22 16:47:08 +02:00
parent 72cba5d9eb
commit 48dabdfdc7
3 changed files with 13 additions and 18 deletions

View file

@ -28,14 +28,18 @@
class OverlayModal : public OverlayWidget
{
public:
explicit OverlayModal(QWidget *parent, QWidget *content);
OverlayModal(QWidget *parent, QWidget *content);
void fadeIn();
void fadeOut();
public:
inline void setDuration(int duration);
inline void setColor(QColor color);
void setDuration(int duration)
{
duration_ = duration;
animation_->setDuration(duration_);
};
void setColor(QColor color) { color_ = color; }
void setDismissible(bool state) { isDismissible_ = state; }
protected:
void paintEvent(QPaintEvent *event) override;
@ -48,19 +52,9 @@ private:
int duration_;
QColor color_;
//! Decides whether or not the modal can be removed by clicking into it.
bool isDismissible_ = true;
QGraphicsOpacityEffect *opacity_;
QPropertyAnimation *animation_;
};
inline void
OverlayModal::setDuration(int duration)
{
duration_ = duration;
animation_->setDuration(duration_);
}
inline void
OverlayModal::setColor(QColor color)
{
color_ = color;
}

View file

@ -213,6 +213,7 @@ MainWindow::showChatPage(QString userid, QString homeserver, QString token)
progressModal_ =
QSharedPointer<OverlayModal>(new OverlayModal(this, spinner_.data()),
[=](OverlayModal *modal) { modal->deleteLater(); });
progressModal_->setDismissible(false);
progressModal_->fadeIn();
progressModal_->setDuration(modalOpacityDuration);
}

View file

@ -64,7 +64,7 @@ OverlayModal::paintEvent(QPaintEvent *event)
void
OverlayModal::mousePressEvent(QMouseEvent *e)
{
if (content_ && !content_->geometry().contains(e->pos()))
if (isDismissible_ && content_ && !content_->geometry().contains(e->pos()))
fadeOut();
}