summary refs log tree commit diff
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-01-22 16:47:08 +0200
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-01-22 16:47:08 +0200
commit48dabdfdc780d26c0e0a8e2f916ce879296f01e2 (patch)
tree03b35a018fb35f56544f998773eace103deaeeb4
parentDisable minimize to tray except for the ChatPage (diff)
downloadnheko-48dabdfdc780d26c0e0a8e2f916ce879296f01e2.tar.xz
Don't dismiss the loading overlay by clicking
-rw-r--r--include/ui/OverlayModal.h28
-rw-r--r--src/MainWindow.cc1
-rw-r--r--src/ui/OverlayModal.cc2
3 files changed, 13 insertions, 18 deletions
diff --git a/include/ui/OverlayModal.h b/include/ui/OverlayModal.h
index 2ac5eb6d..0fd96390 100644
--- a/include/ui/OverlayModal.h
+++ b/include/ui/OverlayModal.h
@@ -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;
-}
diff --git a/src/MainWindow.cc b/src/MainWindow.cc
index 228c900b..9437b401 100644
--- a/src/MainWindow.cc
+++ b/src/MainWindow.cc
@@ -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);
         }
diff --git a/src/ui/OverlayModal.cc b/src/ui/OverlayModal.cc
index 62d31f24..87703af8 100644
--- a/src/ui/OverlayModal.cc
+++ b/src/ui/OverlayModal.cc
@@ -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();
 }