void CPeripherals::OnSettingAction(const CSetting *setting) { if (setting == NULL) return; const std::string &settingId = setting->GetId(); if (settingId == CSettings::SETTING_INPUT_PERIPHERALS) { CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); CFileItemList items; GetDirectory("peripherals://all/", items); int iPos = -1; do { pDialog->Reset(); pDialog->SetHeading(CVariant{35000}); pDialog->SetUseDetails(true); pDialog->SetItems(items); pDialog->SetSelected(iPos); pDialog->Open(); iPos = pDialog->IsConfirmed() ? pDialog->GetSelectedLabel() : -1; if (iPos >= 0) { CFileItemPtr pItem = items.Get(iPos); CGUIDialogPeripheralSettings *pSettingsDialog = (CGUIDialogPeripheralSettings *)g_windowManager.GetWindow(WINDOW_DIALOG_PERIPHERAL_SETTINGS); if (pItem && pSettingsDialog) { // pass peripheral item properties to settings dialog so skin authors // can use it to show more detailed information about the device pSettingsDialog->SetProperty("vendor", pItem->GetProperty("vendor")); pSettingsDialog->SetProperty("product", pItem->GetProperty("product")); pSettingsDialog->SetProperty("bus", pItem->GetProperty("bus")); pSettingsDialog->SetProperty("location", pItem->GetProperty("location")); pSettingsDialog->SetProperty("class", pItem->GetProperty("class")); pSettingsDialog->SetProperty("version", pItem->GetProperty("version")); // open settings dialog pSettingsDialog->SetFileItem(pItem.get()); pSettingsDialog->Open(); } } } while (pDialog->IsConfirmed()); } }
std::vector<int>* Dialog::multiselect(const String& heading, const std::vector<String>& options, int autoclose) { DelayedCallGuard dcguard(languageHook); CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); if (pDialog == nullptr) throw WindowException("Error: Window is NULL"); pDialog->Reset(); pDialog->SetMultiSelection(true); pDialog->SetHeading(CVariant{heading}); for (const auto& option : options) pDialog->Add(option); if (autoclose > 0) pDialog->SetAutoClose(autoclose); pDialog->Open(); if (pDialog->IsConfirmed()) return new std::vector<int>(pDialog->GetSelectedItems()); else return nullptr; }
void CGUIDialogSmartPlaylistRule::OnField() { const auto fields = CSmartPlaylistRule::GetFields(m_type); CGUIDialogSelect* dialog = g_windowManager.GetWindow<CGUIDialogSelect>(); dialog->Reset(); dialog->SetHeading(CVariant{20427}); int selected = -1; for (auto field = fields.begin(); field != fields.end(); field++) { dialog->Add(CSmartPlaylistRule::GetLocalizedField(*field)); if (*field == m_rule.m_field) selected = std::distance(fields.begin(), field); } if (selected > -1) dialog->SetSelected(selected); dialog->Open(); int newSelected = dialog->GetSelectedItem(); // check if selection has changed if (!dialog->IsConfirmed() || newSelected < 0 || newSelected == selected) return; m_rule.m_field = fields[newSelected]; // check if operator is still valid. if not, reset to first valid one std::vector< std::pair<std::string, int> > validOperators = GetValidOperators(m_rule); bool isValid = false; for (auto op : validOperators) if (std::get<0>(op) == std::get<0>(OperatorLabel(m_rule.m_operator))) isValid = true; if (!isValid) m_rule.m_operator = (CDatabaseQueryRule::SEARCH_OPERATOR)std::get<1>(validOperators[0]); m_rule.SetParameter(""); UpdateButtons(); }
bool CGUIWindowPVRBase::OpenGroupSelectionDialog(void) { CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); if (!dialog) return false; CFileItemList options; g_PVRChannelGroups->Get(m_bRadio)->GetGroupList(&options, true); dialog->Reset(); dialog->SetHeading(CVariant{g_localizeStrings.Get(19146)}); dialog->SetItems(options); dialog->SetMultiSelection(false); dialog->SetSelected(m_group->GroupName()); dialog->Open(); if (!dialog->IsConfirmed()) return false; const CFileItemPtr item = dialog->GetSelectedItem(); if (!item) return false; SetGroup(g_PVRChannelGroups->Get(m_bRadio)->GetByName(item->m_strTitle)); return true; }
bool CGUIWindowPVRBase::OpenChannelGroupSelectionDialog(void) { CGUIDialogSelect *dialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogSelect>(WINDOW_DIALOG_SELECT); if (!dialog) return false; CFileItemList options; CServiceBroker::GetPVRManager().ChannelGroups()->Get(m_bRadio)->GetGroupList(&options, true); dialog->Reset(); dialog->SetHeading(CVariant{g_localizeStrings.Get(19146)}); dialog->SetItems(options); dialog->SetMultiSelection(false); dialog->SetSelected(m_channelGroup->GroupName()); dialog->Open(); if (!dialog->IsConfirmed()) return false; const CFileItemPtr item = dialog->GetSelectedFileItem(); if (!item) return false; SetChannelGroup(CServiceBroker::GetPVRManager().ChannelGroups()->Get(m_bRadio)->GetByName(item->m_strTitle)); return true; }
bool CGUIControlListSetting::OnClick() { if (m_pButton == NULL) return false; CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); if (dialog == NULL) return false; CFileItemList options; if (!GetItems(m_pSetting, options) || options.Size() <= 1) return false; const CSettingControlList *control = static_cast<const CSettingControlList*>(m_pSetting->GetControl()); dialog->Reset(); dialog->SetHeading(g_localizeStrings.Get(m_pSetting->GetLabel())); dialog->SetItems(&options); dialog->SetMultiSelection(control->CanMultiSelect()); dialog->DoModal(); if (!dialog->IsConfirmed()) return false; const CFileItemList &items = dialog->GetSelectedItems(); std::vector<CVariant> values; for (int index = 0; index < items.Size(); index++) { const CFileItemPtr item = items[index]; if (item == NULL || !item->HasProperty("value")) return false; values.push_back(item->GetProperty("value")); } bool ret = false; switch (m_pSetting->GetType()) { case SettingTypeInteger: if (values.size() > 1) return false; ret = ((CSettingInt *)m_pSetting)->SetValue((int)values.at(0).asInteger()); case SettingTypeString: if (values.size() > 1) return false; ret = ((CSettingString *)m_pSetting)->SetValue(values.at(0).asString()); case SettingTypeList: ret = CSettings::Get().SetList(m_pSetting->GetId(), values); default: break; } if (ret) Update(); return ret; }
bool Interface_GUIDialogSelect::open_multi_select(void* kodiBase, const char *heading, const char *entryIDs[], const char *entryNames[], bool entriesSelected[], unsigned int size, unsigned int autoclose) { CAddonDll* addon = static_cast<CAddonDll*>(kodiBase); if (!addon) { CLog::Log(LOGERROR, "Interface_GUIDialogMultiSelect::%s - invalid data", __FUNCTION__); return false; } CGUIDialogSelect* dialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogSelect>(WINDOW_DIALOG_SELECT); if (!heading || !entryIDs || !entryNames || !entriesSelected || !dialog) { CLog::Log(LOGERROR, "Interface_GUIDialogMultiSelect::%s - invalid handler data (heading='%p', " "entryIDs='%p', entryNames='%p', entriesSelected='%p', dialog='%p') on addon '%s'", __FUNCTION__, heading, static_cast<const void*>(entryIDs), static_cast<const void*>(entryNames), static_cast<void*>(entriesSelected), static_cast<void*>(dialog), addon->ID().c_str()); return false; } dialog->Reset(); dialog->SetMultiSelection(true); dialog->SetHeading(CVariant{heading}); std::vector<int> selectedIndexes; for (unsigned int i = 0; i < size; ++i) { dialog->Add(entryNames[i]); if (entriesSelected[i]) selectedIndexes.push_back(i); } dialog->SetSelected(selectedIndexes); if (autoclose > 0) dialog->SetAutoClose(autoclose); dialog->Open(); if (dialog->IsConfirmed()) { for (unsigned int i = 0; i < size; ++i) entriesSelected[i] = false; selectedIndexes = dialog->GetSelectedItems(); for (unsigned int i = 0; i < selectedIndexes.size(); ++i) { if (selectedIndexes[i]) entriesSelected[selectedIndexes[i]] = true; } } return true; }
RENDER_STEREO_MODE CStereoscopicsManager::GetStereoModeByUserChoice(const std::string &heading) { RENDER_STEREO_MODE mode = GetStereoMode(); // if no stereo mode is set already, suggest mode of current video by preselecting it if (mode == RENDER_STEREO_MODE_OFF && g_infoManager.EvaluateBool("videoplayer.isstereoscopic")) mode = GetStereoModeOfPlayingVideo(); CGUIDialogSelect* pDlgSelect = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDlgSelect->Reset(); if (heading.empty()) pDlgSelect->SetHeading(CVariant{g_localizeStrings.Get(36528)}); else pDlgSelect->SetHeading(CVariant{heading}); // prepare selectable stereo modes std::vector<RENDER_STEREO_MODE> selectableModes; for (int i = RENDER_STEREO_MODE_OFF; i < RENDER_STEREO_MODE_COUNT; i++) { RENDER_STEREO_MODE selectableMode = (RENDER_STEREO_MODE) i; if (g_Windowing.SupportsStereo(selectableMode)) { selectableModes.push_back(selectableMode); std::string label = GetLabelForStereoMode((RENDER_STEREO_MODE) i); pDlgSelect->Add( label ); if (mode == selectableMode) pDlgSelect->SetSelected( label ); } // inject AUTO pseudo mode after OFF if (i == RENDER_STEREO_MODE_OFF) { selectableModes.push_back(RENDER_STEREO_MODE_AUTO); pDlgSelect->Add(GetLabelForStereoMode(RENDER_STEREO_MODE_AUTO)); } } pDlgSelect->Open(); int iItem = pDlgSelect->GetSelectedLabel(); if (iItem > -1 && pDlgSelect->IsConfirmed()) mode = (RENDER_STEREO_MODE) selectableModes[iItem]; else mode = GetStereoMode(); return mode; }
void CGUIDialogSmartPlaylistRule::OnOperator() { const auto labels = GetValidOperators(m_rule); CGUIDialogSelect* dialog = g_windowManager.GetWindow<CGUIDialogSelect>(); dialog->Reset(); dialog->SetHeading(CVariant{ 16023 }); for (auto label : labels) dialog->Add(std::get<0>(label)); dialog->SetSelected(CSmartPlaylistRule::GetLocalizedOperator(m_rule.m_operator)); dialog->Open(); int newSelected = dialog->GetSelectedItem(); // check if selection has changed if (!dialog->IsConfirmed() || newSelected < 0) return; m_rule.m_operator = (CDatabaseQueryRule::SEARCH_OPERATOR)std::get<1>(labels[newSelected]); UpdateButtons(); }
bool CGUIControlListSetting::OnClick() { if (m_pButton == NULL) return false; CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); if (dialog == NULL) return false; CFileItemList options; if (!GetItems(m_pSetting, options) || options.Size() <= 1) return false; dialog->Reset(); dialog->SetHeading(g_localizeStrings.Get(m_pSetting->GetLabel())); dialog->SetItems(&options); dialog->SetMultiSelection(false); dialog->DoModal(); if (!dialog->IsConfirmed()) return false; const CFileItemPtr item = dialog->GetSelectedItem(); if (item == NULL || !item->HasProperty("value")) return false; CVariant value = item->GetProperty("value"); switch (m_pSetting->GetType()) { case SettingTypeInteger: return ((CSettingInt *)m_pSetting)->SetValue((int)value.asInteger()); case SettingTypeString: return ((CSettingString *)m_pSetting)->SetValue(value.asString()); default: break; } return true; }
bool CGUIViewState::ChooseSortMethod() { CGUIDialogSelect *dialog = g_windowManager.GetWindow<CGUIDialogSelect>(WINDOW_DIALOG_SELECT); if (!dialog) return false; dialog->Reset(); dialog->SetHeading(CVariant{ 39010 }); // Label "Sort by" for (auto &sortMethod : m_sortMethods) dialog->Add(g_localizeStrings.Get(sortMethod.m_buttonLabel)); dialog->SetSelected(m_currentSortMethod); dialog->Open(); int newSelected = dialog->GetSelectedItem(); // check if selection has changed if (!dialog->IsConfirmed() || newSelected < 0 || newSelected == m_currentSortMethod) return false; m_currentSortMethod = newSelected; SaveViewState(); return true; }
/*! \brief Select and set a skin bool setting. * \param params The parameters. * \details params[0] = Names of skin settings. */ static int SelectBool(const std::vector<std::string>& params) { std::vector<std::pair<std::string, std::string>> settings; CGUIDialogSelect* pDlgSelect = g_windowManager.GetWindow<CGUIDialogSelect>(); pDlgSelect->Reset(); pDlgSelect->SetHeading(CVariant{g_localizeStrings.Get(atoi(params[0].c_str()))}); for (unsigned int i = 1 ; i < params.size() ; i++) { if (params[i].find('|') != std::string::npos) { std::vector<std::string> values = StringUtils::Split(params[i], '|'); std::string label = g_localizeStrings.Get(atoi(values[0].c_str())); settings.push_back(std::make_pair(label, values[1].c_str())); pDlgSelect->Add(label); } } pDlgSelect->Open(); if(pDlgSelect->IsConfirmed()) { unsigned int iItem = pDlgSelect->GetSelectedItem(); for (unsigned int i = 0 ; i < settings.size() ; i++) { std::string item = settings[i].second; int setting = CSkinSettings::GetInstance().TranslateBool(item); if (i == iItem) CSkinSettings::GetInstance().SetBool(setting, true); else CSkinSettings::GetInstance().SetBool(setting, false); } CServiceBroker::GetSettings().Save(); } return 0; }
void CStereoscopicsManager::OnPlaybackStarted(void) { STEREOSCOPIC_PLAYBACK_MODE playbackMode = (STEREOSCOPIC_PLAYBACK_MODE) CSettings::Get().GetInt("videoplayer.stereoscopicplaybackmode"); RENDER_STEREO_MODE mode = GetStereoMode(); // early return if playback mode should be ignored and we're in no stereoscopic mode right now if (playbackMode == STEREOSCOPIC_PLAYBACK_MODE_IGNORE && mode == RENDER_STEREO_MODE_OFF) return; if (!g_infoManager.EvaluateBool("videoplayer.isstereoscopic")) { // exit stereo mode if started item is not stereoscopic // and if user prefers to stop 3D playback when movie is finished if (mode != RENDER_STEREO_MODE_OFF && CSettings::Get().GetBool("videoplayer.quitstereomodeonstop")) SetStereoMode(RENDER_STEREO_MODE_OFF); return; } // if we're not in stereomode yet, restore previously selected stereo mode in case it was user selected if (m_stereoModeSetByUser != RENDER_STEREO_MODE_UNDEFINED) { SetStereoMode(m_stereoModeSetByUser); return; } RENDER_STEREO_MODE preferred = GetPreferredPlaybackMode(); RENDER_STEREO_MODE playing = GetStereoModeOfPlayingVideo(); if (mode != RENDER_STEREO_MODE_OFF) { // don't change mode if user selected to not exit stereomode on playback stop // users selecting this option usually have to manually switch their TV into 3D mode // and would be annoyed by having to switch TV modes when next movies comes up // @todo probably add a new setting for just this behavior if (CSettings::Get().GetBool("videoplayer.quitstereomodeonstop") == false) return; // only change to new stereo mode if not yet in preferred stereo mode if (mode == preferred || (preferred == RENDER_STEREO_MODE_AUTO && mode == playing)) return; } switch (playbackMode) { case STEREOSCOPIC_PLAYBACK_MODE_ASK: // Ask { CApplicationMessenger::Get().MediaPause(); CGUIDialogSelect* pDlgSelect = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDlgSelect->Reset(); pDlgSelect->SetHeading(CVariant{g_localizeStrings.Get(36527)}); int idx_playing = -1; // add choices int idx_preferred = pDlgSelect->Add(g_localizeStrings.Get(36524) // preferred + " (" + GetLabelForStereoMode(preferred) + ")"); int idx_mono = pDlgSelect->Add(GetLabelForStereoMode(RENDER_STEREO_MODE_MONO)); // mono / 2d if (playing != RENDER_STEREO_MODE_OFF && playing != preferred && preferred != RENDER_STEREO_MODE_AUTO && g_Windowing.SupportsStereo(playing)) // same as movie idx_playing = pDlgSelect->Add(g_localizeStrings.Get(36532) + " (" + GetLabelForStereoMode(playing) + ")"); int idx_select = pDlgSelect->Add( g_localizeStrings.Get(36531) ); // other / select pDlgSelect->Open(); if(pDlgSelect->IsConfirmed()) { int iItem = pDlgSelect->GetSelectedLabel(); if (iItem == idx_preferred) mode = preferred; else if (iItem == idx_mono) mode = RENDER_STEREO_MODE_MONO; else if (iItem == idx_playing) mode = RENDER_STEREO_MODE_AUTO; else if (iItem == idx_select) mode = GetStereoModeByUserChoice(); SetStereoModeByUser( mode ); } CApplicationMessenger::Get().MediaUnPause(); } break; case STEREOSCOPIC_PLAYBACK_MODE_PREFERRED: // Stereoscopic SetStereoMode( preferred ); break; case 2: // Mono SetStereoMode( RENDER_STEREO_MODE_MONO ); break; default: break; } }
void CStereoscopicsManager::OnPlaybackStarted(void) { if (!g_infoManager.EvaluateBool("videoplayer.isstereoscopic")) return; // only change stereo mode if not yet in stereo mode RENDER_STEREO_MODE mode = GetStereoMode(); if (mode != RENDER_STEREO_MODE_OFF) return; int playbackMode = CSettings::Get().GetInt("videoplayer.stereoscopicplaybackmode"); switch (playbackMode) { case 0: // Ask { CApplicationMessenger::Get().MediaPause(); CGUIDialogSelect* pDlgSelect = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDlgSelect->Reset(); pDlgSelect->SetHeading(g_localizeStrings.Get(36527).c_str()); RENDER_STEREO_MODE preferred = GetPreferredPlaybackMode(); RENDER_STEREO_MODE playing = GetStereoModeOfPlayingVideo(); int idx_preferred = -1 , idx_playing = -1 , idx_mono = -1 , idx_select = -1; // add choices idx_preferred = pDlgSelect->Add( g_localizeStrings.Get(36530) + " (" + GetLabelForStereoMode(preferred) + ")"); if(preferred != RENDER_STEREO_MODE_MONO) idx_mono = pDlgSelect->Add( g_localizeStrings.Get(36529) ); // mono / 2d if(playing != RENDER_STEREO_MODE_OFF && g_Windowing.SupportsStereo(playing)) idx_playing = pDlgSelect->Add( g_localizeStrings.Get(36532) + " (" + GetLabelForStereoMode(playing) + ")"); idx_select = pDlgSelect->Add( g_localizeStrings.Get(36531) ); // other / select pDlgSelect->DoModal(); if(pDlgSelect->IsConfirmed()) { int iItem = pDlgSelect->GetSelectedLabel(); if (iItem == idx_preferred) mode = preferred; else if (iItem == idx_mono) mode = RENDER_STEREO_MODE_MONO; else if (iItem == idx_playing) mode = playing; else if (iItem == idx_select) mode = GetStereoModeByUserChoice(); SetStereoMode(mode); } CApplicationMessenger::Get().MediaUnPause(); } break; case 1: // Stereoscopic SetStereoMode( GetPreferredPlaybackMode() ); break; default: break; } }
void CGUIDialogMediaFilter::OnBrowse(const Filter &filter, CFileItemList &items, bool countOnly /* = false */) { CFileItemList selectItems; if (m_mediaType == "movies" || m_mediaType == "tvshows" || m_mediaType == "episodes" || m_mediaType == "musicvideos") { CVideoDatabase videodb; if (!videodb.Open()) return; CSmartPlaylist tmpFilter = *m_filter; for (vector<CSmartPlaylistRule>::iterator rule = tmpFilter.m_ruleCombination.m_rules.begin(); rule != tmpFilter.m_ruleCombination.m_rules.end(); rule++) { if (rule->m_field == filter.field) { tmpFilter.m_ruleCombination.m_rules.erase(rule); break; } } std::set<CStdString> playlists; CDatabase::Filter dbfilter; dbfilter.where = tmpFilter.GetWhereClause(videodb, playlists); VIDEODB_CONTENT_TYPE type = VIDEODB_CONTENT_MOVIES; if (m_mediaType == "tvshows") type = VIDEODB_CONTENT_TVSHOWS; else if (m_mediaType == "episodes") type = VIDEODB_CONTENT_EPISODES; else if (m_mediaType == "musicvideos") type = VIDEODB_CONTENT_MUSICVIDEOS; if (filter.field == FieldGenre) videodb.GetGenresNav(m_dbUrl->ToString(), selectItems, type, dbfilter, countOnly); else if (filter.field == FieldActor || filter.field == FieldArtist) videodb.GetActorsNav(m_dbUrl->ToString(), selectItems, type, dbfilter, countOnly); else if (filter.field == FieldDirector) videodb.GetDirectorsNav(m_dbUrl->ToString(), selectItems, type, dbfilter, countOnly); else if (filter.field == FieldStudio) videodb.GetStudiosNav(m_dbUrl->ToString(), selectItems, type, dbfilter, countOnly); else if (filter.field == FieldAlbum) videodb.GetMusicVideoAlbumsNav(m_dbUrl->ToString(), selectItems, -1, dbfilter, countOnly); else if (filter.field == FieldTag) videodb.GetTagsNav(m_dbUrl->ToString(), selectItems, type, dbfilter, countOnly); } else if (m_mediaType == "artists" || m_mediaType == "albums" || m_mediaType == "songs") { CMusicDatabase musicdb; if (!musicdb.Open()) return; CSmartPlaylist tmpFilter = *m_filter; for (vector<CSmartPlaylistRule>::iterator rule = tmpFilter.m_ruleCombination.m_rules.begin(); rule != tmpFilter.m_ruleCombination.m_rules.end(); rule++) { if (rule->m_field == filter.field) { tmpFilter.m_ruleCombination.m_rules.erase(rule); break; } } std::set<CStdString> playlists; CDatabase::Filter dbfilter; dbfilter.where = tmpFilter.GetWhereClause(musicdb, playlists); if (filter.field == FieldGenre) musicdb.GetGenresNav(m_dbUrl->ToString(), selectItems, dbfilter, countOnly); else if (filter.field == FieldArtist) musicdb.GetArtistsNav(m_dbUrl->ToString(), selectItems, m_mediaType == "albums", -1, -1, -1, dbfilter, SortDescription(), countOnly); else if (filter.field == FieldAlbum) musicdb.GetAlbumsNav(m_dbUrl->ToString(), selectItems, -1, -1, dbfilter, SortDescription(), countOnly); else if (filter.field == FieldAlbumType) musicdb.GetAlbumTypesNav(m_dbUrl->ToString(), selectItems, dbfilter, countOnly); else if (filter.field == FieldMusicLabel) musicdb.GetMusicLabelsNav(m_dbUrl->ToString(), selectItems, dbfilter, countOnly); } if (selectItems.Size() <= 0) return; if (countOnly) { items.Copy(selectItems); return; } // sort the items selectItems.Sort(SORT_METHOD_LABEL, SortOrderAscending); CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDialog->Reset(); pDialog->SetItems(&selectItems); CStdString strHeading; strHeading.Format(g_localizeStrings.Get(13401), g_localizeStrings.Get(filter.label)); pDialog->SetHeading(strHeading); pDialog->SetMultiSelection(true); if (filter.rule != NULL && !filter.rule->m_parameter.empty()) pDialog->SetSelected(filter.rule->m_parameter); pDialog->DoModal(); if (pDialog->IsConfirmed()) items.Copy(pDialog->GetSelectedItems()); else items.Clear(); pDialog->Reset(); }
void CStereoscopicsManager::OnPlaybackStarted(void) { if (!g_infoManager.EvaluateBool("videoplayer.isstereoscopic")) return; STEREOSCOPIC_PLAYBACK_MODE playbackMode = (STEREOSCOPIC_PLAYBACK_MODE) CSettings::Get().GetInt("videoplayer.stereoscopicplaybackmode"); RENDER_STEREO_MODE mode = GetStereoMode(); // early return if playback mode should be ignored and we're in no stereoscopic mode right now if (playbackMode == STEREOSCOPIC_PLAYBACK_MODE_IGNORE && mode == RENDER_STEREO_MODE_OFF) return; if (mode != RENDER_STEREO_MODE_OFF) return; switch (playbackMode) { case STEREOSCOPIC_PLAYBACK_MODE_ASK: // Ask { CApplicationMessenger::Get().MediaPause(); CGUIDialogSelect* pDlgSelect = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDlgSelect->Reset(); pDlgSelect->SetHeading(g_localizeStrings.Get(36527).c_str()); RENDER_STEREO_MODE preferred = GetPreferredPlaybackMode(); RENDER_STEREO_MODE playing = GetStereoModeOfPlayingVideo(); int idx_playing = -1; // add choices int idx_preferred = pDlgSelect->Add(g_localizeStrings.Get(36524) // preferred + " (" + GetLabelForStereoMode(preferred) + ")"); int idx_mono = pDlgSelect->Add(GetLabelForStereoMode(RENDER_STEREO_MODE_MONO)); // mono / 2d if(playing != RENDER_STEREO_MODE_OFF && playing != preferred && g_Windowing.SupportsStereo(playing)) idx_playing = pDlgSelect->Add(g_localizeStrings.Get(36532) + " (" + GetLabelForStereoMode(playing) + ")"); int idx_select = pDlgSelect->Add( g_localizeStrings.Get(36531) ); // other / select pDlgSelect->DoModal(); if(pDlgSelect->IsConfirmed()) { int iItem = pDlgSelect->GetSelectedLabel(); if (iItem == idx_preferred) mode = preferred; else if (iItem == idx_mono) mode = RENDER_STEREO_MODE_MONO; else if (iItem == idx_playing) mode = playing; else if (iItem == idx_select) mode = GetStereoModeByUserChoice(); SetStereoMode(mode); } CApplicationMessenger::Get().MediaUnPause(); } break; case STEREOSCOPIC_PLAYBACK_MODE_PREFERRED: // Stereoscopic SetStereoMode( GetPreferredPlaybackMode() ); break; case 2: // Mono SetStereoMode( RENDER_STEREO_MODE_MONO ); break; default: break; } }
void CGUIDialogContentSettings::OnSettingAction(std::shared_ptr<const CSetting> setting) { if (setting == NULL) return; CGUIDialogSettingsManualBase::OnSettingAction(setting); const std::string &settingId = setting->GetId(); if (settingId == SETTING_CONTENT_TYPE) { std::vector<std::pair<std::string, int>> labels; if (m_content == CONTENT_ALBUMS || m_content == CONTENT_ARTISTS) { labels.push_back(std::make_pair(ADDON::TranslateContent(m_content, true), m_content)); } else { labels.push_back(std::make_pair(ADDON::TranslateContent(CONTENT_NONE, true), CONTENT_NONE)); labels.push_back(std::make_pair(ADDON::TranslateContent(CONTENT_MOVIES, true), CONTENT_MOVIES)); labels.push_back(std::make_pair(ADDON::TranslateContent(CONTENT_TVSHOWS, true), CONTENT_TVSHOWS)); labels.push_back(std::make_pair(ADDON::TranslateContent(CONTENT_MUSICVIDEOS, true), CONTENT_MUSICVIDEOS)); } std::sort(labels.begin(), labels.end()); CGUIDialogSelect *dialog = g_windowManager.GetWindow<CGUIDialogSelect>(WINDOW_DIALOG_SELECT); if (dialog) { dialog->SetHeading(CVariant{ 20344 }); //Label "This directory contains" int iIndex = 0; int iSelected = 0; for (const auto &label : labels) { dialog->Add(label.first); if (m_content == label.second) iSelected = iIndex; iIndex++; } dialog->SetSelected(iSelected); dialog->Open(); // Selected item has not changes - in case of cancel or the user selecting the same item int newSelected = dialog->GetSelectedItem(); if (!dialog->IsConfirmed() || newSelected < 0 || newSelected == iSelected) return; auto selected = labels.at(newSelected); m_content = static_cast<CONTENT_TYPE>(selected.second); AddonPtr scraperAddon; if (!CAddonSystemSettings::GetInstance().GetActive(ADDON::ScraperTypeFromContent(m_content), scraperAddon) && m_content != CONTENT_NONE) return; m_scraper = std::dynamic_pointer_cast<CScraper>(scraperAddon); SetupView(); SetFocus(SETTING_CONTENT_TYPE); } } else if (settingId == SETTING_SCRAPER_LIST) { ADDON::TYPE type = ADDON::ScraperTypeFromContent(m_content); std::string currentScraperId; if (m_scraper != nullptr) currentScraperId = m_scraper->ID(); std::string selectedAddonId = currentScraperId; if (CGUIWindowAddonBrowser::SelectAddonID(type, selectedAddonId, false) == 1 && selectedAddonId != currentScraperId) { AddonPtr scraperAddon; CServiceBroker::GetAddonMgr().GetAddon(selectedAddonId, scraperAddon); m_scraper = std::dynamic_pointer_cast<CScraper>(scraperAddon); SetupView(); SetFocus(SETTING_SCRAPER_LIST); } } else if (settingId == SETTING_SCRAPER_SETTINGS) CGUIDialogAddonSettings::ShowForAddon(m_scraper, false); }
void CGUIDialogSmartPlaylistRule::OnBrowse() { CFileItemList items; CMusicDatabase database; database.Open(); CVideoDatabase videodatabase; videodatabase.Open(); std::string basePath; if (CSmartPlaylist::IsMusicType(m_type)) basePath = "musicdb://"; else basePath = "videodb://"; VIDEODB_CONTENT_TYPE type = VIDEODB_CONTENT_MOVIES; if (m_type == "movies") basePath += "movies/"; else if (m_type == "tvshows") { type = VIDEODB_CONTENT_TVSHOWS; basePath += "tvshows/"; } else if (m_type == "musicvideos") { type = VIDEODB_CONTENT_MUSICVIDEOS; basePath += "musicvideos/"; } else if (m_type == "episodes") { if (m_rule.m_field == FieldGenre || m_rule.m_field == FieldYear || m_rule.m_field == FieldStudio) type = VIDEODB_CONTENT_TVSHOWS; else type = VIDEODB_CONTENT_EPISODES; basePath += "tvshows/"; } int iLabel = 0; if (m_rule.m_field == FieldGenre) { if (m_type == "tvshows" || m_type == "episodes" || m_type == "movies") videodatabase.GetGenresNav(basePath + "genres/", items, type); else if (m_type == "songs" || m_type == "albums" || m_type == "artists" || m_type == "mixed") database.GetGenresNav("musicdb://genres/",items); if (m_type == "musicvideos" || m_type == "mixed") { CFileItemList items2; videodatabase.GetGenresNav("videodb://musicvideos/genres/",items2,VIDEODB_CONTENT_MUSICVIDEOS); items.Append(items2); } iLabel = 515; } else if (m_rule.m_field == FieldCountry) { videodatabase.GetCountriesNav(basePath, items, type); iLabel = 574; } else if (m_rule.m_field == FieldArtist || m_rule.m_field == FieldAlbumArtist) { if (CSmartPlaylist::IsMusicType(m_type)) database.GetArtistsNav("musicdb://artists/", items, m_rule.m_field == FieldAlbumArtist, -1); if (m_type == "musicvideos" || m_type == "mixed") { CFileItemList items2; videodatabase.GetMusicVideoArtistsByName("", items2); items.Append(items2); } iLabel = 557; } else if (m_rule.m_field == FieldAlbum) { if (CSmartPlaylist::IsMusicType(m_type)) database.GetAlbumsNav("musicdb://albums/", items); if (m_type == "musicvideos" || m_type == "mixed") { CFileItemList items2; videodatabase.GetMusicVideoAlbumsByName("", items2); items.Append(items2); } iLabel = 558; } else if (m_rule.m_field == FieldActor) { videodatabase.GetActorsNav(basePath + "actors/",items,type); iLabel = 20337; } else if (m_rule.m_field == FieldYear) { if (CSmartPlaylist::IsMusicType(m_type)) database.GetYearsNav("musicdb://years/", items); if (CSmartPlaylist::IsVideoType(m_type)) { CFileItemList items2; videodatabase.GetYearsNav(basePath + "years/", items2, type); items.Append(items2); } iLabel = 562; } else if (m_rule.m_field == FieldDirector) { videodatabase.GetDirectorsNav(basePath + "directors/", items, type); iLabel = 20339; } else if (m_rule.m_field == FieldStudio) { videodatabase.GetStudiosNav(basePath + "studios/", items, type); iLabel = 572; } else if (m_rule.m_field == FieldWriter) { videodatabase.GetWritersNav(basePath, items, type); iLabel = 20417; } else if (m_rule.m_field == FieldTvShowTitle || (m_type == "tvshows" && m_rule.m_field == FieldTitle)) { videodatabase.GetTvShowsNav(basePath + "titles/", items); iLabel = 20343; } else if (m_rule.m_field == FieldTitle) { if (m_type == "songs" || m_type == "mixed") { database.GetSongsNav("musicdb://songs/", items, -1, -1, -1); iLabel = 134; } if (m_type == "movies") { videodatabase.GetMoviesNav(basePath + "titles/", items); iLabel = 20342; } if (m_type == "episodes") { videodatabase.GetEpisodesNav(basePath + "titles/-1/-1/", items); // we need to replace the db label (<season>x<episode> <title>) with the title only CLabelFormatter format("%T", ""); for (int i = 0; i < items.Size(); i++) format.FormatLabel(items[i].get()); iLabel = 20360; } if (m_type == "musicvideos" || m_type == "mixed") { videodatabase.GetMusicVideosNav(basePath + "titles/", items); iLabel = 20389; } } else if (m_rule.m_field == FieldPlaylist || m_rule.m_field == FieldVirtualFolder) { // use filebrowser to grab another smart playlist // Note: This can cause infinite loops (playlist that refers to the same playlist) but I don't // think there's any decent way to deal with this, as the infinite loop may be an arbitrary // number of playlists deep, eg playlist1 -> playlist2 -> playlist3 ... -> playlistn -> playlist1 if (CSmartPlaylist::IsVideoType(m_type)) XFILE::CDirectory::GetDirectory("special://videoplaylists/", items, ".xsp", XFILE::DIR_FLAG_NO_FILE_DIRS); if (CSmartPlaylist::IsMusicType(m_type)) { CFileItemList items2; XFILE::CDirectory::GetDirectory("special://musicplaylists/", items2, ".xsp", XFILE::DIR_FLAG_NO_FILE_DIRS); items.Append(items2); } for (int i = 0; i < items.Size(); i++) { CFileItemPtr item = items[i]; CSmartPlaylist playlist; // don't list unloadable smartplaylists or any referencable smartplaylists // which do not match the type of the current smartplaylist if (!playlist.Load(item->GetPath()) || (m_rule.m_field == FieldPlaylist && (!CSmartPlaylist::CheckTypeCompatibility(m_type, playlist.GetType()) || (!playlist.GetGroup().empty() || playlist.IsGroupMixed())))) { items.Remove(i); i -= 1; continue; } if (!playlist.GetName().empty()) item->SetLabel(playlist.GetName()); } iLabel = 559; } else if (m_rule.m_field == FieldPath) { VECSOURCES sources; if (m_type == "songs" || m_type == "mixed") sources = *CMediaSourceSettings::GetInstance().GetSources("music"); if (CSmartPlaylist::IsVideoType(m_type)) { VECSOURCES sources2 = *CMediaSourceSettings::GetInstance().GetSources("video"); sources.insert(sources.end(),sources2.begin(),sources2.end()); } g_mediaManager.GetLocalDrives(sources); std::string path = m_rule.GetParameter(); CGUIDialogFileBrowser::ShowAndGetDirectory(sources, g_localizeStrings.Get(657), path, false); if (m_rule.m_parameter.size() > 0) m_rule.m_parameter.clear(); if (!path.empty()) m_rule.m_parameter.push_back(path); UpdateButtons(); return; } else if (m_rule.m_field == FieldSet) { videodatabase.GetSetsNav("videodb://movies/sets/", items, VIDEODB_CONTENT_MOVIES); iLabel = 20434; } else if (m_rule.m_field == FieldTag) { VIDEODB_CONTENT_TYPE type = VIDEODB_CONTENT_MOVIES; if (m_type == "tvshows" || m_type == "episodes") type = VIDEODB_CONTENT_TVSHOWS; else if (m_type == "musicvideos") type = VIDEODB_CONTENT_MUSICVIDEOS; else if (m_type != "movies") return; videodatabase.GetTagsNav(basePath + "tags/", items, type); iLabel = 20459; } else { // TODO: Add browseability in here. assert(false); } // sort the items items.Sort(SortByLabel, SortOrderAscending, CSettings::GetInstance().GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING) ? SortAttributeIgnoreArticle : SortAttributeNone); CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDialog->Reset(); pDialog->SetItems(&items); std::string strHeading = StringUtils::Format(g_localizeStrings.Get(13401).c_str(), g_localizeStrings.Get(iLabel).c_str()); pDialog->SetHeading(CVariant{std::move(strHeading)}); pDialog->SetMultiSelection(m_rule.m_field != FieldPlaylist && m_rule.m_field != FieldVirtualFolder); if (!m_rule.m_parameter.empty()) pDialog->SetSelected(m_rule.m_parameter); pDialog->Open(); if (pDialog->IsConfirmed()) { m_rule.m_parameter.clear(); for (int i : pDialog->GetSelectedItems()) m_rule.m_parameter.push_back(items.Get(i)->GetLabel()); UpdateButtons(); } pDialog->Reset(); }
int CGUIWindowAddonBrowser::SelectAddonID(const vector<ADDON::TYPE> &types, CStdStringArray &addonIDs, bool showNone /*= false*/, bool multipleSelection /*= true*/) { CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); if (!dialog) return 0; CFileItemList items; CStdString heading; int iTypes = 0; for (vector<ADDON::TYPE>::const_iterator it = types.begin(); it != types.end(); ++it) { if (*it == ADDON_UNKNOWN) continue; ADDON::VECADDONS addons; iTypes++; if (*it == ADDON_AUDIO) CAddonsDirectory::GetScriptsAndPlugins("audio",addons); else if (*it == ADDON_EXECUTABLE) CAddonsDirectory::GetScriptsAndPlugins("executable",addons); else if (*it == ADDON_IMAGE) CAddonsDirectory::GetScriptsAndPlugins("image",addons); else if (*it == ADDON_VIDEO) CAddonsDirectory::GetScriptsAndPlugins("video",addons); else CAddonMgr::Get().GetAddons(*it, addons); for (ADDON::IVECADDONS it2 = addons.begin() ; it2 != addons.end() ; ++it2) { CFileItemPtr item(CAddonsDirectory::FileItemFromAddon(*it2, "")); if (!items.Contains(item->GetPath())) items.Add(item); } if (!heading.IsEmpty()) heading += ", "; heading += TranslateType(*it, true); } if (iTypes == 0) return 0; dialog->SetHeading(heading); dialog->Reset(); dialog->SetUseDetails(true); if (multipleSelection) showNone = false; if (multipleSelection || iTypes > 1) dialog->EnableButton(true, 186); else dialog->EnableButton(true, 21452); if (showNone) { CFileItemPtr item(new CFileItem("", false)); item->SetLabel(g_localizeStrings.Get(231)); item->SetLabel2(g_localizeStrings.Get(24040)); item->SetIconImage("DefaultAddonNone.png"); item->SetSpecialSort(SortSpecialOnTop); items.Add(item); } items.Sort(SORT_METHOD_LABEL, SortOrderAscending); if (addonIDs.size() > 0) { for (CStdStringArray::const_iterator it = addonIDs.begin(); it != addonIDs.end() ; it++) { CFileItemPtr item = items.Get(*it); if (item) item->Select(true); } } dialog->SetItems(&items); dialog->SetMultiSelection(multipleSelection); dialog->DoModal(); if (!multipleSelection && iTypes == 1 && dialog->IsButtonPressed()) { // switch to the addons browser. vector<CStdString> params; params.push_back("addons://all/"+TranslateType(types[0],false)+"/"); params.push_back("return"); g_windowManager.ActivateWindow(WINDOW_ADDON_BROWSER, params); return 2; } if (!dialog->IsConfirmed()) return 0; addonIDs.clear(); const CFileItemList& list = dialog->GetSelectedItems(); for (int i = 0 ; i < list.Size() ; i++) addonIDs.push_back(list.Get(i)->GetPath()); return 1; }
void CPeripherals::OnSettingAction(const CSetting *setting) { if (setting == nullptr) return; const std::string &settingId = setting->GetId(); if (settingId == CSettings::SETTING_INPUT_PERIPHERALS) { CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); CFileItemList items; GetDirectory("peripherals://all/", items); int iPos = -1; do { pDialog->Reset(); pDialog->SetHeading(CVariant{35000}); pDialog->SetUseDetails(true); pDialog->SetItems(items); pDialog->SetSelected(iPos); pDialog->Open(); iPos = pDialog->IsConfirmed() ? pDialog->GetSelectedItem() : -1; if (iPos >= 0) { CFileItemPtr pItem = items.Get(iPos); // show an error if the peripheral doesn't have any settings PeripheralPtr peripheral = GetByPath(pItem->GetPath()); if (!peripheral || peripheral->GetSettings().empty()) { CGUIDialogOK::ShowAndGetInput(CVariant{35000}, CVariant{35004}); continue; } CGUIDialogPeripheralSettings *pSettingsDialog = (CGUIDialogPeripheralSettings *)g_windowManager.GetWindow(WINDOW_DIALOG_PERIPHERAL_SETTINGS); if (pItem && pSettingsDialog) { // pass peripheral item properties to settings dialog so skin authors // can use it to show more detailed information about the device pSettingsDialog->SetProperty("vendor", pItem->GetProperty("vendor")); pSettingsDialog->SetProperty("product", pItem->GetProperty("product")); pSettingsDialog->SetProperty("bus", pItem->GetProperty("bus")); pSettingsDialog->SetProperty("location", pItem->GetProperty("location")); pSettingsDialog->SetProperty("class", pItem->GetProperty("class")); pSettingsDialog->SetProperty("version", pItem->GetProperty("version")); // open settings dialog pSettingsDialog->SetFileItem(pItem.get()); pSettingsDialog->Open(); } } } while (pDialog->IsConfirmed()); } else if (settingId == CSettings::SETTING_INPUT_CONTROLLERCONFIG) g_windowManager.ActivateWindow(WINDOW_DIALOG_GAME_CONTROLLERS); else if (settingId == CSettings::SETTING_INPUT_TESTRUMBLE) TestFeature(FEATURE_RUMBLE); }
std::string CGUIDialogSelectGameClient::ShowAndGetGameClient(const std::string &gamePath, const GameClientVector& candidates, const GameClientVector& installable) { std::string gameClient; LogGameClients(candidates, installable); std::string extension = URIUtils::GetExtension(gamePath); std::string xmlPath = CSavestateUtils::MakeMetadataPath(gamePath); // Load savestate CSavestate save; CSavestateDatabase db; CLog::Log(LOGDEBUG, "Select game client dialog: Loading savestate metadata %s", CURL::GetRedacted(xmlPath).c_str()); const bool bLoaded = db.GetSavestate(xmlPath, save); // Get savestate game client std::string saveGameClient; if (bLoaded) { saveGameClient = save.GameClient(); CLog::Log(LOGDEBUG, "Select game client dialog: Auto-selecting %s", saveGameClient.c_str()); } // "Select emulator for {0:s}" CGUIDialogSelect *dialog = GetDialog(StringUtils::Format(g_localizeStrings.Get(35258), extension)); if (dialog != nullptr) { // Turn the addons into items CFileItemList items; for (const auto &candidate : candidates) { CFileItemPtr item(XFILE::CAddonsDirectory::FileItemFromAddon(candidate, candidate->ID())); item->SetLabel2(g_localizeStrings.Get(35257)); // "Installed" if (item->GetPath() == saveGameClient) item->SetLabel2(item->GetLabel2() + ", " + g_localizeStrings.Get(35259)); // "Saved" items.Add(std::move(item)); } for (const auto &addon : installable) { CFileItemPtr item(XFILE::CAddonsDirectory::FileItemFromAddon(addon, addon->ID())); items.Add(std::move(item)); } items.Sort(SortByLabel, SortOrderAscending); dialog->SetItems(items); for (int i = 0; i < items.Size(); i++) { if (items[i]->GetPath() == saveGameClient) dialog->SetSelected(i); } dialog->Open(); // If the "Get More" button has been pressed, show a list of installable addons if (dialog->IsConfirmed()) { int selectedIndex = dialog->GetSelectedItem(); if (0 <= selectedIndex && selectedIndex < items.Size()) { gameClient = items[selectedIndex]->GetPath(); CLog::Log(LOGDEBUG, "Select game client dialog: User selected emulator %s", gameClient.c_str()); if (Install(gameClient)) { // If the addon is disabled we need to enable it if (!Enable(gameClient)) CLog::Log(LOGDEBUG, "Failed to enable game client %s", gameClient.c_str()); } else CLog::Log(LOGDEBUG, "Failed to install game client: %s", gameClient.c_str()); } else { CLog::Log(LOGDEBUG, "Select game client dialog: User selected invalid emulator %d", selectedIndex); } } else { CLog::Log(LOGDEBUG, "Select game client dialog: User cancelled game client installation"); } } return gameClient; }
int CGUIWindowAddonBrowser::SelectAddonID(const std::vector<ADDON::TYPE> &types, std::vector<std::string> &addonIDs, bool showNone /* = false */, bool showDetails /* = true */, bool multipleSelection /* = true */, bool showInstalled /* = true */, bool showInstallable /* = false */, bool showMore /* = true */) { // if we shouldn't show neither installed nor installable addons the list will be empty if (!showInstalled && !showInstallable) return -1; // can't show the "Get More" button if we already show installable addons if (showInstallable) showMore = false; CGUIDialogSelect *dialog = g_windowManager.GetWindow<CGUIDialogSelect>(); if (!dialog) return -1; // get rid of any invalid addon types std::vector<ADDON::TYPE> validTypes(types.size()); std::copy_if(types.begin(), types.end(), validTypes.begin(), [](ADDON::TYPE type) { return type != ADDON_UNKNOWN; }); if (validTypes.empty()) return -1; // get all addons to show VECADDONS addons; if (showInstalled) { for (std::vector<ADDON::TYPE>::const_iterator type = validTypes.begin(); type != validTypes.end(); ++type) { VECADDONS typeAddons; if (*type == ADDON_AUDIO) CAddonsDirectory::GetScriptsAndPlugins("audio", typeAddons); else if (*type == ADDON_EXECUTABLE) CAddonsDirectory::GetScriptsAndPlugins("executable", typeAddons); else if (*type == ADDON_IMAGE) CAddonsDirectory::GetScriptsAndPlugins("image", typeAddons); else if (*type == ADDON_VIDEO) CAddonsDirectory::GetScriptsAndPlugins("video", typeAddons); else if (*type == ADDON_GAME) CAddonsDirectory::GetScriptsAndPlugins("game", typeAddons); else CAddonMgr::GetInstance().GetAddons(typeAddons, *type); addons.insert(addons.end(), typeAddons.begin(), typeAddons.end()); } } if (showInstallable || showMore) { VECADDONS installableAddons; if (CAddonMgr::GetInstance().GetInstallableAddons(installableAddons)) { for (ADDON::IVECADDONS addon = installableAddons.begin(); addon != installableAddons.end();) { AddonPtr pAddon = *addon; // check if the addon matches one of the provided addon types bool matchesType = false; for (std::vector<ADDON::TYPE>::const_iterator type = validTypes.begin(); type != validTypes.end(); ++type) { if (pAddon->IsType(*type)) { matchesType = true; break; } } if (matchesType) { ++addon; continue; } addon = installableAddons.erase(addon); } if (showInstallable) addons.insert(addons.end(), installableAddons.begin(), installableAddons.end()); else if (showMore) showMore = !installableAddons.empty(); } } if (addons.empty() && !showNone) return -1; // turn the addons into items std::map<std::string, AddonPtr> addonMap; CFileItemList items; for (ADDON::IVECADDONS addon = addons.begin(); addon != addons.end(); ++addon) { CFileItemPtr item(CAddonsDirectory::FileItemFromAddon(*addon, (*addon)->ID())); item->SetLabel2((*addon)->Summary()); if (!items.Contains(item->GetPath())) { items.Add(item); addonMap.insert(std::make_pair(item->GetPath(), *addon)); } } if (items.IsEmpty() && !showNone) return -1; std::string heading; for (std::vector<ADDON::TYPE>::const_iterator type = validTypes.begin(); type != validTypes.end(); ++type) { if (!heading.empty()) heading += ", "; heading += TranslateType(*type, true); } dialog->SetHeading(CVariant{std::move(heading)}); dialog->Reset(); dialog->SetUseDetails(showDetails); if (multipleSelection) { showNone = false; showMore = false; dialog->EnableButton(true, 186); } else if (showMore) dialog->EnableButton(true, 21452); if (showNone) { CFileItemPtr item(new CFileItem("", false)); item->SetLabel(g_localizeStrings.Get(231)); item->SetLabel2(g_localizeStrings.Get(24040)); item->SetIconImage("DefaultAddonNone.png"); item->SetSpecialSort(SortSpecialOnTop); items.Add(item); } items.Sort(SortByLabel, SortOrderAscending); if (!addonIDs.empty()) { for (std::vector<std::string>::const_iterator it = addonIDs.begin(); it != addonIDs.end() ; ++it) { CFileItemPtr item = items.Get(*it); if (item) item->Select(true); } } dialog->SetItems(items); dialog->SetMultiSelection(multipleSelection); dialog->Open(); // if the "Get More" button has been pressed and we haven't shown the // installable addons so far show a list of installable addons if (showMore&& dialog->IsButtonPressed()) return SelectAddonID(types, addonIDs, showNone, showDetails, multipleSelection, false, true, false); if (!dialog->IsConfirmed()) return 0; addonIDs.clear(); for (int i : dialog->GetSelectedItems()) { const CFileItemPtr& item = items.Get(i); // check if one of the selected addons needs to be installed if (showInstallable) { std::map<std::string, AddonPtr>::const_iterator itAddon = addonMap.find(item->GetPath()); if (itAddon != addonMap.end()) { const AddonPtr& addon = itAddon->second; // if the addon isn't installed we need to install it if (!CAddonMgr::GetInstance().IsAddonInstalled(addon->ID())) { AddonPtr installedAddon; if (!CAddonInstaller::GetInstance().InstallModal(addon->ID(), installedAddon, false)) continue; } // if the addon is disabled we need to enable it if (CAddonMgr::GetInstance().IsAddonDisabled(addon->ID())) CAddonMgr::GetInstance().EnableAddon(addon->ID()); } } addonIDs.push_back(item->GetPath()); } return 1; }
void CGUIDialogSmartPlaylistRule::OnBrowse() { CFileItemList items; CMusicDatabase database; database.Open(); CVideoDatabase videodatabase; videodatabase.Open(); VIDEODB_CONTENT_TYPE type = VIDEODB_CONTENT_MOVIES; if (m_type.Equals("tvshows")) type = VIDEODB_CONTENT_TVSHOWS; else if (m_type.Equals("musicvideos")) type = VIDEODB_CONTENT_MUSICVIDEOS; else if (m_type.Equals("episodes")) type = VIDEODB_CONTENT_EPISODES; int iLabel = 0; if (m_rule.m_field == FieldGenre) { if (m_type.Equals("tvshows") || m_type.Equals("episodes") || m_type.Equals("movies")) videodatabase.GetGenresNav("videodb://2/1/",items,type); else if (m_type.Equals("songs") || m_type.Equals("albums") || m_type.Equals("artists") || m_type.Equals("mixed")) database.GetGenresNav("musicdb://1/",items); if (m_type.Equals("musicvideos") || m_type.Equals("mixed")) { CFileItemList items2; videodatabase.GetGenresNav("videodb://3/1/",items2,VIDEODB_CONTENT_MUSICVIDEOS); items.Append(items2); } iLabel = 515; } else if (m_rule.m_field == FieldCountry) { videodatabase.GetCountriesNav("videodb://2/1/",items,type); iLabel = 574; } else if (m_rule.m_field == FieldArtist || m_rule.m_field == FieldAlbumArtist) { if (m_type.Equals("songs") || m_type.Equals("mixed") || m_type.Equals("albums") || m_type.Equals("artists")) database.GetArtistsNav("musicdb://2/", items, m_rule.m_field == FieldAlbumArtist, -1); if (m_type.Equals("musicvideos") || m_type.Equals("mixed")) { CFileItemList items2; videodatabase.GetMusicVideoArtistsByName("",items2); items.Append(items2); } iLabel = 557; } else if (m_rule.m_field == FieldAlbum) { if (m_type.Equals("songs") || m_type.Equals("mixed") || m_type.Equals("albums")) database.GetAlbumsNav("musicdb://3/", items); if (m_type.Equals("musicvideos") || m_type.Equals("mixed")) { CFileItemList items2; videodatabase.GetMusicVideoAlbumsByName("",items2); items.Append(items2); } iLabel = 558; } else if (m_rule.m_field == FieldActor) { videodatabase.GetActorsNav("",items,type); iLabel = 20337; } else if (m_rule.m_field == FieldYear) { if (m_type.Equals("songs") || m_type.Equals("mixed") || m_type.Equals("albums")) database.GetYearsNav("musicdb://9/", items); if (!m_type.Equals("songs") && !m_type.Equals("albums")) { CFileItemList items2; videodatabase.GetYearsNav("", items2, type); items.Append(items2); } iLabel = 562; } else if (m_rule.m_field == FieldDirector) { videodatabase.GetDirectorsNav("",items,type); iLabel = 20339; } else if (m_rule.m_field == FieldStudio) { videodatabase.GetStudiosNav("",items,type); iLabel = 572; } else if (m_rule.m_field == FieldWriter) { videodatabase.GetWritersNav("",items,type); iLabel = 20417; } else if (m_rule.m_field == FieldTvShowTitle) { videodatabase.GetTvShowsNav("videodb://2/2/",items); iLabel = 20343; } else if (m_rule.m_field == FieldPlaylist) { // use filebrowser to grab another smart playlist // Note: This can cause infinite loops (playlist that refers to the same playlist) but I don't // think there's any decent way to deal with this, as the infinite loop may be an arbitrary // number of playlists deep, eg playlist1 -> playlist2 -> playlist3 ... -> playlistn -> playlist1 CStdString path = "special://videoplaylists/"; if (m_type.Equals("songs") || m_type.Equals("albums")) path = "special://musicplaylists/"; XFILE::CDirectory::GetDirectory(path, items, ".xsp", XFILE::DIR_FLAG_NO_FILE_DIRS); for (int i = 0; i < items.Size(); i++) { CFileItemPtr item = items[i]; CSmartPlaylist playlist; if (playlist.OpenAndReadName(item->GetPath())) item->SetLabel(playlist.GetName()); } iLabel = 559; } else if (m_rule.m_field == FieldPath) { VECSOURCES sources; if (m_type == "songs" || m_type == "mixed") sources = *g_settings.GetSourcesFromType("music"); if (m_type != "songs") { VECSOURCES sources2 = *g_settings.GetSourcesFromType("video"); sources.insert(sources.end(),sources2.begin(),sources2.end()); } g_mediaManager.GetLocalDrives(sources); CStdString path = m_rule.GetLocalizedParameter(m_type); CGUIDialogFileBrowser::ShowAndGetDirectory(sources, g_localizeStrings.Get(657), path, false); if (m_rule.m_parameter.size() > 0) m_rule.m_parameter.clear(); if (!path.empty()) m_rule.m_parameter.push_back(path); UpdateButtons(); return; } else if (m_rule.m_field == FieldSet) { videodatabase.GetSetsNav("videodb://1/7/", items, VIDEODB_CONTENT_MOVIES); iLabel = 20434; } else if (m_rule.m_field == FieldTag) { if (m_type == "movies") videodatabase.GetTagsNav("videodb://1/9/", items, VIDEODB_CONTENT_MOVIES); else return; iLabel = 20459; } else { // TODO: Add browseability in here. assert(false); } // sort the items items.Sort(SORT_METHOD_LABEL, SortOrderAscending); CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDialog->Reset(); pDialog->SetItems(&items); CStdString strHeading; strHeading.Format(g_localizeStrings.Get(13401),g_localizeStrings.Get(iLabel)); pDialog->SetHeading(strHeading); pDialog->SetMultiSelection(true); if (!m_rule.m_parameter.empty()) pDialog->SetSelected(m_rule.m_parameter); pDialog->DoModal(); if (pDialog->IsConfirmed()) { const CFileItemList &items = pDialog->GetSelectedItems(); m_rule.m_parameter.clear(); for (int index = 0; index < items.Size(); index++) m_rule.m_parameter.push_back(items[index]->GetLabel()); UpdateButtons(); } pDialog->Reset(); }
bool CGUIControlListSetting::OnClick() { if (m_pButton == NULL) return false; CGUIDialogSelect *dialog = g_windowManager.GetWindow<CGUIDialogSelect>(WINDOW_DIALOG_SELECT); if (dialog == NULL) return false; CFileItemList options; if (!GetItems(m_pSetting, options) || options.Size() <= 1) return false; const CSettingControlList *control = static_cast<const CSettingControlList*>(m_pSetting->GetControl()); dialog->Reset(); dialog->SetHeading(CVariant{g_localizeStrings.Get(m_pSetting->GetLabel())}); dialog->SetItems(options); dialog->SetMultiSelection(control->CanMultiSelect()); dialog->Open(); if (!dialog->IsConfirmed()) return false; std::vector<CVariant> values; for (int i : dialog->GetSelectedItems()) { const CFileItemPtr item = options.Get(i); if (item == NULL || !item->HasProperty("value")) return false; values.push_back(item->GetProperty("value")); } bool ret = false; switch (m_pSetting->GetType()) { case SettingTypeInteger: if (values.size() > 1) return false; ret = ((CSettingInt *)m_pSetting)->SetValue((int)values.at(0).asInteger()); break; case SettingTypeString: if (values.size() > 1) return false; ret = ((CSettingString *)m_pSetting)->SetValue(values.at(0).asString()); break; case SettingTypeList: ret = CSettingUtils::SetList(static_cast<CSettingList*>(m_pSetting), values); break; default: return false; } if (ret) Update(); else SetValid(false); return IsValid(); }