From f6659f24dfde7d1378bc22a83ad6b19e20612926 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Fri, 1 Nov 2019 12:06:43 +0100 Subject: [PATCH 01/15] Fix layout of the code style settings editor Fixes: QTCREATORBUG-23227 Change-Id: I1ae650ba1e66c9444ef0d7fe17d003e5d6662b77 Reviewed-by: Eike Ziller --- .../cpptools/cppcodestylesettingspage.cpp | 2 - .../cpptools/cppcodestylesettingspage.ui | 53 +-- .../simplecodestylepreferenceswidget.cpp | 5 - .../simplecodestylepreferenceswidget.h | 1 - src/plugins/texteditor/tabsettingswidget.cpp | 9 +- src/plugins/texteditor/tabsettingswidget.h | 5 +- src/plugins/texteditor/tabsettingswidget.ui | 373 +++++++++--------- 7 files changed, 186 insertions(+), 262 deletions(-) diff --git a/src/plugins/cpptools/cppcodestylesettingspage.cpp b/src/plugins/cpptools/cppcodestylesettingspage.cpp index ef62ad1fa32..1616411f511 100644 --- a/src/plugins/cpptools/cppcodestylesettingspage.cpp +++ b/src/plugins/cpptools/cppcodestylesettingspage.cpp @@ -161,8 +161,6 @@ CppCodeStylePreferencesWidget::CppCodeStylePreferencesWidget(QWidget *parent) this, &CppCodeStylePreferencesWidget::slotCodeStyleSettingsChanged); m_ui->categoryTab->setCurrentIndex(0); - - m_ui->tabSettingsWidget->setFlat(true); } CppCodeStylePreferencesWidget::~CppCodeStylePreferencesWidget() diff --git a/src/plugins/cpptools/cppcodestylesettingspage.ui b/src/plugins/cpptools/cppcodestylesettingspage.ui index 713c6384efb..5bb0eff89c1 100644 --- a/src/plugins/cpptools/cppcodestylesettingspage.ui +++ b/src/plugins/cpptools/cppcodestylesettingspage.ui @@ -7,7 +7,7 @@ 0 0 463 - 314 + 317 @@ -69,19 +69,7 @@ Indent - - true - - - 0 - - - 0 - - - 0 - @@ -155,19 +143,7 @@ Indent Braces - - true - - - 0 - - - 0 - - - 0 - @@ -238,19 +214,7 @@ Indent within "switch" - - true - - - 0 - - - 0 - - - 0 - @@ -317,19 +281,7 @@ Align - - true - - - 0 - - - 0 - - - 0 - @@ -414,9 +366,6 @@ if they would align to the next line Bind '*' and '&&' in types/declarations to - - true - diff --git a/src/plugins/texteditor/simplecodestylepreferenceswidget.cpp b/src/plugins/texteditor/simplecodestylepreferenceswidget.cpp index d520232c632..d64a588244d 100644 --- a/src/plugins/texteditor/simplecodestylepreferenceswidget.cpp +++ b/src/plugins/texteditor/simplecodestylepreferenceswidget.cpp @@ -89,11 +89,6 @@ void SimpleCodeStylePreferencesWidget::slotTabSettingsChanged(const TextEditor:: current->setTabSettings(settings); } -void SimpleCodeStylePreferencesWidget::setFlat(bool on) -{ - m_tabSettingsWidget->setFlat(on); -} - TabSettingsWidget *SimpleCodeStylePreferencesWidget::tabSettingsWidget() const { return m_tabSettingsWidget; diff --git a/src/plugins/texteditor/simplecodestylepreferenceswidget.h b/src/plugins/texteditor/simplecodestylepreferenceswidget.h index 9b77a98a277..7674b3c657d 100644 --- a/src/plugins/texteditor/simplecodestylepreferenceswidget.h +++ b/src/plugins/texteditor/simplecodestylepreferenceswidget.h @@ -46,7 +46,6 @@ public: void setPreferences(ICodeStylePreferences *tabPreferences); - void setFlat(bool on); TabSettingsWidget *tabSettingsWidget() const; private: diff --git a/src/plugins/texteditor/tabsettingswidget.cpp b/src/plugins/texteditor/tabsettingswidget.cpp index fd4ddb29890..c6e84d26d31 100644 --- a/src/plugins/texteditor/tabsettingswidget.cpp +++ b/src/plugins/texteditor/tabsettingswidget.cpp @@ -32,7 +32,7 @@ namespace TextEditor { TabSettingsWidget::TabSettingsWidget(QWidget *parent) : - QWidget(parent), + QGroupBox(parent), ui(new Internal::Ui::TabSettingsWidget) { ui->setupUi(this); @@ -91,13 +91,6 @@ void TabSettingsWidget::codingStyleLinkActivated(const QString &linkString) emit codingStyleLinkClicked(QtQuickLink); } -void TabSettingsWidget::setFlat(bool on) -{ - ui->tabsAndIndentationGroupBox->setFlat(on); - const int margin = on ? 0 : -1; - ui->tabsAndIndentationGroupBox->layout()->setContentsMargins(margin, -1, margin, margin); -} - void TabSettingsWidget::setCodingStyleWarningVisible(bool visible) { ui->codingStyleWarning->setVisible(visible); diff --git a/src/plugins/texteditor/tabsettingswidget.h b/src/plugins/texteditor/tabsettingswidget.h index 33b8ad919e3..5a5206434ac 100644 --- a/src/plugins/texteditor/tabsettingswidget.h +++ b/src/plugins/texteditor/tabsettingswidget.h @@ -27,7 +27,7 @@ #include "texteditor_global.h" -#include +#include namespace TextEditor { @@ -35,7 +35,7 @@ namespace Internal { namespace Ui { class TabSettingsWidget; } } class TabSettings; -class TEXTEDITOR_EXPORT TabSettingsWidget : public QWidget +class TEXTEDITOR_EXPORT TabSettingsWidget : public QGroupBox { Q_OBJECT @@ -50,7 +50,6 @@ public: TabSettings tabSettings() const; - void setFlat(bool on); void setCodingStyleWarningVisible(bool visible); void setTabSettings(const TextEditor::TabSettings& s); diff --git a/src/plugins/texteditor/tabsettingswidget.ui b/src/plugins/texteditor/tabsettingswidget.ui index 44029650b40..69fe0b9a2a6 100644 --- a/src/plugins/texteditor/tabsettingswidget.ui +++ b/src/plugins/texteditor/tabsettingswidget.ui @@ -1,160 +1,181 @@ TextEditor::Internal::TabSettingsWidget - + 0 0 - 335 - 224 + 254 + 189 - + - - - 0 - - - - - Tabs And Indentation + + Tabs And Indentation + + + + + + The text editor indentation setting is used for non-code files only. See the C++ and Qt Quick coding style settings to configure indentation for code files. - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 30 - 20 - - - - - - - - - 0 - 0 - - - - - Spaces Only - - - - - Tabs Only - - - - - Mixed - - - - - - - - - - - 0 - 0 - - - - Ta&b size: - - - tabSize - - - - - - - - 0 - 0 - - - - 1 - - - 20 - - - - - - - - 0 - 0 - - - - &Indent size: - - - indentSize - - - - - - - - 0 - 0 - - - - 1 - - - 20 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - 0 - 0 - - - - <html><head/><body> + + <i>Code indentation is configured in <a href="C++">C++</a> and <a href="QtQuick">Qt Quick</a> settings.</i> + + + true + + + + + + + Tab policy: + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 30 + 20 + + + + + + + + + 0 + 0 + + + + + Spaces Only + + + + + Tabs Only + + + + + Mixed + + + + + + + + + + + 0 + 0 + + + + Ta&b size: + + + tabSize + + + + + + + + 0 + 0 + + + + 1 + + + 20 + + + + + + + + 0 + 0 + + + + &Indent size: + + + indentSize + + + + + + + + 0 + 0 + + + + 1 + + + 20 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Align continuation lines: + + + + + + + + 0 + 0 + + + + <html><head/><body> Influences the indentation of continuation lines. <ul> @@ -179,52 +200,22 @@ Influences the indentation of continuation lines. </pre> </li> </ul></body></html> - - - - Not At All - - - - - With Spaces - - - - - With Regular Indent - - - - - - - - Tab policy: - - - - - - - Align continuation lines: - - - - - - - The text editor indentation setting is used for non-code files only. See the C++ and Qt Quick coding style settings to configure indentation for code files. - - - <i>Code indentation is configured in <a href="C++">C++</a> and <a href="QtQuick">Qt Quick</a> settings.</i> - - - true - - - - + + + + Not At All + + + + + With Spaces + + + + + With Regular Indent + + From 91b491ffb9bb59f8efd6076b64e0e478c12cef71 Mon Sep 17 00:00:00 2001 From: Henning Gruendl Date: Thu, 19 Dec 2019 11:29:44 +0100 Subject: [PATCH 02/15] QmlDesigner: Add error mode to ColorLogic Task-number: QDS-1221 Change-Id: I95009dc3700f3e308280fadaea374e7ba6dfa08b Reviewed-by: Thomas Hartmann --- .../imports/HelperWidgets/ColorLogic.qml | 10 +++++++++- .../imports/HelperWidgets/ComboBox.qml | 4 +++- .../imports/StudioTheme/Values.qml | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorLogic.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorLogic.qml index 9c200097794..a39d7fd7886 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorLogic.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorLogic.qml @@ -36,20 +36,28 @@ QtObject { property bool isInModel: backendValue.isInModel; property bool isInSubState: backendValue.isInSubState; property bool highlight: textColor === __changedTextColor + property bool errorState: false - property color __defaultTextColor: StudioTheme.Values.themeTextColor + readonly property color __defaultTextColor: StudioTheme.Values.themeTextColor readonly property color __changedTextColor: StudioTheme.Values.themeInteraction + readonly property color __errorTextColor: StudioTheme.Values.themeErrorColor onBackendValueChanged: evaluate() onValueFromBackendChanged: evaluate() onBaseStateFlagChanged: evaluate() onIsInModelChanged: evaluate() onIsInSubStateChanged: evaluate() + onErrorStateChanged: evaluate() function evaluate() { if (innerObject.backendValue === undefined) return + if (innerObject.errorState) { + innerObject.textColor = __errorTextColor + return + } + if (innerObject.baseStateFlag) { if (innerObject.backendValue.isInModel) innerObject.textColor = __changedTextColor diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComboBox.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComboBox.qml index 23327590569..eb6fc60476f 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComboBox.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComboBox.qml @@ -33,7 +33,7 @@ StudioControls.ComboBox { property variant backendValue - labelColor: edit ? StudioTheme.Values.themeTextColor : colorLogic.textColor + labelColor: edit && !colorLogic.errorState ? StudioTheme.Values.themeTextColor : colorLogic.textColor property string scope: "Qt" property bool useInteger: false @@ -48,6 +48,8 @@ StudioControls.ComboBox { property bool showExtendedFunctionButton: true + property alias colorLogic: colorLogic + ExtendedFunctionLogic { id: extFuncLogic backendValue: comboBox.backendValue diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/Values.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/Values.qml index 32136421a46..ff10e1e79f5 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/Values.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/Values.qml @@ -108,6 +108,8 @@ QtObject { property string themeSliderInactiveTrackFocus: "#606060" property string themeSliderHandleFocus: values.themeInteraction + property string themeErrorColor: "#df3a3a" + // NEW NEW NEW NEW NEW property string themeControlBackgroundDisabled: "#363636" property string themeControlOutlineDisabled: "#404040" From 8687d653531bf7646dd480c8576bcb0d86953662 Mon Sep 17 00:00:00 2001 From: Henning Gruendl Date: Fri, 20 Dec 2019 16:37:08 +0100 Subject: [PATCH 03/15] QmlDesigner: Remove tooltip dependency Controls 1 Task-number: QDS-619 Change-Id: I4e54ac43cd6d3052620a9e5ca48cf1fbc66c6181 Reviewed-by: Thomas Hartmann --- .../imports/HelperWidgets/ToolTipArea.qml | 12 +-- src/plugins/qmldesigner/CMakeLists.txt | 1 + .../propertyeditor/propertyeditor.pri | 6 +- .../quick2propertyeditorview.cpp | 2 + .../components/propertyeditor/tooltip.cpp | 78 +++++++++++++++++++ .../components/propertyeditor/tooltip.h | 65 ++++++++++++++++ src/plugins/qmldesigner/qmldesignerplugin.qbs | 2 + 7 files changed, 159 insertions(+), 7 deletions(-) create mode 100644 src/plugins/qmldesigner/components/propertyeditor/tooltip.cpp create mode 100644 src/plugins/qmldesigner/components/propertyeditor/tooltip.h diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ToolTipArea.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ToolTipArea.qml index df39546d93c..d89ec297477 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ToolTipArea.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ToolTipArea.qml @@ -24,16 +24,18 @@ ****************************************************************************/ import QtQuick 2.1 -import QtQuick.Controls 1.1 as Controls +import HelperWidgets 2.0 import QtQuick.Layouts 1.0 -import QtQuick.Controls.Private 1.0 MouseArea { id: mouseArea - onExited: Tooltip.hideText() - onCanceled: Tooltip.hideText() + Tooltip { + id: myTooltip + } + onExited: myTooltip.hideText() + onCanceled: myTooltip.hideText() onClicked: forceActiveFocus() hoverEnabled: true @@ -43,6 +45,6 @@ MouseArea { Timer { interval: 1000 running: mouseArea.containsMouse && tooltip.length - onTriggered: Tooltip.showText(mouseArea, Qt.point(mouseArea.mouseX, mouseArea.mouseY), tooltip) + onTriggered: myTooltip.showText(mouseArea, Qt.point(mouseArea.mouseX, mouseArea.mouseY), tooltip) } } diff --git a/src/plugins/qmldesigner/CMakeLists.txt b/src/plugins/qmldesigner/CMakeLists.txt index 0a758c135f1..5948c7d3b27 100644 --- a/src/plugins/qmldesigner/CMakeLists.txt +++ b/src/plugins/qmldesigner/CMakeLists.txt @@ -320,6 +320,7 @@ extend_qtc_plugin(QmlDesigner simplecolorpalette.cpp simplecolorpalette.h simplecolorpalettemodel.cpp simplecolorpalettemodel.h simplecolorpalettesingleton.cpp simplecolorpalettesingleton.h + tooltip.cpp tooltip.h qmlanchorbindingproxy.cpp qmlanchorbindingproxy.h qmlmodelnodeproxy.cpp qmlmodelnodeproxy.h quick2propertyeditorview.cpp quick2propertyeditorview.h diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri index 1fb9a3981f7..7516c45c2ba 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri @@ -20,7 +20,8 @@ SOURCES += propertyeditorview.cpp \ simplecolorpalettemodel.cpp \ simplecolorpalettesingleton.cpp \ itemfiltermodel.cpp \ - aligndistribute.cpp + aligndistribute.cpp \ + tooltip.cpp HEADERS += propertyeditorview.h \ qmlanchorbindingproxy.h \ @@ -42,6 +43,7 @@ HEADERS += propertyeditorview.h \ simplecolorpalettemodel.h \ simplecolorpalettesingleton.h \ itemfiltermodel.h \ - aligndistribute.h + aligndistribute.h \ + tooltip.h QT += qml quick diff --git a/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp b/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp index 096162490eb..131ef0fe8a2 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp @@ -37,6 +37,7 @@ #include "qmlanchorbindingproxy.h" #include "theme.h" #include "aligndistribute.h" +#include "tooltip.h" namespace QmlDesigner { @@ -63,6 +64,7 @@ void Quick2PropertyEditorView::registerQmlTypes() BindingEditor::registerDeclarativeType(); ActionEditor::registerDeclarativeType(); AlignDistribute::registerDeclarativeType(); + Tooltip::registerDeclarativeType(); } } diff --git a/src/plugins/qmldesigner/components/propertyeditor/tooltip.cpp b/src/plugins/qmldesigner/components/propertyeditor/tooltip.cpp new file mode 100644 index 00000000000..7e4e03fa602 --- /dev/null +++ b/src/plugins/qmldesigner/components/propertyeditor/tooltip.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "tooltip.h" +#include +#include +#include +#include +#include +#include +#include + +Tooltip::Tooltip(QObject *parent) + : QObject(parent) +{} + +void Tooltip::showText(QQuickItem *item, const QPointF &pos, const QString &str) +{ + if (!item || !item->window()) + return; + + if (QGuiApplicationPrivate::platformIntegration()-> + hasCapability(QPlatformIntegration::MultipleWindows) && + QCoreApplication::instance()->inherits("QApplication")) { + QPoint quickWidgetOffsetInTlw; + QWindow *renderWindow = QQuickRenderControl::renderWindowFor(item->window(), &quickWidgetOffsetInTlw); + QWindow *window = renderWindow ? renderWindow : item->window(); + const QPoint offsetInQuickWidget = item->mapToScene(pos).toPoint(); + const QPoint mappedPos = window->mapToGlobal(offsetInQuickWidget + quickWidgetOffsetInTlw); + QToolTip::showText(mappedPos, str); + } +} + +void Tooltip::hideText() +{ + QToolTip::hideText(); +} + +void Tooltip::registerDeclarativeType() +{ + qmlRegisterType("HelperWidgets", 2, 0, "Tooltip"); +} diff --git a/src/plugins/qmldesigner/components/propertyeditor/tooltip.h b/src/plugins/qmldesigner/components/propertyeditor/tooltip.h new file mode 100644 index 00000000000..8487308d11c --- /dev/null +++ b/src/plugins/qmldesigner/components/propertyeditor/tooltip.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TOOLTIP_H +#define TOOLTIP_H + +#include + +#include + +class QPointF; +class QQuickItem; + +class Tooltip : public QObject +{ + Q_OBJECT + +public: + explicit Tooltip(QObject *parent = nullptr); + + Q_INVOKABLE void showText(QQuickItem *item, const QPointF &pos, const QString &text); + Q_INVOKABLE void hideText(); + + static void registerDeclarativeType(); +}; + +QML_DECLARE_TYPE(Tooltip) + +#endif // TOOLTIP_H diff --git a/src/plugins/qmldesigner/qmldesignerplugin.qbs b/src/plugins/qmldesigner/qmldesignerplugin.qbs index 67783c7c157..6de6275ae93 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.qbs +++ b/src/plugins/qmldesigner/qmldesignerplugin.qbs @@ -618,6 +618,8 @@ Project { "propertyeditor/simplecolorpalettemodel.h", "propertyeditor/simplecolorpalettesingleton.cpp", "propertyeditor/simplecolorpalettesingleton.h", + "propertyeditor/tooltip.cpp", + "propertyeditor/tooltip.h", "resources/resources.qrc", "stateseditor/stateseditorimageprovider.cpp", "stateseditor/stateseditorimageprovider.h", From 93c668926d3f454f52b73c631b975a49c43292ed Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 6 Jan 2020 17:52:51 +0100 Subject: [PATCH 04/15] QmlDesigner: Fix qbs build Change-Id: I2c3907f6368160e043a2e848e96f5cea30c407dd Reviewed-by: Christian Stenger --- src/plugins/qmldesigner/qmldesignerplugin.qbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/qmldesigner/qmldesignerplugin.qbs b/src/plugins/qmldesigner/qmldesignerplugin.qbs index 6de6275ae93..454fdfced05 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.qbs +++ b/src/plugins/qmldesigner/qmldesignerplugin.qbs @@ -12,7 +12,7 @@ Project { Depends { name: "Qt"; submodules: [ - "core-private", "quickwidgets" + "core-private", "gui-private", "quickwidgets" ] } Depends { name: "Core" } From 307b4fb97b72dabb80de5c99745cfe1203e063d5 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 6 Jan 2020 17:53:06 +0100 Subject: [PATCH 05/15] QmlDesigner: Fix build with namespaced Qt Change-Id: I1dd6da16165f4503da32bebafec6b43074442a29 Reviewed-by: Christian Stenger --- src/plugins/qmldesigner/components/propertyeditor/tooltip.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/qmldesigner/components/propertyeditor/tooltip.h b/src/plugins/qmldesigner/components/propertyeditor/tooltip.h index 8487308d11c..785a1b51d42 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/tooltip.h +++ b/src/plugins/qmldesigner/components/propertyeditor/tooltip.h @@ -44,8 +44,10 @@ #include +QT_BEGIN_NAMESPACE class QPointF; class QQuickItem; +QT_END_NAMESPACE class Tooltip : public QObject { From b99a495b11358052c0799a69ff626ea6a31de55a Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Tue, 7 Jan 2020 06:50:37 +0100 Subject: [PATCH 06/15] Fix qmake build Amends 93c668926d3f454f52b73c631b975a49c43292ed. Change-Id: I26a332036a2ce6ae7f29d495b9a95f516145e9c1 Reviewed-by: David Schulz --- .../qmldesigner/components/propertyeditor/propertyeditor.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri index 7516c45c2ba..a6002c86c86 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri @@ -46,4 +46,4 @@ HEADERS += propertyeditorview.h \ aligndistribute.h \ tooltip.h -QT += qml quick +QT += qml quick gui-private From 76eba270bf54c2e5e52e327551da22faa2426f9a Mon Sep 17 00:00:00 2001 From: Andrzej Ostruszka Date: Thu, 2 Jan 2020 15:09:54 +0100 Subject: [PATCH 07/15] fakevim: fix indenting of continuation lines Use tab settings for indenting of continuation lines from current document instead of using default value. Task-number: QTCREATORBUG-20876 Change-Id: Ied15226166483dc11672c930145564cf897def19 Reviewed-by: David Schulz --- src/plugins/fakevim/fakevimplugin.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index 211ccb67de2..393e5380ae9 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -1617,6 +1617,8 @@ void FakeVimPluginPrivate::editorOpened(IEditor *editor) tabSettings.m_tabSize = theFakeVimSetting(ConfigTabStop)->value().toInt(); tabSettings.m_tabPolicy = theFakeVimSetting(ConfigExpandTab)->value().toBool() ? TabSettings::SpacesOnlyTabPolicy : TabSettings::TabsOnlyTabPolicy; + tabSettings.m_continuationAlignBehavior = + tew->textDocument()->tabSettings().m_continuationAlignBehavior; QTextDocument *doc = tew->document(); QTextBlock startBlock = doc->findBlockByNumber(beginBlock); From bb02ab161cf956f616ad93da09baf62919641ac5 Mon Sep 17 00:00:00 2001 From: Mahmoud Badri Date: Thu, 2 Jan 2020 11:58:33 +0200 Subject: [PATCH 08/15] Enable common keyboard hotkey actions for the Edit View 3D Clicking undo, redo, delete, or save keyboard hotkeys while the Edit View 3D has focus is working now. Additionally this commit introduces a generic command for carrying any variant data from puppet to creator side. This significantly simplifies and avoids the boiler plate work of sending actions from puppet to creator side. Current commands can be ported to use this generic command but this is not part of this commit. Also a similar command to work the other way around could be implemented. Task-number: QDS-1266 Change-Id: I40fdf6b215ce77402250a791ea49cbdcd2a9d6eb Reviewed-by: Miikka Heikkinen Reviewed-by: Thomas Hartmann --- .../qml/qmlpuppet/commands/commands.pri | 2 + .../commands/puppettocreatorcommand.cpp | 55 ++++++++++++++++++ .../commands/puppettocreatorcommand.h | 56 +++++++++++++++++++ .../instances/nodeinstanceclientproxy.cpp | 6 ++ .../instances/nodeinstanceclientproxy.h | 2 + .../interfaces/nodeinstanceclientinterface.h | 2 + .../nodeinstanceserverinterface.cpp | 7 +++ .../qt5informationnodeinstanceserver.cpp | 8 +++ src/plugins/qmldesigner/CMakeLists.txt | 1 + .../designercore/include/nodeinstanceview.h | 7 ++- .../instances/nodeinstanceserverproxy.cpp | 4 ++ .../instances/nodeinstanceview.cpp | 42 +++++++++++++- src/plugins/qmldesigner/qmldesignerplugin.qbs | 2 + src/tools/qml2puppet/CMakeLists.txt | 1 + src/tools/qml2puppet/qml2puppet.qbs | 2 + 15 files changed, 193 insertions(+), 4 deletions(-) create mode 100644 share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.cpp create mode 100644 share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.h diff --git a/share/qtcreator/qml/qmlpuppet/commands/commands.pri b/share/qtcreator/qml/qmlpuppet/commands/commands.pri index 47ec4473eaf..7bc595154b3 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/commands.pri +++ b/share/qtcreator/qml/qmlpuppet/commands/commands.pri @@ -31,6 +31,7 @@ HEADERS += $$PWD/drop3dlibraryitemcommand.h HEADERS += $$PWD/update3dviewstatecommand.h HEADERS += $$PWD/enable3dviewcommand.h HEADERS += $$PWD/view3dclosedcommand.h +HEADERS += $$PWD/puppettocreatorcommand.h SOURCES += $$PWD/synchronizecommand.cpp SOURCES += $$PWD/debugoutputcommand.cpp @@ -63,3 +64,4 @@ SOURCES += $$PWD/drop3dlibraryitemcommand.cpp SOURCES += $$PWD/update3dviewstatecommand.cpp SOURCES += $$PWD/enable3dviewcommand.cpp SOURCES += $$PWD/view3dclosedcommand.cpp +SOURCES += $$PWD/puppettocreatorcommand.cpp diff --git a/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.cpp new file mode 100644 index 00000000000..b346776a243 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "puppettocreatorcommand.h" + +namespace QmlDesigner { + +// A generic command that can hold a variant data from puppet to creator + +PuppetToCreatorCommand::PuppetToCreatorCommand(Type type, const QVariant &data) + : m_type(type) + , m_data(data) +{ + +} + +QDataStream &operator<<(QDataStream &out, const PuppetToCreatorCommand &command) +{ + out << qint32(command.type()); + out << command.data(); + return out; +} + +QDataStream &operator>>(QDataStream &in, PuppetToCreatorCommand &command) +{ + qint32 type; + in >> type; + command.m_type = PuppetToCreatorCommand::Type(type); + in >> command.m_data; + return in; +} + +} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.h b/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.h new file mode 100644 index 00000000000..aa4dcd1a44e --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include +#include + +namespace QmlDesigner { + +class PuppetToCreatorCommand +{ +public: + enum Type { Key_Pressed, None }; + + PuppetToCreatorCommand(Type type, const QVariant &data); + PuppetToCreatorCommand() = default; + + Type type() const { return m_type; } + QVariant data() const { return m_data; } + +private: + Type m_type = None; + QVariant m_data; + + friend QDataStream &operator>>(QDataStream &in, PuppetToCreatorCommand &command); +}; + +QDataStream &operator<<(QDataStream &out, const PuppetToCreatorCommand &command); +QDataStream &operator>>(QDataStream &in, PuppetToCreatorCommand &command); + +} // namespace QmlDesigner + +Q_DECLARE_METATYPE(QmlDesigner::PuppetToCreatorCommand) diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp index 01d9cd18424..4ca4f0fb385 100644 --- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp +++ b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp @@ -72,6 +72,7 @@ #include "changeselectioncommand.h" #include "drop3dlibraryitemcommand.h" #include "view3dclosedcommand.h" +#include "puppettocreatorcommand.h" namespace QmlDesigner { @@ -262,6 +263,11 @@ void NodeInstanceClientProxy::library3DItemDropped(const Drop3DLibraryItemComman writeCommand(QVariant::fromValue(command)); } +void NodeInstanceClientProxy::handlePuppetToCreatorCommand(const PuppetToCreatorCommand &command) +{ + writeCommand(QVariant::fromValue(command)); +} + void NodeInstanceClientProxy::view3DClosed(const View3DClosedCommand &command) { writeCommand(QVariant::fromValue(command)); diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h index 7c9724e1ff0..6a114bbe3e1 100644 --- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h +++ b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h @@ -60,6 +60,7 @@ class ChangeNodeSourceCommand; class EndPuppetCommand; class ChangeSelectionCommand; class Drop3DLibraryItemCommand; +class PuppetToCreatorCommand; class View3DClosedCommand; class NodeInstanceClientProxy : public QObject, public NodeInstanceClientInterface @@ -81,6 +82,7 @@ public: void puppetAlive(const PuppetAliveCommand &command); void selectionChanged(const ChangeSelectionCommand &command) override; void library3DItemDropped(const Drop3DLibraryItemCommand &command) override; + void handlePuppetToCreatorCommand(const PuppetToCreatorCommand &command) override; void view3DClosed(const View3DClosedCommand &command) override; void flush() override; diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h index b188d7edfdc..d289a1b2594 100644 --- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h +++ b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h @@ -43,6 +43,7 @@ class PuppetAliveCommand; class ChangeSelectionCommand; class Drop3DLibraryItemCommand; class View3DClosedCommand; +class PuppetToCreatorCommand; class NodeInstanceClientInterface { @@ -59,6 +60,7 @@ public: virtual void selectionChanged(const ChangeSelectionCommand &command) = 0; virtual void library3DItemDropped(const Drop3DLibraryItemCommand &command) = 0; virtual void view3DClosed(const View3DClosedCommand &command) = 0; + virtual void handlePuppetToCreatorCommand(const PuppetToCreatorCommand &command) = 0; virtual void flush() {} virtual void synchronizeWithClientProcess() {} diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp index f606bfacf2f..5c7c9d2953a 100644 --- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp +++ b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp @@ -64,6 +64,7 @@ #include "debugoutputcommand.h" #include "puppetalivecommand.h" #include "view3dclosedcommand.h" +#include "puppettocreatorcommand.h" #include @@ -209,6 +210,12 @@ void NodeInstanceServerInterface::registerCommands() qRegisterMetaType("View3DClosedCommand"); qRegisterMetaTypeStreamOperators("View3DClosedCommand"); + + qRegisterMetaType("PuppetToCreatorCommand"); + qRegisterMetaTypeStreamOperators("PuppetToCreatorCommand"); + + qRegisterMetaType>("QPairIntInt"); + qRegisterMetaTypeStreamOperators>("QPairIntInt"); } } diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp index db38985d90e..b9bc5e8a3ff 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp @@ -61,6 +61,7 @@ #include "removesharedmemorycommand.h" #include "objectnodeinstance.h" #include "drop3dlibraryitemcommand.h" +#include "puppettocreatorcommand.h" #include "view3dclosedcommand.h" #include "dummycontextobject.h" @@ -102,6 +103,13 @@ bool Qt5InformationNodeInstanceServer::eventFilter(QObject *, QEvent *event) nodeInstanceClient()->view3DClosed(View3DClosedCommand()); } break; + case QEvent::KeyPress: { + QKeyEvent *keyEvent = static_cast(event); + QPair data = {keyEvent->key(), keyEvent->modifiers()}; + nodeInstanceClient()->handlePuppetToCreatorCommand({PuppetToCreatorCommand::Key_Pressed, + QVariant::fromValue(data)}); + } break; + default: break; } diff --git a/src/plugins/qmldesigner/CMakeLists.txt b/src/plugins/qmldesigner/CMakeLists.txt index 5948c7d3b27..7596514f292 100644 --- a/src/plugins/qmldesigner/CMakeLists.txt +++ b/src/plugins/qmldesigner/CMakeLists.txt @@ -143,6 +143,7 @@ extend_qtc_plugin(QmlDesigner update3dviewstatecommand.cpp update3dviewstatecommand.h enable3dviewcommand.cpp enable3dviewcommand.h view3dclosedcommand.cpp view3dclosedcommand.h + puppettocreatorcommand.cpp puppettocreatorcommand.h ) extend_qtc_plugin(QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h b/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h index c55dae2d87a..3e18424ca69 100644 --- a/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h +++ b/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h @@ -147,6 +147,8 @@ public: void mainWindowActiveChanged(bool active, bool hasPopup); void enable3DView(bool enable); + void handlePuppetToCreatorCommand(const PuppetToCreatorCommand &command) override; + protected: void timerEvent(QTimerEvent *event) override; @@ -198,12 +200,13 @@ private: // functions void restartProcess(); void delayedRestartProcess(); -private: void handleCrash(); void startPuppetTransaction(); void endPuppetTransaction(); -private: //variables + // puppet to creator command handlers + void handlePuppetKeyPress(int key, Qt::KeyboardModifiers modifiers); + NodeInstance m_rootNodeInstance; NodeInstance m_activeStateInstance; diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp index 07e3216f377..76e1b34621d 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -286,6 +287,7 @@ void NodeInstanceServerProxy::dispatchCommand(const QVariant &command, PuppetStr static const int puppetAliveCommandType = QMetaType::type("PuppetAliveCommand"); static const int changeSelectionCommandType = QMetaType::type("ChangeSelectionCommand"); static const int drop3DLibraryItemCommandType = QMetaType::type("Drop3DLibraryItemCommand"); + static const int puppetToCreatorCommand = QMetaType::type("PuppetToCreatorCommand"); static const int view3DClosedCommand = QMetaType::type("View3DClosedCommand"); if (m_destructing) @@ -314,6 +316,8 @@ void NodeInstanceServerProxy::dispatchCommand(const QVariant &command, PuppetStr nodeInstanceClient()->selectionChanged(command.value()); } else if (command.userType() == drop3DLibraryItemCommandType) { nodeInstanceClient()->library3DItemDropped(command.value()); + } else if (command.userType() == puppetToCreatorCommand) { + nodeInstanceClient()->handlePuppetToCreatorCommand(command.value()); } else if (command.userType() == view3DClosedCommand) { nodeInstanceClient()->view3DClosed(command.value()); } else if (command.userType() == puppetAliveCommandType) { diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp index a550a2e4b2d..b06b5137266 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp @@ -30,7 +30,7 @@ #include #include #include - +#include "qmldesignerplugin.h" #include "abstractproperty.h" #include "variantproperty.h" #include "bindingproperty.h" @@ -42,7 +42,10 @@ #include "qmltimeline.h" #include "qmltimelinekeyframegroup.h" #include "qmlvisualnode.h" - +#include "coreplugin/actionmanager/actionmanager.h" +#include "coreplugin/editormanager/editormanager.h" +#include "coreplugin/documentmanager.h" +#include "plugins/qmldesigner/qmldesignerconstants.h" #include "createscenecommand.h" #include "createinstancescommand.h" #include "clearscenecommand.h" @@ -71,6 +74,7 @@ #include "removesharedmemorycommand.h" #include "debugoutputcommand.h" #include "nodeinstanceserverproxy.h" +#include "puppettocreatorcommand.h" #include #include @@ -1454,6 +1458,40 @@ void NodeInstanceView::library3DItemDropped(const Drop3DLibraryItemCommand &comm QmlVisualNode::createQmlVisualNode(this, itemLibraryEntry, {}); } +void NodeInstanceView::handlePuppetToCreatorCommand(const PuppetToCreatorCommand &command) +{ + if (command.type() == PuppetToCreatorCommand::Key_Pressed) { + QPair data = qvariant_cast>(command.data()); + int key = data.first; + Qt::KeyboardModifiers modifiers = Qt::KeyboardModifiers(data.second); + + handlePuppetKeyPress(key, modifiers); + } +} + +// puppet to creator command handlers +void NodeInstanceView::handlePuppetKeyPress(int key, Qt::KeyboardModifiers modifiers) +{ + // TODO: optimal way to handle key events is to just pass them on. This is done + // using the code below but it is so far not working, if someone could get it to work then + // it should be utilized and the rest of the method deleted +// QCoreApplication::postEvent([receiver], new QKeyEvent(QEvent::KeyPress, key, modifiers)); + + // handle common keyboard actions coming from puppet + if (Core::ActionManager::command(Core::Constants::UNDO)->keySequence().matches(key + modifiers) == QKeySequence::ExactMatch) + QmlDesignerPlugin::instance()->currentDesignDocument()->undo(); + else if (Core::ActionManager::command(Core::Constants::REDO)->keySequence().matches(key + modifiers) == QKeySequence::ExactMatch) + QmlDesignerPlugin::instance()->currentDesignDocument()->redo(); + else if (Core::ActionManager::command(Core::Constants::SAVE)->keySequence().matches(key + modifiers) == QKeySequence::ExactMatch) + Core::EditorManager::saveDocument(); + else if (Core::ActionManager::command(Core::Constants::SAVEAS)->keySequence().matches(key + modifiers) == QKeySequence::ExactMatch) + Core::EditorManager::saveDocumentAs(); + else if (Core::ActionManager::command(Core::Constants::SAVEALL)->keySequence().matches(key + modifiers) == QKeySequence::ExactMatch) + Core::DocumentManager::saveAllModifiedDocuments(); + else if (Core::ActionManager::command(QmlDesigner::Constants::C_DELETE)->keySequence().matches(key + modifiers) == QKeySequence::ExactMatch) + QmlDesignerPlugin::instance()->currentDesignDocument()->deleteSelected(); +} + void NodeInstanceView::view3DClosed(const View3DClosedCommand &command) { Q_UNUSED(command) diff --git a/src/plugins/qmldesigner/qmldesignerplugin.qbs b/src/plugins/qmldesigner/qmldesignerplugin.qbs index 454fdfced05..6b11bf52bfa 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.qbs +++ b/src/plugins/qmldesigner/qmldesignerplugin.qbs @@ -177,6 +177,8 @@ Project { "commands/enable3dviewcommand.h", "commands/view3dclosedcommand.cpp", "commands/view3dclosedcommand.h", + "commands/puppettocreatorcommand.cpp", + "commands/puppettocreatorcommand.h", "container/addimportcontainer.cpp", "container/addimportcontainer.h", "container/idcontainer.cpp", diff --git a/src/tools/qml2puppet/CMakeLists.txt b/src/tools/qml2puppet/CMakeLists.txt index 39126452830..06e224a96fc 100644 --- a/src/tools/qml2puppet/CMakeLists.txt +++ b/src/tools/qml2puppet/CMakeLists.txt @@ -49,6 +49,7 @@ extend_qtc_executable(qml2puppet update3dviewstatecommand.cpp update3dviewstatecommand.h enable3dviewcommand.cpp enable3dviewcommand.h view3dclosedcommand.cpp view3dclosedcommand.h + puppettocreatorcommand.cpp puppettocreatorcommand.h valueschangedcommand.cpp ) diff --git a/src/tools/qml2puppet/qml2puppet.qbs b/src/tools/qml2puppet/qml2puppet.qbs index 645250c2d41..cef1c5fe0b1 100644 --- a/src/tools/qml2puppet/qml2puppet.qbs +++ b/src/tools/qml2puppet/qml2puppet.qbs @@ -103,6 +103,8 @@ QtcTool { "commands/enable3dviewcommand.h", "commands/view3dclosedcommand.cpp", "commands/view3dclosedcommand.h", + "commands/puppettocreatorcommand.cpp", + "commands/puppettocreatorcommand.h", "container/addimportcontainer.cpp", "container/addimportcontainer.h", "container/idcontainer.cpp", From 59f08de43a9f0d90aa483cea625141b71b4ca029 Mon Sep 17 00:00:00 2001 From: Henning Gruendl Date: Tue, 7 Jan 2020 09:46:39 +0100 Subject: [PATCH 09/15] QmlDesigner: Fix tooltip build issue Change-Id: I9513172560c7a2556cf49ed5609ce227d0d7b18f Reviewed-by: Thomas Hartmann Reviewed-by: Aleksei German --- .../qmldesigner/components/propertyeditor/tooltip.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/plugins/qmldesigner/components/propertyeditor/tooltip.cpp b/src/plugins/qmldesigner/components/propertyeditor/tooltip.cpp index 7e4e03fa602..ec4085ef832 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/tooltip.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/tooltip.cpp @@ -40,8 +40,6 @@ #include "tooltip.h" #include #include -#include -#include #include #include #include @@ -55,9 +53,7 @@ void Tooltip::showText(QQuickItem *item, const QPointF &pos, const QString &str) if (!item || !item->window()) return; - if (QGuiApplicationPrivate::platformIntegration()-> - hasCapability(QPlatformIntegration::MultipleWindows) && - QCoreApplication::instance()->inherits("QApplication")) { + if (QCoreApplication::instance()->inherits("QApplication")) { QPoint quickWidgetOffsetInTlw; QWindow *renderWindow = QQuickRenderControl::renderWindowFor(item->window(), &quickWidgetOffsetInTlw); QWindow *window = renderWindow ? renderWindow : item->window(); From f75c4ea3f1f584ec1075aa2f3f9361a9a10e1a88 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 7 Jan 2020 12:32:07 +0100 Subject: [PATCH 10/15] QmlDesigner: Fix compile after bb02ab161cf956f616ad93da09baf62919641ac5 and cleanup includes Change-Id: Ia7f5bb2cb1c0ca18d5bffa3cac9ceea495592910 Reviewed-by: Miikka Heikkinen --- .../designercore/instances/nodeinstanceview.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp index b06b5137266..92806065af8 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp @@ -42,10 +42,7 @@ #include "qmltimeline.h" #include "qmltimelinekeyframegroup.h" #include "qmlvisualnode.h" -#include "coreplugin/actionmanager/actionmanager.h" -#include "coreplugin/editormanager/editormanager.h" -#include "coreplugin/documentmanager.h" -#include "plugins/qmldesigner/qmldesignerconstants.h" +#include "qmldesignerconstants.h" #include "createscenecommand.h" #include "createinstancescommand.h" #include "clearscenecommand.h" @@ -76,6 +73,9 @@ #include "nodeinstanceserverproxy.h" #include "puppettocreatorcommand.h" +#include +#include +#include #include #include From 887058f621eb527483bc74cd18ef0850f59e14b6 Mon Sep 17 00:00:00 2001 From: Henning Gruendl Date: Tue, 7 Jan 2020 12:54:19 +0100 Subject: [PATCH 11/15] Fix compilation Change-Id: I98fe164f32bbe8c65a76b853f12ce7765a1c0f7e Reviewed-by: Mahmoud Badri --- share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.h | 1 + 1 file changed, 1 insertion(+) diff --git a/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.h b/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.h index aa4dcd1a44e..ff2ec935769 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.h +++ b/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.h @@ -27,6 +27,7 @@ #include #include +#include namespace QmlDesigner { From c2c48598d49be80f2744f3ab393ad0dbf3d0ae82 Mon Sep 17 00:00:00 2001 From: Henning Gruendl Date: Mon, 6 Jan 2020 15:51:48 +0100 Subject: [PATCH 12/15] QmlDesigner: GradientPreset cleanup - Remove Controls 1 imports - Rework states - Utilize theme values Change-Id: I2d7b818f450387ad0325aae41aac7f8c1b30ea5f Reviewed-by: Thomas Hartmann Reviewed-by: Aleksei German --- .../HelperWidgets/GradientPresetList.qml | 60 ++-- .../GradientPresetTabContent.qml | 302 ++++++++---------- 2 files changed, 163 insertions(+), 199 deletions(-) diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/GradientPresetList.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/GradientPresetList.qml index 6af4f47c381..d756b53fe65 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/GradientPresetList.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/GradientPresetList.qml @@ -25,42 +25,43 @@ import QtQuick 2.11 import QtQuick.Layouts 1.12 -import QtQuick.Controls 2.5 import QtQuick.Dialogs 1.3 import HelperWidgets 2.0 import QtQuickDesignerTheme 1.0 +import StudioControls 1.0 as StudioControls +import StudioTheme 1.0 as StudioTheme Dialog { id: dialogWindow width: 1200 height: 650 - title: "Gradient Picker" + title: qsTr("Gradient Picker") - signal saved; - property alias gradientData: gradientPickerData; + signal saved + property alias gradientData: gradientPickerData QtObject { id: gradientPickerData - property var stops; - property var colors; - property int stopsCount; - property int presetID; - property int presetType; //default(0) or custom(1) - property Item selectedItem; + property var stops + property var colors + property int stopsCount + property int presetID + property int presetType // default(0) or custom(1) + property Item selectedItem } function addGradient(stopsPositions, stopsColors, stopsCount) { - customPresetListModel.addGradient(stopsPositions, stopsColors, stopsCount); + customPresetListModel.addGradient(stopsPositions, stopsColors, stopsCount) } function updatePresets() { - customPresetListModel.readPresets(); + customPresetListModel.readPresets() } - GradientPresetDefaultListModel { id: defaultPresetListModel; } - GradientPresetCustomListModel { id: customPresetListModel; } + GradientPresetDefaultListModel { id: defaultPresetListModel } + GradientPresetCustomListModel { id: customPresetListModel } standardButtons: Dialog.NoButton @@ -68,27 +69,30 @@ Dialog { anchors.fill: parent anchors.margins: -12 anchors.bottomMargin: -70 - color: "#363636" + color: StudioTheme.Values.themeColumnBackground + ColumnLayout { anchors.fill: parent anchors.margins: 13 anchors.bottomMargin: 71 + TabView { id: presetTabView Layout.alignment: Qt.AlignTop | Qt.AlignHCenter Layout.fillHeight: true Layout.fillWidth: true + Tab { title: qsTr("System Presets") - anchors.fill:parent + anchors.fill: parent GradientPresetTabContent { id: defaultTabContent viewModel: defaultPresetListModel editableName: false } + } - } //tab default Tab { title: qsTr("User Presets") anchors.fill: parent @@ -97,11 +101,12 @@ Dialog { id: customTabContent viewModel: customPresetListModel editableName: true - onPresetNameChanged: customPresetListModel.changePresetName(id, name); - property int deleteId; + onPresetNameChanged: customPresetListModel.changePresetName(id, name) + + property int deleteId onDeleteButtonClicked: { - deleteId = id; + deleteId = id deleteDialog.open() } @@ -112,11 +117,12 @@ Dialog { standardButtons: Dialog.No | Dialog.Yes title: qsTr("Delete preset?") text: qsTr("Are you sure you want to delete this preset?") - onAccepted: customPresetListModel.deletePreset(customTabContent.deleteId); + onAccepted: customPresetListModel.deletePreset(customTabContent.deleteId) } } - } //tab custom - } //tabview + } + } + RowLayout { Layout.alignment: Qt.AlignBottom | Qt.AlignRight Layout.topMargin: 5 @@ -124,7 +130,7 @@ Dialog { Button { id: buttonClose; text: qsTr("Close"); onClicked: { dialogWindow.reject(); } } Button { id: buttonSave; text: qsTr("Save"); onClicked: { dialogWindow.saved(); } } Button { id: buttonApply; text: qsTr("Apply"); onClicked: { dialogWindow.apply(); } } - } //RowLayout - } //ColumnLayout - } //rectangle -} //dialog + } + } + } +} diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/GradientPresetTabContent.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/GradientPresetTabContent.qml index c955cd8bc6f..f26064dd213 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/GradientPresetTabContent.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/GradientPresetTabContent.qml @@ -25,31 +25,28 @@ import QtQuick 2.11 import QtQuick.Layouts 1.12 -import QtQuick.Controls 2.5 -import QtQuick.Controls.Styles 1.4 import QtQuick.Dialogs 1.3 import HelperWidgets 2.0 import QtQuickDesignerTheme 1.0 -import QtQuick.Controls.Private 1.0 as PrivateControls - +import StudioControls 1.0 as StudioControls +import StudioTheme 1.0 as StudioTheme Rectangle { id: tabBackground width: parent.width height: parent.height - color: "#242424" + color: StudioTheme.Values.themeControlBackground anchors.fill: parent - property alias viewModel : gradientTable.model; - property bool editableName : false; + property alias viewModel: gradientTable.model + property bool editableName: false signal presetNameChanged(int id, string name) signal deleteButtonClicked(int id) - property real delegateWidth: 154; - property real delegateHeight: 178; - property real gridCellWidth: 160; - + property real delegateWidth: 154 + property real delegateHeight: 178 + property real gridCellWidth: 160 ScrollView { Layout.fillWidth: true @@ -74,7 +71,7 @@ Rectangle { Rectangle { id: backgroundCard - color: "#404040" + color: StudioTheme.Values.themeControlOutline clip: true property real flexibleWidth: (gradientTable.width - gradientTable.cellWidth * gradientTable.gridColumns) / gradientTable.gridColumns @@ -84,82 +81,78 @@ Rectangle { height: tabBackground.delegateHeight radius: 16 + function selectPreset(index) { + gradientTable.currentIndex = index + gradientData.stops = stopsPosList + gradientData.colors = stopsColorList + gradientData.stopsCount = stopListSize + gradientData.presetID = presetID + gradientData.presetType = presetTabView.currentIndex + + if (gradientData.selectedItem != null) + gradientData.selectedItem.isSelected = false + + backgroundCard.isSelected = true + gradientData.selectedItem = backgroundCard + } + MouseArea { id: rectMouseArea anchors.fill: parent hoverEnabled: true onClicked: { - gradientTable.currentIndex = index; - gradientData.stops = stopsPosList; - gradientData.colors = stopsColorList; - gradientData.stopsCount = stopListSize; - gradientData.presetID = presetID; - gradientData.presetType = presetTabView.currentIndex - - if (gradientData.selectedItem != null) - gradientData.selectedItem.isSelected = false - - backgroundCard.isSelected = true - gradientData.selectedItem = backgroundCard + presetNameBox.edit = false + nameInput.focus = false + backgroundCard.selectPreset(index) } - onEntered: { - if (backgroundCard.state != "CLICKED") { - backgroundCard.state = "HOVER"; - } - } - onExited: { - if (backgroundCard.state != "CLICKED") { - backgroundCard.state = "USUAL"; - } - } - } //mouseArea - - onIsSelectedChanged: { - if (isSelected) - backgroundCard.state = "CLICKED" - else - backgroundCard.state = "USUAL" } states: [ State { - name: "HOVER" + name: "default" + when: !(rectMouseArea.containsMouse || removeButton.hovered || + (nameMouseArea.containsMouse && !tabBackground.editableName)) && + !backgroundCard.isSelected PropertyChanges { target: backgroundCard - color: "#606060" - border.width: 1 - border.color: "#029de0" - } - }, - State { - name: "CLICKED" - PropertyChanges { - target: backgroundCard - color:"#029de0" - border.width: 1 - border.color: "#606060" - } - }, - State { - name: "USUAL" - PropertyChanges - { - target: backgroundCard - color: "#404040" + color: StudioTheme.Values.themeControlOutline border.width: 0 } + }, + State { + name: "hovered" + when: (rectMouseArea.containsMouse || removeButton.hovered || + (nameMouseArea.containsMouse && !tabBackground.editableName)) && + !backgroundCard.isSelected + PropertyChanges { + target: backgroundCard + color: StudioTheme.Values.themeControlBackgroundPressed + border.width: 1 + border.color: StudioTheme.Values.themeInteraction + } + }, + State { + name: "selected" + when: backgroundCard.isSelected + PropertyChanges { + target: backgroundCard + color:StudioTheme.Values.themeInteraction + border.width: 1 + border.color: StudioTheme.Values.themeControlBackgroundPressed + } } - ] //states + ] ColumnLayout { spacing: 2 anchors.fill: parent Rectangle { - width: 150; height: 150 id: gradientRect + width: 150 + height: 150 radius: 16 - Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter //was top + Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter Layout.topMargin: 2 gradient: Gradient { @@ -174,36 +167,26 @@ Rectangle { Component.onCompleted: { var stopsAmount = stopListSize; var newStops = []; - for (var i = 0; i < stopsAmount; i++ ) { + for (var i = 0; i < stopsAmount; i++) { newStops.push( stopComponent.createObject(showGr, { "position": stopsPosList[i], "color": stopsColorList[i] }) ); } showGr.stops = newStops; } - Rectangle { - id: removeItemRect + AbstractButton { + id: removeButton + visible: editableName && (rectMouseArea.containsMouse || removeButton.hovered) + backgroundRadius: StudioTheme.Values.smallRectWidth anchors.right: parent.right anchors.rightMargin: 5 anchors.top: parent.top anchors.topMargin: 5 - height: 16 - width: 16 - visible: editableName && rectMouseArea.containsMouse - color: "#804682b4" - - MouseArea { - anchors.fill: parent; - onClicked: tabBackground.deleteButtonClicked(index); - } - - Image { - source: "image://icons/close" - fillMode: Image.PreserveAspectFit - anchors.fill: parent; - Layout.alignment: Qt.AlignCenter - } //image remove - } //rectangle remove - } //rectangle gradient + width: Math.round(StudioTheme.Values.smallRectWidth) + height: Math.round(StudioTheme.Values.smallRectWidth) + buttonIcon: StudioTheme.Constants.closeCross + onClicked: tabBackground.deleteButtonClicked(index) + } + } Item { id: presetNameBox @@ -212,19 +195,7 @@ Rectangle { Layout.preferredHeight: backgroundCard.height - gradientRect.height - 4 Layout.bottomMargin: 4 - property bool readOnly : true; - - onReadOnlyChanged: { - if (!readOnly) { - nameInput.visible = true; - nameInput.forceActiveFocus(); - - //have to select text like this, otherwise there is an issue with long names - nameInput.cursorPosition = 0; - nameInput.cursorPosition = nameInput.length; - nameInput.selectAll(); - } - } //onReadOnlyChanged + property bool edit: false Rectangle { id: nameBackgroundColor @@ -233,131 +204,118 @@ Rectangle { radius: 16 visible: true anchors.fill: parent - } //rectangle + } - MouseArea { + ToolTipArea { id: nameMouseArea - visible: tabBackground.editableName - hoverEnabled: true anchors.fill: parent + tooltip: nameText.text + propagateComposedEvents: true - onClicked: presetNameBox.state = "Clicked"; - - onEntered: { - if (presetNameBox.state != "Clicked") - { - presetNameBox.state = "Hover"; + onClicked: { + if (!tabBackground.editableName) { + backgroundCard.selectPreset(index) + return } + + presetNameBox.edit = true + nameInput.forceActiveFocus() + // have to select text like this, otherwise there is an issue with long names + nameInput.cursorPosition = 0 + nameInput.cursorPosition = nameInput.length + nameInput.selectAll() } - - onExited: { - if (presetNameBox.state != "Clicked") - { - presetNameBox.state = "Normal"; - } - PrivateControls.Tooltip.hideText() - } - - Timer { - interval: 1000 - running: nameMouseArea.containsMouse && presetNameBox.readOnly - onTriggered: PrivateControls.Tooltip.showText(nameMouseArea, Qt.point(nameMouseArea.mouseX, nameMouseArea.mouseY), presetName) - } - - onCanceled: Tooltip.hideText() - - } //mouseArea + } Text { id: nameText - visible: presetNameBox.readOnly text: presetName anchors.fill: parent horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter - color: "#ffffff" + color: StudioTheme.Values.themeTextColor elide: Text.ElideMiddle maximumLineCount: 1 - } //text - + } TextInput { id: nameInput - visible: !presetNameBox.readOnly + enabled: tabBackground.editableName + visible: false text: presetName anchors.fill: parent anchors.leftMargin: 5 anchors.rightMargin: 5 horizontalAlignment: TextInput.AlignHCenter verticalAlignment: TextInput.AlignVCenter - color: "#ffffff" - selectionColor: "#029de0" + color: StudioTheme.Values.themeTextColor + selectionColor: StudioTheme.Values.themeInteraction + selectByMouse: true activeFocusOnPress: true wrapMode: TextInput.NoWrap clip: true onEditingFinished: { nameText.text = text - tabBackground.presetNameChanged(index, text); - presetNameBox.state = "Normal"; + tabBackground.presetNameChanged(index, text) + presetNameBox.edit = false } Keys.onPressed: { if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) { - event.accepted = true; - editingFinished(); - focus = false; - } //if - } //Keys.onPressed - } //textInput + event.accepted = true + nameInput.editingFinished() + nameInput.focus = false + } + + if (event.key === Qt.Key_Escape) { + event.accepted = true + nameInput.text = nameText.text + nameInput.focus = false + } + } + } states: [ State { - name: "Normal" + name: "default" + when: tabBackground.editableName && !nameMouseArea.containsMouse && !presetNameBox.edit PropertyChanges { target: nameBackgroundColor color: "transparent" border.width: 0 } - PropertyChanges { - target: presetNameBox - readOnly: true - } + PropertyChanges { target: nameText; visible: true } + PropertyChanges { target: nameInput; visible: false } }, State { - name: "Hover" + name: "hovered" + when: tabBackground.editableName && nameMouseArea.containsMouse && !presetNameBox.edit PropertyChanges { target: nameBackgroundColor - color: "#606060" + color: StudioTheme.Values.themeControlBackgroundPressed border.width: 0 } - PropertyChanges { - target: presetNameBox - readOnly: true - } + PropertyChanges { target: nameText; visible: true } + PropertyChanges { target: nameInput; visible: false } }, State { - name: "Clicked" + name: "edit" + when: tabBackground.editableName && presetNameBox.edit PropertyChanges { target: nameBackgroundColor - color: "#606060" - border.color: "#029de0" + color: StudioTheme.Values.themeControlBackgroundPressed + border.color: StudioTheme.Values.themeInteraction border.width: 1 } - PropertyChanges { - target: presetNameBox - readOnly: false - } - PropertyChanges { - target: nameInput - visible: true - } + PropertyChanges { target: nameText; visible: false } + PropertyChanges { target: nameInput; visible: true } } - ] //states - } //gradient name Item - } //columnLayout - } //rectangle background - } //component delegate - } //gridview - } //scrollView -} //rectangle + ] + } + } + } + } + } + } +} From dff4469bafd514c408d390a030b25459e3215ec0 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 18 Dec 2019 13:27:20 +0100 Subject: [PATCH 13/15] Debugger: Use a more convenient way to create timing samples Change-Id: I4ca983957c81a1f5f963a85b16a2d1b255b2cd2d Reviewed-by: Orgad Shaneh --- share/qtcreator/debugger/dumper.py | 64 ++++++++++++--------------- share/qtcreator/debugger/gdbbridge.py | 11 +++-- 2 files changed, 34 insertions(+), 41 deletions(-) diff --git a/share/qtcreator/debugger/dumper.py b/share/qtcreator/debugger/dumper.py index 04969d8e322..3ebdedbd2e9 100644 --- a/share/qtcreator/debugger/dumper.py +++ b/share/qtcreator/debugger/dumper.py @@ -173,6 +173,20 @@ def error(message): def showException(msg, exType, exValue, exTraceback): DumperBase.showException(msg, exType, exValue, exTraceback) + +class Timer: + def __init__(self, d, desc): + self.d = d + self.desc = desc + '-' + d.currentIName + + def __enter__(self): + self.starttime = time.time() + + def __exit__(self, exType, exValue, exTraceBack): + elapsed = int(1000 * (time.time() - self.starttime)) + self.d.timings.append([self.desc, elapsed]) + + class Children: def __init__(self, d, numChild = 1, childType = None, childNumChild = None, maxNumChild = None, addrBase = None, addrStep = None): @@ -261,6 +275,9 @@ class DumperBase: except: pass + def timer(self, desc): + return Timer(self, desc) + def __init__(self): self.isCdb = False self.isGdb = False @@ -372,12 +389,10 @@ class DumperBase: self.counts = {} self.structPatternCache = {} - self.pretimings = {} self.timings = [] def resetStats(self): # Timing collection - self.pretimings = {} self.timings = [] pass @@ -392,15 +407,6 @@ class DumperBase: else: self.counts[key] = 1 - def preping(self, key): - return - self.pretimings[key] = time.time() - - def ping(self, key): - return - elapsed = int(1000 * (time.time() - self.pretimings[key])) - self.timings.append([key, elapsed]) - def childRange(self): if self.currentMaxNumChild is None: return xrange(0, self.currentNumChild) @@ -1369,9 +1375,8 @@ class DumperBase: return False def putFormattedPointer(self, value): - self.preping('formattedPointer') + #with self.timer('formattedPointer'): self.putFormattedPointerX(value) - self.ping('formattedPointer') def putDerefedPointer(self, value): derefValue = value.dereference() @@ -1735,15 +1740,13 @@ class DumperBase: metaObjectPtr = 0 if not metaObjectPtr: # measured: 3 ms (example had one level of inheritance) - self.preping('metaObjectType-' + self.currentIName) + #with self.timer('metaObjectType-' + self.currentIName): metaObjectPtr = extractStaticMetaObjectPtrFromType(typeobj) - self.ping('metaObjectType-' + self.currentIName) if not metaObjectPtr: # measured: 200 ms (example had one level of inheritance) - self.preping('metaObjectCall-' + self.currentIName) + #with self.timer('metaObjectCall-' + self.currentIName): metaObjectPtr = extractMetaObjectPtrFromAddress() - self.ping('metaObjectCall-' + self.currentIName) #if metaObjectPtr: # self.bump('foundMetaObject') @@ -2392,7 +2395,7 @@ class DumperBase: def handleLocals(self, variables): #warn('VARIABLES: %s' % variables) - self.preping('locals') + #with self.timer('locals'): shadowed = {} for value in variables: if value.name == 'argv': @@ -2412,20 +2415,17 @@ class DumperBase: # A 'normal' local variable or parameter. iname = value.iname if hasattr(value, 'iname') else 'local.' + name with TopLevelItem(self, iname): - self.preping('all-' + iname) + #with self.timer('all-' + iname): self.putField('iname', iname) self.putField('name', name) self.putItem(value) - self.ping('all-' + iname) - self.ping('locals') def handleWatches(self, args): - self.preping('watches') + #with self.timer('watches'): for watcher in args.get('watchers', []): iname = watcher['iname'] exp = self.hexdecode(watcher['exp']) self.handleWatch(exp, exp, iname) - self.ping('watches') def handleWatch(self, origexp, exp, iname): exp = str(exp).strip() @@ -2734,9 +2734,8 @@ class DumperBase: self.putSubItem(i, val) def putItem(self, value): - self.preping('putItem') + #with self.timer('putItem'): self.putItemX(value) - self.ping('putItem') def putItemX(self, value): #warn('PUT ITEM: %s' % value.stringify()) @@ -2868,9 +2867,8 @@ class DumperBase: self.putEmptyValue() #warn('STRUCT GUTS: %s ADDRESS: 0x%x ' % (value.name, value.address())) if self.showQObjectNames: - self.preping(self.currentIName) + #with self.timer(self.currentIName): self.putQObjectNameValue(value) - self.ping(self.currentIName) if self.isExpanded(): self.putField('sortable', 1) with Children(self, 1, childType=None): @@ -3351,7 +3349,7 @@ class DumperBase: error('CANNOT CONVERT TO BYTES: %s' % self) def extractInteger(self, bitsize, unsigned): - self.dumper.preping('extractInt') + #with self.dumper.timer('extractInt'): self.check() if bitsize > 32: size = 8 @@ -3369,23 +3367,21 @@ class DumperBase: res = struct.unpack_from(self.dumper.packCode + code, rawBytes, 0)[0] #warn('Extract: Code: %s Bytes: %s Bitsize: %s Size: %s' # % (self.dumper.packCode + code, self.dumper.hexencode(rawBytes), bitsize, size)) - self.dumper.ping('extractInt') return res def extractSomething(self, code, bitsize): - self.dumper.preping('extractSomething') + #with self.dumper.timer('extractSomething'): self.check() size = (bitsize + 7) >> 3 rawBytes = self.data(size) res = struct.unpack_from(self.dumper.packCode + code, rawBytes, 0)[0] - self.dumper.ping('extractSomething') return res def to(self, pattern): return self.split(pattern)[0] def split(self, pattern): - self.dumper.preping('split') + #with self.dumper.timer('split'): #warn('EXTRACT STRUCT FROM: %s' % self.type) (pp, size, fields) = self.dumper.describeStruct(pattern) #warn('SIZE: %s ' % size) @@ -3405,7 +3401,6 @@ class DumperBase: return thing if len(fields) != len(result): error('STRUCT ERROR: %s %s' (fields, result)) - self.dumper.ping('split') return tuple(map(structFixer, fields, result)) def checkPointer(self, p, align = 1): @@ -3548,9 +3543,8 @@ class DumperBase: # FIXME: That buys some performance at the cost of a fail # of Gdb13393 dumper test. #return self - self.dumper.preping('dynamicType %s 0x%s' % (self.name, address)) + #with self.dumper.timer('dynamicType %s 0x%s' % (self.name, address)): dynTypeName = self.dynamicTypeName(address) - self.dumper.ping('dynamicType %s 0x%s' % (self.name, address)) if dynTypeName is not None: return self.dumper.createType(dynTypeName) return self diff --git a/share/qtcreator/debugger/gdbbridge.py b/share/qtcreator/debugger/gdbbridge.py index dcd7f694da9..6a912ea388d 100644 --- a/share/qtcreator/debugger/gdbbridge.py +++ b/share/qtcreator/debugger/gdbbridge.py @@ -243,6 +243,10 @@ class Dumper(DumperBase): nativeTargetValue = None targetType = self.fromNativeType(nativeType.target().unqualified()) val = self.createPointerValue(toInteger(nativeValue), targetType) + # The nativeValue is needed in case of multiple inheritance, see + # QTCREATORBUG-17823. Using it triggers nativeValueDereferencePointer() + # later which + # is surprisingly expensive. val.nativeValue = nativeValue #warn('CREATED PTR 1: %s' % val) if not nativeValue.address is None: @@ -447,7 +451,6 @@ class Dumper(DumperBase): return typeId def nativeStructAlignment(self, nativeType): - self.preping('align ' + str(nativeType)) #warn('NATIVE ALIGN FOR %s' % nativeType.name) def handleItem(nativeFieldType, align): a = self.fromNativeType(nativeFieldType).alignment() @@ -455,7 +458,6 @@ class Dumper(DumperBase): align = 1 for f in nativeType.fields(): align = handleItem(f.type, align) - self.ping('align ' + str(nativeType)) return align @@ -668,9 +670,7 @@ class Dumper(DumperBase): self.resetStats() self.prepare(args) - self.preping('endian') self.isBigEndian = gdb.execute('show endian', to_string = True).find('big endian') > 0 - self.ping('endian') self.packCode = '>' if self.isBigEndian else '<' (ok, res) = self.tryFetchInterpreterVariables(args) @@ -827,9 +827,7 @@ class Dumper(DumperBase): #warn('READ: %s FROM 0x%x' % (size, address)) if address == 0 or size == 0: return bytes() - self.preping('readMem') res = self.selectedInferior().read_memory(address, size) - self.ping('readMem') return res def findStaticMetaObject(self, type): @@ -1137,6 +1135,7 @@ class Dumper(DumperBase): self.reportResult('selected="0x%x",expr="(%s*)0x%x"' % (p, n, p), args) def nativeValueDereferencePointer(self, value): + # This is actually pretty expensive, up to 100ms. deref = value.nativeValue.dereference() return self.fromNativeValue(deref.cast(deref.dynamic_type)) From a163bcd8b0f2426585dc5d48a77b2451d473b76b Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 7 Jan 2020 12:05:16 +0100 Subject: [PATCH 14/15] Editor: always set format for visual whitespace Change-Id: I2ab4cb9f77d649c1c7d51dec1ef11005325a4710 Fixes: QTCREATORBUG-23040 Reviewed-by: Orgad Shaneh Reviewed-by: Eike Ziller --- src/plugins/texteditor/highlighter.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/texteditor/highlighter.cpp b/src/plugins/texteditor/highlighter.cpp index 19f0656a152..e0790875200 100644 --- a/src/plugins/texteditor/highlighter.cpp +++ b/src/plugins/texteditor/highlighter.cpp @@ -302,8 +302,10 @@ static bool isClosingParenthesis(QChar c) void Highlighter::highlightBlock(const QString &text) { - if (!definition().isValid()) + if (!definition().isValid()) { + formatSpaces(text); return; + } QTextBlock block = currentBlock(); KSyntaxHighlighting::State state; TextDocumentLayout::setBraceDepth(block, TextDocumentLayout::braceDepth(block.previous())); From cd5f070844c4224e646e30f6edcfb83a7deaa662 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 7 Jan 2020 16:17:42 +0100 Subject: [PATCH 15/15] Fix build of qmldesigner tests NodeInstanceView is build as part of the the test and cannot have depedencies on core or qmldesigner when build in test mode. Change-Id: I5f04ec7ff42fdd0704552c3e791dfabd20fc9317 Reviewed-by: Christian Stenger --- .../designercore/instances/nodeinstanceview.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp index 92806065af8..01605e16b51 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp @@ -30,7 +30,6 @@ #include #include #include -#include "qmldesignerplugin.h" #include "abstractproperty.h" #include "variantproperty.h" #include "bindingproperty.h" @@ -73,9 +72,13 @@ #include "nodeinstanceserverproxy.h" #include "puppettocreatorcommand.h" +#ifndef QMLDESIGNER_TEST +#include #include #include #include +#endif + #include #include @@ -1477,6 +1480,7 @@ void NodeInstanceView::handlePuppetKeyPress(int key, Qt::KeyboardModifiers modif // it should be utilized and the rest of the method deleted // QCoreApplication::postEvent([receiver], new QKeyEvent(QEvent::KeyPress, key, modifiers)); +#ifndef QMLDESIGNER_TEST // handle common keyboard actions coming from puppet if (Core::ActionManager::command(Core::Constants::UNDO)->keySequence().matches(key + modifiers) == QKeySequence::ExactMatch) QmlDesignerPlugin::instance()->currentDesignDocument()->undo(); @@ -1490,6 +1494,10 @@ void NodeInstanceView::handlePuppetKeyPress(int key, Qt::KeyboardModifiers modif Core::DocumentManager::saveAllModifiedDocuments(); else if (Core::ActionManager::command(QmlDesigner::Constants::C_DELETE)->keySequence().matches(key + modifiers) == QKeySequence::ExactMatch) QmlDesignerPlugin::instance()->currentDesignDocument()->deleteSelected(); +#else + Q_UNUSED(key); + Q_UNUSED(modifiers); +#endif } void NodeInstanceView::view3DClosed(const View3DClosedCommand &command)