int CGUIWindowFileManager::GetSelectedItem(int iControl)
{
  if (iControl < 0 || iControl > 1) return -1;
  CGUIListContainer *pControl = (CGUIListContainer *)GetControl(iControl + CONTROL_LEFT_LIST);
  if (!pControl || !m_vecItems[iControl]->Size()) return -1;
  return pControl->GetSelectedItem();
}
Example #2
0
bool CGUIDialogAudioDSPManager::OnClickListActive(CGUIMessage &message)
{
    if (!m_bMovingMode)
    {
        int iAction = message.GetParam1();
        int iItem = m_activeViewControl.GetSelectedItem();

        /* Check file item is in list range and get his pointer */
        if (iItem < 0 || iItem >= (int)m_activeItems[m_iCurrentType]->Size()) return true;

        /* Process actions */
        if (iAction == ACTION_SELECT_ITEM || iAction == ACTION_CONTEXT_MENU || iAction == ACTION_MOUSE_LEFT_CLICK || iAction == ACTION_MOUSE_RIGHT_CLICK)
        {
            /* Show Contextmenu */
            OnPopupMenu(iItem, LIST_ACTIVE);

            return true;
        }
    }
    else
    {
        CFileItemPtr pItem = m_activeItems[m_iCurrentType]->Get(m_iSelected[LIST_ACTIVE]);
        if (pItem)
        {
            pItem->Select(false);
            pItem->SetProperty("Changed", true);
            m_bMovingMode = false;
            m_bContainsChanges = true;

            if (m_bContinousSaving)
            {
                SaveList();
            }

            CGUIListContainer *modeList = dynamic_cast<CGUIListContainer*>(GetControl(CONTROL_LIST_MODE_SELECTION));
            CGUIButtonControl *applyButton = dynamic_cast<CGUIButtonControl*>(GetControl(CONTROL_BUTTON_APPLY_CHANGES));
            CGUIButtonControl *clearActiveModesButton = dynamic_cast<CGUIButtonControl*>(GetControl(CONTROL_BUTTON_CLEAR_ACTIVE_MODES));
            if (!modeList || !applyButton || !clearActiveModesButton)
            {
                helper_LogError(__FUNCTION__);
                return false;
            }

            // reenable all buttons and mode selection list
            modeList->SetEnabled(true);
            clearActiveModesButton->SetEnabled(true);
            if (!m_bContinousSaving)
            {
                applyButton->SetEnabled(true);
            }

            return true;
        }
    }

    return false;
}
bool CGUIDialogVisualisationPresetList::OnMessage(CGUIMessage &message)
{
  switch (message.GetMessage())
  {
  case GUI_MSG_CLICKED:
    {
      if (message.GetSenderId() == CONTROL_LIST && (message.GetParam1() == ACTION_SELECT_ITEM ||
                                                    message.GetParam1() == ACTION_MOUSE_LEFT_CLICK))
      {
        //clicked - ask for the preset to be changed to the new one
        CGUIListContainer *pList = (CGUIListContainer *)GetControl(CONTROL_LIST);
        if (pList)
        {
          int iItem = pList->GetSelectedItem();
          if (m_viz)
            m_viz->OnAction(VIS_ACTION_LOAD_PRESET, (void *)&iItem);
        }
        return true;
      }
    }
    break;
  case GUI_MSG_WINDOW_INIT:
    {
      CGUIDialog::OnMessage(message);

      CGUIMessage msg(GUI_MSG_GET_VISUALISATION, 0, 0);
      g_windowManager.SendMessage(msg);
      SetVisualisation((CVisualisation*)msg.GetPointer());
      return true;
    }
    break;
  case GUI_MSG_WINDOW_DEINIT:
  case GUI_MSG_VISUALISATION_UNLOADING:
    {
      m_viz = NULL;
      CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), CONTROL_LIST);
      OnMessage(msg);
      Update();
    }
    break;
  case GUI_MSG_VISUALISATION_LOADED:
    {
      SetVisualisation((CVisualisation*)message.GetPointer());
    }
    break;
  }
  return CGUIDialog::OnMessage(message);
}
Example #4
0
bool CGUIDialogAudioDSPManager::OnMessage(CGUIMessage& message)
{
    unsigned int iMessage = message.GetMessage();

    switch (iMessage)
    {
    case GUI_MSG_CLICKED:
        return OnMessageClick(message);

    case GUI_MSG_ITEM_SELECT:
    {
        int focusedControl = GetFocusedControlID();
        if (focusedControl == CONTROL_LIST_MODE_SELECTION)
        {
            CGUIListContainer *modeListPtr = dynamic_cast<CGUIListContainer*>(GetControl(CONTROL_LIST_MODE_SELECTION));

            if (modeListPtr)
            {
                CGUIListItemPtr modeListItem = modeListPtr->GetListItem(0); // get current selected list item
                if (modeListItem)
                {
                    std::string currentModeString = modeListItem->GetProperty("currentMode").asString();
                    int newModeType = helper_TranslateModeType(currentModeString);

                    if (m_iCurrentType != newModeType)
                    {
                        m_iCurrentType = newModeType;
                        SetSelectedModeType();
                    }
                }
            }
        }
    }
    }

    return CGUIDialog::OnMessage(message);
}
Example #5
0
bool CGUIDialogAudioDSPManager::OnContextButton(int itemNumber, CONTEXT_BUTTON button, int listType)
{
    CFileItemPtr pItem;
    int listSize = 0;
    if (listType == LIST_ACTIVE)
    {
        pItem = m_activeItems[m_iCurrentType]->Get(itemNumber);
        listSize = m_activeItems[m_iCurrentType]->Size();
    }
    else if (listType == LIST_AVAILABLE)
    {
        pItem = m_availableItems[m_iCurrentType]->Get(itemNumber);
        listSize = m_availableItems[m_iCurrentType]->Size();
    }

    /* Check file item is in list range and get his pointer */
    if (!pItem || itemNumber < 0 || itemNumber >= listSize)
    {
        return false;
    }

    if (button == CONTEXT_BUTTON_HELP)
    {
        /*!
        * Open audio dsp addon mode help text dialog
        */
        AE_DSP_ADDON addon;
        if (CServiceBroker::GetADSP().GetAudioDSPAddon((int)pItem->GetProperty("AddonId").asInteger(), addon))
        {
            CGUIDialogTextViewer* pDlgInfo = (CGUIDialogTextViewer*)g_windowManager.GetWindow(WINDOW_DIALOG_TEXT_VIEWER);
            pDlgInfo->SetHeading(g_localizeStrings.Get(15062) + " - " + pItem->GetProperty("Name").asString());
            pDlgInfo->SetText(g_localizeStrings.GetAddonString(addon->ID(), (uint32_t)pItem->GetProperty("Help").asInteger()));
            pDlgInfo->Open();
        }
    }
    else if (button == CONTEXT_BUTTON_ACTIVATE)
    {
        /*!
        * Deactivate selected processing mode
        */
        if (pItem->GetProperty("ActiveMode").asBoolean())
        {
            // remove mode from active mode list and add it to available mode list
            CFileItemPtr newItem(dynamic_cast<CFileItem*>(pItem->Clone()));
            newItem->SetProperty("ActiveMode", false);
            newItem->SetProperty("Changed", true);
            m_activeItems[m_iCurrentType]->Remove(itemNumber);
            m_availableItems[m_iCurrentType]->Add(newItem);
        }
        else
        {
            /*!
            * Activate selected processing mode
            */
            if ((m_iCurrentType == AE_DSP_MODE_TYPE_INPUT_RESAMPLE || m_iCurrentType == AE_DSP_MODE_TYPE_OUTPUT_RESAMPLE) && m_activeItems[m_iCurrentType]->Size() > 0)
            {   // if there is already an active resampler, now we remove it
                CFileItemPtr activeResampler = m_activeItems[m_iCurrentType]->Get(0);
                if (activeResampler)
                {
                    CFileItemPtr newItem(dynamic_cast<CFileItem*>(activeResampler->Clone()));
                    newItem->SetProperty("ActiveMode", false);
                    newItem->SetProperty("Changed", true);

                    m_availableItems[m_iCurrentType]->Add(newItem);
                    // clear active list, because only one active resampling mode is supported by ActiveAEDSP
                    m_activeItems[m_iCurrentType]->Clear();
                }
            }

            // remove mode from available mode list and add it to active mode list
            CFileItemPtr newItem(dynamic_cast<CFileItem*>(pItem->Clone()));

            newItem->SetProperty("Number", (int)m_activeItems[m_iCurrentType]->Size() +1);
            newItem->SetProperty("Changed", true);
            newItem->SetProperty("ActiveMode", true);

            m_availableItems[m_iCurrentType]->Remove(itemNumber);
            m_activeItems[m_iCurrentType]->Add(newItem);
        }

        m_bContainsChanges = true;
        if (m_bContinousSaving)
        {
            SaveList();
        }

        // reorder available mode list, so that the mode order is always consistent
        m_availableItems[m_iCurrentType]->ClearSortState();
        m_availableItems[m_iCurrentType]->Sort(SortByLabel, SortOrderAscending);

        // update active and available mode list
        Renumber();
        m_availableViewControl.SetItems(*m_availableItems[m_iCurrentType]);
        m_activeViewControl.SetItems(*m_activeItems[m_iCurrentType]);
    }
    else if (button == CONTEXT_BUTTON_MOVE)
    {
        m_bMovingMode = true;
        pItem->Select(true);

        CGUIListContainer *modeList = dynamic_cast<CGUIListContainer*>(GetControl(CONTROL_LIST_MODE_SELECTION));
        CGUIButtonControl *applyButton = dynamic_cast<CGUIButtonControl*>(GetControl(CONTROL_BUTTON_APPLY_CHANGES));
        CGUIButtonControl *clearActiveModesButton = dynamic_cast<CGUIButtonControl*>(GetControl(CONTROL_BUTTON_CLEAR_ACTIVE_MODES));
        if (!modeList || !applyButton || !clearActiveModesButton)
        {
            helper_LogError(__FUNCTION__);
            return false;
        }

        // if we are in MovingMode all buttons and mode selection list will be disabled!
        modeList->SetEnabled(false);
        clearActiveModesButton->SetEnabled(false);
        if (!m_bContinousSaving)
        {
            applyButton->SetEnabled(false);
        }
    }
    else if (button == CONTEXT_BUTTON_SETTINGS)
    {
        int hookId = (int)pItem->GetProperty("SettingsDialog").asInteger();
        if (hookId > 0)
        {
            AE_DSP_ADDON addon;
            if (CServiceBroker::GetADSP().GetAudioDSPAddon((int)pItem->GetProperty("AddonId").asInteger(), addon))
            {
                AE_DSP_MENUHOOK       hook;
                AE_DSP_MENUHOOK_DATA  hookData;

                hook.category           = AE_DSP_MENUHOOK_ALL;
                hook.iHookId            = hookId;
                hook.iRelevantModeId    = (unsigned int)pItem->GetProperty("AddonModeNumber").asInteger();
                hookData.category       = AE_DSP_MENUHOOK_ALL;
                hookData.data.iStreamId = -1;

                /*!
                 * @note the addon dialog becomes always opened on the back of Kodi ones for this reason a
                 * "<animation effect="fade" start="100" end="0" time="400" condition="Window.IsVisible(Addon)">Conditional</animation>"
                 * on skin is needed to hide dialog.
                 */
                addon->CallMenuHook(hook, hookData);
            }
        }
        else
        {
            CGUIDialogOK::ShowAndGetInput(19033, 0, 15040, 0);
        }
    }

    return true;
}
bool CGUIWindowBoxeeWizardNetwork::OnAction(const CAction &action)
{
   int iControl = GetFocusedControlID();

   if (action.wID == ACTION_PREVIOUS_MENU || (action.wID == ACTION_SELECT_ITEM && iControl == CONTROL_BACK))
   {
      Close();
   }
   else if (action.wID == ACTION_SELECT_ITEM && iControl == CONTROL_INTERFACES)
   {  
     ShowWirelessNetworksIfNeeded();
     CGUIListContainer *pList = (CGUIListContainer *)GetControl(CONTROL_INTERFACES);
     if (pList)
       pList->SetSingleSelectedItem();

     return true;
   }
   else if (action.wID == ACTION_MOVE_LEFT && iControl == CONTROL_WIRELESS)
   {
     ShowInterfaces();
     SET_CONTROL_FOCUS(CONTROL_INTERFACES, 0);
     CGUIListContainer *pList = (CGUIListContainer *)GetControl(CONTROL_WIRELESS);
     if (pList)
       pList->SetSingleSelectedItem();

      return true;
   }
   else if (action.wID == ACTION_SELECT_ITEM && iControl == CONTROL_WIRELESS)
   {      
      ShowPasswordIfNeeded();
      CGUIListContainer *pList = (CGUIListContainer *)GetControl(CONTROL_WIRELESS);
      if (pList)
        pList->SetSingleSelectedItem();
      return true;
   }
   else if (action.wID == ACTION_SELECT_ITEM && iControl == CONTROL_PASSWORD)   
   {      
      CGUIButtonControl* passwordButton = (CGUIButtonControl*) GetControl(iControl);
      CStdString password = passwordButton->GetLabel();
      if (CGUIDialogKeyboard::ShowAndGetInput(password, g_localizeStrings.Get(789), false))
      {         
         passwordButton->SetLabel(password);
         CONTROL_ENABLE(CONTROL_NEXT);                        
         SET_CONTROL_FOCUS(CONTROL_NEXT, 0);
      }
      return true;
   }
   else if (action.wID == ACTION_SELECT_ITEM && iControl == CONTROL_ENC)
   {      
      CGUIButtonControl* encSelectionButton = (CGUIButtonControl*) GetControl(CONTROL_ENC_SELECTION);
   
      CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_ENC);
      OnMessage(msg);
      int iItem = msg.GetParam1();
      encSelectionButton->SetLabel(ENC_LABELS[iItem]);
      
      SET_CONTROL_HIDDEN(CONTROL_ENC);
      
      if (iItem == ENC_NONE)
      {
         SET_CONTROL_HIDDEN(CONTROL_PASSWORD_GROUP);
         SET_CONTROL_FOCUS(CONTROL_NEXT, 0);
      }
      else
      {
         SET_CONTROL_FOCUS(CONTROL_PASSWORD, 0);
      }
      return true;
   }
   else if (action.wID == ACTION_MOVE_LEFT && (iControl == CONTROL_ENC_SELECTION || iControl == CONTROL_PASSWORD))
   {
      SET_CONTROL_HIDDEN(CONTROL_ENC_GROUP);
      SET_CONTROL_HIDDEN(CONTROL_PASSWORD_GROUP);
      SET_CONTROL_FOCUS(CONTROL_WIRELESS, 0);
      return true;
   }
   else if (action.wID == ACTION_MOVE_DOWN && iControl == CONTROL_ENC_SELECTION)
   {
      if (GetControl(CONTROL_PASSWORD_GROUP)->IsVisible())
      {
         SET_CONTROL_FOCUS(CONTROL_PASSWORD, 0);
      }
      else if (!GetControl(CONTROL_NEXT)->IsDisabled())
      {
         SET_CONTROL_FOCUS(CONTROL_NEXT, 0);
      }
      return true;     
   }
   else if (action.wID == ACTION_MOVE_UP && (iControl == CONTROL_NEXT || iControl == CONTROL_BACK))
   {
      if (GetControl(CONTROL_PASSWORD_GROUP)->IsVisible())
      {
         SET_CONTROL_FOCUS(CONTROL_PASSWORD, 0);
      }
      else if (GetControl(CONTROL_ENC_GROUP)->IsVisible())
      {
         SET_CONTROL_FOCUS(CONTROL_ENC_SELECTION, 0);
      }
      else 
      {
         SET_CONTROL_FOCUS(CONTROL_INTERFACES, 0);
      }
      return true;     
   }
   else if (action.wID == ACTION_SELECT_ITEM && iControl == CONTROL_NEXT)
   {
      if (GetControl(CONTROL_ENC_SELECTION)->IsVisible() && GetControl(CONTROL_PASSWORD)->IsVisible())
      {
        CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_ENC);
        OnMessage(msg);
        int iItem = msg.GetParam1();
        
        CGUIButtonControl* passwordButton = (CGUIButtonControl*) GetControl(CONTROL_PASSWORD);
        CStdString password = passwordButton->GetLabel();
    
        if (ENC_MODES[iItem] == ENC_WEP_HEX && !IsHexString(password))
        {
          CGUIDialogOK *pDialogOK = (CGUIDialogOK *)m_gWindowManager.GetWindow(WINDOW_DIALOG_OK);
          pDialogOK->SetHeading("");
          pDialogOK->SetLine(0, 51018);
          pDialogOK->SetLine(1, 51019);
          pDialogOK->DoModal();

          return true;
        }
      }
               
      if (SaveConfiguration())
      {
         // Close all wizard dialogs
         Close();
         CGUIDialog* dialog = (CGUIDialog*) m_gWindowManager.GetWindow(WINDOW_BOXEE_WIZARD_AUDIO);
         dialog->Close();
         dialog = (CGUIDialog*) m_gWindowManager.GetWindow(WINDOW_BOXEE_WIZARD_RESOLUTION);
         dialog->Close();
      }
      
      return true;
   }
   
   return CGUIWindow::OnAction(action);
}
void CGUIWindowBoxeeWizardResolution::OnInitWindow()
{
   CGUIWindow::OnInitWindow();
   
   delete m_xrandr;
   m_xrandr = new CXRandR();
   
   if (!m_wizardCompletedOnce)
   {             
      CONTROL_DISABLE(CONTROL_NEXT);
   }
   
   if (m_afterResolutionChange)
   {
       CGUIListContainer *pList = (CGUIListContainer *)GetControl(CONTROL_SD_HD);
       if (pList)
         pList->SetSingleSelectedItem();

      ShowResolutionsList(IsResolutionHD(m_newResolution), &m_newResolution);     
      
      CStdString origHz;
      origHz.Format("%.2f", m_originalResolution.hz);
      CStdString newHz;
      newHz.Format("%.2f", m_newResolution.hz);

      if (m_newResolution.name != m_originalResolution.name || origHz != newHz)
      {
         CGUIDialogYesNo *pDlgYesNo = (CGUIDialogYesNo*)m_gWindowManager.GetWindow(WINDOW_DIALOG_YES_NO);
         pDlgYesNo->SetHeading("Resolution Change");
         pDlgYesNo->SetLine(0, "Do you want to keep this resolution");
         pDlgYesNo->SetLine(1, "(will revert automatically in 6 seconds)");
         pDlgYesNo->SetLine(2, "");
         pDlgYesNo->SetLine(3, "");
         pDlgYesNo->SetChoice(0, "Revert");
         pDlgYesNo->SetChoice(1, "Keep");
         pDlgYesNo->SetDefaultChoice(0);
         pDlgYesNo->SetAutoClose(6000);
         pDlgYesNo->DoModal();
         
         if (!pDlgYesNo->IsConfirmed())
         {
           m_afterResolutionChange = false;   
           // Set the requested resolution
           g_graphicsContext.SetVideoResolution(m_originalResolutionId, TRUE);
           // Reload the fonts to they will scale correctly
           g_fontManager.ReloadTTFFonts();
           // Close the dialog and restart it so it will re-set the size of the labels to 
           // fit for the new resolutions
           Close();
                    
           m_gWindowManager.ActivateWindow(WINDOW_BOXEE_WIZARD_RESOLUTION);
         }
         else
         {
            int xbmcResolutionId = GetXBMCResolutionId();
            if (xbmcResolutionId != -1)
            {
               g_guiSettings.SetInt("videoscreen.resolution", xbmcResolutionId);
               g_guiSettings.SetInt("videoplayer.displayresolution", xbmcResolutionId);
               g_guiSettings.SetInt("pictures.displayresolution", xbmcResolutionId);
               g_settings.Save();
               delete m_xrandr;
               m_xrandr = new CXRandR();
            }
         
            m_wizardCompletedOnce = true;
            CONTROL_ENABLE(CONTROL_NEXT);
            SET_CONTROL_FOCUS(CONTROL_NEXT, 0);            
         }
      }
      else
      {
         m_wizardCompletedOnce = true;
         CONTROL_ENABLE(CONTROL_NEXT);
         SET_CONTROL_FOCUS(CONTROL_NEXT, 0);         
      }
   }
   else if (m_resolutionChangedOnce || m_wizardCompletedOnce)
   {
      XOutput output = GetCurrentOutput();
      XMode currentResolution =  m_xrandr->GetCurrentMode(output.name);
      ShowResolutionsList(IsResolutionHD(currentResolution), &currentResolution);      
   }
   else
   {
      XOutput output = GetCurrentOutput();
      XMode currentResolution =  m_xrandr->GetCurrentMode(output.name);
      CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), CONTROL_SD_HD, IsResolutionHD(currentResolution) ? VALUE_HD : VALUE_SD);
      OnMessage(msg); 
   }
}
void CGUIWindowBoxeeWizardResolution::ShowResolutionsList(bool HD, XMode* selectedMode)
{
   // Set either HD/SD according to the selected mode
   if (selectedMode != NULL)
   {
      CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), CONTROL_SD_HD, IsResolutionHD(*selectedMode) ? VALUE_HD : VALUE_SD);
      OnMessage(msg); 
   }
   
   SET_CONTROL_VISIBLE(CONTROL_RESOLUTIONS);

   // Clear the list first
   CGUIMessage msgReset(GUI_MSG_LABEL_RESET, GetID(), CONTROL_RESOLUTIONS);
   OnMessage(msgReset);
   
   for (unsigned int i = 0; i < m_resolutions.size(); i++)
      delete m_resolutions[i];
   m_resolutions.clear();
   m_resolutionNames.clear();

   // Go over all the resolutions and display them
   int iSelectedItem = 0;
   XOutput output = GetCurrentOutput();
   for (unsigned int i = 0; i < output.modes.size(); i++)
   {
      // skip modes with similar names (but different Hz)
      //if (i > 0 && output.modes[i].name == output.modes[i-1].name)
      //   continue;
         
      if (IsResolutionHD(output.modes[i]) && IsResolutionValid(output.modes[i]))
      {
         CStdString name;
         name.Format("%s / %.0fHz", output.modes[i].name.c_str(), output.modes[i].hz); 
         CFileItem *item = new CFileItem(name);
         item->SetProperty("resolutionName", output.modes[i].name);
         item->SetProperty("resolutionHz", (int) output.modes[i].hz);
         CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_RESOLUTIONS, 0, 0, item);
         OnMessage(msg);            

         m_resolutions.push_back(item);
         
         CStdString resolutionName;
         resolutionName.Format("%s: %s @ %.2fHz", output.name.c_str(), output.modes[i].name, output.modes[i].hz);  
         m_resolutionNames.push_back(resolutionName);

         CStdString modeHz;
         modeHz.Format("%.2f", output.modes[i].hz);
         CStdString selectedHz;
         selectedHz.Format("%.2f", selectedMode->hz);
         
         if (selectedMode != NULL && output.modes[i].name == selectedMode->name && modeHz == selectedHz)
           iSelectedItem = m_resolutions.size() - 1;            
      }
   }
   
   CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), CONTROL_RESOLUTIONS, iSelectedItem);
   OnMessage(msg);      

   CGUIListContainer *pList = (CGUIListContainer *)GetControl(CONTROL_RESOLUTIONS);
   if (pList)
     pList->SetSingleSelectedItem();
   
   SET_CONTROL_FOCUS(CONTROL_RESOLUTIONS, 0);
}
bool CGUIWindowBoxeeWizardResolution::OnAction(const CAction &action)
{
   int iControl = GetFocusedControlID();

   if (action.wID == ACTION_PREVIOUS_MENU || (action.wID == ACTION_SELECT_ITEM && iControl == CONTROL_BACK))
   {
      Close();
      return true;     
   }
   else if (action.wID == ACTION_MOVE_LEFT && iControl == CONTROL_RESOLUTIONS)
   {
      SET_CONTROL_HIDDEN(CONTROL_RESOLUTIONS);
      SET_CONTROL_FOCUS(CONTROL_SD_HD, 0);
      return true;      
   }   
   else if (action.wID == ACTION_SELECT_ITEM && iControl == CONTROL_SD_HD)
   {
      SET_CONTROL_VISIBLE(CONTROL_RESOLUTIONS);
      
      CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_SD_HD);
      OnMessage(msg);
      int iItem = msg.GetParam1();

      CGUIListContainer *pList = (CGUIListContainer *)GetControl(CONTROL_SD_HD);
      if (pList)
        pList->SetSingleSelectedItem();

      XOutput output = GetCurrentOutput();
      XMode currentResolution =  m_xrandr->GetCurrentMode(output.name);
      ShowResolutionsList(iItem == VALUE_HD, &currentResolution);
      
      return true;      
   }      
   else if (action.wID == ACTION_SELECT_ITEM && iControl == CONTROL_RESOLUTIONS)
   {
      CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_RESOLUTIONS);
      OnMessage(msg);
      int iItem = msg.GetParam1();

      CGUIListContainer *pList = (CGUIListContainer *)GetControl(CONTROL_RESOLUTIONS);
      if (pList)
        pList->SetSingleSelectedItem();
   
      XOutput output = GetCurrentOutput();
      m_originalResolution =  m_xrandr->GetCurrentMode(output.name);
      m_originalResolutionId = g_graphicsContext.GetVideoResolution();
      
      for (unsigned int i = 0; i < output.modes.size(); i++)
      {
         if (output.modes[i].name == m_resolutions[iItem]->GetProperty("resolutionName") &&
             (int)output.modes[i].hz == m_resolutions[iItem]->GetPropertyInt("resolutionHz"))
         {
            m_newResolution = output.modes[i];

            CStdString origHz;
            origHz.Format("%.2f", m_originalResolution.hz);
            CStdString newHz;
            newHz.Format("%.2f", m_newResolution.hz);
            
            if (m_newResolution.name != m_originalResolution.name || newHz != origHz)
            {
               // Set the requested resolution
               RESOLUTION res = (RESOLUTION) GetXBMCResolutionId();
               g_graphicsContext.SetVideoResolution(res, TRUE);
   
               // Reload the fonts to they will scale correctly
               g_fontManager.ReloadTTFFonts();
            }
            
            m_afterResolutionChange = true;
            m_resolutionChangedOnce = true;
            
            // Close the dialog and restart it so it will re-set the size of the labels to 
            // fit for the new resolutions
            Close();
            m_gWindowManager.ActivateWindow(WINDOW_BOXEE_WIZARD_RESOLUTION);
                                  
            break;
         }
      }
      
      return true;      
   }
   else if (action.wID == ACTION_MOVE_UP && (iControl == CONTROL_NEXT || iControl == CONTROL_BACK))
   {
      if (GetControl(CONTROL_RESOLUTIONS)->IsVisible())
      {
         SET_CONTROL_FOCUS(CONTROL_RESOLUTIONS, 0);
      }
      else
      {
         SET_CONTROL_FOCUS(CONTROL_SD_HD, 0);
      }
      
      return true;
   }
  
   return CGUIWindow::OnAction(action);
}
bool CGUIDialogAudioDSPManager::OnContextButton(int itemNumber, CONTEXT_BUTTON button, int listType)
{
  CFileItemPtr pItem;
  int listSize = 0;
  if (listType == LIST_ACTIVE)
  {
    pItem = m_activeItems[m_iCurrentType]->Get(itemNumber);
    listSize = m_activeItems[m_iCurrentType]->Size();
  }
  else if (listType == LIST_AVAILABLE)
  {
    pItem = m_availableItems[m_iCurrentType]->Get(itemNumber);
    listSize = m_availableItems[m_iCurrentType]->Size();
  }

  /* Check file item is in list range and get his pointer */
  if (!pItem || itemNumber < 0 || itemNumber >= listSize)
  {
    return false;
  }

  if (button == CONTEXT_BUTTON_ACTIVATE)
  {
    /*!
    * Deactivate selected processing mode
    */
    if (pItem->GetProperty("ActiveMode").asBoolean())
    {
      // remove mode from active mode list and add it to available mode list
      CFileItemPtr newItem(dynamic_cast<CFileItem*>(pItem->Clone()));
      newItem->SetProperty("ActiveMode", false);
      newItem->SetProperty("Changed", true);
      m_activeItems[m_iCurrentType]->Remove(itemNumber);
      m_availableItems[m_iCurrentType]->Add(newItem);
    }
    else
    {
      /*!
      * Activate selected processing mode
      */
      if ((m_iCurrentType == AE_DSP_MODE_TYPE_INPUT_RESAMPLE || m_iCurrentType == AE_DSP_MODE_TYPE_OUTPUT_RESAMPLE) && m_activeItems[m_iCurrentType]->Size() > 0)
      { // if there is already an active resampler, now we remove it
        CFileItemPtr activeResampler = m_activeItems[m_iCurrentType]->Get(0);
        if (activeResampler)
        {
          CFileItemPtr newItem(dynamic_cast<CFileItem*>(activeResampler->Clone()));
          newItem->SetProperty("ActiveMode", false);
          newItem->SetProperty("Changed", true);

          m_availableItems[m_iCurrentType]->Add(newItem);
          // clear active list, because only one active resampling mode is supported by ActiveAEDSP
          m_activeItems[m_iCurrentType]->Clear();
        }
      }

      // remove mode from available mode list and add it to active mode list
      CFileItemPtr newItem(dynamic_cast<CFileItem*>(pItem->Clone()));

      newItem->SetProperty("Number", (int)m_activeItems[m_iCurrentType]->Size() +1);
      newItem->SetProperty("Changed", true);
      newItem->SetProperty("ActiveMode", true);

      m_availableItems[m_iCurrentType]->Remove(itemNumber);
      m_activeItems[m_iCurrentType]->Add(newItem);
    }

    m_bContainsChanges = true;
    if (m_bContinuousSaving)
    {
      SaveList();
    }

    // reorder available mode list, so that the mode order is always consistent
    m_availableItems[m_iCurrentType]->ClearSortState();
    m_availableItems[m_iCurrentType]->Sort(SortByLabel, SortOrderAscending);

    // update active and available mode list
    Renumber();
    m_availableViewControl.SetItems(*m_availableItems[m_iCurrentType]);
    m_activeViewControl.SetItems(*m_activeItems[m_iCurrentType]);
  }
  else if (button == CONTEXT_BUTTON_MOVE)
  {
    m_bMovingMode = true;
    pItem->Select(true);

    CGUIListContainer *modeList = dynamic_cast<CGUIListContainer*>(GetControl(CONTROL_LIST_MODE_SELECTION));
    CGUIButtonControl *applyButton = dynamic_cast<CGUIButtonControl*>(GetControl(CONTROL_BUTTON_APPLY_CHANGES));
    CGUIButtonControl *clearActiveModesButton = dynamic_cast<CGUIButtonControl*>(GetControl(CONTROL_BUTTON_CLEAR_ACTIVE_MODES));
    if (!modeList || !applyButton || !clearActiveModesButton)
    {
      helper_LogError(__FUNCTION__);
      return false;
    }

    // if we are in MovingMode all buttons and mode selection list will be disabled!
    modeList->SetEnabled(false);
    clearActiveModesButton->SetEnabled(false);
    if (!m_bContinuousSaving)
    {
      applyButton->SetEnabled(false);
    }
  }
  else if (button == CONTEXT_BUTTON_SETTINGS)
  {
    HELPERS::ShowOKDialogLines(CVariant{19033}, CVariant{0}, CVariant{15040}, CVariant{0});
  }

  return true;
}