forked from qt-creator/qt-creator
Make C++ code style configurable.
Change-Id: Iaf08edb2361146e6b5e1cbafdb716a23c938875b Done-with: Jarek Kobus Task-number: QTCREATORBUG-2670 Task-number: QTCREATORBUG-4310 Task-number: QTCREATORBUG-2763 Task-number: QTCREATORBUG-3623 Task-number: QTCREATORBUG-567 Reviewed-on: http://codereview.qt.nokia.com/74 Reviewed-by: Leandro T. C. Melo <leandro.melo@nokia.com> Reviewed-by: Jarek Kobus <jaroslaw.kobus@nokia.com> Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
#include "codestylesettingspropertiespage.h"
|
||||
#include "editorconfiguration.h"
|
||||
#include "project.h"
|
||||
#include <texteditor/codestylepreferencesmanager.h>
|
||||
#include <texteditor/icodestylepreferencesfactory.h>
|
||||
|
||||
#include <QtCore/QTextCodec>
|
||||
|
||||
using namespace TextEditor;
|
||||
using namespace ProjectExplorer;
|
||||
using namespace ProjectExplorer::Internal;
|
||||
|
||||
QString CodeStyleSettingsPanelFactory::id() const
|
||||
{
|
||||
return QLatin1String(CODESTYLESETTINGS_PANEL_ID);
|
||||
}
|
||||
|
||||
QString CodeStyleSettingsPanelFactory::displayName() const
|
||||
{
|
||||
return QCoreApplication::translate("CodeStyleSettingsPanelFactory", "Code Style Settings");
|
||||
}
|
||||
|
||||
bool CodeStyleSettingsPanelFactory::supports(Project *project)
|
||||
{
|
||||
Q_UNUSED(project);
|
||||
return true;
|
||||
}
|
||||
|
||||
PropertiesPanel *CodeStyleSettingsPanelFactory::createPanel(Project *project)
|
||||
{
|
||||
PropertiesPanel *panel = new PropertiesPanel;
|
||||
panel->setWidget(new CodeStyleSettingsWidget(project));
|
||||
panel->setIcon(QIcon(":/projectexplorer/images/CodeStyleSettings.png"));
|
||||
panel->setDisplayName(QCoreApplication::translate("CodeStyleSettingsPanel", "Code Style Settings"));
|
||||
return panel;
|
||||
}
|
||||
|
||||
CodeStyleSettingsWidget::CodeStyleSettingsWidget(Project *project) : QWidget(), m_project(project)
|
||||
{
|
||||
m_ui.setupUi(this);
|
||||
|
||||
const EditorConfiguration *config = m_project->editorConfiguration();
|
||||
CodeStylePreferencesManager *manager =
|
||||
CodeStylePreferencesManager::instance();
|
||||
|
||||
QList<ICodeStylePreferencesFactory *> factories = manager->factories();
|
||||
for (int i = 0; i < factories.count(); i++) {
|
||||
ICodeStylePreferencesFactory *factory = factories.at(i);
|
||||
const QString languageId = factory->languageId();
|
||||
TabPreferences *tabPreferences = config->tabPreferences(languageId);
|
||||
IFallbackPreferences *codeStylePreferences = config->codeStylePreferences(languageId);
|
||||
|
||||
QWidget *widget = factory->createEditor(codeStylePreferences, tabPreferences, m_ui.stackedWidget);
|
||||
m_ui.stackedWidget->addWidget(widget);
|
||||
m_ui.languageComboBox->addItem(factory->displayName());
|
||||
}
|
||||
|
||||
connect(m_ui.languageComboBox, SIGNAL(currentIndexChanged(int)),
|
||||
m_ui.stackedWidget, SLOT(setCurrentIndex(int)));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user