summary refs log tree commit diff
path: root/src/ui/OverlayModal.cpp
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-08-11 13:50:56 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-08-11 13:50:56 +0300
commitaa2f6ce77d924a0dc53325a425215a1b03e72f43 (patch)
treea6d8b8808a0f31c541aa7cb6af0cfd1f6826776f /src/ui/OverlayModal.cpp
parentAdd solid background in TypingDisplay (diff)
downloadnheko-aa2f6ce77d924a0dc53325a425215a1b03e72f43.tar.xz
Simplify dialog creation
Diffstat (limited to 'src/ui/OverlayModal.cpp')
-rw-r--r--src/ui/OverlayModal.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/ui/OverlayModal.cpp b/src/ui/OverlayModal.cpp
index 30ebdf5c..abd1827a 100644
--- a/src/ui/OverlayModal.cpp
+++ b/src/ui/OverlayModal.cpp
@@ -20,18 +20,31 @@
 
 #include "OverlayModal.h"
 
-OverlayModal::OverlayModal(QWidget *parent, QWidget *content)
+OverlayModal::OverlayModal(QWidget *parent)
   : OverlayWidget(parent)
-  , content_{content}
   , color_{QColor(30, 30, 30, 170)}
 {
         layout_ = new QVBoxLayout(this);
-        layout_->addWidget(content);
         layout_->setSpacing(0);
         layout_->setContentsMargins(10, 40, 10, 20);
         setContentAlignment(Qt::AlignCenter);
+}
+
+void
+OverlayModal::setWidget(QWidget *widget)
+{
+        // Delete the previous widget
+        if (layout_->count() > 0) {
+                QLayoutItem *item;
+                while ((item = layout_->takeAt(0)) != nullptr) {
+                        delete item->widget();
+                        delete item;
+                }
+        }
 
-        content->setFocus();
+        layout_->addWidget(widget);
+        content_ = widget;
+        content_->setFocus();
 }
 
 void