本文整理汇总了C++中CGUIDialogSelect::IsButtonPressed方法的典型用法代码示例。如果您正苦于以下问题:C++ CGUIDialogSelect::IsButtonPressed方法的具体用法?C++ CGUIDialogSelect::IsButtonPressed怎么用?C++ CGUIDialogSelect::IsButtonPressed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGUIDialogSelect
的用法示例。
在下文中一共展示了CGUIDialogSelect::IsButtonPressed方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ChooseArtType
string CGUIDialogVideoInfo::ChooseArtType(const CFileItem &videoItem, map<string, string> ¤tArt)
{
// prompt for choice
CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
if (!dialog || !videoItem.HasVideoInfoTag())
return "";
CFileItemList items;
dialog->SetHeading(13511);
dialog->Reset();
dialog->SetUseDetails(true);
dialog->EnableButton(true, 13516);
CVideoDatabase db;
db.Open();
vector<string> artTypes = CVideoThumbLoader::GetArtTypes(videoItem.GetVideoInfoTag()->m_type);
// add in any stored art for this item that is non-empty.
db.GetArtForItem(videoItem.GetVideoInfoTag()->m_iDbId, videoItem.GetVideoInfoTag()->m_type, currentArt);
for (CGUIListItem::ArtMap::iterator i = currentArt.begin(); i != currentArt.end(); ++i)
{
if (!i->second.empty() && find(artTypes.begin(), artTypes.end(), i->first) == artTypes.end())
artTypes.push_back(i->first);
}
// add any art types that exist for other media items of the same type
vector<string> dbArtTypes;
db.GetArtTypes(videoItem.GetVideoInfoTag()->m_type, dbArtTypes);
for (vector<string>::const_iterator it = dbArtTypes.begin(); it != dbArtTypes.end(); it++)
{
if (find(artTypes.begin(), artTypes.end(), *it) == artTypes.end())
artTypes.push_back(*it);
}
for (vector<string>::const_iterator i = artTypes.begin(); i != artTypes.end(); ++i)
{
string type = *i;
CFileItemPtr item(new CFileItem(type, "false"));
item->SetLabel(type);
if (videoItem.HasArt(type))
item->SetArt("thumb", videoItem.GetArt(type));
items.Add(item);
}
dialog->SetItems(&items);
dialog->DoModal();
if (dialog->IsButtonPressed())
{
// Get the new artwork name
CStdString strArtworkName;
if (!CGUIKeyboardFactory::ShowAndGetInput(strArtworkName, g_localizeStrings.Get(13516), false))
return "";
return strArtworkName;
}
return dialog->GetSelectedItem()->GetLabel();
}
示例2: GetAutoLoginProfileChoice
bool CGUIWindowSettingsProfile::GetAutoLoginProfileChoice(int &iProfile)
{
CGUIDialogSelect *dialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogSelect>(WINDOW_DIALOG_SELECT);
if (!dialog) return false;
const CProfilesManager &profileManager = CServiceBroker::GetProfileManager();
// add items
// "Last used profile" option comes first, so up indices by 1
int autoLoginProfileId = profileManager.GetAutoLoginProfileId() + 1;
CFileItemList items;
CFileItemPtr item(new CFileItem());
item->SetLabel(g_localizeStrings.Get(37014)); // Last used profile
item->SetIconImage("DefaultUser.png");
items.Add(item);
for (unsigned int i = 0; i < profileManager.GetNumberOfProfiles(); i++)
{
const CProfile *profile = profileManager.GetProfile(i);
std::string locked = g_localizeStrings.Get(profile->getLockMode() > 0 ? 20166 : 20165);
CFileItemPtr item(new CFileItem(profile->getName()));
item->SetLabel2(locked); // lock setting
std::string thumb = profile->getThumb();
if (thumb.empty())
thumb = "DefaultUser.png";
item->SetIconImage(thumb);
items.Add(item);
}
dialog->SetHeading(CVariant{20093}); // Profile name
dialog->Reset();
dialog->SetUseDetails(true);
dialog->SetItems(items);
dialog->SetSelected(autoLoginProfileId);
dialog->Open();
if (dialog->IsButtonPressed() || dialog->GetSelectedItem() < 0)
return false; // user cancelled
iProfile = dialog->GetSelectedItem() - 1;
return true;
}
示例3: GetAutoLoginProfileChoice
bool CGUIWindowSettingsProfile::GetAutoLoginProfileChoice(int &iProfile)
{
CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
if (!dialog) return false;
// add items
// "Most recent" option comes first, so up indices by 1
int autoLoginProfileId = CProfilesManager::Get().GetAutoLoginProfileId() + 1;
CFileItemList items;
CFileItemPtr item(new CFileItem());
item->SetLabel(g_localizeStrings.Get(37014)); // Most recent
item->SetIconImage("unknown-user.png");
items.Add(item);
for (unsigned int i = 0; i < CProfilesManager::Get().GetNumberOfProfiles(); i++)
{
const CProfile *profile = CProfilesManager::Get().GetProfile(i);
CStdString locked = g_localizeStrings.Get(profile->getLockMode() > 0 ? 20166 : 20165);
CFileItemPtr item(new CFileItem(profile->getName()));
item->SetProperty("Addon.Summary", locked); // lock setting
CStdString thumb = profile->getThumb();
if (thumb.IsEmpty())
thumb = "unknown-user.png";
item->SetIconImage(thumb);
items.Add(item);
}
dialog->SetHeading(20093); // Profile name
dialog->Reset();
dialog->SetUseDetails(true);
dialog->EnableButton(true, 222); // Cancel
dialog->SetItems(&items);
dialog->SetSelected(autoLoginProfileId);
dialog->DoModal();
if (dialog->IsButtonPressed() || dialog->GetSelectedLabel() < 0)
return false; // user cancelled
iProfile = dialog->GetSelectedLabel() - 1;
return true;
}
示例4: SelectAddonID
//.........这里部分代码省略.........
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;
}
示例5: Work
//.........这里部分代码省略.........
CVideoInfoDownloader infoDownloader(scraper);
// try to find a matching item
MOVIELIST itemResultList;
int result = infoDownloader.FindMovie(itemTitle, itemResultList, GetProgressDialog());
// close the progress dialog
MarkFinished();
if (result > 0)
{
// there are multiple matches for the item
if (!itemResultList.empty())
{
// choose the first match
if (!IsModal())
scraperUrl = itemResultList.at(0);
else
{
// ask the user what to do
CGUIDialogSelect* selectDialog = static_cast<CGUIDialogSelect*>(g_windowManager.GetWindow(WINDOW_DIALOG_SELECT));
selectDialog->Reset();
selectDialog->SetHeading(scraper->Content() == CONTENT_TVSHOWS ? 20356 : 196);
for (const auto& itemResult : itemResultList)
selectDialog->Add(itemResult.strTitle);
selectDialog->EnableButton(true, 413); // "Manual"
selectDialog->Open();
// check if the user has chosen one of the results
int selectedItem = selectDialog->GetSelectedItem();
if (selectedItem >= 0)
scraperUrl = itemResultList.at(selectedItem);
// the user hasn't chosen one of the results and but has chosen to manually enter a title to use
else if (selectDialog->IsButtonPressed())
{
// ask the user to input a title to use
if (!CGUIKeyboardFactory::ShowAndGetInput(itemTitle, g_localizeStrings.Get(scraper->Content() == CONTENT_TVSHOWS ? 20357 : 16009), false))
return false;
// go through the whole process again
needsRefresh = true;
continue;
}
// nothing else we can do
else
return false;
}
CLog::Log(LOGDEBUG, "CVideoLibraryRefreshingJob: user selected item '%s' with URL '%s'", scraperUrl.strTitle.c_str(), scraperUrl.m_url.at(0).m_url.c_str());
}
}
else if (result < 0 || !VIDEO::CVideoInfoScanner::DownloadFailed(GetProgressDialog()))
{
failure = true;
break;
}
}
// if the URL is still empty, check whether or not we're allowed
// to prompt and ask the user to input a new search title
if (!hasDetails && scraperUrl.m_url.empty())
{
if (IsModal())
{
// ask the user to input a title to use
if (!CGUIKeyboardFactory::ShowAndGetInput(itemTitle, g_localizeStrings.Get(scraper->Content() == CONTENT_TVSHOWS ? 20357 : 16009), false))
示例6: DownloadArtistInfo
//.........这里部分代码省略.........
{
scraper.Cancel();
bCanceled = true;
}
Sleep(1);
}
}
int iSelectedArtist = 0;
if (result == CNfoFile::NO_NFO)
{
if (scraper.Succeeded() && scraper.GetArtistCount() >= 1)
{
// now load the first match
if (pDialog && scraper.GetArtistCount() > 1)
{
// if we found more then 1 album, let user choose one
CGUIDialogSelect *pDlg = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
if (pDlg)
{
pDlg->SetHeading(g_localizeStrings.Get(21890));
pDlg->Reset();
pDlg->EnableButton(true, 413); // manual
for (int i = 0; i < scraper.GetArtistCount(); ++i)
{
// set the label to artist
CFileItem item(scraper.GetArtist(i).GetArtist());
CStdString strTemp=scraper.GetArtist(i).GetArtist().strArtist;
if (!scraper.GetArtist(i).GetArtist().strBorn.IsEmpty())
strTemp += " ("+scraper.GetArtist(i).GetArtist().strBorn+")";
if (!scraper.GetArtist(i).GetArtist().genre.empty())
{
CStdString genres = StringUtils::Join(scraper.GetArtist(i).GetArtist().genre, g_advancedSettings.m_musicItemSeparator);
if (!genres.empty())
strTemp.Format("[%s] %s", genres.c_str(), strTemp.c_str());
}
item.SetLabel(strTemp);
item.m_idepth = i; // use this to hold the index of the album in the scraper
pDlg->Add(&item);
}
pDlg->DoModal();
// and wait till user selects one
if (pDlg->GetSelectedLabel() < 0)
{ // none chosen
if (!pDlg->IsButtonPressed())
{
bCanceled = true;
return false;
}
// manual button pressed
CStdString strNewArtist = strArtist;
if (!CGUIKeyboardFactory::ShowAndGetInput(strNewArtist, g_localizeStrings.Get(16025), false)) return false;
if (pDialog)
{
pDialog->SetLine(0, strNewArtist);
pDialog->Progress();
}
m_musicDatabase.Close();
return DownloadArtistInfo(strPath,strNewArtist,bCanceled,pDialog);
}
iSelectedArtist = pDlg->GetSelectedItem()->m_idepth;
}
}
}
else
{
m_musicDatabase.Close();
return false;
}
}
scraper.LoadArtistInfo(iSelectedArtist, strArtist);
while (!scraper.Completed())
{
if (m_bStop)
{
scraper.Cancel();
bCanceled = true;
}
Sleep(1);
}
if (scraper.Succeeded())
{
artist = scraper.GetArtist(iSelectedArtist).GetArtist();
if (result == CNfoFile::COMBINED_NFO)
nfoReader.GetDetails(artist,NULL,true);
m_musicDatabase.SetArtistInfo(params.GetArtistId(), artist);
}
// check thumb stuff
map<string, string> artwork = GetArtistArtwork(params.GetArtistId(), &artist);
m_musicDatabase.SetArtForItem(params.GetArtistId(), "artist", artwork);
m_musicDatabase.Close();
return true;
}
示例7: DownloadArtistInfo
//.........这里部分代码省略.........
if (!scraper.GetArtistCount())
{
scraper.FindArtistInfo(artist.strArtist);
while (!scraper.Completed())
{
if (m_bStop)
{
scraper.Cancel();
return INFO_CANCELLED;
}
Sleep(1);
}
}
int iSelectedArtist = 0;
if (result == CNfoFile::NO_NFO && !bMusicBrainz)
{
if (scraper.GetArtistCount() >= 1)
{
// now load the first match
if (pDialog && scraper.GetArtistCount() > 1)
{
// if we found more then 1 album, let user choose one
CGUIDialogSelect *pDlg = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
if (pDlg)
{
pDlg->SetHeading(g_localizeStrings.Get(21890));
pDlg->Reset();
pDlg->EnableButton(true, 413); // manual
for (int i = 0; i < scraper.GetArtistCount(); ++i)
{
// set the label to artist
CFileItem item(scraper.GetArtist(i).GetArtist());
std::string strTemp=scraper.GetArtist(i).GetArtist().strArtist;
if (!scraper.GetArtist(i).GetArtist().strBorn.empty())
strTemp += " ("+scraper.GetArtist(i).GetArtist().strBorn+")";
if (!scraper.GetArtist(i).GetArtist().genre.empty())
{
std::string genres = StringUtils::Join(scraper.GetArtist(i).GetArtist().genre, g_advancedSettings.m_musicItemSeparator);
if (!genres.empty())
strTemp = StringUtils::Format("[%s] %s", genres.c_str(), strTemp.c_str());
}
item.SetLabel(strTemp);
item.m_idepth = i; // use this to hold the index of the album in the scraper
pDlg->Add(&item);
}
pDlg->DoModal();
// and wait till user selects one
if (pDlg->GetSelectedLabel() < 0)
{ // none chosen
if (!pDlg->IsButtonPressed())
return INFO_CANCELLED;
// manual button pressed
std::string strNewArtist = artist.strArtist;
if (!CGUIKeyboardFactory::ShowAndGetInput(strNewArtist, g_localizeStrings.Get(16025), false)) return INFO_CANCELLED;
if (pDialog)
{
pDialog->SetLine(0, strNewArtist);
pDialog->Progress();
}
CArtist newArtist;
newArtist.strArtist = strNewArtist;
return DownloadArtistInfo(newArtist, info, artistInfo, pDialog);
}
iSelectedArtist = pDlg->GetSelectedItem()->m_idepth;
}
}
}
else
return INFO_NOT_FOUND;
}
scraper.LoadArtistInfo(iSelectedArtist, artist.strArtist);
while (!scraper.Completed())
{
if (m_bStop)
{
scraper.Cancel();
return INFO_CANCELLED;
}
Sleep(1);
}
if (!scraper.Succeeded())
return INFO_ERROR;
artistInfo = scraper.GetArtist(iSelectedArtist);
if (result == CNfoFile::COMBINED_NFO)
nfoReader.GetDetails(artistInfo.GetArtist(), NULL, true);
return INFO_ADDED;
}
示例8: DownloadAlbumInfo
//.........这里部分代码省略.........
for (int i = 0; i < scraper.GetAlbumCount(); ++i)
{
CMusicAlbumInfo& info = scraper.GetAlbum(i);
double relevance = info.GetRelevance();
if (relevance < 0)
relevance = CUtil::AlbumRelevance(info.GetAlbum().strAlbum, album.strAlbum, StringUtils::Join(info.GetAlbum().artist, g_advancedSettings.m_musicItemSeparator), StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator));
// if we're doing auto-selection (ie querying all albums at once, then allow 95->100% for perfect matches)
// otherwise, perfect matches only
if (relevance >= max(minRelevance, bestRelevance))
{ // we auto-select the best of these
bestRelevance = relevance;
iSelectedAlbum = i;
}
if (pDialog)
{
// set the label to [relevance] album - artist
std::string strTemp = StringUtils::Format("[%0.2f] %s", relevance, info.GetTitle2().c_str());
CFileItem item(strTemp);
item.m_idepth = i; // use this to hold the index of the album in the scraper
pDlg->Add(&item);
}
if (relevance > .99f) // we're so close, no reason to search further
break;
}
if (pDialog && bestRelevance < THRESHOLD)
{
pDlg->Sort(false);
pDlg->DoModal();
// and wait till user selects one
if (pDlg->GetSelectedLabel() < 0)
{ // none chosen
if (!pDlg->IsButtonPressed())
return INFO_CANCELLED;
// manual button pressed
std::string strNewAlbum = album.strAlbum;
if (!CGUIKeyboardFactory::ShowAndGetInput(strNewAlbum, g_localizeStrings.Get(16011), false)) return INFO_CANCELLED;
if (strNewAlbum == "") return INFO_CANCELLED;
std::string strNewArtist = StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator);
if (!CGUIKeyboardFactory::ShowAndGetInput(strNewArtist, g_localizeStrings.Get(16025), false)) return INFO_CANCELLED;
pDialog->SetLine(0, strNewAlbum);
pDialog->SetLine(1, strNewArtist);
pDialog->Progress();
CAlbum newAlbum = album;
newAlbum.strAlbum = strNewAlbum;
newAlbum.artist = StringUtils::Split(strNewArtist, g_advancedSettings.m_musicItemSeparator);
return DownloadAlbumInfo(newAlbum, info, albumInfo, pDialog);
}
iSelectedAlbum = pDlg->GetSelectedItem()->m_idepth;
}
}
else
{
CMusicAlbumInfo& info = scraper.GetAlbum(0);
double relevance = info.GetRelevance();
if (relevance < 0)
relevance = CUtil::AlbumRelevance(info.GetAlbum().strAlbum,
album.strAlbum,
StringUtils::Join(info.GetAlbum().artist, g_advancedSettings.m_musicItemSeparator),
StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator));
if (relevance < THRESHOLD)
return INFO_NOT_FOUND;
iSelectedAlbum = 0;
}
}
if (iSelectedAlbum < 0)
return INFO_NOT_FOUND;
}
scraper.LoadAlbumInfo(iSelectedAlbum);
while (!scraper.Completed())
{
if (m_bStop)
{
scraper.Cancel();
return INFO_CANCELLED;
}
Sleep(1);
}
if (!scraper.Succeeded())
return INFO_ERROR;
albumInfo = scraper.GetAlbum(iSelectedAlbum);
if (result == CNfoFile::COMBINED_NFO)
nfoReader.GetDetails(albumInfo.GetAlbum(), NULL, true);
return INFO_ADDED;
}
示例9: SelectAddonID
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;
}
示例10: DownloadArtistInfo
//.........这里部分代码省略.........
if (!scraper.GetArtistCount())
scraper.FindArtistinfo(strArtist);
while (!scraper.Completed())
{
if (m_bStop)
{
scraper.Cancel();
break;
}
Sleep(1);
}
if (scraper.Successfull() && scraper.GetArtistCount() >= 1)
{
int iSelectedArtist = 0;
// now load the first match
if (pDialog && scraper.GetArtistCount() > 1)
{
// if we found more then 1 album, let user choose one
CGUIDialogSelect *pDlg = (CGUIDialogSelect*)m_gWindowManager.GetWindow(WINDOW_DIALOG_SELECT);
if (pDlg)
{
pDlg->SetHeading(g_localizeStrings.Get(21890));
pDlg->Reset();
pDlg->EnableButton(true);
pDlg->SetButtonLabel(413); // manual
for (int i = 0; i < scraper.GetArtistCount(); ++i)
{
// set the label to artist
CFileItem item(scraper.GetArtist(i).GetArtist());
CStdString strTemp=scraper.GetArtist(i).GetArtist().strArtist;
if (!scraper.GetArtist(i).GetArtist().strBorn.IsEmpty())
strTemp += " ("+scraper.GetArtist(i).GetArtist().strBorn+")";
if (!scraper.GetArtist(i).GetArtist().strGenre.IsEmpty())
strTemp.Format("[%s] %s",scraper.GetArtist(i).GetArtist().strGenre.c_str(),strTemp.c_str());
item.SetLabel(strTemp);
item.m_idepth = i; // use this to hold the index of the album in the scraper
pDlg->Add(&item);
}
pDlg->DoModal();
// and wait till user selects one
if (pDlg->GetSelectedLabel() < 0)
{ // none chosen
if (!pDlg->IsButtonPressed()) return false;
// manual button pressed
CStdString strNewArtist = strArtist;
if (!CGUIDialogKeyboard::ShowAndGetInput(strNewArtist, g_localizeStrings.Get(16025), false)) return false;
if (pDialog)
{
pDialog->SetLine(0, strNewArtist);
pDialog->Progress();
}
m_musicDatabase.Close();
return DownloadArtistInfo(strPath,strArtist,pDialog);
}
iSelectedArtist = pDlg->GetSelectedItem().m_idepth;
}
}
scraper.LoadArtistinfo(iSelectedArtist);
while (!scraper.Completed())
{
if (m_bStop)
{
scraper.Cancel();
break;
}
Sleep(1);
}
if (scraper.Successfull())
{
artist = scraper.GetArtist(iSelectedArtist).GetArtist();
m_musicDatabase.SetArtistInfo(params.GetArtistId(), artist);
}
}
else
{
m_musicDatabase.Close();
return false;
}
// check thumb stuff
if (artist.thumbURL.m_url.size())
{
CFileItem item(strArtist);
CStdString thumb = item.GetCachedArtistThumb();
if (!XFILE::CFile::Exists(thumb))
CScraperUrl::DownloadThumbnail(thumb,artist.thumbURL.m_url[0]);
}
m_musicDatabase.Close();
return true;
}
示例11: SelectAddonID
int CGUIWindowAddonBrowser::SelectAddonID(ADDON::TYPE type, CStdStringArray &addonIDs, bool showNone /*= false*/, bool multipleSelection /*= true*/)
{
CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
if (type == ADDON_UNKNOWN || !dialog)
return 0;
ADDON::VECADDONS addons;
if (type == ADDON_AUDIO)
CAddonsDirectory::GetScriptsAndPlugins("audio",addons);
else if (type == ADDON_EXECUTABLE)
CAddonsDirectory::GetScriptsAndPlugins("executable",addons);
else if (type == ADDON_IMAGE)
CAddonsDirectory::GetScriptsAndPlugins("image",addons);
else if (type == ADDON_VIDEO)
CAddonsDirectory::GetScriptsAndPlugins("video",addons);
else
CAddonMgr::Get().GetAddons(type, addons);
CFileItemList items;
for (ADDON::IVECADDONS i = addons.begin(); i != addons.end(); ++i)
items.Add(CAddonsDirectory::FileItemFromAddon(*i, ""));
dialog->SetHeading(TranslateType(type, true));
dialog->Reset();
dialog->SetUseDetails(true);
if (multipleSelection)
{
showNone = false;
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(SORT_ON_TOP);
items.Add(item);
}
items.Sort(SORT_METHOD_LABEL, SORT_ORDER_ASC);
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 && dialog->IsButtonPressed())
{ // switch to the addons browser.
vector<CStdString> params;
params.push_back("addons://all/"+TranslateType(type,false)+"/");
params.push_back("return");
g_windowManager.ActivateWindow(WINDOW_ADDON_BROWSER, params);
return 2;
}
if (!multipleSelection && dialog->GetSelectedLabel() == -1)
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;
}
示例12: GetSearchResults
//.........这里部分代码省略.........
{
strResult += strSearch[i];
if (!isdigit(strSearch[i]))
break;
}
if (i == 8)
{
return true; // match
}
}
// no match, wipe string
strResult = "";
}
CGUIDialogSelect *pDlgSelect = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
CGUIDialogProgress *pDlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
//do the download
CStdString strURL;
CStdString strXML;
XFILE::CFileCurl httpUtil;
if (pDlgProgress)
{
pDlgProgress->SetHeading(410); //"Accessing Weather.com"
pDlgProgress->SetLine(0, 194); //"Searching"
pDlgProgress->SetLine(1, strSearch);
pDlgProgress->SetLine(2, "");
pDlgProgress->StartModal();
pDlgProgress->Progress();
}
strURL.Format("http://xoap.weather.com/search/search?where=%s", strSearch);
if (!httpUtil.Get(strURL, strXML))
{
if (pDlgProgress)
pDlgProgress->Close();
return false;
}
//some select dialog init stuff
if (!pDlgSelect)
{
if (pDlgProgress)
pDlgProgress->Close();
return false;
}
pDlgSelect->SetHeading(396); //"Select Location"
pDlgSelect->Reset();
///////////////////////////////
// load the xml file
///////////////////////////////
TiXmlDocument xmlDoc;
xmlDoc.Parse(strXML.c_str());
if (xmlDoc.Error())
return false;
TiXmlElement *pRootElement = xmlDoc.RootElement();
if (pRootElement)
{
CStdString strItemTmp;
TiXmlElement *pElement = pRootElement->FirstChildElement("loc");
while (pElement)
{
if (!pElement->NoChildren())
{
strItemTmp.Format("%s - %s", pElement->Attribute("id"), pElement->FirstChild()->Value());
pDlgSelect->Add(strItemTmp);
}
pElement = pElement->NextSiblingElement("loc");
}
}
if (pDlgProgress)
pDlgProgress->Close();
pDlgSelect->EnableButton(true, 222); //'Cancel' button returns to weather settings
pDlgSelect->DoModal();
if (pDlgSelect->GetSelectedLabel() < 0)
{
if (pDlgSelect->IsButtonPressed())
{
pDlgSelect->Close(); //close the select dialog and return to weather settings
return true;
}
}
//copy the selected code into the settings
if (pDlgSelect->GetSelectedLabel() >= 0)
strResult = pDlgSelect->GetSelectedLabelText();
if (pDlgProgress)
pDlgProgress->Close();
return true;
}