UPDATES: Hook dialogs to UpdateManager

This commit is contained in:
Eugene Sandulenko 2016-03-30 19:28:24 +02:00
parent 73784c6a84
commit 47985debe1
2 changed files with 25 additions and 3 deletions

View file

@ -1385,6 +1385,15 @@ void GlobalOptionsDialog::close() {
#ifdef USE_UPDATES #ifdef USE_UPDATES
ConfMan.setInt("updates_check", _updatesPopUp->getSelectedTag()); ConfMan.setInt("updates_check", _updatesPopUp->getSelectedTag());
if (g_system->getUpdateManager()) {
if (_updatesPopUp->getSelectedTag() == Common::UpdateManager::kUpdateIntervalNotSupported) {
g_system->getUpdateManager()->setAutomaticallyChecksForUpdates(Common::UpdateManager::kUpdateStateDisabled);
} else {
g_system->getUpdateManager()->setAutomaticallyChecksForUpdates(Common::UpdateManager::kUpdateStateEnabled);
g_system->getUpdateManager()->setUpdateCheckInterval(_updatesPopUp->getSelectedTag());
}
}
#endif #endif
} }

View file

@ -20,11 +20,11 @@
* *
*/ */
#include "common/str.h"
#include "common/system.h" #include "common/system.h"
#include "common/translation.h" #include "common/translation.h"
#include "common/updates.h" #include "common/updates.h"
#include "common/config-manager.h" #include "common/config-manager.h"
#include "gui/updates-dialog.h" #include "gui/updates-dialog.h"
#include "gui/gui-manager.h" #include "gui/gui-manager.h"
#include "gui/ThemeEval.h" #include "gui/ThemeEval.h"
@ -106,8 +106,10 @@ UpdatesDialog::UpdatesDialog() : Dialog(30, 20, 260, 124) {
int yesButtonPos = (_w - (buttonWidth * 2)) / 2; int yesButtonPos = (_w - (buttonWidth * 2)) / 2;
int noButtonPos = ((_w - (buttonWidth * 2)) / 2) + buttonWidth + 10; int noButtonPos = ((_w - (buttonWidth * 2)) / 2) + buttonWidth + 10;
_yesButton = new ButtonWidget(this, yesButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, _("Yes"), 0, kYesCmd, Common::ASCII_RETURN); _yesButton = new ButtonWidget(this, yesButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight,
_noButton = new ButtonWidget(this, noButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, _("No"), 0, kNoCmd, Common::ASCII_ESCAPE); _("Yes"), 0, kYesCmd, Common::ASCII_RETURN);
_noButton = new ButtonWidget(this, noButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight,
_("No"), 0, kNoCmd, Common::ASCII_ESCAPE);
_state = 0; _state = 0;
} }
@ -125,10 +127,21 @@ void UpdatesDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
draw(); draw();
} else { } else {
ConfMan.setInt("updates_check", _updatesPopUp->getSelectedTag()); ConfMan.setInt("updates_check", _updatesPopUp->getSelectedTag());
if (g_system->getUpdateManager()) {
if (_updatesPopUp->getSelectedTag() == Common::UpdateManager::kUpdateIntervalNotSupported) {
g_system->getUpdateManager()->setAutomaticallyChecksForUpdates(Common::UpdateManager::kUpdateStateDisabled);
} else {
g_system->getUpdateManager()->setAutomaticallyChecksForUpdates(Common::UpdateManager::kUpdateStateEnabled);
g_system->getUpdateManager()->setUpdateCheckInterval(_updatesPopUp->getSelectedTag());
}
}
close(); close();
} }
} else if (cmd == kNoCmd) { } else if (cmd == kNoCmd) {
ConfMan.setInt("updates_check", Common::UpdateManager::kUpdateIntervalNotSupported); ConfMan.setInt("updates_check", Common::UpdateManager::kUpdateIntervalNotSupported);
g_system->getUpdateManager()->setAutomaticallyChecksForUpdates(Common::UpdateManager::kUpdateStateDisabled);
close(); close();
} else { } else {
Dialog::handleCommand(sender, cmd, data); Dialog::handleCommand(sender, cmd, data);