forked from qt-creator/qt-creator
Beautifier: inline generaloptionspage.ui
Change-Id: If989d3a636f7ad046c6a1efdb78a3c3c63e15756 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -18,7 +18,7 @@ add_qtc_plugin(Beautifier
|
|||||||
configurationdialog.cpp configurationdialog.h configurationdialog.ui
|
configurationdialog.cpp configurationdialog.h configurationdialog.ui
|
||||||
configurationeditor.cpp configurationeditor.h
|
configurationeditor.cpp configurationeditor.h
|
||||||
configurationpanel.cpp configurationpanel.h
|
configurationpanel.cpp configurationpanel.h
|
||||||
generaloptionspage.cpp generaloptionspage.h generaloptionspage.ui
|
generaloptionspage.cpp generaloptionspage.h
|
||||||
generalsettings.cpp generalsettings.h
|
generalsettings.cpp generalsettings.h
|
||||||
uncrustify/uncrustify.cpp uncrustify/uncrustify.h
|
uncrustify/uncrustify.cpp uncrustify/uncrustify.h
|
||||||
uncrustify/uncrustifyconstants.h
|
uncrustify/uncrustifyconstants.h
|
||||||
|
@@ -27,7 +27,6 @@ QtcPlugin {
|
|||||||
"configurationpanel.h",
|
"configurationpanel.h",
|
||||||
"generaloptionspage.cpp",
|
"generaloptionspage.cpp",
|
||||||
"generaloptionspage.h",
|
"generaloptionspage.h",
|
||||||
"generaloptionspage.ui",
|
|
||||||
"generalsettings.cpp",
|
"generalsettings.cpp",
|
||||||
"generalsettings.h",
|
"generalsettings.h",
|
||||||
]
|
]
|
||||||
|
@@ -24,13 +24,19 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "generaloptionspage.h"
|
#include "generaloptionspage.h"
|
||||||
#include "ui_generaloptionspage.h"
|
|
||||||
|
|
||||||
#include "beautifierconstants.h"
|
#include "beautifierconstants.h"
|
||||||
#include "generalsettings.h"
|
#include "generalsettings.h"
|
||||||
|
|
||||||
namespace Beautifier {
|
#include <utils/layoutbuilder.h>
|
||||||
namespace Internal {
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QLineEdit>
|
||||||
|
|
||||||
|
namespace Beautifier::Internal {
|
||||||
|
|
||||||
class GeneralOptionsPageWidget : public Core::IOptionsPageWidget
|
class GeneralOptionsPageWidget : public Core::IOptionsPageWidget
|
||||||
{
|
{
|
||||||
@@ -42,29 +48,71 @@ public:
|
|||||||
private:
|
private:
|
||||||
void apply() final;
|
void apply() final;
|
||||||
|
|
||||||
Ui::GeneralOptionsPage ui;
|
QCheckBox *m_autoFormat;
|
||||||
|
QComboBox *m_autoFormatTool;
|
||||||
|
QLineEdit *m_autoFormatMime;
|
||||||
|
QCheckBox *m_autoFormatOnlyCurrentProject;
|
||||||
};
|
};
|
||||||
|
|
||||||
GeneralOptionsPageWidget::GeneralOptionsPageWidget(const QStringList &toolIds)
|
GeneralOptionsPageWidget::GeneralOptionsPageWidget(const QStringList &toolIds)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
resize(817, 631);
|
||||||
ui.autoFormatTool->addItems(toolIds);
|
|
||||||
|
|
||||||
auto settings = GeneralSettings::instance();
|
auto settings = GeneralSettings::instance();
|
||||||
ui.autoFormat->setChecked(settings->autoFormatOnSave());
|
|
||||||
const int index = ui.autoFormatTool->findText(settings->autoFormatTool());
|
m_autoFormat = new QCheckBox(tr("Enable auto format on file save"));
|
||||||
ui.autoFormatTool->setCurrentIndex(qMax(index, 0));
|
m_autoFormat->setChecked(settings->autoFormatOnSave());
|
||||||
ui.autoFormatMime->setText(settings->autoFormatMimeAsString());
|
|
||||||
ui.autoFormatOnlyCurrentProject->setChecked(settings->autoFormatOnlyCurrentProject());
|
auto toolLabel = new QLabel(tr("Tool:"));
|
||||||
|
toolLabel->setEnabled(false);
|
||||||
|
|
||||||
|
auto mimeLabel = new QLabel(tr("Restrict to MIME types:"));
|
||||||
|
mimeLabel->setEnabled(false);
|
||||||
|
|
||||||
|
m_autoFormatMime = new QLineEdit(settings->autoFormatMimeAsString());
|
||||||
|
m_autoFormatMime->setEnabled(false);
|
||||||
|
|
||||||
|
m_autoFormatOnlyCurrentProject =
|
||||||
|
new QCheckBox(tr("Restrict to files contained in the current project"));
|
||||||
|
m_autoFormatOnlyCurrentProject->setEnabled(false);
|
||||||
|
m_autoFormatOnlyCurrentProject->setChecked(settings->autoFormatOnlyCurrentProject());
|
||||||
|
|
||||||
|
m_autoFormatTool = new QComboBox;
|
||||||
|
m_autoFormatTool->setEnabled(false);
|
||||||
|
m_autoFormatTool->addItems(toolIds);
|
||||||
|
const int index = m_autoFormatTool->findText(settings->autoFormatTool());
|
||||||
|
m_autoFormatTool->setCurrentIndex(qMax(index, 0));
|
||||||
|
|
||||||
|
using namespace Utils::Layouting;
|
||||||
|
const Break br;
|
||||||
|
|
||||||
|
Column {
|
||||||
|
Group {
|
||||||
|
Title(tr("Automatic Formatting on File Save")),
|
||||||
|
Form {
|
||||||
|
Span(2, m_autoFormat), br,
|
||||||
|
toolLabel, m_autoFormatTool, br,
|
||||||
|
mimeLabel, m_autoFormatMime, br,
|
||||||
|
Span(2, m_autoFormatOnlyCurrentProject)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Stretch()
|
||||||
|
}.attachTo(this);
|
||||||
|
|
||||||
|
connect(m_autoFormat, &QCheckBox::toggled, m_autoFormatTool, &QComboBox::setEnabled);
|
||||||
|
connect(m_autoFormat, &QCheckBox::toggled, m_autoFormatMime, &QLineEdit::setEnabled);
|
||||||
|
connect(m_autoFormat, &QCheckBox::toggled, toolLabel, &QLabel::setEnabled);
|
||||||
|
connect(m_autoFormat, &QCheckBox::toggled, mimeLabel, &QLabel::setEnabled);
|
||||||
|
connect(m_autoFormat, &QCheckBox::toggled, m_autoFormatOnlyCurrentProject, &QCheckBox::setEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneralOptionsPageWidget::apply()
|
void GeneralOptionsPageWidget::apply()
|
||||||
{
|
{
|
||||||
auto settings = GeneralSettings::instance();
|
auto settings = GeneralSettings::instance();
|
||||||
settings->setAutoFormatOnSave(ui.autoFormat->isChecked());
|
settings->setAutoFormatOnSave(m_autoFormat->isChecked());
|
||||||
settings->setAutoFormatTool(ui.autoFormatTool->currentText());
|
settings->setAutoFormatTool(m_autoFormatTool->currentText());
|
||||||
settings->setAutoFormatMime(ui.autoFormatMime->text());
|
settings->setAutoFormatMime(m_autoFormatMime->text());
|
||||||
settings->setAutoFormatOnlyCurrentProject(ui.autoFormatOnlyCurrentProject->isChecked());
|
settings->setAutoFormatOnlyCurrentProject(m_autoFormatOnlyCurrentProject->isChecked());
|
||||||
settings->save();
|
settings->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,5 +126,4 @@ GeneralOptionsPage::GeneralOptionsPage(const QStringList &toolIds)
|
|||||||
setCategoryIconPath(":/beautifier/images/settingscategory_beautifier.png");
|
setCategoryIconPath(":/beautifier/images/settingscategory_beautifier.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // Beautifier::Internal
|
||||||
} // namespace Beautifier
|
|
||||||
|
@@ -27,8 +27,7 @@
|
|||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
|
|
||||||
namespace Beautifier {
|
namespace Beautifier::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class GeneralOptionsPage final : public Core::IOptionsPage
|
class GeneralOptionsPage final : public Core::IOptionsPage
|
||||||
{
|
{
|
||||||
@@ -36,5 +35,4 @@ public:
|
|||||||
explicit GeneralOptionsPage(const QStringList &toolIds);
|
explicit GeneralOptionsPage(const QStringList &toolIds);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // Beautifier::Internal
|
||||||
} // namespace Beautifier
|
|
||||||
|
@@ -1,178 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Beautifier::Internal::GeneralOptionsPage</class>
|
|
||||||
<widget class="QWidget" name="Beautifier::Internal::GeneralOptionsPage">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>817</width>
|
|
||||||
<height>631</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="formatOnSave">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="title">
|
|
||||||
<string>Automatic Formatting on File Save</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<item row="0" column="0" colspan="2">
|
|
||||||
<widget class="QCheckBox" name="autoFormat">
|
|
||||||
<property name="text">
|
|
||||||
<string>Enable auto format on file save</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Tool:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QComboBox" name="autoFormatTool">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Restrict to MIME types:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QLineEdit" name="autoFormatMime">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0" colspan="2">
|
|
||||||
<widget class="QCheckBox" name="autoFormatOnlyCurrentProject">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Restrict to files contained in the current project</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>autoFormat</sender>
|
|
||||||
<signal>toggled(bool)</signal>
|
|
||||||
<receiver>autoFormatTool</receiver>
|
|
||||||
<slot>setEnabled(bool)</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>140</x>
|
|
||||||
<y>56</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>262</x>
|
|
||||||
<y>99</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>autoFormat</sender>
|
|
||||||
<signal>toggled(bool)</signal>
|
|
||||||
<receiver>autoFormatMime</receiver>
|
|
||||||
<slot>setEnabled(bool)</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>292</x>
|
|
||||||
<y>51</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>288</x>
|
|
||||||
<y>106</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>autoFormat</sender>
|
|
||||||
<signal>toggled(bool)</signal>
|
|
||||||
<receiver>label</receiver>
|
|
||||||
<slot>setEnabled(bool)</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>41</x>
|
|
||||||
<y>55</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>65</x>
|
|
||||||
<y>92</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>autoFormat</sender>
|
|
||||||
<signal>toggled(bool)</signal>
|
|
||||||
<receiver>label_2</receiver>
|
|
||||||
<slot>setEnabled(bool)</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>92</x>
|
|
||||||
<y>47</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>74</x>
|
|
||||||
<y>122</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>autoFormat</sender>
|
|
||||||
<signal>toggled(bool)</signal>
|
|
||||||
<receiver>autoFormatOnlyCurrentProject</receiver>
|
|
||||||
<slot>setEnabled(bool)</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>38</x>
|
|
||||||
<y>50</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>32</x>
|
|
||||||
<y>160</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
Reference in New Issue
Block a user