Skip to content

Commit

Permalink
Refactor|libappfw|Client: Use Untrapper in dialogs and tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Mar 10, 2014
1 parent 9c8f3c4 commit 8173ce9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
10 changes: 10 additions & 0 deletions doomsday/client/src/ui/widgets/tutorialwidget.cpp
Expand Up @@ -25,6 +25,7 @@

#include <de/MessageDialog>
#include <de/SignalAction>
#include <de/Untrapper>

using namespace de;

Expand All @@ -44,11 +45,15 @@ DENG_GUI_PIMPL(TutorialWidget)
MessageDialog *dlg;
LabelWidget *highlight;
QTimer flashing;
bool taskBarInitiallyOpen;
Untrapper untrapper;

Instance(Public *i)
: Base(i)
, current(Welcome)
, dlg(0)
, taskBarInitiallyOpen(ClientWindow::main().taskBar().isOpen())
, untrapper(ClientWindow::main())
{
self.add(darken = new LabelWidget);
darken->set(Background(style().colors().colorf("altaccent") *
Expand Down Expand Up @@ -234,6 +239,11 @@ void TutorialWidget::start()

void TutorialWidget::stop()
{
if(!d->taskBarInitiallyOpen)
{
ClientWindow::main().taskBar().close();
}

d->deinitStep();

// Animate away and unfade darkening.
Expand Down
18 changes: 5 additions & 13 deletions doomsday/libappfw/src/widgets/dialogwidget.cpp
Expand Up @@ -25,6 +25,7 @@

#include <de/KeyEvent>
#include <de/MouseEvent>
#include <de/Untrapper>
#include <QEventLoop>

namespace de {
Expand Down Expand Up @@ -95,7 +96,7 @@ public ChildWidgetOrganizer::IFilter
bool needButtonUpdate;
float normalGlow;
bool animatingGlow;
bool needTrapAfterClose;
QScopedPointer<Untrapper> untrapper;
DialogContentStylist stylist;

Instance(Public *i, Flags const &dialogFlags)
Expand All @@ -106,7 +107,6 @@ public ChildWidgetOrganizer::IFilter
, acceptAction(0)
, needButtonUpdate(false)
, animatingGlow(false)
, needTrapAfterClose(false)
{
// Initialize the border glow.
normalGlow = style().colors().colorf("glow").w;
Expand Down Expand Up @@ -615,12 +615,8 @@ void DialogWidget::reject(int result)

void DialogWidget::prepare()
{
if(root().window().canvas().isMouseTrapped())
{
// Mouse needs to be untrapped for the user to be access the dialog.
root().window().canvas().trapMouse(false);
d->needTrapAfterClose = true;
}
// Mouse needs to be untrapped for the user to be access the dialog.
d->untrapper.reset(new Untrapper(root().window()));

root().setFocus(0);

Expand Down Expand Up @@ -651,11 +647,7 @@ void DialogWidget::finish(int result)
root().setFocus(0);
close();

if(d->needTrapAfterClose)
{
root().window().canvas().trapMouse();
d->needTrapAfterClose = false;
}
d->untrapper.reset();

if(result > 0)
{
Expand Down

0 comments on commit 8173ce9

Please sign in to comment.