forked from qt-creator/qt-creator
ProjectExplorer: inline codestylesettingspropertiespage.ui
Change-Id: I8682685d554fce5d618da913d35720465ac52278 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -25,7 +25,7 @@ add_qtc_plugin(ProjectExplorer
|
|||||||
buildtargetinfo.h
|
buildtargetinfo.h
|
||||||
buildtargettype.h
|
buildtargettype.h
|
||||||
clangparser.cpp clangparser.h
|
clangparser.cpp clangparser.h
|
||||||
codestylesettingspropertiespage.cpp codestylesettingspropertiespage.h codestylesettingspropertiespage.ui
|
codestylesettingspropertiespage.cpp codestylesettingspropertiespage.h
|
||||||
compileoutputwindow.cpp compileoutputwindow.h
|
compileoutputwindow.cpp compileoutputwindow.h
|
||||||
configtaskhandler.cpp configtaskhandler.h
|
configtaskhandler.cpp configtaskhandler.h
|
||||||
copytaskhandler.cpp copytaskhandler.h
|
copytaskhandler.cpp copytaskhandler.h
|
||||||
|
|||||||
@@ -24,36 +24,55 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "codestylesettingspropertiespage.h"
|
#include "codestylesettingspropertiespage.h"
|
||||||
|
|
||||||
#include "editorconfiguration.h"
|
#include "editorconfiguration.h"
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
|
|
||||||
#include <texteditor/texteditorsettings.h>
|
#include <texteditor/texteditorsettings.h>
|
||||||
#include <texteditor/icodestylepreferencesfactory.h>
|
#include <texteditor/icodestylepreferencesfactory.h>
|
||||||
#include <texteditor/codestyleeditor.h>
|
#include <texteditor/codestyleeditor.h>
|
||||||
|
|
||||||
using namespace TextEditor;
|
#include <utils/layoutbuilder.h>
|
||||||
using namespace ProjectExplorer;
|
|
||||||
using namespace ProjectExplorer::Internal;
|
|
||||||
|
|
||||||
CodeStyleSettingsWidget::CodeStyleSettingsWidget(Project *project) : ProjectSettingsWidget(), m_project(project)
|
#include <QComboBox>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QLayout>
|
||||||
|
#include <QStackedWidget>
|
||||||
|
|
||||||
|
using namespace TextEditor;
|
||||||
|
|
||||||
|
namespace ProjectExplorer::Internal {
|
||||||
|
|
||||||
|
CodeStyleSettingsWidget::CodeStyleSettingsWidget(Project *project)
|
||||||
{
|
{
|
||||||
m_ui.setupUi(this);
|
auto languageComboBox = new QComboBox(this);
|
||||||
|
auto stackedWidget = new QStackedWidget(this);
|
||||||
|
|
||||||
setUseGlobalSettingsCheckBoxVisible(false);
|
setUseGlobalSettingsCheckBoxVisible(false);
|
||||||
setUseGlobalSettingsLabelVisible(false);
|
setUseGlobalSettingsLabelVisible(false);
|
||||||
|
|
||||||
const EditorConfiguration *config = m_project->editorConfiguration();
|
const EditorConfiguration *config = project->editorConfiguration();
|
||||||
|
|
||||||
for (ICodeStylePreferencesFactory *factory : TextEditorSettings::codeStyleFactories()) {
|
for (ICodeStylePreferencesFactory *factory : TextEditorSettings::codeStyleFactories()) {
|
||||||
Utils::Id languageId = factory->languageId();
|
Utils::Id languageId = factory->languageId();
|
||||||
ICodeStylePreferences *codeStylePreferences = config->codeStyle(languageId);
|
ICodeStylePreferences *codeStylePreferences = config->codeStyle(languageId);
|
||||||
|
|
||||||
auto preview = factory->createCodeStyleEditor(codeStylePreferences, project, m_ui.stackedWidget);
|
auto preview = factory->createCodeStyleEditor(codeStylePreferences, project, stackedWidget);
|
||||||
if (preview && preview->layout())
|
if (preview && preview->layout())
|
||||||
preview->layout()->setContentsMargins(QMargins());
|
preview->layout()->setContentsMargins(QMargins());
|
||||||
m_ui.stackedWidget->addWidget(preview);
|
stackedWidget->addWidget(preview);
|
||||||
m_ui.languageComboBox->addItem(factory->displayName());
|
languageComboBox->addItem(factory->displayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(m_ui.languageComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
connect(languageComboBox, &QComboBox::currentIndexChanged,
|
||||||
m_ui.stackedWidget, &QStackedWidget::setCurrentIndex);
|
stackedWidget, &QStackedWidget::setCurrentIndex);
|
||||||
|
|
||||||
|
using namespace Utils::Layouting;
|
||||||
|
|
||||||
|
Column {
|
||||||
|
Row { new QLabel(tr("Language:")), languageComboBox, Stretch() },
|
||||||
|
stackedWidget
|
||||||
|
}.attachTo(this, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // ProjectExplorer::Internal
|
||||||
|
|||||||
@@ -25,11 +25,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ui_codestylesettingspropertiespage.h"
|
|
||||||
#include <projectexplorer/projectsettingswidget.h>
|
#include <projectexplorer/projectsettingswidget.h>
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
class EditorConfiguration;
|
|
||||||
class Project;
|
class Project;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -39,10 +38,6 @@ class CodeStyleSettingsWidget : public ProjectSettingsWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit CodeStyleSettingsWidget(Project *project);
|
explicit CodeStyleSettingsWidget(Project *project);
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::CodeStyleSettingsPropertiesPage m_ui;
|
|
||||||
Project *m_project;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>ProjectExplorer::Internal::CodeStyleSettingsPropertiesPage</class>
|
|
||||||
<widget class="QWidget" name="ProjectExplorer::Internal::CodeStyleSettingsPropertiesPage">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>293</width>
|
|
||||||
<height>180</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<property name="margin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="languageLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Language:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QComboBox" name="languageComboBox"/>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="2">
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>73</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0" colspan="3">
|
|
||||||
<widget class="QStackedWidget" name="stackedWidget"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
||||||
@@ -42,7 +42,7 @@ Project {
|
|||||||
"buildtargetinfo.h",
|
"buildtargetinfo.h",
|
||||||
"buildtargettype.h",
|
"buildtargettype.h",
|
||||||
"clangparser.cpp", "clangparser.h",
|
"clangparser.cpp", "clangparser.h",
|
||||||
"codestylesettingspropertiespage.cpp", "codestylesettingspropertiespage.h", "codestylesettingspropertiespage.ui",
|
"codestylesettingspropertiespage.cpp", "codestylesettingspropertiespage.h",
|
||||||
"compileoutputwindow.cpp", "compileoutputwindow.h",
|
"compileoutputwindow.cpp", "compileoutputwindow.h",
|
||||||
"configtaskhandler.cpp", "configtaskhandler.h",
|
"configtaskhandler.cpp", "configtaskhandler.h",
|
||||||
"copytaskhandler.cpp", "copytaskhandler.h",
|
"copytaskhandler.cpp", "copytaskhandler.h",
|
||||||
|
|||||||
Reference in New Issue
Block a user