diff --git a/doc/images/qtcreator-autotests-options-qt.png b/doc/images/qtcreator-autotests-options-qt.png index 289f355e017..84a2501717a 100644 Binary files a/doc/images/qtcreator-autotests-options-qt.png and b/doc/images/qtcreator-autotests-options-qt.png differ diff --git a/doc/images/qtcreator-autotests-options.png b/doc/images/qtcreator-autotests-options.png index a9016ecf1ad..e019c2cc912 100644 Binary files a/doc/images/qtcreator-autotests-options.png and b/doc/images/qtcreator-autotests-options.png differ diff --git a/doc/images/qtcreator-autotests.png b/doc/images/qtcreator-autotests.png index e5a2b91bc57..a7e14d5292c 100644 Binary files a/doc/images/qtcreator-autotests.png and b/doc/images/qtcreator-autotests.png differ diff --git a/doc/images/qtcreator-tests-view.png b/doc/images/qtcreator-tests-view.png new file mode 100644 index 00000000000..cb771e06cf7 Binary files /dev/null and b/doc/images/qtcreator-tests-view.png differ diff --git a/doc/src/howto/creator-autotest.qdoc b/doc/src/howto/creator-autotest.qdoc index bdeb94cc87a..2bd3ad5cf7e 100644 --- a/doc/src/howto/creator-autotest.qdoc +++ b/doc/src/howto/creator-autotest.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Creator documentation. @@ -131,6 +131,9 @@ \endlist \QC creates the test in the specified project directory. + For more information about creating Google tests, see the + \l{https://github.com/google/googletest/blob/master/googletest/docs/Primer.md} + {Google Test Primer}. \section1 Setting Up the Google C++ Testing Framework @@ -175,6 +178,87 @@ \li \c {LIBS += -lgmock -L} \endlist + \section1 Building and Running Tests + + To build and run tests: + + \list 1 + + \li Open a project that contains tests. + + \li In the \uicontrol Tests view, select the tests to run. + + \li In the \uicontrol {Test Results} output pane, select + \inlineimage run_small.png + (\uicontrol {Run All Tests}) to run all test or + \inlineimage qtcreator-run-selected-tests.png + (\uicontrol {Run Selected Tests}) to run the selected tests. + + \note By default, \QC builds a project before deploying and running + it. + + \endlist + + If a test takes more than a minute to execute, the default timeout might + stop the test execution. To increase the timeout, select \uicontrol Tools > + \uicontrol Options > \uicontrol {Test Settings} > \uicontrol General. + + \section2 Selecting Tests to Run + + The \uicontrol Tests view shows all the tests found for the currently active + test frameworks in the current project. Select the test cases to run. + + \image qtcreator-tests-view.png + + If a Qt Quick test case does not have a name, it is marked + \uicontrol Unnamed in the list. Unnamed test cases are executed when you + select \uicontrol {Run All Tests}. You cannot select or deselect them. + + \QC scans the project for tests when you open the project and updates the + test list for the currently active test frameworks when you edit tests. + To refresh the view, select \uicontrol {Rescan Tests} in the context menu. + + You can add filters to specify the directories within the current project + to scan for tests. Select \uicontrol Tools > \uicontrol Options > + \uicontrol {Test Settings} > \uicontrol General > \uicontrol Add, and + specify paths to the directories to scan for tests. Wildcards are not + supported in the filter expressions. + + \image qtcreator-autotests-options.png + + To show or hide init and cleanup or data functions in the \uicontrol Tests + view, select \inlineimage filtericon.png + (\uicontrol {Filter Test Tree}), and then select \uicontrol {Show Init and + Cleanup Functions} or \uicontrol {Show Data Functions}. Double-click a + function in the list to open its source code in the code editor. + + The test cases are listed in alphabetic order. To list them in the order in + which they are defined in the source code, select \inlineimage leafsort.png + (\uicontrol {Sort Naturally}). + + \section2 Specifying Settings for Running Qt Tests + + The code inside a benchmark test is measured, and possibly also repeated + several times in order to get an accurate measurement. This depends on the + measurement back-end that you can select in the + \uicontrol {Benchmark Metrics} group in \uicontrol Tools > + \uicontrol Options > \uicontrol {Test Settings} > \uicontrol {Qt Test}: + walltime, CPU tick counter, event counter, Valgrind Callgrind, and Linux + Perf. For more information, see \l{Creating a Benchmark}. + + \image qtcreator-autotests-options-qt.png + + To receive verbose output when running benchmarks, select the + \uicontrol {Verbose benchmarks} check box. + + To allow the debugger to interrupt Qt tests on assertions, select the + \uicontrol {Disable crash handler while debugging} check box. + + To record information about signals and slots in the test log, select the + \uicontrol {Log signals and slots} check box. + + \section2 Specifying Settings for Running Google Tests + To specify settings for running Google tests, select \uicontrol Tools > \uicontrol Options > \uicontrol {Test Settings} > \uicontrol {Google Test}. @@ -193,58 +277,23 @@ failures into C++ exceptions, select the \uicontrol {Throw on failure} check box. - For more information about creating Google tests, see the - \l{https://github.com/google/googletest/blob/master/googletest/docs/Primer.md} - {Google Test Primer}. - - \section1 Building and Running Tests - - To build and run tests: - - \list 1 - - \li Open a project that contains tests. - - \li In the \uicontrol {Test Results} output pane, select - \inlineimage run_small.png - (\uicontrol {Run All Tests}) to run all test or - \inlineimage qtcreator-run-selected-tests.png - (\uicontrol {Run Selected Tests}) to run the selected tests. - - You can select the tests to run in the \uicontrol Tests view in the - \uicontrol Projects pane. For more information, see - \l{Viewing Tests}. - - \note By default, \QC builds a project before deploying and running - it. - - \endlist - - If a test takes more than a minute to execute, the default timeout might - stop the test execution. To increase the timeout, select \uicontrol Tools > - \uicontrol Options > \uicontrol {Test Settings} > \uicontrol General. - - \image qtcreator-autotests-options.png - - \QC scans the project for tests when you open the project and updates the - test list for the currently active test frameworks when you edit tests. - - The code inside a benchmark test is measured, and possibly also repeated - several times in order to get an accurate measurement. This depends on the - measurement back-end that you can select in the - \uicontrol {Benchmark Metrics} group in \uicontrol Tools > - \uicontrol Options > \uicontrol {Test Settings} > \uicontrol {Qt Test}: - walltime, CPU tick counter, event counter, Valgrind Callgrind, and Linux - Perf. For more information, see \l{Creating a Benchmark}. - - \image qtcreator-autotests-options-qt.png - - To allow the debugger to interrupt Qt tests on assertions, select the - \uicontrol {Disable crash handler while debugging} check box. - \section1 Viewing Test Output - The test results are displayed in the \uicontrol {Test Results} output pane. + The test results are displayed in the \uicontrol {Test Results} output pane + in XML format. XML can be parsed more easily and reliably than plain text. + + However, if a Qt test crashes, it might not produce complete XML code that + can be parsed, which might lead to information loss. The lost information + might be retrievable when viewing the results as plain text. + To view the results of Qt tests as plain text, select \uicontrol Tools > + \uicontrol Options > \uicontrol {Test Settings} > \uicontrol {Qt Test}, and + then deselect the \uicontrol {Use XML output} check box. Then select the + \inlineimage text.png + (\uicontrol {Switch Between Visual and Text Display}) button in the + \uicontrol {Test Results} output pane to switch to the text display. + + The following table lists the messages that the \uicontrol {Test Results} + output pane displays: \table \header @@ -272,6 +321,13 @@ \row \li FAIL \li Test case failed. Double-click the line for more information. + \row + \li FATAL + \li A fatal error occurred that stops the test case from being run, + for example. + \row + \li INFO + \li Informative message. \row \li INTERNAL \li Internal message. @@ -281,6 +337,9 @@ \row \li SKIP \li Test case was skipped. + \row + \li SYSTEM + \li An error message received from or influenced by the OS. \row \li XPASS \li Test case passed even though it was expected to fail. @@ -294,7 +353,14 @@ (\uicontrol {Filter Test Results}), and then select the types of messages to show. - To hide internal messages and run configuration warnings, select - \uicontrol Tools > \uicontrol Options > \uicontrol {Test Settings} > - \uicontrol General. + By default, test result output is limited to 100,000 characters. The output + pane is automatically scrolled down when new results are added. To display + full results, select \uicontrol Tools > \uicontrol Options > + \uicontrol {Test Settings} > \uicontrol General, and then deselect the + \uicontrol {Limit result output} check box. To disable automatic scrolling, + deselect the \uicontrol {Automatically scroll results} check box. + + Internal messages and run configuration warnings for guessed configurations + are omitted by default. To view them, deselect the \uicontrol {Omit internal + messages} and \uicontrol {Omit run configuration warnings} check boxes. */ diff --git a/doc/src/howto/creator-ui.qdoc b/doc/src/howto/creator-ui.qdoc index 71e197e8d8b..3e6207a8241 100644 --- a/doc/src/howto/creator-ui.qdoc +++ b/doc/src/howto/creator-ui.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Creator documentation. @@ -141,6 +141,7 @@ hierarchy of a QML file. \li \uicontrol Tests lists autotests and Qt Quick tests in the project. + For more information, see \l {Running Autotests}. \li \uicontrol {Type Hierarchy} shows the base classes of a class. @@ -303,28 +304,6 @@ \endlist - \section2 Viewing Tests - - The \uicontrol Tests view shows the autotests and Qt Quick tests in the - current project. Select the test cases to run. If a Qt - Quick test case does not have a name, it is marked \uicontrol Unnamed in the - list. Unnamed test cases are always executed when the application that - contains them is run, and therefore you cannot select or deselect them. - - To show or hide init and cleanup or data functions, select - \uicontrol {Filter Test Tree} > \uicontrol {Show Init and Cleanup Functions} - or \uicontrol {Show Data Functions}. Double-click a function in the list - to open its source code in the code editor. - - The test cases are listed in alphabetic order. To list them in the order in - which they are defined in the source code, select \inlineimage leafsort.png - (\uicontrol {Sort Naturally}). - - To run tests, select \uicontrol {Run All Tests} or - \uicontrol {Run Selected Tests} in the context menu. - - To refresh the view, select \uicontrol {Rescan Tests} in the context menu. - \section2 Viewing Type Hierarchy To view the base classes of a class, right-click the class and select @@ -375,8 +354,7 @@ To open the \uicontrol{General Messages} and \l{Using Version Control Systems} {Version Control} panes, select \uicontrol {Window > Output Panes}. To display the \uicontrol {To-Do Entries} pane, - enable the Todo plugin and to display the \l{Running Autotests} - {Test Results} pane, enable the Auto Tests plugin. + enable the Todo plugin. \section2 Issues diff --git a/scripts/createDevPackage.py b/scripts/createDevPackage.py index f9b7a3f0e3c..05577438f98 100755 --- a/scripts/createDevPackage.py +++ b/scripts/createDevPackage.py @@ -57,17 +57,16 @@ def parse_arguments(): source_include_patterns = [ # directories - r"^scripts/.*$", # everything under scripts/ - r"^doc/.*$", # everything under doc/ + r"^(?!(share|tests)/.*$)(.*/)?$", # look into all directories except under share/ and tests/ r"^share/(qtcreator/(qml/(qmlpuppet/(.*/)?)?)?)?$", # for shared headers for qt quick designer plugins - r"^src/(.*/)?$", # all directories under src/ - r"^plugins/(.*/)?$", # all directories under plugins/ (if this is run on extra plugin repositories) # files r"^HACKING$", r"^LICENSE.*$", r"^README.md$", - r"^.*\.pri$", - r"^.*\.h$", + r"^scripts/.*$", # include everything under scripts/ + r"^doc/.*$", # include everything under doc/ + r"^.*\.pri$", # .pri files in all directories that are looked into + r"^.*\.h$", # .h files in all directories that are looked into ] build_include_patterns = [ diff --git a/src/app/app.pro b/src/app/app.pro index 4d6030bfe7f..a2313575fee 100644 --- a/src/app/app.pro +++ b/src/app/app.pro @@ -20,9 +20,11 @@ win32 { # We need the version in two separate formats for the .rc file # RC_VERSION=4,3,82,0 (quadruple) # RC_VERSION_STRING="4.4.0-beta1" (free text) + # Also, we need to replace space with \x20 to be able to work with both rc and windres + COPYRIGHT = "2008-$${QTCREATOR_COPYRIGHT_YEAR} The Qt Company Ltd" DEFINES += RC_VERSION=$$replace(QTCREATOR_VERSION, "\\.", ","),0 \ - RC_VERSION_STRING=\\\"$${QTCREATOR_DISPLAY_VERSION}\\\" \ - RC_COPYRIGHT='"\\\"2008-$${QTCREATOR_COPYRIGHT_YEAR} The Qt Company Ltd\\\""' + RC_VERSION_STRING=\"$${QTCREATOR_DISPLAY_VERSION}\" \ + RC_COPYRIGHT=\"$$replace(COPYRIGHT, " ", "\\x20")\" RC_FILE = qtcreator.rc } else:macx { LIBS += -framework CoreFoundation diff --git a/src/app/app.qbs b/src/app/app.qbs index b3023fcbe74..b67ff28a2c4 100644 --- a/src/app/app.qbs +++ b/src/app/app.qbs @@ -54,9 +54,11 @@ QtcProduct { // We need the version in two separate formats for the .rc file // RC_VERSION=4,3,82,0 (quadruple) // RC_VERSION_STRING="4.4.0-beta1" (free text) + // Also, we need to replace space with \x20 to be able to work with both rc and windres cpp.defines: outer.concat(["RC_VERSION=" + qtc.qtcreator_version.replace(/\./g, ",") + ",0", - "RC_VERSION_STRING=\"" + qtc.qtcreator_display_version + "\"", - "RC_COPYRIGHT=\"2008-" + qtc.qtcreator_copyright_year + " The Qt Company Ltd\""]) + "RC_VERSION_STRING=" + qtc.qtcreator_display_version, + "RC_COPYRIGHT=2008-" + qtc.qtcreator_copyright_year + + " The Qt Company Ltd".replace(/ /g, "\\x20")]) files: "qtcreator.rc" } diff --git a/src/app/qtcreator.rc b/src/app/qtcreator.rc index 89f03c4708c..bcc6e7f8ab8 100644 --- a/src/app/qtcreator.rc +++ b/src/app/qtcreator.rc @@ -1,5 +1,8 @@ #include +#define STRINGIFY1(x) #x +#define STRINGIFY(x) STRINGIFY1(x) + IDI_ICON1 ICON DISCARDABLE "qtcreator.ico" IDI_ICON2 ICON DISCARDABLE "winicons/c.ico" IDI_ICON3 ICON DISCARDABLE "winicons/cpp.ico" @@ -19,10 +22,10 @@ VS_VERSION_INFO VERSIONINFO BLOCK "040904E4" { VALUE "FileDescription", "Qt Creator" - VALUE "FileVersion", RC_VERSION_STRING + VALUE "FileVersion", STRINGIFY(RC_VERSION_STRING) VALUE "ProductName", "Qt Creator" - VALUE "ProductVersion", RC_VERSION_STRING - VALUE "LegalCopyright", RC_COPYRIGHT + VALUE "ProductVersion", STRINGIFY(RC_VERSION_STRING) + VALUE "LegalCopyright", STRINGIFY(RC_COPYRIGHT) } } BLOCK "VarFileInfo" diff --git a/src/libs/3rdparty/cplusplus/ASTPatternBuilder.cpp b/src/libs/3rdparty/cplusplus/ASTPatternBuilder.cpp deleted file mode 100644 index 0c1549e51b8..00000000000 --- a/src/libs/3rdparty/cplusplus/ASTPatternBuilder.cpp +++ /dev/null @@ -1,2 +0,0 @@ - -#include "ASTPatternBuilder.h" diff --git a/src/libs/3rdparty/cplusplus/ObjectiveCAtKeywords.cpp b/src/libs/3rdparty/cplusplus/ObjectiveCAtKeywords.cpp index d05222c681a..8177368d7f1 100644 --- a/src/libs/3rdparty/cplusplus/ObjectiveCAtKeywords.cpp +++ b/src/libs/3rdparty/cplusplus/ObjectiveCAtKeywords.cpp @@ -1,3 +1,22 @@ +// Copyright (c) 2008 Roberto Raggi +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. #include "Lexer.h" #include "Token.h" diff --git a/src/libs/3rdparty/cplusplus/ObjectiveCTypeQualifiers.cpp b/src/libs/3rdparty/cplusplus/ObjectiveCTypeQualifiers.cpp index 6b85bf4a1b1..6005fe574fc 100644 --- a/src/libs/3rdparty/cplusplus/ObjectiveCTypeQualifiers.cpp +++ b/src/libs/3rdparty/cplusplus/ObjectiveCTypeQualifiers.cpp @@ -1,3 +1,22 @@ +// Copyright (c) 2008 Roberto Raggi +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. #include "ObjectiveCTypeQualifiers.h" diff --git a/src/libs/3rdparty/cplusplus/ObjectiveCTypeQualifiers.h b/src/libs/3rdparty/cplusplus/ObjectiveCTypeQualifiers.h index ac46bd6070f..3f920e5bfc2 100644 --- a/src/libs/3rdparty/cplusplus/ObjectiveCTypeQualifiers.h +++ b/src/libs/3rdparty/cplusplus/ObjectiveCTypeQualifiers.h @@ -1,9 +1,27 @@ -#ifndef CPLUSPLUS_OBJC_TYPEQUALIFIERS_H -#define CPLUSPLUS_OBJC_TYPEQUALIFIERS_H +// Copyright (c) 2008 Roberto Raggi +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#pragma once #include "CPlusPlusForwardDeclarations.h" - namespace CPlusPlus { enum { @@ -27,6 +45,3 @@ enum { CPLUSPLUS_EXPORT int classifyObjectiveCContextKeyword(const char *s, int n); } // namespace CPlusPlus - - -#endif // CPLUSPLUS_OBJC_TYPEQUALIFIERS_H diff --git a/src/libs/3rdparty/cplusplus/QtContextKeywords.cpp b/src/libs/3rdparty/cplusplus/QtContextKeywords.cpp index 87403aed14f..ce7bd0a1dde 100644 --- a/src/libs/3rdparty/cplusplus/QtContextKeywords.cpp +++ b/src/libs/3rdparty/cplusplus/QtContextKeywords.cpp @@ -1,3 +1,22 @@ +// Copyright (c) 2008 Roberto Raggi +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. #include "QtContextKeywords.h" diff --git a/src/libs/3rdparty/cplusplus/QtContextKeywords.h b/src/libs/3rdparty/cplusplus/QtContextKeywords.h index edef73a7ee8..42dce9b917d 100644 --- a/src/libs/3rdparty/cplusplus/QtContextKeywords.h +++ b/src/libs/3rdparty/cplusplus/QtContextKeywords.h @@ -1,3 +1,22 @@ +// Copyright (c) 2008 Roberto Raggi +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. #pragma once diff --git a/src/libs/3rdparty/cplusplus/SafeMatcher.h b/src/libs/3rdparty/cplusplus/SafeMatcher.h index 98219eeffdc..98fbbae2aa2 100644 --- a/src/libs/3rdparty/cplusplus/SafeMatcher.h +++ b/src/libs/3rdparty/cplusplus/SafeMatcher.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef CPLUSPLUS_SAFETYPEMATCHER_H -#define CPLUSPLUS_SAFETYPEMATCHER_H +#pragma once #include "Matcher.h" @@ -56,5 +55,3 @@ private: }; } // CPlusPlus namespace - -#endif // CPLUSPLUS_SAFETYPEMATCHER_H diff --git a/src/libs/3rdparty/cplusplus/cplusplus.pri b/src/libs/3rdparty/cplusplus/cplusplus.pri index 025519ef89c..2a4f71a7122 100644 --- a/src/libs/3rdparty/cplusplus/cplusplus.pri +++ b/src/libs/3rdparty/cplusplus/cplusplus.pri @@ -40,7 +40,6 @@ SOURCES += \ $$PWD/ASTMatch0.cpp \ $$PWD/ASTVisitor.cpp \ $$PWD/ASTClone.cpp \ - $$PWD/ASTPatternBuilder.cpp \ $$PWD/ASTMatcher.cpp \ $$PWD/Matcher.cpp \ $$PWD/Control.cpp \ diff --git a/src/libs/cplusplus/cplusplus.qbs b/src/libs/cplusplus/cplusplus.qbs index c9aae72b3e3..a0e0d66178c 100644 --- a/src/libs/cplusplus/cplusplus.qbs +++ b/src/libs/cplusplus/cplusplus.qbs @@ -30,7 +30,6 @@ Project { "ASTMatch0.cpp", "ASTMatcher.cpp", "ASTMatcher.h", - "ASTPatternBuilder.cpp", "ASTPatternBuilder.h", "ASTVisit.cpp", "ASTVisitor.cpp", diff --git a/src/libs/extensionsystem/pluginspec.cpp b/src/libs/extensionsystem/pluginspec.cpp index cde1903099f..8fd64007a29 100644 --- a/src/libs/extensionsystem/pluginspec.cpp +++ b/src/libs/extensionsystem/pluginspec.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -631,26 +632,6 @@ static inline QString msgInvalidFormat(const char *key, const QString &content) .arg(QLatin1String(key), content); } -bool PluginSpec::readMultiLineString(const QJsonValue &value, QString *out) -{ - QTC_ASSERT(out, return false); - if (value.isString()) { - *out = value.toString(); - } else if (value.isArray()) { - QJsonArray array = value.toArray(); - QStringList lines; - foreach (const QJsonValue &v, array) { - if (!v.isString()) - return false; - lines.append(v.toString()); - } - *out = lines.join(QLatin1Char('\n')); - } else { - return false; - } - return true; -} - /*! \internal */ @@ -735,7 +716,7 @@ bool PluginSpecPrivate::readMetaData(const QJsonObject &pluginMetaData) copyright = value.toString(); value = metaData.value(QLatin1String(DESCRIPTION)); - if (!value.isUndefined() && !PluginSpec::readMultiLineString(value, &description)) + if (!value.isUndefined() && !Utils::readMultiLineString(value, &description)) return reportError(msgValueIsNotAString(DESCRIPTION)); value = metaData.value(QLatin1String(URL)); @@ -749,7 +730,7 @@ bool PluginSpecPrivate::readMetaData(const QJsonObject &pluginMetaData) category = value.toString(); value = metaData.value(QLatin1String(LICENSE)); - if (!value.isUndefined() && !PluginSpec::readMultiLineString(value, &license)) + if (!value.isUndefined() && !Utils::readMultiLineString(value, &license)) return reportError(msgValueIsNotAMultilineString(LICENSE)); value = metaData.value(QLatin1String(PLATFORM)); @@ -799,7 +780,7 @@ bool PluginSpecPrivate::readMetaData(const QJsonObject &pluginMetaData) } else if (typeValue.toLower() == QLatin1String(DEPENDENCY_TYPE_TEST)) { dep.type = PluginDependency::Test; } else { - return reportError(tr("Dependency: \"%1\" must be \"%2\" or \"%3\" (is \"%4\")") + return reportError(tr("Dependency: \"%1\" must be \"%2\" or \"%3\" (is \"%4\").") .arg(QLatin1String(DEPENDENCY_TYPE), QLatin1String(DEPENDENCY_TYPE_HARD), QLatin1String(DEPENDENCY_TYPE_SOFT), diff --git a/src/libs/extensionsystem/pluginspec.h b/src/libs/extensionsystem/pluginspec.h index da89ff6029f..0462acddefe 100644 --- a/src/libs/extensionsystem/pluginspec.h +++ b/src/libs/extensionsystem/pluginspec.h @@ -131,8 +131,6 @@ public: bool hasError() const; QString errorString() const; - static bool readMultiLineString(const QJsonValue &value, QString *out); - private: PluginSpec(); diff --git a/src/libs/modelinglib/qmt/model_controller/modelcontroller.cpp b/src/libs/modelinglib/qmt/model_controller/modelcontroller.cpp index ddaeafc29f1..614069e0b37 100644 --- a/src/libs/modelinglib/qmt/model_controller/modelcontroller.cpp +++ b/src/libs/modelinglib/qmt/model_controller/modelcontroller.cpp @@ -758,6 +758,13 @@ void ModelController::moveObject(MPackage *newOwner, MObject *object) QMT_ASSERT(object, return); QMT_ASSERT(object != m_rootPackage, return); + // verify that newOwner is not a child of object + MObject *newOwnerObject = newOwner; + while (newOwnerObject && newOwnerObject != object) + newOwnerObject = newOwnerObject->owner(); + if (newOwnerObject == object) + return; + if (newOwner != object->owner()) { int formerRow = 0; MObject *formerOwner = object->owner(); diff --git a/src/libs/qtcreatorcdbext/qtcreatorcdbext.qbs b/src/libs/qtcreatorcdbext/qtcreatorcdbext.qbs index 1e1edbefb32..2243c217586 100644 --- a/src/libs/qtcreatorcdbext/qtcreatorcdbext.qbs +++ b/src/libs/qtcreatorcdbext/qtcreatorcdbext.qbs @@ -2,6 +2,8 @@ import qbs import qbs.Environment import qbs.File import qbs.FileInfo +import qbs.Process +import qbs.Utilities QtcLibrary { condition: qbs.toolchain.contains("msvc") && cdbPath @@ -45,11 +47,98 @@ QtcLibrary { } return undefined; } - cpp.includePaths: [FileInfo.joinPaths(cdbPath, "inc")] - cpp.dynamicLibraries: [ - "user32.lib", - FileInfo.joinPaths(cdbLibPath, "dbgeng.lib") - ] + + property string pythonInstallDir: Environment.getEnv("PYTHON_INSTALL_DIR") + + Probe { + id: pythonDllProbe + condition: product.condition + property string pythonDir: pythonInstallDir // Input + property string buildVariant: qbs.buildVariant // Input + property string fileNamePrefix // Output + configure: { + function printWarning(msg) { + console.warn(msg + " The python dumpers for cdb will not be available."); + } + + if (!pythonDir) { + printWarning("PYTHON_INSTALL_DIR not set."); + return; + } + if (!File.exists(pythonDir)) { + printWarning("The provided python installation directory '" + pythonDir + + "' does not exist."); + return; + } + var p = new Process(); + try { + var pythonFilePath = FileInfo.joinPaths(pythonDir, "python.exe"); + p.exec(pythonFilePath, ["--version"], true); + var output = p.readStdOut().trim(); + var magicPrefix = "Python "; + if (!output.startsWith(magicPrefix)) { + printWarning("Unexpected python output when checking for version: '" + + output + "'"); + return; + } + var versionNumberString = output.slice(magicPrefix.length); + var versionNumbers = versionNumberString.split('.'); + if (versionNumbers.length < 2) { + printWarning("Unexpected python output when checking for version: '" + + output + "'"); + return; + } + if (Utilities.versionCompare(versionNumberString, "3.5") < 0) { + printWarning("The python installation at '" + pythonDir + + "' has version " + versionNumberString + ", but 3.5 or higher " + + "is required."); + return; + } + found = true; + fileNamePrefix = "python" + versionNumbers[0] + versionNumbers[1]; + if (buildVariant === "debug") + fileNamePrefix += "_d" + } finally { + p.close(); + } + + } + } + + Group { + name: "pythonDumper" + condition: pythonDllProbe.found + files: [ + "pycdbextmodule.cpp", + "pycdbextmodule.h", + "pyfield.cpp", + "pyfield.h", + "pystdoutredirect.cpp", + "pystdoutredirect.h", + "pytype.cpp", + "pytype.h", + "pyvalue.cpp", + "pyvalue.h", + ] + } + + Properties { + condition: pythonDllProbe.found + cpp.defines: ["WITH_PYTHON=1"] + } + cpp.includePaths: { + var paths = [FileInfo.joinPaths(cdbPath, "inc")]; + if (pythonDllProbe.found) + paths.push(FileInfo.joinPaths(pythonInstallDir, "include")); + return paths; + } + cpp.dynamicLibraries: { + var libs = [ "user32.lib", FileInfo.joinPaths(cdbLibPath, "dbgeng.lib") ]; + if (pythonDllProbe.found) + libs.push(FileInfo.joinPaths(pythonInstallDir, "libs", + pythonDllProbe.fileNamePrefix + ".lib")); + return libs; + } cpp.linkerFlags: ["/DEF:" + FileInfo.toWindowsSeparators( FileInfo.joinPaths(product.sourceDirectory, "qtcreatorcdbext.def"))] @@ -61,6 +150,16 @@ QtcLibrary { dirName += "32"; return FileInfo.joinPaths(qtc.libDirName, dirName); } + + Group { + condition: pythonDllProbe.found + files: [FileInfo.joinPaths(pythonInstallDir, pythonDllProbe.fileNamePrefix + ".dll")] + qbs.install: true + qbs.installDir: installDir + } + + useNonGuiPchFile: false + files: [ "common.cpp", "common.h", diff --git a/src/libs/utils/highlightingitemdelegate.cpp b/src/libs/utils/highlightingitemdelegate.cpp new file mode 100644 index 00000000000..fe2525122c8 --- /dev/null +++ b/src/libs/utils/highlightingitemdelegate.cpp @@ -0,0 +1,305 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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 "highlightingitemdelegate.h" + +#include +#include +#include + +const int kMinimumLineNumberDigits = 6; + +namespace Utils { + +HighlightingItemDelegate::HighlightingItemDelegate(int tabWidth, QObject *parent) + : QItemDelegate(parent) +{ + setTabWidth(tabWidth); +} + +void HighlightingItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const +{ + static const int iconSize = 16; + + painter->save(); + + const QStyleOptionViewItem opt = setOptions(index, option); + painter->setFont(opt.font); + + QItemDelegate::drawBackground(painter, opt, index); + + // ---- do the layout + QRect checkRect; + QRect pixmapRect; + QRect textRect; + + // check mark + const bool checkable = (index.model()->flags(index) & Qt::ItemIsUserCheckable); + Qt::CheckState checkState = Qt::Unchecked; + if (checkable) { + QVariant checkStateData = index.data(Qt::CheckStateRole); + checkState = static_cast(checkStateData.toInt()); + checkRect = doCheck(opt, opt.rect, checkStateData); + } + + // icon + const QIcon icon = index.model()->data(index, Qt::DecorationRole).value(); + if (!icon.isNull()) { + const QSize size = icon.actualSize(QSize(iconSize, iconSize)); + pixmapRect = QRect(0, 0, size.width(), size.height()); + } + + // text + textRect = opt.rect.adjusted(0, 0, checkRect.width() + pixmapRect.width(), 0); + + // do layout + doLayout(opt, &checkRect, &pixmapRect, &textRect, false); + // ---- draw the items + // icon + if (!icon.isNull()) + icon.paint(painter, pixmapRect, option.decorationAlignment); + + // line numbers + const int lineNumberAreaWidth = drawLineNumber(painter, opt, textRect, index); + textRect.adjust(lineNumberAreaWidth, 0, 0, 0); + + // text and focus/selection + drawText(painter, opt, textRect, index); + QItemDelegate::drawFocus(painter, opt, opt.rect); + + // check mark + if (checkable) + QItemDelegate::drawCheck(painter, opt, checkRect, checkState); + + painter->restore(); +} + +void HighlightingItemDelegate::setTabWidth(int width) +{ + m_tabString = QString(width, ' '); +} + +// returns the width of the line number area +int HighlightingItemDelegate::drawLineNumber(QPainter *painter, const QStyleOptionViewItem &option, + const QRect &rect, + const QModelIndex &index) const +{ + static const int lineNumberAreaHorizontalPadding = 4; + const int lineNumber = index.model()->data(index, int(HighlightingItemRole::LineNumber)).toInt(); + if (lineNumber < 1) + return 0; + const bool isSelected = option.state & QStyle::State_Selected; + const QString lineText = QString::number(lineNumber); + const int minimumLineNumberDigits = qMax(kMinimumLineNumberDigits, lineText.count()); + const int fontWidth = painter->fontMetrics().width(QString(minimumLineNumberDigits, '0')); + const int lineNumberAreaWidth = lineNumberAreaHorizontalPadding + fontWidth + + lineNumberAreaHorizontalPadding; + QRect lineNumberAreaRect(rect); + lineNumberAreaRect.setWidth(lineNumberAreaWidth); + + QPalette::ColorGroup cg = QPalette::Normal; + if (!(option.state & QStyle::State_Active)) + cg = QPalette::Inactive; + else if (!(option.state & QStyle::State_Enabled)) + cg = QPalette::Disabled; + + painter->fillRect(lineNumberAreaRect, QBrush(isSelected ? + option.palette.brush(cg, QPalette::Highlight) : + option.palette.color(cg, QPalette::Base).darker(111))); + + QStyleOptionViewItem opt = option; + opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; + opt.palette.setColor(cg, QPalette::Text, Qt::darkGray); + + const QStyle *style = QApplication::style(); + const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, 0) + 1; + + const QRect rowRect + = lineNumberAreaRect.adjusted(-textMargin, 0, + textMargin - lineNumberAreaHorizontalPadding, 0); + QItemDelegate::drawDisplay(painter, opt, rowRect, lineText); + + return lineNumberAreaWidth; +} + +void HighlightingItemDelegate::drawText(QPainter *painter, + const QStyleOptionViewItem &option, + const QRect &rect, + const QModelIndex &index) const +{ + QString text = index.model()->data(index, Qt::DisplayRole).toString(); + // show number of subresults in displayString + if (index.model()->hasChildren(index)) + text += " (" + QString::number(index.model()->rowCount(index)) + ')'; + + int searchTermStart = index.model()->data(index, int(HighlightingItemRole::StartColumn)).toInt(); + int searchTermLength = index.model()->data(index, int(HighlightingItemRole::Length)).toInt(); + if (searchTermStart < 0 || searchTermStart >= text.length() || searchTermLength < 1) { + drawDisplay(painter, option, rect, text.replace('\t', m_tabString), {}); + return; + } + + // replace tabs with searchTerm bookkeeping + int searchTermEnd = searchTermStart + searchTermLength; + const int tabDiff = m_tabString.size() - 1; + for (int i = 0; i < text.length(); i++) { + if (text.at(i) == '\t') { + text.replace(i, 1, m_tabString); + if (i < searchTermStart) { + searchTermStart += tabDiff; + searchTermEnd += tabDiff; + } else if (i < searchTermEnd) { + searchTermEnd += tabDiff; + searchTermLength += tabDiff; + } + i += tabDiff; + } + } + + const QColor highlightForeground = + index.model()->data(index, int(HighlightingItemRole::Foreground)).value(); + const QColor highlightBackground = + index.model()->data(index, int(HighlightingItemRole::Background)).value(); + QTextCharFormat highlightFormat; + highlightFormat.setForeground(highlightForeground); + highlightFormat.setBackground(highlightBackground); + + drawDisplay(painter, option, rect, text, {{searchTermStart, searchTermLength, highlightFormat}}); +} + +// copied from QItemDelegate for drawDisplay +static QString replaceNewLine(QString text) +{ + static const QChar nl = '\n'; + for (int i = 0; i < text.count(); ++i) + if (text.at(i) == nl) + text[i] = QChar::LineSeparator; + return text; +} + +// copied from QItemDelegate for drawDisplay +QSizeF doTextLayout(QTextLayout *textLayout, int lineWidth) +{ + qreal height = 0; + qreal widthUsed = 0; + textLayout->beginLayout(); + while (true) { + QTextLine line = textLayout->createLine(); + if (!line.isValid()) + break; + line.setLineWidth(lineWidth); + line.setPosition(QPointF(0, height)); + height += line.height(); + widthUsed = qMax(widthUsed, line.naturalTextWidth()); + } + textLayout->endLayout(); + return QSizeF(widthUsed, height); +} + +// copied from QItemDelegate to be able to add the 'format' parameter +void HighlightingItemDelegate::drawDisplay(QPainter *painter, + const QStyleOptionViewItem &option, + const QRect &rect, const QString &text, + const QVector &format) const +{ + QPalette::ColorGroup cg = option.state & QStyle::State_Enabled + ? QPalette::Normal : QPalette::Disabled; + if (cg == QPalette::Normal && !(option.state & QStyle::State_Active)) + cg = QPalette::Inactive; + if (option.state & QStyle::State_Selected) { + painter->fillRect(rect, option.palette.brush(cg, QPalette::Highlight)); + painter->setPen(option.palette.color(cg, QPalette::HighlightedText)); + } else { + painter->setPen(option.palette.color(cg, QPalette::Text)); + } + + if (text.isEmpty()) + return; + + if (option.state & QStyle::State_Editing) { + painter->save(); + painter->setPen(option.palette.color(cg, QPalette::Text)); + painter->drawRect(rect.adjusted(0, 0, -1, -1)); + painter->restore(); + } + + const QStyleOptionViewItem opt = option; + + const QWidget *widget = option.widget; + QStyle *style = widget ? widget->style() : QApplication::style(); + const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1; + QRect textRect = rect.adjusted(textMargin, 0, -textMargin, 0); // remove width padding + const bool wrapText = opt.features & QStyleOptionViewItem::WrapText; + QTextOption textOption; + textOption.setWrapMode(wrapText ? QTextOption::WordWrap : QTextOption::ManualWrap); + textOption.setTextDirection(option.direction); + textOption.setAlignment(QStyle::visualAlignment(option.direction, option.displayAlignment)); + QTextLayout textLayout; + textLayout.setTextOption(textOption); + textLayout.setFont(option.font); + textLayout.setText(replaceNewLine(text)); + + QSizeF textLayoutSize = doTextLayout(&textLayout, textRect.width()); + + if (textRect.width() < textLayoutSize.width() + || textRect.height() < textLayoutSize.height()) { + QString elided; + int start = 0; + int end = text.indexOf(QChar::LineSeparator, start); + if (end == -1) { + elided += option.fontMetrics.elidedText(text, option.textElideMode, textRect.width()); + } else { + while (end != -1) { + elided += option.fontMetrics.elidedText(text.mid(start, end - start), + option.textElideMode, textRect.width()); + elided += QChar::LineSeparator; + start = end + 1; + end = text.indexOf(QChar::LineSeparator, start); + } + // let's add the last line (after the last QChar::LineSeparator) + elided += option.fontMetrics.elidedText(text.mid(start), + option.textElideMode, textRect.width()); + } + textLayout.setText(elided); + textLayoutSize = doTextLayout(&textLayout, textRect.width()); + } + + const QSize layoutSize(textRect.width(), int(textLayoutSize.height())); + const QRect layoutRect = QStyle::alignedRect(option.direction, option.displayAlignment, + layoutSize, textRect); + // if we still overflow even after eliding the text, enable clipping + if (!hasClipping() && (textRect.width() < textLayoutSize.width() + || textRect.height() < textLayoutSize.height())) { + painter->save(); + painter->setClipRect(layoutRect); + textLayout.draw(painter, layoutRect.topLeft(), format, layoutRect); + painter->restore(); + } else { + textLayout.draw(painter, layoutRect.topLeft(), format, layoutRect); + } +} + +} // namespace Utils diff --git a/src/plugins/android/javacompletionassistprovider.h b/src/libs/utils/highlightingitemdelegate.h similarity index 52% rename from src/plugins/android/javacompletionassistprovider.h rename to src/libs/utils/highlightingitemdelegate.h index 277f5c45476..b9cfb617ddf 100644 --- a/src/plugins/android/javacompletionassistprovider.h +++ b/src/libs/utils/highlightingitemdelegate.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of Qt Creator. @@ -25,28 +25,37 @@ #pragma once -#include +#include "utils_global.h" -#include +#include +#include -namespace Android { -namespace Internal { +namespace Utils { -class JavaCompletionAssistProvider : public TextEditor::CompletionAssistProvider -{ - Q_OBJECT - -public: - JavaCompletionAssistProvider(); - ~JavaCompletionAssistProvider(); - - void init() const; - - TextEditor::IAssistProcessor *createProcessor() const; - -private: - mutable QStringList m_keywords; +enum class HighlightingItemRole { + LineNumber = Qt::UserRole, + StartColumn, + Length, + Foreground, + Background, + User }; -} // namespace Internal -} // namespace Android +class QTCREATOR_UTILS_EXPORT HighlightingItemDelegate : public QItemDelegate +{ +public: + HighlightingItemDelegate(int tabWidth, QObject *parent = 0); + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; + void setTabWidth(int width); + +private: + int drawLineNumber(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, const QModelIndex &index) const; + void drawText(QPainter *painter, const QStyleOptionViewItem &option, + const QRect &rect, const QModelIndex &index) const; + using QItemDelegate::drawDisplay; + void drawDisplay(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, + const QString &text, const QVector &format) const; + QString m_tabString; +}; + +} // namespace Utils diff --git a/src/libs/utils/icon.cpp b/src/libs/utils/icon.cpp index e3a9a92ee89..f451d9697e2 100644 --- a/src/libs/utils/icon.cpp +++ b/src/libs/utils/icon.cpp @@ -36,6 +36,7 @@ #include #include #include +#include namespace Utils { @@ -67,7 +68,12 @@ static MasksAndColors masksAndColors(const Icon &icon, int dpr) const QColor color = creatorTheme()->color(i.second); const QString dprFileName = StyleHelper::availableImageResolutions(i.first).contains(dpr) ? StyleHelper::imageFileWithResolution(fileName, dpr) : fileName; - result.append(qMakePair(QPixmap(dprFileName), color)); + QPixmap pixmap; + if (!pixmap.load(dprFileName)) { + pixmap = QPixmap(1, 1); + qWarning() << "Could not load image: " << dprFileName; + } + result.append({pixmap, color}); } return result; } diff --git a/src/libs/utils/stringutils.cpp b/src/libs/utils/stringutils.cpp index b69bfe6f971..f2a13991cb2 100644 --- a/src/libs/utils/stringutils.cpp +++ b/src/libs/utils/stringutils.cpp @@ -28,8 +28,11 @@ #include "hostosinfo.h" #include +#include #include +#include +#include #include #include @@ -246,4 +249,24 @@ QTCREATOR_UTILS_EXPORT QString stripAccelerator(const QString &text) return res; } +QTCREATOR_UTILS_EXPORT bool readMultiLineString(const QJsonValue &value, QString *out) +{ + QTC_ASSERT(out, return false); + if (value.isString()) { + *out = value.toString(); + } else if (value.isArray()) { + QJsonArray array = value.toArray(); + QStringList lines; + foreach (const QJsonValue &v, array) { + if (!v.isString()) + return false; + lines.append(v.toString()); + } + *out = lines.join(QLatin1Char('\n')); + } else { + return false; + } + return true; +} + } // namespace Utils diff --git a/src/libs/utils/stringutils.h b/src/libs/utils/stringutils.h index 8ff42bac6a4..0723e76656f 100644 --- a/src/libs/utils/stringutils.h +++ b/src/libs/utils/stringutils.h @@ -28,6 +28,7 @@ #include "utils_global.h" QT_BEGIN_NAMESPACE +class QJsonValue; class QStringList; QT_END_NAMESPACE @@ -53,6 +54,8 @@ QTCREATOR_UTILS_EXPORT QString withTildeHomePath(const QString &path); // Removes first unescaped ampersand in text QTCREATOR_UTILS_EXPORT QString stripAccelerator(const QString &text); +QTCREATOR_UTILS_EXPORT bool readMultiLineString(const QJsonValue &value, QString *out); + class QTCREATOR_UTILS_EXPORT AbstractMacroExpander { public: diff --git a/src/libs/utils/utils-lib.pri b/src/libs/utils/utils-lib.pri index 3a6aa0a09af..578e0a8d5e4 100644 --- a/src/libs/utils/utils-lib.pri +++ b/src/libs/utils/utils-lib.pri @@ -113,7 +113,8 @@ SOURCES += $$PWD/environment.cpp \ $$PWD/port.cpp \ $$PWD/runextensions.cpp \ $$PWD/utilsicons.cpp \ - $$PWD/guard.cpp + $$PWD/guard.cpp \ + $$PWD/highlightingitemdelegate.cpp win32:SOURCES += $$PWD/consoleprocess_win.cpp else:SOURCES += $$PWD/consoleprocess_unix.cpp @@ -239,8 +240,9 @@ HEADERS += \ $$PWD/asconst.h \ $$PWD/smallstringfwd.h \ $$PWD/optional.h \ + $$PWD/../3rdparty/optional/optional.hpp \ $$PWD/qtcfallthrough.h \ - $$PWD/../3rdparty/optional/optional.hpp + $$PWD/highlightingitemdelegate.cpp FORMS += $$PWD/filewizardpage.ui \ $$PWD/projectintropage.ui \ diff --git a/src/libs/utils/utils.qbs b/src/libs/utils/utils.qbs index 6d68683fdd5..0c0562acaf7 100644 --- a/src/libs/utils/utils.qbs +++ b/src/libs/utils/utils.qbs @@ -117,6 +117,8 @@ Project { "functiontraits.h", "guard.cpp", "guard.h", + "highlightingitemdelegate.cpp", + "highlightingitemdelegate.h", "historycompleter.cpp", "historycompleter.h", "hostosinfo.h", diff --git a/src/plugins/android/android.pro b/src/plugins/android/android.pro index d4bbcb95d39..67cc03f6ca4 100644 --- a/src/plugins/android/android.pro +++ b/src/plugins/android/android.pro @@ -41,7 +41,6 @@ HEADERS += \ androidsignaloperation.h \ javaeditor.h \ javaindenter.h \ - javacompletionassistprovider.h \ avddialog.h \ android_global.h \ androidbuildapkstep.h \ @@ -86,7 +85,6 @@ SOURCES += \ androidsignaloperation.cpp \ javaeditor.cpp \ javaindenter.cpp \ - javacompletionassistprovider.cpp \ avddialog.cpp \ androidbuildapkstep.cpp \ androidbuildapkwidget.cpp \ diff --git a/src/plugins/android/android.qbs b/src/plugins/android/android.qbs index af7106439f3..4fccdaddcf8 100644 --- a/src/plugins/android/android.qbs +++ b/src/plugins/android/android.qbs @@ -107,8 +107,6 @@ Project { "avddialog.h", "certificatesmodel.cpp", "certificatesmodel.h", - "javacompletionassistprovider.cpp", - "javacompletionassistprovider.h", "javaeditor.cpp", "javaeditor.h", "javaindenter.cpp", diff --git a/src/plugins/android/androidplugin.cpp b/src/plugins/android/androidplugin.cpp index c73b73d4835..2af142e0d31 100644 --- a/src/plugins/android/androidplugin.cpp +++ b/src/plugins/android/androidplugin.cpp @@ -42,7 +42,6 @@ #include "androidruncontrol.h" #include "androidsettingspage.h" #include "androidtoolchain.h" -#include "javacompletionassistprovider.h" #include "javaeditor.h" #ifdef HAVE_QBS diff --git a/src/plugins/android/androidrunconfigurationwidget.ui b/src/plugins/android/androidrunconfigurationwidget.ui index 5cfee96dc89..c028aeaa803 100644 --- a/src/plugins/android/androidrunconfigurationwidget.ui +++ b/src/plugins/android/androidrunconfigurationwidget.ui @@ -78,7 +78,7 @@ - Conflicting "am start" options might result in the app startup failure. + If the "am start" options conflict, the application might not start. diff --git a/src/plugins/android/javacompletionassistprovider.cpp b/src/plugins/android/javacompletionassistprovider.cpp deleted file mode 100644 index a237c570add..00000000000 --- a/src/plugins/android/javacompletionassistprovider.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** 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 "javacompletionassistprovider.h" -#include "androidconstants.h" - -#include -#include -#include - -using namespace Android; -using namespace Android::Internal; - -static const char *const keywords[] = { - "abstract", - "continue", - "for", - "new", - "switch", - "assert", - "default", - "goto", - "package", - "synchronized", - "boolean", - "do", - "if", - "private", - "this", - "break", - "double", - "implements", - "protected", - "throw", - "byte", - "else", - "import", - "public", - "throws", - "case", - "enum", - "instanceof", - "return", - "transient", - "catch", - "extends", - "int", - "short", - "try", - "char", - "final", - "interface", - "static", - "void", - "class", - "finally", - "long", - "strictfp", - "volatile", - "const", - "float", - "native", - "super", - "while", - 0 -}; - -JavaCompletionAssistProvider::JavaCompletionAssistProvider() -{ -} - -JavaCompletionAssistProvider::~JavaCompletionAssistProvider() -{ - -} - -void JavaCompletionAssistProvider::init() const -{ - for (uint i = 0; i < sizeof keywords / sizeof keywords[0] - 1; i++) - m_keywords.append(QLatin1String(keywords[i])); -} - -TextEditor::IAssistProcessor *JavaCompletionAssistProvider::createProcessor() const -{ - if (m_keywords.isEmpty()) - init(); - TextEditor::Keywords keywords = TextEditor::Keywords(m_keywords, - QStringList(), - QMap()); - return new TextEditor::KeywordsCompletionAssistProcessor(keywords); -} diff --git a/src/plugins/android/javaeditor.cpp b/src/plugins/android/javaeditor.cpp index 6cddfa95a6a..81c3112219f 100644 --- a/src/plugins/android/javaeditor.cpp +++ b/src/plugins/android/javaeditor.cpp @@ -26,8 +26,8 @@ #include "javaeditor.h" #include "javaindenter.h" #include "androidconstants.h" -#include "javacompletionassistprovider.h" +#include #include #include #include @@ -59,6 +59,14 @@ static TextEditor::TextDocument *createJavaDocument() JavaEditorFactory::JavaEditorFactory() { + static QStringList keywords = { + "abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class", "const", + "continue", "default", "do", "double", "else", "enum", "extends", "final", "finally", + "float", "for", "goto", "if", "implements", "import", "instanceof", "int", "interface", + "long", "native", "new", "package", "private", "protected", "public", "return", "short", + "static", "strictfp", "super", "switch", "synchronized", "this", "throw", "throws", + "transient", "try", "void", "volatile", "while" + }; setId(Constants::JAVA_EDITOR_ID); setDisplayName(tr("Java Editor")); addMimeType(Constants::JAVA_MIMETYPE); @@ -67,8 +75,8 @@ JavaEditorFactory::JavaEditorFactory() setUseGenericHighlighter(true); setCommentDefinition(Utils::CommentDefinition::CppStyle); setEditorActionHandlers(TextEditor::TextEditorActionHandler::UnCommentSelection); - setCompletionAssistProvider(new JavaCompletionAssistProvider); setMarksVisible(true); + setCompletionAssistProvider(new TextEditor::KeywordsCompletionAssistProvider(keywords)); } } // namespace Internal diff --git a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp index 6b0f995ecea..e29f72ae9ef 100644 --- a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp +++ b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp @@ -47,6 +47,7 @@ #include #include +#include #include #include #include @@ -274,6 +275,9 @@ void ClangEditorDocumentProcessor::addDiagnosticToolTipToLayout(uint line, = m_diagnosticManager.diagnosticsAt(line, column); target->addWidget(ClangDiagnosticWidget::create(diagnostics, ClangDiagnosticWidget::ToolTip)); + auto link = TextEditor::DisplaySettings::createAnnotationSettingsLink(); + target->addWidget(link); + target->setAlignment(link, Qt::AlignRight); } void ClangEditorDocumentProcessor::editorDocumentTimerRestarted() diff --git a/src/plugins/clearcase/versionselector.cpp b/src/plugins/clearcase/versionselector.cpp index 70f920cf73f..42067fd0417 100644 --- a/src/plugins/clearcase/versionselector.cpp +++ b/src/plugins/clearcase/versionselector.cpp @@ -39,7 +39,7 @@ VersionSelector::VersionSelector(const QString &fileName, const QString &message { ui->setupUi(this); ui->headerLabel->setText(ui->headerLabel->text().arg(fileName)); - ui->loadedText->setHtml(tr("

NOTE: You will not be able to check in " + ui->loadedText->setHtml(tr("

Note: You will not be able to check in " "this file without merging the changes (not supported by the " "plugin)

")); m_stream = new QTextStream(message.toLocal8Bit(), QIODevice::ReadOnly | QIODevice::Text); diff --git a/src/plugins/clearcase/versionselector.ui b/src/plugins/clearcase/versionselector.ui index d69b901d3cf..7e1c9b620bc 100644 --- a/src/plugins/clearcase/versionselector.ui +++ b/src/plugins/clearcase/versionselector.ui @@ -17,7 +17,7 @@ - There are multiple versions of '%1' which can be considered for checkout. Please select version to checkout: + Multiple versions of "%1" can be checked out. Select the version to check out: true @@ -32,7 +32,7 @@ - &Loaded Version + &Loaded version true diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp index a51d418a6c7..c005b90eaa9 100644 --- a/src/plugins/coreplugin/coreplugin.cpp +++ b/src/plugins/coreplugin/coreplugin.cpp @@ -132,7 +132,7 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage) const QJsonObject metaData = plugin->metaData(); const QJsonValue mimetypes = metaData.value("Mimetypes"); QString mimetypeString; - if (ExtensionSystem::PluginSpec::readMultiLineString(mimetypes, &mimetypeString)) + if (Utils::readMultiLineString(mimetypes, &mimetypeString)) Utils::addMimeTypes(plugin->name() + ".mimetypes", mimetypeString.trimmed().toUtf8()); } diff --git a/src/plugins/coreplugin/find/searchresultwidget.cpp b/src/plugins/coreplugin/find/searchresultwidget.cpp index b09fc6e8fd9..9eee8dee632 100644 --- a/src/plugins/coreplugin/find/searchresultwidget.cpp +++ b/src/plugins/coreplugin/find/searchresultwidget.cpp @@ -79,12 +79,7 @@ public: }; SearchResultWidget::SearchResultWidget(QWidget *parent) : - QWidget(parent), - m_count(0), - m_preserveCaseSupported(true), - m_isShowingReplaceUI(false), - m_searchAgainSupported(false), - m_replaceSupported(false) + QWidget(parent) { QVBoxLayout *layout = new QVBoxLayout(this); layout->setMargin(0); @@ -295,8 +290,6 @@ void SearchResultWidget::addResults(const QList &items, Search } } - - int SearchResultWidget::count() const { return m_count; @@ -309,7 +302,6 @@ void SearchResultWidget::setSupportsReplace(bool replaceSupported, const QString m_dontAskAgainGroup = group; } - void SearchResultWidget::setTextToReplace(const QString &textToReplace) { m_replaceTextEdit->setText(textToReplace); diff --git a/src/plugins/coreplugin/find/searchresultwidget.h b/src/plugins/coreplugin/find/searchresultwidget.h index 5c5e3374a6f..5309ed69e1e 100644 --- a/src/plugins/coreplugin/find/searchresultwidget.h +++ b/src/plugins/coreplugin/find/searchresultwidget.h @@ -119,28 +119,28 @@ private: QList checkedItems() const; void updateMatchesFoundLabel(); - SearchResultTreeView *m_searchResultTreeView; - int m_count; + SearchResultTreeView *m_searchResultTreeView = nullptr; + int m_count = 0; QString m_dontAskAgainGroup; - QFrame *m_messageWidget; + QFrame *m_messageWidget = nullptr; InfoBar m_infoBar; InfoBarDisplay m_infoBarDisplay; - QWidget *m_topReplaceWidget; - QLabel *m_replaceLabel; - QLineEdit *m_replaceTextEdit; - QToolButton *m_replaceButton; - QToolButton *m_searchAgainButton; - QCheckBox *m_preserveCaseCheck; + QWidget *m_topReplaceWidget = nullptr; + QLabel *m_replaceLabel = nullptr; + QLineEdit *m_replaceTextEdit = nullptr; + QToolButton *m_replaceButton = nullptr; + QToolButton *m_searchAgainButton = nullptr; + QCheckBox *m_preserveCaseCheck = nullptr; QCheckBox *m_renameFilesCheckBox = nullptr; - QWidget *m_descriptionContainer; - QLabel *m_label; - QLabel *m_searchTerm; - QToolButton *m_cancelButton; - QLabel *m_matchesFoundLabel; - bool m_preserveCaseSupported; - bool m_isShowingReplaceUI; - bool m_searchAgainSupported; - bool m_replaceSupported; + QWidget *m_descriptionContainer = nullptr; + QLabel *m_label = nullptr; + QLabel *m_searchTerm = nullptr; + QToolButton *m_cancelButton = nullptr; + QLabel *m_matchesFoundLabel = nullptr; + bool m_preserveCaseSupported = true; + bool m_isShowingReplaceUI = false; + bool m_searchAgainSupported = false; + bool m_replaceSupported = false; }; } // Internal diff --git a/src/plugins/coreplugin/locator/locatorwidget.cpp b/src/plugins/coreplugin/locator/locatorwidget.cpp index 3c09e0a32f4..63abc858fc5 100644 --- a/src/plugins/coreplugin/locator/locatorwidget.cpp +++ b/src/plugins/coreplugin/locator/locatorwidget.cpp @@ -33,14 +33,13 @@ #include #include #include -#include -#include #include #include #include #include #include #include +#include #include #include #include @@ -67,6 +66,10 @@ Q_DECLARE_METATYPE(Core::LocatorFilterEntry) +using namespace Utils; + +const int LocatorEntryRole = int(HighlightingItemRole::User); + namespace Core { namespace Internal { @@ -99,7 +102,7 @@ private: QColor mBackgroundColor; }; -class CompletionDelegate : public SearchResultTreeItemDelegate +class CompletionDelegate : public HighlightingItemDelegate { public: CompletionDelegate(QObject *parent); @@ -193,7 +196,6 @@ QVariant LocatorModel::data(const QModelIndex &index, int role) const + QLatin1String("\n\n") + mEntries.at(index.row()).extraInfo); break; case Qt::DecorationRole: - case ItemDataRoles::ResultIconRole: if (index.column() == DisplayNameColumn) { LocatorFilterEntry &entry = mEntries[index.row()]; if (!entry.displayIcon && !entry.fileName.isEmpty()) @@ -205,21 +207,21 @@ QVariant LocatorModel::data(const QModelIndex &index, int role) const if (index.column() == ExtraInfoColumn) return QColor(Qt::darkGray); break; - case ItemDataRoles::ResultItemRole: + case LocatorEntryRole: return qVariantFromValue(mEntries.at(index.row())); - case ItemDataRoles::ResultBeginColumnNumberRole: - case ItemDataRoles::SearchTermLengthRole: { + case int(HighlightingItemRole::StartColumn): + case int(HighlightingItemRole::Length): { LocatorFilterEntry &entry = mEntries[index.row()]; const int highlightColumn = entry.highlightInfo.dataType == LocatorFilterEntry::HighlightInfo::DisplayName ? DisplayNameColumn : ExtraInfoColumn; if (highlightColumn == index.column()) { - const bool startIndexRole = role == ItemDataRoles::ResultBeginColumnNumberRole; + const bool startIndexRole = role == int(HighlightingItemRole::StartColumn); return startIndexRole ? entry.highlightInfo.startIndex : entry.highlightInfo.length; } break; } - case ItemDataRoles::ResultHighlightBackgroundColor: + case int(HighlightingItemRole::Background): return mBackgroundColor; } @@ -843,7 +845,7 @@ void LocatorWidget::acceptEntry(int row) const QModelIndex index = m_locatorModel->index(row, 0); if (!index.isValid()) return; - const LocatorFilterEntry entry = m_locatorModel->data(index, ItemDataRoles::ResultItemRole).value(); + const LocatorFilterEntry entry = m_locatorModel->data(index, LocatorEntryRole).value(); Q_ASSERT(entry.filter != nullptr); QString newText; int selectionStart = -1; @@ -926,13 +928,13 @@ LocatorPopup *createLocatorPopup(Locator *locator, QWidget *parent) } CompletionDelegate::CompletionDelegate(QObject *parent) - : SearchResultTreeItemDelegate(0, parent) + : HighlightingItemDelegate(0, parent) { } QSize CompletionDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { - return SearchResultTreeItemDelegate::sizeHint(option, index) + QSize(0, 2); + return HighlightingItemDelegate::sizeHint(option, index) + QSize(0, 2); } } // namespace Internal diff --git a/src/plugins/coreplugin/navigationwidget.cpp b/src/plugins/coreplugin/navigationwidget.cpp index 61d9feb63df..ff9c6cc5810 100644 --- a/src/plugins/coreplugin/navigationwidget.cpp +++ b/src/plugins/coreplugin/navigationwidget.cpp @@ -312,6 +312,15 @@ void NavigationWidget::resizeEvent(QResizeEvent *re) MiniSplitter::resizeEvent(re); } +static QIcon closeIconForSide(Side side, int itemCount) +{ + if (itemCount > 1) + return Utils::Icons::CLOSE_SPLIT_TOP.icon(); + return side == Side::Left + ? Utils::Icons::CLOSE_SPLIT_LEFT.icon() + : Utils::Icons::CLOSE_SPLIT_RIGHT.icon(); +} + Internal::NavigationSubWidget *NavigationWidget::insertSubItem(int position, int factoryIndex) { for (int pos = position + 1; pos < d->m_subWidgets.size(); ++pos) { @@ -331,9 +340,7 @@ Internal::NavigationSubWidget *NavigationWidget::insertSubItem(int position, int insertWidget(position, nsw); d->m_subWidgets.insert(position, nsw); - d->m_subWidgets.at(0)->setCloseIcon(d->m_subWidgets.size() == 1 - ? Utils::Icons::CLOSE_SPLIT_LEFT.icon() - : Utils::Icons::CLOSE_SPLIT_TOP.icon()); + d->m_subWidgets.at(0)->setCloseIcon(closeIconForSide(d->m_side, d->m_subWidgets.size())); NavigationWidgetPrivate::updateActivationsMap(nsw->factory()->id(), {d->m_side, position}); return nsw; } @@ -386,10 +393,8 @@ void NavigationWidget::closeSubWidget() subWidget->hide(); subWidget->deleteLater(); // update close button of top item - if (d->m_subWidgets.size() == 1) - d->m_subWidgets.at(0)->setCloseIcon(d->m_subWidgets.size() == 1 - ? Utils::Icons::CLOSE_SPLIT_LEFT.icon() - : Utils::Icons::CLOSE_SPLIT_TOP.icon()); + if (!d->m_subWidgets.isEmpty()) + d->m_subWidgets.at(0)->setCloseIcon(closeIconForSide(d->m_side, d->m_subWidgets.size())); } else { setShown(false); } diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp index 32cace3e149..c069b3514e7 100644 --- a/src/plugins/cpptools/cppfindreferences.cpp +++ b/src/plugins/cpptools/cppfindreferences.cpp @@ -25,6 +25,7 @@ #include "cppfindreferences.h" +#include "cppfilesettingspage.h" #include "cpptoolsconstants.h" #include "cppmodelmanager.h" #include "cppworkingcopy.h" @@ -384,6 +385,11 @@ void CppFindReferences::findAll_helper(SearchResult *search, Symbol *symbol, connect(progress, &FutureProgress::clicked, search, &SearchResult::popup); } +static bool isAllLowerCase(const QString &text) +{ + return text.toLower() == text; +} + void CppFindReferences::onReplaceButtonClicked(const QString &text, const QList &items, bool preserveCase) @@ -405,21 +411,40 @@ void CppFindReferences::onReplaceButtonClicked(const QString &text, if (!renameFilesCheckBox || !renameFilesCheckBox->isChecked()) return; + CppFileSettings settings; + settings.fromSettings(Core::ICore::settings()); + const QStringList newPaths = Utils::transform(parameters.filesToRename, - [¶meters, text](const Node *node) -> QString { + [¶meters, text, &settings](const Node *node) -> QString { const QFileInfo fi = node->filePath().toFileInfo(); - const QString fileName = fi.fileName(); - QString newName = fileName; - newName.replace(parameters.prettySymbolName, text, Qt::CaseInsensitive); + const QString oldSymbolName = parameters.prettySymbolName; + const QString oldBaseName = fi.baseName(); + const QString newSymbolName = text; + QString newBaseName = newSymbolName; - if (newName != fileName) { - newName = Utils::matchCaseReplacement(fileName, newName); + // 1) new symbol lowercase: new base name lowercase + if (isAllLowerCase(newSymbolName)) { + newBaseName = newSymbolName; - return fi.absolutePath() + "/" + newName; + // 2) old base name mixed case: new base name is verbatim symbol name + } else if (!isAllLowerCase(oldBaseName)) { + newBaseName = newSymbolName; + + // 3) old base name lowercase, old symbol mixed case: new base name lowercase + } else if (!isAllLowerCase(oldSymbolName)) { + newBaseName = newSymbolName.toLower(); + + // 4) old base name lowercase, old symbol lowercase, new symbol mixed case: + // use the preferences setting for new base name case + } else if (settings.lowerCaseFiles) { + newBaseName = newSymbolName.toLower(); } - return QString(); + if (newBaseName == oldBaseName) + return QString(); + + return fi.absolutePath() + "/" + newBaseName + '.' + fi.completeSuffix(); }); for (int i = 0; i < parameters.filesToRename.size(); ++i) { diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index efc1680458e..543ad8f8190 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -2030,7 +2030,11 @@ void DebuggerEngine::checkState(DebuggerState state, const char *file, int line) bool DebuggerEngine::isNativeMixedEnabled() const { - return runParameters().nativeMixedEnabled && (runParameters().languages & QmlLanguage); + if (DebuggerRunTool *rt = runTool()) { + const DebuggerRunParameters &runParams = rt->runParameters(); + return runParams.nativeMixedEnabled && (runParams.languages & QmlLanguage); + } + return false; } bool DebuggerEngine::isNativeMixedActive() const diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 580749f2f16..fd3f8892f3d 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -4034,7 +4034,10 @@ void GdbEngine::reloadDebuggingHelpers() void GdbEngine::handleGdbError(QProcess::ProcessError error) { - QString program = runParameters().debugger.executable; + QString program; + // avoid accessing invalid memory if the process crashed + if (runTool()) + program = runParameters().debugger.executable; QString msg = RunWorker::userMessageForProcessError(error, program); QString errorString = m_gdbProc.errorString(); if (!errorString.isEmpty()) diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index 74fd2ba37d8..ae1c324c304 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -1065,7 +1065,7 @@ bool GitClient::synchronousReset(const QString &workingDirectory, if (files.isEmpty()) { msgCannotRun(arguments, workingDirectory, resp.stdErr(), errorMessage); } else { - msgCannotRun(tr("Cannot reset %n file(s) in \"%1\": %2", 0, files.size()) + msgCannotRun(tr("Cannot reset %n files in \"%1\": %2", 0, files.size()) .arg(QDir::toNativeSeparators(workingDirectory), resp.stdErr()), errorMessage); } @@ -2468,9 +2468,9 @@ bool GitClient::getCommitData(const QString &workingDirectory, static inline QString msgCommitted(const QString &amendSHA1, int fileCount) { if (amendSHA1.isEmpty()) - return GitClient::tr("Committed %n file(s).", 0, fileCount) + '\n'; + return GitClient::tr("Committed %n files.", 0, fileCount) + '\n'; if (fileCount) - return GitClient::tr("Amended \"%1\" (%n file(s)).", 0, fileCount).arg(amendSHA1) + '\n'; + return GitClient::tr("Amended \"%1\" (%n files).", 0, fileCount).arg(amendSHA1) + '\n'; return GitClient::tr("Amended \"%1\".").arg(amendSHA1); } @@ -2561,7 +2561,7 @@ bool GitClient::addAndCommit(const QString &repositoryDirectory, VcsOutputWindow::appendError(stdErr); return true; } else { - VcsOutputWindow::appendError(tr("Cannot commit %n file(s): %1\n", 0, commitCount).arg(stdErr)); + VcsOutputWindow::appendError(tr("Cannot commit %n files: %1\n", 0, commitCount).arg(stdErr)); return false; } } diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index df286c0fee7..311127aaa7e 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -716,9 +716,11 @@ void GitPlugin::blameFile() cursor.setPosition(selectionStart); const int startBlock = cursor.blockNumber(); cursor.setPosition(selectionEnd); - const int endBlock = cursor.blockNumber(); + int endBlock = cursor.blockNumber(); if (startBlock != endBlock) { firstLine = startBlock + 1; + if (cursor.atBlockStart()) + --endBlock; if (auto widget = qobject_cast(textEditor->widget())) { const int previousFirstLine = widget->firstLineNumber(); if (previousFirstLine > 0) diff --git a/src/plugins/help/helpindexfilter.cpp b/src/plugins/help/helpindexfilter.cpp index 0428ee9c83d..e808f1b9d11 100644 --- a/src/plugins/help/helpindexfilter.cpp +++ b/src/plugins/help/helpindexfilter.cpp @@ -145,11 +145,7 @@ void HelpIndexFilter::accept(LocatorFilterEntry selection, Q_UNUSED(selectionLength) const QString &key = selection.displayName; const QMap &links = HelpManager::linksForKeyword(key); - - if (links.size() == 1) - emit linkActivated(links.begin().value()); - else - emit linksActivated(links, key); + emit linksActivated(links, key); } void HelpIndexFilter::refresh(QFutureInterface &future) diff --git a/src/plugins/help/helpindexfilter.h b/src/plugins/help/helpindexfilter.h index 1cf1f412975..b8e321cbcb3 100644 --- a/src/plugins/help/helpindexfilter.h +++ b/src/plugins/help/helpindexfilter.h @@ -52,7 +52,6 @@ public: Q_INVOKABLE QSet searchMatches(const QString &databaseFilePath, const QString &term, int limit); signals: - void linkActivated(const QUrl &link) const; void linksActivated(const QMap &links, const QString &key) const; private: diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index ef03175df61..39fe63a376e 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -236,10 +236,8 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error) auto helpIndexFilter = new HelpIndexFilter(); addAutoReleasedObject(helpIndexFilter); - connect(helpIndexFilter, &HelpIndexFilter::linkActivated, - this, &HelpPlugin::showLinkInHelpMode); connect(helpIndexFilter, &HelpIndexFilter::linksActivated, - this, &HelpPlugin::showLinksInHelpMode); + this, &HelpPlugin::showLinksInCurrentViewer); RemoteHelpFilter *remoteHelpFilter = new RemoteHelpFilter(); addAutoReleasedObject(remoteHelpFilter); @@ -430,11 +428,12 @@ void HelpPlugin::showLinkInHelpMode(const QUrl &source) showInHelpViewer(source, helpModeHelpViewer()); } -void HelpPlugin::showLinksInHelpMode(const QMap &links, const QString &key) +void HelpPlugin::showLinksInCurrentViewer(const QMap &links, const QString &key) { - activateHelpMode(); - ICore::raiseWindow(m_mode->widget()); - m_centralWidget->showTopicChooser(links, key); + if (links.size() < 1) + return; + HelpWidget *widget = helpWidgetForWindow(QApplication::activeWindow()); + widget->showLinks(links, key); } void HelpPlugin::slotHideRightPane() @@ -499,6 +498,14 @@ HelpViewer *HelpPlugin::helpModeHelpViewer() return viewer; } +HelpWidget *HelpPlugin::helpWidgetForWindow(QWidget *window) +{ + if (m_externalWindow && m_externalWindow->window() == window->window()) + return m_externalWindow; + activateHelpMode(); + return m_centralWidget; +} + HelpViewer *HelpPlugin::viewerForHelpViewerLocation(HelpManager::HelpViewerLocation location) { HelpManager::HelpViewerLocation actualLocation = location; diff --git a/src/plugins/help/helpplugin.h b/src/plugins/help/helpplugin.h index 4e02e5d3fb8..d6985733efb 100644 --- a/src/plugins/help/helpplugin.h +++ b/src/plugins/help/helpplugin.h @@ -89,7 +89,7 @@ private: void saveExternalWindowSettings(); void showLinkInHelpMode(const QUrl &source); - void showLinksInHelpMode(const QMap &links, const QString &key); + void showLinksInCurrentViewer(const QMap &links, const QString &key); void slotHideRightPane(); void updateSideBarSource(const QUrl &newUrl); @@ -109,6 +109,7 @@ private: void createRightPaneContextViewer(); HelpViewer *externalHelpViewer(); HelpViewer *helpModeHelpViewer(); + HelpWidget *helpWidgetForWindow(QWidget *window); void doSetupIfNeeded(); diff --git a/src/plugins/help/helpwidget.cpp b/src/plugins/help/helpwidget.cpp index 207661cec60..b0e6cb3daf7 100644 --- a/src/plugins/help/helpwidget.cpp +++ b/src/plugins/help/helpwidget.cpp @@ -354,10 +354,8 @@ void HelpWidget::addSideBar() auto indexItem = new Core::SideBarItem(indexWindow, Constants::HELP_INDEX); indexWindow->setOpenInNewPageActionVisible(supportsNewPages); indexWindow->setWindowTitle(HelpPlugin::tr(Constants::SB_INDEX)); - connect(indexWindow, &IndexWindow::linkActivated, - this, &HelpWidget::open); connect(indexWindow, &IndexWindow::linksActivated, - this, &HelpWidget::showTopicChooser); + this, &HelpWidget::showLinks); m_indexAction = new QAction(HelpPlugin::tr(Constants::SB_INDEX), this); cmd = Core::ActionManager::registerAction(m_indexAction, Constants::HELP_INDEX, m_context->context()); cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+I") @@ -535,12 +533,18 @@ void HelpWidget::open(const QUrl &url, bool newPage) setSource(url); } -void HelpWidget::showTopicChooser(const QMap &links, +void HelpWidget::showLinks(const QMap &links, const QString &keyword, bool newPage) { - TopicChooser tc(this, keyword, links); - if (tc.exec() == QDialog::Accepted) - open(tc.link(), newPage); + if (links.size() < 1) + return; + if (links.size() == 1) { + open(links.first(), newPage); + } else { + TopicChooser tc(this, keyword, links); + if (tc.exec() == QDialog::Accepted) + open(tc.link(), newPage); + } } void HelpWidget::activateSideBarItem(const QString &id) diff --git a/src/plugins/help/helpwidget.h b/src/plugins/help/helpwidget.h index 5fa1ad1faab..3e27d28619c 100644 --- a/src/plugins/help/helpwidget.h +++ b/src/plugins/help/helpwidget.h @@ -74,7 +74,7 @@ public: void open(const QUrl &url, bool newPage = false); void openFromSearch(const QUrl &url, const QStringList &searchTerms, bool newPage = false); - void showTopicChooser(const QMap &links, const QString &key, + void showLinks(const QMap &links, const QString &key, bool newPage = false); void activateSideBarItem(const QString &id); diff --git a/src/plugins/ios/iosconfigurations.cpp b/src/plugins/ios/iosconfigurations.cpp index 3881b78a579..68680911154 100644 --- a/src/plugins/ios/iosconfigurations.cpp +++ b/src/plugins/ios/iosconfigurations.cpp @@ -289,7 +289,10 @@ void IosConfigurations::updateAutomaticKitList() continue; } Core::Id pDeviceType = deviceId(sdk.directoryName); - QTC_ASSERT(pDeviceType.isValid(), continue); + if (!pDeviceType.isValid()) { + qCDebug(kitSetupLog) << "Unsupported/Invalid device type" << sdk.directoryName; + continue; + } for (BaseQtVersion *qtVersion : qtVersions) { qCDebug(kitSetupLog) << " - Qt version:" << qtVersion->displayName(); diff --git a/src/plugins/ios/iossettingswidget.cpp b/src/plugins/ios/iossettingswidget.cpp index 8e3ff464e7b..0afe270775d 100644 --- a/src/plugins/ios/iossettingswidget.cpp +++ b/src/plugins/ios/iossettingswidget.cpp @@ -125,7 +125,7 @@ void IosSettingsWidget::onStart() QList> futureList; foreach (const SimulatorInfo &info, simulatorInfoList) { if (!info.isShutdown()) { - statusDialog->addMessage(tr("Cannot start simulator(%1, %2) in current state: %3") + statusDialog->addMessage(tr("Cannot start simulator (%1, %2) in current state: %3") .arg(info.name).arg(info.runtimeName).arg(info.state), Utils::StdErrFormat); } else { @@ -151,10 +151,10 @@ void IosSettingsWidget::onCreate() const auto onSimulatorCreate = [this, statusDialog](const QString &name, const SimulatorControl::ResponseData &response) { if (response.success) { - statusDialog->addMessage(tr("Simulator device(%1) created.\nUDID: %2") + statusDialog->addMessage(tr("Simulator device (%1) created.\nUDID: %2") .arg(name).arg(response.simUdid), Utils::StdOutFormat); } else { - statusDialog->addMessage(tr("Simulator device(%1) creation failed.\nError: %2"). + statusDialog->addMessage(tr("Simulator device (%1) creation failed.\nError: %2"). arg(name).arg(QString::fromUtf8(response.commandOutput)), Utils::StdErrFormat); } @@ -218,6 +218,8 @@ void IosSettingsWidget::onRename() const SimulatorInfo &simInfo = simulatorInfoList.at(0); const QString newName = QInputDialog::getText(this, tr("Rename %1").arg(simInfo.name), tr("Enter new name:")); + if (newName.isEmpty()) + return; QPointer statusDialog = new SimulatorOperationDialog(this); statusDialog->setAttribute(Qt::WA_DeleteOnClose); diff --git a/src/plugins/ios/iostoolhandler.cpp b/src/plugins/ios/iostoolhandler.cpp index 317c1f6f594..1e85d8fcbd4 100644 --- a/src/plugins/ios/iostoolhandler.cpp +++ b/src/plugins/ios/iostoolhandler.cpp @@ -396,7 +396,7 @@ void IosToolHandlerPrivate::toolExited(int code) void IosDeviceToolHandlerPrivate::subprocessError(QProcess::ProcessError error) { if (state != Stopped) - errorMsg(IosToolHandler::tr("iOS tool Error %1").arg(error)); + errorMsg(IosToolHandler::tr("iOS tool error %1").arg(error)); stop(-1); if (error == QProcess::FailedToStart) { qCDebug(toolHandlerLog) << "IosToolHandler::finished(" << this << ")"; @@ -837,7 +837,7 @@ void IosSimulatorToolHandlerPrivate::requestTransferApp(const QString &appBundle if (response.success) { installAppOnSimulator(); } else { - errorMsg(IosToolHandler::tr("Application install on Simulator failed. Simulator not running.")); + errorMsg(IosToolHandler::tr("Application install on simulator failed. Simulator not running.")); didTransferApp(m_bundlePath, m_deviceId, IosToolHandler::Failure); emit q->finished(q); } @@ -862,7 +862,7 @@ void IosSimulatorToolHandlerPrivate::requestRunApp(const QString &appBundlePath, Utils::FileName appBundle = Utils::FileName::fromString(m_bundlePath); if (!appBundle.exists()) { - errorMsg(IosToolHandler::tr("Application launch on Simulator failed. Invalid Bundle path %1") + errorMsg(IosToolHandler::tr("Application launch on simulator failed. Invalid bundle path %1") .arg(m_bundlePath)); didStartApp(m_bundlePath, m_deviceId, Ios::IosToolHandler::Failure); return; @@ -874,7 +874,7 @@ void IosSimulatorToolHandlerPrivate::requestRunApp(const QString &appBundlePath, if (response.success) { launchAppOnSimulator(extraArgs); } else { - errorMsg(IosToolHandler::tr("Application launch on Simulator failed. Simulator not running.")); + errorMsg(IosToolHandler::tr("Application launch on simulator failed. Simulator not running.")); didStartApp(m_bundlePath, m_deviceId, Ios::IosToolHandler::Failure); } }; @@ -926,7 +926,7 @@ void IosSimulatorToolHandlerPrivate::installAppOnSimulator() isTransferringApp(m_bundlePath, m_deviceId, 100, 100, ""); didTransferApp(m_bundlePath, m_deviceId, IosToolHandler::Success); } else { - errorMsg(IosToolHandler::tr("Application install on Simulator failed. %1") + errorMsg(IosToolHandler::tr("Application install on simulator failed. %1") .arg(QString::fromLocal8Bit(response.commandOutput))); didTransferApp(m_bundlePath, m_deviceId, IosToolHandler::Failure); } @@ -990,7 +990,7 @@ void IosSimulatorToolHandlerPrivate::launchAppOnSimulator(const QStringList &ext stderrFile); } else { m_pid = -1; - errorMsg(IosToolHandler::tr("Application launch on Simulator failed. %1") + errorMsg(IosToolHandler::tr("Application launch on simulator failed. %1") .arg(QString::fromLocal8Bit(response.commandOutput))); didStartApp(m_bundlePath, m_deviceId, Ios::IosToolHandler::Failure); stop(-1); diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardpagefactory_p.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardpagefactory_p.cpp index 89fa6cb23b6..58c0e20030b 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardpagefactory_p.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardpagefactory_p.cpp @@ -82,7 +82,7 @@ bool FieldPageFactory::validateData(Core::Id typeId, const QVariant &data, QStri QList list = JsonWizardFactory::objectOrList(data, errorMessage); if (list.isEmpty()) { *errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard", - "When parsing fields of page '%1': %2") + "When parsing fields of page \"%1\": %2") .arg(typeId.toString()).arg(*errorMessage); return false; } diff --git a/src/plugins/projectexplorer/msvctoolchain.cpp b/src/plugins/projectexplorer/msvctoolchain.cpp index 56ea77ad459..2562b7fcc4b 100644 --- a/src/plugins/projectexplorer/msvctoolchain.cpp +++ b/src/plugins/projectexplorer/msvctoolchain.cpp @@ -29,6 +29,7 @@ #include "projectexplorerconstants.h" #include +#include #include #include #include @@ -102,7 +103,7 @@ static bool hostSupportsPlatform(MsvcToolChain::Platform platform) if (platform == MsvcToolChain::amd64 || platform == MsvcToolChain::amd64_arm || platform == MsvcToolChain::amd64_x86) return true; - // fall through (all x86 toolchains are also working on an amd64 host) + Q_FALLTHROUGH(); // all x86 toolchains are also working on an amd64 host case Utils::HostOsInfo::HostArchitectureX86: return platform == MsvcToolChain::x86 || platform == MsvcToolChain::x86_amd64 || platform == MsvcToolChain::x86_ia64 || platform == MsvcToolChain::x86_arm; diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index e8f41dcb66d..b1b55f70d57 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -1488,7 +1488,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er }); expander->registerFileVariables("CurrentRun:Executable", - tr("The currently active run configuration's executable (if applicable)"), + tr("The currently active run configuration's executable (if applicable)."), [this]() -> QString { if (Target *target = activeTarget()) { if (RunConfiguration *rc = target->activeRunConfiguration()) { @@ -1847,7 +1847,7 @@ ProjectExplorerPlugin::OpenProjectResult ProjectExplorerPlugin::openProjects(con if (ProjectManager::canOpenProjectForMimeType(mt)) { if (!QFileInfo(filePath).isFile()) { appendError(errorString, - tr("Failed opening project \"%1\": Project is not a file").arg(fileName)); + tr("Failed opening project \"%1\": Project is not a file.").arg(fileName)); } else if (Project *pro = ProjectManager::openProject(mt, Utils::FileName::fromString(filePath))) { QObject::connect(pro, &Project::parsingFinished, [pro]() { emit SessionManager::instance()->projectFinishedParsing(pro); diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index b0f06be3583..6c4336ecba9 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -936,7 +936,7 @@ void RunControlPrivate::onWorkerStarted(RunWorker *worker) continueStart(); return; } - showError(tr("Unexpected run control state %1 when worker %2 started") + showError(tr("Unexpected run control state %1 when worker %2 started.") .arg(stateName(state)) .arg(worker->d->id)); } @@ -1467,11 +1467,11 @@ bool RunWorkerPrivate::canStart() const void RunWorkerPrivate::timerEvent(QTimerEvent *ev) { if (ev->timerId() == startWatchdogTimerId) { - q->reportFailure(tr("Worker start timed out")); + q->reportFailure(tr("Worker start timed out.")); return; } if (ev->timerId() == stopWatchdogTimerId) { - q->reportFailure(tr("Worker stop timed out")); + q->reportFailure(tr("Worker stop timed out.")); return; } } @@ -1610,7 +1610,7 @@ QString RunWorker::userMessageForProcessError(QProcess::ProcessError error, cons "permissions to invoke the program.").arg(program); break; case QProcess::Crashed: - msg = tr("The process was ended forcefully"); + msg = tr("The process was ended forcefully."); break; case QProcess::Timedout: // "The last waitFor...() function timed out. " diff --git a/src/plugins/projectexplorer/taskhub.cpp b/src/plugins/projectexplorer/taskhub.cpp index 699295af844..fe29a4ca60c 100644 --- a/src/plugins/projectexplorer/taskhub.cpp +++ b/src/plugins/projectexplorer/taskhub.cpp @@ -59,18 +59,19 @@ static Core::Id categoryForType(Task::TaskType type) class TaskMark : public TextEditor::TextMark { public: - TaskMark(unsigned int id, const QString &fileName, int lineNumber, - Task::TaskType type, bool visible) : - TextMark(fileName, lineNumber, categoryForType(type)), - m_id(id) + TaskMark(const Task &task) : + TextMark(task.file.toString(), task.line, categoryForType(task.type)), + m_id(task.taskId) { - setColor(type == Task::Error ? Utils::Theme::ProjectExplorer_TaskError_TextMarkColor - : Utils::Theme::ProjectExplorer_TaskWarn_TextMarkColor); - setDefaultToolTip(type == Task::Error ? QApplication::translate("TaskHub", "Error") - : QApplication::translate("TaskHub", "Warning")); - setPriority(type == Task::Error ? TextEditor::TextMark::NormalPriority - : TextEditor::TextMark::LowPriority); - setVisible(visible); + setColor(task.type == Task::Error ? Utils::Theme::ProjectExplorer_TaskError_TextMarkColor + : Utils::Theme::ProjectExplorer_TaskWarn_TextMarkColor); + setDefaultToolTip(task.type == Task::Error ? QApplication::translate("TaskHub", "Error") + : QApplication::translate("TaskHub", "Warning")); + setPriority(task.type == Task::Error ? TextEditor::TextMark::NormalPriority + : TextEditor::TextMark::LowPriority); + setToolTip(task.description); + setIcon(task.icon); + setVisible(!task.icon.isNull()); } bool isClickable() const; @@ -151,12 +152,8 @@ void TaskHub::addTask(Task task) task.line = -1; task.movedLine = task.line; - if (task.line != -1) { - auto mark = new TaskMark(task.taskId, task.file.toString(), task.line, task.type, !task.icon.isNull()); - mark->setToolTip(task.description); - mark->setIcon(task.icon); - task.setMark(mark); - } + if (task.line != -1) + task.setMark(new TaskMark(task)); emit m_instance->taskAdded(task); } diff --git a/src/plugins/qbsprojectmanager/qbsbuildstep.cpp b/src/plugins/qbsprojectmanager/qbsbuildstep.cpp index 8f57fd3c719..a229d05397c 100644 --- a/src/plugins/qbsprojectmanager/qbsbuildstep.cpp +++ b/src/plugins/qbsprojectmanager/qbsbuildstep.cpp @@ -210,7 +210,7 @@ void QbsBuildStep::cancel() QVariantMap QbsBuildStep::qbsConfiguration(VariableHandling variableHandling) const { QVariantMap config = m_qbsConfiguration; - config.insert(QLatin1String(Constants::QBS_FORCE_PROBES_KEY), m_forceProbes); + config.insert(Constants::QBS_FORCE_PROBES_KEY, m_forceProbes); if (variableHandling == ExpandVariables) { const Utils::MacroExpander *expander = Utils::globalMacroExpander(); for (auto it = config.begin(), end = config.end(); it != end; ++it) { @@ -227,9 +227,9 @@ void QbsBuildStep::setQbsConfiguration(const QVariantMap &config) QbsProject *pro = static_cast(project()); QVariantMap tmp = config; - tmp.insert(QLatin1String(Constants::QBS_CONFIG_PROFILE_KEY), pro->profileForTarget(target())); - if (!tmp.contains(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY))) - tmp.insert(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY), + tmp.insert(Constants::QBS_CONFIG_PROFILE_KEY, pro->profileForTarget(target())); + if (!tmp.contains(Constants::QBS_CONFIG_VARIANT_KEY)) + tmp.insert(Constants::QBS_CONFIG_VARIANT_KEY, QString::fromLatin1(Constants::QBS_VARIANT_DEBUG)); if (tmp == m_qbsConfiguration) @@ -263,13 +263,13 @@ bool QbsBuildStep::cleanInstallRoot() const bool QbsBuildStep::hasCustomInstallRoot() const { - return m_qbsConfiguration.contains(QLatin1String(Constants::QBS_INSTALL_ROOT_KEY)); + return m_qbsConfiguration.contains(Constants::QBS_INSTALL_ROOT_KEY); } Utils::FileName QbsBuildStep::installRoot() const { Utils::FileName root = Utils::FileName::fromString(m_qbsConfiguration - .value(QLatin1String(Constants::QBS_INSTALL_ROOT_KEY)).toString()); + .value(Constants::QBS_INSTALL_ROOT_KEY).toString()); if (root.isNull()) { const QbsBuildConfiguration * const bc = static_cast(buildConfiguration()); @@ -293,15 +293,15 @@ bool QbsBuildStep::fromMap(const QVariantMap &map) if (!ProjectExplorer::BuildStep::fromMap(map)) return false; - setQbsConfiguration(map.value(QLatin1String(QBS_CONFIG)).toMap()); - m_qbsBuildOptions.setDryRun(map.value(QLatin1String(QBS_DRY_RUN)).toBool()); - m_qbsBuildOptions.setKeepGoing(map.value(QLatin1String(QBS_KEEP_GOING)).toBool()); - m_qbsBuildOptions.setMaxJobCount(map.value(QLatin1String(QBS_MAXJOBCOUNT)).toInt()); - const bool showCommandLines = map.value(QLatin1String(QBS_SHOWCOMMANDLINES)).toBool(); + setQbsConfiguration(map.value(QBS_CONFIG).toMap()); + m_qbsBuildOptions.setDryRun(map.value(QBS_DRY_RUN).toBool()); + m_qbsBuildOptions.setKeepGoing(map.value(QBS_KEEP_GOING).toBool()); + m_qbsBuildOptions.setMaxJobCount(map.value(QBS_MAXJOBCOUNT).toInt()); + const bool showCommandLines = map.value(QBS_SHOWCOMMANDLINES).toBool(); m_qbsBuildOptions.setEchoMode(showCommandLines ? qbs::CommandEchoModeCommandLine : qbs::CommandEchoModeSummary); - m_qbsBuildOptions.setInstall(map.value(QLatin1String(QBS_INSTALL), true).toBool()); - m_qbsBuildOptions.setRemoveExistingInstallation(map.value(QLatin1String(QBS_CLEAN_INSTALL_ROOT)) + m_qbsBuildOptions.setInstall(map.value(QBS_INSTALL, true).toBool()); + m_qbsBuildOptions.setRemoveExistingInstallation(map.value(QBS_CLEAN_INSTALL_ROOT) .toBool()); m_forceProbes = map.value(forceProbesKey()).toBool(); return true; @@ -310,14 +310,14 @@ bool QbsBuildStep::fromMap(const QVariantMap &map) QVariantMap QbsBuildStep::toMap() const { QVariantMap map = ProjectExplorer::BuildStep::toMap(); - map.insert(QLatin1String(QBS_CONFIG), m_qbsConfiguration); - map.insert(QLatin1String(QBS_DRY_RUN), m_qbsBuildOptions.dryRun()); - map.insert(QLatin1String(QBS_KEEP_GOING), m_qbsBuildOptions.keepGoing()); - map.insert(QLatin1String(QBS_MAXJOBCOUNT), m_qbsBuildOptions.maxJobCount()); - map.insert(QLatin1String(QBS_SHOWCOMMANDLINES), + map.insert(QBS_CONFIG, m_qbsConfiguration); + map.insert(QBS_DRY_RUN, m_qbsBuildOptions.dryRun()); + map.insert(QBS_KEEP_GOING, m_qbsBuildOptions.keepGoing()); + map.insert(QBS_MAXJOBCOUNT, m_qbsBuildOptions.maxJobCount()); + map.insert(QBS_SHOWCOMMANDLINES, m_qbsBuildOptions.echoMode() == qbs::CommandEchoModeCommandLine); - map.insert(QLatin1String(QBS_INSTALL), m_qbsBuildOptions.install()); - map.insert(QLatin1String(QBS_CLEAN_INSTALL_ROOT), + map.insert(QBS_INSTALL, m_qbsBuildOptions.install()); + map.insert(QBS_CLEAN_INSTALL_ROOT, m_qbsBuildOptions.removeExistingInstallation()); map.insert(forceProbesKey(), m_forceProbes); return map; @@ -389,7 +389,7 @@ void QbsBuildStep::handleProcessResultReport(const qbs::ProcessResult &result) m_parser->setWorkingDirectory(result.workingDirectory()); - QString commandline = result.executableFilePath() + QLatin1Char(' ') + QString commandline = result.executableFilePath() + ' ' + Utils::QtcProcess::joinArgs(result.arguments()); addOutput(commandline, OutputFormat::Stdout); @@ -422,15 +422,15 @@ QString QbsBuildStep::buildVariant() const bool QbsBuildStep::isQmlDebuggingEnabled() const { QVariantMap data = qbsConfiguration(PreserveVariables); - return data.value(QLatin1String(Constants::QBS_CONFIG_DECLARATIVE_DEBUG_KEY), false).toBool() - || data.value(QLatin1String(Constants::QBS_CONFIG_QUICK_DEBUG_KEY), false).toBool(); + return data.value(Constants::QBS_CONFIG_DECLARATIVE_DEBUG_KEY, false).toBool() + || data.value(Constants::QBS_CONFIG_QUICK_DEBUG_KEY, false).toBool(); } void QbsBuildStep::setBuildVariant(const QString &variant) { - if (m_qbsConfiguration.value(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY)).toString() == variant) + if (m_qbsConfiguration.value(Constants::QBS_CONFIG_VARIANT_KEY).toString() == variant) return; - m_qbsConfiguration.insert(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY), variant); + m_qbsConfiguration.insert(Constants::QBS_CONFIG_VARIANT_KEY, variant); emit qbsConfigurationChanged(); QbsBuildConfiguration *bc = static_cast(buildConfiguration()); if (bc) @@ -629,18 +629,17 @@ void QbsBuildStepConfigWidget::updateState() updateQmlDebuggingOption(); const QString buildVariant = m_step->buildVariant(); - const int idx = (buildVariant == QLatin1String(Constants::QBS_VARIANT_DEBUG)) ? 0 : 1; + const int idx = (buildVariant == Constants::QBS_VARIANT_DEBUG) ? 0 : 1; m_ui->buildVariantComboBox->setCurrentIndex(idx); QString command = static_cast(m_step->buildConfiguration()) ->equivalentCommandLine(m_step); for (int i = 0; i < m_propertyCache.count(); ++i) { - command += QLatin1Char(' ') + m_propertyCache.at(i).name - + QLatin1Char(':') + m_propertyCache.at(i).effectiveValue; + command += ' ' + m_propertyCache.at(i).name + ':' + m_propertyCache.at(i).effectiveValue; } if (m_step->isQmlDebuggingEnabled()) - command += QLatin1String(" Qt.declarative.qmlDebugging:true Qt.quick.qmlDebugging:true"); + command += " Qt.declarative.qmlDebugging:true Qt.quick.qmlDebugging:true"; m_ui->commandLineTextEdit->setPlainText(command); QString summary = tr("Qbs: %1").arg(command); @@ -670,16 +669,16 @@ void QbsBuildStepConfigWidget::updatePropertyEdit(const QVariantMap &data) QVariantMap editable = data; // remove data that is edited with special UIs: - editable.remove(QLatin1String(Constants::QBS_CONFIG_PROFILE_KEY)); - editable.remove(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY)); - editable.remove(QLatin1String(Constants::QBS_CONFIG_DECLARATIVE_DEBUG_KEY)); - editable.remove(QLatin1String(Constants::QBS_CONFIG_QUICK_DEBUG_KEY)); - editable.remove(QLatin1String(Constants::QBS_FORCE_PROBES_KEY)); - editable.remove(QLatin1String(Constants::QBS_INSTALL_ROOT_KEY)); + editable.remove(Constants::QBS_CONFIG_PROFILE_KEY); + editable.remove(Constants::QBS_CONFIG_VARIANT_KEY); + editable.remove(Constants::QBS_CONFIG_DECLARATIVE_DEBUG_KEY); + editable.remove(Constants::QBS_CONFIG_QUICK_DEBUG_KEY); + editable.remove(Constants::QBS_FORCE_PROBES_KEY); + editable.remove(Constants::QBS_INSTALL_ROOT_KEY); QStringList propertyList; for (QVariantMap::const_iterator i = editable.constBegin(); i != editable.constEnd(); ++i) - propertyList.append(i.key() + QLatin1Char(':') + i.value().toString()); + propertyList.append(i.key() + ':' + i.value().toString()); m_ui->propertyEdit->setText(Utils::QtcProcess::joinArgs(propertyList)); } @@ -688,9 +687,9 @@ void QbsBuildStepConfigWidget::changeBuildVariant(int idx) { QString variant; if (idx == 1) - variant = QLatin1String(Constants::QBS_VARIANT_RELEASE); + variant = Constants::QBS_VARIANT_RELEASE; else - variant = QLatin1String(Constants::QBS_VARIANT_DEBUG); + variant = Constants::QBS_VARIANT_DEBUG; m_ignoreChange = true; m_step->setBuildVariant(variant); m_ignoreChange = false; @@ -768,16 +767,16 @@ void QbsBuildStepConfigWidget::applyCachedProperties() const QVariantMap tmp = m_step->qbsConfiguration(QbsBuildStep::PreserveVariables); // Insert values set up with special UIs: - data.insert(QLatin1String(Constants::QBS_CONFIG_PROFILE_KEY), - tmp.value(QLatin1String(Constants::QBS_CONFIG_PROFILE_KEY))); - data.insert(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY), - tmp.value(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY))); - if (tmp.contains(QLatin1String(Constants::QBS_CONFIG_DECLARATIVE_DEBUG_KEY))) - data.insert(QLatin1String(Constants::QBS_CONFIG_DECLARATIVE_DEBUG_KEY), - tmp.value(QLatin1String(Constants::QBS_CONFIG_DECLARATIVE_DEBUG_KEY))); - if (tmp.contains(QLatin1String(Constants::QBS_CONFIG_QUICK_DEBUG_KEY))) - data.insert(QLatin1String(Constants::QBS_CONFIG_QUICK_DEBUG_KEY), - tmp.value(QLatin1String(Constants::QBS_CONFIG_QUICK_DEBUG_KEY))); + data.insert(Constants::QBS_CONFIG_PROFILE_KEY, + tmp.value(Constants::QBS_CONFIG_PROFILE_KEY)); + data.insert(Constants::QBS_CONFIG_VARIANT_KEY, + tmp.value(Constants::QBS_CONFIG_VARIANT_KEY)); + if (tmp.contains(Constants::QBS_CONFIG_DECLARATIVE_DEBUG_KEY)) + data.insert(Constants::QBS_CONFIG_DECLARATIVE_DEBUG_KEY, + tmp.value(Constants::QBS_CONFIG_DECLARATIVE_DEBUG_KEY)); + if (tmp.contains(Constants::QBS_CONFIG_QUICK_DEBUG_KEY)) + data.insert(Constants::QBS_CONFIG_QUICK_DEBUG_KEY, + tmp.value(Constants::QBS_CONFIG_QUICK_DEBUG_KEY)); for (int i = 0; i < m_propertyCache.count(); ++i) { const Property &property = m_propertyCache.at(i); @@ -793,11 +792,11 @@ void QbsBuildStepConfigWidget::linkQmlDebuggingLibraryChecked(bool checked) { QVariantMap data = m_step->qbsConfiguration(QbsBuildStep::PreserveVariables); if (checked) { - data.insert(QLatin1String(Constants::QBS_CONFIG_DECLARATIVE_DEBUG_KEY), checked); - data.insert(QLatin1String(Constants::QBS_CONFIG_QUICK_DEBUG_KEY), checked); + data.insert(Constants::QBS_CONFIG_DECLARATIVE_DEBUG_KEY, checked); + data.insert(Constants::QBS_CONFIG_QUICK_DEBUG_KEY, checked); } else { - data.remove(QLatin1String(Constants::QBS_CONFIG_DECLARATIVE_DEBUG_KEY)); - data.remove(QLatin1String(Constants::QBS_CONFIG_QUICK_DEBUG_KEY)); + data.remove(Constants::QBS_CONFIG_DECLARATIVE_DEBUG_KEY); + data.remove(Constants::QBS_CONFIG_QUICK_DEBUG_KEY); } m_ignoreChange = true; @@ -819,7 +818,7 @@ bool QbsBuildStepConfigWidget::validateProperties(Utils::FancyLineEdit *edit, QS QList properties; const Utils::MacroExpander *expander = Utils::globalMacroExpander(); foreach (const QString &rawArg, argList) { - int pos = rawArg.indexOf(QLatin1Char(':')); + int pos = rawArg.indexOf(':'); if (pos > 0) { const QString rawValue = rawArg.mid(pos + 1); Property property(rawArg.left(pos), rawValue, expander->expand(rawValue)); diff --git a/src/plugins/qbsprojectmanager/qbsproject.cpp b/src/plugins/qbsprojectmanager/qbsproject.cpp index da88f9ab4a5..f9673887d96 100644 --- a/src/plugins/qbsprojectmanager/qbsproject.cpp +++ b/src/plugins/qbsprojectmanager/qbsproject.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -688,6 +689,30 @@ QString QbsProject::uniqueProductName(const qbs::ProductData &product) return product.name() + QLatin1Char('.') + product.profile(); } +void QbsProject::configureAsExampleProject(const QSet &platforms) +{ + QList infoList; + QList kits = KitManager::kits(); + const auto qtVersionMatchesPlatform = [platforms](const QtSupport::BaseQtVersion *version) { + return platforms.isEmpty() || platforms.intersects(version->targetDeviceTypes()); + }; + foreach (Kit *k, kits) { + const QtSupport::BaseQtVersion * const qtVersion + = QtSupport::QtKitInformation::qtVersion(k); + if (!qtVersion || !qtVersionMatchesPlatform(qtVersion)) + continue; + const IBuildConfigurationFactory * const factory + = IBuildConfigurationFactory::find(k, projectFilePath().toString()); + if (!factory) + continue; + for (BuildInfo * const info : factory->availableSetups(k, projectFilePath().toString())) + infoList << info; + } + setup(infoList); + qDeleteAll(infoList); + prepareForParsing(); +} + void QbsProject::parse(const QVariantMap &config, const Environment &env, const QString &dir, const QString &configName) { diff --git a/src/plugins/qbsprojectmanager/qbsproject.h b/src/plugins/qbsprojectmanager/qbsproject.h index 8ff26640743..23e0f706b90 100644 --- a/src/plugins/qbsprojectmanager/qbsproject.h +++ b/src/plugins/qbsprojectmanager/qbsproject.h @@ -108,6 +108,8 @@ public: const qbs::ProductData &product); static QString uniqueProductName(const qbs::ProductData &product); + void configureAsExampleProject(const QSet &platforms) final; + void invalidate(); void delayParsing(); diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanagerconstants.h b/src/plugins/qbsprojectmanager/qbsprojectmanagerconstants.h index 3195bb8d654..e53beb84fe5 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectmanagerconstants.h +++ b/src/plugins/qbsprojectmanager/qbsprojectmanagerconstants.h @@ -60,19 +60,19 @@ const char QBS_CLEANSTEP_ID[] = "Qbs.CleanStep"; const char QBS_INSTALLSTEP_ID[] = "Qbs.InstallStep"; // QBS strings: -static const char QBS_VARIANT_DEBUG[] = "debug"; -static const char QBS_VARIANT_RELEASE[] = "release"; +const char QBS_VARIANT_DEBUG[] = "debug"; +const char QBS_VARIANT_RELEASE[] = "release"; -static const char QBS_CONFIG_VARIANT_KEY[] = "qbs.buildVariant"; -static const char QBS_CONFIG_PROFILE_KEY[] = "qbs.profile"; -static const char QBS_INSTALL_ROOT_KEY[] = "qbs.installRoot"; -static const char QBS_CONFIG_DECLARATIVE_DEBUG_KEY[] = "Qt.declarative.qmlDebugging"; -static const char QBS_CONFIG_QUICK_DEBUG_KEY[] = "Qt.quick.qmlDebugging"; +const char QBS_CONFIG_VARIANT_KEY[] = "qbs.buildVariant"; +const char QBS_CONFIG_PROFILE_KEY[] = "qbs.profile"; +const char QBS_INSTALL_ROOT_KEY[] = "qbs.installRoot"; +const char QBS_CONFIG_DECLARATIVE_DEBUG_KEY[] = "Qt.declarative.qmlDebugging"; +const char QBS_CONFIG_QUICK_DEBUG_KEY[] = "Qt.quick.qmlDebugging"; const char QBS_FORCE_PROBES_KEY[] = "qbspm.forceProbes"; // Icons: -static const char QBS_GROUP_ICON[] = ":/qbsprojectmanager/images/groups.png"; -static const char QBS_PRODUCT_OVERLAY_ICON[] = ":/qbsprojectmanager/images/productgear.png"; +const char QBS_GROUP_ICON[] = ":/qbsprojectmanager/images/groups.png"; +const char QBS_PRODUCT_OVERLAY_ICON[] = ":/qbsprojectmanager/images/productgear.png"; // Toolchain related settings: const char QBS_TARGETOS[] = "qbs.targetOS"; diff --git a/src/plugins/qmakeprojectmanager/makefileparse.cpp b/src/plugins/qmakeprojectmanager/makefileparse.cpp index aea591e5abd..358fb05bc99 100644 --- a/src/plugins/qmakeprojectmanager/makefileparse.cpp +++ b/src/plugins/qmakeprojectmanager/makefileparse.cpp @@ -244,7 +244,6 @@ void MakeFileParse::parseAssignments(QList *assignments) static FileName findQMakeBinaryFromMakefile(const QString &makefile) { - bool debugAdding = false; QFile fi(makefile); if (fi.exists() && fi.open(QFile::ReadOnly)) { QTextStream ts(&fi); @@ -252,8 +251,6 @@ static FileName findQMakeBinaryFromMakefile(const QString &makefile) while (!ts.atEnd()) { QString line = ts.readLine(); if (r1.exactMatch(line)) { - if (debugAdding) - qDebug()<<"#~~ QMAKE is:"< -#include -#include +#include "texteditor/codeassist/keywordscompletionassist.h" -#include - -using namespace QmakeProjectManager::Internal; -using namespace TextEditor; - - -static const char *const variableKeywords[] = { - "CCFLAG", - "CLEAN_DEPS", - "CONFIG", - "DEFINES", - "DEF_FILE", - "DEPENDPATH", - "DEPLOYMENT", - "DEPLOYMENT_PLUGIN", - "DESTDIR", - "DESTDIR_TARGET", - "DISTFILES", - "DLLDESTDIR", - "DSP_TEMPLATE", - "FORMS", - "FORMS3", - "GUID", - "HEADERS", - "ICON", - "INCLUDEPATH", - "INSTALLS", - "LEXIMPLS", - "LEXOBJECTS", - "LEXSOURCES", - "LIBS", - "LITERAL_HASH", - "MAKEFILE", - "MAKEFILE_GENERATOR", - "MOBILITY", - "MOC_DIR", - "OBJECTIVE_HEADERS", - "OBJECTIVE_SOURCES", - "OBJECTS", - "OBJECTS_DIR", - "OBJMOC", - "OTHER_FILES", - "OUT_PWD", - "PKGCONFIG", - "POST_TARGETDEPS", - "PRECOMPILED_HEADER", - "PRE_TARGETDEPS", - "PWD", - "QMAKE", - "QMAKESPEC", - "QMAKE_APP_FLAG", - "QMAKE_APP_OR_DLL", - "QMAKE_AR_CMD", - "QMAKE_BUNDLE_DATA", - "QMAKE_BUNDLE_EXTENSION", - "QMAKE_CC", - "QMAKE_CFLAGS", - "QMAKE_CFLAGS_DEBUG", - "QMAKE_CFLAGS_MT", - "QMAKE_CFLAGS_MT_DBG", - "QMAKE_CFLAGS_MT_DLL", - "QMAKE_CFLAGS_MT_DLLDBG", - "QMAKE_CFLAGS_RELEASE", - "QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO", - "QMAKE_CFLAGS_SHLIB", - "QMAKE_CFLAGS_THREAD", - "QMAKE_CFLAGS_WARN_OFF", - "QMAKE_CFLAGS_WARN_ON", - "QMAKE_CLEAN", - "QMAKE_CXX", - "QMAKE_CXXFLAGS", - "QMAKE_CXXFLAGS_DEBUG", - "QMAKE_CXXFLAGS_MT", - "QMAKE_CXXFLAGS_MT_DBG", - "QMAKE_CXXFLAGS_MT_DLL", - "QMAKE_CXXFLAGS_MT_DLLDBG", - "QMAKE_CXXFLAGS_RELEASE", - "QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO", - "QMAKE_CXXFLAGS_SHLIB", - "QMAKE_CXXFLAGS_THREAD", - "QMAKE_CXXFLAGS_WARN_OFF", - "QMAKE_CXXFLAGS_WARN_ON", - "QMAKE_DISTCLEAN", - "QMAKE_EXTENSION_SHLIB", - "QMAKE_EXTRA_COMPILERS", - "QMAKE_EXTRA_TARGETS", - "QMAKE_EXT_CPP", - "QMAKE_EXT_H", - "QMAKE_EXT_LEX", - "QMAKE_EXT_MOC", - "QMAKE_EXT_OBJ", - "QMAKE_EXT_PRL", - "QMAKE_EXT_UI", - "QMAKE_EXT_YACC", - "QMAKE_FAILED_REQUIREMENTS", - "QMAKE_FRAMEWORK_BUNDLE_NAME", - "QMAKE_FRAMEWORK_VERSION", - "QMAKE_INCDIR", - "QMAKE_INCDIR_EGL", - "QMAKE_INCDIR_OPENGL", - "QMAKE_INCDIR_OPENGL_ES1", - "QMAKE_INCDIR_OPENGL_ES2", - "QMAKE_INCDIR_OPENVG", - "QMAKE_INCDIR_QT", - "QMAKE_INCDIR_THREAD", - "QMAKE_INCDIR_X11", - "QMAKE_INFO_PLIST", - "QMAKE_LFLAGS", - "QMAKE_LFLAGS_CONSOLE", - "QMAKE_LFLAGS_CONSOLE_DLL", - "QMAKE_LFLAGS_DEBUG", - "QMAKE_LFLAGS_PLUGIN", - "QMAKE_LFLAGS_QT_DLL", - "QMAKE_LFLAGS_RELEASE", - "QMAKE_LFLAGS_RPATH", - "QMAKE_LFLAGS_SHAPP", - "QMAKE_LFLAGS_SHLIB", - "QMAKE_LFLAGS_SONAME", - "QMAKE_LFLAGS_THREAD", - "QMAKE_LFLAGS_WINDOWS", - "QMAKE_LFLAGS_WINDOWS_DLL", - "QMAKE_LIBDIR", - "QMAKE_LIBDIR_EGL", - "QMAKE_LIBDIR_FLAGS", - "QMAKE_LIBDIR_OPENGL", - "QMAKE_LIBDIR_OPENVG", - "QMAKE_LIBDIR_QT", - "QMAKE_LIBDIR_X11", - "QMAKE_LIBS", - "QMAKE_LIBS_CONSOLE", - "QMAKE_LIBS_EGL", - "QMAKE_LIBS_OPENGL", - "QMAKE_LIBS_OPENGL_ES1", - "QMAKE_LIBS_OPENGL_ES2", - "QMAKE_LIBS_OPENGL_QT", - "QMAKE_LIBS_OPENVG", - "QMAKE_LIBS_QT", - "QMAKE_LIBS_QT_DLL", - "QMAKE_LIBS_QT_OPENGL", - "QMAKE_LIBS_QT_THREAD", - "QMAKE_LIBS_RT", - "QMAKE_LIBS_RTMT", - "QMAKE_LIBS_THREAD", - "QMAKE_LIBS_WINDOWS", - "QMAKE_LIBS_X11", - "QMAKE_LIBS_X11SM", - "QMAKE_LIB_FLAG", - "QMAKE_LINK", - "QMAKE_LINK_SHLIB_CMD", - "QMAKE_LN_SHLIB", - "QMAKE_MACOSX_DEPLOYMENT_TARGET", - "QMAKE_MAC_SDK", - "QMAKE_MAKEFILE", - "QMAKE_MOC_SRC", - "QMAKE_POST_LINK", - "QMAKE_PRE_LINK", - "QMAKE_PROJECT_NAME", - "QMAKE_QMAKE", - "QMAKE_QT_DLL", - "QMAKE_RESOURCE_FLAGS", - "QMAKE_RPATH", - "QMAKE_RPATHDIR", - "QMAKE_RUN_CC", - "QMAKE_RUN_CC_IMP", - "QMAKE_RUN_CXX", - "QMAKE_RUN_CXX_IMP", - "QMAKE_TARGET", - "QMAKE_UIC", - "QT", - "QTPLUGIN", - "QT_MAJOR_VERSION", - "QT_MINOR_VERSION", - "QT_PATCH_VERSION", - "QT_VERSION", - "RCC_DIR", - "RC_FILE", - "REQUIRES", - "RESOURCES", - "RES_FILE", - "RSS_RULES", - "SIGNATURE_FILE", - "SOURCES", - "SRCMOC", - "STATECHARTS", - "SUBDIRS", - "TARGET", - "TEMPLATE", - "TRANSLATIONS", - "UICIMPLS", - "UICOBJECTS", - "UI_DIR", - "UI_HEADERS_DIR", - "UI_SOURCES_DIR", - "VERSION", - "VERSION_PE_HEADER", - "VER_MAJ", - "VER_MIN", - "VER_PAT", - "VPATH", - "YACCIMPLS", - "YACCOBJECTS", - "YACCSOURCES", - "_PRO_FILE_", - "_PRO_FILE_PWD_", - 0 -}; - -static const char *const functionKeywords[] = { - "CONFIG", - "absolute_path", - "basename", - "cache", - "cat", - "clean_path", - "clear", - "contains", - "count", - "debug", - "defined", - "dirname", - "enumerate_vars", - "equals", - "error", - "escape_expand", - "eval", - "exists", - "export", - "files", - "find", - "first", - "for", - "format_number", - "fromfile", - "getenv", - "greaterThan", - "if", - "include", - "infile", - "isActiveConfig", - "isEmpty", - "isEqual", - "join", - "last", - "lessThan", - "list", - "load", - "log", - "lower", - "member", - "message", - "mkpath", - "packagesExist", - "parseJson", - "prompt", - "quote", - "re_escape", - "relative_path", - "replace", - "requires", - "resolve_depends", - "reverse", - "section", - "shadowed", - "shell_path", - "shell_quote", - "size", - "sort_depends", - "split", - "sprintf", - "system", - "system_path", - "system_quote", - "title", - "touch", - "unique", - "unset", - "upper", - "val_escape", - "warning", - "write_file", - 0 -}; - -// ------------------------------- -// ProFileCompletionAssistProvider -// ------------------------------- -void ProFileCompletionAssistProvider::init() +const TextEditor::Keywords &QmakeProjectManager::Internal::qmakeKeywords() { - for (uint i = 0; i < sizeof variableKeywords / sizeof variableKeywords[0] - 1; i++) - m_variables.append(QLatin1String(variableKeywords[i])); - for (uint i = 0; i < sizeof functionKeywords / sizeof functionKeywords[0] - 1; i++) - m_functions.append(QLatin1String(functionKeywords[i])); -} - -ProFileCompletionAssistProvider::~ProFileCompletionAssistProvider() -{ -} - -IAssistProcessor *ProFileCompletionAssistProvider::createProcessor() const -{ - if (m_variables.isEmpty()) - const_cast(this)->init(); - TextEditor::Keywords keywords = TextEditor::Keywords(m_variables, m_functions, QMap()); - auto processor = new KeywordsCompletionAssistProcessor(keywords); - processor->setSnippetGroup(TextEditor::Constants::TEXT_SNIPPET_GROUP_ID); - return processor; -} - -QStringList ProFileCompletionAssistProvider::variables() const -{ - if (m_variables.isEmpty()) - const_cast(this)->init(); - return m_variables; -} - -QStringList ProFileCompletionAssistProvider::functions() const -{ - if (m_functions.isEmpty()) - const_cast(this)->init(); - return m_functions; + static TextEditor::Keywords keywords( + QStringList{ // variables + "CCFLAG", + "CLEAN_DEPS", + "CONFIG", + "DEFINES", + "DEF_FILE", + "DEPENDPATH", + "DEPLOYMENT", + "DEPLOYMENT_PLUGIN", + "DESTDIR", + "DESTDIR_TARGET", + "DISTFILES", + "DLLDESTDIR", + "DSP_TEMPLATE", + "FORMS", + "FORMS3", + "GUID", + "HEADERS", + "ICON", + "INCLUDEPATH", + "INSTALLS", + "LEXIMPLS", + "LEXOBJECTS", + "LEXSOURCES", + "LIBS", + "LITERAL_HASH", + "MAKEFILE", + "MAKEFILE_GENERATOR", + "MOBILITY", + "MOC_DIR", + "OBJECTIVE_HEADERS", + "OBJECTIVE_SOURCES", + "OBJECTS", + "OBJECTS_DIR", + "OBJMOC", + "OTHER_FILES", + "OUT_PWD", + "PKGCONFIG", + "POST_TARGETDEPS", + "PRECOMPILED_HEADER", + "PRE_TARGETDEPS", + "PWD", + "QMAKE", + "QMAKESPEC", + "QMAKE_APP_FLAG", + "QMAKE_APP_OR_DLL", + "QMAKE_AR_CMD", + "QMAKE_BUNDLE_DATA", + "QMAKE_BUNDLE_EXTENSION", + "QMAKE_CC", + "QMAKE_CFLAGS", + "QMAKE_CFLAGS_DEBUG", + "QMAKE_CFLAGS_MT", + "QMAKE_CFLAGS_MT_DBG", + "QMAKE_CFLAGS_MT_DLL", + "QMAKE_CFLAGS_MT_DLLDBG", + "QMAKE_CFLAGS_RELEASE", + "QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO", + "QMAKE_CFLAGS_SHLIB", + "QMAKE_CFLAGS_THREAD", + "QMAKE_CFLAGS_WARN_OFF", + "QMAKE_CFLAGS_WARN_ON", + "QMAKE_CLEAN", + "QMAKE_CXX", + "QMAKE_CXXFLAGS", + "QMAKE_CXXFLAGS_DEBUG", + "QMAKE_CXXFLAGS_MT", + "QMAKE_CXXFLAGS_MT_DBG", + "QMAKE_CXXFLAGS_MT_DLL", + "QMAKE_CXXFLAGS_MT_DLLDBG", + "QMAKE_CXXFLAGS_RELEASE", + "QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO", + "QMAKE_CXXFLAGS_SHLIB", + "QMAKE_CXXFLAGS_THREAD", + "QMAKE_CXXFLAGS_WARN_OFF", + "QMAKE_CXXFLAGS_WARN_ON", + "QMAKE_DISTCLEAN", + "QMAKE_EXTENSION_SHLIB", + "QMAKE_EXTRA_COMPILERS", + "QMAKE_EXTRA_TARGETS", + "QMAKE_EXT_CPP", + "QMAKE_EXT_H", + "QMAKE_EXT_LEX", + "QMAKE_EXT_MOC", + "QMAKE_EXT_OBJ", + "QMAKE_EXT_PRL", + "QMAKE_EXT_UI", + "QMAKE_EXT_YACC", + "QMAKE_FAILED_REQUIREMENTS", + "QMAKE_FRAMEWORK_BUNDLE_NAME", + "QMAKE_FRAMEWORK_VERSION", + "QMAKE_INCDIR", + "QMAKE_INCDIR_EGL", + "QMAKE_INCDIR_OPENGL", + "QMAKE_INCDIR_OPENGL_ES1", + "QMAKE_INCDIR_OPENGL_ES2", + "QMAKE_INCDIR_OPENVG", + "QMAKE_INCDIR_QT", + "QMAKE_INCDIR_THREAD", + "QMAKE_INCDIR_X11", + "QMAKE_INFO_PLIST", + "QMAKE_LFLAGS", + "QMAKE_LFLAGS_CONSOLE", + "QMAKE_LFLAGS_CONSOLE_DLL", + "QMAKE_LFLAGS_DEBUG", + "QMAKE_LFLAGS_PLUGIN", + "QMAKE_LFLAGS_QT_DLL", + "QMAKE_LFLAGS_RELEASE", + "QMAKE_LFLAGS_RPATH", + "QMAKE_LFLAGS_SHAPP", + "QMAKE_LFLAGS_SHLIB", + "QMAKE_LFLAGS_SONAME", + "QMAKE_LFLAGS_THREAD", + "QMAKE_LFLAGS_WINDOWS", + "QMAKE_LFLAGS_WINDOWS_DLL", + "QMAKE_LIBDIR", + "QMAKE_LIBDIR_EGL", + "QMAKE_LIBDIR_FLAGS", + "QMAKE_LIBDIR_OPENGL", + "QMAKE_LIBDIR_OPENVG", + "QMAKE_LIBDIR_QT", + "QMAKE_LIBDIR_X11", + "QMAKE_LIBS", + "QMAKE_LIBS_CONSOLE", + "QMAKE_LIBS_EGL", + "QMAKE_LIBS_OPENGL", + "QMAKE_LIBS_OPENGL_ES1", + "QMAKE_LIBS_OPENGL_ES2", + "QMAKE_LIBS_OPENGL_QT", + "QMAKE_LIBS_OPENVG", + "QMAKE_LIBS_QT", + "QMAKE_LIBS_QT_DLL", + "QMAKE_LIBS_QT_OPENGL", + "QMAKE_LIBS_QT_THREAD", + "QMAKE_LIBS_RT", + "QMAKE_LIBS_RTMT", + "QMAKE_LIBS_THREAD", + "QMAKE_LIBS_WINDOWS", + "QMAKE_LIBS_X11", + "QMAKE_LIBS_X11SM", + "QMAKE_LIB_FLAG", + "QMAKE_LINK", + "QMAKE_LINK_SHLIB_CMD", + "QMAKE_LN_SHLIB", + "QMAKE_MACOSX_DEPLOYMENT_TARGET", + "QMAKE_MAC_SDK", + "QMAKE_MAKEFILE", + "QMAKE_MOC_SRC", + "QMAKE_POST_LINK", + "QMAKE_PRE_LINK", + "QMAKE_PROJECT_NAME", + "QMAKE_QMAKE", + "QMAKE_QT_DLL", + "QMAKE_RESOURCE_FLAGS", + "QMAKE_RPATH", + "QMAKE_RPATHDIR", + "QMAKE_RUN_CC", + "QMAKE_RUN_CC_IMP", + "QMAKE_RUN_CXX", + "QMAKE_RUN_CXX_IMP", + "QMAKE_TARGET", + "QMAKE_UIC", + "QT", + "QTPLUGIN", + "QT_MAJOR_VERSION", + "QT_MINOR_VERSION", + "QT_PATCH_VERSION", + "QT_VERSION", + "RCC_DIR", + "RC_FILE", + "REQUIRES", + "RESOURCES", + "RES_FILE", + "RSS_RULES", + "SIGNATURE_FILE", + "SOURCES", + "SRCMOC", + "STATECHARTS", + "SUBDIRS", + "TARGET", + "TEMPLATE", + "TRANSLATIONS", + "UICIMPLS", + "UICOBJECTS", + "UI_DIR", + "UI_HEADERS_DIR", + "UI_SOURCES_DIR", + "VERSION", + "VERSION_PE_HEADER", + "VER_MAJ", + "VER_MIN", + "VER_PAT", + "VPATH", + "YACCIMPLS", + "YACCOBJECTS", + "YACCSOURCES", + "_PRO_FILE_", + "_PRO_FILE_PWD_"}, + QStringList{ // functions + "CONFIG", + "absolute_path", + "basename", + "cache", + "cat", + "clean_path", + "clear", + "contains", + "count", + "debug", + "defined", + "dirname", + "enumerate_vars", + "equals", + "error", + "escape_expand", + "eval", + "exists", + "export", + "files", + "find", + "first", + "for", + "format_number", + "fromfile", + "getenv", + "greaterThan", + "if", + "include", + "infile", + "isActiveConfig", + "isEmpty", + "isEqual", + "join", + "last", + "lessThan", + "list", + "load", + "log", + "lower", + "member", + "message", + "mkpath", + "packagesExist", + "parseJson", + "prompt", + "quote", + "re_escape", + "relative_path", + "replace", + "requires", + "resolve_depends", + "reverse", + "section", + "shadowed", + "shell_path", + "shell_quote", + "size", + "sort_depends", + "split", + "sprintf", + "system", + "system_path", + "system_quote", + "title", + "touch", + "unique", + "unset", + "upper", + "val_escape", + "warning", + "write_file"}); + return keywords; } diff --git a/src/plugins/qmakeprojectmanager/profilecompletionassist.h b/src/plugins/qmakeprojectmanager/profilecompletionassist.h index 76c77a95f06..85ffec0dfd5 100644 --- a/src/plugins/qmakeprojectmanager/profilecompletionassist.h +++ b/src/plugins/qmakeprojectmanager/profilecompletionassist.h @@ -25,29 +25,11 @@ #pragma once -#include - -#include - +namespace TextEditor { class Keywords; } namespace QmakeProjectManager { namespace Internal { -class ProFileCompletionAssistProvider : public TextEditor::CompletionAssistProvider -{ - Q_OBJECT - -public: - void init(); - ~ProFileCompletionAssistProvider(); - - TextEditor::IAssistProcessor *createProcessor() const override; - QStringList variables() const; - QStringList functions() const; - -private: - QStringList m_variables; - QStringList m_functions; -}; +const TextEditor::Keywords &qmakeKeywords(); } // namespace Internal } // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/profileeditor.cpp b/src/plugins/qmakeprojectmanager/profileeditor.cpp index ada9054589d..97c119c456e 100644 --- a/src/plugins/qmakeprojectmanager/profileeditor.cpp +++ b/src/plugins/qmakeprojectmanager/profileeditor.cpp @@ -182,16 +182,14 @@ ProFileEditorFactory::ProFileEditorFactory() setDocumentCreator(createProFileDocument); setEditorWidgetCreator([]() { return new ProFileEditorWidget; }); - ProFileCompletionAssistProvider *pcap = new ProFileCompletionAssistProvider; - setCompletionAssistProvider(pcap); + setCompletionAssistProvider(new KeywordsCompletionAssistProvider(qmakeKeywords())); setCommentDefinition(Utils::CommentDefinition::HashStyle); setEditorActionHandlers(TextEditorActionHandler::UnCommentSelection | TextEditorActionHandler::JumpToFileUnderCursor); - Keywords keywords(pcap->variables(), pcap->functions(), QMap()); - addHoverHandler(new ProFileHoverHandler(keywords)); - setSyntaxHighlighterCreator([keywords]() { return new ProFileHighlighter(keywords); }); + addHoverHandler(new ProFileHoverHandler); + setSyntaxHighlighterCreator([]() { return new ProFileHighlighter; }); const QString defaultOverlay = QLatin1String(ProjectExplorer::Constants::FILEOVERLAY_QT); Core::FileIconProvider::registerIconOverlayForSuffix( diff --git a/src/plugins/qmakeprojectmanager/profilehighlighter.cpp b/src/plugins/qmakeprojectmanager/profilehighlighter.cpp index 0cbfb09b2eb..4b4236fcb2f 100644 --- a/src/plugins/qmakeprojectmanager/profilehighlighter.cpp +++ b/src/plugins/qmakeprojectmanager/profilehighlighter.cpp @@ -52,8 +52,8 @@ static TextStyle styleForFormat(int format) return C_TEXT; } -ProFileHighlighter::ProFileHighlighter(const Keywords &keywords) - : m_keywords(keywords) +ProFileHighlighter::ProFileHighlighter() + : m_keywords(qmakeKeywords()) { setTextFormatCategories(NumProfileFormats, styleForFormat); } diff --git a/src/plugins/qmakeprojectmanager/profilehighlighter.h b/src/plugins/qmakeprojectmanager/profilehighlighter.h index 98de83c9c28..9d85861af85 100644 --- a/src/plugins/qmakeprojectmanager/profilehighlighter.h +++ b/src/plugins/qmakeprojectmanager/profilehighlighter.h @@ -42,7 +42,7 @@ public: NumProfileFormats }; - explicit ProFileHighlighter(const TextEditor::Keywords &keywords); + ProFileHighlighter(); void highlightBlock(const QString &text); private: diff --git a/src/plugins/qmakeprojectmanager/profilehoverhandler.cpp b/src/plugins/qmakeprojectmanager/profilehoverhandler.cpp index 3c9c3962e83..dfbee9bb665 100644 --- a/src/plugins/qmakeprojectmanager/profilehoverhandler.cpp +++ b/src/plugins/qmakeprojectmanager/profilehoverhandler.cpp @@ -39,8 +39,8 @@ using namespace Core; namespace QmakeProjectManager { namespace Internal { -ProFileHoverHandler::ProFileHoverHandler(const TextEditor::Keywords &keywords) - : m_keywords(keywords) +ProFileHoverHandler::ProFileHoverHandler() + : m_keywords(qmakeKeywords()) { } diff --git a/src/plugins/qmakeprojectmanager/profilehoverhandler.h b/src/plugins/qmakeprojectmanager/profilehoverhandler.h index 2fa1fb250e0..381329a93c3 100644 --- a/src/plugins/qmakeprojectmanager/profilehoverhandler.h +++ b/src/plugins/qmakeprojectmanager/profilehoverhandler.h @@ -38,7 +38,7 @@ namespace Internal { class ProFileHoverHandler : public TextEditor::BaseHoverHandler { public: - explicit ProFileHoverHandler(const TextEditor::Keywords &keywords); + ProFileHoverHandler(); private: void identifyMatch(TextEditor::TextEditorWidget *editorWidget, int pos) override; diff --git a/src/plugins/qmldesigner/components/formeditor/selectiontool.cpp b/src/plugins/qmldesigner/components/formeditor/selectiontool.cpp index 3aa1c2c1fd7..9a5f55cd195 100644 --- a/src/plugins/qmldesigner/components/formeditor/selectiontool.cpp +++ b/src/plugins/qmldesigner/components/formeditor/selectiontool.cpp @@ -140,9 +140,9 @@ void SelectionTool::hoverMoveEvent(const QList &itemList, } if ((topSelectedItemIsMovable(itemList) && !view()->hasSingleSelectedModelNode()) - || selectedItemCursorInMovableArea(event->scenePos()) + || (selectedItemCursorInMovableArea(event->scenePos()) && !event->modifiers().testFlag(Qt::ControlModifier) - && !event->modifiers().testFlag(Qt::ShiftModifier)) { + && !event->modifiers().testFlag(Qt::ShiftModifier))) { view()->changeToMoveTool(); return; } diff --git a/src/plugins/qmldesigner/components/integration/designdocument.h b/src/plugins/qmldesigner/components/integration/designdocument.h index ad110bfca4c..e4048dae26f 100644 --- a/src/plugins/qmldesigner/components/integration/designdocument.h +++ b/src/plugins/qmldesigner/components/integration/designdocument.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef DesignDocument_h -#define DesignDocument_h +#pragma once #include #include @@ -155,6 +154,3 @@ private: // variables }; } // namespace QmlDesigner - - -#endif // DesignDocument_h diff --git a/src/plugins/qmldesigner/components/integration/stackedutilitypanelcontroller.h b/src/plugins/qmldesigner/components/integration/stackedutilitypanelcontroller.h index f49d98e1f24..f446297a66d 100644 --- a/src/plugins/qmldesigner/components/integration/stackedutilitypanelcontroller.h +++ b/src/plugins/qmldesigner/components/integration/stackedutilitypanelcontroller.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef StackedUtilityPanelController_h -#define StackedUtilityPanelController_h +#pragma once #include "utilitypanelcontroller.h" @@ -55,5 +54,3 @@ private: }; } // namespace QmlDesigner - -#endif // StackedUtilityPanelController_h diff --git a/src/plugins/qmldesigner/components/integration/utilitypanelcontroller.h b/src/plugins/qmldesigner/components/integration/utilitypanelcontroller.h index 6a2c33cfdf6..8718a83a04f 100644 --- a/src/plugins/qmldesigner/components/integration/utilitypanelcontroller.h +++ b/src/plugins/qmldesigner/components/integration/utilitypanelcontroller.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef UtilityPanelController_h -#define UtilityPanelController_h +#pragma once #include @@ -47,5 +46,3 @@ protected: }; } // namespace QmlDesigner - -#endif // UtilityPanelController_h diff --git a/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.h b/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.h index e73c55629f2..643df70c451 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.h +++ b/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.h @@ -23,8 +23,7 @@ ** ****************************************************************************/ -#ifndef QmlAnchorBindingProxy_h -#define QmlAnchorBindingProxy_h +#pragma once #include #include @@ -248,6 +247,3 @@ private: } // namespace Internal } // namespace QmlDesigner - - -#endif //QmlAnchorBindingProxy diff --git a/src/plugins/qmldesigner/designercore/metainfo/metainforeader.cpp b/src/plugins/qmldesigner/designercore/metainfo/metainforeader.cpp index 13b7af54881..d2d906e6657 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/metainforeader.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/metainforeader.cpp @@ -95,7 +95,7 @@ void MetaInfoReader::elementStart(const QString &name) case ParsingHints: case Finished: case Undefined: setParserState(Error); - addError(tr("Illegal state while parsing"), currentSourceLocation()); + addError(tr("Illegal state while parsing."), currentSourceLocation()); case Error: default: return; } @@ -113,7 +113,7 @@ void MetaInfoReader::elementEnd() case ParsingDocument: case Finished: case Undefined: setParserState(Error); - addError(tr("Illegal state while parsing"), currentSourceLocation()); + addError(tr("Illegal state while parsing."), currentSourceLocation()); case Error: default: return; } @@ -126,12 +126,12 @@ void MetaInfoReader::propertyDefinition(const QString &name, const QVariant &val case ParsingItemLibrary: readItemLibraryEntryProperty(name, value); break; case ParsingProperty: readPropertyProperty(name, value); break; case ParsingQmlSource: readQmlSourceProperty(name, value); break; - case ParsingMetaInfo: addError(tr("No property definition allowed"), currentSourceLocation()); break; + case ParsingMetaInfo: addError(tr("No property definition allowed."), currentSourceLocation()); break; case ParsingDocument: case ParsingHints: readHint(name, value); break; case Finished: case Undefined: setParserState(Error); - addError(tr("Illegal state while parsing"), currentSourceLocation()); + addError(tr("Illegal state while parsing."), currentSourceLocation()); case Error: default: return; } diff --git a/src/plugins/qmldesigner/designercore/pluginmanager/widgetpluginpath.cpp b/src/plugins/qmldesigner/designercore/pluginmanager/widgetpluginpath.cpp index 3954d209171..6904417759f 100644 --- a/src/plugins/qmldesigner/designercore/pluginmanager/widgetpluginpath.cpp +++ b/src/plugins/qmldesigner/designercore/pluginmanager/widgetpluginpath.cpp @@ -66,7 +66,7 @@ static IWidgetPlugin *instance(WidgetPluginData &p) p.failed = true; p.errorMessage = QCoreApplication::translate("WidgetPluginManager", "Failed to create instance of file " - "'%1': %2").arg(p.path).arg(p.errorMessage); + "\"%1\": %2").arg(p.path).arg(p.errorMessage); qWarning() << p.errorMessage; return 0; } @@ -74,7 +74,7 @@ static IWidgetPlugin *instance(WidgetPluginData &p) if (!object) { p.failed = true; p.errorMessage = QCoreApplication::translate("WidgetPluginManager", - "Failed to create instance of file '%1'." + "Failed to create instance of file \"%1\"." ).arg(p.path); qWarning() << p.errorMessage; return 0; @@ -83,7 +83,7 @@ static IWidgetPlugin *instance(WidgetPluginData &p) if (!iplugin) { p.failed = true; p.errorMessage = QCoreApplication::translate("WidgetPluginManager", - "File '%1' is not a QmlDesigner plugin." + "File \"%1\" is not a Qt Quick Designer plugin." ).arg(p.path); qWarning() << p.errorMessage; delete object; diff --git a/src/plugins/qmldesigner/qmldesignerplugin.qbs b/src/plugins/qmldesigner/qmldesignerplugin.qbs index 828142b47f3..9f040daf760 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.qbs +++ b/src/plugins/qmldesigner/qmldesignerplugin.qbs @@ -397,6 +397,7 @@ Project { "componentcore/selectioncontext.h", "componentcore/qmldesignericonprovider.cpp", "componentcore/qmldesignericonprovider.h", + "componentcore/componentcore.qrc", "texteditor/texteditorstatusbar.cpp", "texteditor/texteditorstatusbar.h", "componentcore/changestyleaction.cpp", diff --git a/src/plugins/silversearcher/findinfilessilversearcher.cpp b/src/plugins/silversearcher/findinfilessilversearcher.cpp index 613066de365..a19c37e3af3 100644 --- a/src/plugins/silversearcher/findinfilessilversearcher.cpp +++ b/src/plugins/silversearcher/findinfilessilversearcher.cpp @@ -146,7 +146,7 @@ FindInFilesSilverSearcher::FindInFilesSilverSearcher() if (!isEnabled()) { auto layout = new QHBoxLayout(m_widget); layout->setMargin(0); - QLabel *label = new QLabel(tr("SilverSearcher is not available on system")); + QLabel *label = new QLabel(tr("Silver Searcher is not available on the system.")); label->setStyleSheet("QLabel { color : red; }"); layout->addWidget(label); } diff --git a/src/plugins/texteditor/basefilefind.cpp b/src/plugins/texteditor/basefilefind.cpp index a501ee6518e..7486cfd0d42 100644 --- a/src/plugins/texteditor/basefilefind.cpp +++ b/src/plugins/texteditor/basefilefind.cpp @@ -589,7 +589,7 @@ CountingLabel::CountingLabel() void CountingLabel::updateCount(int count) { - setText(BaseFileFind::tr("%n found", nullptr, count)); + setText(BaseFileFind::tr("%n found.", nullptr, count)); } } // namespace Internal diff --git a/src/plugins/texteditor/codeassist/keywordscompletionassist.cpp b/src/plugins/texteditor/codeassist/keywordscompletionassist.cpp index 3c2ff5a1fc5..25553033cd5 100644 --- a/src/plugins/texteditor/codeassist/keywordscompletionassist.cpp +++ b/src/plugins/texteditor/codeassist/keywordscompletionassist.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -243,4 +244,22 @@ KeywordsCompletionAssistProcessor::generateProposalList(const QStringList &words }); } +KeywordsCompletionAssistProvider::KeywordsCompletionAssistProvider(const Keywords &keyWords, + const QString &snippetGroup) + : m_keyWords(keyWords) + , m_snippetGroup(snippetGroup) +{ } + +IAssistProvider::RunType KeywordsCompletionAssistProvider::runType() const +{ + return Synchronous; +} + +IAssistProcessor *KeywordsCompletionAssistProvider::createProcessor() const +{ + auto processor = new KeywordsCompletionAssistProcessor(m_keyWords); + processor->setSnippetGroup(m_snippetGroup); + return processor; +} + } // namespace TextEditor diff --git a/src/plugins/texteditor/codeassist/keywordscompletionassist.h b/src/plugins/texteditor/codeassist/keywordscompletionassist.h index f65e726022a..c726dc42df4 100644 --- a/src/plugins/texteditor/codeassist/keywordscompletionassist.h +++ b/src/plugins/texteditor/codeassist/keywordscompletionassist.h @@ -28,8 +28,11 @@ #include "iassistprocessor.h" #include "assistproposalitem.h" #include "ifunctionhintproposalmodel.h" +#include "completionassistprovider.h" #include "../snippets/snippetassistcollector.h" +#include "texteditor/texteditorconstants.h" + namespace TextEditor { class AssistInterface; @@ -38,8 +41,8 @@ class TEXTEDITOR_EXPORT Keywords { public: Keywords() = default; - Keywords(const QStringList &variables, const QStringList &functions, - const QMap &functionArgs); + Keywords(const QStringList &variables, const QStringList &functions = QStringList(), + const QMap &functionArgs = QMap()); bool isVariable(const QString &word) const; bool isFunction(const QString &word) const; @@ -79,6 +82,21 @@ private: QStringList m_functionSymbols; }; +class TEXTEDITOR_EXPORT KeywordsCompletionAssistProvider : public CompletionAssistProvider +{ +public: + KeywordsCompletionAssistProvider(const Keywords &keyWords = Keywords(), + const QString &snippetGroup = QString(Constants::TEXT_SNIPPET_GROUP_ID)); + + // IAssistProvider interface + RunType runType() const override; + IAssistProcessor *createProcessor() const override; + +private: + Keywords m_keyWords; + QString m_snippetGroup; +}; + class TEXTEDITOR_EXPORT KeywordsCompletionAssistProcessor : public IAssistProcessor { public: diff --git a/src/plugins/texteditor/displaysettings.cpp b/src/plugins/texteditor/displaysettings.cpp index 3d2eb5c084f..410283a7f6e 100644 --- a/src/plugins/texteditor/displaysettings.cpp +++ b/src/plugins/texteditor/displaysettings.cpp @@ -25,6 +25,12 @@ #include "displaysettings.h" +#include "texteditorconstants.h" + +#include +#include + +#include #include #include @@ -131,7 +137,17 @@ bool DisplaySettings::equals(const DisplaySettings &ds) const && m_displayAnnotations == ds.m_displayAnnotations && m_annotationAlignment == ds.m_annotationAlignment && m_minimalAnnotationContent == ds.m_minimalAnnotationContent - ; + ; +} + +QLabel *DisplaySettings::createAnnotationSettingsLink() +{ + auto *label = new QLabel("Annotation Settings", Core::ICore::mainWindow()); + QObject::connect(label, &QLabel::linkActivated, []() { + Utils::ToolTip::hideImmediately(); + Core::ICore::showOptionsDialog(Constants::TEXT_EDITOR_DISPLAY_SETTINGS); + }); + return label; } } // namespace TextEditor diff --git a/src/plugins/texteditor/displaysettings.h b/src/plugins/texteditor/displaysettings.h index 326f9aad069..41cebc0c6a3 100644 --- a/src/plugins/texteditor/displaysettings.h +++ b/src/plugins/texteditor/displaysettings.h @@ -31,6 +31,7 @@ QT_BEGIN_NAMESPACE class QSettings; +class QLabel; QT_END_NAMESPACE namespace TextEditor { @@ -72,6 +73,8 @@ public: int m_minimalAnnotationContent = 15; bool equals(const DisplaySettings &ds) const; + + static QLabel *createAnnotationSettingsLink(); }; inline bool operator==(const DisplaySettings &t1, const DisplaySettings &t2) { return t1.equals(t2); } diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index c7554dd677f..5325e973ba4 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -46,6 +46,7 @@ #include "tabsettings.h" #include "textdocument.h" #include "textdocumentlayout.h" +#include "texteditorconstants.h" #include "texteditoroverlay.h" #include "refactoroverlay.h" #include "texteditorsettings.h" @@ -56,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -3291,30 +3293,32 @@ bool TextEditorWidgetPrivate::processAnnotaionTooltipRequest(const QTextBlock &b return false; for (const AnnotationRect &annotationRect : m_annotationRects[block.blockNumber()]) { - if (annotationRect.rect.contains(pos)) { - auto layout = new QGridLayout; - layout->setContentsMargins(0, 0, 0, 0); - layout->setSpacing(2); - annotationRect.mark->addToToolTipLayout(layout); - TextMarks marks = blockUserData->marks(); - if (marks.size() > 1) { - QFrame* separator = new QFrame(); - separator->setFrameShape(QFrame::HLine); - layout->addWidget(separator, 2, 0, 1, layout->columnCount()); - layout->addWidget(new QLabel(tr("Other annotations:")), 3, 0, 1, - layout->columnCount()); + if (!annotationRect.rect.contains(pos)) + continue; - Utils::sort(marks, [](const TextMark* mark1, const TextMark* mark2){ - return mark1->priority() > mark2->priority(); - }); - for (const TextMark *mark : Utils::asConst(marks)) { - if (mark != annotationRect.mark) - mark->addToToolTipLayout(layout); - } + auto layout = new QGridLayout; + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(2); + annotationRect.mark->addToToolTipLayout(layout); + TextMarks marks = blockUserData->marks(); + if (marks.size() > 1) { + QFrame* separator = new QFrame(); + separator->setFrameShape(QFrame::HLine); + layout->addWidget(separator, layout->rowCount(), 0, 1, -1); + layout->addWidget(new QLabel(tr("Other annotations:")), layout->rowCount(), 0, 1, -1); + + Utils::sort(marks, [](const TextMark* mark1, const TextMark* mark2){ + return mark1->priority() > mark2->priority(); + }); + for (const TextMark *mark : Utils::asConst(marks)) { + if (mark != annotationRect.mark) + mark->addToToolTipLayout(layout); } - ToolTip::show(q->mapToGlobal(pos), layout, q); - return true; } + layout->addWidget(DisplaySettings::createAnnotationSettingsLink(), + layout->rowCount(), 0, 1, -1, Qt::AlignRight); + ToolTip::show(q->mapToGlobal(pos), layout, q); + return true; } return false; } @@ -8136,13 +8140,7 @@ public: TextEditorFactoryPrivate(TextEditorFactory *parent) : q(parent), m_widgetCreator([]() { return new TextEditorWidget; }), - m_editorCreator([]() { return new BaseTextEditor; }), - m_completionAssistProvider(0), - m_useGenericHighlighter(false), - m_duplicatedSupported(true), - m_codeFoldingSupported(false), - m_paranthesesMatchinEnabled(false), - m_marksVisible(false) + m_editorCreator([]() { return new BaseTextEditor; }) {} BaseTextEditor *duplicateTextEditor(BaseTextEditor *other) @@ -8163,12 +8161,12 @@ public: TextEditorFactory::SyntaxHighLighterCreator m_syntaxHighlighterCreator; CommentDefinition m_commentDefinition; QList m_hoverHandlers; // owned - CompletionAssistProvider * m_completionAssistProvider; // owned - bool m_useGenericHighlighter; - bool m_duplicatedSupported; - bool m_codeFoldingSupported; - bool m_paranthesesMatchinEnabled; - bool m_marksVisible; + CompletionAssistProvider * m_completionAssistProvider = nullptr; // owned + bool m_useGenericHighlighter = false; + bool m_duplicatedSupported = true; + bool m_codeFoldingSupported = false; + bool m_paranthesesMatchinEnabled = false; + bool m_marksVisible = false; }; } /// namespace Internal @@ -8266,6 +8264,7 @@ void TextEditorFactory::setParenthesesMatchingEnabled(bool on) IEditor *TextEditorFactory::createEditor() { + static KeywordsCompletionAssistProvider basicSnippetProvider; TextDocumentPtr doc(d->m_documentCreator()); if (d->m_indenterCreator) @@ -8274,7 +8273,8 @@ IEditor *TextEditorFactory::createEditor() if (d->m_syntaxHighlighterCreator) doc->setSyntaxHighlighter(d->m_syntaxHighlighterCreator()); - doc->setCompletionAssistProvider(d->m_completionAssistProvider); + doc->setCompletionAssistProvider(d->m_completionAssistProvider ? d->m_completionAssistProvider + : &basicSnippetProvider); return d->createEditorHelper(doc); } diff --git a/src/share/3rdparty/generic-highlighter/alert.xml b/src/share/3rdparty/generic-highlighter/alert.xml index 942983ac371..ec881f15032 100644 --- a/src/share/3rdparty/generic-highlighter/alert.xml +++ b/src/share/3rdparty/generic-highlighter/alert.xml @@ -1,68 +1,38 @@ - -