xbmc/xbmc — pull request #4512 by Montellese (2014-04-04 16:10:07+00:00)
Title: Unification of CGUIDialogSettings and CGUIWindowSettingsCategory

This is some work I've wanted to do ever since I've finished the settings refactor but I never had the time/motivation. But now I'm stuck with my media import work on a dialog where I need some settings and I didn't wanna copy & duplicate all the necessary logic like so many dialogs which show some settings already do. So I started working on unifying CGUIDialogSettings and CGUIWindowSettingsCategory into the same code base.

What came out is
* CGUIDialogSettingsBase which contains all the logic to display categories, groups and settings from a CSettingSection object
* CGUIDialogSettingsManagerBase derived from CGUIDialogSettingsBase which uses a CSettingsManager instance to provide the CSettingSection object
* CGUIWindowSettingsCategory derived from CGUIDialogSettingsManagerBase which simply injects the CSettingsManager instance contained in CSettings
* CGUIDialogSettingsManualBase derived from CGUIDialogSettingsManagerBase which provides a lot of methods (AddToggle, AddButton, AddEdit, AddSlider, AddRange, ...) to add settings as specific controls which results in the on-the-fly creation of settings which are stored in a CSettingsManager instance. This is basically the replacement for CGUIDialogSettings
* support for slider and range controls in any settings window/dialog
* easier support for dependencies between settings
* the possibility for skinners to use the exact same control IDs across all dialogs/windows which contain some settings

Unfortunately the last point is only a problem because it results in backwards incompatibility. Right now every dialog containing settings uses different control IDs for the different setting types (which is very stupid but that's the way it is). If this is a problem I can add virtual overridable methods to CGUIDialogSettingsBase which allows every dialog implementation to specify the control ID for the different setting controls. But TBH I wouldn't really like doing that.

Another problem is that not all affected skin XML files contain all the necessary controls. So I had to make all the controls optional in CGUIDialogSettingsBase. That however means that if a skin doesn't contain all the necessary controls (which may differ depending on the dialog but it wouldn't hurt if all were present) the settings using those controls simply wouldn't show and it wouldn't be obvious to the user that something is missing. It's even possible that some skins might crash XBMC because in some dialogs the control ID 2 is the dialog header whereas in others it's an actual control and there's some calls to free setting controls which doesn't end well in those cases.

I've adjusted all the dialogs that are currently based on CGUIDialogSettings but I couldn't test CGUIDialogPVRTimerSettings because I don't have a PVR setup so I can't really open the dialog.

This work also doesn't contain the conversion of CGUIDialogAddonSettings to the new CGUIDialogSettingsManualBase because it is currently completely independent of CGUIDialogSettings and has some features which aren't present in the settings library I wrote.

If preferred I can extract some of the commits from this PR into separate PRs because there are a few commits which IMO make sense independent of the whole dialog unification stuff. But I'll do that once Gotham is out the door and there's a chance for this to get merged. Otherwise it becomes too difficult to work on potential fixes.