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);
|
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)
|
static bool isAcceptedWarningOption(const QString &option)
|
||||||
{
|
{
|
||||||
return option == "-w"
|
return option == "-w"
|
||||||
@@ -267,31 +289,23 @@ void ClangDiagnosticConfigsWidget::syncClangTidyWidgets(const ClangDiagnosticCon
|
|||||||
void ClangDiagnosticConfigsWidget::syncClazyWidgets(const ClangDiagnosticConfig &config)
|
void ClangDiagnosticConfigsWidget::syncClazyWidgets(const ClangDiagnosticConfig &config)
|
||||||
{
|
{
|
||||||
const QString clazyChecks = config.clazyChecks();
|
const QString clazyChecks = config.clazyChecks();
|
||||||
|
|
||||||
|
QRadioButton *button = m_clazyChecks->clazyRadioDisabled;
|
||||||
if (clazyChecks.isEmpty())
|
if (clazyChecks.isEmpty())
|
||||||
m_clazyChecks->clazyLevel->setCurrentIndex(0);
|
button = m_clazyChecks->clazyRadioDisabled;
|
||||||
else
|
else if (clazyChecks == "level0")
|
||||||
m_clazyChecks->clazyLevel->setCurrentText(clazyChecks);
|
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());
|
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)
|
void ClangDiagnosticConfigsWidget::updateConfig(const ClangDiagnosticConfig &config)
|
||||||
{
|
{
|
||||||
m_diagnosticConfigsModel.appendOrUpdate(config);
|
m_diagnosticConfigsModel.appendOrUpdate(config);
|
||||||
@@ -353,6 +367,14 @@ void ClangDiagnosticConfigsWidget::disconnectClangTidyItemChanged()
|
|||||||
this, &ClangDiagnosticConfigsWidget::onClangTidyItemChanged);
|
this, &ClangDiagnosticConfigsWidget::onClangTidyItemChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClangDiagnosticConfigsWidget::connectClazyRadioButtonClicked(QRadioButton *button)
|
||||||
|
{
|
||||||
|
connect(button,
|
||||||
|
&QRadioButton::clicked,
|
||||||
|
this,
|
||||||
|
&ClangDiagnosticConfigsWidget::onClazyRadioButtonChanged);
|
||||||
|
}
|
||||||
|
|
||||||
void ClangDiagnosticConfigsWidget::connectConfigChooserCurrentIndex()
|
void ClangDiagnosticConfigsWidget::connectConfigChooserCurrentIndex()
|
||||||
{
|
{
|
||||||
connect(m_ui->configChooserComboBox,
|
connect(m_ui->configChooserComboBox,
|
||||||
@@ -416,17 +438,12 @@ void ClangDiagnosticConfigsWidget::setupTabs()
|
|||||||
m_clazyChecks.reset(new CppTools::Ui::ClazyChecks);
|
m_clazyChecks.reset(new CppTools::Ui::ClazyChecks);
|
||||||
m_clazyChecksWidget = new QWidget();
|
m_clazyChecksWidget = new QWidget();
|
||||||
m_clazyChecks->setupUi(m_clazyChecksWidget);
|
m_clazyChecks->setupUi(m_clazyChecksWidget);
|
||||||
connect(m_clazyChecks->clazyLevel,
|
|
||||||
static_cast<void (QComboBox::*)(int index)>(&QComboBox::currentIndexChanged),
|
connectClazyRadioButtonClicked(m_clazyChecks->clazyRadioDisabled);
|
||||||
[this](int index) {
|
connectClazyRadioButtonClicked(m_clazyChecks->clazyRadioLevel0);
|
||||||
setClazyLevelDescription(index);
|
connectClazyRadioButtonClicked(m_clazyChecks->clazyRadioLevel1);
|
||||||
ClangDiagnosticConfig config = currentConfig();
|
connectClazyRadioButtonClicked(m_clazyChecks->clazyRadioLevel2);
|
||||||
if (index == 0)
|
connectClazyRadioButtonClicked(m_clazyChecks->clazyRadioLevel3);
|
||||||
config.setClazyChecks(QString());
|
|
||||||
else
|
|
||||||
config.setClazyChecks(m_clazyChecks->clazyLevel->itemText(index));
|
|
||||||
updateConfig(config);
|
|
||||||
});
|
|
||||||
|
|
||||||
m_tidyChecks.reset(new CppTools::Ui::TidyChecks);
|
m_tidyChecks.reset(new CppTools::Ui::TidyChecks);
|
||||||
m_tidyChecksWidget = new QWidget();
|
m_tidyChecksWidget = new QWidget();
|
||||||
|
|||||||
@@ -35,7 +35,10 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QListWidgetItem)
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QListWidgetItem;
|
||||||
|
class QRadioButton;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace CppTools {
|
namespace CppTools {
|
||||||
|
|
||||||
@@ -74,6 +77,7 @@ private:
|
|||||||
void onCopyButtonClicked();
|
void onCopyButtonClicked();
|
||||||
void onRemoveButtonClicked();
|
void onRemoveButtonClicked();
|
||||||
void onClangTidyItemChanged(QListWidgetItem *item);
|
void onClangTidyItemChanged(QListWidgetItem *item);
|
||||||
|
void onClazyRadioButtonChanged(bool checked);
|
||||||
|
|
||||||
void onDiagnosticOptionsEdited();
|
void onDiagnosticOptionsEdited();
|
||||||
|
|
||||||
@@ -83,7 +87,6 @@ private:
|
|||||||
void syncClangTidyWidgets(const ClangDiagnosticConfig &config);
|
void syncClangTidyWidgets(const ClangDiagnosticConfig &config);
|
||||||
void syncClazyWidgets(const ClangDiagnosticConfig &config);
|
void syncClazyWidgets(const ClangDiagnosticConfig &config);
|
||||||
|
|
||||||
void setClazyLevelDescription(int index);
|
|
||||||
void updateConfig(const CppTools::ClangDiagnosticConfig &config);
|
void updateConfig(const CppTools::ClangDiagnosticConfig &config);
|
||||||
|
|
||||||
bool isConfigChooserEmpty() const;
|
bool isConfigChooserEmpty() const;
|
||||||
@@ -95,6 +98,8 @@ private:
|
|||||||
void connectClangTidyItemChanged();
|
void connectClangTidyItemChanged();
|
||||||
void disconnectClangTidyItemChanged();
|
void disconnectClangTidyItemChanged();
|
||||||
|
|
||||||
|
void connectClazyRadioButtonClicked(QRadioButton *button);
|
||||||
|
|
||||||
void connectConfigChooserCurrentIndex();
|
void connectConfigChooserCurrentIndex();
|
||||||
void disconnectConfigChooserCurrentIndex();
|
void disconnectConfigChooserCurrentIndex();
|
||||||
void connectDiagnosticOptionsChanged();
|
void connectDiagnosticOptionsChanged();
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>503</width>
|
<width>609</width>
|
||||||
<height>73</height>
|
<height>220</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@@ -19,92 +19,73 @@
|
|||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<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>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="clazyLevel">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="currentIndex">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Disable</string>
|
<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>
|
||||||
</item>
|
<property name="openExternalLinks">
|
||||||
<item>
|
<bool>true</bool>
|
||||||
<property name="text">
|
|
||||||
<string>level0</string>
|
|
||||||
</property>
|
</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>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<widget class="QRadioButton" name="clazyRadioDisabled">
|
||||||
<property name="leftMargin">
|
|
||||||
<number>10</number>
|
|
||||||
</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">
|
<property name="text">
|
||||||
|
<string>Disabled</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="clazyRadioLevel0">
|
||||||
|
<property name="toolTip">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Level 0: No false positives</string>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
<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>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<widget class="QRadioButton" name="clazyRadioLevel2">
|
||||||
<property name="orientation">
|
<property name="toolTip">
|
||||||
<enum>Qt::Horizontal</enum>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeType">
|
<property name="text">
|
||||||
<enum>QSizePolicy::Expanding</enum>
|
<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>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>10</width>
|
<width>20</width>
|
||||||
<height>20</height>
|
<height>34</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
|
|||||||
Reference in New Issue
Block a user