void CGUIWindowSettingsCategory::FocusElement(const std::string& elementId)
{
  for (size_t i = 0; i < m_categories.size(); ++i)
  {
    if (m_categories[i]->GetId() == elementId)
    {
      SET_CONTROL_FOCUS(CONTROL_SETTINGS_START_BUTTONS + i, 0);
      return;
    }
    for (const auto& group: m_categories[i]->GetGroups())
    {
      for (const auto& setting : group->GetSettings())
      {
        if (setting->GetId() == elementId)
        {
          SET_CONTROL_FOCUS(CONTROL_SETTINGS_START_BUTTONS + i, 0);

          auto control = GetSettingControl(elementId);
          if (control)
            SET_CONTROL_FOCUS(control->GetID(), 0);
          else
            CLog::Log(LOGERROR, "CGUIWindowSettingsCategory: failed to get control for setting '%s'.", elementId.c_str());
          return;
        }
      }
    }
  }
  CLog::Log(LOGERROR, "CGUIWindowSettingsCategory: failed to set focus. unknown category/setting id '%s'.", elementId.c_str());
}
Beispiel #2
0
void CGUIDialogNetworkSetup::OnProtocolChange()
{
  BaseSettingControlPtr settingControl = GetSettingControl(SETTING_PROTOCOL);
  if (settingControl != NULL && settingControl->GetControl() != NULL)
  {
    CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), settingControl->GetID());
    if (!OnMessage(msg))
      return;
    m_protocol = (NET_PROTOCOL)msg.GetParam1();
    // set defaults for the port
    if (m_protocol == NET_PROTOCOL_FTP)
      m_port = "21";
    else if (m_protocol == NET_PROTOCOL_HTTP || 
       m_protocol == NET_PROTOCOL_RSS || 
       m_protocol == NET_PROTOCOL_DAV)
      m_port = "80";
    else if (m_protocol == NET_PROTOCOL_HTTPS || m_protocol == NET_PROTOCOL_DAVS)
      m_port = "443";
    else if (m_protocol == NET_PROTOCOL_SFTP)
      m_port = "22";
    else
      m_port = "0";

    UpdateButtons();
  }
}
void CGUIDialogSettingsBase::UpdateSettingControl(const std::string &settingId)
{
  if (settingId.empty())
    return;

  return UpdateSettingControl(GetSettingControl(settingId));
}
Beispiel #4
0
void CGUIDialogMediaFilter::UpdateControls()
{
  for (std::map<std::string, Filter>::iterator itFilter = m_filters.begin(); itFilter != m_filters.end(); itFilter++)
  {
    if (itFilter->second.controlType != "list")
      continue;

    std::vector<std::string> items;
    int size = GetItems(itFilter->second, items, true);

    std::string label = g_localizeStrings.Get(itFilter->second.label);
    BaseSettingControlPtr control = GetSettingControl(itFilter->second.setting->GetId());
    if (control == NULL)
      continue;

    if (size <= 0 ||
       (size == 1 && itFilter->second.field != FieldSet && itFilter->second.field != FieldTag))
       CONTROL_DISABLE(control->GetID());
    else
    {
      CONTROL_ENABLE(control->GetID());
      label = StringUtils::Format(g_localizeStrings.Get(21470).c_str(), label.c_str(), size);
    }
    SET_CONTROL_LABEL(control->GetID(), label);
  }
}
Beispiel #5
0
void CGUIDialogLockSettings::setLockCodeLabel()
{
  // adjust label2 of the lock code button
  if (m_locks.mode > LOCK_MODE_QWERTY)
    m_locks.mode = LOCK_MODE_EVERYONE;
  BaseSettingControlPtr settingControl = GetSettingControl(SETTING_LOCKCODE);
  if (settingControl != NULL && settingControl->GetControl() != NULL)
    SET_CONTROL_LABEL2(settingControl->GetID(), g_localizeStrings.Get(m_locks.mode == LOCK_MODE_EVERYONE ? 1223 : 12336 + m_locks.mode));
}
Beispiel #6
0
void CGUIDialogNetworkSetup::OnDeinitWindow(int nextWindowID)
{
  // clear protocol spinner
  BaseSettingControlPtr settingControl = GetSettingControl(SETTING_PROTOCOL);
  if (settingControl != NULL && settingControl->GetControl() != NULL)
  {
    CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), settingControl->GetID());
    OnMessage(msg);
  }

  CGUIDialogSettingsManualBase::OnDeinitWindow(nextWindowID);
}
Beispiel #7
0
void CGUIDialogLockSettings::setDetailSettingsEnabled(bool enabled)
{
  if (!m_details)
    return;

  enabled |= !m_conditionalDetails;
  GetSettingControl(SETTING_LOCK_MUSIC)->GetSetting()->SetEnabled(enabled);
  GetSettingControl(SETTING_LOCK_VIDEOS)->GetSetting()->SetEnabled(enabled);
  GetSettingControl(SETTING_LOCK_PICTURES)->GetSetting()->SetEnabled(enabled);
  GetSettingControl(SETTING_LOCK_PROGRAMS)->GetSetting()->SetEnabled(enabled);
  GetSettingControl(SETTING_LOCK_FILEMANAGER)->GetSetting()->SetEnabled(enabled);
  GetSettingControl(SETTING_LOCK_SETTINGS)->GetSetting()->SetEnabled(enabled);
  GetSettingControl(SETTING_LOCK_ADDONMANAGER)->GetSetting()->SetEnabled(enabled);
}
void ClimatologyDialog::OnUpdateDisplay( wxCommandEvent& event )
{
    if(event.IsChecked()) {
        int cursetting = 0;
        for(int i=0; i<ClimatologyOverlaySettings::SETTINGS_COUNT; i++)
            if(wxDynamicCast(event.GetEventObject(), wxCheckBox) == GetSettingControl(i)) {
                m_cfgdlg->m_cDataType->SetSelection(i);
                m_cfgdlg->OnDataTypeChoice( event );
                cursetting = i;
                break;
            }

        if(m_cfgdlg->m_Settings.Settings[cursetting].m_bOverlayMap)
            for(int i=0; i<ClimatologyOverlaySettings::SETTINGS_COUNT; i++) {
                if(i == cursetting)
                    continue;
                ClimatologyOverlaySettings::OverlayDataSettings &odc = m_cfgdlg->m_Settings.Settings[i];
                if(SettingEnabled(i) && odc.m_bOverlayMap)
                    DisableSetting(i);
            }
    }

    RefreshRedraw();
}
Beispiel #9
0
void CGUIDialogProfileSettings::updateProfileDirectory()
{
  BaseSettingControlPtr settingControl = GetSettingControl(SETTING_PROFILE_DIRECTORY);
  if (settingControl != NULL && settingControl->GetControl() != NULL)
    SET_CONTROL_LABEL2(settingControl->GetID(), m_directory);
}
Beispiel #10
0
void CGUIDialogProfileSettings::UpdateProfileImage()
{
  BaseSettingControlPtr settingControl = GetSettingControl(SETTING_PROFILE_IMAGE);
  if (settingControl != NULL && settingControl->GetControl() != NULL)
    SET_CONTROL_LABEL2(settingControl->GetID(), URIUtils::GetFileName(m_thumb));
}
Beispiel #11
0
void CGUIDialogNetworkSetup::UpdateButtons()
{
  // Address label
  BaseSettingControlPtr addressControl = GetSettingControl(SETTING_SERVER_ADDRESS);
  if (addressControl != NULL && addressControl->GetControl() != NULL)
  {
    int addressControlID = addressControl->GetID();
    SET_CONTROL_LABEL2(addressControlID, m_server);
    if (m_protocol == NET_PROTOCOL_SMB)
    {
      SET_CONTROL_LABEL(addressControlID, 1010);  // Server name
    }
    else
    {
      SET_CONTROL_LABEL(addressControlID, 1009);  // Server Address
    }
    SendMessage(GUI_MSG_SET_TYPE, addressControlID, CGUIEditControl::INPUT_TYPE_TEXT, 1016);
  }

  // remote path
  BaseSettingControlPtr pathControl = GetSettingControl(SETTING_REMOTE_PATH);
  if (pathControl != NULL && pathControl->GetControl() != NULL)
  {
    int pathControlID = pathControl->GetID();
    SET_CONTROL_LABEL2(pathControlID, m_path);
    CONTROL_ENABLE_ON_CONDITION(pathControlID, m_protocol != NET_PROTOCOL_UPNP);
    if (m_protocol == NET_PROTOCOL_FTP ||
        m_protocol == NET_PROTOCOL_HTTP ||
        m_protocol == NET_PROTOCOL_HTTPS ||
        m_protocol == NET_PROTOCOL_RSS ||
        m_protocol == NET_PROTOCOL_DAV ||
        m_protocol == NET_PROTOCOL_DAVS||
        m_protocol == NET_PROTOCOL_SFTP||
        m_protocol == NET_PROTOCOL_NFS)
    {
      SET_CONTROL_LABEL(pathControlID, 1011);  // Remote Path
    }
    else
    {
      SET_CONTROL_LABEL(pathControlID, 1012);  // Shared Folder
    }
    SendMessage(GUI_MSG_SET_TYPE, pathControlID, CGUIEditControl::INPUT_TYPE_TEXT, 1017);
  }

  // username
  BaseSettingControlPtr userControl = GetSettingControl(SETTING_USERNAME);
  if (userControl != NULL && userControl->GetControl() != NULL)
  {
    int userControlID = userControl->GetID();
    SET_CONTROL_LABEL2(userControlID, m_username);
    CONTROL_ENABLE_ON_CONDITION(userControlID, m_protocol != NET_PROTOCOL_UPNP &&
                                               m_protocol != NET_PROTOCOL_NFS);

    SendMessage(GUI_MSG_SET_TYPE, userControlID, CGUIEditControl::INPUT_TYPE_TEXT, 1019);
  }

  // port
  BaseSettingControlPtr portControl = GetSettingControl(SETTING_PORT_NUMBER);
  if (portControl != NULL && portControl->GetControl() != NULL)
  {
    int portControlID = portControl->GetID();
    SET_CONTROL_LABEL2(portControlID, m_port);
    CONTROL_ENABLE_ON_CONDITION(portControlID, m_protocol == NET_PROTOCOL_FTP ||
                                               m_protocol == NET_PROTOCOL_HTTP ||
                                               m_protocol == NET_PROTOCOL_HTTPS ||
                                               m_protocol == NET_PROTOCOL_DAV ||
                                               m_protocol == NET_PROTOCOL_DAVS ||
                                               m_protocol == NET_PROTOCOL_RSS ||
                                               m_protocol == NET_PROTOCOL_SFTP);

    SendMessage(GUI_MSG_SET_TYPE, portControlID, CGUIEditControl::INPUT_TYPE_NUMBER, 1018);
  }

  // password
  BaseSettingControlPtr passControl = GetSettingControl(SETTING_PASSWORD);
  if (passControl != NULL && passControl->GetControl() != NULL)
  {
    int passControlID = passControl->GetID();
    SET_CONTROL_LABEL2(passControlID, m_password);
    CONTROL_ENABLE_ON_CONDITION(passControlID, m_protocol != NET_PROTOCOL_UPNP &&
                                                  m_protocol != NET_PROTOCOL_NFS);

    SendMessage(GUI_MSG_SET_TYPE, passControlID, CGUIEditControl::INPUT_TYPE_PASSWORD, 12326);
  }

  // server browse should be disabled if we are in FTP, HTTP, HTTPS, RSS, DAV or DAVS
  BaseSettingControlPtr browseControl = GetSettingControl(SETTING_SERVER_BROWSE);
  if (browseControl != NULL && browseControl->GetControl() != NULL)
  {
    int browseControlID = browseControl->GetID();
    CONTROL_ENABLE_ON_CONDITION(browseControlID, !m_server.empty() || !(m_protocol == NET_PROTOCOL_FTP ||
                                                                        m_protocol == NET_PROTOCOL_HTTP ||
                                                                        m_protocol == NET_PROTOCOL_HTTPS ||
                                                                        m_protocol == NET_PROTOCOL_DAV ||
                                                                        m_protocol == NET_PROTOCOL_DAVS ||
                                                                        m_protocol == NET_PROTOCOL_RSS ||
                                                                        m_protocol == NET_PROTOCOL_SFTP));
  }
}
Beispiel #12
0
bool CGUIDialogSettingsBase::OnMessage(CGUIMessage &message)
{
  switch (message.GetMessage())
  {
    case GUI_MSG_WINDOW_INIT:
    {
      m_delayedSetting.reset();
      if (message.GetParam1() != WINDOW_INVALID)
      { // coming to this window first time (ie not returning back from some other window)
        // so we reset our section and control states
        m_iCategory = 0;
        ResetControlStates();
      }

      if (AllowResettingSettings())
      {
        m_resetSetting = new CSettingAction(SETTINGS_RESET_SETTING_ID);
        m_resetSetting->SetLabel(10041);
        m_resetSetting->SetHelp(10045);
        m_resetSetting->SetControl(CreateControl("button"));
      }

      m_dummyCategory = new CSettingCategory(SETTINGS_EMPTY_CATEGORY_ID);
      m_dummyCategory->SetLabel(10046);
      m_dummyCategory->SetHelp(10047);
      break;
    }

    case GUI_MSG_WINDOW_DEINIT:
    {
      // cancel any delayed changes
      if (m_delayedSetting != NULL)
      {
        m_delayedTimer.Stop();
        CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), m_delayedSetting->GetID());
        OnMessage(message);
      }
      
      CGUIDialog::OnMessage(message);
      FreeControls();
      return true;
    }
    
    case GUI_MSG_FOCUSED:
    {
      CGUIDialog::OnMessage(message);
      int focusedControl = GetFocusedControlID();

      // cancel any delayed changes
      if (m_delayedSetting != NULL && m_delayedSetting->GetID() != focusedControl)
      {
        m_delayedTimer.Stop();
        CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), m_delayedSetting->GetID(), 1); // param1 = 1 for "reset the control if it's invalid"
        g_windowManager.SendThreadMessage(message, GetID());
      }
      // update the value of the previous setting (in case it was invalid)
      else if (m_iSetting >= CONTROL_SETTINGS_START_CONTROL && m_iSetting < (int)(CONTROL_SETTINGS_START_CONTROL + m_settingControls.size()))
      {
        BaseSettingControlPtr control = GetSettingControl(m_iSetting);
        if (control != NULL && control->GetSetting() != NULL && !control->IsValid())
        {
          CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), m_iSetting, 1); // param1 = 1 for "reset the control if it's invalid"
          g_windowManager.SendThreadMessage(message, GetID());
        }
      }

      CVariant description;

      // check if we have changed the category and need to create new setting controls
      if (focusedControl >= CONTROL_SETTINGS_START_BUTTONS && focusedControl < (int)(CONTROL_SETTINGS_START_BUTTONS + m_categories.size()))
      {
        int categoryIndex = focusedControl - CONTROL_SETTINGS_START_BUTTONS;
        const CSettingCategory* category = m_categories.at(categoryIndex);
        if (categoryIndex != m_iCategory)
        {
          if (!category->CanAccess())
          {
            // unable to go to this category - focus the previous one
            SET_CONTROL_FOCUS(CONTROL_SETTINGS_START_BUTTONS + m_iCategory, 0);
            return false;
          }

          m_iCategory = categoryIndex;
          CreateSettings();
        }

        description = category->GetHelp();
      }
      else if (focusedControl >= CONTROL_SETTINGS_START_CONTROL && focusedControl < (int)(CONTROL_SETTINGS_START_CONTROL + m_settingControls.size()))
      {
        m_iSetting = focusedControl;
        CSetting *setting = GetSettingControl(focusedControl)->GetSetting();
        if (setting != NULL)
          description = setting->GetHelp();
      }

      // set the description of the currently focused category/setting
      if (description.isInteger() ||
          (description.isString() && !description.empty()))
        SetDescription(description);

      return true;
    }

    case GUI_MSG_CLICKED:
    {
      int iControl = message.GetSenderId();
      if (iControl == CONTROL_SETTINGS_OKAY_BUTTON)
      {
        OnOkay();
        Close();
        return true;
      }

      if (iControl == CONTROL_SETTINGS_CANCEL_BUTTON)
      {
        OnCancel();
        Close();
        return true;
      }

      BaseSettingControlPtr control = GetSettingControl(iControl);
      if (control != NULL)
        OnClick(control);

      break;
    }
    
    case GUI_MSG_UPDATE_ITEM:
    {
      if (m_delayedSetting != NULL && m_delayedSetting->GetID() == message.GetControlId())
      {
        // first get the delayed setting and reset its member variable
        // to avoid handling the delayed setting twice in case the OnClick()
        // performed later causes the window to be deinitialized (e.g. when
        // changing the language)
        BaseSettingControlPtr delayedSetting = m_delayedSetting;
        m_delayedSetting.reset();

        // if updating the setting fails and param1 has been specifically set
        // we need to call OnSettingChanged() to restore a valid value in the
        // setting control
        if (!delayedSetting->OnClick() && message.GetParam1() != 0)
          OnSettingChanged(delayedSetting->GetSetting());
        return true;
      }

      if (message.GetControlId() >= CONTROL_SETTINGS_START_CONTROL && message.GetControlId() < (int)(CONTROL_SETTINGS_START_CONTROL + m_settingControls.size()))
      {
        BaseSettingControlPtr settingControl = GetSettingControl(message.GetControlId());
        if (settingControl.get() != NULL && settingControl->GetSetting() != NULL)
        {
          settingControl->Update();
          return true;
        }
      }
      break;
    }
    
    case GUI_MSG_UPDATE:
    {
      if (IsActive() && HasID(message.GetSenderId()))
      {
        int focusedControl = GetFocusedControlID();
        CreateSettings();
        SET_CONTROL_FOCUS(focusedControl, 0);
      }
      break;
    }

    default:
      break;
  }

  return CGUIDialog::OnMessage(message);
}
void ClimatologyDialog::DisableSetting(int setting)
{
    GetSettingControl(setting)->SetValue(false);
}
bool ClimatologyDialog::SettingEnabled(int setting)
{
    return GetSettingControl(setting)->GetValue();
}