本文整理汇总了C++中CGUIDialogContextMenu类的典型用法代码示例。如果您正苦于以下问题:C++ CGUIDialogContextMenu类的具体用法?C++ CGUIDialogContextMenu怎么用?C++ CGUIDialogContextMenu使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CGUIDialogContextMenu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnRollback
void CGUIDialogAddonInfo::OnRollback()
{
CGUIDialogContextMenu* dlg = (CGUIDialogContextMenu*)g_windowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU);
CAddonDatabase database;
database.Open();
CContextButtons buttons;
for (unsigned int i=0;i<m_rollbackVersions.size();++i)
{
CStdString label(m_rollbackVersions[i]);
if (m_rollbackVersions[i].Equals(m_localAddon->Version().c_str()))
label += " "+g_localizeStrings.Get(24094);
if (database.IsAddonBlacklisted(m_localAddon->ID(),label))
label += " "+g_localizeStrings.Get(24095);
buttons.Add(i,label);
}
int choice;
if ((choice=dlg->ShowAndGetChoice(buttons)) > -1)
{
// blacklist everything newer
for (unsigned int j=choice+1;j<m_rollbackVersions.size();++j)
database.BlacklistAddon(m_localAddon->ID(),m_rollbackVersions[j]);
CStdString path = "special://home/addons/packages/";
path += m_localAddon->ID()+"-"+m_rollbackVersions[choice]+".zip";
// needed as cpluff won't downgrade
if (!m_localAddon->IsType(ADDON_SERVICE))
//we will handle this for service addons in CAddonInstallJob::OnPostInstall
CAddonMgr::Get().RemoveAddon(m_localAddon->ID());
CAddonInstaller::Get().InstallFromZip(path);
database.RemoveAddonFromBlacklist(m_localAddon->ID(),m_rollbackVersions[choice]);
Close();
}
}
示例2: open
int Interface_GUIDialogContextMenu::open(void* kodiBase, const char *heading, const char *entries[], unsigned int size)
{
CAddonDll* addon = static_cast<CAddonDll*>(kodiBase);
if (!addon)
{
CLog::Log(LOGERROR, "Interface_GUIDialogContextMenu::%s - invalid data", __FUNCTION__);
return -1;
}
CGUIDialogContextMenu* dialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogContextMenu>(WINDOW_DIALOG_CONTEXT_MENU);
if (!heading || !entries || !dialog)
{
CLog::Log(LOGERROR,
"Interface_GUIDialogContextMenu::%s - invalid handler data (heading='%p', "
"entries='%p', dialog='%p') on addon '%s'",
__FUNCTION__, heading, static_cast<const void*>(entries), kodiBase,
addon->ID().c_str());
return -1;
}
CContextButtons choices;
for (unsigned int i = 0; i < size; ++i)
choices.Add(i, entries[i]);
return dialog->Show(choices);
}
示例3: ShowAndGetChoice
int CGUIDialogContextMenu::ShowAndGetChoice(const vector<CStdString> &choices, const CPoint &pos)
{
// no choices??
if (choices.size() == 0)
return 0;
// popup the context menu
CGUIDialogContextMenu *pMenu = (CGUIDialogContextMenu *)m_gWindowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU);
if (pMenu)
{
// load our menu
pMenu->Initialize();
for (unsigned int i = 0; i < choices.size(); i++)
pMenu->AddButton(choices[i]);
// position it correctly
pMenu->SetPosition(pos.x - pMenu->GetWidth() / 2, pos.y - pMenu->GetHeight() / 2);
pMenu->DoModal();
if (pMenu->GetButton() > 0)
return pMenu->GetButton();
}
return 0;
}
示例4: SelectPlayerDialog
EPLAYERCORES CPlayerCoreFactory::SelectPlayerDialog(VECPLAYERCORES &vecCores, float posX, float posY)
{
CGUIDialogContextMenu *pMenu = (CGUIDialogContextMenu *)m_gWindowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU);
// Reset menu
pMenu->Initialize();
// Add all possible players
auto_aptr<int> btn_Cores(NULL);
if( vecCores.size() > 0 )
{
btn_Cores = new int[ vecCores.size() ];
btn_Cores[0] = 0;
CStdString strCaption;
//Add default player
strCaption = CPlayerCoreFactory::GetPlayerName(vecCores[0]);
strCaption += " (";
strCaption += g_localizeStrings.Get(13278);
strCaption += ")";
btn_Cores[0] = pMenu->AddButton(strCaption);
//Add all other players
for( unsigned int i = 1; i < vecCores.size(); i++ )
{
strCaption = CPlayerCoreFactory::GetPlayerName(vecCores[i]);
btn_Cores[i] = pMenu->AddButton(strCaption);
}
}
// Display menu
if (posX && posY)
pMenu->SetPosition(posX - pMenu->GetWidth() / 2, posY - pMenu->GetHeight() / 2);
else
pMenu->CenterWindow();
pMenu->DoModal();
//Check what player we selected
int btnid = pMenu->GetButton();
for( unsigned int i = 0; i < vecCores.size(); i++ )
{
if( btnid == btn_Cores[i] )
{
return vecCores[i];
}
}
return EPC_NONE;
}
示例5: SourcesMenu
bool CGUIDialogContextMenu::SourcesMenu(const CStdString &strType, const CFileItemPtr item, float posX, float posY)
{
// TODO: This should be callable even if we don't have any valid items
if (!item)
return false;
// popup the context menu
CGUIDialogContextMenu *pMenu = (CGUIDialogContextMenu *)g_windowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU);
if (pMenu)
{
// load our menu
pMenu->Initialize();
// grab our context menu
CContextButtons buttons;
GetContextButtons(strType, item, buttons);
// add the buttons and execute it
for (CContextButtons::iterator it = buttons.begin(); it != buttons.end(); it++)
pMenu->AddButton((*it).second);
// position it correctly
pMenu->OffsetPosition(posX, posY);
pMenu->DoModal();
// translate our button press
CONTEXT_BUTTON btn = CONTEXT_BUTTON_CANCELLED;
if (pMenu->GetButton() > 0 && pMenu->GetButton() <= (int)buttons.size())
btn = buttons[pMenu->GetButton() - 1].first;
if (btn != CONTEXT_BUTTON_CANCELLED)
return OnContextButton(strType, item, btn);
}
return false;
}
示例6: ShowAndGetChoice
int CGUIDialogContextMenu::ShowAndGetChoice(const vector<CStdString> &choices, const CPoint *pos)
{
// no choices??
if (choices.size() == 0)
return 0;
// popup the context menu
CGUIDialogContextMenu *pMenu = (CGUIDialogContextMenu *)g_windowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU);
if (pMenu)
{
// load our menu
pMenu->Initialize();
for (unsigned int i = 0; i < choices.size(); i++)
pMenu->AddButton(choices[i]);
// position it correctly
if (pos)
pMenu->OffsetPosition(pos->x, pos->y);
else
pMenu->PositionAtCurrentFocus();
pMenu->DoModal();
if (pMenu->GetButton() > 0)
return pMenu->GetButton();
}
return 0;
}
示例7: GetContextButtons
bool CGUIMediaWindow::OnPopupMenu(int iItem)
{
// popup the context menu
// grab our context menu
CContextButtons buttons;
GetContextButtons(iItem, buttons);
if (buttons.size())
{
// mark the item
if (iItem >= 0 && iItem < m_vecItems->Size())
m_vecItems->Get(iItem)->Select(true);
CGUIDialogContextMenu *pMenu = (CGUIDialogContextMenu *)m_gWindowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU);
if (!pMenu) return false;
// load our menu
pMenu->Initialize();
// add the buttons and execute it
for (CContextButtons::iterator it = buttons.begin(); it != buttons.end(); it++)
pMenu->AddButton((*it).second);
// position it correctly
float posX = 200;
float posY = 100;
const CGUIControl *pList = GetControl(CONTROL_VIEW_START);
if (pList)
{
posX = pList->GetXPosition() + pList->GetWidth() / 2;
posY = pList->GetYPosition() + pList->GetHeight() / 2;
}
pMenu->SetPosition(posX - pMenu->GetWidth() / 2, posY - pMenu->GetHeight() / 2);
pMenu->DoModal();
// translate our button press
CONTEXT_BUTTON btn = CONTEXT_BUTTON_CANCELLED;
if (pMenu->GetButton() > 0 && pMenu->GetButton() <= (int)buttons.size())
btn = buttons[pMenu->GetButton() - 1].first;
// deselect our item
if (iItem >= 0 && iItem < m_vecItems->Size())
m_vecItems->Get(iItem)->Select(false);
if (btn != CONTEXT_BUTTON_CANCELLED)
return OnContextButton(iItem, btn);
}
return false;
}
示例8: ShowAndGetChoice
int CGUIDialogContextMenu::ShowAndGetChoice(const CContextButtons &choices)
{
if (choices.size() == 0)
return -1;
CGUIDialogContextMenu *pMenu = (CGUIDialogContextMenu *)g_windowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU);
if (pMenu)
{
pMenu->m_buttons = choices;
pMenu->Initialize();
pMenu->PositionAtCurrentFocus();
pMenu->DoModal();
return pMenu->m_clickedButton;
}
return -1;
}
示例9: AddEpisodeBookmark
void CGUIDialogVideoBookmarks::AddEpisodeBookmark()
{
vector<CVideoInfoTag> episodes;
CVideoDatabase videoDatabase;
CPoint pos;
videoDatabase.Open();
videoDatabase.GetEpisodesByFile(g_application.CurrentFile(), episodes);
videoDatabase.Close();
if(episodes.size() > 0)
{
CGUIDialogContextMenu *pMenu = (CGUIDialogContextMenu *)g_windowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU);
map<int, CVideoInfoTag*> buttons;
const CGUIControl *pList = GetControl(CONTROL_ADD_EPISODE_BOOKMARK);
if (pList)
pos = pList->GetRenderPosition() + CPoint(pList->GetWidth() * 0.5f, pList->GetHeight() * 0.5f);
if (pMenu)
{
pMenu->Initialize();
for (unsigned int i=0; i < episodes.size(); ++i)
{
CStdString strButton;
strButton.Format("%s %i, %s %i", g_localizeStrings.Get(20373), episodes[i].m_iSeason, g_localizeStrings.Get(20359).c_str(), episodes[i].m_iEpisode);
buttons[pMenu->AddButton(strButton)] = &episodes[i];
}
pMenu->OffsetPosition(pos.x, pos.y);
pMenu->DoModal(GetID());
int pressed = pMenu->GetButton();
if (buttons.find(pressed) != buttons.end())
AddBookmark(buttons[pressed]);
}
}
}
示例10: SwitchMedia
void CGUIDialogContextMenu::SwitchMedia(const CStdString& strType, const CStdString& strPath)
{
// what should we display?
vector <CStdString> vecTypes;
if (!strType.Equals("music"))
vecTypes.push_back(g_localizeStrings.Get(2)); // My Music
if (!strType.Equals("video"))
vecTypes.push_back(g_localizeStrings.Get(3)); // My Videos
if (!strType.Equals("pictures"))
vecTypes.push_back(g_localizeStrings.Get(1)); // My Pictures
if (!strType.Equals("files"))
vecTypes.push_back(g_localizeStrings.Get(7)); // My Files
// something went wrong
if (vecTypes.size() != 3)
return;
// create menu
CGUIDialogContextMenu *pMenu = (CGUIDialogContextMenu *)m_gWindowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU);
pMenu->Initialize();
// add buttons
int btn_Type[3];
for (int i=0; i<3; i++)
{
btn_Type[i] = pMenu->AddButton(vecTypes[i]);
}
// display menu
pMenu->CenterWindow();
pMenu->DoModal();
// check selection
int btn = pMenu->GetButton();
for (int i=0; i<3; i++)
{
if (btn == btn_Type[i])
{
// map back to correct window
int iWindow = WINDOW_INVALID;
if (vecTypes[i].Equals(g_localizeStrings.Get(2)))
iWindow = WINDOW_MUSIC_FILES;
else if (vecTypes[i].Equals(g_localizeStrings.Get(3)))
iWindow = WINDOW_VIDEO_FILES;
else if (vecTypes[i].Equals(g_localizeStrings.Get(1)))
iWindow = WINDOW_PICTURES;
else if (vecTypes[i].Equals(g_localizeStrings.Get(7)))
iWindow = WINDOW_FILES;
//m_gWindowManager.ActivateWindow(iWindow, strPath);
CUtil::ClearFileItemCache();
m_gWindowManager.ChangeActiveWindow(iWindow, strPath);
return;
}
}
return;
}
示例11: OnRollback
void CGUIDialogAddonInfo::OnRollback()
{
if (!g_passwordManager.CheckMenuLock(WINDOW_ADDON_BROWSER))
return;
CGUIDialogContextMenu* dlg = (CGUIDialogContextMenu*)g_windowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU);
CAddonDatabase database;
database.Open();
CContextButtons buttons;
for (unsigned int i=0;i<m_rollbackVersions.size();++i)
{
std::string label(m_rollbackVersions[i]);
if (m_rollbackVersions[i] == m_localAddon->Version().asString())
label += " "+g_localizeStrings.Get(24094);
if (database.IsAddonBlacklisted(m_localAddon->ID(),label))
label += " "+g_localizeStrings.Get(24095);
buttons.Add(i,label);
}
int choice;
if ((choice=dlg->ShowAndGetChoice(buttons)) > -1)
{
// blacklist everything newer
for (unsigned int j=choice+1;j<m_rollbackVersions.size();++j)
database.BlacklistAddon(m_localAddon->ID(),m_rollbackVersions[j]);
std::string path = "special://home/addons/packages/";
path += m_localAddon->ID()+"-"+m_rollbackVersions[choice]+".zip";
//FIXME: this is probably broken
// needed as cpluff won't downgrade
CAddonInstaller::GetInstance().InstallFromZip(path);
database.RemoveAddonFromBlacklist(m_localAddon->ID(),m_rollbackVersions[choice]);
Close();
}
}
示例12: OnPopupMenu
void CGUIDialogFavourites::OnPopupMenu(int item)
{
if (item < 0 || item >= m_favourites->Size())
return;
CGUIDialogContextMenu *pMenu = (CGUIDialogContextMenu *)m_gWindowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU);
if (pMenu)
{
// highlight the item
(*m_favourites)[item]->Select(true);
// initialize the positioning
CPoint pos;
const CGUIControl *pList = GetControl(FAVOURITES_LIST);
if (pList)
pos = pList->GetRenderPosition() + CPoint(pList->GetWidth() * 0.5f, pList->GetHeight() * 0.5f);
pMenu->Initialize();
int btn_MoveUp = m_favourites->Size() > 1 ? pMenu->AddButton(13332) : 0;
int btn_MoveDown = m_favourites->Size() > 1 ? pMenu->AddButton(13333) : 0;
int btn_Remove = pMenu->AddButton(15015);
int btn_Rename = pMenu->AddButton(118);
pMenu->OffsetPosition(pos.x, pos.y);
pMenu->DoModal(GetID());
int button = pMenu->GetButton();
// unhighlight the item
(*m_favourites)[item]->Select(false);
if (button == btn_MoveUp)
OnMoveItem(item, -1);
else if (button == btn_MoveDown)
OnMoveItem(item, 1);
else if (button == btn_Remove)
OnDelete(item);
else if (button == btn_Rename)
OnRename(item);
}
}
示例13: GetContextButtons
bool CGUIMediaWindow::OnPopupMenu(int iItem)
{
// popup the context menu
// grab our context menu
CContextButtons buttons;
GetContextButtons(iItem, buttons);
if (buttons.size())
{
// mark the item
if (iItem >= 0 && iItem < m_vecItems->Size())
m_vecItems->Get(iItem)->Select(true);
CGUIDialogContextMenu *pMenu = (CGUIDialogContextMenu *)m_gWindowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU);
if (!pMenu) return false;
// load our menu
pMenu->Initialize();
// add the buttons and execute it
for (CContextButtons::iterator it = buttons.begin(); it != buttons.end(); it++)
pMenu->AddButton((*it).second);
// position it correctly
CPoint pos = GetContextPosition();
pMenu->OffsetPosition(pos.x, pos.y);
pMenu->DoModal();
// translate our button press
CONTEXT_BUTTON btn = CONTEXT_BUTTON_CANCELLED;
if (pMenu->GetButton() > 0 && pMenu->GetButton() <= (int)buttons.size())
btn = buttons[pMenu->GetButton() - 1].first;
// deselect our item
if (iItem >= 0 && iItem < m_vecItems->Size())
m_vecItems->Get(iItem)->Select(false);
if (btn != CONTEXT_BUTTON_CANCELLED)
return OnContextButton(iItem, btn);
}
return false;
}
示例14: ShowAndGetChoice
int CGUIDialogContextMenu::ShowAndGetChoice(const CContextButtons &choices)
{
if (choices.empty())
return -1;
CGUIDialogContextMenu *pMenu = g_windowManager.GetWindow<CGUIDialogContextMenu>(WINDOW_DIALOG_CONTEXT_MENU);
if (pMenu)
{
pMenu->m_buttons = choices;
pMenu->Initialize();
pMenu->SetInitialVisibility();
pMenu->SetupButtons();
pMenu->PositionAtCurrentFocus();
pMenu->Open();
int idx = pMenu->m_clickedButton;
if (idx != -1)
return choices[idx].first;
}
return -1;
}
示例15: SelectItem
void CGUIWindowFileManager::OnPopupMenu(int list, int item, bool bContextDriven /* = true */)
{
if (list < 0 || list > 2) return ;
bool bDeselect = SelectItem(list, item);
// calculate the position for our menu
float posX = 200;
float posY = 100;
const CGUIControl *pList = GetControl(CONTROL_LEFT_LIST + list);
if (pList)
{
posX = pList->GetXPosition() + pList->GetWidth() / 2;
posY = pList->GetYPosition() + pList->GetHeight() / 2;
}
CFileItemPtr pItem = m_vecItems[list]->Get(item);
if (!pItem.get())
return;
if (m_Directory[list]->IsVirtualDirectoryRoot())
{
if (item < 0)
{ // TODO: We should add the option here for shares to be added if there aren't any
return ;
}
// and do the popup menu
if (CGUIDialogContextMenu::SourcesMenu("files", pItem, posX, posY))
{
m_rootDir.SetSources(g_settings.m_fileSources);
if (m_Directory[1 - list]->IsVirtualDirectoryRoot())
Refresh();
else
Refresh(list);
return ;
}
pItem->Select(false);
return ;
}
// popup the context menu
CGUIDialogContextMenu *pMenu = (CGUIDialogContextMenu *)m_gWindowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU);
if (pMenu)
{
bool showEntry = false;
if (item >= m_vecItems[list]->Size()) item = -1;
if (item >= 0)
showEntry=(!pItem->IsParentFolder() || (pItem->IsParentFolder() && m_vecItems[list]->GetSelectedCount()>0));
// determine available players
VECPLAYERCORES vecCores;
CPlayerCoreFactory::GetPlayers(*pItem, vecCores);
// load our menu
pMenu->Initialize();
// add the needed buttons
int btn_SelectAll = pMenu->AddButton(188); // SelectAll
int btn_HandleFavourite; // Add/Remove Favourite
if (CFavourites::IsFavourite(pItem.get(), GetID()))
btn_HandleFavourite = pMenu->AddButton(14077);
else
btn_HandleFavourite = pMenu->AddButton(14076);
int btn_PlayUsing = pMenu->AddButton(15213); // Play Using ..
int btn_Rename = pMenu->AddButton(118); // Rename
int btn_Delete = pMenu->AddButton(117); // Delete
int btn_Copy = pMenu->AddButton(115); // Copy
int btn_Move = pMenu->AddButton(116); // Move
int btn_NewFolder = pMenu->AddButton(20309); // New Folder
int btn_Size = pMenu->AddButton(13393); // Calculate Size
int btn_Settings = pMenu->AddButton(5); // Settings
int btn_GoToRoot = pMenu->AddButton(20128); // Go To Root
int btn_Switch = pMenu->AddButton(523); // switch media
pMenu->EnableButton(btn_SelectAll, item >= 0);
pMenu->EnableButton(btn_HandleFavourite, item >=0 && !pItem->IsParentFolder());
pMenu->EnableButton(btn_PlayUsing, item >= 0 && vecCores.size() > 1);
pMenu->EnableButton(btn_Rename, item >= 0 && CanRename(list) && !pItem->IsParentFolder());
pMenu->EnableButton(btn_Delete, item >= 0 && CanDelete(list) && showEntry);
pMenu->EnableButton(btn_Copy, item >= 0 && CanCopy(list) && showEntry);
pMenu->EnableButton(btn_Move, item >= 0 && CanMove(list) && showEntry);
pMenu->EnableButton(btn_NewFolder, CanNewFolder(list));
pMenu->EnableButton(btn_Size, item >=0 && pItem->m_bIsFolder && !pItem->IsParentFolder());
// position it correctly
pMenu->OffsetPosition(posX, posY);
pMenu->DoModal();
int btnid = pMenu->GetButton();
if (btnid == btn_SelectAll)
{
OnSelectAll(list);
bDeselect=false;
}
if (btnid == btn_HandleFavourite)
{
CFavourites::AddOrRemove(pItem.get(), GetID());
return;
}
if (btnid == btn_PlayUsing)
{
VECPLAYERCORES vecCores;
//.........这里部分代码省略.........