void CGUIDialogNetworkSetup::OnInitWindow() { // start as unconfirmed m_confirmed = false; CGUIDialog::OnInitWindow(); // Add our protocols std::vector< std::pair<std::string, int> > labels; #ifdef HAS_FILESYSTEM_SMB labels.push_back(make_pair(g_localizeStrings.Get(20171), NET_PROTOCOL_SMB)); #endif labels.push_back(make_pair(g_localizeStrings.Get(20301), NET_PROTOCOL_HTTPS)); labels.push_back(make_pair(g_localizeStrings.Get(20300), NET_PROTOCOL_HTTP)); labels.push_back(make_pair(g_localizeStrings.Get(20254), NET_PROTOCOL_DAVS)); labels.push_back(make_pair(g_localizeStrings.Get(20253), NET_PROTOCOL_DAV)); labels.push_back(make_pair(g_localizeStrings.Get(20173), NET_PROTOCOL_FTP)); labels.push_back(make_pair(g_localizeStrings.Get(20175), NET_PROTOCOL_UPNP)); labels.push_back(make_pair(g_localizeStrings.Get(20304), NET_PROTOCOL_RSS)); #ifdef HAS_FILESYSTEM_NFS labels.push_back(make_pair(g_localizeStrings.Get(20259), NET_PROTOCOL_NFS)); #endif #ifdef HAS_FILESYSTEM_SFTP labels.push_back(make_pair(g_localizeStrings.Get(20260), NET_PROTOCOL_SFTP)); #endif SET_CONTROL_LABELS(CONTROL_PROTOCOL, m_protocol, &labels); UpdateButtons(); }
void CGUIDialogSmartPlaylistEditor::OnWindowLoaded() { CGUIDialog::OnWindowLoaded(); SendMessage(GUI_MSG_SET_TYPE, CONTROL_NAME, 0, 16012); // setup the match spinner std::vector< std::pair<std::string, int> > labels; labels.push_back(make_pair(g_localizeStrings.Get(21425), 0)); labels.push_back(make_pair(g_localizeStrings.Get(21426), 1)); SET_CONTROL_LABELS(CONTROL_MATCH, m_playlist.m_ruleCombination.GetType() == CSmartPlaylistRuleCombination::CombinationAnd ? 0 : 1, &labels); // and now the limit spinner labels.clear(); labels.push_back(make_pair(g_localizeStrings.Get(21428), 0)); const int limits[] = { 10, 25, 50, 100, 250, 500, 1000 }; for (unsigned int i = 0; i < sizeof(limits) / sizeof(int); i++) labels.push_back(make_pair(StringUtils::Format(g_localizeStrings.Get(21436).c_str(), limits[i]), limits[i])); SET_CONTROL_LABELS(CONTROL_LIMIT, 0, &labels); }
void CGUIDialogSmartPlaylistEditor::OnInitWindow() { m_cancelled = false; SendMessage(GUI_MSG_ITEM_SELECT, CONTROL_LIMIT, m_playlist.m_limit); std::vector<PLAYLIST_TYPE> allowedTypes; if (m_mode == "partymusic") { allowedTypes.push_back(TYPE_SONGS); allowedTypes.push_back(TYPE_MIXED); } else if (m_mode == "partyvideo") { allowedTypes.push_back(TYPE_MUSICVIDEOS); allowedTypes.push_back(TYPE_MIXED); } else if (m_mode == "music") { // music types + mixed allowedTypes.push_back(TYPE_SONGS); allowedTypes.push_back(TYPE_ALBUMS); allowedTypes.push_back(TYPE_ARTISTS); allowedTypes.push_back(TYPE_MIXED); } else if (m_mode == "video") { // general category for videos allowedTypes.push_back(TYPE_MOVIES); allowedTypes.push_back(TYPE_TVSHOWS); allowedTypes.push_back(TYPE_EPISODES); allowedTypes.push_back(TYPE_MUSICVIDEOS); allowedTypes.push_back(TYPE_MIXED); } // add to the spinner std::vector< std::pair<std::string, int> > labels; for (unsigned int i = 0; i < allowedTypes.size(); i++) labels.push_back(make_pair(GetLocalizedType(allowedTypes[i]), allowedTypes[i])); // check our playlist type is allowed PLAYLIST_TYPE type = ConvertType(m_playlist.GetType()); bool allowed = false; for (unsigned int i = 0; i < allowedTypes.size(); i++) if (type == allowedTypes[i]) allowed = true; if (!allowed && allowedTypes.size()) type = allowedTypes[0]; SET_CONTROL_LABELS(CONTROL_TYPE, type, &labels); m_playlist.SetType(ConvertType(type)); UpdateButtons(); SET_CONTROL_LABEL(CONTROL_HEADING, 21432); CGUIDialog::OnInitWindow(); }
void CGUIDialogSmartPlaylistRule::OnInitWindow() { CGUIDialog::OnInitWindow(); // add the fields to the field spincontrol std::vector< std::pair<std::string, int> > labels; std::vector<Field> fields = CSmartPlaylistRule::GetFields(m_type); for (unsigned int i = 0; i < fields.size(); i++) labels.push_back(std::make_pair(CSmartPlaylistRule::GetLocalizedField(fields[i]), fields[i])); SET_CONTROL_LABELS(CONTROL_FIELD, 0, &labels); UpdateButtons(); CGUIEditControl *editControl = dynamic_cast<CGUIEditControl*>(GetControl(CONTROL_VALUE)); if (editControl != NULL) editControl->SetInputValidation(CSmartPlaylistRule::Validate, &m_rule); }
void CGUIDialogSmartPlaylistEditor::UpdateButtons() { CONTROL_ENABLE(CONTROL_OK); // always enabled since we can have no rules -> match everything (as we do with default partymode playlists) // if there's no rule available, add a dummy one the user can edit if (m_playlist.m_ruleCombination.m_rules.size() <= 0) m_playlist.m_ruleCombination.AddRule(CSmartPlaylistRule()); // name if (m_mode == "partyvideo" || m_mode == "partymusic") { SET_CONTROL_LABEL2(CONTROL_NAME, g_localizeStrings.Get(16035)); CONTROL_DISABLE(CONTROL_NAME); } else SET_CONTROL_LABEL2(CONTROL_NAME, m_playlist.m_playlistName); UpdateRuleControlButtons(); CONTROL_ENABLE_ON_CONDITION(CONTROL_MATCH, m_playlist.m_ruleCombination.m_rules.size() > 1); int currentItem = GetSelectedItem(); CGUIMessage msgReset(GUI_MSG_LABEL_RESET, GetID(), CONTROL_RULE_LIST); OnMessage(msgReset); m_ruleLabels->Clear(); for (unsigned int i = 0; i < m_playlist.m_ruleCombination.m_rules.size(); i++) { CFileItemPtr item(new CFileItem("", false)); if (m_playlist.m_ruleCombination.m_rules[i]->m_field == FieldNone) item->SetLabel(g_localizeStrings.Get(21423)); else item->SetLabel(std::static_pointer_cast<CSmartPlaylistRule>(m_playlist.m_ruleCombination.m_rules[i])->GetLocalizedRule()); m_ruleLabels->Add(item); } CGUIMessage msg(GUI_MSG_LABEL_BIND, GetID(), CONTROL_RULE_LIST, 0, 0, m_ruleLabels); OnMessage(msg); SendMessage(GUI_MSG_ITEM_SELECT, GetID(), CONTROL_RULE_LIST, currentItem); if (m_playlist.m_orderDirection != SortOrderDescending) { CONTROL_SELECT(CONTROL_ORDER_DIRECTION); } else { CONTROL_DESELECT(CONTROL_ORDER_DIRECTION); } // sort out the order fields std::vector< std::pair<std::string, int> > labels; std::vector<SortBy> orders = CSmartPlaylistRule::GetOrders(m_playlist.GetType()); for (unsigned int i = 0; i < orders.size(); i++) labels.push_back(make_pair(g_localizeStrings.Get(SortUtils::GetSortLabel(orders[i])), orders[i])); SET_CONTROL_LABELS(CONTROL_ORDER_FIELD, m_playlist.m_orderField, &labels); // setup groups labels.clear(); std::vector<Field> groups = CSmartPlaylistRule::GetGroups(m_playlist.GetType()); Field currentGroup = CSmartPlaylistRule::TranslateGroup(m_playlist.GetGroup().c_str()); for (unsigned int i = 0; i < groups.size(); i++) labels.push_back(make_pair(CSmartPlaylistRule::GetLocalizedGroup(groups[i]), groups[i])); SET_CONTROL_LABELS(CONTROL_GROUP_BY, currentGroup, &labels); if (m_playlist.IsGroupMixed()) CONTROL_SELECT(CONTROL_GROUP_MIXED); else CONTROL_DESELECT(CONTROL_GROUP_MIXED); // disable the group controls if there's no group // or only one group which can't be mixed if (groups.empty() || (groups.size() == 1 && !CSmartPlaylistRule::CanGroupMix(groups[0]))) { CONTROL_DISABLE(CONTROL_GROUP_BY); CONTROL_DISABLE(CONTROL_GROUP_MIXED); } else { CONTROL_ENABLE(CONTROL_GROUP_BY); CONTROL_ENABLE_ON_CONDITION(CONTROL_GROUP_MIXED, CSmartPlaylistRule::CanGroupMix(currentGroup)); } }
void CGUIDialogSmartPlaylistRule::UpdateButtons() { // update the field control SendMessage(GUI_MSG_ITEM_SELECT, CONTROL_FIELD, m_rule.m_field); CGUIMessage msg2(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_FIELD); OnMessage(msg2); m_rule.m_field = (Field)msg2.GetParam1(); // and now update the operator set SendMessage(GUI_MSG_LABEL_RESET, CONTROL_OPERATOR); CONTROL_ENABLE(CONTROL_VALUE); if (CSmartPlaylistRule::IsFieldBrowseable(m_rule.m_field)) CONTROL_ENABLE(CONTROL_BROWSE); else CONTROL_DISABLE(CONTROL_BROWSE); std::vector< std::pair<std::string, int> > labels; switch (m_rule.GetFieldType(m_rule.m_field)) { case CDatabaseQueryRule::TEXT_FIELD: // text fields - add the usual comparisons labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_EQUALS)); labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_DOES_NOT_EQUAL)); labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_CONTAINS)); labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_DOES_NOT_CONTAIN)); labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_STARTS_WITH)); labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_ENDS_WITH)); break; case CDatabaseQueryRule::NUMERIC_FIELD: case CDatabaseQueryRule::SECONDS_FIELD: // numerical fields - less than greater than labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_EQUALS)); labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_DOES_NOT_EQUAL)); labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_GREATER_THAN)); labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_LESS_THAN)); break; case CDatabaseQueryRule::DATE_FIELD: // date field labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_AFTER)); labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_BEFORE)); labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_IN_THE_LAST)); labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_NOT_IN_THE_LAST)); break; case CDatabaseQueryRule::PLAYLIST_FIELD: CONTROL_ENABLE(CONTROL_BROWSE); labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_EQUALS)); labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_DOES_NOT_EQUAL)); break; case CDatabaseQueryRule::BOOLEAN_FIELD: CONTROL_DISABLE(CONTROL_VALUE); labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_TRUE)); labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_FALSE)); break; case CDatabaseQueryRule::TEXTIN_FIELD: labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_EQUALS)); labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_DOES_NOT_EQUAL)); break; } SET_CONTROL_LABELS(CONTROL_OPERATOR, m_rule.m_operator, &labels); // check our operator is valid, and update if not CGUIMessage selected(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_OPERATOR); OnMessage(selected); m_rule.m_operator = (CDatabaseQueryRule::SEARCH_OPERATOR)selected.GetParam1(); // update the parameter edit control appropriately SET_CONTROL_LABEL2(CONTROL_VALUE, m_rule.GetParameter()); CGUIEditControl::INPUT_TYPE type = CGUIEditControl::INPUT_TYPE_TEXT; CDatabaseQueryRule::FIELD_TYPE fieldType = m_rule.GetFieldType(m_rule.m_field); switch (fieldType) { case CDatabaseQueryRule::TEXT_FIELD: case CDatabaseQueryRule::PLAYLIST_FIELD: case CDatabaseQueryRule::TEXTIN_FIELD: case CDatabaseQueryRule::NUMERIC_FIELD: type = CGUIEditControl::INPUT_TYPE_TEXT; break; case CDatabaseQueryRule::DATE_FIELD: if (m_rule.m_operator == CDatabaseQueryRule::OPERATOR_IN_THE_LAST || m_rule.m_operator == CDatabaseQueryRule::OPERATOR_NOT_IN_THE_LAST) type = CGUIEditControl::INPUT_TYPE_TEXT; else type = CGUIEditControl::INPUT_TYPE_DATE; break; case CDatabaseQueryRule::SECONDS_FIELD: type = CGUIEditControl::INPUT_TYPE_SECONDS; break; case CDatabaseQueryRule::BOOLEAN_FIELD: type = CGUIEditControl::INPUT_TYPE_NUMBER; break; } SendMessage(GUI_MSG_SET_TYPE, CONTROL_VALUE, type, 21420); }