improve the clang settings

This commit is contained in:
Daniel Marjamäki 2017-08-10 15:47:20 +02:00
parent c29536cfe1
commit 1afebfa96d
5 changed files with 97 additions and 20 deletions

View File

@ -80,6 +80,7 @@
#define SETTINGS_APPLICATION_DEFAULT "Default Application"
#define SETTINGS_LANGUAGE "Application language"
#define SETTINGS_GLOBAL_INCLUDE_PATHS "Global include paths"
#define SETTINGS_CLANG_PATH "Clang path"
#define SETTINGS_VS_INCLUDE_PATHS "Visual studio include paths"
#define SETTINGS_INLINE_SUPPRESSIONS "Inline suppressions"
#define SETTINGS_INCONCLUSIVE_ERRORS "Inconclusive errors"

View File

@ -445,9 +445,13 @@ void MainWindow::doAnalyzeProject(ImportProject p)
mThread->setAddons(mProjectFile->getAddons());
mThread->setVsIncludePaths(mSettings->value(SETTINGS_VS_INCLUDE_PATHS).toString());
#ifdef Q_OS_WIN
QString clangPath = mSettings->value(SETTINGS_CLANG_PATH,QString()).toString();
if (clangPath.isEmpty()) {
// Try to autodetect clang
if (QFileInfo("C:/Program Files/LLVM/bin/clang.exe").exists())
mThread->setClangPath("C:/Program Files/LLVM/bin");
clangPath = "C:/Program Files/LLVM/bin";
}
mThread->setClangPath(clangPath);
#endif
}
mThread->setProject(p);

View File

@ -240,16 +240,6 @@
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="mLabelVsInclude">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Visual Studio include paths&lt;br/&gt;Open Visual Studio command prompt. Type &amp;quot;SET INCLUDE&amp;quot; and paste the outputs below:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="mEditVsInclude"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
@ -355,6 +345,74 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="mTabClang">
<attribute name="title">
<string>Clang</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Clang path</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLineEdit" name="mEditClangPath">
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mBtnBrowseClangPath">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>51</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Visual Studio include paths.&lt;/p&gt;&lt;p&gt;Open Visual Studio Command Prompt. Type &amp;quot;SET INSTALL&amp;quot; and then copy paste the output here&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="mEditVsIncludePaths"/>
</item>
<item>
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>50</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item>

View File

@ -55,13 +55,12 @@ SettingsDialog::SettingsDialog(ApplicationList *list,
mUI.mShowErrorId->setCheckState(boolToCheckState(settings.value(SETTINGS_SHOW_ERROR_ID, false).toBool()));
#ifdef Q_OS_WIN
mUI.mLabelVsInclude->setVisible(true);
mUI.mEditVsInclude->setVisible(true);
mUI.mEditVsInclude->setText(settings.value(SETTINGS_VS_INCLUDE_PATHS, QString()).toString());
mUI.mTabClang->setVisible(true);
mUI.mEditClangPath->setText(settings.value(SETTINGS_CLANG_PATH, QString()).toString());
mUI.mEditVsIncludePaths->setText(settings.value(SETTINGS_VS_INCLUDE_PATHS, QString()).toString());
connect(mUI.mBtnBrowseClangPath, &QPushButton::released, this, &SettingsDialog::browseClangPath);
#else
mUI.mLabelVsInclude->setVisible(false);
mUI.mEditVsInclude->setVisible(false);
mUI.mEditVsInclude->setText(QString());
mUI.mTabClang->setVisible(false);
#endif
connect(mUI.mButtons, &QDialogButtonBox::accepted, this, &SettingsDialog::ok);
connect(mUI.mButtons, &QDialogButtonBox::rejected, this, &SettingsDialog::reject);
@ -187,7 +186,8 @@ void SettingsDialog::saveSettingValues() const
saveCheckboxValue(&settings, mUI.mShowErrorId, SETTINGS_SHOW_ERROR_ID);
#ifdef Q_OS_WIN
QString vsIncludePaths = mUI.mEditVsInclude->text();
settings.setValue(SETTINGS_CLANG_PATH, mUI.mEditClangPath->text());
QString vsIncludePaths = mUI.mEditVsIncludePaths->text();
if (vsIncludePaths.startsWith("INCLUDE="))
vsIncludePaths.remove(0, 8);
settings.setValue(SETTINGS_VS_INCLUDE_PATHS, vsIncludePaths);
@ -358,3 +358,14 @@ void SettingsDialog::editIncludePath()
QListWidgetItem *item = mUI.mListIncludePaths->currentItem();
mUI.mListIncludePaths->editItem(item);
}
void SettingsDialog::browseClangPath()
{
QString selectedDir = QFileDialog::getExistingDirectory(this,
tr("Select clang path"),
QDir::rootPath());
if (!selectedDir.isEmpty()) {
mUI.mEditClangPath->setText(selectedDir);
}
}

View File

@ -142,6 +142,9 @@ protected slots:
*/
void editIncludePath();
/** @brief Slot for browsing for the clang binary */
void browseClangPath();
protected:
/**