diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 18:07:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 18:07:22 +0000 |
commit | c04dcc2e7d834218ef2d4194331e383402495ae1 (patch) | |
tree | 7333e38d10d75386e60f336b80c2443c1166031d /xbmc/guilib/guiinfo/WeatherGUIInfo.cpp | |
parent | Initial commit. (diff) | |
download | kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip |
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xbmc/guilib/guiinfo/WeatherGUIInfo.cpp')
-rw-r--r-- | xbmc/guilib/guiinfo/WeatherGUIInfo.cpp | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/xbmc/guilib/guiinfo/WeatherGUIInfo.cpp b/xbmc/guilib/guiinfo/WeatherGUIInfo.cpp new file mode 100644 index 0000000..3aa2044 --- /dev/null +++ b/xbmc/guilib/guiinfo/WeatherGUIInfo.cpp @@ -0,0 +1,81 @@ +/* + * 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/WeatherGUIInfo.h" + +#include "FileItem.h" +#include "LangInfo.h" +#include "ServiceBroker.h" +#include "guilib/guiinfo/GUIInfo.h" +#include "guilib/guiinfo/GUIInfoLabels.h" +#include "settings/Settings.h" +#include "settings/SettingsComponent.h" +#include "utils/StringUtils.h" +#include "utils/URIUtils.h" +#include "weather/WeatherManager.h" + +using namespace KODI::GUILIB::GUIINFO; + +bool CWeatherGUIInfo::InitCurrentItem(CFileItem *item) +{ + return false; +} + +bool CWeatherGUIInfo::GetLabel(std::string& value, const CFileItem *item, int contextWindow, const CGUIInfo &info, std::string *fallback) const +{ + switch (info.m_info) + { + /////////////////////////////////////////////////////////////////////////////////////////////// + // WEATHER_* + /////////////////////////////////////////////////////////////////////////////////////////////// + case WEATHER_CONDITIONS_TEXT: + value = CServiceBroker::GetWeatherManager().GetInfo(WEATHER_LABEL_CURRENT_COND); + StringUtils::Trim(value); + return true; + case WEATHER_CONDITIONS_ICON: + value = CServiceBroker::GetWeatherManager().GetInfo(WEATHER_IMAGE_CURRENT_ICON); + return true; + case WEATHER_TEMPERATURE: + value = StringUtils::Format( + "{}{}", CServiceBroker::GetWeatherManager().GetInfo(WEATHER_LABEL_CURRENT_TEMP), + g_langInfo.GetTemperatureUnitString()); + return true; + case WEATHER_LOCATION: + value = CServiceBroker::GetWeatherManager().GetInfo(WEATHER_LABEL_LOCATION); + return true; + case WEATHER_FANART_CODE: + value = URIUtils::GetFileName(CServiceBroker::GetWeatherManager().GetInfo(WEATHER_IMAGE_CURRENT_ICON)); + URIUtils::RemoveExtension(value); + return true; + case WEATHER_PLUGIN: + value = CServiceBroker::GetSettingsComponent()->GetSettings()->GetString(CSettings::SETTING_WEATHER_ADDON); + return true; + } + + return false; +} + +bool CWeatherGUIInfo::GetInt(int& value, const CGUIListItem *gitem, int contextWindow, const CGUIInfo &info) const +{ + return false; +} + +bool CWeatherGUIInfo::GetBool(bool& value, const CGUIListItem *gitem, int contextWindow, const CGUIInfo &info) const +{ + switch (info.m_info) + { + /////////////////////////////////////////////////////////////////////////////////////////////// + // WEATHER_* + /////////////////////////////////////////////////////////////////////////////////////////////// + case WEATHER_IS_FETCHED: + value = CServiceBroker::GetWeatherManager().IsFetched(); + return true;; + } + + return false; +} |