forked from qt-creator/qt-creator
CppTools: Use radio buttons for clazy options
Change-Id: I7c307cffce58c8dc4fd00d17b5c477c85ba509d8 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -124,6 +124,28 @@ void ClangDiagnosticConfigsWidget::onClangTidyItemChanged(QListWidgetItem *item)
|
||||
updateConfig(config);
|
||||
}
|
||||
|
||||
void ClangDiagnosticConfigsWidget::onClazyRadioButtonChanged(bool checked)
|
||||
{
|
||||
if (!checked)
|
||||
return;
|
||||
|
||||
QString checks;
|
||||
if (m_clazyChecks->clazyRadioDisabled->isChecked())
|
||||
checks = QString();
|
||||
else if (m_clazyChecks->clazyRadioLevel0->isChecked())
|
||||
checks = "level0";
|
||||
else if (m_clazyChecks->clazyRadioLevel1->isChecked())
|
||||
checks = "level1";
|
||||
else if (m_clazyChecks->clazyRadioLevel2->isChecked())
|
||||
checks = "level2";
|
||||
else if (m_clazyChecks->clazyRadioLevel3->isChecked())
|
||||
checks = "level3";
|
||||
|
||||
ClangDiagnosticConfig config = currentConfig();
|
||||
config.setClazyChecks(checks);
|
||||
updateConfig(config);
|
||||
}
|
||||
|
||||
static bool isAcceptedWarningOption(const QString &option)
|
||||
{
|
||||
return option == "-w"
|
||||
@@ -267,31 +289,23 @@ void ClangDiagnosticConfigsWidget::syncClangTidyWidgets(const ClangDiagnosticCon
|
||||
void ClangDiagnosticConfigsWidget::syncClazyWidgets(const ClangDiagnosticConfig &config)
|
||||
{
|
||||
const QString clazyChecks = config.clazyChecks();
|
||||
|
||||
QRadioButton *button = m_clazyChecks->clazyRadioDisabled;
|
||||
if (clazyChecks.isEmpty())
|
||||
m_clazyChecks->clazyLevel->setCurrentIndex(0);
|
||||
else
|
||||
m_clazyChecks->clazyLevel->setCurrentText(clazyChecks);
|
||||
button = m_clazyChecks->clazyRadioDisabled;
|
||||
else if (clazyChecks == "level0")
|
||||
button = m_clazyChecks->clazyRadioLevel0;
|
||||
else if (clazyChecks == "level1")
|
||||
button = m_clazyChecks->clazyRadioLevel1;
|
||||
else if (clazyChecks == "level2")
|
||||
button = m_clazyChecks->clazyRadioLevel2;
|
||||
else if (clazyChecks == "level3")
|
||||
button = m_clazyChecks->clazyRadioLevel3;
|
||||
|
||||
button->setChecked(true);
|
||||
m_clazyChecksWidget->setEnabled(!config.isReadOnly());
|
||||
}
|
||||
|
||||
void ClangDiagnosticConfigsWidget::setClazyLevelDescription(int index)
|
||||
{
|
||||
// Levels descriptions are taken from https://github.com/KDE/clazy
|
||||
static const QString levelDescriptions[] {
|
||||
QString(),
|
||||
tr("Very stable checks, 99.99% safe, no false-positives."),
|
||||
tr("Similar to level 0, but sometimes (rarely) there might be\n"
|
||||
"some false-positives."),
|
||||
tr("Sometimes has false-positives (20-30%)."),
|
||||
tr("Not always correct, possibly very noisy, might require\n"
|
||||
"a knowledgeable developer to review, might have a very big\n"
|
||||
"rate of false-positives, might have bugs.")
|
||||
};
|
||||
|
||||
QTC_ASSERT(m_clazyChecks, return);
|
||||
m_clazyChecks->levelDescription->setText(levelDescriptions[static_cast<unsigned>(index)]);
|
||||
}
|
||||
|
||||
void ClangDiagnosticConfigsWidget::updateConfig(const ClangDiagnosticConfig &config)
|
||||
{
|
||||
m_diagnosticConfigsModel.appendOrUpdate(config);
|
||||
@@ -353,6 +367,14 @@ void ClangDiagnosticConfigsWidget::disconnectClangTidyItemChanged()
|
||||
this, &ClangDiagnosticConfigsWidget::onClangTidyItemChanged);
|
||||
}
|
||||
|
||||
void ClangDiagnosticConfigsWidget::connectClazyRadioButtonClicked(QRadioButton *button)
|
||||
{
|
||||
connect(button,
|
||||
&QRadioButton::clicked,
|
||||
this,
|
||||
&ClangDiagnosticConfigsWidget::onClazyRadioButtonChanged);
|
||||
}
|
||||
|
||||
void ClangDiagnosticConfigsWidget::connectConfigChooserCurrentIndex()
|
||||
{
|
||||
connect(m_ui->configChooserComboBox,
|
||||
@@ -416,17 +438,12 @@ void ClangDiagnosticConfigsWidget::setupTabs()
|
||||
m_clazyChecks.reset(new CppTools::Ui::ClazyChecks);
|
||||
m_clazyChecksWidget = new QWidget();
|
||||
m_clazyChecks->setupUi(m_clazyChecksWidget);
|
||||
connect(m_clazyChecks->clazyLevel,
|
||||
static_cast<void (QComboBox::*)(int index)>(&QComboBox::currentIndexChanged),
|
||||
[this](int index) {
|
||||
setClazyLevelDescription(index);
|
||||
ClangDiagnosticConfig config = currentConfig();
|
||||
if (index == 0)
|
||||
config.setClazyChecks(QString());
|
||||
else
|
||||
config.setClazyChecks(m_clazyChecks->clazyLevel->itemText(index));
|
||||
updateConfig(config);
|
||||
});
|
||||
|
||||
connectClazyRadioButtonClicked(m_clazyChecks->clazyRadioDisabled);
|
||||
connectClazyRadioButtonClicked(m_clazyChecks->clazyRadioLevel0);
|
||||
connectClazyRadioButtonClicked(m_clazyChecks->clazyRadioLevel1);
|
||||
connectClazyRadioButtonClicked(m_clazyChecks->clazyRadioLevel2);
|
||||
connectClazyRadioButtonClicked(m_clazyChecks->clazyRadioLevel3);
|
||||
|
||||
m_tidyChecks.reset(new CppTools::Ui::TidyChecks);
|
||||
m_tidyChecksWidget = new QWidget();
|
||||
|
||||
@@ -35,7 +35,10 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QListWidgetItem)
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QListWidgetItem;
|
||||
class QRadioButton;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
@@ -74,6 +77,7 @@ private:
|
||||
void onCopyButtonClicked();
|
||||
void onRemoveButtonClicked();
|
||||
void onClangTidyItemChanged(QListWidgetItem *item);
|
||||
void onClazyRadioButtonChanged(bool checked);
|
||||
|
||||
void onDiagnosticOptionsEdited();
|
||||
|
||||
@@ -83,7 +87,6 @@ private:
|
||||
void syncClangTidyWidgets(const ClangDiagnosticConfig &config);
|
||||
void syncClazyWidgets(const ClangDiagnosticConfig &config);
|
||||
|
||||
void setClazyLevelDescription(int index);
|
||||
void updateConfig(const CppTools::ClangDiagnosticConfig &config);
|
||||
|
||||
bool isConfigChooserEmpty() const;
|
||||
@@ -95,6 +98,8 @@ private:
|
||||
void connectClangTidyItemChanged();
|
||||
void disconnectClangTidyItemChanged();
|
||||
|
||||
void connectClazyRadioButtonClicked(QRadioButton *button);
|
||||
|
||||
void connectConfigChooserCurrentIndex();
|
||||
void disconnectConfigChooserCurrentIndex();
|
||||
void connectDiagnosticOptionsChanged();
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>503</width>
|
||||
<height>73</height>
|
||||
<width>609</width>
|
||||
<height>220</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@@ -19,92 +19,73 @@
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="clazyLevel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Each level adds checks to the previous level. For more information, see <a href="https://github.com/KDE/clazy">clazy's homepage</a>.</string>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Disable</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>level0</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>level1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>level2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>level3</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>10</number>
|
||||
<widget class="QRadioButton" name="clazyRadioDisabled">
|
||||
<property name="text">
|
||||
<string>Disabled</string>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="levelDescription">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<widget class="QRadioButton" name="clazyRadioLevel0">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
<property name="text">
|
||||
<string>Level 0: No false positives</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="clazyRadioLevel1">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Level 1: Very few false positives</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="clazyRadioLevel2">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Level 2: More false positives</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="clazyRadioLevel3">
|
||||
<property name="toolTip">
|
||||
<string>Not always correct, possibly very noisy, might require a knowledgeable developer to review, might have a very big rate of false-positives, might have bugs.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Level 3: Experimental checks</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>20</height>
|
||||
<width>20</width>
|
||||
<height>34</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
|
||||
Reference in New Issue
Block a user