//--------------------------------------------------------------------------------------- WINDOW* Show::MatchWindow (const POINT& p) { WINDOW* Match = nullptr; if (Editbox::MatchWindow(p) && Settings == nullptr) { SetName(); POINT p; GetCursorPos (&p); if (WndName.length()) { if ( ( p.y + 270 ) > GetSystemMetrics( SM_CYSCREEN ) ) { p.y -= 260; } CreateSettings(new SettingsBox<Show> (p.x - 5, p.y - 5, 167, 270, SETTINGS, this)); } Match = nullptr; } else { for (std::vector<Entry*>::iterator i = Entries.begin();i != Entries.end();++i) { Match=(*i)->MatchWindow(p); if (Match != nullptr) break; } } return Match; }
bool CGUIWindowSettingsCategory::OnMessage(CGUIMessage &message) { switch (message.GetMessage()) { case GUI_MSG_WINDOW_INIT: { m_iSection = (int)message.GetParam2() - (int)CGUIDialogSettingsManagerBase::GetID(); CGUIDialogSettingsManagerBase::OnMessage(message); m_returningFromSkinLoad = false; if (!message.GetStringParam(0).empty()) FocusCategory(message.GetStringParam(0)); return true; } case GUI_MSG_FOCUSED: { if (!m_returningFromSkinLoad) CGUIDialogSettingsManagerBase::OnMessage(message); return true; } case GUI_MSG_LOAD_SKIN: { if (IsActive()) m_returningFromSkinLoad = true; break; } case GUI_MSG_NOTIFY_ALL: { if (message.GetParam1() == GUI_MSG_WINDOW_RESIZE) { if (IsActive() && CDisplaySettings::GetInstance().GetCurrentResolution() != g_graphicsContext.GetVideoResolution()) { CDisplaySettings::GetInstance().SetCurrentResolution(g_graphicsContext.GetVideoResolution(), true); CreateSettings(); } } break; } } return CGUIDialogSettingsManagerBase::OnMessage(message); }
bool CGUIWindowSettingsCategory::OnAction(const CAction &action) { switch (action.GetID()) { case ACTION_SETTINGS_LEVEL_CHANGE: { //Test if we can access the new level if (!g_passwordManager.CheckSettingLevelLock(CViewStateSettings::GetInstance().GetNextSettingLevel(), true)) return false; CViewStateSettings::GetInstance().CycleSettingLevel(); CSettings::GetInstance().Save(); // try to keep the current position std::string oldCategory; if (m_iCategory >= 0 && m_iCategory < (int)m_categories.size()) oldCategory = m_categories[m_iCategory]->GetId(); SET_CONTROL_LABEL(CONTRL_BTN_LEVELS, 10036 + (int)CViewStateSettings::GetInstance().GetSettingLevel()); // only re-create the categories, the settings will be created later SetupControls(false); m_iCategory = 0; // try to find the category that was previously selected if (!oldCategory.empty()) { for (int i = 0; i < (int)m_categories.size(); i++) { if (m_categories[i]->GetId() == oldCategory) { m_iCategory = i; break; } } } CreateSettings(); return true; } default: break; } return CGUIDialogSettingsManagerBase::OnAction(action); }
HSETTINGS OpenSettingsFromData(const char *data) { unsigned int length = 0; if (!data || (length = strlen(data)) <= 0) { return NULL; } HSETTINGS settings = NULL; if (!(settings = CreateSettings())) { return NULL; } struct IParse parse; if (!InitSettingsParser(&parse, data, length)) { return NULL; } while (ParseSection(&parse, settings)); return (settings); }
GenericSettingsManager::GenericSettingsManager( QString company_name, QString application_name) : CompanyName_ ( company_name ) , ApplicationName_( application_name ) { CreateSettings(); }
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 CGUIDialogSettingsBase::SetupControls(bool createSettings /* = true */) { // cleanup first, if necessary FreeControls(); // get the section CSettingSection *section = GetSection(); if (section == NULL) return; // update the screen string SetHeading(section->GetLabel()); // get the categories we need m_categories = section->GetCategories((SettingLevel)GetSettingLevel()); if (m_categories.empty()) m_categories.push_back(m_dummyCategory); // get all controls m_pOriginalSpin = dynamic_cast<CGUISpinControlEx*>(GetControl(CONTROL_DEFAULT_SPIN)); m_pOriginalSlider = dynamic_cast<CGUISettingsSliderControl*>(GetControl(CONTROL_DEFAULT_SLIDER)); m_pOriginalRadioButton = dynamic_cast<CGUIRadioButtonControl *>(GetControl(CONTROL_DEFAULT_RADIOBUTTON)); m_pOriginalCategoryButton = dynamic_cast<CGUIButtonControl *>(GetControl(CONTROL_DEFAULT_CATEGORY_BUTTON)); m_pOriginalButton = dynamic_cast<CGUIButtonControl *>(GetControl(CONTROL_DEFAULT_BUTTON)); m_pOriginalImage = dynamic_cast<CGUIImage *>(GetControl(CONTROL_DEFAULT_SEPARATOR)); m_pOriginalEdit = dynamic_cast<CGUIEditControl *>(GetControl(CONTROL_DEFAULT_EDIT)); m_pOriginalGroupTitle = dynamic_cast<CGUILabelControl *>(GetControl(CONTROL_DEFAULT_SETTING_LABEL)); if (!m_pOriginalEdit && m_pOriginalButton) { m_pOriginalEdit = new CGUIEditControl(*m_pOriginalButton); m_newOriginalEdit = true; } if (m_pOriginalSpin) m_pOriginalSpin->SetVisible(false); if (m_pOriginalSlider) m_pOriginalSlider->SetVisible(false); if (m_pOriginalRadioButton) m_pOriginalRadioButton->SetVisible(false); if (m_pOriginalButton) m_pOriginalButton->SetVisible(false); if (m_pOriginalCategoryButton) m_pOriginalCategoryButton->SetVisible(false); if (m_pOriginalEdit) m_pOriginalEdit->SetVisible(false); if (m_pOriginalImage) m_pOriginalImage->SetVisible(false); if (m_pOriginalGroupTitle) m_pOriginalGroupTitle->SetVisible(false); if (m_pOriginalCategoryButton != NULL) { // setup our control groups... CGUIControlGroupList *group = dynamic_cast<CGUIControlGroupList *>(GetControl(CATEGORY_GROUP_ID)); if (!group) return; // go through the categories and create the necessary buttons int buttonIdOffset = 0; for (SettingCategoryList::const_iterator category = m_categories.begin(); category != m_categories.end(); ++category) { CGUIButtonControl *pButton = NULL; if (m_pOriginalCategoryButton->GetControlType() == CGUIControl::GUICONTROL_TOGGLEBUTTON) pButton = new CGUIToggleButtonControl(*(CGUIToggleButtonControl *)m_pOriginalCategoryButton); else pButton = new CGUIButtonControl(*m_pOriginalCategoryButton); pButton->SetLabel(GetLocalizedString((*category)->GetLabel())); pButton->SetID(CONTROL_SETTINGS_START_BUTTONS + buttonIdOffset); pButton->SetVisible(true); pButton->AllocResources(); group->AddControl(pButton); buttonIdOffset++; } } if (createSettings) CreateSettings(); // set focus correctly depending on whether there are categories visible or not if (m_pOriginalCategoryButton == NULL && (m_defaultControl <= 0 || m_defaultControl == CATEGORY_GROUP_ID)) m_defaultControl = SETTINGS_GROUP_ID; else if (m_pOriginalCategoryButton != NULL && m_defaultControl <= 0) m_defaultControl = CATEGORY_GROUP_ID; }