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)) 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..ff2ec935769 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** 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 +#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/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/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 + ] + } + } + } + } + } + } +} 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/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" 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/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); diff --git a/src/plugins/qmldesigner/CMakeLists.txt b/src/plugins/qmldesigner/CMakeLists.txt index 0a758c135f1..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 @@ -320,6 +321,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..a6002c86c86 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 +QT += qml quick gui-private 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..ec4085ef832 --- /dev/null +++ b/src/plugins/qmldesigner/components/propertyeditor/tooltip.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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 + +Tooltip::Tooltip(QObject *parent) + : QObject(parent) +{} + +void Tooltip::showText(QQuickItem *item, const QPointF &pos, const QString &str) +{ + if (!item || !item->window()) + return; + + if (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..785a1b51d42 --- /dev/null +++ b/src/plugins/qmldesigner/components/propertyeditor/tooltip.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** 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 + +QT_BEGIN_NAMESPACE +class QPointF; +class QQuickItem; +QT_END_NAMESPACE + +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/designercore/include/nodeinstanceview.h b/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h index 14dd36fc2b0..875d7b58c83 100644 --- a/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h +++ b/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h @@ -138,6 +138,8 @@ public: void mainWindowActiveChanged(bool active, bool hasPopup); void enable3DView(bool enable); + void handlePuppetToCreatorCommand(const PuppetToCreatorCommand &command) override; + protected: void timerEvent(QTimerEvent *event) override; @@ -189,12 +191,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 31272b54978..706d62b2cfc 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 @@ -285,6 +286,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) @@ -313,6 +315,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 ca2d601dac5..9e7a7dadfa6 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 "abstractproperty.h" #include "variantproperty.h" #include "bindingproperty.h" @@ -42,7 +41,7 @@ #include "qmltimeline.h" #include "qmltimelinekeyframegroup.h" #include "qmlvisualnode.h" - +#include "qmldesignerconstants.h" #include "createscenecommand.h" #include "createinstancescommand.h" #include "clearscenecommand.h" @@ -71,6 +70,14 @@ #include "removesharedmemorycommand.h" #include "debugoutputcommand.h" #include "nodeinstanceserverproxy.h" +#include "puppettocreatorcommand.h" + +#ifndef QMLDESIGNER_TEST +#include +#include +#include +#include +#endif #include #include @@ -1446,6 +1453,45 @@ 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)); + +#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(); + 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(); +#else + Q_UNUSED(key); + Q_UNUSED(modifiers); +#endif +} + void NodeInstanceView::view3DClosed(const View3DClosedCommand &command) { Q_UNUSED(command) diff --git a/src/plugins/qmldesigner/qmldesignerplugin.qbs b/src/plugins/qmldesigner/qmldesignerplugin.qbs index 67783c7c157..6b11bf52bfa 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" } @@ -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", @@ -618,6 +620,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", diff --git a/src/plugins/texteditor/highlighter.cpp b/src/plugins/texteditor/highlighter.cpp index 29bc705be94..29b5a8eab55 100644 --- a/src/plugins/texteditor/highlighter.cpp +++ b/src/plugins/texteditor/highlighter.cpp @@ -301,8 +301,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())); 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 + + diff --git a/src/tools/qml2puppet/CMakeLists.txt b/src/tools/qml2puppet/CMakeLists.txt index c48557a8064..a5e2acc2ee5 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",