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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
/*
* Copyright (C) 2012-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.
*/
#include "guilib/guiinfo/VisualisationGUIInfo.h"
#include "GUIUserMessages.h"
#include "ServiceBroker.h"
#include "addons/Addon.h"
#include "addons/AddonManager.h"
#include "guilib/GUIComponent.h"
#include "guilib/GUIVisualisationControl.h"
#include "guilib/GUIWindowManager.h"
#include "guilib/guiinfo/GUIInfo.h"
#include "guilib/guiinfo/GUIInfoLabels.h"
#include "settings/Settings.h"
#include "settings/SettingsComponent.h"
#include "utils/URIUtils.h"
using namespace KODI::GUILIB::GUIINFO;
bool CVisualisationGUIInfo::InitCurrentItem(CFileItem *item)
{
return false;
}
bool CVisualisationGUIInfo::GetLabel(std::string& value, const CFileItem *item, int contextWindow, const CGUIInfo &info, std::string *fallback) const
{
switch (info.m_info)
{
///////////////////////////////////////////////////////////////////////////////////////////////
// VISUALISATION_*
///////////////////////////////////////////////////////////////////////////////////////////////
case VISUALISATION_PRESET:
{
CGUIMessage msg(GUI_MSG_GET_VISUALISATION, 0, 0);
CServiceBroker::GetGUI()->GetWindowManager().SendMessage(msg);
if (msg.GetPointer())
{
CGUIVisualisationControl* viz = static_cast<CGUIVisualisationControl*>(msg.GetPointer());
if (viz)
{
value = viz->GetActivePresetName();
URIUtils::RemoveExtension(value);
return true;
}
}
break;
}
case VISUALISATION_NAME:
{
ADDON::AddonPtr addon;
value = CServiceBroker::GetSettingsComponent()->GetSettings()->GetString(CSettings::SETTING_MUSICPLAYER_VISUALISATION);
if (CServiceBroker::GetAddonMgr().GetAddon(value, addon, ADDON::OnlyEnabled::CHOICE_YES) &&
addon)
{
value = addon->Name();
return true;
}
break;
}
}
return false;
}
bool CVisualisationGUIInfo::GetInt(int& value, const CGUIListItem *gitem, int contextWindow, const CGUIInfo &info) const
{
return false;
}
bool CVisualisationGUIInfo::GetBool(bool& value, const CGUIListItem *gitem, int contextWindow, const CGUIInfo &info) const
{
switch (info.m_info)
{
///////////////////////////////////////////////////////////////////////////////////////////////
// VISUALISATION_*
///////////////////////////////////////////////////////////////////////////////////////////////
case VISUALISATION_LOCKED:
{
CGUIMessage msg(GUI_MSG_GET_VISUALISATION, 0, 0);
CServiceBroker::GetGUI()->GetWindowManager().SendMessage(msg);
if (msg.GetPointer())
{
CGUIVisualisationControl *pVis = static_cast<CGUIVisualisationControl*>(msg.GetPointer());
value = pVis->IsLocked();
return true;
}
break;
}
case VISUALISATION_ENABLED:
{
value = !CServiceBroker::GetSettingsComponent()->GetSettings()->GetString(CSettings::SETTING_MUSICPLAYER_VISUALISATION).empty();
return true;
}
case VISUALISATION_HAS_PRESETS:
{
CGUIMessage msg(GUI_MSG_GET_VISUALISATION, 0, 0);
CServiceBroker::GetGUI()->GetWindowManager().SendMessage(msg);
if (msg.GetPointer())
{
CGUIVisualisationControl* viz = static_cast<CGUIVisualisationControl*>(msg.GetPointer());
value = (viz && viz->HasPresets());
return true;
}
break;
}
}
return false;
}
|