From 33ecb13d2de0b948b23ebef3eaf2e24f827ee88c Mon Sep 17 00:00:00 2001 From: ksooo <3226626+ksooo@users.noreply.github.com> Date: Sun, 1 Jan 2023 16:15:08 +0100 Subject: [PATCH] [PVR][Estuary] Timer settings dialog: Show client name in timer type selection dialog if more than one client supports timers. --- addons/skin.estuary/xml/Includes_DialogSelect.xml | 42 +++++++++++++++++++ xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp | 31 +++++++++++++- xbmc/settings/SettingControl.h | 4 ++ .../dialogs/GUIDialogSettingsManualBase.cpp | 49 ++++++++++++++-------- .../settings/dialogs/GUIDialogSettingsManualBase.h | 32 ++++++++++---- xbmc/settings/lib/SettingDefinitions.h | 18 ++++++-- xbmc/settings/windows/GUIControlSettings.cpp | 9 +++- 7 files changed, 151 insertions(+), 34 deletions(-) diff --git a/addons/skin.estuary/xml/Includes_DialogSelect.xml b/addons/skin.estuary/xml/Includes_DialogSelect.xml index 85e49bdc55..3d0daeaf36 100644 --- a/addons/skin.estuary/xml/Includes_DialogSelect.xml +++ b/addons/skin.estuary/xml/Includes_DialogSelect.xml @@ -54,6 +54,27 @@ 110 $VAR[InfoWallThumbVar] keep + !ListItem.Property(PVR.IsRecordingTimer) + !ListItem.Property(PVR.IsRemindingTimer) + + + 27 + 22 + 80 + 80 + keep + center + icons/pvr/timers/recording.png + ListItem.Property(PVR.IsRecordingTimer) + + + 27 + 22 + 80 + 80 + keep + center + icons/pvr/timers/bell.png + ListItem.Property(PVR.IsRemindingTimer) 135 @@ -90,6 +111,27 @@ 110 $VAR[InfoWallThumbVar] keep + !ListItem.Property(PVR.IsRecordingTimer) + !ListItem.Property(PVR.IsRemindingTimer) + + + 27 + 22 + 80 + 80 + keep + center + icons/pvr/timers/recording.png + ListItem.Property(PVR.IsRecordingTimer) + + + 27 + 22 + 80 + 80 + keep + center + icons/pvr/timers/bell.png + ListItem.Property(PVR.IsRemindingTimer) 135 diff --git a/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp b/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp index dfb8d84f66..8c17467026 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp @@ -240,7 +240,26 @@ void CGUIDialogPVRTimerSettings::InitializeSettings() std::shared_ptr setting = NULL; // Timer type - setting = AddList(group, SETTING_TMR_TYPE, 803, SettingLevel::Basic, 0, TypesFiller, 803); + bool useDetails = false; + bool foundClientSupportingTimers = false; + + const CPVRClientMap clients = CServiceBroker::GetPVRManager().Clients()->GetCreatedClients(); + for (const auto& client : clients) + { + if (client.second->GetClientCapabilities().SupportsTimers()) + { + if (foundClientSupportingTimers) + { + // found second client supporting timers, use detailed timer type list layout + useDetails = true; + break; + } + foundClientSupportingTimers = true; + } + } + + setting = AddList(group, SETTING_TMR_TYPE, 803, SettingLevel::Basic, 0, TypesFiller, 803, true, + -1, useDetails); AddTypeDependentEnableCondition(setting, SETTING_TMR_TYPE); // Timer enabled/disabled @@ -888,10 +907,18 @@ void CGUIDialogPVRTimerSettings::TypesFiller(const SettingConstPtr& setting, static const std::vector> recordingTimerProps{ std::make_pair("PVR.IsRecordingTimer", CVariant{true})}; + const auto clients = CServiceBroker::GetPVRManager().Clients(); + bool foundCurrent(false); for (const auto& typeEntry : pThis->m_typeEntries) { - list.emplace_back(typeEntry.second->GetDescription(), typeEntry.first, + std::string clientName; + + const auto client = clients->GetCreatedClient(typeEntry.second->GetClientId()); + if (client) + clientName = client->GetFriendlyName(); + + list.emplace_back(typeEntry.second->GetDescription(), clientName, typeEntry.first, typeEntry.second->IsReminder() ? reminderTimerProps : recordingTimerProps); if (!foundCurrent && (*(pThis->m_timerType) == *(typeEntry.second))) diff --git a/xbmc/settings/SettingControl.h b/xbmc/settings/SettingControl.h index 68e0e1d67c..c86f040e34 100644 --- a/xbmc/settings/SettingControl.h +++ b/xbmc/settings/SettingControl.h @@ -196,12 +196,16 @@ public: SettingControlListValueFormatter GetFormatter() const { return m_formatter; } void SetFormatter(SettingControlListValueFormatter formatter) { m_formatter = formatter; } + bool UseDetails() const { return m_useDetails; } + void SetUseDetails(bool useDetails) { m_useDetails = useDetails; } + protected: int m_heading = -1; bool m_multiselect = false; bool m_hideValue = false; int m_addButtonLabel = -1; SettingControlListValueFormatter m_formatter = nullptr; + bool m_useDetails{false}; }; class CSettingControlSlider; diff --git a/xbmc/settings/dialogs/GUIDialogSettingsManualBase.cpp b/xbmc/settings/dialogs/GUIDialogSettingsManualBase.cpp index 07f7ae34b1..84114db80c 100644 --- a/xbmc/settings/dialogs/GUIDialogSettingsManualBase.cpp +++ b/xbmc/settings/dialogs/GUIDialogSettingsManualBase.cpp @@ -697,7 +697,8 @@ std::shared_ptr CGUIDialogSettingsManualBase::AddList( StringSettingOptionsFiller filler, int heading, bool visible /* = true */, - int help /* = -1 */) + int help /* = -1 */, + bool details /* = false */) { if (group == NULL || id.empty() || label < 0 || filler == NULL || GetSetting(id) != NULL) @@ -707,7 +708,7 @@ std::shared_ptr CGUIDialogSettingsManualBase::AddList( if (setting == NULL) return NULL; - setting->SetControl(GetListControl("string", false, heading, false)); + setting->SetControl(GetListControl("string", false, heading, false, nullptr, details)); setting->SetOptionsFiller(filler, this); setSettingDetails(setting, level, visible, help); @@ -724,7 +725,8 @@ std::shared_ptr CGUIDialogSettingsManualBase::AddList( const TranslatableIntegerSettingOptions& entries, int heading, bool visible /* = true */, - int help /* = -1 */) + int help /* = -1 */, + bool details /* = false */) { if (group == NULL || id.empty() || label < 0 || entries.empty() || GetSetting(id) != NULL) @@ -734,7 +736,7 @@ std::shared_ptr CGUIDialogSettingsManualBase::AddList( if (setting == NULL) return NULL; - setting->SetControl(GetListControl("integer", false, heading, false)); + setting->SetControl(GetListControl("integer", false, heading, false, nullptr, details)); setting->SetTranslatableOptions(entries); setSettingDetails(setting, level, visible, help); @@ -751,7 +753,8 @@ std::shared_ptr CGUIDialogSettingsManualBase::AddList( const IntegerSettingOptions& entries, int heading, bool visible /* = true */, - int help /* = -1 */) + int help /* = -1 */, + bool details /* = false */) { if (group == NULL || id.empty() || label < 0 || entries.empty() || GetSetting(id) != NULL) @@ -761,7 +764,7 @@ std::shared_ptr CGUIDialogSettingsManualBase::AddList( if (setting == NULL) return NULL; - setting->SetControl(GetListControl("integer", false, heading, false)); + setting->SetControl(GetListControl("integer", false, heading, false, nullptr, details)); setting->SetOptions(entries); setSettingDetails(setting, level, visible, help); @@ -778,7 +781,8 @@ std::shared_ptr CGUIDialogSettingsManualBase::AddList( IntegerSettingOptionsFiller filler, int heading, bool visible /* = true */, - int help /* = -1 */) + int help /* = -1 */, + bool details /* = false */) { if (group == NULL || id.empty() || label < 0 || filler == NULL || GetSetting(id) != NULL) @@ -788,7 +792,7 @@ std::shared_ptr CGUIDialogSettingsManualBase::AddList( if (setting == NULL) return NULL; - setting->SetControl(GetListControl("integer", false, heading, false)); + setting->SetControl(GetListControl("integer", false, heading, false, nullptr, details)); setting->SetOptionsFiller(filler, this); setSettingDetails(setting, level, visible, help); @@ -807,7 +811,8 @@ std::shared_ptr CGUIDialogSettingsManualBase::AddList( int minimumItems /* = 0 */, int maximumItems /* = -1 */, bool visible /* = true */, - int help /* = -1 */) + int help /* = -1 */, + bool details /* = false */) { if (group == NULL || id.empty() || label < 0 || filler == NULL || GetSetting(id) != NULL) @@ -832,7 +837,7 @@ std::shared_ptr CGUIDialogSettingsManualBase::AddList( // setting the default will also set the actual value on an unchanged setting setting->SetDefault(settingValues); - setting->SetControl(GetListControl("string", false, heading, true)); + setting->SetControl(GetListControl("string", false, heading, true, nullptr, details)); setting->SetMinimumItems(minimumItems); setting->SetMaximumItems(maximumItems); setSettingDetails(setting, level, visible, help); @@ -852,7 +857,8 @@ std::shared_ptr CGUIDialogSettingsManualBase::AddList( int minimumItems /* = 0 */, int maximumItems /* = -1 */, bool visible /* = true */, - int help /* = -1 */) + int help /* = -1 */, + bool details /* = false */) { if (group == NULL || id.empty() || label < 0 || entries.empty() || GetSetting(id) != NULL) @@ -877,7 +883,7 @@ std::shared_ptr CGUIDialogSettingsManualBase::AddList( // setting the default will also set the actual value on an unchanged setting setting->SetDefault(settingValues); - setting->SetControl(GetListControl("integer", false, heading, true)); + setting->SetControl(GetListControl("integer", false, heading, true, nullptr, details)); setting->SetMinimumItems(minimumItems); setting->SetMaximumItems(maximumItems); setSettingDetails(setting, level, visible, help); @@ -897,7 +903,8 @@ std::shared_ptr CGUIDialogSettingsManualBase::AddList( int minimumItems /* = 0 */, int maximumItems /* = -1 */, bool visible /* = true */, - int help /* = -1 */) + int help /* = -1 */, + bool details /* = false */) { if (group == NULL || id.empty() || label < 0 || entries.empty() || GetSetting(id) != NULL) @@ -922,7 +929,7 @@ std::shared_ptr CGUIDialogSettingsManualBase::AddList( // setting the default will also set the actual value on an unchanged setting setting->SetDefault(settingValues); - setting->SetControl(GetListControl("integer", false, heading, true)); + setting->SetControl(GetListControl("integer", false, heading, true, nullptr, details)); setting->SetMinimumItems(minimumItems); setting->SetMaximumItems(maximumItems); setSettingDetails(setting, level, visible, help); @@ -943,7 +950,8 @@ std::shared_ptr CGUIDialogSettingsManualBase::AddList( int maximumItems /* = -1 */, bool visible /* = true */, int help /* = -1 */, - SettingControlListValueFormatter formatter /* = NULL */) + SettingControlListValueFormatter formatter /* = NULL */, + bool details /* = false */) { if (group == NULL || id.empty() || label < 0 || filler == NULL || GetSetting(id) != NULL) @@ -968,7 +976,7 @@ std::shared_ptr CGUIDialogSettingsManualBase::AddList( // setting the default will also set the actual value on an unchanged setting setting->SetDefault(settingValues); - setting->SetControl(GetListControl("integer", false, heading, true, formatter)); + setting->SetControl(GetListControl("integer", false, heading, true, formatter, details)); setting->SetMinimumItems(minimumItems); setting->SetMaximumItems(maximumItems); setSettingDetails(setting, level, visible, help); @@ -1550,7 +1558,13 @@ std::shared_ptr CGUIDialogSettingsManualBase::GetSpinnerControl return control; } -std::shared_ptr CGUIDialogSettingsManualBase::GetListControl(const std::string &format, bool delayed /* = false */, int heading /* = -1 */, bool multiselect /* = false */,SettingControlListValueFormatter formatter /* = NULL */) +std::shared_ptr CGUIDialogSettingsManualBase::GetListControl( + const std::string& format, + bool delayed /* = false */, + int heading /* = -1 */, + bool multiselect /* = false */, + SettingControlListValueFormatter formatter /* = NULL */, + bool details /* = false */) { std::shared_ptr control = std::make_shared(); if (!control->SetFormat(format)) @@ -1560,6 +1574,7 @@ std::shared_ptr CGUIDialogSettingsManualBase::GetListControl(co control->SetHeading(heading); control->SetMultiSelect(multiselect); control->SetFormatter(formatter); + control->SetUseDetails(details); return control; } diff --git a/xbmc/settings/dialogs/GUIDialogSettingsManualBase.h b/xbmc/settings/dialogs/GUIDialogSettingsManualBase.h index a877902dba..338259cb13 100644 --- a/xbmc/settings/dialogs/GUIDialogSettingsManualBase.h +++ b/xbmc/settings/dialogs/GUIDialogSettingsManualBase.h @@ -288,7 +288,8 @@ protected: StringSettingOptionsFiller filler, int heading, bool visible = true, - int help = -1); + int help = -1, + bool details = false); std::shared_ptr AddList(const std::shared_ptr& group, const std::string& id, int label, @@ -297,7 +298,8 @@ protected: const TranslatableIntegerSettingOptions& entries, int heading, bool visible = true, - int help = -1); + int help = -1, + bool details = false); std::shared_ptr AddList(const std::shared_ptr& group, const std::string& id, int label, @@ -306,7 +308,8 @@ protected: const IntegerSettingOptions& entries, int heading, bool visible = true, - int help = -1); + int help = -1, + bool details = false); std::shared_ptr AddList(const std::shared_ptr& group, const std::string& id, int label, @@ -315,7 +318,8 @@ protected: IntegerSettingOptionsFiller filler, int heading, bool visible = true, - int help = -1); + int help = -1, + bool details = false); std::shared_ptr AddList(const std::shared_ptr& group, const std::string& id, int label, @@ -326,7 +330,8 @@ protected: int minimumItems = 0, int maximumItems = -1, bool visible = true, - int help = -1); + int help = -1, + bool details = false); std::shared_ptr AddList(const std::shared_ptr& group, const std::string& id, int label, @@ -337,7 +342,8 @@ protected: int minimumItems = 0, int maximumItems = -1, bool visible = true, - int help = -1); + int help = -1, + bool details = false); std::shared_ptr AddList(const std::shared_ptr& group, const std::string& id, int label, @@ -348,7 +354,8 @@ protected: int minimumItems = 0, int maximumItems = -1, bool visible = true, - int help = -1); + int help = -1, + bool details = false); std::shared_ptr AddList(const std::shared_ptr& group, const std::string& id, int label, @@ -360,7 +367,8 @@ protected: int maximumItems = -1, bool visible = true, int help = -1, - SettingControlListValueFormatter formatter = NULL); + SettingControlListValueFormatter formatter = nullptr, + bool details = false); // slider controls std::shared_ptr AddPercentageSlider(const std::shared_ptr& group, @@ -588,7 +596,13 @@ protected: std::shared_ptr GetButtonControl(const std::string &format, bool delayed = false, int heading = -1, bool hideValue = false, bool showInstalledAddons = true, bool showInstallableAddons = false, bool showMoreAddons = true); std::shared_ptr GetSpinnerControl(const std::string &format, bool delayed = false, int minimumLabel = -1, int formatLabel = -1, const std::string &formatString = ""); - std::shared_ptr GetListControl(const std::string &format, bool delayed = false, int heading = -1, bool multiselect = false, SettingControlListValueFormatter formatter = NULL); + std::shared_ptr GetListControl( + const std::string& format, + bool delayed = false, + int heading = -1, + bool multiselect = false, + SettingControlListValueFormatter formatter = nullptr, + bool details = false); std::shared_ptr GetSliderControl(const std::string &format, bool delayed = false, int heading = -1, bool usePopup = false, int formatLabel = -1, const std::string &formatString = ""); std::shared_ptr GetRangeControl(const std::string &format, bool delayed = false, int formatLabel = -1, int valueFormatLabel = -1, const std::string &valueFormatString = ""); diff --git a/xbmc/settings/lib/SettingDefinitions.h b/xbmc/settings/lib/SettingDefinitions.h index 74aea817d7..ae18347760 100644 --- a/xbmc/settings/lib/SettingDefinitions.h +++ b/xbmc/settings/lib/SettingDefinitions.h @@ -68,11 +68,16 @@ struct IntegerSettingOption IntegerSettingOption(const std::string& _label, int _value) : label(_label), value(_value) {} - IntegerSettingOption(const std::string& _label, int _value, + IntegerSettingOption(const std::string& _label, + const std::string& _label2, + int _value, const std::vector>& props) - : label(_label), value(_value), properties(props) {} + : label(_label), label2(_label2), value(_value), properties(props) + { + } std::string label; + std::string label2; int value = 0; std::vector> properties; }; @@ -82,11 +87,16 @@ struct StringSettingOption StringSettingOption(const std::string& _label, const std::string& _value) : label(_label), value(_value) {} - StringSettingOption(const std::string& _label, const std::string& _value, + StringSettingOption(const std::string& _label, + const std::string& _label2, + const std::string& _value, const std::vector>& props) - : label(_label), value(_value), properties(props) {} + : label(_label), label2(_label2), value(_value), properties(props) + { + } std::string label; + std::string label2; std::string value; std::vector> properties; }; diff --git a/xbmc/settings/windows/GUIControlSettings.cpp b/xbmc/settings/windows/GUIControlSettings.cpp index 4dc8688cc7..fcbf1fa908 100644 --- a/xbmc/settings/windows/GUIControlSettings.cpp +++ b/xbmc/settings/windows/GUIControlSettings.cpp @@ -68,12 +68,14 @@ static std::string Localize(std::uint32_t code, template static CFileItemPtr GetFileItem(const std::string& label, + const std::string& label2, const TValueType& value, const std::vector>& properties, const std::set& selectedValues) { CFileItemPtr item(new CFileItem(label)); item->SetProperty("value", value); + item->SetLabel2(label2); for (const auto& prop : properties) item->SetProperty(prop.first, prop.second); @@ -678,6 +680,7 @@ bool CGUIControlListSetting::OnClick() dialog->SetHeading(CVariant{Localize(m_pSetting->GetLabel())}); dialog->SetItems(options); dialog->SetMultiSelection(control->CanMultiSelect()); + dialog->SetUseDetails(control->UseDetails()); dialog->Open(); if (!dialog->IsConfirmed()) @@ -897,7 +900,8 @@ bool CGUIControlListSetting::GetIntegerItems(const SettingConstPtr& setting, // turn them into CFileItems and add them to the item list for (const auto& option : options) - items.Add(GetFileItem(option.label, option.value, option.properties, selectedValues)); + items.Add( + GetFileItem(option.label, option.label2, option.value, option.properties, selectedValues)); return true; } @@ -914,7 +918,8 @@ bool CGUIControlListSetting::GetStringItems(const SettingConstPtr& setting, // turn them into CFileItems and add them to the item list for (const auto& option : options) - items.Add(GetFileItem(option.label, option.value, option.properties, selectedValues)); + items.Add( + GetFileItem(option.label, option.label2, option.value, option.properties, selectedValues)); return true; } -- 2.11.4.GIT