summaryrefslogtreecommitdiffstats
path: root/xbmc/music/dialogs/GUIDialogInfoProviderSettings.h
blob: 56a33b52d81a9f4a6c2187f8f2cfd1ee8cd3d212 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
 *  Copyright (C) 2017-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

#include "addons/Addon.h"
#include "addons/Scraper.h"
#include "settings/dialogs/GUIDialogSettingsManualBase.h"

#include <map>
#include <utility>

class CFileItemList;

// Enumeration of what combination of items to apply the scraper settings
enum INFOPROVIDERAPPLYOPTIONS
{
  INFOPROVIDER_DEFAULT = 0x0000,
  INFOPROVIDER_ALLVIEW = 0x0001,
  INFOPROVIDER_THISITEM = 0x0002
};

class CGUIDialogInfoProviderSettings : public CGUIDialogSettingsManualBase
{
public:
  CGUIDialogInfoProviderSettings();

  // specialization of CGUIWindow
  bool HasListItems() const override { return true; }

  const ADDON::ScraperPtr& GetAlbumScraper() const { return m_albumscraper; }
  void SetAlbumScraper(ADDON::ScraperPtr scraper) { m_albumscraper = std::move(scraper); }
  const ADDON::ScraperPtr& GetArtistScraper() const { return m_artistscraper; }
  void SetArtistScraper(ADDON::ScraperPtr scraper) { m_artistscraper = std::move(scraper); }

  /*! \brief Show dialog to change information provider for either artists or albums (not both).
   Has a list to select how settings are to be applied - as system default, to just current item or to all the filtered items on the node.
   This does not save the settings itself, that is left to the caller
  \param scraper [in/out] the selected scraper addon and settings. Scraper content must be artists or albums.
  \return 0 settings apply as system default, 1 to all items on node, 2 to just the selected item or -1 if dialog cancelled or error occurs
  */
  static int Show(ADDON::ScraperPtr& scraper);

  /*! \brief Show dialog to change the music scraping settings including default information providers for both artists or albums.
  This saves the settings when the dialog is confirmed.
  \return true if the dialog is confirmed, false otherwise
  */
  static bool Show();

protected:
  // specializations of CGUIWindow
  void OnInitWindow() override;

  // implementations of ISettingCallback
  void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override;
  void OnSettingAction(const std::shared_ptr<const CSetting>& setting) override;

  // specialization of CGUIDialogSettingsBase
  bool AllowResettingSettings() const override { return false; }
  bool Save() override;
  void SetupView() override;

  // specialization of CGUIDialogSettingsManualBase
  void InitializeSettings() override;

private:
  void SetLabel2(const std::string &settingid, const std::string &label);
  void ToggleState(const std::string &settingid, bool enabled);
  using CGUIDialogSettingsManualBase::SetFocus;
  void SetFocus(const std::string &settingid);
  void ResetDefaults();

  /*!
  * @brief The currently selected album scraper
  */
  ADDON::ScraperPtr m_albumscraper;
  /*!
  * @brief The currently selected artist scraper
  */
  ADDON::ScraperPtr m_artistscraper;

  std::string m_strArtistInfoPath;
  bool m_showSingleScraper = false;
  CONTENT_TYPE m_singleScraperType = CONTENT_NONE;
  bool m_fetchInfo;
  unsigned int m_applyToItems = INFOPROVIDER_THISITEM;
};