Skip to content

Commit

Permalink
Updater|Mac OS X: Fine-tuning
Browse files Browse the repository at this point in the history
Switch to windowed mode when showing one of the updater dialogs.
The current fullscreen mode implementation would cause the main
window to overlap the dialogs.

"update" and "update config" commands are now operational.
  • Loading branch information
skyjake committed Jun 7, 2012
1 parent 120afbe commit f0786af
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 5 deletions.
14 changes: 13 additions & 1 deletion doomsday/engine/portable/src/dd_main.c
Expand Up @@ -127,16 +127,28 @@ static Game* nullGame; // Special "null-game" object.

D_CMD(CheckForUpdates)
{
Updater_ShowSettings();
Con_Message("Checking for available updates...\n");
Updater_CheckNow();
return true;
}

D_CMD(Update)
{
if(!stricmp(argv[1], "config"))
{
Updater_ShowSettings();
return true;
}
return false;
}

/**
* Register the engine commands and variables.
*/
void DD_Register(void)
{
C_CMD("update", "", CheckForUpdates);
C_CMD("update", "s", Update);

DD_RegisterLoop();
DD_RegisterInput();
Expand Down
57 changes: 54 additions & 3 deletions doomsday/engine/portable/src/updater.cpp
Expand Up @@ -25,13 +25,15 @@
#include "dd_version.h"
#include "dd_types.h"
#include "nativeui.h"
#include "window.h"
#include "json.h"
#include "updater.h"
#include "updater/downloaddialog.h"
#include "updater/updateavailabledialog.h"
#include "updater/updatersettings.h"
#include "updater/updatersettingsdialog.h"
#include "updater/versioninfo.h"
#include <de/c_wrapper.h>
#include <de/App>
#include <de/Time>
#include <de/Log>
Expand All @@ -44,6 +46,8 @@
#include <QDir>
#include <QDebug>

extern LegacyCore* de2LegacyCore;

static Updater* updater = 0;

#ifdef MACOSX
Expand Down Expand Up @@ -81,6 +85,26 @@ static void runInstallerCommand(void)
installerCommand = 0;
}

static bool switchToWindowedMode()
{
bool wasFull = Window_IsFullscreen(Window_Main());
if(wasFull)
{
int attribs[] = { DDWA_FULLSCREEN, false, DDWA_END };
Window_ChangeAttributes(Window_Main(), attribs);
}
return wasFull;
}

static void switchBackToFullscreen(bool wasFull)
{
if(wasFull)
{
int attribs[] = { DDWA_FULLSCREEN, true, DDWA_END };
Window_ChangeAttributes(Window_Main(), attribs);
}
}

struct Updater::Instance
{
Updater* self;
Expand Down Expand Up @@ -190,14 +214,21 @@ struct Updater::Instance
// Is this newer than what we're running?
if(latestVersion > currentVersion || alwaysShowNotification)
{
UpdateAvailableDialog dlg(latestVersion, latestLogUri);
// Automatically switch to windowed mode for convenience.
bool wasFull = switchToWindowedMode();

UpdateAvailableDialog dlg(latestVersion, latestLogUri, Window_Widget(Window_Main()));
if(dlg.exec())
{
LOG_MSG("Download and install.");
download = new DownloadDialog(latestPackageUri);
QObject::connect(download, SIGNAL(finished(int)), self, SLOT(downloadCompleted(int)));
download->show();
}
else
{
switchBackToFullscreen(wasFull);
}
}
}

Expand Down Expand Up @@ -349,11 +380,31 @@ Updater* Updater_Instance(void)

void Updater_CheckNow(void)
{
if(novideo || !updater) return;

updater->checkNow();
}

static void showSettingsDialog(void)
{
UpdaterSettingsDialog* st = new UpdaterSettingsDialog(Window_Widget(Window_Main()));
QObject::connect(st, SIGNAL(finished(int)), st, SLOT(deleteLater()));
st->open();
}

void Updater_ShowSettings(void)
{
UpdaterSettingsDialog st;
st.exec();
if(novideo || !updater) return;

// Automatically switch to windowed mode for convenience.
int delay = 0;
if(switchToWindowedMode())
{
// The mode switch takes a while and may include deferred window resizing,
// so let's wait a while before opening the dialog to make sure everything
// has settled.
/// @todo Improve the mode changes so that this is not needed.
delay = 500;
}
LegacyCore_Timer(de2LegacyCore, delay, showSettingsDialog);
}
Expand Up @@ -117,7 +117,7 @@ void UpdateAvailableDialog::showWhatsNew()

void UpdateAvailableDialog::editSettings()
{
UpdaterSettingsDialog st;
UpdaterSettingsDialog st(this);
if(st.exec())
{
d->neverCheck->setChecked(UpdaterSettings().onlyCheckManually());
Expand Down

0 comments on commit f0786af

Please sign in to comment.