Skip to content

Commit

Permalink
UI|Client|AlertDialog: Fixed layout problem when dialog is narrow
Browse files Browse the repository at this point in the history
Now space is reserved for the auto-hide setting.
  • Loading branch information
skyjake committed Oct 30, 2014
1 parent 1d32f4e commit 8f56388
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion doomsday/client/include/ui/dialogs/alertdialog.h
Expand Up @@ -66,7 +66,7 @@ public slots:
void showListOfAlerts();
void showLogFilterSettings();
void hideNotification();
void hideTimeChanged();
void autohideTimeChanged();

protected:
void finish(int result);
Expand Down
35 changes: 20 additions & 15 deletions doomsday/client/src/ui/dialogs/alertdialog.cpp
Expand Up @@ -88,7 +88,7 @@ DENG_GUI_PIMPL(AlertDialog)
bool clearOnDismiss;
TextStyling styling;
QTimer hideTimer; ///< Automatically hides the notification.
ChoiceWidget *hideTimes;
ChoiceWidget *autohideTimes;
DialogContentStylist stylist;

dsize maxCount;
Expand Down Expand Up @@ -275,17 +275,17 @@ DENG_GUI_PIMPL(AlertDialog)
return false;
}

void updateHideTimeSelection()
void updateAutohideTimeSelection()
{
int const time = autoHideAfterSeconds();
ui::DataPos pos = hideTimes->items().findData(time);
ui::DataPos pos = autohideTimes->items().findData(time);
if(pos != ui::Data::InvalidPos)
{
hideTimes->setSelected(pos);
autohideTimes->setSelected(pos);
}
else
{
hideTimes->setSelected(hideTimes->items().findData(0));
autohideTimes->setSelected(autohideTimes->items().findData(0));
}
}
};
Expand All @@ -309,25 +309,30 @@ AlertDialog::AlertDialog(String const &/*name*/) : d(new Instance(this))

auto *lab = LabelWidget::newWithText(tr("Hide After:"), this);

add(d->hideTimes = new ChoiceWidget);
d->hideTimes->items()
add(d->autohideTimes = new ChoiceWidget);
d->autohideTimes->items()
<< new ChoiceItem(tr("1 min"), 60)
<< new ChoiceItem(tr("3 mins"), 3 * 60)
<< new ChoiceItem(tr("5 mins"), 5 * 60)
<< new ChoiceItem(tr("10 mins"), 10 * 60)
<< new ChoiceItem(tr("Never"), 0);
d->updateHideTimeSelection();
d->updateAutohideTimeSelection();

lab->rule()
.setInput(Rule::Left, gearButton.rule().right())
.setInput(Rule::AnchorY, gearButton.rule().midY())
.setAnchorPoint(Vector2f(0, .5f));
.setInput(Rule::Left, gearButton.rule().right())
.setMidAnchorY(gearButton.rule().midY());

d->hideTimes->rule()
d->autohideTimes->rule()
.setInput(Rule::Left, lab->rule().right())
.setInput(Rule::Top, lab->rule().top());

connect(d->hideTimes, SIGNAL(selectionChangedByUser(uint)), this, SLOT(hideTimeChanged()));
// Tell the dialog about the additional space requirements.
setMinimumContentWidth(extraButtonsMenu().rule().width() +
buttonsMenu().rule().width() +
lab->rule().width() +
d->autohideTimes->rule().width());

connect(d->autohideTimes, SIGNAL(selectionChangedByUser(uint)), this, SLOT(autohideTimeChanged()));
}

void AlertDialog::newAlert(String const &message, Level level)
Expand Down Expand Up @@ -370,9 +375,9 @@ void AlertDialog::hideNotification()
d->hideNotification();
}

void AlertDialog::hideTimeChanged()
void AlertDialog::autohideTimeChanged()
{
App::config().set(VAR_AUTOHIDE, d->hideTimes->selectedItem().data().toInt());
App::config().set(VAR_AUTOHIDE, d->autohideTimes->selectedItem().data().toInt());
}

void AlertDialog::finish(int result)
Expand Down

0 comments on commit 8f56388

Please sign in to comment.