diff options
author | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2018-08-11 13:50:56 +0300 |
---|---|---|
committer | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2018-08-11 13:50:56 +0300 |
commit | aa2f6ce77d924a0dc53325a425215a1b03e72f43 (patch) | |
tree | a6d8b8808a0f31c541aa7cb6af0cfd1f6826776f /src/ui/OverlayModal.cpp | |
parent | Add solid background in TypingDisplay (diff) | |
download | nheko-aa2f6ce77d924a0dc53325a425215a1b03e72f43.tar.xz |
Simplify dialog creation
Diffstat (limited to 'src/ui/OverlayModal.cpp')
-rw-r--r-- | src/ui/OverlayModal.cpp | 21 |
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 |