From 7d8a140f05482c04c787c34e63eeb52b2846b303 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 17 Oct 2022 14:58:47 +0200 Subject: [PATCH] Beautifier: Fix enabling of options Set the path to clang-format after connecting with the path chooser, otherwise setting the initial enabled state breaks. Broke when inline the ui file. Amends 4933697d9a5b38299340e265d2f4e6c78dd1604a Fixes: QTCREATORBUG-28297 Change-Id: I4c6ff7c4515edf13569cf5cd125623005f2967ad Reviewed-by: hjk --- .../beautifier/clangformat/clangformatoptionspage.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugins/beautifier/clangformat/clangformatoptionspage.cpp b/src/plugins/beautifier/clangformat/clangformatoptionspage.cpp index fcefbfc257e..d6244eb466d 100644 --- a/src/plugins/beautifier/clangformat/clangformatoptionspage.cpp +++ b/src/plugins/beautifier/clangformat/clangformatoptionspage.cpp @@ -79,7 +79,6 @@ ClangFormatOptionsPageWidget::ClangFormatOptionsPageWidget(ClangFormatSettings * m_command->setCommandVersionArguments({"--version"}); m_command->setPromptDialogTitle( BeautifierPlugin::msgCommandPromptDialogTitle("Clang Format")); - m_command->setFilePath(m_settings->command()); if (m_settings->usePredefinedStyle()) m_usePredefinedStyle->setChecked(true); @@ -107,13 +106,16 @@ ClangFormatOptionsPageWidget::ClangFormatOptionsPageWidget(ClangFormatSettings * }.attachTo(this); connect(m_command, &Utils::PathChooser::validChanged, options, &QWidget::setEnabled); - connect(m_predefinedStyle, &QComboBox::currentTextChanged, [this](const QString &item) { + connect(m_predefinedStyle, &QComboBox::currentTextChanged, this, [this](const QString &item) { m_fallbackStyle->setEnabled(item == "File"); }); - connect(m_usePredefinedStyle, &QRadioButton::toggled, [this](bool checked) { + connect(m_usePredefinedStyle, &QRadioButton::toggled, this, [this](bool checked) { m_fallbackStyle->setEnabled(checked && m_predefinedStyle->currentText() == "File"); m_predefinedStyle->setEnabled(checked); }); + + // might trigger PathChooser::validChanged, so so after the connect above + m_command->setFilePath(m_settings->command()); } void ClangFormatOptionsPageWidget::apply()