diff --git a/src/plugins/beautifier/CMakeLists.txt b/src/plugins/beautifier/CMakeLists.txt index 742dae66156..79d2d9a855f 100644 --- a/src/plugins/beautifier/CMakeLists.txt +++ b/src/plugins/beautifier/CMakeLists.txt @@ -18,7 +18,7 @@ add_qtc_plugin(Beautifier configurationdialog.cpp configurationdialog.h configurationdialog.ui configurationeditor.cpp configurationeditor.h configurationpanel.cpp configurationpanel.h - generaloptionspage.cpp generaloptionspage.h generaloptionspage.ui + generaloptionspage.cpp generaloptionspage.h generalsettings.cpp generalsettings.h uncrustify/uncrustify.cpp uncrustify/uncrustify.h uncrustify/uncrustifyconstants.h diff --git a/src/plugins/beautifier/beautifier.qbs b/src/plugins/beautifier/beautifier.qbs index 976a47f9611..c3676f93758 100644 --- a/src/plugins/beautifier/beautifier.qbs +++ b/src/plugins/beautifier/beautifier.qbs @@ -27,7 +27,6 @@ QtcPlugin { "configurationpanel.h", "generaloptionspage.cpp", "generaloptionspage.h", - "generaloptionspage.ui", "generalsettings.cpp", "generalsettings.h", ] diff --git a/src/plugins/beautifier/generaloptionspage.cpp b/src/plugins/beautifier/generaloptionspage.cpp index 3a6005c10c3..f00121718bb 100644 --- a/src/plugins/beautifier/generaloptionspage.cpp +++ b/src/plugins/beautifier/generaloptionspage.cpp @@ -24,13 +24,19 @@ ****************************************************************************/ #include "generaloptionspage.h" -#include "ui_generaloptionspage.h" #include "beautifierconstants.h" #include "generalsettings.h" -namespace Beautifier { -namespace Internal { +#include + +#include +#include +#include +#include +#include + +namespace Beautifier::Internal { class GeneralOptionsPageWidget : public Core::IOptionsPageWidget { @@ -42,29 +48,71 @@ public: private: void apply() final; - Ui::GeneralOptionsPage ui; + QCheckBox *m_autoFormat; + QComboBox *m_autoFormatTool; + QLineEdit *m_autoFormatMime; + QCheckBox *m_autoFormatOnlyCurrentProject; }; GeneralOptionsPageWidget::GeneralOptionsPageWidget(const QStringList &toolIds) { - ui.setupUi(this); - ui.autoFormatTool->addItems(toolIds); + resize(817, 631); auto settings = GeneralSettings::instance(); - ui.autoFormat->setChecked(settings->autoFormatOnSave()); - const int index = ui.autoFormatTool->findText(settings->autoFormatTool()); - ui.autoFormatTool->setCurrentIndex(qMax(index, 0)); - ui.autoFormatMime->setText(settings->autoFormatMimeAsString()); - ui.autoFormatOnlyCurrentProject->setChecked(settings->autoFormatOnlyCurrentProject()); + + m_autoFormat = new QCheckBox(tr("Enable auto format on file save")); + m_autoFormat->setChecked(settings->autoFormatOnSave()); + + 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() { auto settings = GeneralSettings::instance(); - settings->setAutoFormatOnSave(ui.autoFormat->isChecked()); - settings->setAutoFormatTool(ui.autoFormatTool->currentText()); - settings->setAutoFormatMime(ui.autoFormatMime->text()); - settings->setAutoFormatOnlyCurrentProject(ui.autoFormatOnlyCurrentProject->isChecked()); + settings->setAutoFormatOnSave(m_autoFormat->isChecked()); + settings->setAutoFormatTool(m_autoFormatTool->currentText()); + settings->setAutoFormatMime(m_autoFormatMime->text()); + settings->setAutoFormatOnlyCurrentProject(m_autoFormatOnlyCurrentProject->isChecked()); settings->save(); } @@ -78,5 +126,4 @@ GeneralOptionsPage::GeneralOptionsPage(const QStringList &toolIds) setCategoryIconPath(":/beautifier/images/settingscategory_beautifier.png"); } -} // namespace Internal -} // namespace Beautifier +} // Beautifier::Internal diff --git a/src/plugins/beautifier/generaloptionspage.h b/src/plugins/beautifier/generaloptionspage.h index 2995fd05e24..1e54a74a8bf 100644 --- a/src/plugins/beautifier/generaloptionspage.h +++ b/src/plugins/beautifier/generaloptionspage.h @@ -27,8 +27,7 @@ #include -namespace Beautifier { -namespace Internal { +namespace Beautifier::Internal { class GeneralOptionsPage final : public Core::IOptionsPage { @@ -36,5 +35,4 @@ public: explicit GeneralOptionsPage(const QStringList &toolIds); }; -} // namespace Internal -} // namespace Beautifier +} // Beautifier::Internal diff --git a/src/plugins/beautifier/generaloptionspage.ui b/src/plugins/beautifier/generaloptionspage.ui deleted file mode 100644 index 07fd22b2168..00000000000 --- a/src/plugins/beautifier/generaloptionspage.ui +++ /dev/null @@ -1,178 +0,0 @@ - - - Beautifier::Internal::GeneralOptionsPage - - - - 0 - 0 - 817 - 631 - - - - - - - - - - true - - - Automatic Formatting on File Save - - - - - - Enable auto format on file save - - - - - - - false - - - Tool: - - - - - - - false - - - - - - - false - - - Restrict to MIME types: - - - - - - - false - - - - - - - false - - - Restrict to files contained in the current project - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - autoFormat - toggled(bool) - autoFormatTool - setEnabled(bool) - - - 140 - 56 - - - 262 - 99 - - - - - autoFormat - toggled(bool) - autoFormatMime - setEnabled(bool) - - - 292 - 51 - - - 288 - 106 - - - - - autoFormat - toggled(bool) - label - setEnabled(bool) - - - 41 - 55 - - - 65 - 92 - - - - - autoFormat - toggled(bool) - label_2 - setEnabled(bool) - - - 92 - 47 - - - 74 - 122 - - - - - autoFormat - toggled(bool) - autoFormatOnlyCurrentProject - setEnabled(bool) - - - 38 - 50 - - - 32 - 160 - - - - -