Skip to content

Commit

Permalink
Widgets|libappfw: Opening a modal dialog without blocking event loop
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Nov 22, 2016
1 parent 7d11389 commit b695bb1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 3 additions & 1 deletion doomsday/sdk/libappfw/include/de/widgets/dialogwidget.h
Expand Up @@ -225,7 +225,9 @@ class LIBAPPFW_PUBLIC DialogWidget : public PopupWidget
* Opens the dialog as non-modal. The dialog must already be added to the
* widget tree. Use accept() or reject() to close the dialog.
*/
void open();
void open() override;

void open(Modality modality);

ui::ActionItem *defaultActionItem();

Expand Down
11 changes: 8 additions & 3 deletions doomsday/sdk/libappfw/src/widgets/dialogwidget.cpp
Expand Up @@ -568,7 +568,12 @@ int DialogWidget::exec(GuiRootWidget &root)

void DialogWidget::open()
{
d->modality = NonModal;
open(NonModal);
}

void DialogWidget::open(Modality modality)
{
d->modality = modality;

DENG2_ASSERT(hasRoot());
prepare(); // calls base class's open()
Expand Down Expand Up @@ -660,7 +665,7 @@ void DialogWidget::accept(int result)
d->subloop.exit(result);
emit accepted(result);
}
else if (d->modality == NonModal)
else
{
emit accepted(result);
finish(result);
Expand All @@ -675,7 +680,7 @@ void DialogWidget::reject(int result)
d->subloop.exit(result);
emit rejected(result);
}
else if (d->modality == NonModal)
else
{
emit rejected(result);
finish(result);
Expand Down

0 comments on commit b695bb1

Please sign in to comment.