diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index 42254415db5..7ab0201d974 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -48,9 +48,7 @@ jobs: - name: Checkout submodules run: | git submodule set-url -- perfparser https://code.qt.io/qt-creator/perfparser.git - git submodule update --init src/plugins/help/qlitehtml/litehtml - git submodule update --init src/tools/perfparser - git submodule update --init tests/unit/unittest/3rdparty/googletest + git submodule update --init - name: Download Ninja and CMake shell: cmake -P {0} diff --git a/cmake/QtCreatorAPIInternal.cmake b/cmake/QtCreatorAPIInternal.cmake index 6105c9f00e8..5404680da0f 100644 --- a/cmake/QtCreatorAPIInternal.cmake +++ b/cmake/QtCreatorAPIInternal.cmake @@ -360,8 +360,7 @@ function(enable_pch target) endif() unset(PCH_TARGET) - if ("Qt5::Widgets" IN_LIST dependencies OR - "Qt5::Gui" IN_LIST dependencies) + if ("Qt5::Widgets" IN_LIST dependencies) set(PCH_TARGET QtCreatorPchGui) elseif ("Qt5::Core" IN_LIST dependencies) set(PCH_TARGET QtCreatorPchConsole) diff --git a/doc/qtcreator/images/qtcreator-clang-copy-diagnostic-configuration.png b/doc/qtcreator/images/qtcreator-clang-copy-diagnostic-configuration.png new file mode 100644 index 00000000000..374d45132b2 Binary files /dev/null and b/doc/qtcreator/images/qtcreator-clang-copy-diagnostic-configuration.png differ diff --git a/doc/qtcreator/images/qtcreator-clang-tools-options-customized.png b/doc/qtcreator/images/qtcreator-clang-tools-options-customized.png index 1941f1adc08..7484117db5f 100644 Binary files a/doc/qtcreator/images/qtcreator-clang-tools-options-customized.png and b/doc/qtcreator/images/qtcreator-clang-tools-options-customized.png differ diff --git a/doc/qtcreator/images/qtcreator-clang-tools-options.png b/doc/qtcreator/images/qtcreator-clang-tools-options.png index 68616df1cd0..6f9cea77b92 100644 Binary files a/doc/qtcreator/images/qtcreator-clang-tools-options.png and b/doc/qtcreator/images/qtcreator-clang-tools-options.png differ diff --git a/doc/qtcreator/images/qtcreator-diagnostics-configuration.png b/doc/qtcreator/images/qtcreator-diagnostics-configuration.png index 4f68a780c45..73c6a7950fa 100644 Binary files a/doc/qtcreator/images/qtcreator-diagnostics-configuration.png and b/doc/qtcreator/images/qtcreator-diagnostics-configuration.png differ diff --git a/doc/qtcreator/src/analyze/creator-clang-static-analyzer.qdoc b/doc/qtcreator/src/analyze/creator-clang-static-analyzer.qdoc index 804b8695a12..4f1ce5a8bd9 100644 --- a/doc/qtcreator/src/analyze/creator-clang-static-analyzer.qdoc +++ b/doc/qtcreator/src/analyze/creator-clang-static-analyzer.qdoc @@ -113,10 +113,15 @@ icon, hover the mouse pointer over the line. Select the \inlineimage settings.png - button to configure Clang diagnostics globally for Clang tools. + button to customize Clang diagnostics for the current project. \image qtcreator-clang-tools-options-customized.png "Clang Tools customized settings" + To restore the global settings, select \uicontrol {Restore Global Settings}. + To view and modify the global settings, select + \uicontrol {Open Global Settings}. To open the Clang static analyzer, + select \uicontrol {Go to Analyzer}. + \section1 Configuring Clang Tools To configure Clang diagnostics globally for Clang tools: @@ -138,6 +143,9 @@ generated during the build. For big projects, not building the project might save some time. + \li To disable automatic analysis of open documents, deselect the + \uicontrol {Analyze open files} check box. + \li In the \uicontrol {Parallel jobs} field, select the number of jobs to run in parallel to make the analysis faster on multi-core processors. @@ -147,7 +155,7 @@ \li Select \uicontrol Copy to create a custom Clang configuration. - \image qtcreator-diagnostics-configuration.png "Diagnostics Configuration dialog" + \image qtcreator-clang-copy-diagnostic-configuration.png "Copy Diagnostic Configuration dialog" \li In the \uicontrol {Diagnostic configuration name} field, give the configuration a name, and then select \uicontrol OK. @@ -158,6 +166,8 @@ system to the Clang code model for displaying annotations in the code editor. + \image qtcreator-diagnostics-configuration.png "Diagnostics Configuration dialog" + \li In the \uicontrol {Clang-Tidy Checks} tab, select \uicontrol {Select Checks} to select the checks to perform. diff --git a/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.cpp index 22482c81780..18370be9fcb 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.cpp +++ b/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.cpp @@ -26,8 +26,10 @@ #include "valueschangedcommand.h" #include "sharedmemory.h" + #include #include +#include #include diff --git a/src/libs/advanceddockingsystem/dockcontainerwidget.cpp b/src/libs/advanceddockingsystem/dockcontainerwidget.cpp index 1b0af0dcf88..3b75ece3197 100644 --- a/src/libs/advanceddockingsystem/dockcontainerwidget.cpp +++ b/src/libs/advanceddockingsystem/dockcontainerwidget.cpp @@ -728,11 +728,11 @@ namespace ADS while (stateReader.readNextStartElement()) { QWidget *childNode = nullptr; bool result = true; - if (stateReader.name() == "splitter") { + if (stateReader.name() == QLatin1String("splitter")) { result = restoreSplitter(stateReader, childNode, testing); - } else if (stateReader.name() == "area") { + } else if (stateReader.name() == QLatin1String("area")) { result = restoreDockArea(stateReader, childNode, testing); - } else if (stateReader.name() == "sizes") { + } else if (stateReader.name() == QLatin1String("sizes")) { QString size = stateReader.readElementText().trimmed(); qCInfo(adsLog) << "Size: " << size; QTextStream textStream(&size); @@ -797,7 +797,7 @@ namespace ADS dockArea = new DockAreaWidget(m_dockManager, q); while (stateReader.readNextStartElement()) { - if (stateReader.name() != "widget") + if (stateReader.name() != QLatin1String("widget")) continue; auto objectName = stateReader.attributes().value("name"); @@ -849,10 +849,10 @@ namespace ADS { bool result = true; while (stateReader.readNextStartElement()) { - if (stateReader.name() == "splitter") { + if (stateReader.name() == QLatin1String("splitter")) { result = restoreSplitter(stateReader, createdWidget, testing); qCInfo(adsLog) << "Splitter"; - } else if (stateReader.name() == "area") { + } else if (stateReader.name() == QLatin1String("area")) { result = restoreDockArea(stateReader, createdWidget, testing); qCInfo(adsLog) << "DockAreaWidget"; } else { @@ -1302,7 +1302,7 @@ namespace ADS if (isFloating) { qCInfo(adsLog) << "Restore floating widget"; - if (!stateReader.readNextStartElement() || stateReader.name() != "geometry") + if (!stateReader.readNextStartElement() || stateReader.name() != QLatin1String("geometry")) return false; QByteArray geometryString = stateReader diff --git a/src/libs/advanceddockingsystem/dockmanager.cpp b/src/libs/advanceddockingsystem/dockmanager.cpp index a7d0653863a..eee95049f20 100644 --- a/src/libs/advanceddockingsystem/dockmanager.cpp +++ b/src/libs/advanceddockingsystem/dockmanager.cpp @@ -191,7 +191,7 @@ namespace ADS if (!stateReader.readNextStartElement()) return false; - if (stateReader.name() != "QtAdvancedDockingSystem") + if (stateReader.name() != QLatin1String("QtAdvancedDockingSystem")) return false; qCInfo(adsLog) << stateReader.attributes().value("version"); @@ -219,7 +219,7 @@ namespace ADS #endif int dockContainerCount = 0; while (stateReader.readNextStartElement()) { - if (stateReader.name() == "container") { + if (stateReader.name() == QLatin1String("container")) { result = restoreContainer(dockContainerCount, stateReader, testing); if (!result) break; diff --git a/src/libs/qtcreatorcdbext/CMakeLists.txt b/src/libs/qtcreatorcdbext/CMakeLists.txt index 394405f37fb..0a45ef0cc33 100644 --- a/src/libs/qtcreatorcdbext/CMakeLists.txt +++ b/src/libs/qtcreatorcdbext/CMakeLists.txt @@ -52,14 +52,15 @@ if (_library_enabled) return() endif() - set(PythonRegex "^(.*)/(.*)/(python[0-9]+)${CMAKE_IMPORT_LIBRARY_SUFFIX}$") + set(PythonRegex "^(.*)/(.*)/(python([0-9]+))${CMAKE_IMPORT_LIBRARY_SUFFIX}$") if (CMAKE_BUILD_TYPE STREQUAL "Debug") - set(PythonRegex "^(.*)/(.*)/(python[0-9]+_d)${CMAKE_IMPORT_LIBRARY_SUFFIX}$") + set(PythonRegex "^(.*)/(.*)/(python([0-9]+)_d)${CMAKE_IMPORT_LIBRARY_SUFFIX}$") endif() foreach(lib IN LISTS PYTHON_LIBRARIES) if (lib MATCHES ${PythonRegex}) set(PythonDll "${CMAKE_MATCH_1}/${CMAKE_MATCH_3}${CMAKE_SHARED_LIBRARY_SUFFIX}") + set(PythonZip "${CMAKE_MATCH_1}/python${CMAKE_MATCH_4}.zip") break() endif() endforeach() @@ -84,13 +85,16 @@ if (_library_enabled) pyvalue.cpp pyvalue.h ) - install(FILES "${PythonDll}" + install(FILES + "${PythonDll}" + "${PythonZip}" DESTINATION lib/qtcreatorcdbext${ArchSuffix}/ COMPONENT qtcreatorcdbext) add_custom_target(copy_python_dll ALL VERBATIM) add_custom_command(TARGET copy_python_dll POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy "${PythonDll}" "${PROJECT_BINARY_DIR}/lib/qtcreatorcdbext${ArchSuffix}/" + COMMAND "${CMAKE_COMMAND}" -E copy "${PythonZip}" "${PROJECT_BINARY_DIR}/lib/qtcreatorcdbext${ArchSuffix}/" VERBATIM ) endif() diff --git a/src/libs/utils/aspects.cpp b/src/libs/utils/aspects.cpp index 217a3abfa70..77b4eda3062 100644 --- a/src/libs/utils/aspects.cpp +++ b/src/libs/utils/aspects.cpp @@ -85,6 +85,36 @@ void BaseAspect::setConfigWidgetCreator(const ConfigWidgetCreator &configWidgetC m_configWidgetCreator = configWidgetCreator; } +/*! + Returns the key to be used when accessing the settings. + + \sa setSettingsKey() +*/ +QString BaseAspect::settingsKey() const +{ + return m_settingsKey; +} + +/*! + Sets the key to be used when accessing the settings. + + \sa settingsKey() +*/ +void BaseAspect::setSettingsKey(const QString &key) +{ + m_settingsKey = key; +} + +/*! + Sets the key and group to be used when accessing the settings. + + \sa settingsKey() +*/ +void BaseAspect::setSettingsKey(const QString &group, const QString &key) +{ + m_settingsKey = group + "/" + key; +} + /*! \internal */ diff --git a/src/libs/utils/aspects.h b/src/libs/utils/aspects.h index 6308a13e8c7..8313bcc83dc 100644 --- a/src/libs/utils/aspects.h +++ b/src/libs/utils/aspects.h @@ -59,11 +59,12 @@ public: void setId(Utils::Id id) { m_id = id; } void setDisplayName(const QString &displayName) { m_displayName = displayName; } - void setSettingsKey(const QString &settingsKey) { m_settingsKey = settingsKey; } + void setSettingsKey(const QString &settingsKey); + void setSettingsKey(const QString &group, const QString &key); Utils::Id id() const { return m_id; } QString displayName() const { return m_displayName; } - QString settingsKey() const { return m_settingsKey; } + QString settingsKey() const; bool isVisible() const { return m_visible; } void setVisible(bool visible) { m_visible = visible; } diff --git a/src/libs/utils/layoutbuilder.cpp b/src/libs/utils/layoutbuilder.cpp index bc4e4c59f70..2edb07c343c 100644 --- a/src/libs/utils/layoutbuilder.cpp +++ b/src/libs/utils/layoutbuilder.cpp @@ -31,6 +31,7 @@ #include #include +#include #include namespace Utils { @@ -69,7 +70,7 @@ LayoutBuilder::LayoutItem::LayoutItem() Constructs a layout item proxy for \a layout, spanning the number of cells specified by \a span in the target layout, with alignment \a align. */ -LayoutBuilder::LayoutItem::LayoutItem(QLayout *layout, int span, Qt::Alignment align) +LayoutBuilder::LayoutItem::LayoutItem(QLayout *layout, int span, Alignment align) : layout(layout), span(span), align(align) {} @@ -77,7 +78,7 @@ LayoutBuilder::LayoutItem::LayoutItem(QLayout *layout, int span, Qt::Alignment a Constructs a layout item proxy for \a widget, spanning the number of cell specified by \a span in the target layout, with alignment \a align. */ -LayoutBuilder::LayoutItem::LayoutItem(QWidget *widget, int span, Qt::Alignment align) +LayoutBuilder::LayoutItem::LayoutItem(QWidget *widget, int span, Alignment align) : widget(widget), span(span), align(align) {} @@ -269,8 +270,12 @@ LayoutBuilder &LayoutBuilder::addItem(const LayoutItem &item) item.aspect->addToLayout(*this); } else { if (m_gridLayout) { - if (auto widget = item.widget) - m_gridLayout->addWidget(widget, m_currentGridRow, m_currentGridColumn, 1, item.span, item.align); + if (auto widget = item.widget) { + Qt::Alignment align; + if (item.align == AlignAsFormLabel) + align = Qt::Alignment(widget->style()->styleHint(QStyle::SH_FormLayoutLabelAlignment)); + m_gridLayout->addWidget(widget, m_currentGridRow, m_currentGridColumn, 1, item.span, align); + } m_currentGridColumn += item.span; } else { m_pendingFormItems.append(item); diff --git a/src/libs/utils/layoutbuilder.h b/src/libs/utils/layoutbuilder.h index ddf60185181..1a2ad1f5e51 100644 --- a/src/libs/utils/layoutbuilder.h +++ b/src/libs/utils/layoutbuilder.h @@ -45,6 +45,8 @@ class QTCREATOR_UTILS_EXPORT LayoutBuilder { public: enum LayoutType { GridLayout, FormLayout }; + enum Alignment { DefaultAlignment, AlignAsFormLabel }; + explicit LayoutBuilder(QWidget *parent, LayoutType layoutType = FormLayout); explicit LayoutBuilder(QLayout *layout); // Adds to existing layout. @@ -54,8 +56,8 @@ public: { public: LayoutItem(); - LayoutItem(QLayout *layout, int span = 1, Qt::Alignment align = {}); - LayoutItem(QWidget *widget, int span = 1, Qt::Alignment align = {}); + LayoutItem(QLayout *layout, int span = 1, Alignment align = {}); + LayoutItem(QWidget *widget, int span = 1, Alignment align = {}); LayoutItem(BaseAspect *aspect); LayoutItem(const QString &text); @@ -64,7 +66,7 @@ public: BaseAspect *aspect = nullptr; QString text; int span = 1; - Qt::Alignment align; + Alignment align; }; LayoutBuilder &addItem(const LayoutItem &item); diff --git a/src/libs/utils/savedaction.cpp b/src/libs/utils/savedaction.cpp index 65f9492a6b0..6388818dcbb 100644 --- a/src/libs/utils/savedaction.cpp +++ b/src/libs/utils/savedaction.cpp @@ -113,38 +113,6 @@ void SavedAction::setDefaultValue(const QVariant &value) } -/*! - Returns the key to be used when accessing the settings. - - \sa settingsKey() -*/ -QString SavedAction::settingsKey() const -{ - return m_settingsKey; -} - - -/*! - Sets the key to be used when accessing the settings. - - \sa settingsKey() -*/ -void SavedAction::setSettingsKey(const QString &key) -{ - m_settingsKey = key; -} - - -/*! - Sets the key and group to be used when accessing the settings. - - \sa settingsKey() -*/ -void SavedAction::setSettingsKey(const QString &group, const QString &key) -{ - m_settingsKey = group + "/" + key; -} - QString SavedAction::toString() const { return QLatin1String("value: ") + m_value.toString() diff --git a/src/libs/utils/savedaction.h b/src/libs/utils/savedaction.h index 98403d683be..a6188ab5091 100644 --- a/src/libs/utils/savedaction.h +++ b/src/libs/utils/savedaction.h @@ -54,11 +54,6 @@ public: void trigger(const QVariant &data); - // used for persistency - QString settingsKey() const; - void setSettingsKey(const QString &key); - void setSettingsKey(const QString &group, const QString &key); - virtual void readSettings(const QSettings *settings); virtual void writeSettings(QSettings *settings); @@ -88,7 +83,6 @@ private: QVariant m_value; QVariant m_defaultValue; - QString m_settingsKey; QString m_dialogText; QWidget *m_widget = nullptr; QAction m_action; diff --git a/src/plugins/android/avddialog.cpp b/src/plugins/android/avddialog.cpp index ded445e2cb1..f4eedb2876b 100644 --- a/src/plugins/android/avddialog.cpp +++ b/src/plugins/android/avddialog.cpp @@ -244,14 +244,16 @@ void AvdDialog::updateApiLevelComboBox() if (installedSystemImages.isEmpty()) { m_avdDialog.targetApiComboBox->setEnabled(false); m_avdDialog.warningText->setVisible(true); - m_avdDialog.warningText->setText(tr("Cannot create a new AVD. No sufficiently recent Android SDK available.\n" - "Install an SDK of at least API version %1.") - .arg(m_minApiLevel)); + m_avdDialog.warningText->setText( + tr("Cannot create a new AVD. No suitable Android system image is installed.\n" + "Install a system image of at least API version %1 from the SDK Manager tab.") + .arg(m_minApiLevel)); } else if (filteredList.isEmpty()) { m_avdDialog.targetApiComboBox->setEnabled(false); m_avdDialog.warningText->setVisible(true); - m_avdDialog.warningText->setText(tr("Cannot create a AVD for ABI %1. Install an image for it.") - .arg(abi())); + m_avdDialog.warningText->setText(tr("Cannot create an AVD for ABI %1. Install a system " + "image for it from the SDK Manager tab first.") + .arg(abi())); } else { m_avdDialog.warningText->setVisible(false); m_avdDialog.targetApiComboBox->setEnabled(true); diff --git a/src/plugins/autotest/catch/catchoutputreader.cpp b/src/plugins/autotest/catch/catchoutputreader.cpp index 760d5214cb2..4a46c7722ce 100644 --- a/src/plugins/autotest/catch/catchoutputreader.cpp +++ b/src/plugins/autotest/catch/catchoutputreader.cpp @@ -143,16 +143,16 @@ void CatchOutputReader::processOutputLine(const QByteArray &outputLineWithNewLin case QXmlStreamReader::EndElement: { const auto currentTag = m_xmlReader.name(); - if (currentTag == CatchXml::SectionElement) { + if (currentTag == QLatin1String(CatchXml::SectionElement)) { sendResult(ResultType::TestEnd); testOutputNodeFinished(SectionNode); - } else if (currentTag == CatchXml::TestCaseElement) { + } else if (currentTag == QLatin1String(CatchXml::TestCaseElement)) { sendResult(ResultType::TestEnd); testOutputNodeFinished(TestCaseNode); - } else if (currentTag == CatchXml::GroupElement) { + } else if (currentTag == QLatin1String(CatchXml::GroupElement)) { testOutputNodeFinished(GroupNode); - } else if (currentTag == CatchXml::ExpressionElement - || currentTag == CatchXml::BenchmarkResults) { + } else if (currentTag == QLatin1String(CatchXml::ExpressionElement) + || currentTag == QLatin1String(CatchXml::BenchmarkResults)) { sendResult(m_currentResult); m_currentExpression.clear(); m_testCaseInfo.pop(); diff --git a/src/plugins/autotest/testresultspane.cpp b/src/plugins/autotest/testresultspane.cpp index c3518b44e7a..8a6ef9022d6 100644 --- a/src/plugins/autotest/testresultspane.cpp +++ b/src/plugins/autotest/testresultspane.cpp @@ -343,10 +343,6 @@ void TestResultsPane::clearContents() clearMarks(); } -void TestResultsPane::visibilityChanged(bool /*visible*/) -{ -} - void TestResultsPane::setFocus() { } diff --git a/src/plugins/autotest/testresultspane.h b/src/plugins/autotest/testresultspane.h index 658165f01db..0f3d05c1cff 100644 --- a/src/plugins/autotest/testresultspane.h +++ b/src/plugins/autotest/testresultspane.h @@ -85,7 +85,6 @@ public: QString displayName() const override; int priorityInStatusBar() const override; void clearContents() override; - void visibilityChanged(bool visible) override; void setFocus() override; bool hasFocus() const override; bool canFocus() const override; diff --git a/src/plugins/baremetal/debugservers/uvsc/uvtargetdevicemodel.cpp b/src/plugins/baremetal/debugservers/uvsc/uvtargetdevicemodel.cpp index c8bf0fdea66..0fbf6ffdecb 100644 --- a/src/plugins/baremetal/debugservers/uvsc/uvtargetdevicemodel.cpp +++ b/src/plugins/baremetal/debugservers/uvsc/uvtargetdevicemodel.cpp @@ -249,7 +249,7 @@ void DeviceSelectionModel::parsePackage(const QString &packageFile) QXmlStreamReader in(&f); while (in.readNextStartElement()) { const auto elementName = in.name(); - if (elementName == "package") + if (elementName == QLatin1String("package")) parsePackage(in, packageFile); else in.skipCurrentElement(); @@ -265,18 +265,18 @@ void DeviceSelectionModel::parsePackage(QXmlStreamReader &in, const QString &pac child->version = extractPackVersion(packageFile); while (in.readNextStartElement()) { const auto elementName = in.name(); - if (elementName == "name") { + if (elementName == QLatin1String("name")) { fillElementProperty(in, child->name); - } else if (elementName == "description") { + } else if (elementName == QLatin1String("description")) { fillElementProperty(in, child->desc); - } else if (elementName == "vendor") { + } else if (elementName == QLatin1String("vendor")) { fillVendor(in, child->vendorName, child->vendorId); - } else if (elementName == "url") { + } else if (elementName == QLatin1String("url")) { fillElementProperty(in, child->url); - } else if (elementName == "devices") { + } else if (elementName == QLatin1String("devices")) { while (in.readNextStartElement()) { const auto elementName = in.name(); - if (elementName == "family") + if (elementName == QLatin1String("family")) parseFamily(in, child); else in.skipCurrentElement(); @@ -297,17 +297,17 @@ void DeviceSelectionModel::parseFamily(QXmlStreamReader &in, DeviceSelectionItem fillVendor(attrs.value("Dvendor").toString(), child->vendorName, child->vendorId); while (in.readNextStartElement()) { const auto elementName = in.name(); - if (elementName == "processor") { + if (elementName == QLatin1String("processor")) { fillCpu(in, child->cpu); - } else if (elementName == "algorithm") { + } else if (elementName == QLatin1String("algorithm")) { fillAlgorithms(in, child->algorithms); - } else if (elementName == "memory") { + } else if (elementName == QLatin1String("memory")) { fillMemories(in, child->memories); - } else if (elementName == "description") { + } else if (elementName == QLatin1String("description")) { fillElementProperty(in, child->desc); - } else if (elementName == "subFamily") { + } else if (elementName == QLatin1String("subFamily")) { parseSubFamily(in, child); - } else if (elementName == "device") { + } else if (elementName == QLatin1String("device")) { parseDevice(in, child); } else { in.skipCurrentElement(); @@ -324,11 +324,11 @@ void DeviceSelectionModel::parseSubFamily(QXmlStreamReader &in, DeviceSelectionI child->name = attrs.value("DsubFamily").toString(); while (in.readNextStartElement()) { const auto elementName = in.name(); - if (elementName == "processor") { + if (elementName == QLatin1String("processor")) { fillCpu(in, child->cpu); - } else if (elementName == "debug") { + } else if (elementName == QLatin1String("debug")) { fillSvd(in, child->svd); - } else if (elementName == "device") { + } else if (elementName == QLatin1String("device")) { parseDevice(in, child); } else { in.skipCurrentElement(); @@ -345,17 +345,17 @@ void DeviceSelectionModel::parseDevice(QXmlStreamReader &in, DeviceSelectionItem child->name = attrs.value("Dname").toString(); while (in.readNextStartElement()) { const auto elementName = in.name(); - if (elementName == "processor") { + if (elementName == QLatin1String("processor")) { fillCpu(in, child->cpu); - } else if (elementName == "debug") { + } else if (elementName == QLatin1String("debug")) { fillSvd(in, child->svd); - } else if (elementName == "description") { + } else if (elementName == QLatin1String("description")) { fillElementProperty(in, child->desc); - } else if (elementName == "memory") { + } else if (elementName == QLatin1String("memory")) { fillMemories(in, child->memories); - } else if (elementName == "algorithm") { + } else if (elementName == QLatin1String("algorithm")) { fillAlgorithms(in, child->algorithms); - } else if (elementName == "variant") { + } else if (elementName == QLatin1String("variant")) { parseDeviceVariant(in, child); } else { in.skipCurrentElement(); @@ -372,11 +372,11 @@ void DeviceSelectionModel::parseDeviceVariant(QXmlStreamReader &in, DeviceSelect child->name = attrs.value("Dvariant").toString(); while (in.readNextStartElement()) { const auto elementName = in.name(); - if (elementName == "processor") { + if (elementName == QLatin1String("processor")) { fillCpu(in, child->cpu); - } else if (elementName == "memory") { + } else if (elementName == QLatin1String("memory")) { fillMemories(in, child->memories); - } else if (elementName == "algorithm") { + } else if (elementName == QLatin1String("algorithm")) { fillAlgorithms(in, child->algorithms); } else { in.skipCurrentElement(); diff --git a/src/plugins/beautifier/abstractsettings.cpp b/src/plugins/beautifier/abstractsettings.cpp index 3c65322bc13..3d9bc75b1a5 100644 --- a/src/plugins/beautifier/abstractsettings.cpp +++ b/src/plugins/beautifier/abstractsettings.cpp @@ -319,7 +319,7 @@ void AbstractSettings::readDocumentation() QXmlStreamReader xml(&file); if (!xml.readNextStartElement()) return; - if (xml.name() != Constants::DOCUMENTATION_XMLROOT) { + if (xml.name() != QLatin1String(Constants::DOCUMENTATION_XMLROOT)) { BeautifierPlugin::showError(tr("The file \"%1\" is not a valid documentation file.") .arg(filename)); return; diff --git a/src/plugins/clangcodemodel/test/clangbatchfileprocessor.cpp b/src/plugins/clangcodemodel/test/clangbatchfileprocessor.cpp index 85312170d97..b1ce0cd6ebb 100644 --- a/src/plugins/clangcodemodel/test/clangbatchfileprocessor.cpp +++ b/src/plugins/clangcodemodel/test/clangbatchfileprocessor.cpp @@ -469,7 +469,7 @@ bool CompleteCommand::run() auto *processor = ClangEditorDocumentProcessor::get(documentFilePath); QTC_ASSERT(processor, return false); - return completionResults(editor, QStringList(), timeOutInMs()); + return !completionResults(editor, QStringList(), timeOutInMs()).isNull(); } Command::Ptr CompleteCommand::parse(BatchFileLineTokenizer &arguments, diff --git a/src/plugins/coreplugin/externaltool.cpp b/src/plugins/coreplugin/externaltool.cpp index 8994686cace..1f46b9d6c33 100644 --- a/src/plugins/coreplugin/externaltool.cpp +++ b/src/plugins/coreplugin/externaltool.cpp @@ -352,11 +352,11 @@ static void localizedText(const QStringList &locales, QXmlStreamReader *reader, static bool parseOutputAttribute(const QString &attribute, QXmlStreamReader *reader, ExternalTool::OutputHandling *value) { const auto output = reader->attributes().value(attribute); - if (output == kOutputShowInPane) { + if (output == QLatin1String(kOutputShowInPane)) { *value = ExternalTool::ShowInPane; - } else if (output == kOutputReplaceSelection) { + } else if (output == QLatin1String(kOutputReplaceSelection)) { *value = ExternalTool::ReplaceSelection; - } else if (output == kOutputIgnore) { + } else if (output == QLatin1String(kOutputIgnore)) { *value = ExternalTool::Ignore; } else { reader->raiseError("Allowed values for output attribute are 'showinpane','replaceselection','ignore'"); @@ -374,19 +374,19 @@ ExternalTool * ExternalTool::createFromXml(const QByteArray &xml, QString *error auto tool = new ExternalTool; QXmlStreamReader reader(xml); - if (!reader.readNextStartElement() || reader.name() != kExternalTool) + if (!reader.readNextStartElement() || reader.name() != QLatin1String(kExternalTool)) reader.raiseError("Missing start element "); tool->m_id = reader.attributes().value(kId).toString(); if (tool->m_id.isEmpty()) reader.raiseError("Missing or empty id attribute for "); while (reader.readNextStartElement()) { - if (reader.name() == kDescription) { + if (reader.name() == QLatin1String(kDescription)) { localizedText(locales, &reader, &descriptionLocale, &tool->m_description); - } else if (reader.name() == kDisplayName) { + } else if (reader.name() == QLatin1String(kDisplayName)) { localizedText(locales, &reader, &nameLocale, &tool->m_displayName); - } else if (reader.name() == kCategory) { + } else if (reader.name() == QLatin1String(kCategory)) { localizedText(locales, &reader, &categoryLocale, &tool->m_displayCategory); - } else if (reader.name() == kOrder) { + } else if (reader.name() == QLatin1String(kOrder)) { if (tool->m_order >= 0) { reader.raiseError("only one element allowed"); break; @@ -395,7 +395,7 @@ ExternalTool * ExternalTool::createFromXml(const QByteArray &xml, QString *error tool->m_order = reader.readElementText().toInt(&ok); if (!ok || tool->m_order < 0) reader.raiseError(" element requires non-negative integer value"); - } else if (reader.name() == kExecutable) { + } else if (reader.name() == QLatin1String(kExecutable)) { if (reader.attributes().hasAttribute(kOutput)) { if (!parseOutputAttribute(kOutput, &reader, &tool->m_outputHandling)) break; @@ -406,9 +406,9 @@ ExternalTool * ExternalTool::createFromXml(const QByteArray &xml, QString *error } if (reader.attributes().hasAttribute(kModifiesDocument)) { const auto value = reader.attributes().value(kModifiesDocument); - if (value == kYes || value == kTrue) { + if (value == QLatin1String(kYes) || value == QLatin1String(kTrue)) { tool->m_modifiesCurrentDocument = true; - } else if (value == kNo || value == kFalse) { + } else if (value == QLatin1String(kNo) || value == QLatin1String(kFalse)) { tool->m_modifiesCurrentDocument = false; } else { reader.raiseError("Allowed values for modifiesdocument attribute are 'yes','true','no','false'"); @@ -416,33 +416,33 @@ ExternalTool * ExternalTool::createFromXml(const QByteArray &xml, QString *error } } while (reader.readNextStartElement()) { - if (reader.name() == kPath) { + if (reader.name() == QLatin1String(kPath)) { tool->m_executables.append(reader.readElementText()); - } else if (reader.name() == kArguments) { + } else if (reader.name() == QLatin1String(kArguments)) { if (!tool->m_arguments.isEmpty()) { reader.raiseError("only one element allowed"); break; } tool->m_arguments = reader.readElementText(); - } else if (reader.name() == kInput) { + } else if (reader.name() == QLatin1String(kInput)) { if (!tool->m_input.isEmpty()) { reader.raiseError("only one element allowed"); break; } tool->m_input = reader.readElementText(); - } else if (reader.name() == kWorkingDirectory) { + } else if (reader.name() == QLatin1String(kWorkingDirectory)) { if (!tool->m_workingDirectory.isEmpty()) { reader.raiseError("only one element allowed"); break; } tool->m_workingDirectory = reader.readElementText(); - } else if (reader.name() == kBaseEnvironmentId) { + } else if (reader.name() == QLatin1String(kBaseEnvironmentId)) { if (tool->m_baseEnvironmentProviderId.isValid()) { reader.raiseError("only one element allowed"); break; } tool->m_baseEnvironmentProviderId = Id::fromString(reader.readElementText()); - } else if (reader.name() == kEnvironment) { + } else if (reader.name() == QLatin1String(kEnvironment)) { if (!tool->m_environment.isEmpty()) { reader.raiseError("only one element allowed"); break; diff --git a/src/plugins/coreplugin/ioutputpane.h b/src/plugins/coreplugin/ioutputpane.h index 8d3bfc50ef5..68d62550a4e 100644 --- a/src/plugins/coreplugin/ioutputpane.h +++ b/src/plugins/coreplugin/ioutputpane.h @@ -58,7 +58,7 @@ public: virtual int priorityInStatusBar() const = 0; virtual void clearContents() = 0; - virtual void visibilityChanged(bool visible) = 0; + virtual void visibilityChanged(bool visible); virtual void setFocus() = 0; virtual bool hasFocus() const = 0; diff --git a/src/plugins/coreplugin/manhattanstyle.cpp b/src/plugins/coreplugin/manhattanstyle.cpp index d1617534d51..92c59e77eae 100644 --- a/src/plugins/coreplugin/manhattanstyle.cpp +++ b/src/plugins/coreplugin/manhattanstyle.cpp @@ -34,11 +34,13 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -116,6 +118,12 @@ bool lightColored(const QWidget *widget) return false; } +static bool isDarkFusionStyle(const QStyle *style) +{ + return creatorTheme()->flag(Theme::DarkUserInterface) + && strcmp(style->metaObject()->className(), "QFusionStyle") == 0; +} + class ManhattanStylePrivate { public: @@ -385,11 +393,150 @@ int ManhattanStyle::styleHint(StyleHint hint, const QStyleOption *option, const return ret; } +static void drawPrimitiveTweakedForDarkTheme(QStyle::PrimitiveElement element, + const QStyleOption *option, + QPainter *painter, const QWidget *widget) +{ + const bool hasFocus = option->state & QStyle::State_HasFocus; + const bool isChecked = option->state & QStyle::State_On; + const bool isPartiallyChecked = option->state & QStyle::State_NoChange; + const bool isEnabled = option->state & QStyle::State_Enabled; + const bool isSunken = option->state & QStyle::State_Sunken; + + const QColor frameColor = isEnabled ? option->palette.color(QPalette::Mid).darker(132) + : creatorTheme()->color(Theme::BackgroundColorDisabled); + const QColor indicatorColor = isEnabled ? option->palette.color(QPalette::Mid).darker(90) + : creatorTheme()->color(Theme::BackgroundColorDisabled); + const QColor bgColor = isSunken ? option->palette.color(QPalette::Mid).darker() + : option->palette.color(QPalette::Window); + const QColor hlColor = option->palette.color(QPalette::Highlight); + + QPen framePen(hasFocus ? hlColor : frameColor, 1); + framePen.setJoinStyle(Qt::MiterJoin); + QPen indicatorPen(indicatorColor, 1); + indicatorPen.setJoinStyle(Qt::MiterJoin); + + painter->save(); + painter->setRenderHint(QPainter::Antialiasing); + + switch (element) { + case QStyle::PE_Frame: { + const QRectF frameRectF = QRectF(option->rect).adjusted(0.5, 0.5, -0.5, -0.5); + painter->setPen(framePen); + painter->drawRect(frameRectF); + break; + } + case QStyle::PE_FrameLineEdit: { + const bool isComboBox = widget->inherits("QComboBox"); + const QRectF frameRectF = + QRectF(option->rect).adjusted(0.5, 0.5, isComboBox ? -8.5 : -0.5, -0.5); + painter->setPen(framePen); + painter->drawRect(frameRectF); + break; + } + case QStyle::PE_FrameGroupBox: { + // Snippet from QFusionStyle::drawPrimitive - BEGIN + static const int groupBoxTopMargin = 3; + int topMargin = 0; + auto control = dynamic_cast(widget); + if (control && !control->isCheckable() && control->title().isEmpty()) { + // Shrinking the topMargin if Not checkable AND title is empty + topMargin = groupBoxTopMargin; + } else { + topMargin = qMax(widget->style()->pixelMetric(QStyle::PM_ExclusiveIndicatorHeight), + option->fontMetrics.height()) + groupBoxTopMargin; + } + // Snippet from QFusionStyle::drawPrimitive - END + + const QRectF frameRectF = QRectF(option->rect).adjusted(0.5, topMargin + 0.5, -0.5, -0.5); + painter->setPen(framePen); + if (isEnabled) + painter->setOpacity(0.5); + painter->drawRect(frameRectF); + break; + } + case QStyle::PE_IndicatorRadioButton: { + const double lineWidth = 1.666; + const double o = lineWidth / 2; + indicatorPen.setWidth(lineWidth); + painter->setPen(framePen); + if (isEnabled) + painter->setBrush(bgColor); + painter->drawRoundedRect(QRectF(option->rect).adjusted(o, o, -o, -o), + 100, 100, Qt::RelativeSize); + + if (isChecked) { + painter->setPen(Qt::NoPen); + painter->setBrush(indicatorColor); + const double o = 4.25; + painter->drawRoundedRect(QRectF(option->rect).adjusted(o, o, -o, -o), + 100, 100, Qt::RelativeSize); + } + break; + } + case QStyle::PE_IndicatorCheckBox: { + const QRectF frameRectF = QRectF(option->rect).adjusted(0.5, 0.5, -0.5, -0.5); + painter->setPen(framePen); + if (isEnabled) + painter->setBrush(bgColor); + painter->drawRect(frameRectF); + + if (isPartiallyChecked) { + QPen outline(indicatorColor, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); + painter->setPen(outline); + QColor fill(frameColor); + fill.setAlphaF(0.8); + painter->setBrush(fill); + const double o = 3.5; + painter->drawRect(QRectF(option->rect).adjusted(o, o, -o, -o)); + } else if (isChecked) { + const double o = 3; + const QRectF r = QRectF(option->rect).adjusted(o, o, -o, -o); + QPen checkMarkPen(indicatorColor, 1.75, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); + painter->setPen(checkMarkPen); + painter->drawPolyline(QPolygonF({QPointF(r.left(), r.top() + r.height() / 2), + QPointF(r.left() + r.width() / 2.3, r.bottom()), + r.topRight()})); + } + break; + } + case QStyle::PE_IndicatorTabClose: { + QWindow *window = widget->window()->windowHandle(); + QRect iconRect = QRect(0, 0, 16, 16); + iconRect.moveCenter(option->rect.center()); + const QIcon::Mode mode = !isEnabled ? QIcon::Disabled : QIcon::Normal; + const static QIcon closeIcon = Utils::Icons::CLOSE_FOREGROUND.icon(); + if (option->state & QStyle::State_MouseOver) + widget->style()->drawPrimitive(QStyle::PE_PanelButtonCommand, option, painter, widget); + const QPixmap iconPx = + closeIcon.pixmap(window, iconRect.size() * widget->devicePixelRatio(), mode); + painter->drawPixmap(iconRect, iconPx); + break; + } + default: + QTC_ASSERT_STRING("Unhandled QStyle::PrimitiveElement case"); + break; + } + painter->restore(); +} + void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { - if (!panelWidget(widget)) { - QProxyStyle::drawPrimitive(element, option, painter, widget); + const bool isPanelWidget = panelWidget(widget); + if (!isPanelWidget) { + const bool tweakDarkTheme = + (element == PE_Frame + || element == PE_FrameLineEdit + || element == PE_FrameGroupBox + || element == PE_IndicatorRadioButton + || element == PE_IndicatorCheckBox + || element == PE_IndicatorTabClose) + && isDarkFusionStyle(baseStyle()); + if (tweakDarkTheme) + drawPrimitiveTweakedForDarkTheme(element, option, painter, widget); + else + QProxyStyle::drawPrimitive(element, option, painter, widget); return; } diff --git a/src/plugins/coreplugin/messageoutputwindow.cpp b/src/plugins/coreplugin/messageoutputwindow.cpp index 384b34c113a..97b47a1e2f9 100644 --- a/src/plugins/coreplugin/messageoutputwindow.cpp +++ b/src/plugins/coreplugin/messageoutputwindow.cpp @@ -105,10 +105,6 @@ QString MessageOutputWindow::displayName() const return tr("General Messages"); } -void MessageOutputWindow::visibilityChanged(bool /*b*/) -{ -} - void MessageOutputWindow::append(const QString &text) { m_widget->appendMessage(text, Utils::DebugFormat); diff --git a/src/plugins/coreplugin/messageoutputwindow.h b/src/plugins/coreplugin/messageoutputwindow.h index 152a707702b..e43688b3199 100644 --- a/src/plugins/coreplugin/messageoutputwindow.h +++ b/src/plugins/coreplugin/messageoutputwindow.h @@ -45,7 +45,6 @@ public: QString displayName() const override; int priorityInStatusBar() const override; void clearContents() override; - void visibilityChanged(bool visible) override; void append(const QString &text); bool canFocus() const override; diff --git a/src/plugins/coreplugin/outputpanemanager.cpp b/src/plugins/coreplugin/outputpanemanager.cpp index 4240c1120cd..92008d6b046 100644 --- a/src/plugins/coreplugin/outputpanemanager.cpp +++ b/src/plugins/coreplugin/outputpanemanager.cpp @@ -126,6 +126,10 @@ QList IOutputPane::toolBarWidgets() const return widgets << m_zoomInButton << m_zoomOutButton; } +void IOutputPane::visibilityChanged(bool /*visible*/) +{ +} + void IOutputPane::setFont(const QFont &font) { emit fontChanged(font); diff --git a/src/plugins/cppeditor/resourcepreviewhoverhandler.cpp b/src/plugins/cppeditor/resourcepreviewhoverhandler.cpp index 003c97e37aa..07fb181d7b7 100644 --- a/src/plugins/cppeditor/resourcepreviewhoverhandler.cpp +++ b/src/plugins/cppeditor/resourcepreviewhoverhandler.cpp @@ -96,12 +96,12 @@ static QString findResourceInFile(const QString &resName, const QString &filePat while (!xmlr.atEnd() && !xmlr.hasError()) { const QXmlStreamReader::TokenType token = xmlr.readNext(); if (token == QXmlStreamReader::StartElement) { - if (xmlr.name() == "qresource") { + if (xmlr.name() == QLatin1String("qresource")) { const QXmlStreamAttributes sa = xmlr.attributes(); const QString prefixName = sa.value("prefix").toString(); if (!prefixName.isEmpty()) prefixStack.push_back(prefixName); - } else if (xmlr.name() == "file") { + } else if (xmlr.name() == QLatin1String("file")) { const QXmlStreamAttributes sa = xmlr.attributes(); const QString aliasName = sa.value("alias").toString(); const QString fileName = xmlr.readElementText(); @@ -117,7 +117,7 @@ static QString findResourceInFile(const QString &resName, const QString &filePat return fileName; } } else if (token == QXmlStreamReader::EndElement) { - if (xmlr.name() == "qresource") { + if (xmlr.name() == QLatin1String("qresource")) { if (!prefixStack.isEmpty()) prefixStack.pop_back(); } diff --git a/src/plugins/debugger/console/console.cpp b/src/plugins/debugger/console/console.cpp index 1b29f70d61f..074d1f3c8cd 100644 --- a/src/plugins/debugger/console/console.cpp +++ b/src/plugins/debugger/console/console.cpp @@ -175,10 +175,6 @@ void Console::clearContents() m_consoleItemModel->clear(); } -void Console::visibilityChanged(bool /*visible*/) -{ -} - bool Console::canFocus() const { return true; diff --git a/src/plugins/debugger/console/console.h b/src/plugins/debugger/console/console.h index 8ad12eac69d..10800e93ef6 100644 --- a/src/plugins/debugger/console/console.h +++ b/src/plugins/debugger/console/console.h @@ -61,7 +61,6 @@ public: QString displayName() const override { return tr("QML Debugger Console"); } int priorityInStatusBar() const override; void clearContents() override; - void visibilityChanged(bool visible) override; bool canFocus() const override; bool hasFocus() const override; void setFocus() override; diff --git a/src/plugins/debugger/peripheralregisterhandler.cpp b/src/plugins/debugger/peripheralregisterhandler.cpp index 2642f2dc9b2..0236697d7e0 100644 --- a/src/plugins/debugger/peripheralregisterhandler.cpp +++ b/src/plugins/debugger/peripheralregisterhandler.cpp @@ -568,13 +568,13 @@ static void handleField(QXmlStreamReader &in, PeripheralRegister ®) PeripheralRegisterField fld; while (in.readNextStartElement()) { const auto elementName = in.name(); - if (elementName == kName) { + if (elementName == QLatin1String(kName)) { fld.name = in.readElementText(); - } else if (elementName == kDescription) { + } else if (elementName == QLatin1String(kDescription)) { fld.description = in.readElementText(); - } else if (elementName == kAccess) { + } else if (elementName == QLatin1String(kAccess)) { fld.access = decodeAccess(in.readElementText()); - } else if (elementName == kBitRange) { + } else if (elementName == QLatin1String(kBitRange)) { const QString elementText = in.readElementText(); const int startBracket = elementText.indexOf('['); const int endBracket = elementText.indexOf(']'); @@ -589,9 +589,9 @@ static void handleField(QXmlStreamReader &in, PeripheralRegister ®) const int to = int(decodeNumeric(items.at(MaxBit))); fld.bitOffset = from; fld.bitWidth = to - from + 1; - } else if (elementName == kBitOffset) { + } else if (elementName == QLatin1String(kBitOffset)) { fld.bitOffset = int(decodeNumeric(in.readElementText())); - } else if (elementName == kBitWidth) { + } else if (elementName == QLatin1String(kBitWidth)) { fld.bitWidth = int(decodeNumeric(in.readElementText())); } else { in.skipCurrentElement(); @@ -611,24 +611,24 @@ static void handleRegister(QXmlStreamReader &in, PeripheralRegisterGroup &group) PeripheralRegister reg; while (in.readNextStartElement()) { const auto elementName = in.name(); - if (elementName == kName) { + if (elementName == QLatin1String(kName)) { reg.name = in.readElementText(); - } else if (elementName == kDisplayName) { + } else if (elementName == QLatin1String(kDisplayName)) { reg.displayName = in.readElementText(); - } else if (elementName == kDescription) { + } else if (elementName == QLatin1String(kDescription)) { reg.description = in.readElementText(); - } else if (elementName == kAddressOffset) { + } else if (elementName == QLatin1String(kAddressOffset)) { reg.addressOffset = decodeNumeric(in.readElementText()); - } else if (elementName == kSize) { + } else if (elementName == QLatin1String(kSize)) { reg.size = int(decodeNumeric(in.readElementText())); - } else if (elementName == kAccess) { + } else if (elementName == QLatin1String(kAccess)) { reg.access = decodeAccess(in.readElementText()); - } else if (elementName == kResetvalue) { + } else if (elementName == QLatin1String(kResetvalue)) { reg.resetValue = decodeNumeric(in.readElementText()); - } else if (elementName == kFields) { + } else if (elementName == QLatin1String(kFields)) { while (in.readNextStartElement()) { const auto elementName = in.name(); - if (elementName == kField) + if (elementName == QLatin1String(kField)) handleField(in, reg); else in.skipCurrentElement(); @@ -657,22 +657,22 @@ static void handleGroup(QXmlStreamReader &in, PeripheralRegisterGroups &groups) while (in.readNextStartElement()) { const auto elementName = in.name(); - if (elementName == kName) { + if (elementName == QLatin1String(kName)) { group.name = in.readElementText(); - } else if (elementName == kDescription) { + } else if (elementName == QLatin1String(kDescription)) { group.description = in.readElementText(); - } else if (elementName == kGroupName) { + } else if (elementName == QLatin1String(kGroupName)) { group.displayName = in.readElementText(); - } else if (elementName == kBaseAddress) { + } else if (elementName == QLatin1String(kBaseAddress)) { group.baseAddress = decodeNumeric(in.readElementText()); - } else if (elementName == kSize) { + } else if (elementName == QLatin1String(kSize)) { group.size = int(decodeNumeric(in.readElementText())); - } else if (elementName == kAccess) { + } else if (elementName == QLatin1String(kAccess)) { group.access = decodeAccess(in.readElementText()); - } else if (elementName == kRegisters) { + } else if (elementName == QLatin1String(kRegisters)) { while (in.readNextStartElement()) { const auto elementName = in.name(); - if (elementName == kRegister) + if (elementName == QLatin1String(kRegister)) handleRegister(in, group); else in.skipCurrentElement(); @@ -694,13 +694,13 @@ static PeripheralRegisterGroups availablePeripheralRegisterGroups(const FilePath PeripheralRegisterGroups groups; while (in.readNextStartElement()) { const auto elementName = in.name(); - if (elementName == kDevice) { + if (elementName == QLatin1String(kDevice)) { while (in.readNextStartElement()) { const auto elementName = in.name(); - if (elementName == kPeripherals) { + if (elementName == QLatin1String(kPeripherals)) { while (in.readNextStartElement()) { const auto elementName = in.name(); - if (elementName == kPeripheral) + if (elementName == QLatin1String(kPeripheral)) handleGroup(in, groups); else in.skipCurrentElement(); diff --git a/src/plugins/designer/codemodelhelpers.cpp b/src/plugins/designer/codemodelhelpers.cpp index 7beed0874ac..67adc0d5885 100644 --- a/src/plugins/designer/codemodelhelpers.cpp +++ b/src/plugins/designer/codemodelhelpers.cpp @@ -137,7 +137,9 @@ bool navigateToSlot(const QString &uiFileName, SearchFunction searchFunc(setupUiC); const SearchFunction::FunctionList funcs = searchFunc(generatedHeaderDoc); if (funcs.size() != 1) { - *errorMessage = QString::fromLatin1("Internal error: The function \"%1\" could not be found in %2").arg(setupUiC, generatedHeaderFile); + *errorMessage = QString::fromLatin1( + "Internal error: The function \"%1\" could not be found in %2") + .arg(QLatin1String(setupUiC), generatedHeaderFile); return false; } return true; diff --git a/src/plugins/diffeditor/diffeditor.cpp b/src/plugins/diffeditor/diffeditor.cpp index f303c22e708..533ad4d1279 100644 --- a/src/plugins/diffeditor/diffeditor.cpp +++ b/src/plugins/diffeditor/diffeditor.cpp @@ -56,6 +56,7 @@ #include #include #include +#include #include #include @@ -80,9 +81,13 @@ public: QSize sizeHint() const override; +signals: + void requestResize(); + protected: void setDisplaySettings(const DisplaySettings &ds) override; void setMarginSettings(const MarginSettings &ms) override; + void applyFontSettings() override; }; DescriptionEditorWidget::DescriptionEditorWidget(QWidget *parent) @@ -133,6 +138,12 @@ void DescriptionEditorWidget::setMarginSettings(const MarginSettings &ms) TextEditorWidget::setMarginSettings(MarginSettings()); } +void DescriptionEditorWidget::applyFontSettings() +{ + TextEditorWidget::applyFontSettings(); + emit requestResize(); +} + ///////////////////////////////// DiffEditor ////////////////////////////////// DiffEditor::DiffEditor() @@ -145,6 +156,18 @@ DiffEditor::DiffEditor() m_descriptionWidget = new DescriptionEditorWidget(splitter); m_descriptionWidget->setReadOnly(true); + connect(m_descriptionWidget, &DescriptionEditorWidget::requestResize, this, [splitter](){ + if (splitter->count() == 0) + return; + QList sizes = splitter->sizes(); + const int descHeight = splitter->widget(0)->fontMetrics().lineSpacing() * 8; + const int diff = descHeight - sizes[0]; + if (diff > 0) { + sizes[0] += diff; + sizes[1] -= diff; + splitter->setSizes(sizes); + } + }); splitter->addWidget(m_descriptionWidget); m_stackedWidget = new QStackedWidget(splitter); diff --git a/src/plugins/help/helpwidget.cpp b/src/plugins/help/helpwidget.cpp index 7d25d631a90..65c468ac386 100644 --- a/src/plugins/help/helpwidget.cpp +++ b/src/plugins/help/helpwidget.cpp @@ -1008,9 +1008,9 @@ void HelpWidget::print(HelpViewer *viewer) QPrintDialog dlg(m_printer, this); dlg.setWindowTitle(tr("Print Documentation")); if (!viewer->selectedText().isEmpty()) - dlg.addEnabledOption(QAbstractPrintDialog::PrintSelection); - dlg.addEnabledOption(QAbstractPrintDialog::PrintPageRange); - dlg.addEnabledOption(QAbstractPrintDialog::PrintCollateCopies); + dlg.setOption(QAbstractPrintDialog::PrintSelection, true); + dlg.setOption(QAbstractPrintDialog::PrintPageRange, true); + dlg.setOption(QAbstractPrintDialog::PrintCollateCopies, true); if (dlg.exec() == QDialog::Accepted) viewer->print(m_printer); diff --git a/src/plugins/help/xbelsupport.cpp b/src/plugins/help/xbelsupport.cpp index bf890c5e6db..f711fbde8fc 100644 --- a/src/plugins/help/xbelsupport.cpp +++ b/src/plugins/help/xbelsupport.cpp @@ -110,9 +110,8 @@ bool XbelReader::readFromFile(QIODevice *device) readNext(); if (isStartElement()) { - if (name() == "xbel" - && attributes().value("version") - == "1.0") { + if (name() == QLatin1String("xbel") + && attributes().value("version") == QLatin1String("1.0")) { readXBEL(); } else { raiseError(QCoreApplication::translate("Help::Internal::XbelReader", "The file is not an XBEL version 1.0 file.")); @@ -132,9 +131,9 @@ void XbelReader::readXBEL() break; if (isStartElement()) { - if (name() == "folder") + if (name() == QLatin1String("folder")) readFolder(nullptr); - else if (name() == "bookmark") + else if (name() == QLatin1String("bookmark")) readBookmark(nullptr); else readUnknownElement(); @@ -161,8 +160,7 @@ void XbelReader::readFolder(QStandardItem *item) folder->setIcon(folderIcon); folder->setData("Folder", Qt::UserRole + 10); - bool expanded = - (attributes().value("folded") != "no"); + const bool expanded = attributes().value("folded") != QLatin1String("no"); folder->setData(expanded, Qt::UserRole + 11); while (!atEnd()) { @@ -172,11 +170,11 @@ void XbelReader::readFolder(QStandardItem *item) break; if (isStartElement()) { - if (name() == "title") + if (name() == QLatin1String("title")) folder->setText(readElementText()); - else if (name() == "folder") + else if (name() == QLatin1String("folder")) readFolder(folder); - else if (name() == "bookmark") + else if (name() == QLatin1String("bookmark")) readBookmark(folder); else readUnknownElement(); @@ -199,7 +197,7 @@ void XbelReader::readBookmark(QStandardItem *item) break; if (isStartElement()) { - if (name() == "title") + if (name() == QLatin1String("title")) bookmark->setText(readElementText()); else readUnknownElement(); diff --git a/src/plugins/perfprofiler/perfconfigeventsmodel.cpp b/src/plugins/perfprofiler/perfconfigeventsmodel.cpp index 304adfa4a52..744885f3de8 100644 --- a/src/plugins/perfprofiler/perfconfigeventsmodel.cpp +++ b/src/plugins/perfprofiler/perfconfigeventsmodel.cpp @@ -355,7 +355,7 @@ PerfConfigEventsModel::EventDescription PerfConfigEventsModel::parseEvent( if (event.startsWith('r') && event.length() == 4) { bool ok = false; - const uint eventNumber = event.midRef(1).toUInt(&ok, 16); + const uint eventNumber = event.mid(1).toUInt(&ok, 16); if (ok) { description.eventType = EventTypeRaw; description.numericEvent = eventNumber; diff --git a/src/plugins/perfprofiler/perftimelinemodel.cpp b/src/plugins/perfprofiler/perftimelinemodel.cpp index 234338ffe38..44083eea18e 100644 --- a/src/plugins/perfprofiler/perftimelinemodel.cpp +++ b/src/plugins/perfprofiler/perftimelinemodel.cpp @@ -179,8 +179,8 @@ QVariantMap PerfTimelineModel::details(int index) const result.insert(tr("Name"), orUnknown(manager->string(tracePoint.name))); const QHash &extraData = m_extraData[index]; for (auto it = extraData.constBegin(), end = extraData.constEnd(); it != end; ++it) { - result.insertMulti(QString::fromUtf8(manager->string(it.key())), - prettyPrintTraceData(it.value())); + result.insert(QString::fromUtf8(manager->string(it.key())), + prettyPrintTraceData(it.value())); } } if (!m_resourceBlocks.isEmpty()) { diff --git a/src/plugins/perfprofiler/tests/perfresourcecounter_test.cpp b/src/plugins/perfprofiler/tests/perfresourcecounter_test.cpp index f48d6aec45c..fc44c0e60f5 100644 --- a/src/plugins/perfprofiler/tests/perfresourcecounter_test.cpp +++ b/src/plugins/perfprofiler/tests/perfresourcecounter_test.cpp @@ -112,19 +112,20 @@ void PerfResourceCounterTest::testMallocFree() void PerfResourceCounterTest::testRandomFill() { + auto rg = QRandomGenerator::global(); for (int i = 0; i < 100; ++i) { SizeCounter::Container container; SizeCounter counter(&container); for (int i = 0; i < 10000; ++i) { - const int amount = qrand(); + const int amount = rg->generate(); counter.request(amount, i); - counter.obtain(qrand()); + counter.obtain(rg->generate()); if (sum(container) != counter.currentTotal()) qDebug() << "ouch"; QCOMPARE(sum(container), counter.currentTotal()); } for (int i = 0; i < 10000; ++i) { - counter.release(qrand()); + counter.release(rg->generate()); QCOMPARE(sum(container), counter.currentTotal()); } @@ -138,9 +139,10 @@ void PerfResourceCounterTest::testUnitSized() NoPayloadCounter::Container container; NoPayloadCounter counter(&container); QList ids; + auto rg = QRandomGenerator::global(); for (int i = 0; i < 10000; ++i) { counter.request(1); - const int id = qrand(); + const int id = rg->generate(); counter.obtain(id); if (id != 0) // Otherwise it's the invalid ID and that means the allocation "failed". ids.append(id); @@ -158,11 +160,12 @@ void PerfResourceCounterTest::testRandomAlternate() { NoPayloadCounter::Container container; NoPayloadCounter counter(&container); + auto rg = QRandomGenerator::global(); for (int i = 0; i < 1000; ++i) { for (int i = 0; i < 100; ++i) { - counter.request(qrand()); - counter.obtain(qrand()); - counter.release(qrand()); + counter.request(rg->generate()); + counter.obtain(rg->generate()); + counter.release(rg->generate()); } QCOMPARE(sum(container), counter.currentTotal()); } diff --git a/src/plugins/projectexplorer/ProjectExplorer.json.in b/src/plugins/projectexplorer/ProjectExplorer.json.in index 9c1ee0eee44..8764d7d6eab 100644 --- a/src/plugins/projectexplorer/ProjectExplorer.json.in +++ b/src/plugins/projectexplorer/ProjectExplorer.json.in @@ -22,7 +22,7 @@ }, { \"Name\" : \"-ensure-kit-for-binary\", - \"Parameter\" : \"\", + \"Parameter\" : \"file path\", \"Description\" : \"Create kit with architecture matching a given application or library\" }, { diff --git a/src/plugins/projectexplorer/appoutputpane.cpp b/src/plugins/projectexplorer/appoutputpane.cpp index 63a9377df74..95f04e20c51 100644 --- a/src/plugins/projectexplorer/appoutputpane.cpp +++ b/src/plugins/projectexplorer/appoutputpane.cpp @@ -341,10 +341,6 @@ void AppOutputPane::clearContents() currentWindow->clear(); } -void AppOutputPane::visibilityChanged(bool /* b */) -{ -} - bool AppOutputPane::hasFocus() const { QWidget *widget = m_tabWidget->currentWidget(); diff --git a/src/plugins/projectexplorer/appoutputpane.h b/src/plugins/projectexplorer/appoutputpane.h index f682cfe2967..24728d5e716 100644 --- a/src/plugins/projectexplorer/appoutputpane.h +++ b/src/plugins/projectexplorer/appoutputpane.h @@ -70,7 +70,6 @@ public: QString displayName() const override; int priorityInStatusBar() const override; void clearContents() override; - void visibilityChanged(bool) override; bool canFocus() const override; bool hasFocus() const override; void setFocus() override; diff --git a/src/plugins/projectexplorer/compileoutputwindow.cpp b/src/plugins/projectexplorer/compileoutputwindow.cpp index 97ab9b69be1..9d8ad02a78a 100644 --- a/src/plugins/projectexplorer/compileoutputwindow.cpp +++ b/src/plugins/projectexplorer/compileoutputwindow.cpp @@ -215,9 +215,6 @@ void CompileOutputWindow::clearContents() m_taskPositions.clear(); } -void CompileOutputWindow::visibilityChanged(bool) -{ } - int CompileOutputWindow::priorityInStatusBar() const { return 50; diff --git a/src/plugins/projectexplorer/compileoutputwindow.h b/src/plugins/projectexplorer/compileoutputwindow.h index a146ea16cb7..babdfc17dfb 100644 --- a/src/plugins/projectexplorer/compileoutputwindow.h +++ b/src/plugins/projectexplorer/compileoutputwindow.h @@ -60,7 +60,6 @@ public: QString displayName() const override { return tr("Compile Output"); } int priorityInStatusBar() const override; void clearContents() override; - void visibilityChanged(bool visible) override; bool canFocus() const override; bool hasFocus() const override; void setFocus() override; diff --git a/src/plugins/projectexplorer/kitmanager.cpp b/src/plugins/projectexplorer/kitmanager.cpp index 70151b58002..bfbf58f57fb 100644 --- a/src/plugins/projectexplorer/kitmanager.cpp +++ b/src/plugins/projectexplorer/kitmanager.cpp @@ -44,12 +44,14 @@ #include #include +#include #include #include #include #include #include +#include #include #include @@ -729,6 +731,24 @@ Utils::Id KitAspectWidget::kitInformationId() const return m_kitInformation->id(); } +void KitAspectWidget::addToLayout(LayoutBuilder &builder) +{ + QTC_ASSERT(!m_label, delete m_label); + m_label = new QLabel(m_kitInformation->displayName() + ':'); + m_label->setToolTip(m_kitInformation->description()); + + builder.addRow({{m_label, 1, LayoutBuilder::AlignAsFormLabel}, mainWidget(), buttonWidget()}); +} + +void KitAspectWidget::setVisible(bool visible) +{ + mainWidget()->setVisible(visible); + if (buttonWidget()) + buttonWidget()->setVisible(visible); + QTC_ASSERT(m_label, return); + m_label->setVisible(visible); +} + QString KitAspectWidget::msgManage() { return tr("Manage..."); diff --git a/src/plugins/projectexplorer/kitmanager.h b/src/plugins/projectexplorer/kitmanager.h index ecf542e8518..99e9a40ac6a 100644 --- a/src/plugins/projectexplorer/kitmanager.h +++ b/src/plugins/projectexplorer/kitmanager.h @@ -37,9 +37,14 @@ #include +QT_BEGIN_NAMESPACE +class QLabel; +QT_END_NAMESPACE + namespace Utils { class Environment; class FilePath; +class LayoutBuilder; class MacroExpander; class OutputLineParser; } // namespace Utils @@ -136,19 +141,20 @@ public: virtual QWidget *mainWidget() const = 0; virtual QWidget *buttonWidget() const { return nullptr; } + void addToLayout(Utils::LayoutBuilder &builder); + void setVisible(bool visible); + bool isSticky() const { return m_isSticky; } static QString msgManage(); Kit *kit() const { return m_kit; } -signals: - void dirty(); - protected: Kit *m_kit; const KitAspect *m_kitInformation; bool m_isSticky; + QLabel *m_label = nullptr; }; class PROJECTEXPLORER_EXPORT KitManager : public QObject diff --git a/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp b/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp index caeed15cdf8..dc0797c29e7 100644 --- a/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp +++ b/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp @@ -46,16 +46,11 @@ #include #include #include -#include #include #include #include -#include -#include #include -#include #include -#include static const char WORKING_COPY_KIT_ID[] = "modified kit"; @@ -71,14 +66,12 @@ KitManagerConfigWidget::KitManagerConfigWidget(Kit *k) : m_kit(k), m_modifiedKit(std::make_unique(Utils::Id(WORKING_COPY_KIT_ID))) { - static auto alignment - = static_cast(style()->styleHint(QStyle::SH_FormLayoutLabelAlignment)); - setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); LayoutBuilder builder(this, LayoutBuilder::GridLayout); - QLabel *label = createLabel(tr("Name:"), tr("Kit name and icon.")); - builder.addRow({{label, 1, alignment}, m_nameEdit, m_iconButton}); + QLabel *label = new QLabel(tr("Name:")); + label->setToolTip(tr("Kit name and icon.")); + builder.addRow({{label, 1, LayoutBuilder::AlignAsFormLabel}, m_nameEdit, m_iconButton}); QString toolTip = tr("

The name of the kit suitable for generating " @@ -90,8 +83,9 @@ KitManagerConfigWidget::KitManagerConfigWidget(Kit *k) : Q_ASSERT(fileSystemFriendlyNameRegexp.isValid()); m_fileSystemFriendlyNameLineEdit->setValidator(new QRegularExpressionValidator(fileSystemFriendlyNameRegexp, m_fileSystemFriendlyNameLineEdit)); - label = createLabel(tr("File system name:"), toolTip); - builder.addRow({{label, 1, alignment}, m_fileSystemFriendlyNameLineEdit}); + label = new QLabel(tr("File system name:")); + label->setToolTip(toolTip); + builder.addRow({{label, 1, LayoutBuilder::AlignAsFormLabel}, m_fileSystemFriendlyNameLineEdit}); connect(m_fileSystemFriendlyNameLineEdit, &QLineEdit::textChanged, this, &KitManagerConfigWidget::setFileSystemFriendlyName); @@ -222,9 +216,6 @@ void KitManagerConfigWidget::addAspectToWorkingCopy(KitAspect *aspect) QTC_ASSERT(widget, return); QTC_ASSERT(!m_widgets.contains(widget), return); - const QString name = aspect->displayName() + ':'; - QString toolTip = aspect->description(); - auto action = new QAction(tr("Mark as Mutable"), nullptr); action->setCheckable(true); action->setChecked(workingCopy()->isMutable(aspect->id())); @@ -239,14 +230,9 @@ void KitManagerConfigWidget::addAspectToWorkingCopy(KitAspect *aspect) m_actions << action; - static auto alignment - = static_cast(style()->styleHint(QStyle::SH_FormLayoutLabelAlignment)); - - QLabel *label = createLabel(name, toolTip); LayoutBuilder builder(layout()); - builder.addRow({{label, 1, alignment}, widget->mainWidget(), widget->buttonWidget()}); + widget->addToLayout(builder); m_widgets.append(widget); - m_labels.append(label); } void KitManagerConfigWidget::updateVisibility() @@ -256,10 +242,7 @@ void KitManagerConfigWidget::updateVisibility() KitAspectWidget *widget = m_widgets.at(i); const bool visible = widget->visibleInKit() && !m_modifiedKit->irrelevantAspects().contains(widget->kitInformationId()); - widget->mainWidget()->setVisible(visible); - if (widget->buttonWidget()) - widget->buttonWidget()->setVisible(visible); - m_labels.at(i)->setVisible(visible); + widget->setVisible(visible); } } @@ -410,12 +393,5 @@ void KitManagerConfigWidget::showEvent(QShowEvent *event) widget->refresh(); } -QLabel *KitManagerConfigWidget::createLabel(const QString &name, const QString &toolTip) -{ - auto label = new QLabel(name); - label->setToolTip(toolTip); - return label; -} - } // namespace Internal } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/kitmanagerconfigwidget.h b/src/plugins/projectexplorer/kitmanagerconfigwidget.h index b6e775579ea..89b74d7ee7c 100644 --- a/src/plugins/projectexplorer/kitmanagerconfigwidget.h +++ b/src/plugins/projectexplorer/kitmanagerconfigwidget.h @@ -89,13 +89,11 @@ private: }; void showEvent(QShowEvent *event) override; - QLabel *createLabel(const QString &name, const QString &toolTip); QToolButton *m_iconButton; QLineEdit *m_nameEdit; QLineEdit *m_fileSystemFriendlyNameLineEdit; QList m_widgets; - QList m_labels; Kit *m_kit; std::unique_ptr m_modifiedKit; bool m_isDefaultKit = false; diff --git a/src/plugins/projectexplorer/processstep.cpp b/src/plugins/projectexplorer/processstep.cpp index 0ffde35238f..cdc5d3a4c70 100644 --- a/src/plugins/projectexplorer/processstep.cpp +++ b/src/plugins/projectexplorer/processstep.cpp @@ -51,37 +51,43 @@ class ProcessStep final : public AbstractProcessStep Q_DECLARE_TR_FUNCTIONS(ProjectExplorer::ProcessStep) public: - ProcessStep(BuildStepList *bsl, Utils::Id id); + ProcessStep(BuildStepList *bsl, Id id); - void setupOutputFormatter(Utils::OutputFormatter *formatter); - void setupProcessParameters(ProcessParameters *pp); - - StringAspect *m_command; - StringAspect *m_arguments; - StringAspect *m_workingDirectory; + void setupOutputFormatter(OutputFormatter *formatter); }; -ProcessStep::ProcessStep(BuildStepList *bsl, Utils::Id id) +ProcessStep::ProcessStep(BuildStepList *bsl, Id id) : AbstractProcessStep(bsl, id) { - m_command = addAspect(); - m_command->setSettingsKey(PROCESS_COMMAND_KEY); - m_command->setDisplayStyle(StringAspect::PathChooserDisplay); - m_command->setLabelText(tr("Command:")); - m_command->setExpectedKind(Utils::PathChooser::Command); - m_command->setHistoryCompleter("PE.ProcessStepCommand.History"); + auto command = addAspect(); + command->setSettingsKey(PROCESS_COMMAND_KEY); + command->setDisplayStyle(StringAspect::PathChooserDisplay); + command->setLabelText(tr("Command:")); + command->setExpectedKind(PathChooser::Command); + command->setHistoryCompleter("PE.ProcessStepCommand.History"); - m_arguments = addAspect(); - m_arguments->setSettingsKey(PROCESS_ARGUMENTS_KEY); - m_arguments->setDisplayStyle(StringAspect::LineEditDisplay); - m_arguments->setLabelText(tr("Arguments:")); + auto arguments = addAspect(); + arguments->setSettingsKey(PROCESS_ARGUMENTS_KEY); + arguments->setDisplayStyle(StringAspect::LineEditDisplay); + arguments->setLabelText(tr("Arguments:")); - m_workingDirectory = addAspect(); - m_workingDirectory->setSettingsKey(PROCESS_WORKINGDIRECTORY_KEY); - m_workingDirectory->setValue(Constants::DEFAULT_WORKING_DIR); - m_workingDirectory->setDisplayStyle(StringAspect::PathChooserDisplay); - m_workingDirectory->setLabelText(tr("Working directory:")); - m_workingDirectory->setExpectedKind(Utils::PathChooser::Directory); + auto workingDirectory = addAspect(); + workingDirectory->setSettingsKey(PROCESS_WORKINGDIRECTORY_KEY); + workingDirectory->setValue(Constants::DEFAULT_WORKING_DIR); + workingDirectory->setDisplayStyle(StringAspect::PathChooserDisplay); + workingDirectory->setLabelText(tr("Working directory:")); + workingDirectory->setExpectedKind(PathChooser::Directory); + + setWorkingDirectoryProvider([this, workingDirectory] { + const FilePath workingDir = workingDirectory->filePath(); + if (workingDir.isEmpty()) + return FilePath::fromString(fallbackWorkingDirectory()); + return workingDir; + }); + + setCommandLineProvider([command, arguments] { + return CommandLine{command->filePath(), arguments->value(), CommandLine::Raw}; + }); setSummaryUpdater([this] { QString display = displayName(); @@ -101,18 +107,6 @@ void ProcessStep::setupOutputFormatter(OutputFormatter *formatter) AbstractProcessStep::setupOutputFormatter(formatter); } -void ProcessStep::setupProcessParameters(ProcessParameters *pp) -{ - QString workingDirectory = m_workingDirectory->value(); - if (workingDirectory.isEmpty()) - workingDirectory = fallbackWorkingDirectory(); - - pp->setMacroExpander(macroExpander()); - pp->setEnvironment(buildEnvironment()); - pp->setWorkingDirectory(FilePath::fromString(workingDirectory)); - pp->setCommandLine({m_command->filePath(), m_arguments->value(), CommandLine::Raw}); -} - // ProcessStepFactory ProcessStepFactory::ProcessStepFactory() diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/selectionmodel.h b/src/plugins/qmldesigner/components/curveeditor/detail/selectionmodel.h index 5a9a52ba072..ff4a0bbf2fa 100644 --- a/src/plugins/qmldesigner/components/curveeditor/detail/selectionmodel.h +++ b/src/plugins/qmldesigner/components/curveeditor/detail/selectionmodel.h @@ -25,13 +25,13 @@ #pragma once +#include "curveitem.h" #include "treeitem.h" #include namespace DesignTools { -class CurveItem; class TreeItem; class NodeTreeItem; class PropertyTreeItem; diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/treeview.h b/src/plugins/qmldesigner/components/curveeditor/detail/treeview.h index 9fa2de14ad6..338ab6f052b 100644 --- a/src/plugins/qmldesigner/components/curveeditor/detail/treeview.h +++ b/src/plugins/qmldesigner/components/curveeditor/detail/treeview.h @@ -25,6 +25,7 @@ #pragma once +#include "curveitem.h" #include "selectionmodel.h" #include @@ -33,7 +34,6 @@ namespace DesignTools { class AnimationCurve; class CurveEditorModel; -class CurveItem; struct CurveEditorStyle; diff --git a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp index 5b8735bdbb1..e59731ffb34 100644 --- a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp +++ b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp @@ -395,7 +395,7 @@ QmlProfilerModelManager::rangeFilter(qint64 rangeStart, qint64 rangeEnd) const if (type.rangeType() != MaximumRangeType) { if (event.rangeStage() == RangeStart) stack.push(event); - else if (event.rangeStage() == RangeEnd) + else if (event.rangeStage() == RangeEnd && !stack.isEmpty()) stack.pop(); return true; } else if (isStateful(type)) { diff --git a/src/plugins/scxmleditor/plugin_interface/scxmldocument.cpp b/src/plugins/scxmleditor/plugin_interface/scxmldocument.cpp index 74f288e8990..a0c677ba464 100644 --- a/src/plugins/scxmleditor/plugin_interface/scxmldocument.cpp +++ b/src/plugins/scxmleditor/plugin_interface/scxmldocument.cpp @@ -214,7 +214,7 @@ bool ScxmlDocument::load(QIODevice *io) continue; if (token == QXmlStreamReader::StartElement) { - if (xml.name() == "scxml") { + if (xml.name() == QLatin1String("scxml")) { // Get and add namespaces QXmlStreamNamespaceDeclarations ns = xml.namespaceDeclarations(); for (int i = 0; i < ns.count(); ++i) diff --git a/src/plugins/scxmleditor/plugin_interface/scxmltag.cpp b/src/plugins/scxmleditor/plugin_interface/scxmltag.cpp index 248eeff99a4..924f5127293 100644 --- a/src/plugins/scxmleditor/plugin_interface/scxmltag.cpp +++ b/src/plugins/scxmleditor/plugin_interface/scxmltag.cpp @@ -579,7 +579,7 @@ void ScxmlTag::readXml(QXmlStreamReader &xml, bool checkCopyId) // Read and set attributes QXmlStreamAttributes attributes = xml.attributes(); for (int i = 0; i < attributes.count(); ++i) { - if (m_tagType == Scxml && attributes[i].qualifiedName() == "initial") + if (m_tagType == Scxml && attributes[i].qualifiedName() == QLatin1String("initial")) scxmlInitial = attributes[i].value().toString(); else { QString key = attributes[i].qualifiedName().toString(); diff --git a/src/plugins/serialterminal/serialoutputpane.cpp b/src/plugins/serialterminal/serialoutputpane.cpp index 0ef4a3544ab..3d23606fa4c 100644 --- a/src/plugins/serialterminal/serialoutputpane.cpp +++ b/src/plugins/serialterminal/serialoutputpane.cpp @@ -210,11 +210,6 @@ void SerialOutputPane::clearContents() currentWindow->clear(); } -void SerialOutputPane::visibilityChanged(bool) -{ - // Unused but pure virtual -} - bool SerialOutputPane::canFocus() const { return m_tabWidget->currentWidget(); diff --git a/src/plugins/serialterminal/serialoutputpane.h b/src/plugins/serialterminal/serialoutputpane.h index 944b008ab17..24249fd8412 100644 --- a/src/plugins/serialterminal/serialoutputpane.h +++ b/src/plugins/serialterminal/serialoutputpane.h @@ -76,7 +76,6 @@ public: int priorityInStatusBar() const final; void clearContents() final; - void visibilityChanged(bool) final; bool canFocus() const final; bool hasFocus() const final; void setFocus() final; diff --git a/src/plugins/todo/todooutputpane.cpp b/src/plugins/todo/todooutputpane.cpp index a4a3fa1cce4..30be160d56f 100644 --- a/src/plugins/todo/todooutputpane.cpp +++ b/src/plugins/todo/todooutputpane.cpp @@ -94,11 +94,6 @@ void TodoOutputPane::clearContents() clearKeywordFilter(); } -void TodoOutputPane::visibilityChanged(bool visible) -{ - Q_UNUSED(visible) -} - void TodoOutputPane::setFocus() { m_todoTreeView->setFocus(); diff --git a/src/plugins/todo/todooutputpane.h b/src/plugins/todo/todooutputpane.h index 78b0aff45d4..11f259cfaf1 100644 --- a/src/plugins/todo/todooutputpane.h +++ b/src/plugins/todo/todooutputpane.h @@ -60,7 +60,6 @@ public: QString displayName() const override; int priorityInStatusBar() const override; void clearContents() override; - void visibilityChanged(bool visible) override; void setFocus() override; bool hasFocus() const override; bool canFocus() const override; diff --git a/src/plugins/valgrind/xmlprotocol/parser.cpp b/src/plugins/valgrind/xmlprotocol/parser.cpp index e4059112470..df2fe3cd1af 100644 --- a/src/plugins/valgrind/xmlprotocol/parser.cpp +++ b/src/plugins/valgrind/xmlprotocol/parser.cpp @@ -304,13 +304,13 @@ XWhat Parser::Private::parseXWhat() if (reader.isEndElement()) break; const auto name = reader.name(); - if (name == "text") + if (name == QLatin1String("text")) what.text = blockingReadElementText(); - else if (name == "leakedbytes") + else if (name == QLatin1String("leakedbytes")) what.leakedbytes = parseInt64(blockingReadElementText(), "error/xwhat[memcheck]/leakedbytes"); - else if (name == "leakedblocks") + else if (name == QLatin1String("leakedblocks")) what.leakedblocks = parseInt64(blockingReadElementText(), "error/xwhat[memcheck]/leakedblocks"); - else if (name == "hthreadid") + else if (name == QLatin1String("hthreadid")) what.hthreadid = parseInt64(blockingReadElementText(), "error/xwhat[memcheck]/hthreadid"); else if (reader.isStartElement()) reader.skipCurrentElement(); @@ -326,15 +326,15 @@ XauxWhat Parser::Private::parseXauxWhat() if (reader.isEndElement()) break; const auto name = reader.name(); - if (name == "text") + if (name == QLatin1String("text")) what.text = blockingReadElementText(); - else if (name == "file") + else if (name == QLatin1String("file")) what.file = blockingReadElementText(); - else if (name == "dir") + else if (name == QLatin1String("dir")) what.dir = blockingReadElementText(); - else if (name == "line") + else if (name == QLatin1String("line")) what.line = parseInt64(blockingReadElementText(), "error/xauxwhat/line"); - else if (name == "hthreadid") + else if (name == QLatin1String("hthreadid")) what.hthreadid = parseInt64(blockingReadElementText(), "error/xauxwhat/hthreadid"); else if (reader.isStartElement()) reader.skipCurrentElement(); @@ -434,27 +434,27 @@ void Parser::Private::parseError() if (reader.isStartElement()) lastAuxWhat++; const auto name = reader.name(); - if (name == "unique") { + if (name == QLatin1String("unique")) { e.setUnique(parseHex(blockingReadElementText(), "unique")); - } else if (name == "tid") { + } else if (name == QLatin1String("tid")) { e.setTid(parseInt64(blockingReadElementText(), "error/tid")); - } else if (name == "kind") { //TODO this is memcheck-specific: + } else if (name == QLatin1String("kind")) { //TODO this is memcheck-specific: e.setKind(parseErrorKind(blockingReadElementText())); - } else if (name == "suppression") { + } else if (name == QLatin1String("suppression")) { e.setSuppression(parseSuppression()); - } else if (name == "xwhat") { + } else if (name == QLatin1String("xwhat")) { const XWhat xw = parseXWhat(); e.setWhat(xw.text); e.setLeakedBlocks(xw.leakedblocks); e.setLeakedBytes(xw.leakedbytes); e.setHelgrindThreadId(xw.hthreadid); - } else if (name == "what") { + } else if (name == QLatin1String("what")) { e.setWhat(blockingReadElementText()); - } else if (name == "xauxwhat") { + } else if (name == QLatin1String("xauxwhat")) { if (!currentAux.text.isEmpty()) auxs.push_back(currentAux); currentAux = parseXauxWhat(); - } else if (name == "auxwhat") { + } else if (name == QLatin1String("auxwhat")) { const QString aux = blockingReadElementText(); //concatenate multiple consecutive tags if (lastAuxWhat > 1) { @@ -468,7 +468,7 @@ void Parser::Private::parseError() currentAux.text.append(aux); } lastAuxWhat = 0; - } else if (name == "stack") { + } else if (name == QLatin1String("stack")) { frames.push_back(parseStack()); } else if (reader.isStartElement()) { reader.skipCurrentElement(); @@ -505,17 +505,17 @@ Frame Parser::Private::parseFrame() break; if (reader.isStartElement()) { const auto name = reader.name(); - if (name == "ip") + if (name == QLatin1String("ip")) frame.setInstructionPointer(parseHex(blockingReadElementText(), "error/frame/ip")); - else if (name == "obj") + else if (name == QLatin1String("obj")) frame.setObject(blockingReadElementText()); - else if (name == "fn") + else if (name == QLatin1String("fn")) frame.setFunctionName( blockingReadElementText()); - else if (name == "dir") + else if (name == QLatin1String("dir")) frame.setDirectory(blockingReadElementText()); - else if (name == "file") + else if (name == QLatin1String("file")) frame.setFileName(blockingReadElementText()); - else if (name == "line") + else if (name == QLatin1String("line")) frame.setLine(parseInt64(blockingReadElementText(), "error/frame/line")); else if (reader.isStartElement()) reader.skipCurrentElement(); @@ -535,9 +535,9 @@ void Parser::Private::parseAnnounceThread() break; if (reader.isStartElement()) { const auto name = reader.name(); - if (name == "hthreadid") + if (name == QLatin1String("hthreadid")) at.setHelgrindThreadId(parseInt64(blockingReadElementText(), "announcethread/hthreadid")); - else if (name == "stack") + else if (name == QLatin1String("stack")) at.setStack(parseStack()); else if (reader.isStartElement()) reader.skipCurrentElement(); @@ -554,7 +554,7 @@ void Parser::Private::parseErrorCounts() if (reader.isEndElement()) break; if (reader.isStartElement()) { - if (reader.name() == "pair") { + if (reader.name() == QLatin1String("pair")) { qint64 unique = 0; qint64 count = 0; while (notAtEnd()) { @@ -563,17 +563,16 @@ void Parser::Private::parseErrorCounts() break; if (reader.isStartElement()) { const auto name = reader.name(); - if (name == "unique") + if (name == QLatin1String("unique")) unique = parseHex(blockingReadElementText(), "errorcounts/pair/unique"); - else if (name == "count") + else if (name == QLatin1String("count")) count = parseInt64(blockingReadElementText(), "errorcounts/pair/count"); else if (reader.isStartElement()) reader.skipCurrentElement(); } } emit q->errorCount(unique, count); - } - else if (reader.isStartElement()) + } else if (reader.isStartElement()) reader.skipCurrentElement(); } } @@ -587,7 +586,7 @@ void Parser::Private::parseSuppressionCounts() if (reader.isEndElement()) break; if (reader.isStartElement()) { - if (reader.name() == "pair") { + if (reader.name() == QLatin1String("pair")) { QString pairName; qint64 count = 0; while (notAtEnd()) { @@ -596,17 +595,16 @@ void Parser::Private::parseSuppressionCounts() break; if (reader.isStartElement()) { const auto name = reader.name(); - if (name == "name") + if (name == QLatin1String("name")) pairName = blockingReadElementText(); - else if (name == "count") + else if (name == QLatin1String("count")) count = parseInt64(blockingReadElementText(), "suppcounts/pair/count"); else if (reader.isStartElement()) reader.skipCurrentElement(); } } emit q->suppressionCount(pairName, count); - } - else if (reader.isStartElement()) + } else if (reader.isStartElement()) reader.skipCurrentElement(); } } @@ -622,9 +620,9 @@ void Parser::Private::parseStatus() break; if (reader.isStartElement()) { const auto name = reader.name(); - if (name == "state") + if (name == QLatin1String("state")) s.setState(parseState(blockingReadElementText())); - else if (name == "time") + else if (name == QLatin1String("time")) s.setTime(blockingReadElementText()); else if (reader.isStartElement()) reader.skipCurrentElement(); @@ -642,7 +640,7 @@ QVector Parser::Private::parseStack() if (reader.isEndElement()) break; if (reader.isStartElement()) { - if (reader.name() == "frame") + if (reader.name() == QLatin1String("frame")) frames.append(parseFrame()); } } @@ -660,9 +658,9 @@ SuppressionFrame Parser::Private::parseSuppressionFrame() break; if (reader.isStartElement()) { const auto name = reader.name(); - if (name == "obj") + if (name == QLatin1String("obj")) frame.setObject(blockingReadElementText()); - else if (name == "fun") + else if (name == QLatin1String("fun")) frame.setFunction( blockingReadElementText()); else if (reader.isStartElement()) reader.skipCurrentElement(); @@ -682,15 +680,15 @@ Suppression Parser::Private::parseSuppression() break; if (reader.isStartElement()) { const auto name = reader.name(); - if (name == "sname") + if (name == QLatin1String("sname")) supp.setName(blockingReadElementText()); - else if (name == "skind") + else if (name == QLatin1String("skind")) supp.setKind(blockingReadElementText()); - else if (name == "skaux") + else if (name == QLatin1String("skaux")) supp.setAuxKind(blockingReadElementText()); - else if (name == "rawtext") + else if (name == QLatin1String("rawtext")) supp.setRawText(blockingReadElementText()); - else if (name == "sframe") + else if (name == QLatin1String("sframe")) frames.push_back(parseSuppressionFrame()); } } @@ -708,19 +706,19 @@ void Parser::Private::parse(QIODevice *device) while (notAtEnd()) { blockingReadNext(); const auto name = reader.name(); - if (name == "error") + if (name == QLatin1String("error")) parseError(); - else if (name == "announcethread") + else if (name == QLatin1String("announcethread")) parseAnnounceThread(); - else if (name == "status") + else if (name == QLatin1String("status")) parseStatus(); - else if (name == "errorcounts") + else if (name == QLatin1String("errorcounts")) parseErrorCounts(); - else if (name == "suppcounts") + else if (name == QLatin1String("suppcounts")) parseSuppressionCounts(); - else if (name == "protocolversion") + else if (name == QLatin1String("protocolversion")) checkProtocolVersion(blockingReadElementText()); - else if (name == "protocoltool") + else if (name == QLatin1String("protocoltool")) checkTool(blockingReadElementText()); } } catch (const ParserException &e) { diff --git a/src/plugins/vcsbase/vcsoutputwindow.cpp b/src/plugins/vcsbase/vcsoutputwindow.cpp index 39b8d51d57b..ab9617ebb71 100644 --- a/src/plugins/vcsbase/vcsoutputwindow.cpp +++ b/src/plugins/vcsbase/vcsoutputwindow.cpp @@ -363,12 +363,6 @@ void VcsOutputWindow::clearContents() d->widget.clear(); } -void VcsOutputWindow::visibilityChanged(bool visible) -{ - if (visible) - d->widget.setFocus(); -} - void VcsOutputWindow::setFocus() { d->widget.setFocus(); diff --git a/src/plugins/vcsbase/vcsoutputwindow.h b/src/plugins/vcsbase/vcsoutputwindow.h index 749e824c388..21bd81be974 100644 --- a/src/plugins/vcsbase/vcsoutputwindow.h +++ b/src/plugins/vcsbase/vcsoutputwindow.h @@ -46,7 +46,6 @@ public: int priorityInStatusBar() const override; void clearContents() override; - void visibilityChanged(bool visible) override; void setFocus() override; bool hasFocus() const override; diff --git a/src/shared/CMakeLists.txt b/src/shared/CMakeLists.txt index eeaad66af22..4d702e889d1 100644 --- a/src/shared/CMakeLists.txt +++ b/src/shared/CMakeLists.txt @@ -4,3 +4,37 @@ add_subdirectory(qtsingleapplication) add_subdirectory(qtlockedfile) add_subdirectory(help) add_subdirectory(registryaccess) + +if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/qbs/CMakeLists.txt) + set(BUILD_QBS_DEFAULT YES) +else() + set(BUILD_QBS_DEFAULT FALSE) +endif() + +option(BUILD_QBS "Build Qbs together with Qt Creator" ${BUILD_QBS_DEFAULT}) + +if (BUILD_QBS) + find_package(Qt5 COMPONENTS Script QUIET) + if (TARGET Qt5::Script) + set(ENABLE_BUILD_QBS YES) + endif() +else() + set(ENABLE_BUILD_QBS NO) +endif() + +add_feature_info("Build Qbs" ENABLE_BUILD_QBS "with CONDITION TARGET Qt5::Script") +if (ENABLE_BUILD_QBS) + file(RELATIVE_PATH _REL_PATH_TO_QTC "${CMAKE_BINARY_DIR}" "${PROJECT_BINARY_DIR}") + set(QBS_OUTPUT_PREFIX "${_REL_PATH_TO_QTC}/" CACHE STRING "" FORCE) + set(QBS_APP_INSTALL_DIR "${IDE_BIN_PATH}" CACHE STRING "" FORCE) + set(QBS_LIB_INSTALL_DIR "${IDE_LIBRARY_PATH}" CACHE STRING "" FORCE) + set(QBS_DLL_INSTALL_DIR "${IDE_BIN_PATH}" CACHE STRING "" FORCE) + set(QBS_LIBEXEC_INSTALL_DIR "${IDE_LIBEXEC_PATH}" CACHE STRING "" FORCE) + set(QBS_PLUGINS_INSTALL_BASE "${IDE_PLUGIN_PATH}" CACHE STRING "" FORCE) + set(QBS_RESOURCES_INSTALL_BASE "${IDE_DATA_PATH}/qbs" CACHE STRING "" FORCE) + set(QBS_HEADERS_INSTALL_DIR "${IDE_DATA_PATH}/qbs/include/qbs" CACHE STRING "" FORCE) + + set(INSTALL_PUBLIC_HEADERS OFF) + set(WITH_TESTS OFF) + add_subdirectory(qbs) +endif() diff --git a/src/shared/qbs b/src/shared/qbs index 1f2900f4181..0d5fdcee74b 160000 --- a/src/shared/qbs +++ b/src/shared/qbs @@ -1 +1 @@ -Subproject commit 1f2900f4181d44b53f2a36ee637b8570f611515f +Subproject commit 0d5fdcee74b76175e0b03269b12d9bd4b6eee9c4 diff --git a/src/tools/clangbackend/source/fulltokeninfo.cpp b/src/tools/clangbackend/source/fulltokeninfo.cpp index fd59d25766b..58b8398c972 100644 --- a/src/tools/clangbackend/source/fulltokeninfo.cpp +++ b/src/tools/clangbackend/source/fulltokeninfo.cpp @@ -106,13 +106,16 @@ static Utf8String getPropertyType(const SourceLocation &location, uint propertyP uint offset; clang_getFileLocation(location.cx(), &cxFile, nullptr, nullptr, &offset); const char *const contents = clang_getFileContents(location.tu(), cxFile, nullptr); - const char *const lineContents = &contents[offset - propertyPosition]; - - const char *typeStart = std::strstr(lineContents, "Q_PROPERTY") + 10; + const int keywordOffset = QByteArray::fromRawData(contents, propertyPosition) + .lastIndexOf("Q_PROPERTY"); + if (keywordOffset == -1) + return {}; + const char * const keywordStart = contents + keywordOffset; + const char *typeStart = keywordStart + 10; typeStart += std::strspn(typeStart, "( \t\n\r"); - if (typeStart - lineContents >= propertyPosition) + if (typeStart - keywordStart >= propertyPosition) return Utf8String(); - auto typeEnd = std::find_if(std::reverse_iterator(lineContents + propertyPosition), + auto typeEnd = std::find_if(std::reverse_iterator(keywordStart + propertyPosition), std::reverse_iterator(typeStart), Utils::unequalTo(' ')); diff --git a/src/tools/qml2puppet/CMakeLists.txt b/src/tools/qml2puppet/CMakeLists.txt index 7d1d32c19b9..3d2e53a48c3 100644 --- a/src/tools/qml2puppet/CMakeLists.txt +++ b/src/tools/qml2puppet/CMakeLists.txt @@ -8,7 +8,7 @@ endif() add_qtc_library(qml2puppet_static STATIC DEPENDS - Qt5::CorePrivate Qt5::Gui + Qt5::CorePrivate Qt5::Widgets PUBLIC_INCLUDES "${SRCDIR}/interfaces" SOURCES_PREFIX "${SRCDIR}/interfaces" SOURCES diff --git a/src/tools/qtcreatorcrashhandler/backtracecollector.cpp b/src/tools/qtcreatorcrashhandler/backtracecollector.cpp index b3bc1939f7f..3f77d4ac98e 100644 --- a/src/tools/qtcreatorcrashhandler/backtracecollector.cpp +++ b/src/tools/qtcreatorcrashhandler/backtracecollector.cpp @@ -63,7 +63,7 @@ BacktraceCollector::~BacktraceCollector() delete d; } -void BacktraceCollector::run(Q_PID pid) +void BacktraceCollector::run(qint64 pid) { d->debugger.start(QLatin1String("gdb"), QStringList({ "--nw", // Do not use a window interface. diff --git a/src/tools/qtcreatorcrashhandler/backtracecollector.h b/src/tools/qtcreatorcrashhandler/backtracecollector.h index 50d0bee0560..6750f7105af 100644 --- a/src/tools/qtcreatorcrashhandler/backtracecollector.h +++ b/src/tools/qtcreatorcrashhandler/backtracecollector.h @@ -36,7 +36,7 @@ public: explicit BacktraceCollector(QObject *parent = 0); ~BacktraceCollector(); - void run(Q_PID pid); + void run(qint64 pid); bool isRunning() const; void kill(); diff --git a/src/tools/qtcreatorcrashhandler/main.cpp b/src/tools/qtcreatorcrashhandler/main.cpp index 700e796ab3c..ca5c9250ab2 100644 --- a/src/tools/qtcreatorcrashhandler/main.cpp +++ b/src/tools/qtcreatorcrashhandler/main.cpp @@ -46,7 +46,7 @@ static void printErrorAndExit() exit(EXIT_FAILURE); } -static bool hasProcessOriginFromQtCreatorBuildDir(Q_PID pid) +static bool hasProcessOriginFromQtCreatorBuildDir(qint64 pid) { const QString executable = QFile::symLinkTarget(QString::fromLatin1("/proc/%1/exe") .arg(QString::number(pid))); @@ -73,7 +73,7 @@ int main(int argc, char *argv[]) if (positionalArguments.size() != 2) printErrorAndExit(); - Q_PID parentPid = getppid(); + qint64 parentPid = getppid(); if (!hasProcessOriginFromQtCreatorBuildDir(parentPid)) printErrorAndExit(); diff --git a/tests/auto/debugger/tst_dumpers.cpp b/tests/auto/debugger/tst_dumpers.cpp index 1ca3131caf4..d1a70c2ba23 100644 --- a/tests/auto/debugger/tst_dumpers.cpp +++ b/tests/auto/debugger/tst_dumpers.cpp @@ -511,6 +511,20 @@ struct Watcher : DumperOptions {} }; +enum AdditionalCriteria +{ + NeedsInferiorCall = 0x1, +}; + +static bool matchesAdditionalCriteria(int criteria) +{ +#ifdef Q_OS_UNIX + return true; +#else + return !(criteria & NeedsInferiorCall); +#endif +} + struct Check { Check() {} @@ -533,7 +547,8 @@ struct Check && gccVersionForCheck.covers(context.gccVersion) && clangVersionForCheck.covers(context.clangVersion) && msvcVersionForCheck.covers(context.msvcVersion) - && qtVersionForCheck.covers(context.qtVersion); + && qtVersionForCheck.covers(context.qtVersion) + && matchesAdditionalCriteria(additionalCriteria); } const Check &operator%(Optional) const @@ -595,6 +610,12 @@ struct Check return *this; } + const Check &operator%(AdditionalCriteria criteria) const + { + additionalCriteria = criteria; + return *this; + } + QString iname; Name expectedName; Value expectedValue; @@ -607,6 +628,7 @@ struct Check mutable VersionBase msvcVersionForCheck; mutable QtVersion qtVersionForCheck; mutable BoostVersion boostVersionForCheck; + mutable int additionalCriteria = 0; mutable bool optionallyPresent = false; }; @@ -2212,29 +2234,29 @@ void tst_Dumpers::dumper_data() + Check("d0", "(invalid)", "@QDate") + Check("d1", "Tue Jan 1 1980", "@QDate") - + Check("d1.(ISO)", "\"1980-01-01\"", "@QString") % Optional() - + Check("d1.toString", "\"Tue Jan 1 1980\"", "@QString") % Optional() - + CheckType("d1.(Locale)", "@QString") % Optional() - + CheckType("d1.(SystemLocale)", "@QString") % Optional() + + Check("d1.(ISO)", "\"1980-01-01\"", "@QString") % NeedsInferiorCall + + Check("d1.toString", "\"Tue Jan 1 1980\"", "@QString") % NeedsInferiorCall + + CheckType("d1.(Locale)", "@QString") % NeedsInferiorCall + + CheckType("d1.(SystemLocale)", "@QString") % NeedsInferiorCall + Check("t0", "(invalid)", "@QTime") + Check("t1", "13:15:32", "@QTime") - + Check("t1.(ISO)", "\"13:15:32\"", "@QString") % Optional() - + Check("t1.toString", "\"13:15:32\"", "@QString") % Optional() - + CheckType("t1.(Locale)", "@QString") % Optional() - + CheckType("t1.(SystemLocale)", "@QString") % Optional() + + Check("t1.(ISO)", "\"13:15:32\"", "@QString") % NeedsInferiorCall + + Check("t1.toString", "\"13:15:32\"", "@QString") % NeedsInferiorCall + + CheckType("t1.(Locale)", "@QString") % NeedsInferiorCall + + CheckType("t1.(SystemLocale)", "@QString") % NeedsInferiorCall + Check("dt0", "(invalid)", "@QDateTime") + Check("dt1", Value4("Tue Jan 1 13:15:32 1980"), "@QDateTime") + Check("dt1", Value5("Tue Jan 1 13:15:32 1980 GMT"), "@QDateTime") + Check("dt1.(ISO)", - "\"1980-01-01T13:15:32Z\"", "@QString") % Optional() - + CheckType("dt1.(Locale)", "@QString") % Optional() - + CheckType("dt1.(SystemLocale)", "@QString") % Optional() + "\"1980-01-01T13:15:32Z\"", "@QString") % NeedsInferiorCall + + CheckType("dt1.(Locale)", "@QString") % NeedsInferiorCall + + CheckType("dt1.(SystemLocale)", "@QString") % NeedsInferiorCall + Check("dt1.toString", - Value4("\"Tue Jan 1 13:15:32 1980\""), "@QString") % Optional() + Value4("\"Tue Jan 1 13:15:32 1980\""), "@QString") % NeedsInferiorCall + Check("dt1.toString", - Value5("\"Tue Jan 1 13:15:32 1980 GMT\""), "@QString") % Optional(); + Value5("\"Tue Jan 1 13:15:32 1980 GMT\""), "@QString") % NeedsInferiorCall; //+ Check("dt1.toUTC", // Value4("Tue Jan 1 13:15:32 1980"), "@QDateTime") % Optional() //+ Check("dt1.toUTC", @@ -2724,7 +2746,7 @@ void tst_Dumpers::dumper_data() + CheckType("loc", "@QLocale") + CheckType("m", "@QLocale::MeasurementSystem") - + Check("loc1", "\"en_US\"", "@QLocale") + + Check("loc1", "\"en_US\"", "@QLocale") % NeedsInferiorCall + Check("loc1.country", "@QLocale::UnitedStates (225)", "@QLocale::Country") % Qt5 + Check("loc1.language", "@QLocale::English (31)", "@QLocale::Language") % Qt5 + Check("loc1.numberOptions", "@QLocale::DefaultNumberOptions (0)", "@QLocale::NumberOptions") @@ -3306,7 +3328,7 @@ void tst_Dumpers::dumper_data() "QT_BEGIN_NAMESPACE\n" "uint qHash(const QMap &) { return 0; }\n" "uint qHash(const double & f) { return int(f); }\n" - "uint qHash(const QPointer &p) { return (ulong)p.data(); }\n" + "uint qHash(const QPointer &p) { return (quintptr)p.data(); }\n" "QT_END_NAMESPACE\n", "QSet s1;\n" diff --git a/tests/unit/unittest/data/highlightingmarks.cpp b/tests/unit/unittest/data/highlightingmarks.cpp index 2476cabfb22..33dfbe91dec 100644 --- a/tests/unit/unittest/data/highlightingmarks.cpp +++ b/tests/unit/unittest/data/highlightingmarks.cpp @@ -699,3 +699,35 @@ private: template struct S { }; template using spec = S; spec<2> s; + +class Property { + Q_PROPERTY( + + const + + volatile + + unsigned + + long + + long + + * + + prop + + READ + + getProp + + WRITE + + setProp + + NOTIFY + + propChanged + + ) +}; diff --git a/tests/unit/unittest/tokenprocessor-test.cpp b/tests/unit/unittest/tokenprocessor-test.cpp index 786b980f222..37c76d8ce6d 100644 --- a/tests/unit/unittest/tokenprocessor-test.cpp +++ b/tests/unit/unittest/tokenprocessor-test.cpp @@ -146,6 +146,7 @@ public: static void TearDownTestCase(); SourceRange sourceRange(uint line, uint columnEnd) const; + SourceRange sourceRangeMultiLine(uint firstLine, uint lastLine, uint columnEnd) const; protected: static Data *d; @@ -1574,6 +1575,14 @@ TEST_F(TokenProcessor, QtPropertyName) ASSERT_THAT(infos[8], HasOnlyType(HighlightingType::QtProperty)); } +TEST_F(TokenProcessor, QtPropertyNameMultiLine) +{ + const auto infos = translationUnit.fullTokenInfosInRange(sourceRangeMultiLine(704, 732, 14)); + + ASSERT_THAT(infos[0], HasOnlyType(HighlightingType::PreprocessorExpansion)); + ASSERT_THAT(infos[8], HasOnlyType(HighlightingType::QtProperty)); +} + TEST_F(TokenProcessor, QtPropertyFunction) { const auto infos = translationUnit.fullTokenInfosInRange(sourceRange(599, 103)); @@ -1581,6 +1590,13 @@ TEST_F(TokenProcessor, QtPropertyFunction) ASSERT_THAT(infos[10], HasOnlyType(HighlightingType::Function)); } +TEST_F(TokenProcessor, QtPropertyFunctionMultiLine) +{ + const auto infos = translationUnit.fullTokenInfosInRange(sourceRangeMultiLine(704, 732, 14)); + + ASSERT_THAT(infos[10], HasOnlyType(HighlightingType::Function)); +} + TEST_F(TokenProcessor, QtPropertyInternalKeyword) { const auto infos = translationUnit.fullTokenInfosInRange(sourceRange(599, 103)); @@ -1588,6 +1604,13 @@ TEST_F(TokenProcessor, QtPropertyInternalKeyword) ASSERT_THAT(infos[9], HasOnlyType(HighlightingType::Invalid)); } +TEST_F(TokenProcessor, QtPropertyInternalKeywordMultiLine) +{ + const auto infos = translationUnit.fullTokenInfosInRange(sourceRangeMultiLine(704, 732, 14)); + + ASSERT_THAT(infos[9], HasOnlyType(HighlightingType::Invalid)); +} + TEST_F(TokenProcessor, QtPropertyLastToken) { const auto infos = translationUnit.fullTokenInfosInRange(sourceRange(599, 103)); @@ -1595,6 +1618,13 @@ TEST_F(TokenProcessor, QtPropertyLastToken) ASSERT_THAT(infos[14], HasOnlyType(HighlightingType::Function)); } +TEST_F(TokenProcessor, QtPropertyLastTokenMultiLine) +{ + const auto infos = translationUnit.fullTokenInfosInRange(sourceRangeMultiLine(704, 732, 14)); + + ASSERT_THAT(infos[14], HasOnlyType(HighlightingType::Function)); +} + TEST_F(TokenProcessor, QtPropertyType) { const auto infos = translationUnit.fullTokenInfosInRange(sourceRange(600, 46)); @@ -1747,4 +1777,10 @@ ClangBackEnd::SourceRange TokenProcessor::sourceRange(uint line, uint columnEnd) return translationUnit.sourceRange(line, 1, line, columnEnd); } +ClangBackEnd::SourceRange TokenProcessor::sourceRangeMultiLine(uint firstLine, uint lastLine, + uint columnEnd) const +{ + return translationUnit.sourceRange(firstLine, 1, lastLine, columnEnd); +} + }