Skip to content

Commit

Permalink
Shell|GUI|Mac OS X: Preferences dialog applies changes immediately
Browse files Browse the repository at this point in the history
Conforming to platform conventions.
  • Loading branch information
skyjake committed Mar 15, 2013
1 parent 88f5630 commit 81eab9b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions doomsday/tools/shell/shell-gui/src/folderselection.cpp
Expand Up @@ -58,6 +58,7 @@ DENG2_PIMPL(FolderSelection)
#else
button = new QPushButton(tr("..."));
#endif
button->setAutoDefault(false);

layout->addWidget(edit, 1);
layout->addWidget(button, 0);
Expand Down
4 changes: 4 additions & 0 deletions doomsday/tools/shell/shell-gui/src/guishellapp.cpp
Expand Up @@ -269,7 +269,11 @@ void GuiShellApp::showPreferences()
{
connect(d->prefs, SIGNAL(consoleFontChanged()), win, SLOT(updateConsoleFontFromPreferences()));
}
#ifdef MACOSX
d->prefs->show();
#else
d->prefs->open();
#endif
}
else
{
Expand Down
18 changes: 18 additions & 0 deletions doomsday/tools/shell/shell-gui/src/preferences.cpp
Expand Up @@ -10,6 +10,10 @@
#include <QLabel>
#include <QFontDialog>

#ifdef MACOSX
# define PREFS_APPLY_IMMEDIATELY
#endif

DENG2_PIMPL(Preferences)
{
QCheckBox *useCustomIwad;
Expand Down Expand Up @@ -38,6 +42,7 @@ DENG2_PIMPL(Preferences)
fontDesc = new QLabel;

QPushButton *selFont = new QPushButton(tr("Select..."));
selFont->setAutoDefault(false);
QObject::connect(selFont, SIGNAL(clicked()), thisPublic, SLOT(selectFont()));

QHBoxLayout *fl = new QHBoxLayout;
Expand Down Expand Up @@ -66,6 +71,11 @@ DENG2_PIMPL(Preferences)

mainLayout->addStretch(1);

#ifndef PREFS_APPLY_IMMEDIATELY

// On Mac, changes to the preferences are applied immediately.
// Other platforms use OK/Cancel buttons.

// Buttons.
QDialogButtonBox *bbox = new QDialogButtonBox;
mainLayout->addWidget(bbox);
Expand All @@ -76,6 +86,7 @@ DENG2_PIMPL(Preferences)
QObject::connect(no, SIGNAL(clicked()), &self, SLOT(reject()));
QObject::connect(act, SIGNAL(clicked()), &self, SLOT(saveState()));
yes->setDefault(true);
#endif
}

void updateFontDesc()
Expand Down Expand Up @@ -107,6 +118,9 @@ Preferences::Preferences(QWidget *parent) :
{
connect(d->useCustomIwad, SIGNAL(toggled(bool)), this, SLOT(validate()));
connect(this, SIGNAL(accepted()), this, SLOT(saveState()));
#ifdef PREFS_APPLY_IMMEDIATELY
connect(d->iwadFolder, SIGNAL(selected()), this, SLOT(saveState()));
#endif
validate();
}

Expand Down Expand Up @@ -151,5 +165,9 @@ void Preferences::selectFont()
{
d->consoleFont = font;
d->updateFontDesc();

#ifdef PREFS_APPLY_IMMEDIATELY
saveState();
#endif
}
}

0 comments on commit 81eab9b

Please sign in to comment.