Merge pull request #4676 from jmarshallnz/dont_set_scraper_on_tvshow_on_nfo
[vuplus_xbmc] / xbmc / addons / GUIDialogAddonSettings.h
1 #pragma once
2 /*
3  *      Copyright (C) 2005-2013 Team XBMC
4  *      http://xbmc.org
5  *
6  *  This Program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2, or (at your option)
9  *  any later version.
10  *
11  *  This Program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with XBMC; see the file COPYING.  If not, see
18  *  <http://www.gnu.org/licenses/>.
19  *
20  */
21
22 #include "dialogs/GUIDialogBoxBase.h"
23 #include "addons/Addon.h"
24
25 class CGUIDialogAddonSettings : public CGUIDialogBoxBase
26 {
27 public:
28   CGUIDialogAddonSettings(void);
29   virtual ~CGUIDialogAddonSettings(void);
30   virtual bool OnMessage(CGUIMessage& message);
31   virtual bool OnAction(const CAction& action);
32   /*! \brief Show the addon settings dialog, allowing the user to configure an addon
33    \param addon the addon to configure
34    \param saveToDisk whether the changes should be saved to disk or just made local to the addon.  Defaults to true
35    \return true if settings were changed and the dialog confirmed, false otherwise.
36    */
37   static bool ShowAndGetInput(const ADDON::AddonPtr &addon, bool saveToDisk = true);
38   virtual void DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions);
39
40   CStdString GetCurrentID() const;
41 protected:
42   virtual void OnInitWindow();
43   virtual int GetDefaultLabelID(int controlId) const;
44
45 private:
46   /*! \brief return a (localized) addon string.
47    \param value either a character string (which is used directly) or a number to lookup in the addons strings.xml
48    \param subsetting whether the character string should be prefixed by "- ", defaults to false
49    \return the localized addon string
50    */
51   CStdString GetString(const char *value, bool subSetting = false) const;
52
53   /*! \brief return a the values for a fileenum setting
54    \param path the path to use for files
55    \param mask the mask to use
56    \param options any options, such as "hideext" to hide extensions
57    \return the filenames in the path that match the mask
58    */
59   std::vector<std::string> GetFileEnumValues(const CStdString &path, const CStdString &mask, const CStdString &options) const;
60
61   /*! \brief Translate list of addon IDs to list of addon names
62    \param addonIDslist comma seperated list of addon IDs
63    \return comma seperated list of addon names
64    */
65   CStdString GetAddonNames(const CStdString& addonIDslist) const;
66
67   void CreateSections();
68   void FreeSections();
69   void CreateControls();
70   void FreeControls();
71   void UpdateFromControls();
72   void EnableControls();
73   void SetDefaultSettings();
74   bool GetCondition(const CStdString &condition, const int controlId);
75
76   void SaveSettings(void);
77   bool ShowVirtualKeyboard(int iControl);
78   bool TranslateSingleString(const CStdString &strCondition, std::vector<CStdString> &enableVec);
79
80   const TiXmlElement *GetFirstSetting() const;
81
82   ADDON::AddonPtr m_addon;
83   std::map<CStdString,CStdString> m_buttonValues;
84   bool m_changed;
85   bool m_saveToDisk; // whether the addon settings should be saved to disk or just stored locally in the addon
86
87   unsigned int m_currentSection;
88   unsigned int m_totalSections;
89
90   std::map<CStdString,CStdString> m_settings; // local storage of values
91 };
92