settings: add a "Reset above settings to default" control at the end of every setting...
authormontellese <montellese@xbmc.org>
Fri, 25 Oct 2013 16:41:45 +0000 (18:41 +0200)
committermontellese <montellese@xbmc.org>
Thu, 31 Oct 2013 21:54:31 +0000 (22:54 +0100)
language/English/strings.po
xbmc/settings/windows/GUIWindowSettingsCategory.cpp
xbmc/settings/windows/GUIWindowSettingsCategory.h

index 4d3e6ff..20c3382 100755 (executable)
@@ -4162,19 +4162,19 @@ msgid "Reset"
 msgstr ""
 
 msgctxt "#10036"
-msgid "Level: Basic"
+msgid "Basic"
 msgstr ""
 
 msgctxt "#10037"
-msgid "Level: Standard"
+msgid "Standard"
 msgstr ""
 
 msgctxt "#10038"
-msgid "Level: Advanced"
+msgid "Advanced"
 msgstr ""
 
 msgctxt "#10039"
-msgid "Level: Expert"
+msgid "Expert"
 msgstr ""
 
 #: xbmc/guilib/WindowIDs.h
@@ -4182,10 +4182,12 @@ msgctxt "#10040"
 msgid "Add-on browser"
 msgstr ""
 
+#: xbmc/settings/windows/GUIWindowSettingsCategory.cpp
 msgctxt "#10041"
-msgid "Reset settings"
+msgid "Reset above settings to default"
 msgstr ""
 
+#: xbmc/settings/windows/GUIWindowSettingsCategory.cpp
 msgctxt "#10042"
 msgid "Are you sure you want to reset the settings in this category?"
 msgstr ""
@@ -4198,7 +4200,11 @@ msgctxt "#10044"
 msgid "No help available"
 msgstr ""
 
-#empty strings from id 10045 to 10099
+msgctxt "#10045"
+msgid "Resets all the visible settings to their default values."
+msgstr ""
+
+#empty strings from id 10046 to 10099
 
 #: xbmc/guilib/WindowIDs.h
 msgctxt "#10100"
index e213da0..1175303 100644 (file)
@@ -72,6 +72,8 @@ using namespace std;
 #define CONTROL_START_CONTROL           -80
 #define CONTRL_BTN_LEVELS               20
 
+#define RESET_SETTING_ID                "settings.reset"
+
 typedef struct {
   int id;
   string name;
@@ -93,6 +95,7 @@ CGUIWindowSettingsCategory::CGUIWindowSettingsCategory(void)
     : CGUIWindow(WINDOW_SETTINGS_MYPICTURES, "SettingsCategory.xml"),
       m_settings(CSettings::Get()),
       m_iSetting(0), m_iCategory(0), m_iSection(0),
+      m_resetSetting(NULL),
       m_pOriginalSpin(NULL),
       m_pOriginalRadioButton(NULL),
       m_pOriginalCategoryButton(NULL),
@@ -127,6 +130,8 @@ CGUIWindowSettingsCategory::~CGUIWindowSettingsCategory(void)
     delete m_pOriginalEdit;
     m_pOriginalEdit = NULL;
   }
+
+  delete m_resetSetting;
 }
 
 bool CGUIWindowSettingsCategory::OnMessage(CGUIMessage &message)
@@ -142,6 +147,11 @@ bool CGUIWindowSettingsCategory::OnMessage(CGUIMessage &message)
         m_iCategory = 0;
         ResetControlStates();
       }
+
+      m_resetSetting = new CSettingAction(RESET_SETTING_ID);
+      m_resetSetting->SetLabel(10041);
+      m_resetSetting->SetHelp(10045);
+
       
       m_iSection = (int)message.GetParam2() - (int)CGUIWindow::GetID();
       CGUIWindow::OnMessage(message);
@@ -593,6 +603,13 @@ void CGUIWindowSettingsCategory::CreateSettings()
 
   if (!settingMap.empty())
     m_settings.RegisterCallback(this, settingMap);
+
+  if (!settingMap.empty())
+  {
+    // add "Reset" control
+    AddSeparator(group->GetWidth(), iControlID);
+    AddSetting(m_resetSetting, group->GetWidth(), iControlID);
+  }
   
   // update our settings (turns controls on/off as appropriate)
   UpdateSettings();
@@ -758,6 +775,12 @@ CGUIControl* CGUIWindowSettingsCategory::AddSettingControl(CGUIControl *pControl
 
 void CGUIWindowSettingsCategory::OnClick(BaseSettingControlPtr pSettingControl)
 {
+  if (pSettingControl->GetSetting()->GetId() == RESET_SETTING_ID)
+  {
+    OnAction(CAction(ACTION_SETTINGS_RESET));
+    return;
+  }
+
   // we need to first set the delayed setting and then execute OnClick()
   // because OnClick() triggers OnSettingChanged() and there we need to
   // know if the changed setting is delayed or not
index f5b9f4b..696c31c 100644 (file)
@@ -89,6 +89,7 @@ protected:
   int m_iSetting;
   int m_iCategory;
   int m_iSection;
+  CSettingAction *m_resetSetting;
   
   CGUISpinControlEx *m_pOriginalSpin;
   CGUIRadioButtonControl *m_pOriginalRadioButton;