Esempio n. 1
0
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;
}
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->OffsetPosition(posX, posY);
  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;
}