Skip to content

Commit

Permalink
UI|Renderer Settings: Option to reset the entire profile; UI improvem…
Browse files Browse the repository at this point in the history
…ents

The various popup dialogs now use buttons that clearly state the
action to be taken.
  • Loading branch information
skyjake committed Sep 10, 2013
1 parent 7431cab commit 64b2cbd
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 4 deletions.
2 changes: 1 addition & 1 deletion doomsday/client/include/ui/dialogs/inputdialog.h
Expand Up @@ -28,7 +28,7 @@
class InputDialog : public MessageDialog
{
public:
InputDialog(de::String const &name = "");
InputDialog(de::String const &name = "");
~InputDialog();

LineEditWidget &editor();
Expand Down
Expand Up @@ -40,6 +40,7 @@ protected slots:
void editProfile();
void renameProfile();
void duplicateProfile();
void resetProfile();
void deleteProfile();
void applySelectedAppearance();

Expand Down
2 changes: 2 additions & 0 deletions doomsday/client/include/ui/widgets/dialogwidget.h
Expand Up @@ -147,6 +147,8 @@ class DialogWidget : public PopupWidget
*/
void open();

ui::ActionItem *defaultActionItem();

// Events.
void update();
bool handleEvent(de::Event const &event);
Expand Down
5 changes: 5 additions & 0 deletions doomsday/client/src/settingsregister.cpp
Expand Up @@ -533,6 +533,11 @@ void SettingsRegister::setProfile(String const &name)
void SettingsRegister::resetToDefaults()
{
d->reset();

DENG2_FOR_AUDIENCE(ProfileChange, i)
{
i->currentProfileChanged(d->current);
}
}

void SettingsRegister::resetSettingToDefaults(String const &settingName)
Expand Down
27 changes: 24 additions & 3 deletions doomsday/client/src/ui/dialogs/renderersettingsdialog.cpp
Expand Up @@ -246,6 +246,7 @@ void RendererSettingsDialog::showAppearanceMenu()
<< new Item(Item::Separator)
<< new ActionItem(tr("Add Duplicate..."), new SignalAction(this, SLOT(duplicateProfile())))
<< new Item(Item::Separator)
<< new ActionItem(tr("Reset to Defaults..."), new SignalAction(this, SLOT(resetProfile())))
<< new ActionItem(tr("Delete..."), new SignalAction(this, SLOT(deleteProfile())));
add(popup);

Expand All @@ -259,11 +260,12 @@ void RendererSettingsDialog::showAppearanceMenu()
org.itemWidget(0)->disable();
org.itemWidget(1)->disable();
org.itemWidget(5)->disable();
org.itemWidget(6)->disable();
}
if(reg.profileCount() == 1)
{
// The last profile cannot be deleted.
org.itemWidget(5)->disable();
org.itemWidget(6)->disable();
}

popup->setDeleteAfterDismissed(true);
Expand All @@ -289,6 +291,7 @@ void RendererSettingsDialog::renameProfile()
InputDialog dlg;
dlg.title().setText(tr("Renaming \"%1\"").arg(d->currentAppearance()));
dlg.message().setText(tr("Enter a new name for the appearance profile:"));
dlg.defaultActionItem()->setLabel(tr("Rename Profile"));

dlg.editor().setText(d->currentAppearance());

Expand Down Expand Up @@ -322,6 +325,7 @@ void RendererSettingsDialog::duplicateProfile()
InputDialog dlg;
dlg.title().setText(tr("Duplicating \"%1\"").arg(d->currentAppearance()));
dlg.message().setText(tr("Enter a name for the new appearance profile:"));
dlg.defaultActionItem()->setLabel(tr("Duplicate Profile"));

if(dlg.exec(root()))
{
Expand All @@ -346,6 +350,23 @@ void RendererSettingsDialog::duplicateProfile()
}
}

void RendererSettingsDialog::resetProfile()
{
MessageDialog dlg;
dlg.title().setText(tr("Reset?").arg(d->currentAppearance()));
dlg.message().setText(tr("Are you sure you want to reset the appearance profile %1 to the default values?")
.arg(_E(b) + d->currentAppearance() + _E(.)));

dlg.buttons().items()
<< new DialogButtonItem(DialogWidget::Default | DialogWidget::Reject)
<< new DialogButtonItem(DialogWidget::Accept, tr("Reset Profile"));

if(dlg.exec(root()))
{
ClientApp::rendererAppearanceSettings().resetToDefaults();
}
}

void RendererSettingsDialog::deleteProfile()
{
MessageDialog dlg;
Expand All @@ -354,8 +375,8 @@ void RendererSettingsDialog::deleteProfile()
tr("Are you sure you want to delete the appearance profile %1? This cannot be undone.")
.arg(_E(b) + d->currentAppearance() + _E(.)));
dlg.buttons().items()
<< new DialogButtonItem(DialogWidget::Default | DialogWidget::No)
<< new DialogButtonItem(DialogWidget::Yes);
<< new DialogButtonItem(DialogWidget::Default | DialogWidget::Reject)
<< new DialogButtonItem(DialogWidget::Accept, tr("Delete Profile"));

if(!dlg.exec(root())) return;

Expand Down
5 changes: 5 additions & 0 deletions doomsday/client/src/ui/widgets/dialogwidget.cpp
Expand Up @@ -412,6 +412,11 @@ void DialogWidget::open()
prepare();
}

ui::ActionItem *DialogWidget::defaultActionItem()
{
return const_cast<ui::ActionItem *>(d->findDefaultAction());
}

void DialogWidget::update()
{
PopupWidget::update();
Expand Down

0 comments on commit 64b2cbd

Please sign in to comment.