Merge remote-tracking branch 'origin/master' into 4.0

Change-Id: Iab01658c329f3bf57077595d54be6ed73f11f715
This commit is contained in:
Eike Ziller
2016-03-02 09:17:54 +01:00
42 changed files with 24116 additions and 13910 deletions

View File

@@ -1,5 +1,5 @@
import QtQuick 2.4 import QtQuick 2.4
import QtCanvas3D 1.0 import QtCanvas3D 1.1
import QtQuick.Window 2.2 import QtQuick.Window 2.2
import "glcode.js" as GLCode import "glcode.js" as GLCode

File diff suppressed because one or more lines are too long

View File

@@ -9,7 +9,6 @@ function initializeGL(canvas) {
camera.position.z = 5; camera.position.z = 5;
var material = new THREE.MeshBasicMaterial({ color: 0x80c342, var material = new THREE.MeshBasicMaterial({ color: 0x80c342,
ambient: 0x000000,
shading: THREE.SmoothShading }); shading: THREE.SmoothShading });
var cubeGeometry = new THREE.BoxGeometry(1, 1, 1); var cubeGeometry = new THREE.BoxGeometry(1, 1, 1);
cube = new THREE.Mesh(cubeGeometry, material); cube = new THREE.Mesh(cubeGeometry, material);

View File

@@ -7,7 +7,7 @@
"trDisplayName": "Qt Canvas 3D Application", "trDisplayName": "Qt Canvas 3D Application",
"trDisplayCategory": "Application", "trDisplayCategory": "Application",
"icon": "3dapplication.png", "icon": "3dapplication.png",
"featuresRequired": [ "QtSupport.Wizards.FeatureQtCanvas3d" ], "featuresRequired": [ "QtSupport.Wizards.FeatureQtCanvas3d1.1" ],
"enabled": "%{JS: [ %{Plugins} ].indexOf('QmakeProjectManager') >= 0}", "enabled": "%{JS: [ %{Plugins} ].indexOf('QmakeProjectManager') >= 0}",
"options": "options":

View File

@@ -0,0 +1,10 @@
import QtQuick %{QtQuickVersion}
Page1Form {
button1.onClicked: {
console.log("Button 1 clicked.");
}
button2.onClicked: {
console.log("Button 2 clicked.");
}
}

View File

@@ -0,0 +1,22 @@
import QtQuick %{QtQuickVersion}
import Qt.labs.controls %{QtLabsControlsVersion}
import QtQuick.Layouts %{QtQuickLayoutsVersion}
Item {
property alias button1: button1
property alias button2: button2
RowLayout {
anchors.centerIn: parent
Button {
id: button1
text: qsTr("Press Me 1")
}
Button {
id: button2
text: qsTr("Press Me 2")
}
}
}

View File

@@ -0,0 +1,13 @@
QT += qml quick
CONFIG += c++11
SOURCES += %{MainCppFileName}
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Default rules for deployment.
include(deployment.pri)

View File

@@ -0,0 +1,12 @@
%{Cpp:LicenseTemplate}\
%{JS: QtSupport.qtIncludes([], ["QtGui/QGuiApplication", "QtQml/QQmlApplicationEngine"])}
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QLatin1String("qrc:/main.qml")));
return app.exec();
}

View File

@@ -0,0 +1,37 @@
import QtQuick %{QtQuickVersion}
import QtQuick.Layouts %{QtQuickLayoutsVersion}
import Qt.labs.controls %{QtLabsControlsVersion}
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
SwipeView {
id: swipeView
anchors.fill: parent
currentIndex: tabBar.currentIndex
Page1 {
}
Page {
Label {
text: qsTr("Second page")
anchors.centerIn: parent
}
}
}
footer: TabBar {
id: tabBar
currentIndex: swipeView.currentIndex
TabButton {
text: qsTr("First")
}
TabButton {
text: qsTr("Second")
}
}
}

View File

@@ -0,0 +1,7 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>Page1.qml</file>
<file>Page1Form.ui.qml</file>
</qresource>
</RCC>

View File

@@ -0,0 +1,86 @@
{
"version": 1,
"supportedProjectTypes": [ "Qt4ProjectManager.Qt4Project" ],
"id": "W.QtLabsControlsApplication",
"category": "F.Application",
"trDescription": "Creates a deployable Qt Quick 2 application using Qt Labs Controls.",
"trDisplayName": "Qt Labs Controls Application",
"trDisplayCategory": "Application",
"icon": "../qtquickapplication/qml_wizard.png",
"featuresRequired": [ "QtSupport.Wizards.FeatureQt.labs.controls.1.0" ],
"enabled": "%{JS: [ %{Plugins} ].indexOf('QmakeProjectManager') >= 0}",
"options":
[
{ "key": "ProFileName", "value": "%{JS: Util.fileName('%{ProjectDirectory}/%{ProjectName}', 'pro')}" },
{ "key": "MainCppFileName", "value": "%{JS: 'main.' + Util.preferredSuffix('text/x-c++src')}" },
{ "key": "QtQuickVersion", "value": "2.6" },
{ "key": "QtLabsControlsVersion", "value": "1.0" },
{ "key": "QtQuickDialogsVersion", "value": "1.0" },
{ "key": "QtQuickLayoutsVersion", "value": "1.0" }
],
"pages":
[
{
"trDisplayName": "Project Location",
"trShortTitle": "Location",
"typeId": "Project"
},
{
"trDisplayName": "Kit Selection",
"trShortTitle": "Kits",
"typeId": "Kits",
"enabled": "%{IsTopLevelProject}",
"data": { "projectFilePath": "%{ProFileName}" }
},
{
"trDisplayName": "Project Management",
"trShortTitle": "Summary",
"typeId": "Summary"
}
],
"generators":
[
{
"typeId": "File",
"data":
[
{
"source": "app.pro",
"target": "%{ProFileName}",
"openAsProject": true
},
{
"source": "main.cpp",
"target": "%{MainCppFileName}"
},
{
"source": "main.qml.tpl",
"target": "main.qml",
"openInEditor": true
},
{
"source": "Page1.qml.tpl",
"target": "Page1.qml"
},
{
"source": "Page1Form.ui.qml.tpl",
"target": "Page1Form.ui.qml"
},
{
"source": "qml.qrc"
},
{
"source": "../../../../shared/qrcdeployment.pri",
"target": "%{ProjectDirectory}/deployment.pri"
},
{
"source": "../../git.ignore",
"target": "%{ProjectDirectory}/.gitignore",
"condition": "%{JS: !%{IsSubproject} && '%{VersionControl}' === 'G.Git'}"
}
]
}
]
}

View File

@@ -0,0 +1,184 @@
[General]
ThemeName=Dark Frame
PreferredStyles=Fusion
[Palette]
shadowBackground=ff404244
text=ff000000
textDisabled=55000000
toolBarItem=b6fbfdff
toolBarItemDisabled=38fbfdff
hoverBackground=ff515151
selectedBackground=ff151515
normalBackground=ffffffff
alternateBackground=ff515151
error=ffe41e25
[Colors]
BackgroundColorAlternate=alternateBackground
BackgroundColorDark=shadowBackground
BackgroundColorHover=hoverBackground
BackgroundColorNormal=normalBackground
BackgroundColorDisabled=ff444444
BackgroundColorSelected=ff909090
BadgeLabelBackgroundColorChecked=normalBackground
BadgeLabelBackgroundColorUnchecked=selectedBackground
BadgeLabelTextColorChecked=text
BadgeLabelTextColorUnchecked=text
CanceledSearchTextColor=ff0000
ComboBoxArrowColor=toolBarItem
ComboBoxArrowColorDisabled=toolBarItemDisabled
ComboBoxTextColor=toolBarItem
DetailsButtonBackgroundColorHover=hoverBackground
DetailsWidgetBackgroundColor=ff4a4a4a
DockWidgetResizeHandleColor=shadowBackground
DoubleTabWidget1stEmptyAreaBackgroundColor=normalBackground
DoubleTabWidget1stSeparatorColor=hoverBackground
DoubleTabWidget1stTabActiveTextColor=text
DoubleTabWidget1stTabBackgroundColor=ff4a4a4a
DoubleTabWidget1stTabInactiveTextColor=textDisabled
DoubleTabWidget2ndSeparatorColor=hoverBackground
DoubleTabWidget2ndTabActiveTextColor=text
DoubleTabWidget2ndTabBackgroundColor=ff434343
DoubleTabWidget2ndTabInactiveTextColor=textDisabled
EditorPlaceholderColor=normalBackground
FancyTabBarBackgroundColor=shadowBackground
FancyTabWidgetDisabledSelectedTextColor=toolBarItemDisabled
FancyTabWidgetDisabledUnselectedTextColor=toolBarItemDisabled
FancyTabWidgetEnabledSelectedTextColor=toolBarItem
FancyTabWidgetEnabledUnselectedTextColor=toolBarItem
FancyToolButtonHoverColor=35ffffff
FancyToolButtonSelectedColor=66000000
FutureProgressBackgroundColor=shadowBackground
IconsBaseColor=toolBarItem
IconsDisabledColor=toolBarItemDisabled
IconsInfoColor=ff3099dc
IconsInfoToolBarColor=ff71b2db
IconsWarningColor=ffecbc1c
IconsWarningToolBarColor=fff2d76e
IconsErrorColor=ffdf4f4f
IconsErrorToolBarColor=ffdb6f71
IconsRunColor=dda4d576
IconsStopColor=dddb6f71
IconsDebugColor=toolBarItem
IconsInterruptColor=dd7488db
IconsNavigationArrowsColor=ffebc322
IconsBuildHammerHandleColor=dddd7710
IconsBuildHammerHeadColor=dd989898
IconsModeWelcomeActiveColor=ff80c342
IconsModeEditActiveColor=ff99aaef
IconsModeDesignActiveColor=ffbb6000
IconsModeDebugActiveColor=ff99aaef
IconsModeProjetcsActiveColor=ff80c342
IconsModeAnalyzeActiveColor=ff43adee
IconsModeHelpActiveColor=fff4be04
InfoBarBackground=ff505000
InfoBarText=text
MenuBarEmptyAreaBackgroundColor=shadowBackground
MenuBarItemBackgroundColor=shadowBackground
MenuBarItemTextColorDisabled=toolBarItemDisabled
MenuBarItemTextColorNormal=toolBarItem
MenuItemTextColorDisabled=textDisabled
MenuItemTextColorNormal=text
MiniProjectTargetSelectorBackgroundColor=shadowBackground
MiniProjectTargetSelectorBorderColor=shadowBackground
MiniProjectTargetSelectorSummaryBackgroundColor=shadowBackground
MiniProjectTargetSelectorTextColor=text
PanelButtonToolBackgroundColorHover=hoverBackground
PanelStatusBarBackgroundColor=shadowBackground
PanelsWidgetSeparatorLineColor=0
PanelTextColorDark=toolBarItem
PanelTextColorMid=ff666666
PanelTextColorLight=toolBarItem
ProgressBarColorError=error
ProgressBarColorFinished=ff5aaa3c
ProgressBarColorNormal=hoverBackground
ProgressBarTitleColor=toolBarItem
SplitterColor=ff000000
TextColorDisabled=textDisabled
TextColorError=ffff4040
TextColorHighlight=ffff0000
TextColorLink=ff007af4
TextColorLinkVisited=ffa57aff
TextColorNormal=text
TodoItemTextColor=text
ToggleButtonBackgroundColor=shadowBackground
ToolBarBackgroundColor=shadowBackground
TreeViewArrowColorNormal=hoverBackground
TreeViewArrowColorSelected=text
OutputPanes_DebugTextColor=text
OutputPanes_ErrorMessageTextColor=ffff6c6c
OutputPanes_MessageOutput=ff008787
OutputPanes_NormalMessageTextColor=text
OutputPanes_StdErrTextColor=ffff6666
OutputPanes_StdOutTextColor=text
OutputPanes_WarningMessageTextColor=fff3c300
OutputPaneButtonFlashColor=error
OutputPaneToggleButtonTextColorChecked=toolBarItem
OutputPaneToggleButtonTextColorUnchecked=toolBarItem
Debugger_LogWindow_LogInput=ff00acac
Debugger_LogWindow_LogStatus=ff00875a
Debugger_LogWindow_LogTime=ffbf0303
Debugger_WatchItem_ValueNormal=text
Debugger_WatchItem_ValueInvalid=textDisabled
Debugger_WatchItem_ValueChanged=ffbf0303
Debugger_Breakpoint_TextMarkColor=ffff4040
Welcome_BackgroundColorNormal=normalBackground
Welcome_Button_BorderColorNormal=ff727476
Welcome_Button_BorderColorPressed=ff727476
Welcome_Button_TextColorNormal=text
Welcome_Button_TextColorPressed=text
Welcome_Caption_TextColorNormal=text
Welcome_DividerColor=ffd6d6d6
Welcome_Link_BackgroundColor=normalBackground
Welcome_Link_TextColorActive=text
Welcome_Link_TextColorNormal=text
Welcome_ProjectItem_BackgroundColorHover=ffd2d4d6
Welcome_ProjectItem_TextColorFilepath=textDisabled
Welcome_SessionItemExpanded_BackgroundColorHover=hoverBackground
Welcome_SessionItemExpanded_BackgroundColorNormal=selectedBackground
Welcome_SessionItem_BackgroundColorHover=hoverBackground
Welcome_SessionItem_BackgroundColorNormal=normalBackground
Welcome_SideBar_BackgroundColor=normalBackground
Welcome_TextColorHeading=text
Welcome_TextColorNormal=text
VcsBase_FileStatusUnknown_TextColor=text
VcsBase_FileAdded_TextColor=ff00ff00
VcsBase_FileModified_TextColor=ff8ee0ff
VcsBase_FileDeleted_TextColor=fffff6c6c
VcsBase_FileRenamed_TextColor=ffffa500
Bookmarks_TextMarkColor=ff8080ff
TextEditor_SearchResult_ScrollBarColor=ff00c000
TextEditor_CurrentLine_ScrollBarColor=ffffffff
ProjectExplorer_TaskError_TextMarkColor=ffff4040
ProjectExplorer_TaskWarn_TextMarkColor=ffffff40
ClangCodeModel_Error_TextMarkColor=ffff882f
ClangCodeModel_Warning_TextMarkColor=ffceff40
[Flags]
ComboBoxDrawTextShadow=false
DerivePaletteFromTheme=false
DrawIndicatorBranch=true
DrawProgressBarSunken=false
DrawSearchResultWidgetFrame=false
DrawTargetSelectorBottom=false
ApplyThemePaletteGlobally=false
FlatSideBarIcons=true
[Gradients]
DetailsWidgetHeaderGradient\1\color=0
DetailsWidgetHeaderGradient\1\pos=1
DetailsWidgetHeaderGradient\size=1
[Style]
WidgetStyle=StyleFlat

View File

@@ -29,6 +29,8 @@ SOURCES += \
clanghighlightingmarksreporter.cpp \ clanghighlightingmarksreporter.cpp \
clangmodelmanagersupport.cpp \ clangmodelmanagersupport.cpp \
clangpreprocessorassistproposalitem.cpp \ clangpreprocessorassistproposalitem.cpp \
clangprojectsettings.cpp \
clangprojectsettingswidget.cpp \
clangtextmark.cpp \ clangtextmark.cpp \
clangutils.cpp clangutils.cpp
@@ -58,9 +60,13 @@ HEADERS += \
clangisdiagnosticrelatedtolocation.h \ clangisdiagnosticrelatedtolocation.h \
clangmodelmanagersupport.h \ clangmodelmanagersupport.h \
clangpreprocessorassistproposalitem.h \ clangpreprocessorassistproposalitem.h \
clangprojectsettings.h \
clangprojectsettingswidget.h \
clangtextmark.h \ clangtextmark.h \
clangutils.h clangutils.h
FORMS += clangprojectsettingswidget.ui
RESOURCES += \ RESOURCES += \
clangcodemodel.qrc clangcodemodel.qrc

View File

@@ -84,6 +84,11 @@ QtcPlugin {
"clangmodelmanagersupport.h", "clangmodelmanagersupport.h",
"clangpreprocessorassistproposalitem.cpp", "clangpreprocessorassistproposalitem.cpp",
"clangpreprocessorassistproposalitem.h", "clangpreprocessorassistproposalitem.h",
"clangprojectsettings.cpp",
"clangprojectsettings.h",
"clangprojectsettingswidget.cpp",
"clangprojectsettingswidget.h",
"clangprojectsettingswidget.ui",
"clangtextmark.cpp", "clangtextmark.cpp",
"clangtextmark.h", "clangtextmark.h",
"clangutils.cpp", "clangutils.cpp",

View File

@@ -26,6 +26,7 @@
#include "clangcodemodelplugin.h" #include "clangcodemodelplugin.h"
#include "clangconstants.h" #include "clangconstants.h"
#include "clangprojectsettingswidget.h"
#ifdef WITH_TESTS #ifdef WITH_TESTS
# include "test/clangcodecompletion_test.h" # include "test/clangcodecompletion_test.h"
@@ -33,6 +34,10 @@
#include <cpptools/cppmodelmanager.h> #include <cpptools/cppmodelmanager.h>
#include <projectexplorer/projectpanelfactory.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/session.h>
#include <texteditor/textmark.h> #include <texteditor/textmark.h>
namespace ClangCodeModel { namespace ClangCodeModel {
@@ -48,6 +53,15 @@ void initializeTextMarks()
Utils::Theme::ClangCodeModel_Error_TextMarkColor); Utils::Theme::ClangCodeModel_Error_TextMarkColor);
} }
void addProjectPanelWidget()
{
auto panelFactory = new ProjectExplorer::ProjectPanelFactory();
panelFactory->setPriority(60);
panelFactory->setDisplayName(ClangProjectSettingsWidget::tr("Clang Code Model"));
panelFactory->setSimpleCreateWidgetFunction<ClangProjectSettingsWidget>(QIcon());
ProjectExplorer::ProjectPanelFactory::registerFactory(panelFactory);
}
} // anonymous namespace } // anonymous namespace
bool ClangCodeModelPlugin::initialize(const QStringList &arguments, QString *errorMessage) bool ClangCodeModelPlugin::initialize(const QStringList &arguments, QString *errorMessage)
@@ -58,6 +72,7 @@ bool ClangCodeModelPlugin::initialize(const QStringList &arguments, QString *err
CppTools::CppModelManager::instance()->activateClangCodeModel(&m_modelManagerSupportProvider); CppTools::CppModelManager::instance()->activateClangCodeModel(&m_modelManagerSupportProvider);
initializeTextMarks(); initializeTextMarks();
addProjectPanelWidget();
return true; return true;
} }

View File

@@ -30,11 +30,14 @@
#include "clangfixitoperation.h" #include "clangfixitoperation.h"
#include "clangfixitoperationsextractor.h" #include "clangfixitoperationsextractor.h"
#include "clanghighlightingmarksreporter.h" #include "clanghighlightingmarksreporter.h"
#include "clangprojectsettings.h"
#include "clangutils.h" #include "clangutils.h"
#include <diagnosticcontainer.h> #include <diagnosticcontainer.h>
#include <sourcelocationcontainer.h> #include <sourcelocationcontainer.h>
#include <cpptools/clangdiagnosticconfigsmodel.h>
#include <cpptools/clangdiagnosticconfigsmodel.h>
#include <cpptools/compileroptionsbuilder.h> #include <cpptools/compileroptionsbuilder.h>
#include <cpptools/cppcodemodelsettings.h> #include <cpptools/cppcodemodelsettings.h>
#include <cpptools/cppmodelmanager.h> #include <cpptools/cppmodelmanager.h>
@@ -340,10 +343,25 @@ static QStringList languageOptions(const QString &filePath, CppTools::ProjectPar
return builder.options(); return builder.options();
} }
static QStringList warningOptions(CppTools::ProjectPart *projectPart)
{
if (projectPart && projectPart->project) {
ClangProjectSettings projectSettings(projectPart->project);
if (!projectSettings.useGlobalWarningConfig()) {
const Core::Id warningConfigId = projectSettings.warningConfigId();
const CppTools::ClangDiagnosticConfigsModel configsModel(
CppTools::codeModelSettings()->clangCustomDiagnosticConfigs());
if (configsModel.hasConfigWithId(warningConfigId))
return configsModel.configWithId(warningConfigId).commandLineOptions();
}
}
return CppTools::codeModelSettings()->clangDiagnosticConfig().commandLineOptions();
}
static QStringList fileArguments(const QString &filePath, CppTools::ProjectPart *projectPart) static QStringList fileArguments(const QString &filePath, CppTools::ProjectPart *projectPart)
{ {
return QStringList(languageOptions(filePath, projectPart)) return languageOptions(filePath, projectPart) + warningOptions(projectPart);
+ CppTools::codeModelSettings()->extraClangOptions();
} }
ClangBackEnd::FileContainer ClangBackEnd::FileContainer

View File

@@ -0,0 +1,91 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "clangprojectsettings.h"
namespace ClangCodeModel {
namespace Internal {
static QString useGlobalWarningConfigKey()
{ return QStringLiteral("ClangCodeModel.UseGlobalWarningConfig"); }
static QString warningConfigIdKey()
{ return QStringLiteral("ClangCodeModel.WarningConfigId"); }
ClangProjectSettings::ClangProjectSettings(ProjectExplorer::Project *project)
: m_project(project)
{
load();
connect(project, &ProjectExplorer::Project::settingsLoaded,
this, &ClangProjectSettings::load);
connect(project, &ProjectExplorer::Project::aboutToSaveSettings,
this, &ClangProjectSettings::store);
}
Core::Id ClangProjectSettings::warningConfigId() const
{
return m_warningConfigId;
}
void ClangProjectSettings::setWarningConfigId(const Core::Id &customConfigId)
{
m_warningConfigId = customConfigId;
}
bool ClangProjectSettings::useGlobalWarningConfig() const
{
return m_useGlobalWarningConfig;
}
void ClangProjectSettings::setUseGlobalWarningConfig(bool useGlobalWarningConfig)
{
m_useGlobalWarningConfig = useGlobalWarningConfig;
}
void ClangProjectSettings::load()
{
const QVariant useGlobalConfigVariant = m_project->namedSettings(useGlobalWarningConfigKey());
const bool useGlobalConfig = useGlobalConfigVariant.isValid()
? useGlobalConfigVariant.toBool()
: true;
setUseGlobalWarningConfig(useGlobalConfig);
setWarningConfigId(Core::Id::fromSetting(m_project->namedSettings(warningConfigIdKey())));
}
void ClangProjectSettings::store()
{
m_project->setNamedSettings(useGlobalWarningConfigKey(), useGlobalWarningConfig());
m_project->setNamedSettings(warningConfigIdKey(), warningConfigId().toSetting());
}
} // namespace Internal
} // namespace ClangCodeModel

View File

@@ -0,0 +1,66 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#pragma once
#include <coreplugin/id.h>
#include <projectexplorer/project.h>
#include <QObject>
#include <QString>
namespace ClangCodeModel {
namespace Internal {
class ClangProjectSettings: public QObject
{
Q_OBJECT
public:
ClangProjectSettings(ProjectExplorer::Project *project);
bool useGlobalWarningConfig() const;
void setUseGlobalWarningConfig(bool useGlobalWarningConfig);
Core::Id warningConfigId() const;
void setWarningConfigId(const Core::Id &warningConfigId);
public slots:
void load();
void store();
private:
ProjectExplorer::Project *m_project;
bool m_useGlobalWarningConfig = true;
Core::Id m_warningConfigId;
};
} // namespace Internal
} // namespace ClangCodeModel

View File

@@ -0,0 +1,160 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "clangprojectsettingswidget.h"
#include "clangprojectsettings.h"
#include <coreplugin/icore.h>
#include <cpptools/clangdiagnosticconfig.h>
#include <cpptools/clangdiagnosticconfigswidget.h>
#include <cpptools/cppcodemodelsettings.h>
#include <cpptools/cpptoolsreuse.h>
static const char GLOBAL_PROXY_CONFIG_ID[] = "globalProxyConfig";
namespace ClangCodeModel {
namespace Internal {
static CppTools::ClangDiagnosticConfig
createConfigRepresentingGlobalSetting(const CppTools::ClangDiagnosticConfig &baseConfig)
{
CppTools::ClangDiagnosticConfig config = baseConfig;
config.setId(GLOBAL_PROXY_CONFIG_ID);
QString displayName = config.displayName();
if (config.isReadOnly())
displayName = CppTools::ClangDiagnosticConfigsModel::displayNameWithBuiltinIndication(config);
displayName = ClangProjectSettingsWidget::tr("Global setting (%1)").arg(displayName);
config.setDisplayName(displayName);
config.setIsReadOnly(true);
return config;
}
static Core::Id globalConfigId(const CppTools::CppCodeModelSettings &settings,
const CppTools::ClangDiagnosticConfigsModel &model)
{
const Core::Id configId = settings.clangDiagnosticConfigId();
if (model.hasConfigWithId(configId))
return configId;
return model.at(0).id(); // Config saved in the settings was removed, fallback to first.
}
static CppTools::ClangDiagnosticConfigsModel
createConfigsModelWithGlobalProxyConfig(const CppTools::CppCodeModelSettings &settings)
{
using namespace CppTools;
ClangDiagnosticConfigsModel configsModel(settings.clangCustomDiagnosticConfigs());
const Core::Id globalId = globalConfigId(settings, configsModel);
const ClangDiagnosticConfig globalConfig = configsModel.configWithId(globalId);
const ClangDiagnosticConfig globalProxy
= createConfigRepresentingGlobalSetting(globalConfig);
configsModel.prepend(globalProxy);
return configsModel;
}
static Core::Id configIdForProject(const ClangProjectSettings &projectSettings)
{
return projectSettings.useGlobalWarningConfig()
? Core::Id(GLOBAL_PROXY_CONFIG_ID)
: projectSettings.warningConfigId();
}
ClangProjectSettingsWidget::ClangProjectSettingsWidget(ProjectExplorer::Project *project)
: m_projectSettings(project)
{
m_ui.setupUi(this);
using namespace CppTools;
m_diagnosticConfigWidget = new ClangDiagnosticConfigsWidget;
m_diagnosticConfigWidget->setConfigWithUndecoratedDisplayName(Core::Id(GLOBAL_PROXY_CONFIG_ID));
refreshDiagnosticConfigsWidgetFromSettings();
connectToCppCodeModelSettingsChanged();
connect(m_diagnosticConfigWidget.data(), &ClangDiagnosticConfigsWidget::currentConfigChanged,
this, &ClangProjectSettingsWidget::onCurrentWarningConfigChanged);
connect(m_diagnosticConfigWidget.data(), &ClangDiagnosticConfigsWidget::customConfigsChanged,
this, &ClangProjectSettingsWidget::onCustomWarningConfigsChanged);
m_ui.diagnosticConfigurationGroupBox->layout()->addWidget(m_diagnosticConfigWidget);
}
void ClangProjectSettingsWidget::onCurrentWarningConfigChanged(const Core::Id &currentConfigId)
{
const bool useGlobalConfig = currentConfigId == Core::Id(GLOBAL_PROXY_CONFIG_ID);
m_projectSettings.setUseGlobalWarningConfig(useGlobalConfig);
m_projectSettings.setWarningConfigId(currentConfigId);
m_projectSettings.store();
}
void ClangProjectSettingsWidget::onCustomWarningConfigsChanged(
const CppTools::ClangDiagnosticConfigs &customConfigs)
{
disconnectFromCppCodeModelSettingsChanged();
const QSharedPointer<CppTools::CppCodeModelSettings> codeModelSettings
= CppTools::codeModelSettings();
codeModelSettings->setClangCustomDiagnosticConfigs(customConfigs);
codeModelSettings->toSettings(Core::ICore::settings());
connectToCppCodeModelSettingsChanged();
}
void ClangProjectSettingsWidget::refreshDiagnosticConfigsWidgetFromSettings()
{
m_diagnosticConfigWidget->refresh(
createConfigsModelWithGlobalProxyConfig(*CppTools::codeModelSettings()),
configIdForProject(m_projectSettings));
}
void ClangProjectSettingsWidget::connectToCppCodeModelSettingsChanged()
{
connect(CppTools::codeModelSettings().data(), &CppTools::CppCodeModelSettings::changed,
this, &ClangProjectSettingsWidget::refreshDiagnosticConfigsWidgetFromSettings);
}
void ClangProjectSettingsWidget::disconnectFromCppCodeModelSettingsChanged()
{
disconnect(CppTools::codeModelSettings().data(), &CppTools::CppCodeModelSettings::changed,
this, &ClangProjectSettingsWidget::refreshDiagnosticConfigsWidgetFromSettings);
}
} // namespace Internal
} // namespace ClangCodeModel

View File

@@ -0,0 +1,70 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#pragma once
#include "ui_clangprojectsettingswidget.h"
#include "clangprojectsettings.h"
#include <cpptools/clangdiagnosticconfigsmodel.h>
#include <QPointer>
namespace ProjectExplorer { class Project; }
namespace CppTools { class ClangDiagnosticConfigsWidget; }
namespace ClangCodeModel {
namespace Internal {
class ClangProjectSettingsWidget: public QWidget
{
Q_OBJECT
public:
explicit ClangProjectSettingsWidget(ProjectExplorer::Project *project);
private slots:
void onCurrentWarningConfigChanged(const Core::Id &currentConfigId);
void onCustomWarningConfigsChanged(const CppTools::ClangDiagnosticConfigs &customConfigs);
private:
void refreshDiagnosticConfigsWidgetFromSettings();
void connectToCppCodeModelSettingsChanged();
void disconnectFromCppCodeModelSettingsChanged();
private:
Ui::ClangProjectSettingsWidget m_ui;
ClangProjectSettings m_projectSettings;
QPointer<CppTools::ClangDiagnosticConfigsWidget> m_diagnosticConfigWidget;
};
} // namespace Internal
} // namespace ClangCodeModel

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ClangCodeModel::Internal::ClangProjectSettingsWidget</class>
<widget class="QWidget" name="ClangCodeModel::Internal::ClangProjectSettingsWidget">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>814</width>
<height>330</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="diagnosticConfigurationGroupBox">
<property name="title">
<string>Warnings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2"/>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -130,9 +130,16 @@ public:
StyleAnimator animator; StyleAnimator animator;
}; };
QString lineEditImageFileName(const QString &pngFileName)
{
return Utils::creatorTheme()->widgetStyle() == Utils::Theme::StyleDefault
? StyleHelper::dpiSpecificImageFile(pngFileName)
: QString();
}
ManhattanStylePrivate::ManhattanStylePrivate() : ManhattanStylePrivate::ManhattanStylePrivate() :
lineeditImage(StyleHelper::dpiSpecificImageFile(QStringLiteral(":/core/images/inputfield.png"))), lineeditImage(lineEditImageFileName(QLatin1String(":/core/images/inputfield.png"))),
lineeditImage_disabled(StyleHelper::dpiSpecificImageFile(QStringLiteral(":/core/images/inputfield_disabled.png"))), lineeditImage_disabled(lineEditImageFileName(QLatin1String(":/core/images/inputfield_disabled.png"))),
extButtonPixmap(Core::Icons::TOOLBAR_EXTENSION.pixmap()), extButtonPixmap(Core::Icons::TOOLBAR_EXTENSION.pixmap()),
closeButtonPixmap(Core::Icons::CLOSE_FOREGROUND.pixmap()) closeButtonPixmap(Core::Icons::CLOSE_FOREGROUND.pixmap())
{ {
@@ -451,24 +458,25 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
painter->save(); painter->save();
// Fill the line edit background // Fill the line edit background
QRect filledRect = option->rect.adjusted(1, 1, -1, -1); QRectF backgroundRect = option->rect;
painter->setBrushOrigin(filledRect.topLeft()); if (Utils::creatorTheme()->widgetStyle() == Utils::Theme::StyleDefault) {
painter->fillRect(filledRect, option->palette.base()); backgroundRect.adjust(1, 1, -1, -1);
painter->setBrushOrigin(backgroundRect.topLeft());
painter->fillRect(backgroundRect, option->palette.base());
if (option->state & State_Enabled) const bool enabled = option->state & State_Enabled;
StyleHelper::drawCornerImage(d->lineeditImage, painter, option->rect, 5, 5, 5, 5); StyleHelper::drawCornerImage(enabled ? d->lineeditImage : d->lineeditImage_disabled,
else painter, option->rect, 5, 5, 5, 5);
StyleHelper::drawCornerImage(d->lineeditImage_disabled, painter, option->rect, 5, 5, 5, 5); } else {
painter->fillRect(backgroundRect, option->palette.base());
}
if (option->state & State_HasFocus || option->state & State_MouseOver) { const bool hasFocus = state & State_HasFocus;
if (hasFocus || state & State_MouseOver) {
QColor hover = StyleHelper::baseColor(); QColor hover = StyleHelper::baseColor();
if (state & State_HasFocus) hover.setAlpha(hasFocus ? 100 : 50);
hover.setAlpha(100); painter->setPen(QPen(hover, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
else painter->drawRect(backgroundRect.adjusted(0.5, 0.5, -0.5, -0.5));
hover.setAlpha(50);
painter->setPen(QPen(hover, 1));
painter->drawRect(QRectF(option->rect).adjusted(1.5, 1.5, -1.5, -1.5));
} }
painter->restore(); painter->restore();
} }

View File

@@ -0,0 +1,78 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "clangdiagnosticconfig.h"
namespace CppTools {
Core::Id ClangDiagnosticConfig::id() const
{
return m_id;
}
void ClangDiagnosticConfig::setId(const Core::Id &id)
{
m_id = id;
}
QString ClangDiagnosticConfig::displayName() const
{
return m_displayName;
}
void ClangDiagnosticConfig::setDisplayName(const QString &displayName)
{
m_displayName = displayName;
}
QStringList ClangDiagnosticConfig::commandLineOptions() const
{
return m_commandLineOptions;
}
void ClangDiagnosticConfig::setCommandLineOptions(const QStringList &options)
{
m_commandLineOptions = options;
}
bool ClangDiagnosticConfig::isReadOnly() const
{
return m_isReadOnly;
}
void ClangDiagnosticConfig::setIsReadOnly(bool isReadOnly)
{
m_isReadOnly = isReadOnly;
}
bool ClangDiagnosticConfig::operator==(const ClangDiagnosticConfig &other) const
{
return m_id == other.m_id
&& m_displayName == other.m_displayName
&& m_commandLineOptions == other.m_commandLineOptions
&& m_isReadOnly == other.m_isReadOnly;
}
} // namespace CppTools

View File

@@ -0,0 +1,63 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "cpptools_global.h"
#include <coreplugin/id.h>
#include <QStringList>
#include <QVector>
namespace CppTools {
class CPPTOOLS_EXPORT ClangDiagnosticConfig
{
public:
Core::Id id() const;
void setId(const Core::Id &id);
QString displayName() const;
void setDisplayName(const QString &displayName);
QStringList commandLineOptions() const;
void setCommandLineOptions(const QStringList &commandLineOptions);
bool isReadOnly() const;
void setIsReadOnly(bool isReadOnly);
bool operator==(const ClangDiagnosticConfig &other) const;
private:
Core::Id m_id;
QString m_displayName;
QStringList m_commandLineOptions;
bool m_isReadOnly = false;
};
using ClangDiagnosticConfigs = QVector<ClangDiagnosticConfig>;
} // namespace CppTools

View File

@@ -0,0 +1,163 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "clangdiagnosticconfigsmodel.h"
#include "cpptoolsconstants.h"
#include <utils/algorithm.h>
#include <QCoreApplication>
namespace CppTools {
static void addConfigForQuestionableConstructs(ClangDiagnosticConfigsModel &model)
{
ClangDiagnosticConfig config;
config.setId("Builtin.Questionable");
config.setDisplayName(QCoreApplication::translate("ClangDiagnosticConfigsModel",
"Warnings for questionable constructs"));
config.setIsReadOnly(true);
config.setCommandLineOptions({
QStringLiteral("-Wall"),
QStringLiteral("-Wextra"),
});
model.appendOrUpdate(config);
}
static void addConfigForPedanticWarnings(ClangDiagnosticConfigsModel &model)
{
ClangDiagnosticConfig config;
config.setId("Builtin.Pedantic");
config.setDisplayName(QCoreApplication::translate("ClangDiagnosticConfigsModel",
"Pedantic Warnings"));
config.setIsReadOnly(true);
config.setCommandLineOptions({QStringLiteral("-Wpedantic")});
model.appendOrUpdate(config);
}
static void addConfigForAlmostEveryWarning(ClangDiagnosticConfigsModel &model)
{
ClangDiagnosticConfig config;
config.setId(Constants::CPP_CLANG_BUILTIN_CONFIG_ID_EVERYTHING_WITH_EXCEPTIONS);
config.setDisplayName(QCoreApplication::translate("ClangDiagnosticConfigsModel",
"Warnings for almost everything"));
config.setIsReadOnly(true);
config.setCommandLineOptions({
QStringLiteral("-Weverything"),
QStringLiteral("-Wno-c++98-compat"),
QStringLiteral("-Wno-c++98-compat-pedantic"),
QStringLiteral("-Wno-unused-macros"),
QStringLiteral("-Wno-newline-eof"),
QStringLiteral("-Wno-exit-time-destructors"),
QStringLiteral("-Wno-global-constructors"),
QStringLiteral("-Wno-gnu-zero-variadic-macro-arguments"),
QStringLiteral("-Wno-documentation"),
QStringLiteral("-Wno-shadow"),
QStringLiteral("-Wno-missing-prototypes"), // Not optimal for C projects.
});
model.appendOrUpdate(config);
}
static void addBuiltinConfigs(ClangDiagnosticConfigsModel &model)
{
addConfigForPedanticWarnings(model);
addConfigForQuestionableConstructs(model);
addConfigForAlmostEveryWarning(model);
}
ClangDiagnosticConfigsModel::ClangDiagnosticConfigsModel(const ClangDiagnosticConfigs &customConfigs)
{
addBuiltinConfigs(*this);
foreach (const ClangDiagnosticConfig &config, customConfigs)
m_diagnosticConfigs.append(config);
}
int ClangDiagnosticConfigsModel::size() const
{
return m_diagnosticConfigs.size();
}
const ClangDiagnosticConfig &ClangDiagnosticConfigsModel::at(int index) const
{
return m_diagnosticConfigs.at(index);
}
void ClangDiagnosticConfigsModel::prepend(const ClangDiagnosticConfig &config)
{
m_diagnosticConfigs.prepend(config);
}
void ClangDiagnosticConfigsModel::appendOrUpdate(const ClangDiagnosticConfig &config)
{
const int index = indexOfConfig(config.id());
if (index >= 0 && index < m_diagnosticConfigs.size())
m_diagnosticConfigs.replace(index, config);
else
m_diagnosticConfigs.append(config);
}
void ClangDiagnosticConfigsModel::removeConfigWithId(const Core::Id &id)
{
m_diagnosticConfigs.removeOne(configWithId(id));
}
ClangDiagnosticConfigs ClangDiagnosticConfigsModel::configs() const
{
return m_diagnosticConfigs;
}
bool ClangDiagnosticConfigsModel::hasConfigWithId(const Core::Id &id) const
{
return indexOfConfig(id) != -1;
}
const ClangDiagnosticConfig &ClangDiagnosticConfigsModel::configWithId(const Core::Id &id) const
{
return m_diagnosticConfigs.at(indexOfConfig(id));
}
QString
ClangDiagnosticConfigsModel::displayNameWithBuiltinIndication(const ClangDiagnosticConfig &config)
{
return config.isReadOnly()
? QCoreApplication::translate("ClangDiagnosticConfigsModel", "%1 [built-in]")
.arg(config.displayName())
: config.displayName();
}
int ClangDiagnosticConfigsModel::indexOfConfig(const Core::Id &id) const
{
return Utils::indexOf(m_diagnosticConfigs, [&](const ClangDiagnosticConfig &config) {
return config.id() == id;
});
}
} // namespace CppTools

View File

@@ -0,0 +1,60 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "cpptools_global.h"
#include "clangdiagnosticconfig.h"
namespace CppTools {
class CPPTOOLS_EXPORT ClangDiagnosticConfigsModel
{
public:
ClangDiagnosticConfigsModel() = default;
ClangDiagnosticConfigsModel(const ClangDiagnosticConfigs &customConfigs);
int size() const;
const ClangDiagnosticConfig &at(int index) const;
void prepend(const ClangDiagnosticConfig &config);
void appendOrUpdate(const ClangDiagnosticConfig &config);
void removeConfigWithId(const Core::Id &id);
ClangDiagnosticConfigs configs() const;
bool hasConfigWithId(const Core::Id &id) const;
const ClangDiagnosticConfig &configWithId(const Core::Id &id) const;
static QString displayNameWithBuiltinIndication(const ClangDiagnosticConfig &config);
private:
int indexOfConfig(const Core::Id &id) const;
private:
ClangDiagnosticConfigs m_diagnosticConfigs;
};
} // namespace CppTools

View File

@@ -0,0 +1,256 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "clangdiagnosticconfigswidget.h"
#include "ui_clangdiagnosticconfigswidget.h"
#include <utils/algorithm.h>
#include <utils/qtcassert.h>
#include <QDebug>
#include <QInputDialog>
#include <QUuid>
namespace CppTools {
ClangDiagnosticConfigsWidget::ClangDiagnosticConfigsWidget(
const ClangDiagnosticConfigsModel &diagnosticConfigsModel,
const Core::Id &configToSelect,
QWidget *parent)
: QWidget(parent)
, m_ui(new Ui::ClangDiagnosticConfigsWidget)
, m_diagnosticConfigsModel(diagnosticConfigsModel)
{
m_ui->setupUi(this);
connectConfigChooserCurrentIndex();
connect(m_ui->copyButton, &QPushButton::clicked,
this, &ClangDiagnosticConfigsWidget::onCopyButtonClicked);
connect(m_ui->removeButton, &QPushButton::clicked,
this, &ClangDiagnosticConfigsWidget::onRemoveButtonClicked);
connectDiagnosticOptionsChanged();
syncWidgetsToModel(configToSelect);
}
ClangDiagnosticConfigsWidget::~ClangDiagnosticConfigsWidget()
{
delete m_ui;
}
void ClangDiagnosticConfigsWidget::onCurrentConfigChanged(int)
{
syncOtherWidgetsToComboBox();
emit currentConfigChanged(currentConfigId());
}
static ClangDiagnosticConfig createCustomConfig(const ClangDiagnosticConfig &config,
const QString &displayName)
{
ClangDiagnosticConfig copied = config;
copied.setId(Core::Id::fromString(QUuid::createUuid().toString()));
copied.setDisplayName(displayName);
copied.setIsReadOnly(false);
return copied;
}
void ClangDiagnosticConfigsWidget::onCopyButtonClicked()
{
const ClangDiagnosticConfig &config = currentConfig();
bool diaglogAccepted = false;
const QString newName = QInputDialog::getText(this,
tr("Copy Diagnostic Configuration"),
tr("Diagnostic configuration name:"),
QLineEdit::Normal,
tr("%1 (Copy)").arg(config.displayName()),
&diaglogAccepted);
if (diaglogAccepted) {
const ClangDiagnosticConfig customConfig = createCustomConfig(config, newName);
m_diagnosticConfigsModel.appendOrUpdate(customConfig);
emit customConfigsChanged(customConfigs());
syncConfigChooserToModel(customConfig.id());
m_ui->diagnosticOptionsTextEdit->setFocus();
}
}
void ClangDiagnosticConfigsWidget::onRemoveButtonClicked()
{
m_diagnosticConfigsModel.removeConfigWithId(currentConfigId());
emit customConfigsChanged(customConfigs());
syncConfigChooserToModel();
}
void ClangDiagnosticConfigsWidget::onDiagnosticOptionsEdited()
{
const QString diagnosticOptions
= m_ui->diagnosticOptionsTextEdit->document()->toPlainText().trimmed();
const QStringList updatedCommandLine
= diagnosticOptions.trimmed().split(QLatin1Char(' '), QString::SkipEmptyParts);
ClangDiagnosticConfig updatedConfig = currentConfig();
updatedConfig.setCommandLineOptions(updatedCommandLine);
m_diagnosticConfigsModel.appendOrUpdate(updatedConfig);
emit customConfigsChanged(customConfigs());
}
void ClangDiagnosticConfigsWidget::syncWidgetsToModel(const Core::Id &configToSelect)
{
syncConfigChooserToModel(configToSelect);
syncOtherWidgetsToComboBox();
}
static QString displayNameWithBuiltinIndication(const ClangDiagnosticConfig &config,
const Core::Id &exceptionalConfig)
{
if (exceptionalConfig == config.id())
return config.displayName();
return ClangDiagnosticConfigsModel::displayNameWithBuiltinIndication(config);
}
void ClangDiagnosticConfigsWidget::syncConfigChooserToModel(const Core::Id &configToSelect)
{
disconnectConfigChooserCurrentIndex();
const int previousCurrentIndex = m_ui->configChooserComboBox->currentIndex();
m_ui->configChooserComboBox->clear();
int configToSelectIndex = -1;
const int size = m_diagnosticConfigsModel.size();
for (int i = 0; i < size; ++i) {
const ClangDiagnosticConfig &config = m_diagnosticConfigsModel.at(i);
const QString displayName
= displayNameWithBuiltinIndication(config, m_configWithUndecoratedDisplayName);
m_ui->configChooserComboBox->addItem(displayName, config.id().toSetting());
if (configToSelect == config.id())
configToSelectIndex = i;
}
connectConfigChooserCurrentIndex();
if (configToSelectIndex != -1)
m_ui->configChooserComboBox->setCurrentIndex(configToSelectIndex);
else if (previousCurrentIndex != m_ui->configChooserComboBox->currentIndex())
emit currentConfigChanged(currentConfigId());
}
void ClangDiagnosticConfigsWidget::syncOtherWidgetsToComboBox()
{
if (isConfigChooserEmpty())
return;
const ClangDiagnosticConfig &config = currentConfig();
// Update main button row
m_ui->removeButton->setEnabled(!config.isReadOnly());
// Update child widgets
const QString commandLineOptions = config.commandLineOptions().join(QLatin1Char(' '));
setDiagnosticOptions(commandLineOptions);
m_ui->diagnosticOptionsTextEdit->setReadOnly(config.isReadOnly());
}
bool ClangDiagnosticConfigsWidget::isConfigChooserEmpty() const
{
return m_ui->configChooserComboBox->count() == 0;
}
const ClangDiagnosticConfig &ClangDiagnosticConfigsWidget::currentConfig() const
{
return m_diagnosticConfigsModel.configWithId(currentConfigId());
}
void ClangDiagnosticConfigsWidget::setDiagnosticOptions(const QString &options)
{
if (options != m_ui->diagnosticOptionsTextEdit->document()->toPlainText()) {
disconnectDiagnosticOptionsChanged();
m_ui->diagnosticOptionsTextEdit->document()->setPlainText(options);
connectDiagnosticOptionsChanged();
}
}
void ClangDiagnosticConfigsWidget::connectConfigChooserCurrentIndex()
{
connect(m_ui->configChooserComboBox,
static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this,
&ClangDiagnosticConfigsWidget::onCurrentConfigChanged);
}
void ClangDiagnosticConfigsWidget::disconnectConfigChooserCurrentIndex()
{
disconnect(m_ui->configChooserComboBox,
static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this,
&ClangDiagnosticConfigsWidget::onCurrentConfigChanged);
}
void ClangDiagnosticConfigsWidget::connectDiagnosticOptionsChanged()
{
connect(m_ui->diagnosticOptionsTextEdit->document(), &QTextDocument::contentsChanged,
this, &ClangDiagnosticConfigsWidget::onDiagnosticOptionsEdited);
}
void ClangDiagnosticConfigsWidget::disconnectDiagnosticOptionsChanged()
{
disconnect(m_ui->diagnosticOptionsTextEdit->document(), &QTextDocument::contentsChanged,
this, &ClangDiagnosticConfigsWidget::onDiagnosticOptionsEdited);
}
void ClangDiagnosticConfigsWidget::setConfigWithUndecoratedDisplayName(const Core::Id &id)
{
m_configWithUndecoratedDisplayName = id;
}
Core::Id ClangDiagnosticConfigsWidget::currentConfigId() const
{
return Core::Id::fromSetting(m_ui->configChooserComboBox->currentData());
}
ClangDiagnosticConfigs ClangDiagnosticConfigsWidget::customConfigs() const
{
const ClangDiagnosticConfigs allConfigs = m_diagnosticConfigsModel.configs();
return Utils::filtered(allConfigs, [](const ClangDiagnosticConfig &config){
return !config.isReadOnly();
});
}
void ClangDiagnosticConfigsWidget::refresh(
const ClangDiagnosticConfigsModel &diagnosticConfigsModel,
const Core::Id &configToSelect)
{
m_diagnosticConfigsModel = diagnosticConfigsModel;
syncWidgetsToModel(configToSelect);
}
} // CppTools namespace

View File

@@ -0,0 +1,89 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "cpptools_global.h"
#include "clangdiagnosticconfig.h"
#include "clangdiagnosticconfigsmodel.h"
#include <QWidget>
namespace CppTools {
namespace Ui { class ClangDiagnosticConfigsWidget; }
class CPPTOOLS_EXPORT ClangDiagnosticConfigsWidget : public QWidget
{
Q_OBJECT
public:
explicit ClangDiagnosticConfigsWidget(
const ClangDiagnosticConfigsModel &diagnosticConfigsModel = ClangDiagnosticConfigsModel(),
const Core::Id &configToSelect = Core::Id(),
QWidget *parent = 0);
~ClangDiagnosticConfigsWidget();
Core::Id currentConfigId() const;
ClangDiagnosticConfigs customConfigs() const;
void setConfigWithUndecoratedDisplayName(const Core::Id &id);
void refresh(const ClangDiagnosticConfigsModel &diagnosticConfigsModel,
const Core::Id &configToSelect);
signals:
void currentConfigChanged(const Core::Id &currentConfigId);
void customConfigsChanged(const CppTools::ClangDiagnosticConfigs &customConfigs);
private slots:
void onCurrentConfigChanged(int);
void onCopyButtonClicked();
void onRemoveButtonClicked();
void onDiagnosticOptionsEdited();
private:
void syncWidgetsToModel(const Core::Id &configToSelect = Core::Id());
void syncConfigChooserToModel(const Core::Id &configToSelect = Core::Id());
void syncOtherWidgetsToComboBox();
bool isConfigChooserEmpty() const;
const ClangDiagnosticConfig &currentConfig() const;
void setDiagnosticOptions(const QString &options);
void connectConfigChooserCurrentIndex();
void disconnectConfigChooserCurrentIndex();
void connectDiagnosticOptionsChanged();
void disconnectDiagnosticOptionsChanged();
private:
Ui::ClangDiagnosticConfigsWidget *m_ui;
ClangDiagnosticConfigsModel m_diagnosticConfigsModel;
Core::Id m_configWithUndecoratedDisplayName;
};
} // CppTools namespace

View File

@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CppTools::ClangDiagnosticConfigsWidget</class>
<widget class="QWidget" name="CppTools::ClangDiagnosticConfigsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>597</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<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>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Configuration to use:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="configChooserComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="copyButton">
<property name="text">
<string>Copy...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeButton">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPlainTextEdit" name="diagnosticOptionsTextEdit"/>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>For appropriate options, consult the GCC or Clang manual pages or the &lt;a href=&quot;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html&quot;&gt;GCC online documentation&lt;/a&gt;.</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -24,24 +24,63 @@
****************************************************************************/ ****************************************************************************/
#include "cppcodemodelsettings.h" #include "cppcodemodelsettings.h"
#include "clangdiagnosticconfigsmodel.h"
#include "cpptoolsconstants.h" #include "cpptoolsconstants.h"
#include <utils/qtcassert.h>
#include <QSettings> #include <QSettings>
using namespace CppTools; using namespace CppTools;
static QLatin1String cppHeaderMimeType(Constants::CPP_HEADER_MIMETYPE); static Core::Id initialClangDiagnosticConfigId()
static QLatin1String cHeaderMimeType(Constants::C_HEADER_MIMETYPE); { return Core::Id(Constants::CPP_CLANG_BUILTIN_CONFIG_ID_EVERYTHING_WITH_EXCEPTIONS); }
static QLatin1String clangExtraOptionsKey(Constants::CPPTOOLS_EXTRA_CLANG_OPTIONS);
static CppCodeModelSettings::PCHUsage initialPchUsage()
{ return CppCodeModelSettings::PchUse_None; }
static QString clangDiagnosticConfigKey()
{ return QStringLiteral("ClangDiagnosticConfig"); }
static QString clangDiagnosticConfigsArrayKey()
{ return QStringLiteral("ClangDiagnosticConfigs"); }
static QString clangDiagnosticConfigsArrayIdKey()
{ return QLatin1String("id"); }
static QString clangDiagnosticConfigsArrayDisplayNameKey()
{ return QLatin1String("displayName"); }
static QString clangDiagnosticConfigsArrayOptionsKey()
{ return QLatin1String("diagnosticOptions"); }
static QString pchUsageKey()
{ return QLatin1String(Constants::CPPTOOLS_MODEL_MANAGER_PCH_USAGE); }
void CppCodeModelSettings::fromSettings(QSettings *s) void CppCodeModelSettings::fromSettings(QSettings *s)
{ {
s->beginGroup(QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP)); s->beginGroup(QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP));
setExtraClangOptions(s->value(clangExtraOptionsKey, defaultExtraClangOptions()).toStringList()); const int size = s->beginReadArray(clangDiagnosticConfigsArrayKey());
for (int i = 0; i < size; ++i) {
s->setArrayIndex(i);
QVariant v = s->value(QLatin1String(Constants::CPPTOOLS_MODEL_MANAGER_PCH_USAGE), PchUse_None); ClangDiagnosticConfig config;
setPCHUsage(static_cast<PCHUsage>(v.toInt())); config.setId(Core::Id::fromSetting(s->value(clangDiagnosticConfigsArrayIdKey())));
config.setDisplayName(s->value(clangDiagnosticConfigsArrayDisplayNameKey()).toString());
config.setCommandLineOptions(s->value(clangDiagnosticConfigsArrayOptionsKey()).toStringList());
m_clangCustomDiagnosticConfigs.append(config);
}
s->endArray();
const Core::Id diagnosticConfigId = Core::Id::fromSetting(
s->value(clangDiagnosticConfigKey(),
initialClangDiagnosticConfigId().toSetting()));
setClangDiagnosticConfigId(diagnosticConfigId);
const QVariant pchUsageVariant = s->value(pchUsageKey(), initialPchUsage());
setPCHUsage(static_cast<PCHUsage>(pchUsageVariant.toInt()));
s->endGroup(); s->endGroup();
emit changed(); emit changed();
@@ -51,39 +90,50 @@ void CppCodeModelSettings::toSettings(QSettings *s)
{ {
s->beginGroup(QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP)); s->beginGroup(QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP));
s->setValue(clangExtraOptionsKey, extraClangOptions()); s->beginWriteArray(clangDiagnosticConfigsArrayKey());
s->setValue(QLatin1String(Constants::CPPTOOLS_MODEL_MANAGER_PCH_USAGE), pchUsage()); for (int i = 0, size = m_clangCustomDiagnosticConfigs.size(); i < size; ++i) {
const ClangDiagnosticConfig &config = m_clangCustomDiagnosticConfigs.at(i);
s->setArrayIndex(i);
s->setValue(clangDiagnosticConfigsArrayIdKey(), config.id().toSetting());
s->setValue(clangDiagnosticConfigsArrayDisplayNameKey(), config.displayName());
s->setValue(clangDiagnosticConfigsArrayOptionsKey(), config.commandLineOptions());
}
s->endArray();
s->setValue(clangDiagnosticConfigKey(), clangDiagnosticConfigId().toSetting());
s->setValue(pchUsageKey(), pchUsage());
s->endGroup(); s->endGroup();
emit changed(); emit changed();
} }
QStringList CppCodeModelSettings::defaultExtraClangOptions() Core::Id CppCodeModelSettings::clangDiagnosticConfigId() const
{ {
return { return m_clangDiagnosticConfigId;
QStringLiteral("-Weverything"),
QStringLiteral("-Wno-c++98-compat"),
QStringLiteral("-Wno-c++98-compat-pedantic"),
QStringLiteral("-Wno-unused-macros"),
QStringLiteral("-Wno-newline-eof"),
QStringLiteral("-Wno-exit-time-destructors"),
QStringLiteral("-Wno-global-constructors"),
QStringLiteral("-Wno-gnu-zero-variadic-macro-arguments"),
QStringLiteral("-Wno-documentation"),
QStringLiteral("-Wno-shadow"),
QStringLiteral("-Wno-missing-prototypes"), // Not optimal for C projects.
};
} }
QStringList CppCodeModelSettings::extraClangOptions() const void CppCodeModelSettings::setClangDiagnosticConfigId(const Core::Id &configId)
{ {
return m_extraClangOptions; m_clangDiagnosticConfigId = configId;
} }
void CppCodeModelSettings::setExtraClangOptions(const QStringList &extraClangOptions) const ClangDiagnosticConfig CppCodeModelSettings::clangDiagnosticConfig() const
{ {
m_extraClangOptions = extraClangOptions; const ClangDiagnosticConfigsModel configsModel(m_clangCustomDiagnosticConfigs);
return configsModel.configWithId(clangDiagnosticConfigId());
}
ClangDiagnosticConfigs CppCodeModelSettings::clangCustomDiagnosticConfigs() const
{
return m_clangCustomDiagnosticConfigs;
}
void CppCodeModelSettings::setClangCustomDiagnosticConfigs(const ClangDiagnosticConfigs &configs)
{
m_clangCustomDiagnosticConfigs = configs;
} }
CppCodeModelSettings::PCHUsage CppCodeModelSettings::pchUsage() const CppCodeModelSettings::PCHUsage CppCodeModelSettings::pchUsage() const

View File

@@ -28,6 +28,8 @@
#include "cpptools_global.h" #include "cpptools_global.h"
#include "clangdiagnosticconfigsmodel.h"
#include <QObject> #include <QObject>
#include <QStringList> #include <QStringList>
@@ -52,9 +54,12 @@ public:
void toSettings(QSettings *s); void toSettings(QSettings *s);
public: public:
static QStringList defaultExtraClangOptions(); Core::Id clangDiagnosticConfigId() const;
QStringList extraClangOptions() const; void setClangDiagnosticConfigId(const Core::Id &configId);
void setExtraClangOptions(const QStringList &extraClangOptions); const ClangDiagnosticConfig clangDiagnosticConfig() const;
ClangDiagnosticConfigs clangCustomDiagnosticConfigs() const;
void setClangCustomDiagnosticConfigs(const ClangDiagnosticConfigs &configs);
PCHUsage pchUsage() const; PCHUsage pchUsage() const;
void setPCHUsage(PCHUsage pchUsage); void setPCHUsage(PCHUsage pchUsage);
@@ -64,10 +69,12 @@ public: // for tests
signals: signals:
void changed(); void changed();
void clangDiagnosticConfigIdChanged();
private: private:
QStringList m_extraClangOptions;
PCHUsage m_pchUsage = PchUse_None; PCHUsage m_pchUsage = PchUse_None;
ClangDiagnosticConfigs m_clangCustomDiagnosticConfigs;
Core::Id m_clangDiagnosticConfigId;
}; };
} // namespace CppTools } // namespace CppTools

View File

@@ -24,6 +24,8 @@
****************************************************************************/ ****************************************************************************/
#include "cppcodemodelsettingspage.h" #include "cppcodemodelsettingspage.h"
#include "clangdiagnosticconfigswidget.h"
#include "cppmodelmanager.h" #include "cppmodelmanager.h"
#include "cpptoolsconstants.h" #include "cpptoolsconstants.h"
#include "ui_cppcodemodelsettingspage.h" #include "ui_cppcodemodelsettingspage.h"
@@ -43,10 +45,6 @@ CppCodeModelSettingsWidget::CppCodeModelSettingsWidget(QWidget *parent)
m_ui->setupUi(this); m_ui->setupUi(this);
m_ui->clangSettingsGroupBox->setVisible(true); m_ui->clangSettingsGroupBox->setVisible(true);
connect(m_ui->clangOptionsResetButton, &QPushButton::clicked, [this]() {
const QString options = m_settings->defaultExtraClangOptions().join(QLatin1Char('\n'));
m_ui->clangOptionsToAppendTextEdit->document()->setPlainText(options);
});
} }
CppCodeModelSettingsWidget::~CppCodeModelSettingsWidget() CppCodeModelSettingsWidget::~CppCodeModelSettingsWidget()
@@ -73,15 +71,18 @@ void CppCodeModelSettingsWidget::applyToSettings() const
m_settings->toSettings(Core::ICore::settings()); m_settings->toSettings(Core::ICore::settings());
} }
void CppCodeModelSettingsWidget::setupClangCodeModelWidgets() const void CppCodeModelSettingsWidget::setupClangCodeModelWidgets()
{ {
const bool isClangActive = CppModelManager::instance()->isClangCodeModelActive(); const bool isClangActive = CppModelManager::instance()->isClangCodeModelActive();
m_ui->activateClangCodeModelPluginHint->setVisible(!isClangActive); m_ui->activateClangCodeModelPluginHint->setVisible(!isClangActive);
m_ui->clangSettingsGroupBox->setEnabled(isClangActive); m_ui->clangSettingsGroupBox->setEnabled(isClangActive);
const QString extraClangOptions = m_settings->extraClangOptions().join(QLatin1Char('\n')); ClangDiagnosticConfigsModel diagnosticConfigsModel(m_settings->clangCustomDiagnosticConfigs());
m_ui->clangOptionsToAppendTextEdit->document()->setPlainText(extraClangOptions); m_clangDiagnosticConfigsWidget = new ClangDiagnosticConfigsWidget(
diagnosticConfigsModel,
m_settings->clangDiagnosticConfigId());
m_ui->clangSettingsGroupBox->layout()->addWidget(m_clangDiagnosticConfigsWidget);
} }
void CppCodeModelSettingsWidget::setupPchCheckBox() const void CppCodeModelSettingsWidget::setupPchCheckBox() const
@@ -94,12 +95,18 @@ bool CppCodeModelSettingsWidget::applyClangCodeModelWidgetsToSettings() const
{ {
bool settingsChanged = false; bool settingsChanged = false;
const QStringList previousOptions = m_settings->extraClangOptions(); const Core::Id oldConfigId = m_settings->clangDiagnosticConfigId();
const QString newOptionsAsString = m_ui->clangOptionsToAppendTextEdit->document()->toPlainText(); const Core::Id currentConfigId = m_clangDiagnosticConfigsWidget->currentConfigId();
const QStringList newOptions = newOptionsAsString.split(QLatin1Char('\n'), if (oldConfigId != currentConfigId) {
QString::SkipEmptyParts); m_settings->setClangDiagnosticConfigId(currentConfigId);
if (newOptions != previousOptions) { settingsChanged = true;
m_settings->setExtraClangOptions(newOptions); }
const ClangDiagnosticConfigs oldDiagnosticConfigs = m_settings->clangCustomDiagnosticConfigs();
const ClangDiagnosticConfigs currentDiagnosticConfigs
= m_clangDiagnosticConfigsWidget->customConfigs();
if (oldDiagnosticConfigs != currentDiagnosticConfigs) {
m_settings->setClangCustomDiagnosticConfigs(currentDiagnosticConfigs);
settingsChanged = true; settingsChanged = true;
} }

View File

@@ -37,6 +37,9 @@ QT_FORWARD_DECLARE_CLASS(QComboBox)
QT_FORWARD_DECLARE_CLASS(QSettings) QT_FORWARD_DECLARE_CLASS(QSettings)
namespace CppTools { namespace CppTools {
class ClangDiagnosticConfigsWidget;
namespace Internal { namespace Internal {
namespace Ui { class CppCodeModelSettingsPage; } namespace Ui { class CppCodeModelSettingsPage; }
@@ -53,7 +56,7 @@ public:
void applyToSettings() const; void applyToSettings() const;
private: private:
void setupClangCodeModelWidgets() const; void setupClangCodeModelWidgets();
void setupPchCheckBox() const; void setupPchCheckBox() const;
bool applyClangCodeModelWidgetsToSettings() const; bool applyClangCodeModelWidgetsToSettings() const;
@@ -61,6 +64,7 @@ private:
private: private:
Ui::CppCodeModelSettingsPage *m_ui; Ui::CppCodeModelSettingsPage *m_ui;
QPointer<ClangDiagnosticConfigsWidget> m_clangDiagnosticConfigsWidget;
QSharedPointer<CppCodeModelSettings> m_settings; QSharedPointer<CppCodeModelSettings> m_settings;
}; };

View File

@@ -24,47 +24,12 @@
<item> <item>
<widget class="QGroupBox" name="clangSettingsGroupBox"> <widget class="QGroupBox" name="clangSettingsGroupBox">
<property name="title"> <property name="title">
<string>Clang Code Model</string> <string>Clang Code Model Warnings</string>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>false</bool> <bool>false</bool>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3"/>
<item>
<widget class="QLabel" name="clangOptionsGeneralHintLabel">
<property name="text">
<string>Append additional command line options to Clang, one per line. &lt;i&gt;Use this with care.&lt;/i&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="clangOptionsToAppendTextEdit"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="clangOptionsResetButton">
<property name="text">
<string>Reset Options</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget> </widget>
</item> </item>
<item> <item>

View File

@@ -9,6 +9,9 @@ HEADERS += \
builtineditordocumentparser.h \ builtineditordocumentparser.h \
builtineditordocumentprocessor.h \ builtineditordocumentprocessor.h \
builtinindexingsupport.h \ builtinindexingsupport.h \
clangdiagnosticconfig.h \
clangdiagnosticconfigsmodel.h \
clangdiagnosticconfigswidget.h \
commentssettings.h \ commentssettings.h \
completionsettingspage.h \ completionsettingspage.h \
cppchecksymbols.h \ cppchecksymbols.h \
@@ -84,6 +87,9 @@ SOURCES += \
builtineditordocumentparser.cpp \ builtineditordocumentparser.cpp \
builtineditordocumentprocessor.cpp \ builtineditordocumentprocessor.cpp \
builtinindexingsupport.cpp \ builtinindexingsupport.cpp \
clangdiagnosticconfig.cpp \
clangdiagnosticconfigsmodel.cpp \
clangdiagnosticconfigswidget.cpp \
commentssettings.cpp \ commentssettings.cpp \
completionsettingspage.cpp \ completionsettingspage.cpp \
cppchecksymbols.cpp \ cppchecksymbols.cpp \
@@ -149,6 +155,7 @@ SOURCES += \
compileroptionsbuilder.cpp compileroptionsbuilder.cpp
FORMS += \ FORMS += \
clangdiagnosticconfigswidget.ui \
completionsettingspage.ui \ completionsettingspage.ui \
cppcodemodelsettingspage.ui \ cppcodemodelsettingspage.ui \
cppcodestylesettingspage.ui \ cppcodestylesettingspage.ui \

View File

@@ -31,6 +31,10 @@ QtcPlugin {
"builtineditordocumentparser.cpp", "builtineditordocumentparser.h", "builtineditordocumentparser.cpp", "builtineditordocumentparser.h",
"builtineditordocumentprocessor.cpp", "builtineditordocumentprocessor.h", "builtineditordocumentprocessor.cpp", "builtineditordocumentprocessor.h",
"builtinindexingsupport.cpp", "builtinindexingsupport.h", "builtinindexingsupport.cpp", "builtinindexingsupport.h",
"clangdiagnosticconfig.cpp", "clangdiagnosticconfig.h",
"clangdiagnosticconfigsmodel.cpp", "clangdiagnosticconfigsmodel.h",
"clangdiagnosticconfigswidget.cpp", "clangdiagnosticconfigswidget.h",
"clangdiagnosticconfigswidget.ui",
"compileroptionsbuilder.cpp", "compileroptionsbuilder.h", "compileroptionsbuilder.cpp", "compileroptionsbuilder.h",
"commentssettings.cpp", "commentssettings.h", "commentssettings.cpp", "commentssettings.h",
"completionsettingspage.cpp", "completionsettingspage.h", "completionsettingspage.ui", "completionsettingspage.cpp", "completionsettingspage.h", "completionsettingspage.ui",

View File

@@ -49,7 +49,8 @@ const char LOWERCASE_CPPFILES_KEY[] = "LowerCaseFiles";
enum { lowerCaseFilesDefault = 1 }; enum { lowerCaseFilesDefault = 1 };
const char CPPTOOLS_SORT_EDITOR_DOCUMENT_OUTLINE[] = "SortedMethodOverview"; const char CPPTOOLS_SORT_EDITOR_DOCUMENT_OUTLINE[] = "SortedMethodOverview";
const char CPPTOOLS_MODEL_MANAGER_PCH_USAGE[] = "PCHUsage"; const char CPPTOOLS_MODEL_MANAGER_PCH_USAGE[] = "PCHUsage";
const char CPPTOOLS_EXTRA_CLANG_OPTIONS[] = "ExtraClangOptions";
const char CPP_CLANG_BUILTIN_CONFIG_ID_EVERYTHING_WITH_EXCEPTIONS[] = "Builtin.EverythingWithExceptions";
const char CPP_CODE_STYLE_SETTINGS_ID[] = "A.Cpp.Code Style"; const char CPP_CODE_STYLE_SETTINGS_ID[] = "A.Cpp.Code Style";
const char CPP_CODE_STYLE_SETTINGS_NAME[] = QT_TRANSLATE_NOOP("CppTools", "Code Style"); const char CPP_CODE_STYLE_SETTINGS_NAME[] = QT_TRANSLATE_NOOP("CppTools", "Code Style");

View File

@@ -103,16 +103,26 @@ UnstartedAppWatcherDialog::UnstartedAppWatcherDialog(QWidget *parent)
else if (KitManager::defaultKit()) else if (KitManager::defaultKit())
m_kitChooser->setCurrentKitId(KitManager::defaultKit()->id()); m_kitChooser->setCurrentKitId(KitManager::defaultKit()->id());
auto pathLayout = new QHBoxLayout;
m_pathChooser = new Utils::PathChooser(this); m_pathChooser = new Utils::PathChooser(this);
m_pathChooser->setExpectedKind(Utils::PathChooser::ExistingCommand); m_pathChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
m_pathChooser->setHistoryCompleter(QLatin1String("LocalExecutable")); m_pathChooser->setHistoryCompleter(QLatin1String("LocalExecutable"), true);
m_pathChooser->setMinimumWidth(400); m_pathChooser->setMinimumWidth(400);
auto resetExecutable = new QPushButton(tr("Reset"));
resetExecutable->setEnabled(false);
pathLayout->addWidget(m_pathChooser);
pathLayout->addWidget(resetExecutable);
if (activeTarget) { if (activeTarget) {
if (RunConfiguration *runConfig = activeTarget->activeRunConfiguration()) { if (RunConfiguration *runConfig = activeTarget->activeRunConfiguration()) {
const Runnable runnable = runConfig->runnable(); const Runnable runnable = runConfig->runnable();
if (runnable.is<StandardRunnable>() && isLocal(runConfig)) if (runnable.is<StandardRunnable>() && isLocal(runConfig)) {
m_pathChooser->setPath(runnable.as<StandardRunnable>().executable); resetExecutable->setEnabled(true);
connect(resetExecutable, &QPushButton::clicked,
this, [this, runnable]() {
m_pathChooser->setPath(runnable.as<StandardRunnable>().executable);
});
}
} }
} }
@@ -140,7 +150,7 @@ UnstartedAppWatcherDialog::UnstartedAppWatcherDialog(QWidget *parent)
QFormLayout *mainLayout = new QFormLayout(this); QFormLayout *mainLayout = new QFormLayout(this);
mainLayout->addRow(new QLabel(tr("Kit: "), this), m_kitChooser); mainLayout->addRow(new QLabel(tr("Kit: "), this), m_kitChooser);
mainLayout->addRow(new QLabel(tr("Executable: "), this), m_pathChooser); mainLayout->addRow(new QLabel(tr("Executable: "), this), pathLayout);
mainLayout->addRow(m_hideOnAttachCheckBox); mainLayout->addRow(m_hideOnAttachCheckBox);
mainLayout->addRow(m_continueOnAttachCheckBox); mainLayout->addRow(m_continueOnAttachCheckBox);
mainLayout->addRow(m_waitingLabel); mainLayout->addRow(m_waitingLabel);

View File

@@ -51,8 +51,8 @@ class ExtraCompilerPrivate
public: public:
const Project *project; const Project *project;
Utils::FileName source; Utils::FileName source;
QHash<Utils::FileName, QByteArray> contents;
Utils::FileNameList targets; Utils::FileNameList targets;
QVector<QByteArray> contents;
QList<Task> issues; QList<Task> issues;
QDateTime compileTime; QDateTime compileTime;
Core::IEditor *lastEditor = 0; Core::IEditor *lastEditor = 0;
@@ -71,7 +71,8 @@ ExtraCompiler::ExtraCompiler(const Project *project, const Utils::FileName &sour
d->project = project; d->project = project;
d->source = source; d->source = source;
d->targets = targets; d->targets = targets;
d->contents.resize(targets.size()); foreach (const Utils::FileName &target, targets)
d->contents.insert(target, QByteArray());
d->timer.setSingleShot(true); d->timer.setSingleShot(true);
connect(d->project, &Project::activeTargetChanged, this, &ExtraCompiler::onActiveTargetChanged); connect(d->project, &Project::activeTargetChanged, this, &ExtraCompiler::onActiveTargetChanged);
@@ -148,11 +149,7 @@ Utils::FileName ExtraCompiler::source() const
QByteArray ExtraCompiler::content(const Utils::FileName &file) const QByteArray ExtraCompiler::content(const Utils::FileName &file) const
{ {
for (int i = 0; i < d->targets.length(); ++i) { return d->contents.value(file);
if (d->targets[i] == file)
return d->contents[i];
}
return QByteArray();
} }
Utils::FileNameList ExtraCompiler::targets() const Utils::FileNameList ExtraCompiler::targets() const
@@ -335,13 +332,11 @@ void ExtraCompilerPrivate::updateIssues()
void ExtraCompiler::setContent(const Utils::FileName &file, const QByteArray &contents) void ExtraCompiler::setContent(const Utils::FileName &file, const QByteArray &contents)
{ {
for (int i = 0; i < d->targets.length(); ++i) { auto it = d->contents.find(file);
if (d->targets[i] == file) { if (it != d->contents.end()) {
if (d->contents[i] != contents) { if (it.value() != contents) {
d->contents[i] = contents; it.value() = contents;
emit contentsChanged(file); emit contentsChanged(file);
}
return;
} }
} }
} }

View File

@@ -441,10 +441,10 @@ QSet<Id> BaseQtVersion::availableFeatures() const
return features; return features;
features.insert(Constants::FEATURE_QT_3D); features.insert(Constants::FEATURE_QT_3D);
features.insert(Constants::FEATURE_QT_CANVAS3D);
features.unite(versionedIds(Constants::FEATURE_QT_QUICK_PREFIX, 2, 5)); features.unite(versionedIds(Constants::FEATURE_QT_QUICK_PREFIX, 2, 5));
features.unite(versionedIds(Constants::FEATURE_QT_QUICK_CONTROLS_PREFIX, 1, 4)); features.unite(versionedIds(Constants::FEATURE_QT_QUICK_CONTROLS_PREFIX, 1, 4));
features.unite(versionedIds(Constants::FEATURE_QT_CANVAS3D_PREFIX, 1, 0));
if (qtVersion().matches(5, 5)) if (qtVersion().matches(5, 5))
return features; return features;
@@ -452,6 +452,7 @@ QSet<Id> BaseQtVersion::availableFeatures() const
features.unite(versionedIds(Constants::FEATURE_QT_QUICK_PREFIX, 2, 6)); features.unite(versionedIds(Constants::FEATURE_QT_QUICK_PREFIX, 2, 6));
features.unite(versionedIds(Constants::FEATURE_QT_QUICK_CONTROLS_PREFIX, 1, 5)); features.unite(versionedIds(Constants::FEATURE_QT_QUICK_CONTROLS_PREFIX, 1, 5));
features.unite(versionedIds(Constants::FEATURE_QT_LABS_CONTROLS_PREFIX, 1, 0)); features.unite(versionedIds(Constants::FEATURE_QT_LABS_CONTROLS_PREFIX, 1, 0));
features.unite(versionedIds(Constants::FEATURE_QT_CANVAS3D_PREFIX, 1, 1));
if (qtVersion().matches(5, 6)) if (qtVersion().matches(5, 6))
return features; return features;

View File

@@ -54,7 +54,7 @@ const char FEATURE_QT_LABS_CONTROLS_PREFIX[] = "QtSupport.Wizards.FeatureQt.labs
const char FEATURE_QT_QUICK_UI_FILES[] = "QtSupport.Wizards.FeatureQtQuick.UiFiles"; const char FEATURE_QT_QUICK_UI_FILES[] = "QtSupport.Wizards.FeatureQtQuick.UiFiles";
const char FEATURE_QT_WEBKIT[] = "QtSupport.Wizards.FeatureQtWebkit"; const char FEATURE_QT_WEBKIT[] = "QtSupport.Wizards.FeatureQtWebkit";
const char FEATURE_QT_3D[] = "QtSupport.Wizards.FeatureQt3d"; const char FEATURE_QT_3D[] = "QtSupport.Wizards.FeatureQt3d";
const char FEATURE_QT_CANVAS3D[] = "QtSupport.Wizards.FeatureQtCanvas3d"; const char FEATURE_QT_CANVAS3D_PREFIX[] = "QtSupport.Wizards.FeatureQtCanvas3d";
const char FEATURE_QT_CONSOLE[] = "QtSupport.Wizards.FeatureQtConsole"; const char FEATURE_QT_CONSOLE[] = "QtSupport.Wizards.FeatureQtConsole";
const char FEATURE_MOBILE[] = "QtSupport.Wizards.FeatureMobile"; const char FEATURE_MOBILE[] = "QtSupport.Wizards.FeatureMobile";
const char FEATURE_DESKTOP[] = "QtSupport.Wizards.FeatureDesktop"; const char FEATURE_DESKTOP[] = "QtSupport.Wizards.FeatureDesktop";

View File

@@ -976,6 +976,27 @@ TEST_F(HighlightingInformations, LambdaCapture)
ASSERT_THAT(infos[4], HasType(HighlightingType::LocalVariable)); ASSERT_THAT(infos[4], HasType(HighlightingType::LocalVariable));
} }
TEST_F(HighlightingInformations, LambdaCapturedVarUsage)
{
const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(443, 41));
ASSERT_THAT(infos[1], HasType(HighlightingType::LocalVariable));
}
TEST_F(HighlightingInformations, LambdaArgumentUsage)
{
const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(443, 41));
ASSERT_THAT(infos[3], HasType(HighlightingType::LocalVariable));
}
TEST_F(HighlightingInformations, LambdaFieldUsage)
{
const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(443, 41));
ASSERT_THAT(infos[5], HasType(HighlightingType::Field));
}
Data *HighlightingInformations::d; Data *HighlightingInformations::d;
void HighlightingInformations::SetUpTestCase() void HighlightingInformations::SetUpTestCase()