Merge remote-tracking branch 'origin/4.10'

Change-Id: If85094fcd5bc2a85de9dbbaf065636f4b568401e
This commit is contained in:
Eike Ziller
2019-06-12 07:29:02 +02:00
102 changed files with 1243 additions and 1055 deletions

217
dist/changes-4.10.0.md vendored Normal file
View File

@@ -0,0 +1,217 @@
# Qt Creator 4.10
Qt Creator version 4.10 contains bug fixes and new features.
The most important changes are listed in this document. For a complete
list of changes, see the Git log for the Qt Creator sources that
you can check out from the public Git repository. For example:
git clone git://code.qt.io/qt-creator/qt-creator.git
git log --cherry-pick --pretty=oneline origin/4.9..v4.10.0
## Editing
* Removed support for KDE code paster after removal of official API
* Added option for pinning files so they stay open when closing all files (QTCREATORBUG-21899)
### Language Client
* Added option for starting server when needed
* Added option for starting one server per project
* Added support for `workspace/workspaceFolders` server request
* Added Locator filter for current document (`.`)
* Added Locator filters for symbols in workspace (`:`, `c`, and `m`) (QTCREATORBUG-21915)
* Added hover information
* Made client settings expand variables for executable and arguments
* Improved completion item tooltip (QTCREATORBUG-22429)
## Help
* Added option for scroll wheel zooming (QTCREATORBUG-14154)
## All Projects
* Added option for hiding kit settings (QTCREATORBUG-9134)
* Added support for drag & drop in Projects tree (QTCREATORBUG-6446)
* Added option for closing files of project when closing project (QTCREATORBUG-22198)
* Added filtering to `Application Output`, `Compile Output`, and `General Messages`
(QTCREATORBUG-16356)
* Added `Re-detect` and `Remove All` to compiler settings
* Added Locator filter for all files in all project directory trees (`a`) (QTCREATORBUG-19122)
* Added `CurrentRun:WorkingDir` Qt Creator variable
* Added `Tools` > `Parse Build Output` (QTCREATORBUG-16017)
* Added option for not clearing `Issues` pane on build (QTCREATORBUG-22478)
* Moved `Application Output` and `Build Output` options to separate tabs in the
`Build & Run` options
* Improved search for files from `Issues` pane (QTCREATORBUG-13623)
### Wizards
* Added build system choice to `Qt Widgets Application` and `C++ Library` wizards
* Added `value('variablename')` to JavaScript context in JSON wizards, adding support for
lists and dictionaries as values
* Fixed that file names were always lower-cased by file wizards (QTCREATORBUG-14711)
## QMake Projects
* Added option for adding existing project as sub-project (QTCREATORBUG-5837)
* Added option for running `qmake` on every build (QTCREATORBUG-20888)
* Added completion of paths in project files (QTCREATORBUG-5915)
* Added forced `qmake` run on rebuild
* Fixed building sub-project in case of additional custom make steps (QTCREATORBUG-15794)
## CMake Projects
* Removed `Default` from build types (QTCREATORBUG-22013)
* Added support for Android targets
* Added support for building single file (QTCREATORBUG-18898)
* Added completion of paths in project files (QTCREATORBUG-5915)
* Improved text in `Configuration has changed on disk` dialog (QTCREATORBUG-22059)
## Qbs Projects
* Added support for Android targets
* Fixed `Build product` for files in groups
## Python Projects
* Added support for adding and removing files from project
* Improved wizards
## Compilation Database Projects
* Added setting for project header path (QTCREATORBUG-22031)
* Added custom build steps and run configuration (QTCREATORBUG-21727)
* Added option for specifying additional files in `compile_database.json.files`
* Fixed handling of relative paths (QTCREATORBUG-22338)
* Fixed handling of `--sysroot` (QTCREATORBUG-22339)
## Qt Support
* Added handling of QtTest messages in compile output (QTCREATORBUG-8091)
## C++ Support
* Improved auto-insertion of closing curly brace (QTCREATORBUG-18872)
* Fixed that snippet completion could get in the way (QTCREATORBUG-21767)
### Clang Format
* Improved configuration UI
* Fixed that clang format was triggered on save when Beautifier already was as well
## QML Support
## Debugging
* Added pretty printer for `QMargin`
### CDB
* Fixed loading of custom debugging helpers (QTCREATORBUG-20481)
## Perf Profiler
* Changed format of saved traces
* Added support for multiple attributes per sample
* Added CPU ID for events
## Qt Quick Designer
* Added support for `ShapeGradient` (QDS-359)
* Added gradient picker that allows loading and saving of presets
* Updated properties of `Flickable`
## Version Control Systems
* Added zoom buttons to `Version Control` output pane
### Git
* Added support for different reset types in `Branches` view
* Added choice of build system to `Git Clone` wizard if cloned project supports multiple
build systems (QTCREATORBUG-17828)
## Test Integration
* Added basic support for Boost tests
* Added wizard for Boost tests (QTCREATORBUG-21169)
* Added option for automatically opening test results pane
* Improved handling of unexpected test output (QTCREATORBUG-22354)
## Platform Specific
### Windows
* Added `Clone` for MSVC toolchains (QTCREATORBUG-22163)
* Fixed that `mingw32-make`'s warnings were categorized as errors (QTCREATORBUG-22171)
* Fixed bitness detection for MinGW (QTCREATORBUG-22160)
### Linux
* Improved auto-detection of toolchains (QTCREATORBUG-19179, QTCREATORBUG-20044, QTCREATORBUG-22081)
### macOS
### Android
* Removed support for MIPS64
### Remote Linux
* Added deployment method that deploys everything that is installed by the build system
in its install step (QTCREATORBUG-21855)
* Added support for opening remote terminal with run environment
* Added option for `rsync` flags for deployment (QTCREATORBUG-22352)
### Boot to Qt
### Bare Metal
* Added include path detection and output parsers for `IAR`, `KEIL` and `SDCC` toolchains
## Credits for these changes go to:
Aleksei German
Alessandro Ambrosano
Alessandro Portale
Andre Hartmann
André Pönitz
Anton Danielsson
Antonio Di Monaco
Asit Dhal
BogDan Vatra
Christian Gagneraud
Christian Kandeler
Christian Stenger
Cristian Adam
Cristián Maureira-Fredes
Daniel Teske
David Schulz
Denis Shienkov
Denis Vygovskiy
Eike Ziller
Friedemann Kleint
Haxor Leet
illiteratecoder
Ivan Donchevskii
Ivan Komissarov
Joel Smith
Jörg Bornemann
Kavindra Palaraja
Luca Carlon
Marco Bubke
Martin Haase
Mitch Curtis
Nikolai Kosjar
Oliver Wolff
Orgad Shaneh
Przemyslaw Gorszkowski
Robert Löhning
Thomas Hartmann
Thomas Otto
Tim Henning
Tim Jenssen
Tobias Hunger
Tor Arne Vestbø
Ulf Hermann
Ville Nummela

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

@@ -159,6 +159,10 @@
\li To see the absolute path of a file, move the mouse pointer over the
file name.
\li To move files from one project to another, drag-and-drop them
in the project tree. \QC makes the necessary changes to project
configuration files.
\endlist
\if defined(qtcreator)
@@ -188,7 +192,10 @@
\li Expand or collapse the tree view to show or hide all files and
folders.
\li Close all files in a project.
\li Close projects.
\li Close projects. By default, all files in the project are also
closed. To keep them open, deselect the \uicontrol Tools >
\uicontrol Options > \uicontrol {Build & Run} > \uicontrol General
> \uicontrol {Close source files along with project} check box.
\endlist
For managing files and directories, the same functions are available as in

View File

@@ -487,6 +487,38 @@
You can also reach the options page by clicking the \uicontrol {Open Settings Page}
button.
To copy the output from the pane to the clipboard, select
\uicontrol {Select All} in the context menu, and then select
\uicontrol Copy. Save the output as a file if you want to
examine it later without having to build the project again.
This is useful for large projects that take a long time to build.
\section2 Parsing Existing Compile Output
You can use \QC's output parsers to parse output from builds done outside
of \QC or stored from previous build runs. By default, the parsers from the
kit selected for the active project are used, but you can select another
kit.
To parse compile output:
\list 1
\li Select \uicontrol Tools > \uicontrol {Parse Build Output}.
\image qtcreator-parse-build-output.png
\li Paste the build output in the \uicontrol {Build Output} field, or
select \uicontrol {Load from File} to load it from a file.
\li Deselect the \uicontrol {Output went to stderr} check box if the
parser expects issues on \c stdout.
\li In the \uicontrol {Use parsers from kit} field, select the kit to
use for parsing the output. Select \uicontrol Manage to view
and modify kit settings.
\li The parser displays the parsed output in the \uicontrol Issues
pane. By default, the pane is cleared before adding the new output.
Deselect the \uicontrol {Clear existing tasks} check box to append
the new output to the old output.
\li Select \uicontrol OK to start parsing.
\endlist
\if defined(qtcreator)
\section1 To-Do Entries

View File

@@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2018 The Qt Company Ltd.
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Creator documentation.
@@ -44,7 +44,12 @@
for and running it on a particular platform.
\QC automatically detects the compilers that are registered by your system
or by an installer. You can add compilers to build applications by using other
or by an installer and lists them in \uicontrol Tools > \uicontrol Options >
\uicontrol Kits > \uicontrol Compilers:
\image qtcreator-toolchains.png
You can add the following compilers to build applications by using other
compilers or by using additional versions of the automatically detected
compilers:
@@ -94,6 +99,20 @@
\endlist
\section1 Redetecting Compilers
When \QC finds an x86_64 GCC compiler, it sets up an instance for the native
x86_64 target. If you plan to create also 32-bit x86 binaries without using
a dedicated cross-compiler, select \uicontrol {Auto-detection Settings} >
\uicontrol {Detect x86_64 GCC compilers as x86_64 and x86}. Then select
\uicontrol Re-detect to refresh the list of automatically detected
compilers.
To remove manually added compilers, select \uicontrol Remove or
\uicontrol {Remove All}.
\section1 Specifying Compiler Settings
To build an application using GCC, MinGW, Clang, or QCC, specify the path
to the directory where the compiler is located and select
the application binary interface (ABI) version from the list of available
@@ -118,8 +137,6 @@
then select a compiler in the list, and then select \uicontrol C or
\uicontrol C++ to add a C or C++ compiler.
\image qtcreator-toolchains.png
To clone the selected compiler, select \uicontrol Clone.
\li In the \uicontrol Name field, enter a name for the compiler to

View File

@@ -73,6 +73,21 @@
\endlist
\section1 Filtering Kit Settings
Typically, only a subset of the kit settings is relevant for a particular
setup. Therefore, \QC plugins register sets of relevant settings that you
can view and modify in \uicontrol Tools > \uicontrol Options >
\uicontrol Kits >. For example, if you use CMake to build all your projects,
you can hide Qbs and qmake settings by default.
To hide and show settings in the \uicontrol Kits tab for the
current kit, select \uicontrol {Settings Filter}. To view and
modify the settings displayed when you add a new kit, select
\uicontrol {Default Settings Filter}.
\section1 Specifying Kit Settings
To add kits:
\list 1
@@ -105,13 +120,13 @@
\li In the \uicontrol Device field, select a device.
\li In the \uicontrol {Emulator skin} field, select the skin to use for
the \l {Emulator}{Boot2Qt Emulator Device}.
\li In the \uicontrol Sysroot field, specify the directory where the device
image is located. If you are not cross-compiling, leave this field
empty.
\li In the \uicontrol {Emulator skin} field, select the skin to use for
the \l {Emulator}{Boot2Qt Emulator Device}.
\li In the \uicontrol {Compiler} field, select the C or C++ compiler
that you use to build the project. You can add compilers to the list
if they are installed on the development PC, but were not detected
@@ -153,6 +168,10 @@
configuration that should be used by qmake. If you leave this field
empty, the default mkspec of the selected Qt version is used.
\li In the \uicontrol {Additional Qbs profile settings} field, select
\uicontrol Change to add settings to Qbs build profiles. For more
information, see \l {Editing Qbs Profiles}.
\li In the \uicontrol {CMake Tool} field, select the CMake tool to use
for building the project. Select \uicontrol Manage to add installed
CMake tools to the list. For more information, see
@@ -169,10 +188,6 @@
\uicontrol Change to edit the variables of the CMake configuration
for the kit.
\li In the \uicontrol {Additional Qbs profile settings} field, select
\uicontrol Change to add settings to Qbs build profiles. For more
information, see \l {Editing Qbs Profiles}.
\endlist
\QC uses the \e {default kit} if it does not have enough information to
@@ -194,16 +209,18 @@
\list 1
\li Select \uicontrol Change next to the
\uicontrol {Additional Qbs Profile Settings} field.
\uicontrol {Additional Qbs Profile Settings} field to open the
\uicontrol {Custom Properties} dialog.
\image qtcreator-qbs-profile-settings.
\li Select \uicontrol Add.
\li Double-click an empty cell in the \uicontrol Key column to specify
the key to add or modify as: \c <module_name>.<property_name>.
\li In the \uicontrol Key column, spefify the key to add or modify as:
\c <module_name>.<property_name>.
\li Double-click the cell on the same row in the \uicontrol Value column
to specify a value as a JSON literal.
\li In the \uicontrol Value column, specify a value as a JSON literal.
\li Select \uicontrol Add to add the key-value pair.
\li Click \uicontrol OK.

View File

@@ -49,13 +49,14 @@ Section {
SecondColumnLayout {
SpinBox {
sliderIndicatorVisible: true
backendValue: backendValues.scale
hasSlider: true
decimals: 2
minimumValue: 0.01
stepSize: 0.1
maximumValue: 10
Layout.preferredWidth: 100
Layout.preferredWidth: 140
}
ExpandingSpacer {
}
@@ -65,12 +66,13 @@ Section {
}
SecondColumnLayout {
SpinBox {
sliderIndicatorVisible: true
backendValue: backendValues.rotation
hasSlider: true
decimals: 2
minimumValue: -360
maximumValue: 360
Layout.preferredWidth: 100
Layout.preferredWidth: 140
}
ExpandingSpacer {
}
@@ -80,11 +82,12 @@ Section {
}
SecondColumnLayout {
SpinBox {
sliderIndicatorVisible: true
backendValue: backendValues.z
hasSlider: true
minimumValue: -100
maximumValue: 100
Layout.preferredWidth: 100
Layout.preferredWidth: 140
}
ExpandingSpacer {
}

View File

@@ -33,6 +33,10 @@ Rectangle {
width: 320
height: 400
color: Theme.qmlDesignerBackgroundColorDarkAlternate()
MouseArea {
anchors.fill: parent
onClicked: forceActiveFocus()
}
ScrollView {
anchors.fill: parent
@@ -117,6 +121,7 @@ Rectangle {
placeholderText: qsTr("id")
text: backendValues.id.value
Layout.fillWidth: true
width: 240
showTranslateCheckBox: false
showExtendedFunctionButton: false
enabled: !modelNodeBackend.multiSelection
@@ -183,6 +188,7 @@ Rectangle {
SecondColumnLayout {
SpinBox {
sliderIndicatorVisible: true
backendValue: backendValues.opacity
decimals: 2

View File

@@ -26,14 +26,16 @@
import QtQuick 2.0
import HelperWidgets 2.0
import QtQuick.Layouts 1.0
import QtQuick.Controls 1.0 as Controls
import StudioControls 1.0 as StudioControls
import QtQuickDesignerTheme 1.0
Controls.ComboBox {
StudioControls.ComboBox {
property string targetName: anchorBackend.topTarget
property color textColor: Theme.color(Theme.PanelTextColorLight)
actionIndicatorVisible: false
id: targetComboBox
Connections {
@@ -50,8 +52,4 @@ Controls.ComboBox {
}
model: anchorBackend.possibleTargetItems
style: CustomComboBoxStyle {
textColor: targetComboBox.textColor
}
}

View File

@@ -47,8 +47,8 @@ Controls.CheckBox {
id: colorLogic
backendValue: checkBox.backendValue
onValueFromBackendChanged: {
if (checkBox.checked !== valueFromBackend)
checkBox.checked = valueFromBackend;
if (checkBox.checked !== colorLogic.valueFromBackend)
checkBox.checked = colorLogic.valueFromBackend;
}
}

View File

@@ -281,7 +281,7 @@ Item {
maximumValue: 255
decimals: 0
onValueChanged: {
onCompressedValueModified: {
if (color.r !== value && !colorButton.block) {
color.r = (value / 255.0)
colorButton.clicked()
@@ -293,7 +293,7 @@ Item {
Row {
z: 2
spacing: 1
Controls.Label {
Label {
text: "G"
width: 16
color: "#eee"
@@ -310,7 +310,7 @@ Item {
maximumValue: 255
decimals: 0
onValueChanged: {
onCompressedValueModified: {
if (color.g !== value && !colorButton.block) {
color.g = (value / 255.0)
colorButton.clicked()
@@ -322,7 +322,7 @@ Item {
Row {
z: 1
spacing: 1
Controls.Label {
Label {
text: "B"
width: 16
color: "#eee"
@@ -338,7 +338,7 @@ Item {
maximumValue: 255
decimals: 0
onValueChanged: {
onCompressedValueModified: {
if (color.b !== value && !colorButton.block) {
color.b = (value / 255.0)
colorButton.clicked()
@@ -350,7 +350,7 @@ Item {
Row {
z: 0
spacing: 1
Controls.Label {
Label {
text: "A"
width: 16
color: "#eee"
@@ -361,7 +361,7 @@ Item {
DoubleSpinBox {
id: alphaSlider
width: 64
onValueChanged: {
onCompressedValueModified: {
if (colorButton.alpha !== value && !colorButton.block) {
colorButton.alpha = value
colorButton.clicked()
@@ -387,7 +387,7 @@ Item {
DoubleSpinBox {
id: hueSlider2
width: 64
onValueChanged: {
onCompressedValueModified: {
if (colorButton.hue !== value && !colorButton.block) {
colorButton.hue = value
colorButton.clicked()
@@ -399,7 +399,7 @@ Item {
Row {
z: 2
spacing: 1
Controls.Label {
Label {
text: "S"
width: 16
color: "#eee"
@@ -410,7 +410,7 @@ Item {
DoubleSpinBox {
id: saturationSlider
width: 64
onValueChanged: {
onCompressedValueModified: {
if (colorButton.saturation !== value && !colorButton.block) {
colorButton.saturation = value
colorButton.clicked()
@@ -422,7 +422,7 @@ Item {
Row {
z: 1
spacing: 1
Controls.Label {
Label {
text: "L"
width: 16
color: "#eee"
@@ -432,7 +432,7 @@ Item {
DoubleSpinBox {
id: lightnessSlider
width: 64
onValueChanged: {
onCompressedValueModified: {
if (colorButton.lightness !== value && !colorButton.block) {
colorButton.lightness = value
colorButton.clicked()

View File

@@ -588,18 +588,8 @@ Column {
}
}
//empty spacer 2
Item {
height: 6
}
Item {
height: 6
}
//spacer 3
Item {
height: 6
height: 8
}
ColorButton {
@@ -622,13 +612,17 @@ Column {
onClicked: colorEditor.color = colorButton.color
}
//empty spacer 4
Item { height: 2 }
Item { height: 2 }
//spacer 5
Item {
height: 4
height: 1
}
Item {
height: 2
visible: checkButton.checked
}
Item {
height: 1
}
Item {
@@ -645,7 +639,8 @@ Column {
spacing: 2
Column {
spacing: 5
Text {
Label {
width: parent.width
text: qsTr("Original")
color: "#eee"
}
@@ -670,7 +665,8 @@ Column {
Column {
spacing: 5
Text {
Label {
width: parent.width
text: qsTr("New")
color: "#eee"
}
@@ -688,7 +684,8 @@ Column {
Column {
spacing: 5
Text {
Label {
width: parent.width
text: qsTr("Recent")
color: "#eee"
elide: Text.ElideRight
@@ -705,8 +702,6 @@ Column {
}
}
ExpandingSpacer {
}
}
}
}

View File

@@ -45,6 +45,8 @@ Controls.ComboBox {
property bool block: false
property bool showExtendedFunctionButton: true
ExtendedFunctionLogic {
id: extFuncLogic
backendValue: comboBox.backendValue
@@ -54,6 +56,8 @@ Controls.ComboBox {
actionIndicator.icon.text: extFuncLogic.glyph
actionIndicator.onClicked: extFuncLogic.show()
actionIndicator.visible: showExtendedFunctionButton
ColorLogic {
id: colorLogic
backendValue: comboBox.backendValue

View File

@@ -24,20 +24,70 @@
****************************************************************************/
import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuickDesignerTheme 1.0
import StudioControls 1.0 as StudioControls
SpinBox {
Item {
id: wrapper
property alias decimals: spinBox.decimals
property alias hasSlider: spinBox.hasSlider
property real minimumValue: 0.0
property real maximumValue: 1.0
property real stepSize: 0.1
property alias sliderIndicatorVisible: spinBox.sliderIndicatorVisible
property real value
onValueChanged: spinBox.value = wrapper.value * spinBox.factor
signal compressedValueModified
signal valueModified
width: 90
implicitHeight: spinBox.height
onStepSizeChanged: spinBox.convert("stepSize", wrapper.stepSize)
onMinimumValueChanged: spinBox.convert("from", wrapper.minimumValue)
onMaximumValueChanged: spinBox.convert("to", wrapper.maximumValue)
StudioControls.SpinBox {
id: spinBox
width: 76
onValueModified: wrapper.valueModified()
onCompressedValueModified: wrapper.compressedValueModified()
onValueChanged: {
if (spinBox.__initialized)
wrapper.value = spinBox.value / spinBox.factor
}
width: wrapper.width
decimals: 2
stepSize: 0.1
minimumValue: 0
maximumValue: 1
property color textColor: Theme.color(Theme.PanelTextColorLight)
actionIndicatorVisible: false
style: CustomSpinBoxStyle {
property bool __initialized: false
property bool hasSlider: spinBox.sliderIndicatorVisible
Component.onCompleted: {
spinBox.__initialized = true
spinBox.convert("stepSize", wrapper.stepSize)
spinBox.convert("from", wrapper.minimumValue)
spinBox.convert("to", wrapper.maximumValue)
spinBox.value = wrapper.value * spinBox.factor
}
function convert(target, value) {
if (!spinBox.__initialized)
return
spinBox[target] = Math.round(value * spinBox.factor)
}
}
}

View File

@@ -26,14 +26,16 @@
import QtQuick 2.1
import HelperWidgets 2.0
import QtQuick.Layouts 1.0
import QtQuick.Controls 1.0 as Controls
import StudioControls 1.0 as StudioControls
Controls.ComboBox {
StudioControls.ComboBox {
id: comboBox
property variant backendValue
property color textColor: colorLogic.textColor
labelColor: colorLogic.textColor
onTextColorChanged: setColor()
editable: true
@@ -43,10 +45,19 @@ Controls.ComboBox {
editText = comboBox.backendValue.valueToString
}
style: CustomComboBoxStyle {
textColor: comboBox.textColor
ExtendedFunctionLogic {
id: extFuncLogic
backendValue: comboBox.backendValue
}
actionIndicator.icon.color: extFuncLogic.color
actionIndicator.icon.text: extFuncLogic.glyph
actionIndicator.onClicked: extFuncLogic.show()
property bool showExtendedFunctionButton: true
actionIndicator.visible: showExtendedFunctionButton
ColorLogic {
id: colorLogic
backendValue: comboBox.backendValue
@@ -82,13 +93,6 @@ Controls.ComboBox {
backendValue.value = indexText;
}
ExtendedFunctionButton {
x: 2
anchors.verticalCenter: parent.verticalCenter
backendValue: comboBox.backendValue
visible: comboBox.enabled
}
Connections {
target: modelNodeBackend
onSelectionChanged: {

View File

@@ -26,7 +26,7 @@
import QtQuick 2.1
import HelperWidgets 2.0
import QtQuick.Layouts 1.0
import QtQuick.Controls 1.0 as Controls
import StudioControls 1.0 as StudioControls
import QtQuickDesignerTheme 1.0
Section {
@@ -63,6 +63,7 @@ Section {
FontComboBox {
backendValue: fontSection.fontFamily
Layout.fillWidth: true
width: 160
}
Label {
@@ -111,11 +112,13 @@ Section {
}
}
Controls.ComboBox {
StudioControls.ComboBox {
id: sizeType
model: ["pixels", "points"]
property color textColor: Theme.color(Theme.PanelTextColorLight)
onCurrentIndexChanged: {
actionIndicatorVisible: false
onActivated: {
if (sizeWidget.isSetup)
return;
if (currentText == "pixels") {
@@ -128,10 +131,6 @@ Section {
}
Layout.fillWidth: true
style: CustomComboBoxStyle {
}
}
}

View File

@@ -25,20 +25,20 @@
import QtQuick 2.1
import QtQuick.Layouts 1.0
import QtQuick.Controls 1.0 as Controls
import QtQuickDesignerTheme 1.0
import QtQuick.Controls.Styles 1.1
import StudioControls 1.0 as StudioControls
DoubleSpinBox {
StudioControls.SpinBox {
id: spinBox
width: 82
Layout.minimumWidth: 82
property string propertyName
actionIndicatorVisible: false
minimumValue: -9999
maximumValue: 9999
from: -9999
to: 9999
Component.onCompleted: spinBox.value = gradientLine.model.readGradientProperty(propertyName)
onValueChanged: gradientLine.model.setGradientProperty(propertyName, spinBox.value)
onCompressedValueModified: gradientLine.model.setGradientProperty(propertyName, spinBox.value)
stepSize: 1
}

View File

@@ -45,6 +45,8 @@ Controls.TextField {
property bool showExtendedFunctionButton: true
actionIndicator.visible: showExtendedFunctionButton
signal commitData
property string context

View File

@@ -25,6 +25,7 @@
import QtQuick 2.1
import QtQuick.Controls 2.5
import StudioControls 1.0 as StudioControls
import HelperWidgets 2.0
import QtQuick.Controls.Private 1.0 // showing a ToolTip
@@ -79,11 +80,9 @@ Item {
contextMenu.popup()
}
}
Menu {
StudioControls.Menu {
id: contextMenu
modal: true
closePolicy: Popup.CloseOnPressOutside | Popup.CloseOnEscape
MenuItem {
StudioControls.MenuItem {
text: (backgroundColor.favorite
? qsTr("Remove from Favorites")
: qsTr("Add to Favorites"))
@@ -91,10 +90,6 @@ Item {
paletteModel.toggleFavorite(index)
}
}
Overlay.modal: Rectangle {
color: "transparent"
}
}
}
}

View File

@@ -38,6 +38,7 @@ Item {
property real stepSize: 1.0
property alias backendValue: spinBox.backendValue
property alias sliderIndicatorVisible: spinBox.sliderIndicatorVisible
width: 120
implicitHeight: spinBox.height
@@ -67,7 +68,7 @@ Item {
property real realValue: value / factor
property variant backendValue
property bool hasSlider: false
property bool hasSlider: wrapper.sliderIndicatorVisible
from: minimumValue * factor
to: maximumValue * factor
@@ -90,7 +91,7 @@ Item {
}
}
textColor: colorLogic.textColor
labelColor: colorLogic.textColor
onCompressedValueModified: {
if (backendValue.value !== realValue)

View File

@@ -34,6 +34,8 @@ MouseArea {
onExited: Tooltip.hideText()
onCanceled: Tooltip.hideText()
onClicked: forceActiveFocus()
hoverEnabled: true
property string tooltip

View File

@@ -25,7 +25,7 @@
import QtQuick 2.1
import HelperWidgets 2.0
import QtQuick.Controls 1.1 as Controls
import StudioControls 1.0 as StudioControls
import QtQuick.Layouts 1.0
import QtQuick.Controls.Styles 1.1
@@ -49,14 +49,16 @@ RowLayout {
backendValue: urlChooser.backendValue
}
Controls.ComboBox {
StudioControls.ComboBox {
id: comboBox
ExtendedFunctionButton {
x: 2
anchors.verticalCenter: parent.verticalCenter
backendValue: urlChooser.backendValue
visible: urlChooser.enabled
actionIndicator.icon.color: extFuncLogic.color
actionIndicator.icon.text: extFuncLogic.glyph
actionIndicator.onClicked: extFuncLogic.show()
ExtendedFunctionLogic {
id: extFuncLogic
backendValue: comboBox.backendValue
}
property bool isComplete: false
@@ -86,9 +88,6 @@ RowLayout {
Layout.fillWidth: true
editable: true
style: CustomComboBoxStyle {
textColor: urlChooser.textColor
}
model: fileModel.fileModel

View File

@@ -17,6 +17,7 @@ CustomComboBoxStyle 2.0 CustomComboBoxStyle.qml
CustomSpinBoxStyle 2.0 CustomSpinBoxStyle.qml
ExpandingSpacer 2.0 ExpandingSpacer.qml
ExtendedFunctionButton 2.0 ExtendedFunctionButton.qml
ExtendedFunctionLogic 2.0 ExtendedFunctionLogic.qml
FlickableSection 2.0 FlickableSection.qml
FontComboBox 2.0 FontComboBox.qml
FontSection 2.0 FontSection.qml

View File

@@ -40,7 +40,7 @@ T.AbstractButton {
height: StudioTheme.Values.height
width: StudioTheme.Values.height
z: myButton.checked ? 10 : 3
activeFocusOnTab: false // TODO Decision pending. Focus for AbstractButtons?
activeFocusOnTab: false
background: Rectangle {
id: buttonBackground

View File

@@ -70,7 +70,7 @@ Rectangle {
name: "default"
when: myControl.enabled && !actionIndicator.hover
&& !actionIndicator.pressed && !myControl.hover
&& !myControl.activeFocus && !myControl.drag
&& !myControl.edit && !myControl.drag
PropertyChanges {
target: actionIndicator
color: StudioTheme.Values.themeControlBackground
@@ -80,7 +80,7 @@ Rectangle {
State {
name: "hovered"
when: actionIndicator.hover && !actionIndicator.pressed
&& !myControl.activeFocus && !myControl.drag
&& !myControl.edit && !myControl.drag
PropertyChanges {
target: actionIndicatorIcon
scale: 1.2
@@ -89,7 +89,7 @@ Rectangle {
State {
name: "globalHover"
when: myControl.hover && !actionIndicator.hover
&& !actionIndicator.pressed && !myControl.activeFocus
&& !actionIndicator.pressed && !myControl.edit
&& !myControl.drag
PropertyChanges {
target: actionIndicator
@@ -99,7 +99,7 @@ Rectangle {
},
State {
name: "edit"
when: myControl.activeFocus
when: myControl.edit
PropertyChanges {
target: actionIndicator
color: StudioTheme.Values.themeFocusEdit

View File

@@ -32,7 +32,8 @@ T.CheckBox {
property alias actionIndicator: actionIndicator
property bool hover: myCheckBox.hovered // TODO two underscores
property bool hover: myCheckBox.hovered
property bool edit: false
property alias actionIndicatorVisible: actionIndicator.visible
property real __actionIndicatorWidth: StudioTheme.Values.squareComponentWidth
@@ -43,21 +44,23 @@ T.CheckBox {
font.pixelSize: StudioTheme.Values.myFontSize
height: StudioTheme.Values.height
width: StudioTheme.Values.height * 5
implicitWidth: Math.max(
implicitBackgroundWidth + leftInset + rightInset,
implicitContentWidth + leftPadding + rightPadding
+ implicitIndicatorWidth + spacing + actionIndicator.width)
implicitHeight: Math.max(
implicitBackgroundHeight + topInset + bottomInset,
implicitContentHeight + topPadding + bottomPadding,
implicitIndicatorHeight + topPadding + bottomPadding)
spacing: StudioTheme.Values.checkBoxSpacing
hoverEnabled: true
activeFocusOnTab: false // TODO Decision pending. Focus for CheckBoxes?
activeFocusOnTab: false
contentItem: T.Label {
id: checkBoxLabel
leftPadding: 0
rightPadding: 0
width: 20 // TODO Not working
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
text: myCheckBox.text
font: myCheckBox.font
@@ -68,9 +71,7 @@ T.CheckBox {
id: actionIndicator
myControl: myCheckBox // TODO global hover issue. Can be solved with extra property in ActionIndicator
x: checkBoxLabel.visible ? checkBoxLabel.contentWidth
+ (myCheckBox.spacing
* StudioTheme.Values.scaleFactor) : 0 // TODO scale factor
x: checkBoxLabel.visible ? checkBoxLabel.contentWidth + myCheckBox.spacing : 0
y: 0
width: actionIndicator.visible ? __actionIndicatorWidth : 0
height: actionIndicator.visible ? __actionIndicatorHeight : 0
@@ -125,6 +126,7 @@ T.CheckBox {
State {
name: "hovered"
when: myCheckBox.hovered && !myCheckBox.pressed
&& !actionIndicator.hover
PropertyChanges {
target: checkBoxBackground
color: StudioTheme.Values.themeHoverHighlight

View File

@@ -73,7 +73,7 @@ Rectangle {
name: "default"
when: myControl.enabled && !(checkIndicator.hover
|| myControl.hover)
&& !checkIndicator.checked && !myControl.activeFocus
&& !checkIndicator.checked && !myControl.edit
&& !myControl.drag
PropertyChanges {
target: checkIndicator
@@ -84,7 +84,7 @@ Rectangle {
State {
name: "hovered"
when: (checkIndicator.hover || myControl.hover)
&& !checkIndicator.checked && !myControl.activeFocus
&& !checkIndicator.checked && !myControl.edit
&& !myControl.drag
PropertyChanges {
target: checkIndicator
@@ -103,7 +103,7 @@ Rectangle {
},
State {
name: "edit"
when: myControl.activeFocus && !checkIndicator.checked
when: myControl.edit && !checkIndicator.checked
&& !(checkIndicator.hover && myControl.hover)
PropertyChanges {
target: checkIndicator

View File

@@ -32,10 +32,10 @@ T.ComboBox {
id: myComboBox
property alias actionIndicator: actionIndicator
property alias labelColor: comboBoxInput.color
property bool hover: false // This property is used to indicate the global hover state
property bool edit: myComboBox.activeFocus
property alias actionIndicatorVisible: actionIndicator.visible
property real __actionIndicatorWidth: StudioTheme.Values.squareComponentWidth
@@ -203,7 +203,7 @@ T.ComboBox {
states: [
State {
name: "default"
when: !myComboBox.hover && !myComboBox.activeFocus
when: !myComboBox.hover && !myComboBox.edit
PropertyChanges {
target: myComboBox
wheelEnabled: false
@@ -220,7 +220,7 @@ T.ComboBox {
},
State {
name: "focus"
when: myComboBox.activeFocus && !myComboBox.editable
when: myComboBox.edit && !myComboBox.editable
PropertyChanges {
target: myComboBox
wheelEnabled: true
@@ -232,7 +232,7 @@ T.ComboBox {
},
State {
name: "edit"
when: myComboBox.activeFocus && myComboBox.editable
when: myComboBox.edit && myComboBox.editable
PropertyChanges {
target: myComboBox
wheelEnabled: true

View File

@@ -32,7 +32,7 @@ TextInput {
property T.Control myControl
property bool edit: false
property bool edit: textInput.activeFocus
property bool drag: false
z: 2
@@ -99,7 +99,7 @@ TextInput {
states: [
State {
name: "default"
when: myControl.enabled && !textInput.activeFocus
when: myControl.enabled && !textInput.edit
&& !mouseArea.containsMouse && !myControl.drag
PropertyChanges {
target: textInputArea
@@ -113,7 +113,7 @@ TextInput {
},
State {
name: "hovered"
when: myControl.hover && !textInput.activeFocus && !myControl.drag
when: myControl.hover && !textInput.edit && !myControl.drag
PropertyChanges {
target: textInputArea
color: StudioTheme.Values.themeHoverHighlight
@@ -122,7 +122,7 @@ TextInput {
},
State {
name: "focus"
when: textInput.activeFocus && !myControl.editable
when: textInput.edit && !myControl.editable
PropertyChanges {
target: textInputArea
color: StudioTheme.Values.themeFocusEdit
@@ -131,7 +131,7 @@ TextInput {
},
State {
name: "edit"
when: textInput.activeFocus && myControl.editable
when: textInput.edit && myControl.editable
extend: "focus"
PropertyChanges {
target: tapHandler

View File

@@ -51,32 +51,32 @@ Menu {
text: "Copy"
enabled: myTextEdit.selectedText !== ""
onTriggered: myTextEdit.copy()
shortcut: StandardKey.Copy
/* shortcut: StandardKey.Copy Shortcuts in QQC2 seem to override global shortcuts */
}
Controls2.Action {
text: "Cut"
enabled: myTextEdit.selectedText !== "" && !myTextEdit.readOnly
onTriggered: myTextEdit.cut()
shortcut: StandardKey.Cut
/* shortcut: StandardKey.Cut Shortcuts in QQC2 seem to override global shortcuts */
}
Controls2.Action {
text: "Paste"
enabled: myTextEdit.canPaste
onTriggered: myTextEdit.paste()
shortcut: StandardKey.Paste
/* shortcut: StandardKey.Paste Shortcuts in QQC2 seem to override global shortcuts */
}
Controls2.Action {
text: "Delete"
enabled: myTextEdit.selectedText !== ""
onTriggered: myTextEdit.remove(myTextEdit.selectionStart,
myTextEdit.selectionEnd)
shortcut: StandardKey.Delete
/* shortcut: StandardKey.Delete Shortcuts in QQC2 seem to override global shortcuts */
}
Controls2.Action {
text: "Clear"
enabled: myTextEdit.text !== ""
onTriggered: myTextEdit.clear()
shortcut: StandardKey.DeleteCompleteLine
/* shortcut: StandardKey.DeleteCompleteLine Shortcuts in QQC2 seem to override global shortcuts */
}
MenuSeparator {

View File

@@ -43,6 +43,8 @@ T.Menu {
overlap: 1
padding: 0
closePolicy: T.Popup.CloseOnPressOutside | T.Popup.CloseOnPressOutsideParent | T.Popup.CloseOnEscape
delegate: MenuItem {
}

View File

@@ -47,6 +47,7 @@ T.Slider {
property string __inactiveColor: StudioTheme.Values.themeSliderInactiveTrack
property bool hover: false // This property is used to indicate the global hover state
property bool edit: slider.activeFocus
property alias actionIndicatorVisible: actionIndicator.visible
property real __actionIndicatorWidth: StudioTheme.Values.squareComponentWidth
@@ -223,7 +224,7 @@ T.Slider {
states: [
State {
name: "default"
when: slider.enabled && !slider.hover && !slider.activeFocus
when: slider.enabled && !slider.hover && !slider.edit
PropertyChanges {
target: slider
wheelEnabled: false
@@ -231,7 +232,7 @@ T.Slider {
},
State {
name: "hovered"
when: slider.enabled && slider.hover && !slider.activeFocus
when: slider.enabled && slider.hover && !slider.edit
PropertyChanges {
target: slider
__activeColor: StudioTheme.Values.themeSliderActiveTrackHover
@@ -244,7 +245,7 @@ T.Slider {
},
State {
name: "focus"
when: slider.enabled && slider.activeFocus
when: slider.enabled && slider.edit
PropertyChanges {
target: slider
wheelEnabled: true

View File

@@ -33,7 +33,6 @@ T.Popup {
property T.Control myControl
dim: false
closePolicy: T.Popup.CloseOnEscape | T.Popup.CloseOnPressOutsideParent
background: Rectangle {

View File

@@ -30,7 +30,7 @@ import StudioTheme 1.0 as StudioTheme
T.SpinBox {
id: mySpinBox
property alias textColor: spinBoxInput.color
property alias labelColor: spinBoxInput.color
property alias actionIndicator: actionIndicator
property int decimals: 0
@@ -40,7 +40,7 @@ T.SpinBox {
property real minStepSize: 1
property real maxStepSize: 10
property bool edit: false
property bool edit: spinBoxInput.activeFocus
property bool hover: false // This property is used to indicate the global hover state
property bool drag: false
@@ -91,11 +91,6 @@ T.SpinBox {
top: Math.max(mySpinBox.from, mySpinBox.to)
}
Connections {
target: spinBoxInput
onActiveFocusChanged: mySpinBox.edit = spinBoxInput.activeFocus
}
ActionIndicator {
id: actionIndicator
myControl: mySpinBox
@@ -188,7 +183,7 @@ T.SpinBox {
State {
name: "default"
when: mySpinBox.enabled && !mySpinBox.hover
&& !mySpinBox.activeFocus && !mySpinBox.drag
&& !mySpinBox.edit && !mySpinBox.drag
PropertyChanges {
target: mySpinBox
__wheelEnabled: false
@@ -205,7 +200,7 @@ T.SpinBox {
},
State {
name: "edit"
when: spinBoxInput.activeFocus
when: mySpinBox.edit
PropertyChanges {
target: mySpinBox
__wheelEnabled: true
@@ -245,7 +240,7 @@ T.SpinBox {
// QTBUG-75862 && mySpinBox.focusReason === Qt.TabFocusReason)
spinBoxInput.selectAll()
if (sliderPopup.opened && !activeFocus)
if (sliderPopup.opened && !mySpinBox.activeFocus)
sliderPopup.close()
}

View File

@@ -47,7 +47,10 @@ Rectangle {
anchors.fill: parent
hoverEnabled: true
onContainsMouseChanged: spinBoxIndicator.hover = containsMouse
onPressed: mouse.accepted = false
onPressed: {
myControl.forceActiveFocus()
mouse.accepted = false
}
}
T.Label {

View File

@@ -32,7 +32,7 @@ TextInput {
property T.Control myControl
property bool edit: false
property bool edit: textInput.activeFocus
property bool drag: false
z: 2
@@ -53,7 +53,7 @@ TextInput {
activeFocusOnPress: false
clip: true
// TextInput foucs needs to be set to activeFocus whenever it changes,
// TextInput focus needs to be set to activeFocus whenever it changes,
// otherwise TextInput will get activeFocus whenever the parent SpinBox gets
// activeFocus. This will lead to weird side effects.
onActiveFocusChanged: textInput.focus = activeFocus
@@ -139,7 +139,7 @@ TextInput {
states: [
State {
name: "default"
when: myControl.enabled && !textInput.activeFocus
when: myControl.enabled && !textInput.edit
&& !mouseArea.containsMouse && !myControl.drag
PropertyChanges {
target: textInputArea
@@ -161,7 +161,7 @@ TextInput {
},
State {
name: "hovered"
when: myControl.hover && !textInput.activeFocus && !myControl.drag
when: myControl.hover && !textInput.edit && !myControl.drag
PropertyChanges {
target: textInputArea
color: StudioTheme.Values.themeHoverHighlight
@@ -170,7 +170,7 @@ TextInput {
},
State {
name: "edit"
when: textInput.activeFocus
when: textInput.edit
PropertyChanges {
target: textInputArea
color: StudioTheme.Values.themeFocusEdit

View File

@@ -31,10 +31,9 @@ T.TextField {
id: myTextField
property alias actionIndicator: actionIndicator
property alias translationIndicator: translationIndicator
property bool edit: false
property bool edit: myTextField.activeFocus
property bool hover: false // This property is used to indicate the global hover state
property alias actionIndicatorVisible: actionIndicator.visible
@@ -68,8 +67,6 @@ T.TextField {
rightPadding: StudioTheme.Values.inputHorizontalPadding + translationIndicator.width
- (translationIndicatorVisible ? StudioTheme.Values.border : 0)
onActiveFocusChanged: myTextField.edit = myTextField.activeFocus
MouseArea {
id: mouseArea
anchors.fill: parent
@@ -126,7 +123,7 @@ T.TextField {
State {
name: "default"
when: myTextField.enabled && !myTextField.hover
&& !myTextField.activeFocus
&& !myTextField.edit
PropertyChanges {
target: textFieldBackground
color: StudioTheme.Values.themeControlBackground
@@ -139,7 +136,7 @@ T.TextField {
},
State {
name: "hovered"
when: myTextField.hover && !myTextField.activeFocus
when: myTextField.hover && !myTextField.edit
PropertyChanges {
target: textFieldBackground
color: StudioTheme.Values.themeHoverHighlight
@@ -148,7 +145,7 @@ T.TextField {
},
State {
name: "edit"
when: myTextField.activeFocus
when: myTextField.edit
PropertyChanges {
target: textFieldBackground
color: StudioTheme.Values.themeFocusEdit

View File

@@ -26,8 +26,14 @@ QtcProduct {
property bool qtcRunnable: true
bundle.identifier: qtc.ide_bundle_identifier
// Some of these are in here only to override the entries added to app-Info.plist with other
// build systems in mind.
bundle.infoPlist: ({
"NSHumanReadableCopyright": qtc.qtcreator_copyright_string
"NSHumanReadableCopyright": qtc.qtcreator_copyright_string,
"CFBundleExecutable": qtc.ide_app_target,
"CFBundleIdentifier": qtc.ide_bundle_identifier,
"CFBundleVersion": version
})
cpp.rpaths: qbs.targetOS.contains("macos") ? ["@executable_path/../Frameworks"]

View File

@@ -96,6 +96,7 @@ class Rewriter : protected Visitor
int _lastNewlineOffset = -1;
bool _hadEmptyLine = false;
int _binaryExpDepth = 0;
bool _hasOpenComment = false;
public:
Rewriter(Document::Ptr doc)
@@ -201,6 +202,9 @@ protected:
void out(const QString &str, const SourceLocation &lastLoc = SourceLocation())
{
if (_hasOpenComment) {
newLine();
}
if (lastLoc.isValid()) {
QList<SourceLocation> comments = _doc->engine()->comments();
for (; _nextComment < comments.size(); ++_nextComment) {
@@ -371,6 +375,7 @@ protected:
{
// if preceded by a newline, it's an empty line!
_hadEmptyLine = _line.trimmed().isEmpty();
_hasOpenComment = false;
// if the preceding line wasn't empty, reindent etc.
if (!_hadEmptyLine) {
@@ -524,6 +529,7 @@ protected:
out(" ");
out(toString(nextCommentLoc));
_hasOpenComment = true;
}
}
}
@@ -536,6 +542,37 @@ protected:
return false;
}
bool visit(UiEnumDeclaration *ast) override
{
out(ast->enumToken);
out(" ");
out(ast->name.toString());
out(" ");
out("{"); // TODO: out(ast->lbraceToken);
newLine();
accept(ast->members);
out(ast->rbraceToken);
return false;
}
bool visit(UiEnumMemberList *list) override
{
for (UiEnumMemberList *it = list; it; it = it->next) {
out(it->memberToken);
if (it->valueToken.isValid()) {
out(" = ");
out(it->valueToken);
}
if (it->next) {
out(",");
}
newLine();
}
return false;
}
bool visit(UiImport *ast) override
{
out("import ", ast->importToken);
@@ -565,9 +602,10 @@ protected:
bool visit(UiObjectInitializer *ast) override
{
out(ast->lbraceToken);
if (ast->members)
if (ast->members) {
lnAcceptIndented(ast->members);
newLine();
}
out(ast->rbraceToken);
return false;
}
@@ -679,8 +717,10 @@ protected:
bool visit(ObjectPattern *ast) override
{
out(ast->lbraceToken);
if (ast->properties) {
lnAcceptIndented(ast->properties);
newLine();
}
out(ast->rbraceToken);
return false;
}
@@ -916,14 +956,23 @@ protected:
bool visit(VariableStatement *ast) override
{
out("var ", ast->declarationKindToken);
out(ast->declarationKindToken);
out(" ");
accept(ast->declarations);
return false;
}
bool visit(PatternElement *ast) override
{
if (ast->isForDeclaration) {
if (ast->scope == VariableScope::Var) {
out("var ");
} else if (ast->scope == VariableScope::Let) {
out("let ");
} else if (ast->scope == VariableScope::Const) {
out("const ");
}
}
out(ast->identifierToken);
if (ast->initializer) {
if (ast->isVariableDeclaration())
@@ -987,7 +1036,12 @@ protected:
out(ast->forToken);
out(" ");
out(ast->lparenToken);
if (ast->initialiser) {
accept(ast->initialiser);
} else if (ast->declarations) {
out("var ");
accept(ast->declarations);
}
out("; ", ast->firstSemicolonToken);
accept(ast->condition);
out("; ", ast->secondSemicolonToken);
@@ -1275,6 +1329,9 @@ protected:
{
for (FormalParameterList *it = ast; it; it = it->next) {
out(it->element->bindingIdentifier.toString()); // TODO
if (it->next) {
out(", ");
}
}
return false;
}

View File

@@ -231,7 +231,7 @@ void SshConnection::disconnectFromHost()
case Connecting:
case Connected:
if (!d->sharingEnabled) {
emitDisconnected();
QTimer::singleShot(0, this, &SshConnection::emitDisconnected);
return;
}
d->state = Disconnecting;

View File

@@ -112,6 +112,16 @@ void BoostCodeParser::handleIdentifier()
handleTestCase(TestCaseType::Fixture);
} else if (identifier == "BOOST_DATA_TEST_CASE") {
handleTestCase(TestCaseType::Data);
} else if (identifier == "BOOST_DATA_TEST_CASE_F") {
m_currentState.setFlag(BoostTestTreeItem::Fixture);
handleTestCase(TestCaseType::Data);
} else if (identifier == "BOOST_AUTO_TEST_CASE_TEMPLATE") {
m_currentState.setFlag(BoostTestTreeItem::Templated);
handleTestCase(TestCaseType::Auto);
} else if (identifier == "BOOST_FIXTURE_TEST_CASE_TEMPLATE") {
m_currentState.setFlag(BoostTestTreeItem::Fixture);
m_currentState.setFlag(BoostTestTreeItem::Templated);
handleTestCase(TestCaseType::Auto);
} else if (identifier == "BOOST_TEST_DECORATOR") {
handleDecorator();
}
@@ -133,6 +143,7 @@ void BoostCodeParser::handleSuiteBegin(bool isFixture)
m_currentSuite.prepend(m_suites.last().fullName + '/');
if (isFixture) { // fixture suites have a (fixture) class name as 2nd parameter
m_currentState.setFlag(BoostTestTreeItem::Fixture);
if (!skipCommentsUntil(T_COMMA))
return;
if (!skipCommentsUntil(T_IDENTIFIER))
@@ -194,6 +205,12 @@ void BoostCodeParser::handleTestCase(TestCaseType testCaseType)
}
if (testCaseType == TestCaseType::Parameter)
m_currentState |= BoostTestTreeItem::Parameterized;
} else if (m_currentState.testFlag(BoostTestTreeItem::Fixture)) {
// ignore first parameter (fixture) and first comma
if (!skipCommentsUntil(T_IDENTIFIER))
return;
if (!skipCommentsUntil(T_COMMA))
return;
}
if (!skipCommentsUntil(T_IDENTIFIER))
return;
@@ -227,6 +244,7 @@ void BoostCodeParser::handleTestCase(TestCaseType testCaseType)
m_currentState = BoostTestTreeItem::Enabled;
}
} else {
if (!m_currentState.testFlag(BoostTestTreeItem::Templated))
handleDecorators();
locationAndType = locationAndTypeFromToken(token, m_source, m_currentState, m_suites);
m_testCases.append(locationAndType);
@@ -279,8 +297,11 @@ void BoostCodeParser::handleDecorators()
} else {
// FIXME we have a const(expr) bool? currently not easily achievable
}
} else if (symbolName == "decorator::fixture"
|| (aliasedOrReal && simplifiedName.startsWith("::fixture"))){
m_currentState.setFlag(BoostTestTreeItem::Fixture);
}
// TODO.. fixture, label, depends_on, label, precondition, timeout,...
// TODO.. depends_on, label, precondition, timeout,...
skipCommentsUntil(T_LPAREN);
skipCommentsUntil(T_RPAREN);

View File

@@ -107,7 +107,7 @@ void BoostTestOutputReader::sendCompleteInformation()
if (m_lineNumber) {
result->setLine(m_lineNumber);
result->setFileName(m_fileName);
} // else TODO
}
result->setDescription(m_description);
result->setResult(m_result);
@@ -133,6 +133,8 @@ void BoostTestOutputReader::handleMessageMatch(const QRegularExpressionMatch &ma
if (m_currentTest.isEmpty() || m_logLevel > LogLevel::UnitScope)
m_currentTest = caseFromContent(content);
m_result = ResultType::Fail;
if (m_reportLevel == ReportLevel::No)
++m_summary[ResultType::Fail];
m_description = content;
} else if (content.startsWith("fatal error:")) {
if (m_currentTest.isEmpty() || m_logLevel > LogLevel::UnitScope)
@@ -171,6 +173,8 @@ void BoostTestOutputReader::handleMessageMatch(const QRegularExpressionMatch &ma
} else if (content.startsWith("Test case ")) {
m_currentTest = match.captured(4);
m_result = ResultType::Skip;
if (m_reportLevel == ReportLevel::Confirm || m_reportLevel == ReportLevel::No)
++m_summary[ResultType::Skip];
m_description = content;
}
@@ -193,10 +197,10 @@ void BoostTestOutputReader::processOutputLine(const QByteArray &outputLineWithNe
static QRegularExpression noAssertion("^Test case (.*) did not check any assertions$");
static QRegularExpression summaryPreamble("^\\s*Test (module|suite|case) \"(.*)\" has "
"(failed|passed) with:$");
"(failed|passed)( with:)?$");
static QRegularExpression summarySkip("^\\s+Test case \"(.*)\" was skipped$");
static QRegularExpression summaryDetail("^\\s+(\\d+) test cases? out of (\\d+) "
"(failed|passed)$");
"(failed|passed|skipped)$");
static QRegularExpression summaryAssertion("^\\s+(\\d+) assertions? out of (\\d+) "
"(failed|passed)$");
@@ -284,16 +288,34 @@ void BoostTestOutputReader::processOutputLine(const QByteArray &outputLineWithNe
return;
}
// should summary get reported unconditionally?
match = summaryPreamble.match(line);
if (match.hasMatch()) {
createAndReportResult(match.captured(0), ResultType::MessageInfo);
if (m_reportLevel == ReportLevel::Detailed || match.captured(4).isEmpty()) {
if (match.captured(1) == "case") {
if (match.captured(3) == "passed")
++m_summary[ResultType::Pass];
else
++m_summary[ResultType::Fail];
}
}
return;
}
match = summaryDetail.match(line);
if (match.hasMatch()) {
createAndReportResult(match.captured(0), ResultType::MessageInfo);
int report = match.captured(1).toInt();
QString type = match.captured(3);
if (m_reportLevel != ReportLevel::Detailed) {
if (type == "passed")
m_summary[ResultType::Pass] += report;
else if (type == "failed")
m_summary[ResultType::Fail] += report;
else if (type == "skipped")
m_summary[ResultType::Skip] += report;
}
return;
}
@@ -306,6 +328,8 @@ void BoostTestOutputReader::processOutputLine(const QByteArray &outputLineWithNe
match = summarySkip.match(line);
if (match.hasMatch()) {
createAndReportResult(match.captured(0), ResultType::MessageInfo);
if (m_reportLevel == ReportLevel::Detailed)
++m_summary[ResultType::Skip];
return;
}
@@ -316,11 +340,17 @@ void BoostTestOutputReader::processOutputLine(const QByteArray &outputLineWithNe
BoostTestResult *result = new BoostTestResult(id(), m_projectFile, QString());
int failed = match.captured(1).toInt();
QString txt = tr("%1 failures detected in %2.").arg(failed).arg(match.captured(3));
int passed = (m_testCaseCount != -1)
? m_testCaseCount - failed - m_summary[ResultType::Skip] : -1;
if (m_testCaseCount != -1)
txt.append(' ').append(tr("%1 tests passed.").arg(m_testCaseCount - failed));
txt.append(' ').append(tr("%1 tests passed.").arg(passed));
result->setDescription(txt);
result->setResult(ResultType::MessageInfo); // TODO report similar to disabled tests
result->setResult(ResultType::MessageInfo);
reportResult(TestResultPtr(result));
if (m_reportLevel == ReportLevel::Confirm) { // for the final summary
m_summary[ResultType::Pass] += passed;
m_summary[ResultType::Fail] += failed;
}
m_testCaseCount = -1;
return;
}
@@ -333,8 +363,10 @@ void BoostTestOutputReader::processOutputLine(const QByteArray &outputLineWithNe
if (m_testCaseCount != -1)
txt.append(' ').append(tr("%1 tests passed.").arg(m_testCaseCount));
result->setDescription(txt);
result->setResult(ResultType::MessageInfo); // TODO report similar to disabled tests
result->setResult(ResultType::MessageInfo);
reportResult(TestResultPtr(result));
if (m_reportLevel == ReportLevel::Confirm) // for the final summary
m_summary.insert(ResultType::Pass, m_testCaseCount);
return;
}
@@ -374,15 +406,17 @@ TestResultPtr BoostTestOutputReader::createDefaultResult() const
result->setTestSuite(m_currentSuite);
result->setTestCase(m_currentTest);
// TODO find corresponding TestTreeItem and set filename/line
return TestResultPtr(result);
}
void BoostTestOutputReader::onFinished(int exitCode, QProcess::ExitStatus /*exitState*/) {
if (m_reportLevel == ReportLevel::No && m_testCaseCount != -1) {
int reportedFailsAndSkips = m_summary[ResultType::Fail] + m_summary[ResultType::Skip];
m_summary.insert(ResultType::Pass, m_testCaseCount - reportedFailsAndSkips);
}
// boost::exit_success (0), boost::exit_test_failure (201)
// or boost::exit_exception_failure (200)
// be graceful and do not add a fatal for exit_test_failure
// but exit code 0 can be forced with an option - what todo in that case?
if (m_logLevel == LogLevel::Nothing && m_reportLevel == ReportLevel::No) {
switch (exitCode) {
case 0:

View File

@@ -40,7 +40,9 @@ namespace BoostTestUtils {
static const QStringList relevant = {
QStringLiteral("BOOST_AUTO_TEST_CASE"), QStringLiteral("BOOST_TEST_CASE"),
QStringLiteral("BOOST_DATA_TEST_CASE"), QStringLiteral("BOOST_FIXTURE_TEST_CASE"),
QStringLiteral("BOOST_PARAM_TEST_CASE")
QStringLiteral("BOOST_PARAM_TEST_CASE"), QStringLiteral("BOOST_DATA_TEST_CASE_F"),
QStringLiteral("BOOST_AUTO_TEST_CASE_TEMPLATE"),
QStringLiteral("BOOST_FIXTURE_TEST_CASE_TEMPLATE"),
};
bool isBoostTestMacro(const QString &macro)

View File

@@ -233,7 +233,10 @@ QList<TestConfiguration *> BoostTestTreeItem::getSelectedTestConfigurations() co
if (!item->enabled()) // ignore child tests known to be disabled when using run selected
return;
if (item->checked() == Qt::Checked) {
QString tcName = handleSpecialFunctionNames(item->name());
QString tcName = item->name();
if (item->state().testFlag(BoostTestTreeItem::Templated))
tcName.append("<*");
tcName = handleSpecialFunctionNames(tcName);
testCasesForProjectFile[item->proFile()].testCases.append(
item->prependWithParentsSuitePaths(tcName));
testCasesForProjectFile[item->proFile()].internalTargets.unite(item->internalTargets());
@@ -268,12 +271,17 @@ TestConfiguration *BoostTestTreeItem::testConfiguration() const
QString tcName = handleSpecialFunctionNames(boostItem->name());
if (boostItem->type() == TestSuite) // execute everything below a suite
tcName.append("/*");
else if (boostItem->state().testFlag(BoostTestTreeItem::Templated))
tcName.append("<*");
testCases.append(boostItem->prependWithParentsSuitePaths(tcName));
}
}
});
} else {
testCases.append(prependWithParentsSuitePaths(handleSpecialFunctionNames(name())));
QString tcName = name();
if (state().testFlag(BoostTestTreeItem::Templated))
tcName.append("<*");
testCases.append(prependWithParentsSuitePaths(handleSpecialFunctionNames(tcName)));
}
BoostTestConfiguration *config = new BoostTestConfiguration;
@@ -297,12 +305,15 @@ TestConfiguration *BoostTestTreeItem::debugConfiguration() const
QString BoostTestTreeItem::nameSuffix() const
{
static QString markups[] = {QCoreApplication::translate("BoostTestTreeItem", "parameterized"),
QCoreApplication::translate("BoostTestTreeItem", "fixture")};
QCoreApplication::translate("BoostTestTreeItem", "fixture"),
QCoreApplication::translate("BoostTestTreeItem", "templated")};
QString suffix;
if (m_state & Parameterized)
suffix = QString(" [") + markups[0];
if (m_state & Fixture)
suffix += (suffix.isEmpty() ? QString(" [") : QString(", ")) + markups[1];
if (m_state & Templated)
suffix += (suffix.isEmpty() ? QString(" [") : QString(", ")) + markups[2];
if (!suffix.isEmpty())
suffix += ']';
return suffix;

View File

@@ -43,6 +43,7 @@ public:
Parameterized = 0x10,
Fixture = 0x20,
Templated = 0x40,
};
Q_FLAGS(TestState)
Q_DECLARE_FLAGS(TestStates, TestState)

View File

@@ -48,6 +48,8 @@ public:
void createAndReportResult(const QString &message, ResultType type);
bool hadValidOutput() const { return m_hadValidOutput; }
int disabledTests() const { return m_disabled; }
bool hasSummary() const { return !m_summary.isEmpty(); }
QHash<ResultType, int> summary() const { return m_summary; }
void setId(const QString &id) { m_id = id; }
QString id() const { return m_id; }
@@ -64,6 +66,7 @@ protected:
QProcess *m_testApplication; // not owned
QString m_buildDir;
QString m_id;
QHash<ResultType, int> m_summary;
int m_disabled = -1;
private:
bool m_hadValidOutput = false;

View File

@@ -23,10 +23,11 @@
**
****************************************************************************/
#include "testresultmodel.h"
#include "autotesticons.h"
#include "autotestplugin.h"
#include "testresultdelegate.h"
#include "testresultmodel.h"
#include "testrunner.h"
#include "testsettings.h"
#include <projectexplorer/projectexplorericons.h>
@@ -220,6 +221,10 @@ QString TestResultItem::resultString() const
TestResultModel::TestResultModel(QObject *parent)
: Utils::TreeModel<TestResultItem>(new TestResultItem(TestResultPtr()), parent)
{
connect(TestRunner::instance(), &TestRunner::reportSummary,
this, [this](const QString &id, const QHash<ResultType, int> &summary){
m_reportedSummary.insert(id, summary);
});
}
void TestResultModel::updateParent(const TestResultItem *item)
@@ -256,7 +261,7 @@ void TestResultModel::addTestResult(const TestResultPtr &testResult, bool autoEx
return;
}
m_testResultCount[testResult->result()]++;
m_testResultCount[testResult->id()][testResult->result()]++;
TestResultItem *newItem = new TestResultItem(testResult);
TestResultItem *root = nullptr;
@@ -314,6 +319,7 @@ void TestResultModel::clearTestResults()
{
clear();
m_testResultCount.clear();
m_reportedSummary.clear();
m_disabled = 0;
m_fileNames.clear();
m_maxWidthOfFileName = 0;
@@ -363,6 +369,21 @@ int TestResultModel::maxWidthOfLineNumber(const QFont &font)
return m_widthOfLineNumber;
}
int TestResultModel::resultTypeCount(ResultType type) const
{
int result = 0;
for (auto resultsForId : m_testResultCount.values())
result += resultsForId.value(type, 0);
for (auto id : m_reportedSummary.keys()) {
if (int counted = m_testResultCount.value(id).value(type))
result -= counted;
result += m_reportedSummary[id].value(type);
}
return result;
}
TestResultItem *TestResultModel::findParentItemFor(const TestResultItem *item,
const TestResultItem *startItem) const
{

View File

@@ -84,7 +84,7 @@ public:
int maxWidthOfFileName(const QFont &font);
int maxWidthOfLineNumber(const QFont &font);
int resultTypeCount(ResultType type) const { return m_testResultCount.value(type, 0); }
int resultTypeCount(ResultType type) const;
int disabledTests() const { return m_disabled; }
void raiseDisabledTests(int amount) { m_disabled += amount; }
@@ -94,7 +94,8 @@ private:
TestResultItem *findParentItemFor(const TestResultItem *item,
const TestResultItem *startItem = nullptr) const;
void updateParent(const TestResultItem *item);
QMap<ResultType, int> m_testResultCount;
QHash<QString, QMap<ResultType, int>> m_testResultCount;
QHash<QString, QHash<ResultType, int>> m_reportedSummary;
int m_widthOfLineNumber = 0;
int m_maxWidthOfFileName = 0;
int m_disabled = 0;

View File

@@ -270,6 +270,9 @@ void TestRunner::onProcessFinished()
const int disabled = m_currentOutputReader->disabledTests();
if (disabled > 0)
emit hadDisabledTests(disabled);
if (m_currentOutputReader->hasSummary())
emit reportSummary(m_currentOutputReader->id(), m_currentOutputReader->summary());
resetInternalPointers();
if (!m_fakeFutureInterface) {

View File

@@ -71,6 +71,7 @@ signals:
void requestStopTestRun();
void testResultReady(const TestResultPtr &result);
void hadDisabledTests(int disabled);
void reportSummary(const QString &id, const QHash<ResultType, int> &summary);
private:
void buildProject(ProjectExplorer::Project *project);

View File

@@ -152,8 +152,13 @@ bool ClangFormatPlugin::initialize(const QStringList &arguments, QString *errorS
openClangFormatConfigAction->setData(doc->filePath().toString());
});
}
#endif
return true;
#else
*errorString = "Disabling ClangFormat plugin as it is not built against a suitable version of "
"Clang's libFormat. For more information, see the Qt Creator README at "
"https://code.qt.io/cgit/qt-creator/qt-creator.git/tree/README.md";
return false;
#endif
}
} // namespace ClangFormat

View File

@@ -119,6 +119,7 @@ OutputWindow::OutputWindow(Context context, const QString &settingsKey, QWidget
connect(copyAction, &QAction::triggered, this, &QPlainTextEdit::copy);
connect(pasteAction, &QAction::triggered, this, &QPlainTextEdit::paste);
connect(selectAllAction, &QAction::triggered, this, &QPlainTextEdit::selectAll);
connect(this, &QPlainTextEdit::blockCountChanged, this, &OutputWindow::filterNewContent);
connect(this, &QPlainTextEdit::undoAvailable, undoAction, &QAction::setEnabled);
connect(this, &QPlainTextEdit::redoAvailable, redoAction, &QAction::setEnabled);
@@ -216,10 +217,8 @@ OutputFormatter *OutputWindow::formatter() const
void OutputWindow::setFormatter(OutputFormatter *formatter)
{
d->formatter = formatter;
if (d->formatter) {
if (d->formatter)
d->formatter->setPlainTextEdit(this);
connect(d->formatter, &OutputFormatter::contentChanged, this, &OutputWindow::filterNewContent);
}
}
void OutputWindow::showEvent(QShowEvent *e)

View File

@@ -52,6 +52,7 @@ using namespace CppTools;
using namespace CppTools::Internal;
static const bool FindErrorsIndexing = qgetenv("QTC_FIND_ERRORS_INDEXING") == "1";
static Q_LOGGING_CATEGORY(indexerLog, "qtc.cpptools.indexer", QtWarningMsg)
namespace {
@@ -205,6 +206,8 @@ void index(QFutureInterface<void> &indexingFuture,
const ProjectExplorer::HeaderPaths fallbackHeaderPaths = cmm->headerPaths();
const CPlusPlus::LanguageFeatures defaultFeatures =
CPlusPlus::LanguageFeatures::defaultFeatures();
qCDebug(indexerLog) << "About to index" << files.size() << "files.";
for (int i = 0; i < files.size(); ++i) {
if (indexingFuture.isCanceled() || superFuture.isCanceled())
break;
@@ -225,6 +228,7 @@ void index(QFutureInterface<void> &indexingFuture,
processingHeaders = true;
}
qCDebug(indexerLog) << " Indexing" << i + 1 << "of" << files.size() << ":" << fileName;
ProjectExplorer::HeaderPaths headerPaths = parts.isEmpty()
? fallbackHeaderPaths
: parts.first()->headerPaths;
@@ -236,6 +240,7 @@ void index(QFutureInterface<void> &indexingFuture,
if (isSourceFile)
sourceProcessor->resetEnvironment();
}
qCDebug(indexerLog) << "Indexing finished.";
}
void parse(QFutureInterface<void> &indexingFuture,

View File

@@ -288,13 +288,12 @@ DebuggerMainWindow::DebuggerMainWindow()
cmd->setAttribute(Command::CA_Hide);
viewsMenu->addAction(cmd, Core::Constants::G_DEFAULT_THREE);
connect(ICore::instance(), &ICore::saveSettingsRequested, this, [this] {
connect(ICore::instance(), &ICore::saveSettingsRequested, this,
[this](ICore::SaveSettingsReason reason) {
// There's one saveSettings triggered after plugin loading intentionally.
// We do not want to save anything at that time.
static bool firstOne = true;
if (firstOne) {
if (reason == ICore::InitializationDone) {
qCDebug(perspectivesLog) << "FIRST SAVE SETTINGS REQUEST IGNORED";
firstOne = false;
} else {
qCDebug(perspectivesLog) << "SAVING SETTINGS";
savePersistentSettings();

View File

@@ -1011,6 +1011,8 @@ void DebuggerRunTool::showMessage(const QString &msg, int channel, int timeout)
if (channel == ConsoleOutput)
debuggerConsole()->printItem(ConsoleItem::DefaultType, msg);
QTC_ASSERT(m_engine, qDebug() << msg; return);
m_engine->showMessage(msg, channel, timeout);
if (m_engine2)
m_engine->showMessage(msg, channel, timeout);

View File

@@ -51,6 +51,18 @@ add_qtc_plugin(componentsplugin
SKIP_DEBUG_CMAKE_FILE_CHECK
)
add_qtc_plugin(qmlpreviewplugin
CONDITION TARGET QmlDesigner
DEPENDS Core ProjectExplorer QmlDesigner Utils Qt5::Qml
INCLUDES ${CMAKE_CURRENT_LIST_DIR}/designercore/include
SOURCES
qmlpreviewplugin/qmlpreviewactions.cpp qmlpreviewplugin/qmlpreviewactions.h
qmlpreviewplugin/qmlpreviewplugin.cpp qmlpreviewplugin/qmlpreviewplugin.h
qmlpreviewplugin/qmlpreviewplugin.qrc
PLUGIN_PATH ${QmlDesignerPluginInstallPrefix}
SKIP_DEBUG_CMAKE_FILE_CHECK
)
add_qtc_plugin(qtquickplugin
CONDITION TARGET QmlDesigner
DEPENDS Core QmlDesigner Utils Qt5::Qml
@@ -283,6 +295,9 @@ extend_qtc_plugin(QmlDesigner
propertyeditorvalue.cpp propertyeditorvalue.h
propertyeditorview.cpp propertyeditorview.h
propertyeditorwidget.cpp propertyeditorwidget.h
simplecolorpalette.cpp simplecolorpalette.h
simplecolorpalettemodel.cpp simplecolorpalettemodel.h
simplecolorpalettesingleton.cpp simplecolorpalettesingleton.h
qmlanchorbindingproxy.cpp qmlanchorbindingproxy.h
qmlmodelnodeproxy.cpp qmlmodelnodeproxy.h
quick2propertyeditorview.cpp quick2propertyeditorview.h
@@ -305,6 +320,7 @@ extend_qtc_plugin(QmlDesigner
extend_qtc_plugin(QmlDesigner
SOURCES_PREFIX components/texteditor
SOURCES
texteditor.qrc
texteditorstatusbar.cpp texteditorstatusbar.h
texteditorview.cpp texteditorview.h
texteditorwidget.cpp texteditorwidget.h

View File

@@ -185,17 +185,16 @@ void LayoutInGridLayout::doIt()
if (qmlItemNode.hasInstanceParentItem()) {
ModelNode layoutNode;
{
RewriterTransaction transaction(m_selectionContext.view(), QByteArrayLiteral("LayoutInGridLayout1"));
m_selectionContext.view()->executeInTransaction("LayoutInGridLayout1",[this, &layoutNode, layoutType](){
QTC_ASSERT(m_selectionContext.view()->model()->hasNodeMetaInfo(layoutType), return);
NodeMetaInfo metaInfo = m_selectionContext.view()->model()->metaInfo(layoutType);
layoutNode = m_selectionContext.view()->createModelNode(layoutType, metaInfo.majorVersion(), metaInfo.minorVersion());
reparentTo(layoutNode, m_parentNode);
}
});
{
RewriterTransaction transaction(m_selectionContext.view(), QByteArrayLiteral("LayoutInGridLayout2"));
m_selectionContext.view()->executeInTransaction("LayoutInGridLayout2", [this, layoutNode](){
fillEmptyCells();
@@ -208,7 +207,7 @@ void LayoutInGridLayout::doIt()
reparentToNodeAndRemovePositionForModelNodes(layoutNode, sortedSelectedNodes);
setSizeAsPreferredSize(sortedSelectedNodes);
setSpanning(layoutNode);
}
});
}
}
}

View File

@@ -240,9 +240,7 @@ void changeOrder(const SelectionContext &selectionState, OderAction orderAction)
if (!modelNode.parentProperty().isNodeListProperty())
return;
try {
RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|raise"));
selectionState.view()->executeInTransaction("DesignerActionManager|raise",[orderAction, selectionState, modelNode](){
ModelNode modelNode = selectionState.currentSingleSelectedNode();
NodeListProperty parentProperty = modelNode.parentProperty().toNodeListProperty();
const int index = parentProperty.indexOf(modelNode);
@@ -255,11 +253,7 @@ void changeOrder(const SelectionContext &selectionState, OderAction orderAction)
if (index > 0)
parentProperty.slide(index, index - 1);
}
transaction.commit();
} catch (const RewritingException &e) { //better save then sorry
e.showException();
}
});
}
void raise(const SelectionContext &selectionState)
@@ -328,16 +322,13 @@ void resetSize(const SelectionContext &selectionState)
if (!selectionState.view())
return;
try {
RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|resetSize"));
selectionState.view()->executeInTransaction("DesignerActionManager|resetSize",[selectionState](){
foreach (ModelNode node, selectionState.selectedModelNodes()) {
QmlItemNode itemNode(node);
itemNode.removeProperty("width");
itemNode.removeProperty("height");
}
} catch (const RewritingException &e) { //better save then sorry
e.showException();
}
});
}
void resetPosition(const SelectionContext &selectionState)
@@ -345,17 +336,13 @@ void resetPosition(const SelectionContext &selectionState)
if (!selectionState.view())
return;
try {
RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|resetPosition"));
selectionState.view()->executeInTransaction("DesignerActionManager|resetPosition",[selectionState](){
foreach (ModelNode node, selectionState.selectedModelNodes()) {
QmlItemNode itemNode(node);
itemNode.removeProperty("x");
itemNode.removeProperty("y");
}
transaction.commit();
} catch (const RewritingException &e) { //better save then sorry
e.showException();
}
});
}
void goIntoComponentOperation(const SelectionContext &selectionState)
@@ -372,11 +359,12 @@ void resetZ(const SelectionContext &selectionState)
if (!selectionState.view())
return;
RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|resetZ"));
selectionState.view()->executeInTransaction("DesignerActionManager|resetZ",[selectionState](){
foreach (ModelNode node, selectionState.selectedModelNodes()) {
QmlItemNode itemNode(node);
itemNode.removeProperty("z");
}
});
}
static inline void backupPropertyAndRemove(const ModelNode &node, const PropertyName &propertyName)
@@ -404,9 +392,7 @@ void anchorsFill(const SelectionContext &selectionState)
if (!selectionState.view())
return;
try {
RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|anchorsFill"));
selectionState.view()->executeInTransaction("DesignerActionManager|anchorsFill",[selectionState](){
ModelNode modelNode = selectionState.currentSingleSelectedNode();
QmlItemNode node = modelNode;
@@ -417,11 +403,7 @@ void anchorsFill(const SelectionContext &selectionState)
backupPropertyAndRemove(modelNode, "width");
backupPropertyAndRemove(modelNode, "height");
}
transaction.commit();
} catch (const RewritingException &e) { //better save then sorry
e.showException();
}
});
}
void anchorsReset(const SelectionContext &selectionState)
@@ -429,8 +411,7 @@ void anchorsReset(const SelectionContext &selectionState)
if (!selectionState.view())
return;
RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|anchorsReset"));
selectionState.view()->executeInTransaction("DesignerActionManager|anchorsReset",[selectionState](){
ModelNode modelNode = selectionState.currentSingleSelectedNode();
QmlItemNode node = modelNode;
@@ -442,6 +423,7 @@ void anchorsReset(const SelectionContext &selectionState)
restoreProperty(node, "width");
restoreProperty(node, "height");
}
});
}
using LessThan = std::function<bool (const ModelNode &, const ModelNode&)>;
@@ -481,7 +463,7 @@ bool compareByGrid(const ModelNode &node1, const ModelNode &node2)
static void layoutHelperFunction(const SelectionContext &selectionContext,
const TypeName &layoutType,
LessThan lessThan)
const LessThan &lessThan)
{
if (!selectionContext.view()
|| !selectionContext.hasSingleSelectedModelNode()
@@ -492,10 +474,8 @@ static void layoutHelperFunction(const SelectionContext &selectionContext,
const QmlItemNode qmlItemNode = QmlItemNode(selectionContext.firstSelectedModelNode());
if (qmlItemNode.hasInstanceParentItem()) {
ModelNode layoutNode;
{
RewriterTransaction transaction(selectionContext.view(), QByteArrayLiteral("DesignerActionManager|layoutHelperFunction1"));
selectionContext.view()->executeInTransaction("DesignerActionManager|layoutHelperFunction1",[=, &layoutNode](){
QmlItemNode parentNode = qmlItemNode.instanceParentItem();
@@ -504,10 +484,9 @@ static void layoutHelperFunction(const SelectionContext &selectionContext,
layoutNode = selectionContext.view()->createModelNode(layoutType, metaInfo.majorVersion(), metaInfo.minorVersion());
reparentTo(layoutNode, parentNode);
}
});
{
RewriterTransaction transaction(selectionContext.view(), QByteArrayLiteral("DesignerActionManager|layoutHelperFunction2"));
selectionContext.view()->executeInTransaction("DesignerActionManager|layoutHelperFunction2",[=](){
QList<ModelNode> sortedSelectedNodes = selectionContext.selectedModelNodes();
Utils::sort(sortedSelectedNodes, lessThan);
@@ -516,7 +495,7 @@ static void layoutHelperFunction(const SelectionContext &selectionContext,
LayoutInGridLayout::reparentToNodeAndRemovePositionForModelNodes(layoutNode, sortedSelectedNodes);
if (layoutType.contains("Layout"))
LayoutInGridLayout::setSizeAsPreferredSize(sortedSelectedNodes);
}
});
}
}
}
@@ -662,16 +641,9 @@ void addSignalHandlerOrGotoImplementation(const SelectionContext &selectionState
if (!qmlObjectNode.isRootModelNode()) {
isModelNodeRoot = false;
try {
RewriterTransaction transaction =
qmlObjectNode.view()->beginRewriterTransaction(QByteArrayLiteral("NavigatorTreeModel:exportItem"));
QmlObjectNode qmlObjectNode(modelNode);
qmlObjectNode.view()->executeInTransaction("NavigatorTreeModel:exportItem", [&qmlObjectNode](){
qmlObjectNode.ensureAliasExport();
transaction.commit();
} catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail
exception.showException();
}
});
}
QString itemId = modelNode.id();
@@ -708,14 +680,10 @@ void addSignalHandlerOrGotoImplementation(const SelectionContext &selectionState
if (dialog->signal().isEmpty())
return;
try {
RewriterTransaction transaction =
qmlObjectNode.view()->beginRewriterTransaction(QByteArrayLiteral("NavigatorTreeModel:exportItem"));
qmlObjectNode.view()->executeInTransaction("NavigatorTreeModel:exportItem", [=](){
addSignal(typeName, itemId, dialog->signal(), isModelNodeRoot);
} catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail
exception.showException();
}
});
addSignal(typeName, itemId, dialog->signal(), isModelNodeRoot);
@@ -751,9 +719,7 @@ void removeLayout(const SelectionContext &selectionContext)
if (!parent.isValid())
return;
{
RewriterTransaction transaction(selectionContext.view(), QByteArrayLiteral("DesignerActionManager|removeLayout"));
selectionContext.view()->executeInTransaction("DesignerActionManager|removeLayout", [selectionContext, &layoutItem, parent](){
foreach (const ModelNode &modelNode, selectionContext.currentSingleSelectedNode().directSubModelNodes()) {
if (QmlItemNode::isValidQmlItemNode(modelNode)) {
@@ -772,7 +738,7 @@ void removeLayout(const SelectionContext &selectionContext)
parent.modelNode().defaultNodeListProperty().reparentHere(modelNode);
}
layoutItem.destroy();
}
});
}
void removePositioner(const SelectionContext &selectionContext)
@@ -826,9 +792,7 @@ void addItemToStackedContainer(const SelectionContext &selectionContext)
}
}
try {
RewriterTransaction transaction =
view->beginRewriterTransaction(QByteArrayLiteral("DesignerActionManager:addItemToStackedContainer"));
view->executeInTransaction("DesignerActionManager:addItemToStackedContainer", [=](){
NodeMetaInfo itemMetaInfo = view->model()->metaInfo("QtQuick.Item", -1, -1);
QTC_ASSERT(itemMetaInfo.isValid(), return);
@@ -853,11 +817,7 @@ void addItemToStackedContainer(const SelectionContext &selectionContext)
}
}
transaction.commit();
} catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail
exception.showException();
}
});
}
PropertyName getIndexPropertyName(const ModelNode &modelNode)
@@ -969,9 +929,8 @@ void addTabBarToStackedContainer(const SelectionContext &selectionContext)
const PropertyName indexPropertyName = getIndexPropertyName(container);
QTC_ASSERT(container.metaInfo().hasProperty(indexPropertyName), return);
try {
RewriterTransaction transaction =
view->beginRewriterTransaction(QByteArrayLiteral("DesignerActionManager:addItemToStackedContainer"));
view->executeInTransaction("DesignerActionManager:addItemToStackedContainer",
[view, container, containerItemNode, tabBarMetaInfo, tabButtonMetaInfo, indexPropertyName](){
ModelNode tabBarNode =
view->createModelNode("QtQuick.Controls.TabBar",
@@ -1003,11 +962,8 @@ void addTabBarToStackedContainer(const SelectionContext &selectionContext)
container.removeProperty(indexPropertyName);
const QString expression = id + "." + QString::fromLatin1(indexPropertyName);
container.bindingProperty(indexPropertyName).setExpression(expression);
});
transaction.commit();
} catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail
exception.showException();
}
}
bool addImageToProject(const QStringList &fileNames, const QString &defaultDirectory)

View File

@@ -365,18 +365,13 @@ void DesignDocument::deleteSelected()
if (!currentModel())
return;
try {
RewriterTransaction transaction(rewriterView(), QByteArrayLiteral("DesignDocument::deleteSelected"));
rewriterView()->executeInTransaction("DesignDocument::deleteSelected", [this](){
QList<ModelNode> toDelete = view()->selectedModelNodes();
foreach (ModelNode node, toDelete) {
if (node.isValid() && !node.isRootNode() && QmlObjectNode::isValidQmlObjectNode(node))
QmlObjectNode(node).destroy();
}
transaction.commit();
} catch (const RewritingException &e) {
e.showException();
}
});
}
void DesignDocument::copySelected()
@@ -465,11 +460,9 @@ void DesignDocument::paste()
}
}
rewriterView()->executeInTransaction("DesignDocument::paste1", [this, &view, selectedNodes, targetNode](){
QList<ModelNode> pastedNodeList;
try {
RewriterTransaction transaction(rewriterView(), QByteArrayLiteral("DesignDocument::paste1"));
int offset = double(qrand()) / RAND_MAX * 20 - 10;
foreach (const ModelNode &node, selectedNodes) {
@@ -481,14 +474,10 @@ void DesignDocument::paste()
}
view.setSelectedModelNodes(pastedNodeList);
transaction.commit();
} catch (const RewritingException &e) {
qWarning() << e.description(); //silent error
}
} else {
try {
RewriterTransaction transaction(rewriterView(), QByteArrayLiteral("DesignDocument::paste2"));
});
} else {
rewriterView()->executeInTransaction("DesignDocument::paste1", [this, &view, selectedNodes, rootNode](){
currentModel()->attachView(&view);
ModelNode pastedNode(view.insertModel(rootNode));
ModelNode targetNode;
@@ -514,15 +503,9 @@ void DesignDocument::paste()
} else {
qWarning() << "Cannot reparent to" << targetNode;
}
transaction.commit();
NodeMetaInfo::clearCache();
view.setSelectedModelNodes({pastedNode});
transaction.commit();
} catch (const RewritingException &e) {
qWarning() << e.description(); //silent error
}
});
NodeMetaInfo::clearCache();
}
}

View File

@@ -545,10 +545,9 @@ void NavigatorTreeModel::handleItemLibraryImageDrop(const QMimeData *mimeData, i
void NavigatorTreeModel::moveNodesInteractive(NodeAbstractProperty &parentProperty, const QList<ModelNode> &modelNodes, int targetIndex)
{
QTC_ASSERT(m_view, return);
try {
const TypeName propertyQmlType = parentProperty.parentModelNode().metaInfo().propertyTypeName(parentProperty.name());
RewriterTransaction transaction = m_view->beginRewriterTransaction(QByteArrayLiteral("NavigatorTreeModel::moveNodesInteractive"));
m_view->executeInTransaction("NavigatorTreeModel::moveNodesInteractive",[this, &parentProperty, modelNodes, targetIndex](){
const TypeName propertyQmlType = parentProperty.parentModelNode().metaInfo().propertyTypeName(parentProperty.name());
foreach (const ModelNode &modelNode, modelNodes) {
if (modelNode.isValid()
&& modelNode != parentProperty.parentModelNode()
@@ -565,10 +564,7 @@ void NavigatorTreeModel::moveNodesInteractive(NodeAbstractProperty &parentProper
}
}
}
transaction.commit();
} catch (const RewritingException &exception) { //better safe than sorry! There always might be cases where we fail
exception.showException();
}
});
}
Qt::DropActions NavigatorTreeModel::supportedDropActions() const

View File

@@ -198,16 +198,10 @@ void NavigatorView::handleChangedExport(const ModelNode &modelNode, bool exporte
if (rootNode.hasProperty(modelNodeId))
rootNode.removeProperty(modelNodeId);
if (exported) {
try {
RewriterTransaction transaction =
beginRewriterTransaction(QByteArrayLiteral("NavigatorTreeModel:exportItem"));
executeInTransaction("NavigatorTreeModel:exportItem", [this, modelNode](){
QmlObjectNode qmlObjectNode(modelNode);
qmlObjectNode.ensureAliasExport();
transaction.commit();
} catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail
exception.showException();
}
});
}
}

View File

@@ -36,7 +36,7 @@
#include <variantproperty.h>
#include <abstractview.h>
#include <nodemetainfo.h>
#include <rewritertransaction.h>
#include <exception.h>
#include <utils/qtcassert.h>
@@ -147,17 +147,15 @@ void GradientModel::addGradient()
return;
if (!m_itemNode.modelNode().hasNodeProperty(gradientPropertyName().toUtf8())) {
try {
QColor color = m_itemNode.instanceValue("color").value<QColor>();
if (!color.isValid())
color = QColor(Qt::white);
if (m_gradientTypeName != "Gradient")
ensureShapesImport();
QmlDesigner::RewriterTransaction transaction = view()->beginRewriterTransaction(QByteArrayLiteral("GradientModel::addGradient"));
view()->executeInTransaction("GradientModel::addGradient", [this](){
QColor color = m_itemNode.instanceValue("color").value<QColor>();
if (!color.isValid())
color = QColor(Qt::white);
QmlDesigner::ModelNode gradientNode = createGradientNode();
@@ -172,11 +170,7 @@ void GradientModel::addGradient()
gradientStopNode.variantProperty("position").setValue(1.0);
gradientStopNode.variantProperty("color").setValue(QColor(Qt::black));
gradientNode.nodeListProperty("stops").reparentHere(gradientStopNode);
} catch (const QmlDesigner::Exception &e) {
e.showException();
}
});
}
setupModel();
@@ -244,18 +238,18 @@ qreal GradientModel::getPosition(int index) const
void GradientModel::removeStop(int index)
{
if (index < rowCount() - 1 && index != 0) {
QmlDesigner::RewriterTransaction transaction = view()->beginRewriterTransaction(QByteArrayLiteral("GradientModel::removeStop"));
view()->executeInTransaction("GradientModel::removeStop", [this, index](){
QmlDesigner::ModelNode gradientNode = m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).modelNode();
QmlDesigner::QmlObjectNode stop = gradientNode.nodeListProperty("stops").at(index);
if (stop.isValid()) {
stop.destroy();
setupModel();
}
});
}
qWarning() << Q_FUNC_INFO << "invalid index";
}
void GradientModel::deleteGradient()
{
if (!m_itemNode.isValid())
@@ -385,7 +379,11 @@ void GradientModel::ensureShapesImport()
{
if (!hasShapesImport()) {
QmlDesigner::Import timelineImport = QmlDesigner::Import::createLibraryImport("QtQuick.Shapes", "1.0");
try {
model()->changeImports({timelineImport}, {});
} catch (const QmlDesigner::Exception &) {
QTC_ASSERT(false, return);
}
}
}

View File

@@ -152,24 +152,16 @@ void PropertyEditorContextObject::toogleExportAlias()
PropertyName modelNodeId = selectedNode.id().toUtf8();
ModelNode rootModelNode = rewriterView->rootModelNode();
try {
RewriterTransaction transaction =
rewriterView->beginRewriterTransaction(QByteArrayLiteral("PropertyEditorContextObject:toogleExportAlias"));
rewriterView->executeInTransaction("PropertyEditorContextObject:toogleExportAlias", [&objectNode, &rootModelNode, modelNodeId](){
if (!objectNode.isAliasExported())
objectNode.ensureAliasExport();
else
if (rootModelNode.hasProperty(modelNodeId))
rootModelNode.removeProperty(modelNodeId);
transaction.commit();
} catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail
exception.showException();
});
}
}
}
void PropertyEditorContextObject::changeTypeName(const QString &typeName)
{
@@ -181,12 +173,9 @@ void PropertyEditorContextObject::changeTypeName(const QString &typeName)
QTC_ASSERT(!rewriterView->selectedModelNodes().isEmpty(), return);
rewriterView->executeInTransaction("PropertyEditorContextObject:changeTypeName", [this, rewriterView, typeName](){
ModelNode selectedNode = rewriterView->selectedModelNodes().constFirst();
try {
RewriterTransaction transaction =
rewriterView->beginRewriterTransaction(QByteArrayLiteral("PropertyEditorContextObject:changeTypeName"));
NodeMetaInfo metaInfo = m_model->metaInfo(typeName.toLatin1());
if (!metaInfo.isValid()) {
Core::AsynchronousMessageBox::warning(tr("Invalid Type"), tr("%1 is an invalid type.").arg(typeName));
@@ -196,13 +185,7 @@ void PropertyEditorContextObject::changeTypeName(const QString &typeName)
rewriterView->changeRootNodeType(metaInfo.typeName(), metaInfo.majorVersion(), metaInfo.minorVersion());
else
selectedNode.changeType(metaInfo.typeName(), metaInfo.majorVersion(), metaInfo.minorVersion());
transaction.commit();
} catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail
exception.showException();
}
});
}
void PropertyEditorContextObject::insertKeyframe(const QString &propertyName)

View File

@@ -481,7 +481,9 @@ static NodeMetaInfo findCommonSuperClass(const NodeMetaInfo &first, const NodeMe
NodeMetaInfo PropertyEditorQmlBackend::findCommonAncestor(const ModelNode &node)
{
QTC_ASSERT(node.isValid(), return {});
if (!node.isValid())
return {};
QTC_ASSERT(node.metaInfo().isValid(), return {});
AbstractView *view = node.view();

View File

@@ -235,9 +235,7 @@ void PropertyEditorView::changeExpression(const QString &propertyName)
if (!m_selectedNode.isValid())
return;
RewriterTransaction transaction = beginRewriterTransaction(QByteArrayLiteral("PropertyEditorView::changeExpression"));
try {
executeInTransaction("PropertyEditorView::changeExpression", [this, name](){
PropertyName underscoreName(name);
underscoreName.replace('.', '_');
@@ -253,7 +251,6 @@ void PropertyEditorView::changeExpression(const QString &propertyName)
if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "QColor") {
if (QColor(value->expression().remove('"')).isValid()) {
qmlObjectNode.setVariantProperty(name, QColor(value->expression().remove('"')));
transaction.commit(); //committing in the try block
return;
}
} else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "bool") {
@@ -263,7 +260,6 @@ void PropertyEditorView::changeExpression(const QString &propertyName)
qmlObjectNode.setVariantProperty(name, true);
else
qmlObjectNode.setVariantProperty(name, false);
transaction.commit(); //committing in the try block
return;
}
} else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "int") {
@@ -271,7 +267,6 @@ void PropertyEditorView::changeExpression(const QString &propertyName)
int intValue = value->expression().toInt(&ok);
if (ok) {
qmlObjectNode.setVariantProperty(name, intValue);
transaction.commit(); //committing in the try block
return;
}
} else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "qreal") {
@@ -279,7 +274,6 @@ void PropertyEditorView::changeExpression(const QString &propertyName)
qreal realValue = value->expression().toDouble(&ok);
if (ok) {
qmlObjectNode.setVariantProperty(name, realValue);
transaction.commit(); //committing in the try block
return;
}
}
@@ -291,12 +285,7 @@ void PropertyEditorView::changeExpression(const QString &propertyName)
if (qmlObjectNode.expression(name) != value->expression() || !qmlObjectNode.propertyAffectedByCurrentState(name))
qmlObjectNode.setBindingProperty(name, value->expression());
transaction.commit(); //committing in the try block
}
catch (const RewritingException &e) {
e.showException();
}
}); /* end of transaction */
}
void PropertyEditorView::exportPopertyAsAlias(const QString &name)
@@ -310,9 +299,7 @@ void PropertyEditorView::exportPopertyAsAlias(const QString &name)
if (!m_selectedNode.isValid())
return;
RewriterTransaction transaction = beginRewriterTransaction(QByteArrayLiteral("PropertyEditorView::exportPopertyAsAlias"));
try {
executeInTransaction("PropertyEditorView::exportPopertyAsAlias", [this, name](){
const QString id = m_selectedNode.validId();
QString upperCasePropertyName = name;
upperCasePropertyName.replace(0, 1, upperCasePropertyName.at(0).toUpper());
@@ -326,11 +313,7 @@ void PropertyEditorView::exportPopertyAsAlias(const QString &name)
return;
}
rootModelNode().bindingProperty(propertyName).setDynamicTypeNameAndExpression("alias", id + "." + name);
transaction.commit(); //committing in the try block
} catch (const RewritingException &e) {
e.showException();
}
});
}
void PropertyEditorView::removeAliasExport(const QString &name)
@@ -344,9 +327,7 @@ void PropertyEditorView::removeAliasExport(const QString &name)
if (!m_selectedNode.isValid())
return;
RewriterTransaction transaction = beginRewriterTransaction(QByteArrayLiteral("PropertyEditorView::exportPopertyAsAlias"));
try {
executeInTransaction("PropertyEditorView::exportPopertyAsAlias", [this, name](){
const QString id = m_selectedNode.validId();
for (const BindingProperty &property : rootModelNode().bindingProperties())
@@ -354,10 +335,7 @@ void PropertyEditorView::removeAliasExport(const QString &name)
rootModelNode().removeProperty(property.name());
break;
}
transaction.commit(); //committing in the try block
} catch (const RewritingException &e) {
e.showException();
}
});
}
bool PropertyEditorView::locked() const
@@ -575,10 +553,11 @@ void PropertyEditorView::modelAttached(Model *model)
m_locked = true;
if (!m_setupCompleted) {
m_singleShotTimer->setSingleShot(true);
m_singleShotTimer->setInterval(100);
connect(m_singleShotTimer, &QTimer::timeout, this, &PropertyEditorView::setupPanes);
m_singleShotTimer->start();
QTimer::singleShot(50, this, [this]{
PropertyEditorView::setupPanes();
/* workaround for QTBUG-75847 */
reloadQml();
});
}
m_locked = false;
@@ -681,6 +660,9 @@ void PropertyEditorView::instanceInformationsChanged(const QMultiHash<ModelNode,
if (!m_selectedNode.isValid())
return;
if (!m_qmlBackEndForCurrentType)
return;
m_locked = true;
QList<InformationName> informationNameList = informationChangedHash.values(m_selectedNode);
if (informationNameList.contains(Anchor)

View File

@@ -292,9 +292,9 @@ void QmlAnchorBindingProxy::setDefaultRelativeRightTarget()
}
}
RewriterTransaction QmlAnchorBindingProxy::beginRewriterTransaction(const QByteArray &identifier)
bool QmlAnchorBindingProxy::executeInTransaction(const QByteArray &identifier, const AbstractView::OperationBlock &lambda)
{
return m_qmlItemNode.modelNode().view()->beginRewriterTransaction(identifier);
return m_qmlItemNode.modelNode().view()->executeInTransaction(identifier, lambda);
}
bool QmlAnchorBindingProxy::hasParent() const
@@ -361,20 +361,11 @@ void QmlAnchorBindingProxy::setTopTarget(const QString &target)
if (!newTarget.isValid())
return;
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setTopTarget"));
executeInTransaction("QmlAnchorBindingProxy::setTopTarget", [this, newTarget](){
m_topTarget = newTarget;
setDefaultRelativeTopTarget();
anchorTop();
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
emit topTargetChanged();
}
@@ -393,18 +384,12 @@ void QmlAnchorBindingProxy::setBottomTarget(const QString &target)
if (!newTarget.isValid())
return;
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setBottomTarget"));
executeInTransaction("QmlAnchorBindingProxy::setBottomTarget", [this, newTarget](){
m_bottomTarget = newTarget;
setDefaultRelativeBottomTarget();
anchorBottom();
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
emit bottomTargetChanged();
}
@@ -422,18 +407,11 @@ void QmlAnchorBindingProxy::setLeftTarget(const QString &target)
if (!newTarget.isValid())
return;
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setLeftTarget"));
executeInTransaction("QmlAnchorBindingProxy::setLeftTarget", [this, newTarget](){
m_leftTarget = newTarget;
setDefaultRelativeLeftTarget();
anchorLeft();
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
emit leftTargetChanged();
}
@@ -451,18 +429,11 @@ void QmlAnchorBindingProxy::setRightTarget(const QString &target)
if (!newTarget.isValid())
return;
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setRightTarget"));
executeInTransaction("QmlAnchorBindingProxy::setRightTarget", [this, newTarget](){
m_rightTarget = newTarget;
setDefaultRelativeRightTarget();
anchorRight();
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
emit rightTargetChanged();
}
@@ -480,17 +451,10 @@ void QmlAnchorBindingProxy::setVerticalTarget(const QString &target)
if (!newTarget.isValid())
return;
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setVerticalTarget"));
executeInTransaction("QmlAnchorBindingProxy::setVerticalTarget", [this, newTarget](){
m_verticalTarget = newTarget;
anchorVertical();
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
emit verticalTargetChanged();
}
@@ -508,17 +472,10 @@ void QmlAnchorBindingProxy::setHorizontalTarget(const QString &target)
if (!newTarget.isValid())
return;
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setHorizontalTarget"));
executeInTransaction("QmlAnchorBindingProxy::setHorizontalTarget", [this, newTarget](){
m_horizontalTarget = newTarget;
anchorHorizontal();\
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
anchorHorizontal();
});
emit horizontalTargetChanged();
}
@@ -531,18 +488,10 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetTop(QmlAnchorBindingProxy::Re
if (target == m_relativeTopTarget)
return;
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetTop"));
executeInTransaction("QmlAnchorBindingProxy::setRelativeAnchorTargetTop", [this, target](){
m_relativeTopTarget = target;
anchorTop();
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
emit relativeAnchorTargetTopChanged();
}
@@ -555,19 +504,10 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetBottom(QmlAnchorBindingProxy:
if (target == m_relativeBottomTarget)
return;
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetBottom"));
executeInTransaction("QmlAnchorBindingProxy::setRelativeAnchorTargetBottom", [this, target](){
m_relativeBottomTarget = target;
anchorBottom();
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
emit relativeAnchorTargetBottomChanged();
}
@@ -580,18 +520,11 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetLeft(QmlAnchorBindingProxy::R
if (target == m_relativeLeftTarget)
return;
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetLeft"));
executeInTransaction("QmlAnchorBindingProxy::setRelativeAnchorTargetLeft", [this, target](){
m_relativeLeftTarget = target;
anchorLeft();
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
emit relativeAnchorTargetLeftChanged();
}
@@ -604,18 +537,10 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetRight(QmlAnchorBindingProxy::
if (target == m_relativeRightTarget)
return;
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetRight"));
executeInTransaction("QmlAnchorBindingProxy::setRelativeAnchorTargetRight", [this, target](){
m_relativeRightTarget = target;
anchorRight();
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
emit relativeAnchorTargetRightChanged();
@@ -629,18 +554,11 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetVertical(QmlAnchorBindingProx
if (target == m_relativeVerticalTarget)
return;
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetVertical"));
executeInTransaction("QmlAnchorBindingProxy::setRelativeAnchorTargetVertical", [this, target](){
m_relativeVerticalTarget = target;
anchorVertical();
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
emit relativeAnchorTargetVerticalChanged();
}
@@ -653,18 +571,10 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetHorizontal(QmlAnchorBindingPr
if (target == m_relativeHorizontalTarget)
return;
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetHorizontal"));
executeInTransaction("QmlAnchorBindingProxy::setRelativeAnchorTargetHorizontal", [this, target](){
m_relativeHorizontalTarget = target;
anchorHorizontal();
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
emit relativeAnchorTargetHorizontalChanged();
}
@@ -709,12 +619,10 @@ int QmlAnchorBindingProxy::indexOfPossibleTargetItem(const QString &targetName)
return possibleTargetItems().indexOf(targetName);
}
void QmlAnchorBindingProxy::resetLayout() {
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::resetLayout"));
void QmlAnchorBindingProxy::resetLayout()
{
executeInTransaction("QmlAnchorBindingProxy::resetLayout", [this](){
m_qmlItemNode.anchors().removeAnchors();
m_qmlItemNode.anchors().removeMargins();
@@ -722,11 +630,7 @@ void QmlAnchorBindingProxy::resetLayout() {
restoreProperty(modelNode(), "y");
restoreProperty(modelNode(), "width");
restoreProperty(modelNode(), "height");
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
emit topAnchorChanged();
emit bottomAnchorChanged();
@@ -743,10 +647,7 @@ void QmlAnchorBindingProxy::setBottomAnchor(bool anchor)
if (bottomAnchored() == anchor)
return;
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setBottomAnchor"));
executeInTransaction("QmlAnchorBindingProxy::setBottomAnchor", [this, anchor](){
if (!anchor) {
removeBottomAnchor();
} else {
@@ -756,10 +657,7 @@ void QmlAnchorBindingProxy::setBottomAnchor(bool anchor)
backupPropertyAndRemove(modelNode(), "height");
}
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
emit relativeAnchorTargetBottomChanged();
emit bottomAnchorChanged();
@@ -776,10 +674,8 @@ void QmlAnchorBindingProxy::setLeftAnchor(bool anchor)
if (leftAnchored() == anchor)
return;
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setLeftAnchor"));
executeInTransaction("QmlAnchorBindingProxy::setLeftAnchor", [this, anchor](){
if (!anchor) {
removeLeftAnchor();
} else {
@@ -791,10 +687,7 @@ void QmlAnchorBindingProxy::setLeftAnchor(bool anchor)
backupPropertyAndRemove(modelNode(), "width");
}
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
emit relativeAnchorTargetLeftChanged();
emit leftAnchorChanged();
@@ -810,10 +703,7 @@ void QmlAnchorBindingProxy::setRightAnchor(bool anchor)
if (rightAnchored() == anchor)
return;
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setRightAnchor"));
executeInTransaction("QmlAnchorBindingProxy::setRightAnchor", [this, anchor](){
if (!anchor) {
removeRightAnchor();
} else {
@@ -824,10 +714,7 @@ void QmlAnchorBindingProxy::setRightAnchor(bool anchor)
backupPropertyAndRemove(modelNode(), "width");
}
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
emit relativeAnchorTargetRightChanged();
emit rightAnchorChanged();
@@ -1026,10 +913,7 @@ void QmlAnchorBindingProxy::setTopAnchor(bool anchor)
if (topAnchored() == anchor)
return;
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setTopAnchor"));
executeInTransaction("QmlAnchorBindingProxy::setTopAnchor", [this, anchor](){
if (!anchor) {
removeTopAnchor();
} else {
@@ -1040,10 +924,7 @@ void QmlAnchorBindingProxy::setTopAnchor(bool anchor)
if (bottomAnchored())
backupPropertyAndRemove(modelNode(), "height");
}
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
emit relativeAnchorTargetTopChanged();
emit topAnchorChanged();
@@ -1052,70 +933,44 @@ void QmlAnchorBindingProxy::setTopAnchor(bool anchor)
}
void QmlAnchorBindingProxy::removeTopAnchor() {
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::removeTopAnchor"));
executeInTransaction("QmlAnchorBindingProxy::removeTopAnchor", [this](){
m_qmlItemNode.anchors().removeAnchor(AnchorLineTop);
m_qmlItemNode.anchors().removeMargin(AnchorLineTop);
restoreProperty(modelNode(), "y");
restoreProperty(modelNode(), "height");
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
}
void QmlAnchorBindingProxy::removeBottomAnchor() {
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::removeBottomAnchor"));
void QmlAnchorBindingProxy::removeBottomAnchor()
{
executeInTransaction("QmlAnchorBindingProxy::removeBottomAnchor", [this](){
m_qmlItemNode.anchors().removeAnchor(AnchorLineBottom);
m_qmlItemNode.anchors().removeMargin(AnchorLineBottom);
restoreProperty(modelNode(), "height");
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
}
void QmlAnchorBindingProxy::removeLeftAnchor() {
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::removeLeftAnchor"));
void QmlAnchorBindingProxy::removeLeftAnchor()
{
executeInTransaction("QmlAnchorBindingProxy::removeLeftAnchor", [this](){
m_qmlItemNode.anchors().removeAnchor(AnchorLineLeft);
m_qmlItemNode.anchors().removeMargin(AnchorLineLeft);
restoreProperty(modelNode(), "x");
restoreProperty(modelNode(), "width");
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
}
void QmlAnchorBindingProxy::removeRightAnchor() {
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::removeRightAnchor"));
void QmlAnchorBindingProxy::removeRightAnchor()
{
executeInTransaction("QmlAnchorBindingProxy::removeRightAnchor", [this](){
m_qmlItemNode.anchors().removeAnchor(AnchorLineRight);
m_qmlItemNode.anchors().removeMargin(AnchorLineRight);
restoreProperty(modelNode(), "width");
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
}
void QmlAnchorBindingProxy::setVerticalCentered(bool centered)
@@ -1128,10 +983,7 @@ void QmlAnchorBindingProxy::setVerticalCentered(bool centered)
m_locked = true;
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setVerticalCentered"));
executeInTransaction("QmlAnchorBindingProxy::setVerticalCentered", [this, centered](){
if (!centered) {
m_qmlItemNode.anchors().removeAnchor(AnchorLineVerticalCenter);
m_qmlItemNode.anchors().removeMargin(AnchorLineVerticalCenter);
@@ -1141,10 +993,7 @@ void QmlAnchorBindingProxy::setVerticalCentered(bool centered)
anchorVertical();
}
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
m_locked = false;
emit relativeAnchorTargetVerticalChanged();
@@ -1161,10 +1010,7 @@ void QmlAnchorBindingProxy::setHorizontalCentered(bool centered)
m_locked = true;
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setHorizontalCentered"));
executeInTransaction("QmlAnchorBindingProxy::setHorizontalCentered", [this, centered](){
if (!centered) {
m_qmlItemNode.anchors().removeAnchor(AnchorLineHorizontalCenter);
m_qmlItemNode.anchors().removeMargin(AnchorLineHorizontalCenter);
@@ -1173,11 +1019,7 @@ void QmlAnchorBindingProxy::setHorizontalCentered(bool centered)
anchorHorizontal();
}
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
m_locked = false;
emit relativeAnchorTargetHorizontalChanged();
@@ -1256,12 +1098,7 @@ bool QmlAnchorBindingProxy::horizontalCentered()
void QmlAnchorBindingProxy::fill()
{
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::fill"));
executeInTransaction("QmlAnchorBindingProxy::fill", [this](){
backupPropertyAndRemove(modelNode(), "x");
backupPropertyAndRemove(modelNode(), "y");
backupPropertyAndRemove(modelNode(), "width");
@@ -1277,10 +1114,7 @@ void QmlAnchorBindingProxy::fill()
m_qmlItemNode.anchors().removeMargin(AnchorLineTop);
m_qmlItemNode.anchors().removeMargin(AnchorLineBottom);
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
emit topAnchorChanged();
emit bottomAnchorChanged();

View File

@@ -210,7 +210,7 @@ private:
void setDefaultRelativeLeftTarget();
void setDefaultRelativeRightTarget();
RewriterTransaction beginRewriterTransaction(const QByteArray &identifier);
bool executeInTransaction(const QByteArray &identifier, const AbstractView::OperationBlock &lambda);
QmlItemNode targetIdToNode(const QString &id) const;
QString idForNode(const QmlItemNode &qmlItemNode) const;

View File

@@ -39,6 +39,8 @@
#include <QObject>
#include <QPointer>
#include <functional>
QT_BEGIN_NAMESPACE
class QStyle;
class QToolButton;
@@ -263,6 +265,9 @@ public:
void activateTimelineRecording(const ModelNode &timeline);
void deactivateTimelineRecording();
using OperationBlock = std::function<void()>;
bool executeInTransaction(const QByteArray &identifier, const OperationBlock &lambda);
protected:
void setModel(Model * model);
void removeModel();

View File

@@ -616,6 +616,20 @@ void AbstractView::deactivateTimelineRecording()
model()->d->notifyCurrentTimelineChanged(ModelNode());
}
bool AbstractView::executeInTransaction(const QByteArray &identifier, const AbstractView::OperationBlock &lambda)
{
try {
RewriterTransaction transaction = beginRewriterTransaction(identifier);
lambda();
transaction.commit();
} catch (const Exception &e) {
e.showException();
return false;
}
return true;
}
QList<ModelNode> AbstractView::allModelNodes() const
{
return toModelNodeList(model()->d->allNodes());

View File

@@ -178,9 +178,7 @@ void ModelMerger::replaceModel(const ModelNode &modelNode)
view()->model()->changeImports(modelNode.model()->imports(), {});
view()->model()->setFileUrl(modelNode.model()->fileUrl());
try {
RewriterTransaction transaction(view()->beginRewriterTransaction(QByteArrayLiteral("ModelMerger::replaceModel")));
view()->executeInTransaction("ModelMerger::replaceModel", [this, modelNode](){
ModelNode rootNode(view()->rootModelNode());
foreach (const PropertyName &propertyName, rootNode.propertyNames())
@@ -196,11 +194,7 @@ void ModelMerger::replaceModel(const ModelNode &modelNode)
syncNodeProperties(rootNode, modelNode, idRenamingHash, view());
syncNodeListProperties(rootNode, modelNode, idRenamingHash, view());
m_view->changeRootNodeType(modelNode.type(), modelNode.majorVersion(), modelNode.minorVersion());
transaction.commit();
} catch (const RewritingException &e) {
qWarning() << e.description(); //silent error
}
});
}
} //namespace QmlDesigner

View File

@@ -161,7 +161,7 @@ void QmlAnchors::setAnchor(AnchorLineType sourceAnchorLine,
const QmlItemNode &targetQmlItemNode,
AnchorLineType targetAnchorLine)
{
RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchors::setAnchor"));
qmlItemNode().view()->executeInTransaction("QmlAnchors::setAnchor", [this, sourceAnchorLine, targetQmlItemNode, targetAnchorLine](){
if (qmlItemNode().isInBaseState()) {
if ((qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLineFill))
|| ((qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn") && (sourceAnchorLine & AnchorLineCenter)))) {
@@ -177,6 +177,7 @@ void QmlAnchors::setAnchor(AnchorLineType sourceAnchorLine,
targetExpression = targetExpression + QLatin1Char('.') + QString::fromLatin1(lineTypeToString(targetAnchorLine));
qmlItemNode().modelNode().bindingProperty(propertyName).setExpression(targetExpression);
}
});
}
bool detectHorizontalCycle(const ModelNode &node, QList<ModelNode> knownNodeList)
@@ -315,7 +316,7 @@ AnchorLine QmlAnchors::instanceAnchor(AnchorLineType sourceAnchorLine) const
void QmlAnchors::removeAnchor(AnchorLineType sourceAnchorLine)
{
RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchors::removeAnchor"));
qmlItemNode().view()->executeInTransaction("QmlAnchors::removeAnchor", [this, sourceAnchorLine](){
if (qmlItemNode().isInBaseState()) {
const PropertyName propertyName = anchorPropertyName(sourceAnchorLine);
if (qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLineFill)) {
@@ -333,11 +334,12 @@ void QmlAnchors::removeAnchor(AnchorLineType sourceAnchorLine)
qmlItemNode().modelNode().removeProperty(propertyName);
}
});
}
void QmlAnchors::removeAnchors()
{
RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchors::removeAnchors"));
qmlItemNode().view()->executeInTransaction("QmlAnchors::removeAnchors", [this](){
if (qmlItemNode().nodeInstance().hasAnchor("anchors.fill"))
qmlItemNode().modelNode().removeProperty("anchors.fill");
if (qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn"))
@@ -356,6 +358,7 @@ void QmlAnchors::removeAnchors()
qmlItemNode().modelNode().removeProperty("anchors.verticalCenter");
if (qmlItemNode().nodeInstance().hasAnchor("anchors.baseline"))
qmlItemNode().modelNode().removeProperty("anchors.baseline");
});
}
bool QmlAnchors::instanceHasAnchor(AnchorLineType sourceAnchorLine) const
@@ -532,13 +535,14 @@ void QmlAnchors::removeMargin(AnchorLineType sourceAnchorLineType)
void QmlAnchors::removeMargins()
{
RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchors::removeMargins"));
qmlItemNode().view()->executeInTransaction("QmlAnchors::removeMargins", [this](){
removeMargin(AnchorLineLeft);
removeMargin(AnchorLineRight);
removeMargin(AnchorLineTop);
removeMargin(AnchorLineBottom);
removeMargin(AnchorLineHorizontalCenter);
removeMargin(AnchorLineVerticalCenter);
});
}
void QmlAnchors::fill()

View File

@@ -102,9 +102,7 @@ QmlItemNode QmlItemNode::createQmlItemNode(AbstractView *view, const ItemLibrary
{
QmlItemNode newQmlItemNode;
try {
RewriterTransaction transaction = view->beginRewriterTransaction(QByteArrayLiteral("QmlItemNode::createQmlItemNode"));
view->executeInTransaction("QmlItemNode::createQmlItemNode", [=, &newQmlItemNode, &parentproperty](){
NodeMetaInfo metaInfo = view->model()->metaInfo(itemLibraryEntry.typeName());
int minorVersion = metaInfo.minorVersion();
@@ -139,7 +137,7 @@ QmlItemNode QmlItemNode::createQmlItemNode(AbstractView *view, const ItemLibrary
parentproperty.reparentHere(newQmlItemNode);
if (!newQmlItemNode.isValid())
return newQmlItemNode;
return;
newQmlItemNode.setId(view->generateNewId(itemLibraryEntry.name()));
@@ -150,10 +148,7 @@ QmlItemNode QmlItemNode::createQmlItemNode(AbstractView *view, const ItemLibrary
newQmlItemNode.modelNode().variantProperty(propertyBindingEntry.first).setEnumeration(propertyBindingEntry.second.toUtf8());
Q_ASSERT(newQmlItemNode.isValid());
}
catch (const RewritingException &e) {
e.showException();
}
});
Q_ASSERT(newQmlItemNode.isValid());
@@ -174,10 +169,8 @@ QmlItemNode QmlItemNode::createQmlItemNodeFromImage(AbstractView *view, const QS
{
QmlItemNode newQmlItemNode;
if (parentproperty.isValid()) {
RewriterTransaction transaction = view->beginRewriterTransaction(QByteArrayLiteral("QmlItemNode::createQmlItemNodeFromImage"));
if (view->model()->hasNodeMetaInfo("QtQuick.Image")) {
if (parentproperty.isValid() && view->model()->hasNodeMetaInfo("QtQuick.Image")) {
view->executeInTransaction("QmlItemNode::createQmlItemNodeFromImage", [=, &newQmlItemNode, &parentproperty](){
NodeMetaInfo metaInfo = view->model()->metaInfo("QtQuick.Image");
QList<QPair<PropertyName, QVariant> > propertyPairList;
propertyPairList.append({PropertyName("x"), QVariant(qRound(position.x()))});
@@ -200,8 +193,7 @@ QmlItemNode QmlItemNode::createQmlItemNodeFromImage(AbstractView *view, const QS
newQmlItemNode.modelNode().variantProperty("fillMode").setEnumeration("Image.PreserveAspectFit");
Q_ASSERT(newQmlItemNode.isValid());
}
Q_ASSERT(newQmlItemNode.isValid());
});
}
return newQmlItemNode;

View File

@@ -232,8 +232,6 @@ void BackendModel::addNewBackend()
Import import = Import::createLibraryImport(importSplit.constFirst(), importSplit.constLast());
try {
/* We cannot add an import and add a node from that import in a single transaction.
* We need the import to have the meta info available.
*/
@@ -247,12 +245,11 @@ void BackendModel::addNewBackend()
QTC_ASSERT(metaInfo.isValid(), return);
int minorVersion = metaInfo.minorVersion();
int majorVersion = metaInfo.majorVersion();
/* Add a property for non singleton types. For singletons just adding the import is enough. */
if (!dialog.isSingleton()) {
RewriterTransaction transaction = m_connectionView->beginRewriterTransaction("BackendModel::addNewBackend");
m_connectionView->executeInTransaction("BackendModel::addNewBackend", [=, &dialog](){
int minorVersion = metaInfo.minorVersion();
int majorVersion = metaInfo.majorVersion();
if (dialog.localDefinition()) {
ModelNode newNode = m_connectionView->createModelNode(metaInfo.typeName(), majorVersion, minorVersion);
@@ -263,14 +260,9 @@ void BackendModel::addNewBackend()
m_connectionView->rootModelNode().bindingProperty(
propertyName.toUtf8()).setDynamicTypeNameAndExpression(typeName.toUtf8(), "null");
}
transaction.commit();
}
} catch (const Exception &e) {
e.showException();
});
}
}
resetModel();
}
@@ -279,11 +271,9 @@ void BackendModel::updatePropertyName(int rowNumber)
const PropertyName newName = data(index(rowNumber, 1)).toString().toUtf8();
const PropertyName oldName = data(index(rowNumber, 0), Qt::UserRole + 1).toString().toUtf8();
m_connectionView->executeInTransaction("BackendModel::updatePropertyName", [this, newName, oldName](){
ModelNode rootModelNode = m_connectionView->rootModelNode();
try {
RewriterTransaction transaction = m_connectionView->beginRewriterTransaction("BackendModel::updatePropertyName");
if (rootModelNode.property(oldName).isNodeProperty()) {
const TypeName typeName = rootModelNode.nodeProperty(oldName).dynamicTypeName();
@@ -306,12 +296,7 @@ void BackendModel::updatePropertyName(int rowNumber)
qWarning() << Q_FUNC_INFO << oldName << newName << "failed...";
QTC_ASSERT(false, return);
}
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
}
void BackendModel::handleDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)

View File

@@ -290,8 +290,6 @@ void BindingModel::addModelNode(const ModelNode &modelNode)
void BindingModel::updateExpression(int row)
{
BindingProperty bindingProperty = bindingPropertyForRow(row);
const QString sourceNode = data(index(row, SourceModelNodeRow)).toString().trimmed();
const QString sourceProperty = data(index(row, SourcePropertyNameRow)).toString().trimmed();
@@ -302,15 +300,10 @@ void BindingModel::updateExpression(int row)
expression = sourceNode + QLatin1String(".") + sourceProperty;
}
RewriterTransaction transaction =
connectionView()->beginRewriterTransaction(QByteArrayLiteral("BindingModel::updateExpression"));
try {
connectionView()->executeInTransaction("BindingModel::updateExpression", [this, row, expression](){
BindingProperty bindingProperty = bindingPropertyForRow(row);
bindingProperty.setExpression(expression.trimmed());
transaction.commit(); //committing in the try block
} catch (Exception &e) {
m_exceptionError = e.description();
QTimer::singleShot(200, this, &BindingModel::handleException);
}
});
}
void BindingModel::updatePropertyName(int rowNumber)

View File

@@ -182,26 +182,21 @@ void ConnectionModel::updateSource(int row)
void ConnectionModel::updateSignalName(int rowNumber)
{
SignalHandlerProperty signalHandlerProperty = signalHandlerPropertyForRow(rowNumber);
const PropertyName newName = data(index(rowNumber, TargetPropertyNameRow)).toString().toUtf8();
const QString source = signalHandlerProperty.source();
ModelNode connectionNode = signalHandlerProperty.parentModelNode();
const PropertyName newName = data(index(rowNumber, TargetPropertyNameRow)).toString().toUtf8();
if (!newName.isEmpty()) {
RewriterTransaction transaction =
connectionView()->beginRewriterTransaction(QByteArrayLiteral("ConnectionModel::updateSignalName"));
try {
connectionView()->executeInTransaction("ConnectionModel::updateSignalName", [=, &connectionNode](){
const QString source = signalHandlerProperty.source();
connectionNode.signalHandlerProperty(newName).setSource(source);
connectionNode.removeProperty(signalHandlerProperty.name());
transaction.commit(); //committing in the try block
} catch (Exception &e) { //better save then sorry
QMessageBox::warning(nullptr, tr("Error"), e.description());
}
});
QStandardItem* idItem = item(rowNumber, 0);
SignalHandlerProperty newSignalHandlerProperty = connectionNode.signalHandlerProperty(newName);
updateCustomData(idItem, newSignalHandlerProperty);
} else {
qWarning() << "BindingModel::updatePropertyName invalid property name";
}
@@ -214,14 +209,9 @@ void ConnectionModel::updateTargetNode(int rowNumber)
ModelNode connectionNode = signalHandlerProperty.parentModelNode();
if (!newTarget.isEmpty()) {
RewriterTransaction transaction =
connectionView()->beginRewriterTransaction(QByteArrayLiteral("ConnectionModel::updateTargetNode"));
try {
connectionView()->executeInTransaction("ConnectionModel::updateTargetNode", [= ,&connectionNode](){
connectionNode.bindingProperty("target").setExpression(newTarget);
transaction.commit(); //committing in the try block
} catch (Exception &e) { //better save then sorry
QMessageBox::warning(nullptr, tr("Error"), e.description());
}
});
QStandardItem* idItem = item(rowNumber, 0);
updateCustomData(idItem, signalHandlerProperty);
@@ -259,9 +249,7 @@ void ConnectionModel::addConnection()
NodeMetaInfo nodeMetaInfo = connectionView()->model()->metaInfo("QtQuick.Connections");
if (nodeMetaInfo.isValid()) {
RewriterTransaction transaction =
connectionView()->beginRewriterTransaction(QByteArrayLiteral("ConnectionModel::addConnection"));
try {
connectionView()->executeInTransaction("ConnectionModel::addConnection", [=](){
ModelNode newNode = connectionView()->createModelNode("QtQuick.Connections",
nodeMetaInfo.majorVersion(),
nodeMetaInfo.minorVersion());
@@ -276,10 +264,7 @@ void ConnectionModel::addConnection()
} else {
newNode.bindingProperty("target").setExpression(QLatin1String("parent"));
}
transaction.commit();
} catch (Exception &e) { //better save then sorry
QMessageBox::warning(nullptr, tr("Error"), e.description());
}
});
}
}
}

View File

@@ -464,19 +464,16 @@ void DynamicPropertiesModel::updatePropertyName(int rowNumber)
BindingProperty bindingProperty = bindingPropertyForRow(rowNumber);
if (bindingProperty.isBindingProperty()) {
const QString expression = bindingProperty.expression();
const PropertyName dynamicPropertyType = bindingProperty.dynamicTypeName();
ModelNode targetNode = bindingProperty.parentModelNode();
RewriterTransaction transaction = connectionView()->beginRewriterTransaction(QByteArrayLiteral("DynamicPropertiesModel::updatePropertyName"));
try {
if (bindingProperty.isBindingProperty()) {
connectionView()->executeInTransaction("DynamicPropertiesModel::updatePropertyName", [bindingProperty, newName, &targetNode](){
const QString expression = bindingProperty.expression();
const PropertyName dynamicPropertyType = bindingProperty.dynamicTypeName();
targetNode.bindingProperty(newName).setDynamicTypeNameAndExpression(dynamicPropertyType, expression);
targetNode.removeProperty(bindingProperty.name());
transaction.commit(); //committing in the try block
} catch (Exception &e) { //better save then sorry
QMessageBox::warning(nullptr, tr("Error"), e.description());
}
});
updateCustomData(rowNumber, targetNode.bindingProperty(newName));
return;
@@ -489,14 +486,10 @@ void DynamicPropertiesModel::updatePropertyName(int rowNumber)
const PropertyName dynamicPropertyType = variantProperty.dynamicTypeName();
ModelNode targetNode = variantProperty.parentModelNode();
RewriterTransaction transaction = connectionView()->beginRewriterTransaction(QByteArrayLiteral("DynamicPropertiesModel::updatePropertyName"));
try {
connectionView()->executeInTransaction("DynamicPropertiesModel::updatePropertyName", [=](){
targetNode.variantProperty(newName).setDynamicTypeNameAndValue(dynamicPropertyType, value);
targetNode.removeProperty(variantProperty.name());
transaction.commit(); //committing in the try block
} catch (Exception &e) { //better save then sorry
QMessageBox::warning(nullptr, tr("Error"), e.description());
}
});
updateCustomData(rowNumber, targetNode.variantProperty(newName));
}
@@ -519,14 +512,10 @@ void DynamicPropertiesModel::updatePropertyType(int rowNumber)
const PropertyName propertyName = bindingProperty.name();
ModelNode targetNode = bindingProperty.parentModelNode();
RewriterTransaction transaction = connectionView()->beginRewriterTransaction(QByteArrayLiteral("DynamicPropertiesModel::updatePropertyType"));
try {
connectionView()->executeInTransaction("DynamicPropertiesModel::updatePropertyType", [=](){
targetNode.removeProperty(bindingProperty.name());
targetNode.bindingProperty(propertyName).setDynamicTypeNameAndExpression(newType, expression);
transaction.commit(); //committing in the try block
} catch (Exception &e) { //better save then sorry
QMessageBox::warning(nullptr, tr("Error"), e.description());
}
});
updateCustomData(rowNumber, targetNode.bindingProperty(propertyName));
return;
@@ -539,18 +528,14 @@ void DynamicPropertiesModel::updatePropertyType(int rowNumber)
ModelNode targetNode = variantProperty.parentModelNode();
const PropertyName propertyName = variantProperty.name();
RewriterTransaction transaction = connectionView()->beginRewriterTransaction(QByteArrayLiteral("DynamicPropertiesModel::updatePropertyType"));
try {
connectionView()->executeInTransaction("DynamicPropertiesModel::updatePropertyType", [=](){
targetNode.removeProperty(variantProperty.name());
if (newType == "alias") { //alias properties have to be bindings
targetNode.bindingProperty(propertyName).setDynamicTypeNameAndExpression(newType, QLatin1String("none.none"));
} else {
targetNode.variantProperty(propertyName).setDynamicTypeNameAndValue(newType, convertVariantForTypeName(value, newType));
}
transaction.commit(); //committing in the try block
} catch (Exception &e) { //better save then sorry
QMessageBox::warning(nullptr, tr("Error"), e.description());
}
});
updateCustomData(rowNumber, targetNode.variantProperty(propertyName));

View File

@@ -133,8 +133,7 @@ void PathItem::writePathToProperty()
ModelNode pathNode = pathModelNode(formEditorItem());
RewriterTransaction rewriterTransaction = pathNode.view()->beginRewriterTransaction(QByteArrayLiteral("PathItem::writePathToProperty"));
pathNode.view()->executeInTransaction("PathItem::writePathToProperty", [this, &pathNode](){
QList<ModelNode> pathSegmentNodes = pathNode.nodeListProperty("pathElements").toModelNodeList();
foreach (ModelNode pathSegment, pathSegmentNodes)
@@ -159,19 +158,15 @@ void PathItem::writePathToProperty()
writePathAttributes(pathNode, m_lastAttributes);
writePathPercent(pathNode, m_lastPercent);
}
rewriterTransaction.commit();
});
}
void PathItem::writePathAsCubicSegmentsOnly()
{
try {
PathUpdateDisabler pathUpdateDisabler(this);
ModelNode pathNode = pathModelNode(formEditorItem());
RewriterTransaction rewriterTransaction =
pathNode.view()->beginRewriterTransaction(QByteArrayLiteral("PathItem::writePathAsCubicSegmentsOnly"));
pathNode.view()->executeInTransaction("PathItem::writePathAsCubicSegmentsOnly", [this, &pathNode](){
QList<ModelNode> pathSegmentNodes = pathNode.nodeListProperty("pathElements").toModelNodeList();
@@ -192,11 +187,7 @@ void PathItem::writePathAsCubicSegmentsOnly()
writePathAttributes(pathNode, m_lastAttributes);
writePathPercent(pathNode, m_lastPercent);
}
rewriterTransaction.commit();
} catch (const RewritingException &e) {
e.showException();
}
});
}
void PathItem::setFormEditorItem(FormEditorItem *formEditorItem)

View File

@@ -202,22 +202,13 @@ bool EasingCurveDialog::apply()
msgBox.exec();
return false;
}
try {
AbstractView *view = m_frames.first().view();
RewriterTransaction transaction(view->beginRewriterTransaction("EasingCurveDialog::apply"));
return view->executeInTransaction("EasingCurveDialog::apply", [this, view](){
auto expression = m_splineEditor->easingCurve().toString();
for (const auto &frame : m_frames)
frame.bindingProperty("easing.bezierCurve").setExpression(expression);
transaction.commit();
return true;
} catch (const RewritingException &e) {
e.showException();
}
return false;
});
}
void EasingCurveDialog::textChanged()

View File

@@ -48,28 +48,18 @@ TimelineActions::TimelineActions() = default;
void TimelineActions::deleteAllKeyframesForTarget(const ModelNode &targetNode,
const QmlTimeline &timeline)
{
try {
RewriterTransaction transaction(targetNode.view()->beginRewriterTransaction(
"TimelineActions::deleteAllKeyframesForTarget"));
targetNode.view()->executeInTransaction("TimelineActions::deleteAllKeyframesForTarget", [=](){
if (timeline.isValid()) {
for (auto frames : timeline.keyframeGroupsForTarget(targetNode))
frames.destroy();
}
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
}
void TimelineActions::insertAllKeyframesForTarget(const ModelNode &targetNode,
const QmlTimeline &timeline)
{
try {
RewriterTransaction transaction(targetNode.view()->beginRewriterTransaction(
"TimelineGraphicsScene::insertAllKeyframesForTarget"));
targetNode.view()->executeInTransaction("TimelineActions::insertAllKeyframesForTarget", [=](){
auto object = QmlObjectNode(targetNode);
if (timeline.isValid() && object.isValid()) {
for (auto frames : timeline.keyframeGroupsForTarget(targetNode)) {
@@ -78,10 +68,7 @@ void TimelineActions::insertAllKeyframesForTarget(const ModelNode &targetNode,
}
}
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
}
void TimelineActions::copyAllKeyframesForTarget(const ModelNode &targetNode,
@@ -117,11 +104,10 @@ void TimelineActions::pasteKeyframesToTarget(const ModelNode &targetNode,
pasteModel->detachView(&view);
try {
targetNode.view()->model()->attachView(&view);
view.executeInTransaction("TimelineActions::pasteKeyframesToTarget", [=, &view](){
RewriterTransaction transaction(
view.beginRewriterTransaction("TimelineActions::pasteKeyframesToTarget"));
targetNode.view()->model()->attachView(&view);
ModelNode nonConstTargetNode = targetNode;
nonConstTargetNode.validId();
@@ -144,11 +130,7 @@ void TimelineActions::pasteKeyframesToTarget(const ModelNode &targetNode,
timeline.modelNode().defaultNodeListProperty().reparentHere(newNode);
}
}
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
}
}
@@ -296,9 +278,7 @@ void TimelineActions::pasteKeyframes(AbstractView *timelineView, const QmlTimeli
ModelNode rootNode = view.rootModelNode();
try {
RewriterTransaction transaction(
timelineView->beginRewriterTransaction("TimelineActions::pasteKeyframes"));
timelineView->executeInTransaction("TimelineActions::pasteKeyframes", [=](){
if (isKeyframe(rootNode))
pasteKeyframe(currentTime, rootNode, timelineView, timeline);
else
@@ -308,10 +288,7 @@ void TimelineActions::pasteKeyframes(AbstractView *timelineView, const QmlTimeli
timelineView,
timeline);
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
}
bool TimelineActions::clipboardContainsKeyframes()

View File

@@ -663,26 +663,16 @@ void TimelineGraphicsScene::deleteKeyframeGroup(const ModelNode &group)
if (!QmlTimelineKeyframeGroup::isValidQmlTimelineKeyframeGroup(group))
return;
timelineView()->executeInTransaction("TimelineGraphicsScene::handleKeyframeGroupDeletion", [group](){
ModelNode nonConst = group;
try {
RewriterTransaction transaction(timelineView()->beginRewriterTransaction(
"TimelineGraphicsScene::handleKeyframeGroupDeletion"));
nonConst.destroy();
});
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
}
void TimelineGraphicsScene::deleteKeyframes(const QList<ModelNode> &frames)
{
try {
RewriterTransaction transaction(timelineView()->beginRewriterTransaction(
"TimelineGraphicsScene::handleKeyframeDeletion"));
timelineView()->executeInTransaction("TimelineGraphicsScene::handleKeyframeDeletion", [frames](){
for (auto keyframe : frames) {
if (keyframe.isValid()) {
ModelNode frame = keyframe;
@@ -692,10 +682,7 @@ void TimelineGraphicsScene::deleteKeyframes(const QList<ModelNode> &frames)
parent.destroy();
}
}
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
}
void TimelineGraphicsScene::activateLayout()

View File

@@ -136,10 +136,7 @@ void TimelineMoveTool::mouseReleaseEvent(TimelineMovableAbstractItem *item,
}
}
try {
RewriterTransaction transaction(scene()->timelineView()->beginRewriterTransaction(
"TimelineMoveTool::mouseReleaseEvent"));
scene()->timelineView()->executeInTransaction("TimelineMoveTool::mouseReleaseEvent", [this, current](){
current->commitPosition(mapToItem(current, current->rect().center()));
if (current->asTimelineKeyframeItem()) {
@@ -152,12 +149,7 @@ void TimelineMoveTool::mouseReleaseEvent(TimelineMovableAbstractItem *item,
if (keyframe != current)
keyframe->commitPosition(mapToItem(current, keyframe->rect().center()));
}
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
}
}

View File

@@ -534,15 +534,9 @@ void TimelineKeyframeItem::commitPosition(const QPointF &point)
blockUpdates();
try {
RewriterTransaction transaction(
m_frame.view()->beginRewriterTransaction("TimelineKeyframeItem::commitPosition"));
m_frame.view()->executeInTransaction("TimelineKeyframeItem::commitPosition", [this, frame](){
m_frame.variantProperty("frame").setValue(frame);
transaction.commit();
} catch (const RewritingException &e) {
e.showException();
}
});
enableUpdates();
}

View File

@@ -821,20 +821,15 @@ void TimelineBarItem::commitPosition(const QPointF & /*point*/)
{
if (sectionItem()->view()) {
if (m_handle != Location::Undefined) {
sectionItem()->view()->executeInTransaction("TimelineBarItem::commitPosition", [this](){
qreal scaleFactor = rect().width() / m_oldRect.width();
qreal moved = (rect().topLeft().x() - m_oldRect.topLeft().x()) / rulerScaling();
qreal supposedFirstFrame = qRound(sectionItem()->firstFrame() + moved);
try {
RewriterTransaction transaction(sectionItem()->view()->beginRewriterTransaction(
"TimelineBarItem::commitPosition"));
sectionItem()->scaleAllFrames(scaleFactor);
sectionItem()->moveAllFrames(supposedFirstFrame - sectionItem()->firstFrame());
transaction.commit();
} catch (const RewritingException &e) {
e.showException();
}
});
}
}

View File

@@ -266,15 +266,13 @@ ModelNode TimelineSettingsModel::animationForTimelineAndState(const QmlTimeline
void TimelineSettingsModel::updateTimeline(int row)
{
timelineView()->executeInTransaction("TimelineSettingsModel::updateTimeline", [this, row](){
QmlModelState modelState(stateForRow(row));
QmlTimeline timeline(timelineForRow(row));
ModelNode animation(animationForRow(row));
QmlTimeline oldTimeline = timelineView()->timelineForState(modelState);
RewriterTransaction transaction = timelineView()->beginRewriterTransaction(
QByteArrayLiteral("TimelineSettingsModel::updateTimeline"));
try {
if (modelState.isBaseState()) {
if (oldTimeline.isValid())
oldTimeline.modelNode().variantProperty("enabled").setValue(false);
@@ -301,27 +299,20 @@ void TimelineSettingsModel::updateTimeline(int row)
propertyChanges.modelNode().variantProperty("enabled").setValue(true);
}
}
} catch (Exception &e) {
m_exceptionError = e.description();
QTimer::singleShot(200, this, &TimelineSettingsModel::handleException);
}
});
resetRow(row);
}
void TimelineSettingsModel::updateAnimation(int row)
{
timelineView()->executeInTransaction("TimelineSettingsModel::updateAnimation", [this, row](){
QmlModelState modelState(stateForRow(row));
QmlTimeline timeline(timelineForRow(row));
ModelNode animation(animationForRow(row));
QmlTimeline oldTimeline = timelineView()->timelineForState(modelState);
ModelNode oldAnimation = animationForTimelineAndState(oldTimeline, modelState);
RewriterTransaction transaction = timelineView()->beginRewriterTransaction(
QByteArrayLiteral("TimelineSettingsModel::updateAnimation"));
try {
if (modelState.isBaseState()) {
if (oldAnimation.isValid())
oldAnimation.variantProperty("running").setValue(false);
@@ -353,27 +344,20 @@ void TimelineSettingsModel::updateAnimation(int row)
propertyChanges.modelNode().variantProperty("running").setValue(true);
}
}
} catch (Exception &e) {
m_exceptionError = e.description();
QTimer::singleShot(200, this, &TimelineSettingsModel::handleException);
}
});
resetRow(row);
}
void TimelineSettingsModel::updateFixedFrameRow(int row)
{
timelineView()->executeInTransaction("TimelineSettingsModel::updateFixedFrameRow", [this, row](){
QmlModelState modelState(stateForRow(row));
QmlTimeline timeline(timelineForRow(row));
ModelNode animation = animationForTimelineAndState(timeline, modelState);
RewriterTransaction transaction = timelineView()->beginRewriterTransaction(
QByteArrayLiteral("TimelineSettingsModel::updateFixedFrameRow"));
int fixedFrame = fixedFrameForRow(row);
try {
if (modelState.isBaseState()) {
if (animation.isValid())
animation.variantProperty("running").setValue(false);
@@ -390,10 +374,8 @@ void TimelineSettingsModel::updateFixedFrameRow(int row)
if (propertyChanges.isValid())
propertyChanges.modelNode().variantProperty("currentFrame").setValue(fixedFrame);
}
} catch (Exception &e) {
m_exceptionError = e.description();
QTimer::singleShot(200, this, &TimelineSettingsModel::handleException);
}
});
resetRow(row);
}

View File

@@ -264,9 +264,7 @@ const QmlTimeline TimelineView::addNewTimeline()
ModelNode timelineNode;
try {
RewriterTransaction transaction(beginRewriterTransaction("TimelineView::addNewTimeline"));
executeInTransaction("TimelineView::addNewTimeline", [=, &timelineNode](){
bool hasTimelines = getTimelines().isEmpty();
timelineNode = createModelNode(timelineType,
@@ -279,10 +277,7 @@ const QmlTimeline TimelineView::addNewTimeline()
timelineNode.variantProperty("enabled").setValue(hasTimelines);
rootModelNode().defaultNodeListProperty().reparentHere(timelineNode);
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
return QmlTimeline(timelineNode);
}
@@ -300,10 +295,8 @@ ModelNode TimelineView::addAnimation(QmlTimeline timeline)
QTC_ASSERT(metaInfo.isValid(), return ModelNode());
ModelNode animationNode;
try {
RewriterTransaction transaction(
beginRewriterTransaction("TimelineSettingsDialog::addAnimation"));
executeInTransaction("TimelineView::addAnimation", [=, &animationNode](){
animationNode = createModelNode(animationType,
metaInfo.majorVersion(),
metaInfo.minorVersion());
@@ -321,10 +314,7 @@ ModelNode TimelineView::addAnimation(QmlTimeline timeline)
if (timeline.modelNode().hasProperty("currentFrame"))
timeline.modelNode().removeProperty("currentFrame");
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
return animationNode;
}
@@ -391,9 +381,7 @@ void TimelineView::insertKeyframe(const ModelNode &target, const PropertyName &p
ModelNode targetNode = target;
if (timeline.isValid() && targetNode.isValid()
&& QmlObjectNode::isValidQmlObjectNode(targetNode)) {
try {
RewriterTransaction transaction(
beginRewriterTransaction("TimelineView::insertKeyframe"));
executeInTransaction("TimelineView::insertKeyframe", [=, &timeline, &targetNode](){
targetNode.validId();
@@ -408,10 +396,7 @@ void TimelineView::insertKeyframe(const ModelNode &target, const PropertyName &p
timelineFrames.setValue(value, frame);
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
});
}
}

View File

@@ -235,4 +235,18 @@ Image {
}
}
}
Text {
id: all_rights_reserved1
x: 15
y: 75
color: "#ffffff"
text: qsTr("Community Edition")
font.pixelSize: 13
font.family: Constants.titilliumWeb_light
visible: projectModel.communityVersion
ProjectModel {
id: projectModel
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View File

@@ -185,5 +185,20 @@ Item {
onClicked: Qt.openUrlExternally("http://blog.qt.io/")
}
}
Text {
id: qtDesignStudio1
x: 891
y: 171
color: "#ffffff"
text: qsTr("Community Edition")
anchors.right: parent.right
anchors.rightMargin: 23
font.weight: Font.Light
font.pixelSize: 14
font.family: Constants.titilliumWeb_regular
renderType: Text.NativeRendering
visible: projectModel.communityVersion
}
}
}

View File

@@ -274,9 +274,9 @@ void Highlighter::highlightBlock(const QString &text)
{
if (!definition().isValid())
return;
const QTextBlock block = currentBlock();
QTextBlock block = currentBlock();
KSyntaxHighlighting::State state;
setCurrentBlockState(qMax(0, previousBlockState()));
TextDocumentLayout::setBraceDepth(block, TextDocumentLayout::braceDepth(block.previous()));
if (TextBlockUserData *data = TextDocumentLayout::testUserData(block)) {
state = data->syntaxState();
data->setFoldingStartIncluded(false);
@@ -298,8 +298,11 @@ void Highlighter::highlightBlock(const QString &text)
if (nextBlock.isValid()) {
TextBlockUserData *data = TextDocumentLayout::userData(nextBlock);
if (data->syntaxState() != state) {
data->setSyntaxState(state);
data->setFoldingIndent(currentBlockState());
setCurrentBlockState(currentBlockState() ^ 1); // force rehighlight of next block
}
data->setFoldingIndent(TextDocumentLayout::braceDepth(block));
}
formatSpaces(text);
@@ -316,24 +319,24 @@ void Highlighter::applyFolding(int offset,
{
if (!region.isValid())
return;
const QTextBlock &block = currentBlock();
QTextBlock block = currentBlock();
const QString &text = block.text();
TextBlockUserData *data = TextDocumentLayout::userData(currentBlock());
const bool fromStart = TabSettings::firstNonSpace(text) == offset;
const bool toEnd = (offset + length) == (text.length() - TabSettings::trailingWhitespaces(text));
if (region.type() == KSyntaxHighlighting::FoldingRegion::Begin) {
setCurrentBlockState(currentBlockState() + 1);
TextDocumentLayout::changeBraceDepth(block, 1);
// if there is only a folding begin in the line move the current block into the fold
if (fromStart && toEnd) {
data->setFoldingIndent(currentBlockState());
data->setFoldingIndent(TextDocumentLayout::braceDepth(block));
data->setFoldingStartIncluded(true);
}
} else if (region.type() == KSyntaxHighlighting::FoldingRegion::End) {
setCurrentBlockState(qMax(0, currentBlockState() - 1));
TextDocumentLayout::changeBraceDepth(block, -1);
// if the folding end is at the end of the line move the current block into the fold
if (toEnd)
data->setFoldingEndIncluded(true);
else
data->setFoldingIndent(currentBlockState());
data->setFoldingIndent(TextDocumentLayout::braceDepth(block));
}
}

View File

@@ -21,5 +21,13 @@ Item {
{
console.log("test")
}
var a = 1
if (a > 0) {
console.log("positive")
} // Final condition
else {
console.log("negative or zero")
}
}
}

View File

@@ -0,0 +1,14 @@
import QtQuick 2.0
Item {
enum Test {
A,
B
}
enum TestWithValues {
A = 11.1,
B,
C = 3
}
}

View File

@@ -1,6 +1,10 @@
var x
var y = 12
var a_var = 1
let a_let = 2
const a_const = 3
function foo(a, b) {
x = 15
x += 4
@@ -28,6 +32,12 @@ while (true) {
for (var x in a) {
print(a[x])
}
for (let x in a) {
print(a[x])
}
for (const x in a) {
print(a[x])
}
do {
a = x

View File

@@ -10,3 +10,5 @@ var x = {
},
"z": 12
}
var empty_object = {}

View File

@@ -2,5 +2,4 @@ pragma Singleton
import QtQuick 2.0
Item {
}
Item {}

View File

@@ -45,4 +45,6 @@ Text {
function foo(a, b) {
x = a + 12 * b
}
value: Rectangle {}
}

Some files were not shown because too many files have changed in this diff Show More