From 474d49dc146876b773bfef80335b740d1b1fa8a7 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 13 Feb 2007 21:06:45 +0000 Subject: Implement FR#1611172: GUI: Add autosave period widgets svn-id: r25563 --- gui/options.cpp | 22 ++++++++++++++++++++++ gui/options.h | 5 +++++ gui/theme-config.cpp | 2 ++ gui/themes/modern.ini | 2 ++ 4 files changed, 31 insertions(+) diff --git a/gui/options.cpp b/gui/options.cpp index aff32dbf4f..fb41c4bfcc 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -81,6 +81,10 @@ enum { }; #endif +static const char *savePeriodLabels[] = { "Never", "each 5 mins", "each 10 mins", "each 15 mins", "each 30 mins", 0 }; +static const int savePeriodValues[] = { 0, 5 * 60, 10 * 60, 15 * 60, 30 * 60, -1 }; + + OptionsDialog::OptionsDialog(const String &domain, int x, int y, int w, int h) : Dialog(x, y, w, h), _domain(domain) { @@ -697,6 +701,14 @@ GlobalOptionsDialog::GlobalOptionsDialog() new ButtonWidget(tab, "globaloptions_themebutton2", "Theme:", kChooseThemeCmd, 0); _curTheme = new StaticTextWidget(tab, "globaloptions_curtheme", g_gui.theme()->getThemeName()); + int labelWidth = g_gui.evaluator()->getVar("tabPopupsLabelW"); + + _autosavePeriodPopUp = new PopUpWidget(tab, "globaloptions_autosaveperiod", "Autosave: ", labelWidth); + + for (int i = 0; savePeriodLabels[i]; i++) { + _autosavePeriodPopUp->appendEntry(savePeriodLabels[i], savePeriodValues[i]); + } + // TODO: joystick setting @@ -748,6 +760,14 @@ void GlobalOptionsDialog::open() { _extraPath->setLabel(extraPath); } #endif + + // Misc Tab + _autosavePeriodPopUp->setSelected(1); + int value = ConfMan.getInt("autosave_period"); + for (int i = 0; savePeriodLabels[i]; i++) { + if (value == savePeriodValues[i]) + _autosavePeriodPopUp->setSelected(i); + } } void GlobalOptionsDialog::close() { @@ -762,6 +782,8 @@ void GlobalOptionsDialog::close() { String extraPath(_extraPath->getLabel()); if (!extraPath.empty() && (extraPath != "None")) ConfMan.set("extrapath", extraPath, _domain); + + ConfMan.setInt("autosave_period", _autosavePeriodPopUp->getSelectedTag(), _domain); } OptionsDialog::close(); } diff --git a/gui/options.h b/gui/options.h index 99dd50d368..1a1dfda2f0 100644 --- a/gui/options.h +++ b/gui/options.h @@ -155,7 +155,12 @@ protected: StaticTextWidget *_themePath; StaticTextWidget *_extraPath; + // + // Misc controls + // StaticTextWidget *_curTheme; + + PopUpWidget *_autosavePeriodPopUp; }; } // End of namespace GUI diff --git a/gui/theme-config.cpp b/gui/theme-config.cpp index 524518a689..fdcca9db6b 100644 --- a/gui/theme-config.cpp +++ b/gui/theme-config.cpp @@ -190,6 +190,8 @@ const char *Theme::_defaultConfigINI = "glOff=((buttonHeight - kLineHeight) / 2 + 2)\n" "globaloptions_themebutton2=10 yoffset buttonWidth buttonHeight\n" "globaloptions_curtheme=(prev.x2 + 20) (yoffset + glOff) (parent.w - (prev.w + 20) - 10) kLineHeight\n" +"yoffset=(yoffset + buttonHeight + 4)\n" +"globaloptions_autosaveperiod=10 yoffset (parent.w - 10 - 25) (kLineHeight + 2)\n" "\n" "globaloptions_cancel=(parent.w - 2 * (buttonWidth + 10)) (parent.h - buttonHeight - 8) buttonWidth buttonHeight\n" "globaloptions_ok=(prev.x2 + 10) prev.y prev.w prev.h\n" diff --git a/gui/themes/modern.ini b/gui/themes/modern.ini index 801994680b..fca576dc80 100644 --- a/gui/themes/modern.ini +++ b/gui/themes/modern.ini @@ -304,6 +304,8 @@ yoffset=vBorder glOff=((buttonHeight - kLineHeight) / 2 + 2) globaloptions_themebutton2=10 yoffset buttonWidth buttonHeight globaloptions_curtheme=(prev.x2 + 20) (yoffset + glOff) (parent.w - (prev.w + 20) - 10) kLineHeight +yoffset=(yoffset + buttonHeight + 12) +globaloptions_autosaveperiod=10 yoffset (parent.w - 10 - 25) kPopUpHeight globaloptions_cancel=(parent.w - 2 * (buttonWidth + 10)) (parent.h - buttonHeight - 8) buttonWidth buttonHeight globaloptions_ok=(prev.x2 + 10) prev.y prev.w prev.h -- cgit v1.2.3