CodeStyleSettingsWidget::CodeStyleSettingsWidget(Project *project) : QWidget(), m_project(project) { m_ui.setupUi(this); const EditorConfiguration *config = m_project->editorConfiguration(); QMap<Core::Id, ICodeStylePreferencesFactory *> factories = TextEditorSettings::codeStyleFactories(); QMapIterator<Core::Id, ICodeStylePreferencesFactory *> it(factories); while (it.hasNext()) { it.next(); ICodeStylePreferencesFactory *factory = it.value(); Core::Id languageId = factory->languageId(); ICodeStylePreferences *codeStylePreferences = config->codeStyle(languageId); auto preview = factory->createCodeStyleEditor(codeStylePreferences, m_ui.stackedWidget); if (preview && preview->layout()) preview->layout()->setContentsMargins(QMargins()); m_ui.stackedWidget->addWidget(preview); m_ui.languageComboBox->addItem(factory->displayName()); } connect(m_ui.languageComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), m_ui.stackedWidget, &QStackedWidget::setCurrentIndex); }
CodeStyleSettingsWidget::CodeStyleSettingsWidget(Project *project) : QWidget(), m_project(project) { m_ui.setupUi(this); const EditorConfiguration *config = m_project->editorConfiguration(); QMap<Core::Id, ICodeStylePreferencesFactory *> factories = TextEditorSettings::codeStyleFactories(); QMapIterator<Core::Id, ICodeStylePreferencesFactory *> it(factories); while (it.hasNext()) { it.next(); ICodeStylePreferencesFactory *factory = it.value(); Core::Id languageId = factory->languageId(); ICodeStylePreferences *codeStylePreferences = config->codeStyle(languageId); CodeStyleEditor *preview = new CodeStyleEditor(factory, codeStylePreferences, m_ui.stackedWidget); preview->clearMargins(); m_ui.stackedWidget->addWidget(preview); m_ui.languageComboBox->addItem(factory->displayName()); } connect(m_ui.languageComboBox, SIGNAL(currentIndexChanged(int)), m_ui.stackedWidget, SLOT(setCurrentIndex(int))); }