2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2011-07-06 10:38:53 +02:00
|
|
|
|
2011-02-03 15:48:14 +01:00
|
|
|
#include "codestylesettingspropertiespage.h"
|
2022-07-12 17:43:55 +02:00
|
|
|
|
2011-02-03 15:48:14 +01:00
|
|
|
#include "editorconfiguration.h"
|
|
|
|
|
#include "project.h"
|
2022-07-12 17:43:55 +02:00
|
|
|
|
2022-08-01 17:28:42 +02:00
|
|
|
#include <cppeditor/cppeditorconstants.h>
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
#include <texteditor/texteditorsettings.h>
|
2011-02-03 15:48:14 +01:00
|
|
|
#include <texteditor/icodestylepreferencesfactory.h>
|
2011-08-16 10:45:23 +02:00
|
|
|
#include <texteditor/codestyleeditor.h>
|
2011-02-03 15:48:14 +01:00
|
|
|
|
2022-07-12 17:43:55 +02:00
|
|
|
#include <utils/layoutbuilder.h>
|
|
|
|
|
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QLayout>
|
|
|
|
|
#include <QStackedWidget>
|
|
|
|
|
|
2011-02-03 15:48:14 +01:00
|
|
|
using namespace TextEditor;
|
|
|
|
|
|
2022-07-12 17:43:55 +02:00
|
|
|
namespace ProjectExplorer::Internal {
|
|
|
|
|
|
|
|
|
|
CodeStyleSettingsWidget::CodeStyleSettingsWidget(Project *project)
|
2011-02-03 15:48:14 +01:00
|
|
|
{
|
2022-07-12 17:43:55 +02:00
|
|
|
auto languageComboBox = new QComboBox(this);
|
|
|
|
|
auto stackedWidget = new QStackedWidget(this);
|
|
|
|
|
|
2022-08-01 17:28:42 +02:00
|
|
|
setGlobalSettingsId(CppEditor::Constants::CPP_CODE_STYLE_SETTINGS_ID);
|
2022-04-14 15:51:18 +02:00
|
|
|
setUseGlobalSettingsCheckBoxVisible(false);
|
2011-02-03 15:48:14 +01:00
|
|
|
|
2022-07-12 17:43:55 +02:00
|
|
|
const EditorConfiguration *config = project->editorConfiguration();
|
2011-02-03 15:48:14 +01:00
|
|
|
|
2019-07-24 13:43:54 +02:00
|
|
|
for (ICodeStylePreferencesFactory *factory : TextEditorSettings::codeStyleFactories()) {
|
2020-06-26 13:59:38 +02:00
|
|
|
Utils::Id languageId = factory->languageId();
|
2011-08-16 10:45:23 +02:00
|
|
|
ICodeStylePreferences *codeStylePreferences = config->codeStyle(languageId);
|
2011-02-03 15:48:14 +01:00
|
|
|
|
2022-07-12 17:43:55 +02:00
|
|
|
auto preview = factory->createCodeStyleEditor(codeStylePreferences, project, stackedWidget);
|
2018-11-20 11:23:30 +01:00
|
|
|
if (preview && preview->layout())
|
|
|
|
|
preview->layout()->setContentsMargins(QMargins());
|
2022-07-12 17:43:55 +02:00
|
|
|
stackedWidget->addWidget(preview);
|
|
|
|
|
languageComboBox->addItem(factory->displayName());
|
2011-02-03 15:48:14 +01:00
|
|
|
}
|
|
|
|
|
|
2022-07-12 17:43:55 +02:00
|
|
|
connect(languageComboBox, &QComboBox::currentIndexChanged,
|
|
|
|
|
stackedWidget, &QStackedWidget::setCurrentIndex);
|
|
|
|
|
|
|
|
|
|
using namespace Utils::Layouting;
|
|
|
|
|
|
|
|
|
|
Column {
|
2022-07-22 18:54:04 +02:00
|
|
|
Row { new QLabel(tr("Language:")), languageComboBox, st },
|
2022-07-12 17:43:55 +02:00
|
|
|
stackedWidget
|
2022-07-26 11:35:19 +02:00
|
|
|
}.attachTo(this, WithoutMargins);
|
2011-02-03 15:48:14 +01:00
|
|
|
}
|
|
|
|
|
|
2022-07-12 17:43:55 +02:00
|
|
|
} // ProjectExplorer::Internal
|