Merge "Merge remote-tracking branch 'origin/4.10'"

This commit is contained in:
The Qt Project
2019-06-12 07:21:16 +00: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 \li To see the absolute path of a file, move the mouse pointer over the
file name. 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 \endlist
\if defined(qtcreator) \if defined(qtcreator)
@@ -188,7 +192,10 @@
\li Expand or collapse the tree view to show or hide all files and \li Expand or collapse the tree view to show or hide all files and
folders. folders.
\li Close all files in a project. \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 \endlist
For managing files and directories, the same functions are available as in 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} You can also reach the options page by clicking the \uicontrol {Open Settings Page}
button. 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) \if defined(qtcreator)
\section1 To-Do Entries \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/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of the Qt Creator documentation. ** This file is part of the Qt Creator documentation.
@@ -44,7 +44,12 @@
for and running it on a particular platform. for and running it on a particular platform.
\QC automatically detects the compilers that are registered by your system \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 or by using additional versions of the automatically detected
compilers: compilers:
@@ -94,6 +99,20 @@
\endlist \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 build an application using GCC, MinGW, Clang, or QCC, specify the path
to the directory where the compiler is located and select to the directory where the compiler is located and select
the application binary interface (ABI) version from the list of available 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 then select a compiler in the list, and then select \uicontrol C or
\uicontrol C++ to add a C or C++ compiler. \uicontrol C++ to add a C or C++ compiler.
\image qtcreator-toolchains.png
To clone the selected compiler, select \uicontrol Clone. To clone the selected compiler, select \uicontrol Clone.
\li In the \uicontrol Name field, enter a name for the compiler to \li In the \uicontrol Name field, enter a name for the compiler to

View File

@@ -73,6 +73,21 @@
\endlist \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: To add kits:
\list 1 \list 1
@@ -105,13 +120,13 @@
\li In the \uicontrol Device field, select a device. \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 \li In the \uicontrol Sysroot field, specify the directory where the device
image is located. If you are not cross-compiling, leave this field image is located. If you are not cross-compiling, leave this field
empty. 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 \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 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 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 configuration that should be used by qmake. If you leave this field
empty, the default mkspec of the selected Qt version is used. 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 \li In the \uicontrol {CMake Tool} field, select the CMake tool to use
for building the project. Select \uicontrol Manage to add installed for building the project. Select \uicontrol Manage to add installed
CMake tools to the list. For more information, see CMake tools to the list. For more information, see
@@ -169,10 +188,6 @@
\uicontrol Change to edit the variables of the CMake configuration \uicontrol Change to edit the variables of the CMake configuration
for the kit. 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 \endlist
\QC uses the \e {default kit} if it does not have enough information to \QC uses the \e {default kit} if it does not have enough information to
@@ -194,16 +209,18 @@
\list 1 \list 1
\li Select \uicontrol Change next to the \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. \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: \li Double-click the cell on the same row in the \uicontrol Value column
\c <module_name>.<property_name>. 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. \li Click \uicontrol OK.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -24,20 +24,70 @@
****************************************************************************/ ****************************************************************************/
import QtQuick 2.1 import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuickDesignerTheme 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 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 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 QtQuick 2.1
import HelperWidgets 2.0 import HelperWidgets 2.0
import QtQuick.Layouts 1.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 id: comboBox
property variant backendValue property variant backendValue
property color textColor: colorLogic.textColor property color textColor: colorLogic.textColor
labelColor: colorLogic.textColor
onTextColorChanged: setColor() onTextColorChanged: setColor()
editable: true editable: true
@@ -43,10 +45,19 @@ Controls.ComboBox {
editText = comboBox.backendValue.valueToString editText = comboBox.backendValue.valueToString
} }
style: CustomComboBoxStyle { ExtendedFunctionLogic {
textColor: comboBox.textColor 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 { ColorLogic {
id: colorLogic id: colorLogic
backendValue: comboBox.backendValue backendValue: comboBox.backendValue
@@ -82,13 +93,6 @@ Controls.ComboBox {
backendValue.value = indexText; backendValue.value = indexText;
} }
ExtendedFunctionButton {
x: 2
anchors.verticalCenter: parent.verticalCenter
backendValue: comboBox.backendValue
visible: comboBox.enabled
}
Connections { Connections {
target: modelNodeBackend target: modelNodeBackend
onSelectionChanged: { onSelectionChanged: {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -26,8 +26,14 @@ QtcProduct {
property bool qtcRunnable: true property bool qtcRunnable: true
bundle.identifier: qtc.ide_bundle_identifier 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: ({ 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"] cpp.rpaths: qbs.targetOS.contains("macos") ? ["@executable_path/../Frameworks"]

View File

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

View File

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

View File

@@ -112,6 +112,16 @@ void BoostCodeParser::handleIdentifier()
handleTestCase(TestCaseType::Fixture); handleTestCase(TestCaseType::Fixture);
} else if (identifier == "BOOST_DATA_TEST_CASE") { } else if (identifier == "BOOST_DATA_TEST_CASE") {
handleTestCase(TestCaseType::Data); 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") { } else if (identifier == "BOOST_TEST_DECORATOR") {
handleDecorator(); handleDecorator();
} }
@@ -133,6 +143,7 @@ void BoostCodeParser::handleSuiteBegin(bool isFixture)
m_currentSuite.prepend(m_suites.last().fullName + '/'); m_currentSuite.prepend(m_suites.last().fullName + '/');
if (isFixture) { // fixture suites have a (fixture) class name as 2nd parameter if (isFixture) { // fixture suites have a (fixture) class name as 2nd parameter
m_currentState.setFlag(BoostTestTreeItem::Fixture);
if (!skipCommentsUntil(T_COMMA)) if (!skipCommentsUntil(T_COMMA))
return; return;
if (!skipCommentsUntil(T_IDENTIFIER)) if (!skipCommentsUntil(T_IDENTIFIER))
@@ -194,6 +205,12 @@ void BoostCodeParser::handleTestCase(TestCaseType testCaseType)
} }
if (testCaseType == TestCaseType::Parameter) if (testCaseType == TestCaseType::Parameter)
m_currentState |= BoostTestTreeItem::Parameterized; 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)) if (!skipCommentsUntil(T_IDENTIFIER))
return; return;
@@ -227,6 +244,7 @@ void BoostCodeParser::handleTestCase(TestCaseType testCaseType)
m_currentState = BoostTestTreeItem::Enabled; m_currentState = BoostTestTreeItem::Enabled;
} }
} else { } else {
if (!m_currentState.testFlag(BoostTestTreeItem::Templated))
handleDecorators(); handleDecorators();
locationAndType = locationAndTypeFromToken(token, m_source, m_currentState, m_suites); locationAndType = locationAndTypeFromToken(token, m_source, m_currentState, m_suites);
m_testCases.append(locationAndType); m_testCases.append(locationAndType);
@@ -279,8 +297,11 @@ void BoostCodeParser::handleDecorators()
} else { } else {
// FIXME we have a const(expr) bool? currently not easily achievable // 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_LPAREN);
skipCommentsUntil(T_RPAREN); skipCommentsUntil(T_RPAREN);

View File

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

View File

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

View File

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

View File

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

View File

@@ -23,10 +23,11 @@
** **
****************************************************************************/ ****************************************************************************/
#include "testresultmodel.h"
#include "autotesticons.h" #include "autotesticons.h"
#include "autotestplugin.h" #include "autotestplugin.h"
#include "testresultdelegate.h" #include "testresultdelegate.h"
#include "testresultmodel.h" #include "testrunner.h"
#include "testsettings.h" #include "testsettings.h"
#include <projectexplorer/projectexplorericons.h> #include <projectexplorer/projectexplorericons.h>
@@ -220,6 +221,10 @@ QString TestResultItem::resultString() const
TestResultModel::TestResultModel(QObject *parent) TestResultModel::TestResultModel(QObject *parent)
: Utils::TreeModel<TestResultItem>(new TestResultItem(TestResultPtr()), 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) void TestResultModel::updateParent(const TestResultItem *item)
@@ -256,7 +261,7 @@ void TestResultModel::addTestResult(const TestResultPtr &testResult, bool autoEx
return; return;
} }
m_testResultCount[testResult->result()]++; m_testResultCount[testResult->id()][testResult->result()]++;
TestResultItem *newItem = new TestResultItem(testResult); TestResultItem *newItem = new TestResultItem(testResult);
TestResultItem *root = nullptr; TestResultItem *root = nullptr;
@@ -314,6 +319,7 @@ void TestResultModel::clearTestResults()
{ {
clear(); clear();
m_testResultCount.clear(); m_testResultCount.clear();
m_reportedSummary.clear();
m_disabled = 0; m_disabled = 0;
m_fileNames.clear(); m_fileNames.clear();
m_maxWidthOfFileName = 0; m_maxWidthOfFileName = 0;
@@ -363,6 +369,21 @@ int TestResultModel::maxWidthOfLineNumber(const QFont &font)
return m_widthOfLineNumber; 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, TestResultItem *TestResultModel::findParentItemFor(const TestResultItem *item,
const TestResultItem *startItem) const const TestResultItem *startItem) const
{ {

View File

@@ -84,7 +84,7 @@ public:
int maxWidthOfFileName(const QFont &font); int maxWidthOfFileName(const QFont &font);
int maxWidthOfLineNumber(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; } int disabledTests() const { return m_disabled; }
void raiseDisabledTests(int amount) { m_disabled += amount; } void raiseDisabledTests(int amount) { m_disabled += amount; }
@@ -94,7 +94,8 @@ private:
TestResultItem *findParentItemFor(const TestResultItem *item, TestResultItem *findParentItemFor(const TestResultItem *item,
const TestResultItem *startItem = nullptr) const; const TestResultItem *startItem = nullptr) const;
void updateParent(const TestResultItem *item); 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_widthOfLineNumber = 0;
int m_maxWidthOfFileName = 0; int m_maxWidthOfFileName = 0;
int m_disabled = 0; int m_disabled = 0;

View File

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

View File

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

View File

@@ -152,8 +152,13 @@ bool ClangFormatPlugin::initialize(const QStringList &arguments, QString *errorS
openClangFormatConfigAction->setData(doc->filePath().toString()); openClangFormatConfigAction->setData(doc->filePath().toString());
}); });
} }
#endif
return true; 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 } // namespace ClangFormat

View File

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

View File

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

View File

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

View File

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

View File

@@ -51,6 +51,18 @@ add_qtc_plugin(componentsplugin
SKIP_DEBUG_CMAKE_FILE_CHECK 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 add_qtc_plugin(qtquickplugin
CONDITION TARGET QmlDesigner CONDITION TARGET QmlDesigner
DEPENDS Core QmlDesigner Utils Qt5::Qml DEPENDS Core QmlDesigner Utils Qt5::Qml
@@ -283,6 +295,9 @@ extend_qtc_plugin(QmlDesigner
propertyeditorvalue.cpp propertyeditorvalue.h propertyeditorvalue.cpp propertyeditorvalue.h
propertyeditorview.cpp propertyeditorview.h propertyeditorview.cpp propertyeditorview.h
propertyeditorwidget.cpp propertyeditorwidget.h propertyeditorwidget.cpp propertyeditorwidget.h
simplecolorpalette.cpp simplecolorpalette.h
simplecolorpalettemodel.cpp simplecolorpalettemodel.h
simplecolorpalettesingleton.cpp simplecolorpalettesingleton.h
qmlanchorbindingproxy.cpp qmlanchorbindingproxy.h qmlanchorbindingproxy.cpp qmlanchorbindingproxy.h
qmlmodelnodeproxy.cpp qmlmodelnodeproxy.h qmlmodelnodeproxy.cpp qmlmodelnodeproxy.h
quick2propertyeditorview.cpp quick2propertyeditorview.h quick2propertyeditorview.cpp quick2propertyeditorview.h
@@ -305,6 +320,7 @@ extend_qtc_plugin(QmlDesigner
extend_qtc_plugin(QmlDesigner extend_qtc_plugin(QmlDesigner
SOURCES_PREFIX components/texteditor SOURCES_PREFIX components/texteditor
SOURCES SOURCES
texteditor.qrc
texteditorstatusbar.cpp texteditorstatusbar.h texteditorstatusbar.cpp texteditorstatusbar.h
texteditorview.cpp texteditorview.h texteditorview.cpp texteditorview.h
texteditorwidget.cpp texteditorwidget.h texteditorwidget.cpp texteditorwidget.h

View File

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

View File

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

View File

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

View File

@@ -545,10 +545,9 @@ void NavigatorTreeModel::handleItemLibraryImageDrop(const QMimeData *mimeData, i
void NavigatorTreeModel::moveNodesInteractive(NodeAbstractProperty &parentProperty, const QList<ModelNode> &modelNodes, int targetIndex) void NavigatorTreeModel::moveNodesInteractive(NodeAbstractProperty &parentProperty, const QList<ModelNode> &modelNodes, int targetIndex)
{ {
QTC_ASSERT(m_view, return); 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) { foreach (const ModelNode &modelNode, modelNodes) {
if (modelNode.isValid() if (modelNode.isValid()
&& modelNode != parentProperty.parentModelNode() && 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 Qt::DropActions NavigatorTreeModel::supportedDropActions() const

View File

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

View File

@@ -152,22 +152,14 @@ void PropertyEditorContextObject::toogleExportAlias()
PropertyName modelNodeId = selectedNode.id().toUtf8(); PropertyName modelNodeId = selectedNode.id().toUtf8();
ModelNode rootModelNode = rewriterView->rootModelNode(); ModelNode rootModelNode = rewriterView->rootModelNode();
try { rewriterView->executeInTransaction("PropertyEditorContextObject:toogleExportAlias", [&objectNode, &rootModelNode, modelNodeId](){
RewriterTransaction transaction =
rewriterView->beginRewriterTransaction(QByteArrayLiteral("PropertyEditorContextObject:toogleExportAlias"));
if (!objectNode.isAliasExported()) if (!objectNode.isAliasExported())
objectNode.ensureAliasExport(); objectNode.ensureAliasExport();
else else
if (rootModelNode.hasProperty(modelNodeId)) if (rootModelNode.hasProperty(modelNodeId))
rootModelNode.removeProperty(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) void PropertyEditorContextObject::changeTypeName(const QString &typeName)
@@ -181,12 +173,9 @@ void PropertyEditorContextObject::changeTypeName(const QString &typeName)
QTC_ASSERT(!rewriterView->selectedModelNodes().isEmpty(), return); QTC_ASSERT(!rewriterView->selectedModelNodes().isEmpty(), return);
rewriterView->executeInTransaction("PropertyEditorContextObject:changeTypeName", [this, rewriterView, typeName](){
ModelNode selectedNode = rewriterView->selectedModelNodes().constFirst(); ModelNode selectedNode = rewriterView->selectedModelNodes().constFirst();
try {
RewriterTransaction transaction =
rewriterView->beginRewriterTransaction(QByteArrayLiteral("PropertyEditorContextObject:changeTypeName"));
NodeMetaInfo metaInfo = m_model->metaInfo(typeName.toLatin1()); NodeMetaInfo metaInfo = m_model->metaInfo(typeName.toLatin1());
if (!metaInfo.isValid()) { if (!metaInfo.isValid()) {
Core::AsynchronousMessageBox::warning(tr("Invalid Type"), tr("%1 is an invalid type.").arg(typeName)); 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()); rewriterView->changeRootNodeType(metaInfo.typeName(), metaInfo.majorVersion(), metaInfo.minorVersion());
else else
selectedNode.changeType(metaInfo.typeName(), metaInfo.majorVersion(), metaInfo.minorVersion()); 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) 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) NodeMetaInfo PropertyEditorQmlBackend::findCommonAncestor(const ModelNode &node)
{ {
QTC_ASSERT(node.isValid(), return {}); if (!node.isValid())
return {};
QTC_ASSERT(node.metaInfo().isValid(), return {}); QTC_ASSERT(node.metaInfo().isValid(), return {});
AbstractView *view = node.view(); AbstractView *view = node.view();

View File

@@ -235,9 +235,7 @@ void PropertyEditorView::changeExpression(const QString &propertyName)
if (!m_selectedNode.isValid()) if (!m_selectedNode.isValid())
return; return;
RewriterTransaction transaction = beginRewriterTransaction(QByteArrayLiteral("PropertyEditorView::changeExpression")); executeInTransaction("PropertyEditorView::changeExpression", [this, name](){
try {
PropertyName underscoreName(name); PropertyName underscoreName(name);
underscoreName.replace('.', '_'); underscoreName.replace('.', '_');
@@ -253,7 +251,6 @@ void PropertyEditorView::changeExpression(const QString &propertyName)
if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "QColor") { if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "QColor") {
if (QColor(value->expression().remove('"')).isValid()) { if (QColor(value->expression().remove('"')).isValid()) {
qmlObjectNode.setVariantProperty(name, QColor(value->expression().remove('"'))); qmlObjectNode.setVariantProperty(name, QColor(value->expression().remove('"')));
transaction.commit(); //committing in the try block
return; return;
} }
} else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "bool") { } else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "bool") {
@@ -263,7 +260,6 @@ void PropertyEditorView::changeExpression(const QString &propertyName)
qmlObjectNode.setVariantProperty(name, true); qmlObjectNode.setVariantProperty(name, true);
else else
qmlObjectNode.setVariantProperty(name, false); qmlObjectNode.setVariantProperty(name, false);
transaction.commit(); //committing in the try block
return; return;
} }
} else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "int") { } else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "int") {
@@ -271,7 +267,6 @@ void PropertyEditorView::changeExpression(const QString &propertyName)
int intValue = value->expression().toInt(&ok); int intValue = value->expression().toInt(&ok);
if (ok) { if (ok) {
qmlObjectNode.setVariantProperty(name, intValue); qmlObjectNode.setVariantProperty(name, intValue);
transaction.commit(); //committing in the try block
return; return;
} }
} else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "qreal") { } else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "qreal") {
@@ -279,7 +274,6 @@ void PropertyEditorView::changeExpression(const QString &propertyName)
qreal realValue = value->expression().toDouble(&ok); qreal realValue = value->expression().toDouble(&ok);
if (ok) { if (ok) {
qmlObjectNode.setVariantProperty(name, realValue); qmlObjectNode.setVariantProperty(name, realValue);
transaction.commit(); //committing in the try block
return; return;
} }
} }
@@ -291,12 +285,7 @@ void PropertyEditorView::changeExpression(const QString &propertyName)
if (qmlObjectNode.expression(name) != value->expression() || !qmlObjectNode.propertyAffectedByCurrentState(name)) if (qmlObjectNode.expression(name) != value->expression() || !qmlObjectNode.propertyAffectedByCurrentState(name))
qmlObjectNode.setBindingProperty(name, value->expression()); qmlObjectNode.setBindingProperty(name, value->expression());
transaction.commit(); //committing in the try block }); /* end of transaction */
}
catch (const RewritingException &e) {
e.showException();
}
} }
void PropertyEditorView::exportPopertyAsAlias(const QString &name) void PropertyEditorView::exportPopertyAsAlias(const QString &name)
@@ -310,9 +299,7 @@ void PropertyEditorView::exportPopertyAsAlias(const QString &name)
if (!m_selectedNode.isValid()) if (!m_selectedNode.isValid())
return; return;
RewriterTransaction transaction = beginRewriterTransaction(QByteArrayLiteral("PropertyEditorView::exportPopertyAsAlias")); executeInTransaction("PropertyEditorView::exportPopertyAsAlias", [this, name](){
try {
const QString id = m_selectedNode.validId(); const QString id = m_selectedNode.validId();
QString upperCasePropertyName = name; QString upperCasePropertyName = name;
upperCasePropertyName.replace(0, 1, upperCasePropertyName.at(0).toUpper()); upperCasePropertyName.replace(0, 1, upperCasePropertyName.at(0).toUpper());
@@ -326,11 +313,7 @@ void PropertyEditorView::exportPopertyAsAlias(const QString &name)
return; return;
} }
rootModelNode().bindingProperty(propertyName).setDynamicTypeNameAndExpression("alias", id + "." + name); 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) void PropertyEditorView::removeAliasExport(const QString &name)
@@ -344,9 +327,7 @@ void PropertyEditorView::removeAliasExport(const QString &name)
if (!m_selectedNode.isValid()) if (!m_selectedNode.isValid())
return; return;
RewriterTransaction transaction = beginRewriterTransaction(QByteArrayLiteral("PropertyEditorView::exportPopertyAsAlias")); executeInTransaction("PropertyEditorView::exportPopertyAsAlias", [this, name](){
try {
const QString id = m_selectedNode.validId(); const QString id = m_selectedNode.validId();
for (const BindingProperty &property : rootModelNode().bindingProperties()) for (const BindingProperty &property : rootModelNode().bindingProperties())
@@ -354,10 +335,7 @@ void PropertyEditorView::removeAliasExport(const QString &name)
rootModelNode().removeProperty(property.name()); rootModelNode().removeProperty(property.name());
break; break;
} }
transaction.commit(); //committing in the try block });
} catch (const RewritingException &e) {
e.showException();
}
} }
bool PropertyEditorView::locked() const bool PropertyEditorView::locked() const
@@ -575,10 +553,11 @@ void PropertyEditorView::modelAttached(Model *model)
m_locked = true; m_locked = true;
if (!m_setupCompleted) { if (!m_setupCompleted) {
m_singleShotTimer->setSingleShot(true); QTimer::singleShot(50, this, [this]{
m_singleShotTimer->setInterval(100); PropertyEditorView::setupPanes();
connect(m_singleShotTimer, &QTimer::timeout, this, &PropertyEditorView::setupPanes); /* workaround for QTBUG-75847 */
m_singleShotTimer->start(); reloadQml();
});
} }
m_locked = false; m_locked = false;
@@ -681,6 +660,9 @@ void PropertyEditorView::instanceInformationsChanged(const QMultiHash<ModelNode,
if (!m_selectedNode.isValid()) if (!m_selectedNode.isValid())
return; return;
if (!m_qmlBackEndForCurrentType)
return;
m_locked = true; m_locked = true;
QList<InformationName> informationNameList = informationChangedHash.values(m_selectedNode); QList<InformationName> informationNameList = informationChangedHash.values(m_selectedNode);
if (informationNameList.contains(Anchor) 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 bool QmlAnchorBindingProxy::hasParent() const
@@ -361,20 +361,11 @@ void QmlAnchorBindingProxy::setTopTarget(const QString &target)
if (!newTarget.isValid()) if (!newTarget.isValid())
return; return;
try { executeInTransaction("QmlAnchorBindingProxy::setTopTarget", [this, newTarget](){
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setTopTarget"));
m_topTarget = newTarget; m_topTarget = newTarget;
setDefaultRelativeTopTarget(); setDefaultRelativeTopTarget();
anchorTop(); anchorTop();
});
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
emit topTargetChanged(); emit topTargetChanged();
} }
@@ -393,18 +384,12 @@ void QmlAnchorBindingProxy::setBottomTarget(const QString &target)
if (!newTarget.isValid()) if (!newTarget.isValid())
return; return;
try { executeInTransaction("QmlAnchorBindingProxy::setBottomTarget", [this, newTarget](){
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setBottomTarget"));
m_bottomTarget = newTarget; m_bottomTarget = newTarget;
setDefaultRelativeBottomTarget(); setDefaultRelativeBottomTarget();
anchorBottom(); anchorBottom();
transaction.commit(); });
} catch (const Exception &e) {
e.showException();
}
emit bottomTargetChanged(); emit bottomTargetChanged();
} }
@@ -422,18 +407,11 @@ void QmlAnchorBindingProxy::setLeftTarget(const QString &target)
if (!newTarget.isValid()) if (!newTarget.isValid())
return; return;
try { executeInTransaction("QmlAnchorBindingProxy::setLeftTarget", [this, newTarget](){
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setLeftTarget"));
m_leftTarget = newTarget; m_leftTarget = newTarget;
setDefaultRelativeLeftTarget(); setDefaultRelativeLeftTarget();
anchorLeft(); anchorLeft();
});
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
emit leftTargetChanged(); emit leftTargetChanged();
} }
@@ -451,18 +429,11 @@ void QmlAnchorBindingProxy::setRightTarget(const QString &target)
if (!newTarget.isValid()) if (!newTarget.isValid())
return; return;
try { executeInTransaction("QmlAnchorBindingProxy::setRightTarget", [this, newTarget](){
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setRightTarget"));
m_rightTarget = newTarget; m_rightTarget = newTarget;
setDefaultRelativeRightTarget(); setDefaultRelativeRightTarget();
anchorRight(); anchorRight();
});
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
emit rightTargetChanged(); emit rightTargetChanged();
} }
@@ -480,17 +451,10 @@ void QmlAnchorBindingProxy::setVerticalTarget(const QString &target)
if (!newTarget.isValid()) if (!newTarget.isValid())
return; return;
try { executeInTransaction("QmlAnchorBindingProxy::setVerticalTarget", [this, newTarget](){
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setVerticalTarget"));
m_verticalTarget = newTarget; m_verticalTarget = newTarget;
anchorVertical(); anchorVertical();
});
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
emit verticalTargetChanged(); emit verticalTargetChanged();
} }
@@ -508,17 +472,10 @@ void QmlAnchorBindingProxy::setHorizontalTarget(const QString &target)
if (!newTarget.isValid()) if (!newTarget.isValid())
return; return;
try { executeInTransaction("QmlAnchorBindingProxy::setHorizontalTarget", [this, newTarget](){
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setHorizontalTarget"));
m_horizontalTarget = newTarget; m_horizontalTarget = newTarget;
anchorHorizontal();\ anchorHorizontal();
});
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
emit horizontalTargetChanged(); emit horizontalTargetChanged();
} }
@@ -531,18 +488,10 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetTop(QmlAnchorBindingProxy::Re
if (target == m_relativeTopTarget) if (target == m_relativeTopTarget)
return; return;
try { executeInTransaction("QmlAnchorBindingProxy::setRelativeAnchorTargetTop", [this, target](){
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetTop"));
m_relativeTopTarget = target; m_relativeTopTarget = target;
anchorTop(); anchorTop();
});
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
emit relativeAnchorTargetTopChanged(); emit relativeAnchorTargetTopChanged();
} }
@@ -555,19 +504,10 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetBottom(QmlAnchorBindingProxy:
if (target == m_relativeBottomTarget) if (target == m_relativeBottomTarget)
return; return;
try { executeInTransaction("QmlAnchorBindingProxy::setRelativeAnchorTargetBottom", [this, target](){
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetBottom"));
m_relativeBottomTarget = target; m_relativeBottomTarget = target;
anchorBottom(); anchorBottom();
});
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
emit relativeAnchorTargetBottomChanged(); emit relativeAnchorTargetBottomChanged();
} }
@@ -580,18 +520,11 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetLeft(QmlAnchorBindingProxy::R
if (target == m_relativeLeftTarget) if (target == m_relativeLeftTarget)
return; return;
try { executeInTransaction("QmlAnchorBindingProxy::setRelativeAnchorTargetLeft", [this, target](){
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetLeft"));
m_relativeLeftTarget = target; m_relativeLeftTarget = target;
anchorLeft(); anchorLeft();
transaction.commit(); });
} catch (const Exception &e) {
e.showException();
}
emit relativeAnchorTargetLeftChanged(); emit relativeAnchorTargetLeftChanged();
} }
@@ -604,18 +537,10 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetRight(QmlAnchorBindingProxy::
if (target == m_relativeRightTarget) if (target == m_relativeRightTarget)
return; return;
try { executeInTransaction("QmlAnchorBindingProxy::setRelativeAnchorTargetRight", [this, target](){
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetRight"));
m_relativeRightTarget = target; m_relativeRightTarget = target;
anchorRight(); anchorRight();
});
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
emit relativeAnchorTargetRightChanged(); emit relativeAnchorTargetRightChanged();
@@ -629,18 +554,11 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetVertical(QmlAnchorBindingProx
if (target == m_relativeVerticalTarget) if (target == m_relativeVerticalTarget)
return; return;
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetVertical"));
executeInTransaction("QmlAnchorBindingProxy::setRelativeAnchorTargetVertical", [this, target](){
m_relativeVerticalTarget = target; m_relativeVerticalTarget = target;
anchorVertical(); anchorVertical();
});
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
emit relativeAnchorTargetVerticalChanged(); emit relativeAnchorTargetVerticalChanged();
} }
@@ -653,18 +571,10 @@ void QmlAnchorBindingProxy::setRelativeAnchorTargetHorizontal(QmlAnchorBindingPr
if (target == m_relativeHorizontalTarget) if (target == m_relativeHorizontalTarget)
return; return;
try { executeInTransaction("QmlAnchorBindingProxy::setRelativeAnchorTargetHorizontal", [this, target](){
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setRelativeAnchorTargetHorizontal"));
m_relativeHorizontalTarget = target; m_relativeHorizontalTarget = target;
anchorHorizontal(); anchorHorizontal();
});
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
emit relativeAnchorTargetHorizontalChanged(); emit relativeAnchorTargetHorizontalChanged();
} }
@@ -709,12 +619,10 @@ int QmlAnchorBindingProxy::indexOfPossibleTargetItem(const QString &targetName)
return possibleTargetItems().indexOf(targetName); return possibleTargetItems().indexOf(targetName);
} }
void QmlAnchorBindingProxy::resetLayout() { void QmlAnchorBindingProxy::resetLayout()
{
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::resetLayout"));
executeInTransaction("QmlAnchorBindingProxy::resetLayout", [this](){
m_qmlItemNode.anchors().removeAnchors(); m_qmlItemNode.anchors().removeAnchors();
m_qmlItemNode.anchors().removeMargins(); m_qmlItemNode.anchors().removeMargins();
@@ -722,11 +630,7 @@ void QmlAnchorBindingProxy::resetLayout() {
restoreProperty(modelNode(), "y"); restoreProperty(modelNode(), "y");
restoreProperty(modelNode(), "width"); restoreProperty(modelNode(), "width");
restoreProperty(modelNode(), "height"); restoreProperty(modelNode(), "height");
});
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
emit topAnchorChanged(); emit topAnchorChanged();
emit bottomAnchorChanged(); emit bottomAnchorChanged();
@@ -743,10 +647,7 @@ void QmlAnchorBindingProxy::setBottomAnchor(bool anchor)
if (bottomAnchored() == anchor) if (bottomAnchored() == anchor)
return; return;
try { executeInTransaction("QmlAnchorBindingProxy::setBottomAnchor", [this, anchor](){
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setBottomAnchor"));
if (!anchor) { if (!anchor) {
removeBottomAnchor(); removeBottomAnchor();
} else { } else {
@@ -756,10 +657,7 @@ void QmlAnchorBindingProxy::setBottomAnchor(bool anchor)
backupPropertyAndRemove(modelNode(), "height"); backupPropertyAndRemove(modelNode(), "height");
} }
transaction.commit(); });
} catch (const Exception &e) {
e.showException();
}
emit relativeAnchorTargetBottomChanged(); emit relativeAnchorTargetBottomChanged();
emit bottomAnchorChanged(); emit bottomAnchorChanged();
@@ -776,10 +674,8 @@ void QmlAnchorBindingProxy::setLeftAnchor(bool anchor)
if (leftAnchored() == anchor) if (leftAnchored() == anchor)
return; return;
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setLeftAnchor"));
executeInTransaction("QmlAnchorBindingProxy::setLeftAnchor", [this, anchor](){
if (!anchor) { if (!anchor) {
removeLeftAnchor(); removeLeftAnchor();
} else { } else {
@@ -791,10 +687,7 @@ void QmlAnchorBindingProxy::setLeftAnchor(bool anchor)
backupPropertyAndRemove(modelNode(), "width"); backupPropertyAndRemove(modelNode(), "width");
} }
transaction.commit(); });
} catch (const Exception &e) {
e.showException();
}
emit relativeAnchorTargetLeftChanged(); emit relativeAnchorTargetLeftChanged();
emit leftAnchorChanged(); emit leftAnchorChanged();
@@ -810,10 +703,7 @@ void QmlAnchorBindingProxy::setRightAnchor(bool anchor)
if (rightAnchored() == anchor) if (rightAnchored() == anchor)
return; return;
try { executeInTransaction("QmlAnchorBindingProxy::setRightAnchor", [this, anchor](){
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setRightAnchor"));
if (!anchor) { if (!anchor) {
removeRightAnchor(); removeRightAnchor();
} else { } else {
@@ -824,10 +714,7 @@ void QmlAnchorBindingProxy::setRightAnchor(bool anchor)
backupPropertyAndRemove(modelNode(), "width"); backupPropertyAndRemove(modelNode(), "width");
} }
transaction.commit(); });
} catch (const Exception &e) {
e.showException();
}
emit relativeAnchorTargetRightChanged(); emit relativeAnchorTargetRightChanged();
emit rightAnchorChanged(); emit rightAnchorChanged();
@@ -1026,10 +913,7 @@ void QmlAnchorBindingProxy::setTopAnchor(bool anchor)
if (topAnchored() == anchor) if (topAnchored() == anchor)
return; return;
try { executeInTransaction("QmlAnchorBindingProxy::setTopAnchor", [this, anchor](){
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setTopAnchor"));
if (!anchor) { if (!anchor) {
removeTopAnchor(); removeTopAnchor();
} else { } else {
@@ -1040,10 +924,7 @@ void QmlAnchorBindingProxy::setTopAnchor(bool anchor)
if (bottomAnchored()) if (bottomAnchored())
backupPropertyAndRemove(modelNode(), "height"); backupPropertyAndRemove(modelNode(), "height");
} }
transaction.commit(); });
} catch (const Exception &e) {
e.showException();
}
emit relativeAnchorTargetTopChanged(); emit relativeAnchorTargetTopChanged();
emit topAnchorChanged(); emit topAnchorChanged();
@@ -1052,70 +933,44 @@ void QmlAnchorBindingProxy::setTopAnchor(bool anchor)
} }
void QmlAnchorBindingProxy::removeTopAnchor() { void QmlAnchorBindingProxy::removeTopAnchor() {
try { executeInTransaction("QmlAnchorBindingProxy::removeTopAnchor", [this](){
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::removeTopAnchor"));
m_qmlItemNode.anchors().removeAnchor(AnchorLineTop); m_qmlItemNode.anchors().removeAnchor(AnchorLineTop);
m_qmlItemNode.anchors().removeMargin(AnchorLineTop); m_qmlItemNode.anchors().removeMargin(AnchorLineTop);
restoreProperty(modelNode(), "y"); restoreProperty(modelNode(), "y");
restoreProperty(modelNode(), "height"); restoreProperty(modelNode(), "height");
});
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
} }
void QmlAnchorBindingProxy::removeBottomAnchor() { void QmlAnchorBindingProxy::removeBottomAnchor()
try { {
RewriterTransaction transaction = beginRewriterTransaction( executeInTransaction("QmlAnchorBindingProxy::removeBottomAnchor", [this](){
QByteArrayLiteral("QmlAnchorBindingProxy::removeBottomAnchor"));
m_qmlItemNode.anchors().removeAnchor(AnchorLineBottom); m_qmlItemNode.anchors().removeAnchor(AnchorLineBottom);
m_qmlItemNode.anchors().removeMargin(AnchorLineBottom); m_qmlItemNode.anchors().removeMargin(AnchorLineBottom);
restoreProperty(modelNode(), "height"); restoreProperty(modelNode(), "height");
});
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
} }
void QmlAnchorBindingProxy::removeLeftAnchor() { void QmlAnchorBindingProxy::removeLeftAnchor()
try { {
RewriterTransaction transaction = beginRewriterTransaction( executeInTransaction("QmlAnchorBindingProxy::removeLeftAnchor", [this](){
QByteArrayLiteral("QmlAnchorBindingProxy::removeLeftAnchor"));
m_qmlItemNode.anchors().removeAnchor(AnchorLineLeft); m_qmlItemNode.anchors().removeAnchor(AnchorLineLeft);
m_qmlItemNode.anchors().removeMargin(AnchorLineLeft); m_qmlItemNode.anchors().removeMargin(AnchorLineLeft);
restoreProperty(modelNode(), "x"); restoreProperty(modelNode(), "x");
restoreProperty(modelNode(), "width"); restoreProperty(modelNode(), "width");
});
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
} }
void QmlAnchorBindingProxy::removeRightAnchor() { void QmlAnchorBindingProxy::removeRightAnchor()
try { {
RewriterTransaction transaction = beginRewriterTransaction( executeInTransaction("QmlAnchorBindingProxy::removeRightAnchor", [this](){
QByteArrayLiteral("QmlAnchorBindingProxy::removeRightAnchor"));
m_qmlItemNode.anchors().removeAnchor(AnchorLineRight); m_qmlItemNode.anchors().removeAnchor(AnchorLineRight);
m_qmlItemNode.anchors().removeMargin(AnchorLineRight); m_qmlItemNode.anchors().removeMargin(AnchorLineRight);
restoreProperty(modelNode(), "width"); restoreProperty(modelNode(), "width");
});
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
} }
void QmlAnchorBindingProxy::setVerticalCentered(bool centered) void QmlAnchorBindingProxy::setVerticalCentered(bool centered)
@@ -1128,10 +983,7 @@ void QmlAnchorBindingProxy::setVerticalCentered(bool centered)
m_locked = true; m_locked = true;
try { executeInTransaction("QmlAnchorBindingProxy::setVerticalCentered", [this, centered](){
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setVerticalCentered"));
if (!centered) { if (!centered) {
m_qmlItemNode.anchors().removeAnchor(AnchorLineVerticalCenter); m_qmlItemNode.anchors().removeAnchor(AnchorLineVerticalCenter);
m_qmlItemNode.anchors().removeMargin(AnchorLineVerticalCenter); m_qmlItemNode.anchors().removeMargin(AnchorLineVerticalCenter);
@@ -1141,10 +993,7 @@ void QmlAnchorBindingProxy::setVerticalCentered(bool centered)
anchorVertical(); anchorVertical();
} }
transaction.commit(); });
} catch (const Exception &e) {
e.showException();
}
m_locked = false; m_locked = false;
emit relativeAnchorTargetVerticalChanged(); emit relativeAnchorTargetVerticalChanged();
@@ -1161,10 +1010,7 @@ void QmlAnchorBindingProxy::setHorizontalCentered(bool centered)
m_locked = true; m_locked = true;
try { executeInTransaction("QmlAnchorBindingProxy::setHorizontalCentered", [this, centered](){
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::setHorizontalCentered"));
if (!centered) { if (!centered) {
m_qmlItemNode.anchors().removeAnchor(AnchorLineHorizontalCenter); m_qmlItemNode.anchors().removeAnchor(AnchorLineHorizontalCenter);
m_qmlItemNode.anchors().removeMargin(AnchorLineHorizontalCenter); m_qmlItemNode.anchors().removeMargin(AnchorLineHorizontalCenter);
@@ -1173,11 +1019,7 @@ void QmlAnchorBindingProxy::setHorizontalCentered(bool centered)
anchorHorizontal(); anchorHorizontal();
} }
});
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
m_locked = false; m_locked = false;
emit relativeAnchorTargetHorizontalChanged(); emit relativeAnchorTargetHorizontalChanged();
@@ -1256,12 +1098,7 @@ bool QmlAnchorBindingProxy::horizontalCentered()
void QmlAnchorBindingProxy::fill() void QmlAnchorBindingProxy::fill()
{ {
executeInTransaction("QmlAnchorBindingProxy::fill", [this](){
try {
RewriterTransaction transaction = beginRewriterTransaction(
QByteArrayLiteral("QmlAnchorBindingProxy::fill"));
backupPropertyAndRemove(modelNode(), "x"); backupPropertyAndRemove(modelNode(), "x");
backupPropertyAndRemove(modelNode(), "y"); backupPropertyAndRemove(modelNode(), "y");
backupPropertyAndRemove(modelNode(), "width"); backupPropertyAndRemove(modelNode(), "width");
@@ -1277,10 +1114,7 @@ void QmlAnchorBindingProxy::fill()
m_qmlItemNode.anchors().removeMargin(AnchorLineTop); m_qmlItemNode.anchors().removeMargin(AnchorLineTop);
m_qmlItemNode.anchors().removeMargin(AnchorLineBottom); m_qmlItemNode.anchors().removeMargin(AnchorLineBottom);
transaction.commit(); });
} catch (const Exception &e) {
e.showException();
}
emit topAnchorChanged(); emit topAnchorChanged();
emit bottomAnchorChanged(); emit bottomAnchorChanged();

View File

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

View File

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

View File

@@ -616,6 +616,20 @@ void AbstractView::deactivateTimelineRecording()
model()->d->notifyCurrentTimelineChanged(ModelNode()); 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 QList<ModelNode> AbstractView::allModelNodes() const
{ {
return toModelNodeList(model()->d->allNodes()); 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()->changeImports(modelNode.model()->imports(), {});
view()->model()->setFileUrl(modelNode.model()->fileUrl()); view()->model()->setFileUrl(modelNode.model()->fileUrl());
try { view()->executeInTransaction("ModelMerger::replaceModel", [this, modelNode](){
RewriterTransaction transaction(view()->beginRewriterTransaction(QByteArrayLiteral("ModelMerger::replaceModel")));
ModelNode rootNode(view()->rootModelNode()); ModelNode rootNode(view()->rootModelNode());
foreach (const PropertyName &propertyName, rootNode.propertyNames()) foreach (const PropertyName &propertyName, rootNode.propertyNames())
@@ -196,11 +194,7 @@ void ModelMerger::replaceModel(const ModelNode &modelNode)
syncNodeProperties(rootNode, modelNode, idRenamingHash, view()); syncNodeProperties(rootNode, modelNode, idRenamingHash, view());
syncNodeListProperties(rootNode, modelNode, idRenamingHash, view()); syncNodeListProperties(rootNode, modelNode, idRenamingHash, view());
m_view->changeRootNodeType(modelNode.type(), modelNode.majorVersion(), modelNode.minorVersion()); m_view->changeRootNodeType(modelNode.type(), modelNode.majorVersion(), modelNode.minorVersion());
});
transaction.commit();
} catch (const RewritingException &e) {
qWarning() << e.description(); //silent error
}
} }
} //namespace QmlDesigner } //namespace QmlDesigner

View File

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

View File

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

View File

@@ -232,8 +232,6 @@ void BackendModel::addNewBackend()
Import import = Import::createLibraryImport(importSplit.constFirst(), importSplit.constLast()); 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 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. * We need the import to have the meta info available.
*/ */
@@ -247,12 +245,11 @@ void BackendModel::addNewBackend()
QTC_ASSERT(metaInfo.isValid(), return); 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. */ /* Add a property for non singleton types. For singletons just adding the import is enough. */
if (!dialog.isSingleton()) { 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()) { if (dialog.localDefinition()) {
ModelNode newNode = m_connectionView->createModelNode(metaInfo.typeName(), majorVersion, minorVersion); ModelNode newNode = m_connectionView->createModelNode(metaInfo.typeName(), majorVersion, minorVersion);
@@ -263,14 +260,9 @@ void BackendModel::addNewBackend()
m_connectionView->rootModelNode().bindingProperty( m_connectionView->rootModelNode().bindingProperty(
propertyName.toUtf8()).setDynamicTypeNameAndExpression(typeName.toUtf8(), "null"); propertyName.toUtf8()).setDynamicTypeNameAndExpression(typeName.toUtf8(), "null");
} }
transaction.commit(); });
}
} catch (const Exception &e) {
e.showException();
} }
} }
resetModel(); resetModel();
} }
@@ -279,11 +271,9 @@ void BackendModel::updatePropertyName(int rowNumber)
const PropertyName newName = data(index(rowNumber, 1)).toString().toUtf8(); const PropertyName newName = data(index(rowNumber, 1)).toString().toUtf8();
const PropertyName oldName = data(index(rowNumber, 0), Qt::UserRole + 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(); ModelNode rootModelNode = m_connectionView->rootModelNode();
try {
RewriterTransaction transaction = m_connectionView->beginRewriterTransaction("BackendModel::updatePropertyName");
if (rootModelNode.property(oldName).isNodeProperty()) { if (rootModelNode.property(oldName).isNodeProperty()) {
const TypeName typeName = rootModelNode.nodeProperty(oldName).dynamicTypeName(); const TypeName typeName = rootModelNode.nodeProperty(oldName).dynamicTypeName();
@@ -306,12 +296,7 @@ void BackendModel::updatePropertyName(int rowNumber)
qWarning() << Q_FUNC_INFO << oldName << newName << "failed..."; qWarning() << Q_FUNC_INFO << oldName << newName << "failed...";
QTC_ASSERT(false, return); QTC_ASSERT(false, return);
} }
});
transaction.commit();
} catch (const Exception &e) {
e.showException();
}
} }
void BackendModel::handleDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) 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) void BindingModel::updateExpression(int row)
{ {
BindingProperty bindingProperty = bindingPropertyForRow(row);
const QString sourceNode = data(index(row, SourceModelNodeRow)).toString().trimmed(); const QString sourceNode = data(index(row, SourceModelNodeRow)).toString().trimmed();
const QString sourceProperty = data(index(row, SourcePropertyNameRow)).toString().trimmed(); const QString sourceProperty = data(index(row, SourcePropertyNameRow)).toString().trimmed();
@@ -302,15 +300,10 @@ void BindingModel::updateExpression(int row)
expression = sourceNode + QLatin1String(".") + sourceProperty; expression = sourceNode + QLatin1String(".") + sourceProperty;
} }
RewriterTransaction transaction = connectionView()->executeInTransaction("BindingModel::updateExpression", [this, row, expression](){
connectionView()->beginRewriterTransaction(QByteArrayLiteral("BindingModel::updateExpression")); BindingProperty bindingProperty = bindingPropertyForRow(row);
try {
bindingProperty.setExpression(expression.trimmed()); 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) void BindingModel::updatePropertyName(int rowNumber)

View File

@@ -182,26 +182,21 @@ void ConnectionModel::updateSource(int row)
void ConnectionModel::updateSignalName(int rowNumber) void ConnectionModel::updateSignalName(int rowNumber)
{ {
SignalHandlerProperty signalHandlerProperty = signalHandlerPropertyForRow(rowNumber); SignalHandlerProperty signalHandlerProperty = signalHandlerPropertyForRow(rowNumber);
const PropertyName newName = data(index(rowNumber, TargetPropertyNameRow)).toString().toUtf8();
const QString source = signalHandlerProperty.source();
ModelNode connectionNode = signalHandlerProperty.parentModelNode(); ModelNode connectionNode = signalHandlerProperty.parentModelNode();
const PropertyName newName = data(index(rowNumber, TargetPropertyNameRow)).toString().toUtf8();
if (!newName.isEmpty()) { if (!newName.isEmpty()) {
RewriterTransaction transaction = connectionView()->executeInTransaction("ConnectionModel::updateSignalName", [=, &connectionNode](){
connectionView()->beginRewriterTransaction(QByteArrayLiteral("ConnectionModel::updateSignalName"));
try { const QString source = signalHandlerProperty.source();
connectionNode.signalHandlerProperty(newName).setSource(source); connectionNode.signalHandlerProperty(newName).setSource(source);
connectionNode.removeProperty(signalHandlerProperty.name()); 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); QStandardItem* idItem = item(rowNumber, 0);
SignalHandlerProperty newSignalHandlerProperty = connectionNode.signalHandlerProperty(newName); SignalHandlerProperty newSignalHandlerProperty = connectionNode.signalHandlerProperty(newName);
updateCustomData(idItem, newSignalHandlerProperty); updateCustomData(idItem, newSignalHandlerProperty);
} else { } else {
qWarning() << "BindingModel::updatePropertyName invalid property name"; qWarning() << "BindingModel::updatePropertyName invalid property name";
} }
@@ -214,14 +209,9 @@ void ConnectionModel::updateTargetNode(int rowNumber)
ModelNode connectionNode = signalHandlerProperty.parentModelNode(); ModelNode connectionNode = signalHandlerProperty.parentModelNode();
if (!newTarget.isEmpty()) { if (!newTarget.isEmpty()) {
RewriterTransaction transaction = connectionView()->executeInTransaction("ConnectionModel::updateTargetNode", [= ,&connectionNode](){
connectionView()->beginRewriterTransaction(QByteArrayLiteral("ConnectionModel::updateTargetNode"));
try {
connectionNode.bindingProperty("target").setExpression(newTarget); 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); QStandardItem* idItem = item(rowNumber, 0);
updateCustomData(idItem, signalHandlerProperty); updateCustomData(idItem, signalHandlerProperty);
@@ -259,9 +249,7 @@ void ConnectionModel::addConnection()
NodeMetaInfo nodeMetaInfo = connectionView()->model()->metaInfo("QtQuick.Connections"); NodeMetaInfo nodeMetaInfo = connectionView()->model()->metaInfo("QtQuick.Connections");
if (nodeMetaInfo.isValid()) { if (nodeMetaInfo.isValid()) {
RewriterTransaction transaction = connectionView()->executeInTransaction("ConnectionModel::addConnection", [=](){
connectionView()->beginRewriterTransaction(QByteArrayLiteral("ConnectionModel::addConnection"));
try {
ModelNode newNode = connectionView()->createModelNode("QtQuick.Connections", ModelNode newNode = connectionView()->createModelNode("QtQuick.Connections",
nodeMetaInfo.majorVersion(), nodeMetaInfo.majorVersion(),
nodeMetaInfo.minorVersion()); nodeMetaInfo.minorVersion());
@@ -276,10 +264,7 @@ void ConnectionModel::addConnection()
} else { } else {
newNode.bindingProperty("target").setExpression(QLatin1String("parent")); 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); BindingProperty bindingProperty = bindingPropertyForRow(rowNumber);
if (bindingProperty.isBindingProperty()) {
const QString expression = bindingProperty.expression();
const PropertyName dynamicPropertyType = bindingProperty.dynamicTypeName();
ModelNode targetNode = bindingProperty.parentModelNode(); ModelNode targetNode = bindingProperty.parentModelNode();
RewriterTransaction transaction = connectionView()->beginRewriterTransaction(QByteArrayLiteral("DynamicPropertiesModel::updatePropertyName")); if (bindingProperty.isBindingProperty()) {
try { connectionView()->executeInTransaction("DynamicPropertiesModel::updatePropertyName", [bindingProperty, newName, &targetNode](){
const QString expression = bindingProperty.expression();
const PropertyName dynamicPropertyType = bindingProperty.dynamicTypeName();
targetNode.bindingProperty(newName).setDynamicTypeNameAndExpression(dynamicPropertyType, expression); targetNode.bindingProperty(newName).setDynamicTypeNameAndExpression(dynamicPropertyType, expression);
targetNode.removeProperty(bindingProperty.name()); 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)); updateCustomData(rowNumber, targetNode.bindingProperty(newName));
return; return;
@@ -489,14 +486,10 @@ void DynamicPropertiesModel::updatePropertyName(int rowNumber)
const PropertyName dynamicPropertyType = variantProperty.dynamicTypeName(); const PropertyName dynamicPropertyType = variantProperty.dynamicTypeName();
ModelNode targetNode = variantProperty.parentModelNode(); ModelNode targetNode = variantProperty.parentModelNode();
RewriterTransaction transaction = connectionView()->beginRewriterTransaction(QByteArrayLiteral("DynamicPropertiesModel::updatePropertyName")); connectionView()->executeInTransaction("DynamicPropertiesModel::updatePropertyName", [=](){
try {
targetNode.variantProperty(newName).setDynamicTypeNameAndValue(dynamicPropertyType, value); targetNode.variantProperty(newName).setDynamicTypeNameAndValue(dynamicPropertyType, value);
targetNode.removeProperty(variantProperty.name()); 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)); updateCustomData(rowNumber, targetNode.variantProperty(newName));
} }
@@ -519,14 +512,10 @@ void DynamicPropertiesModel::updatePropertyType(int rowNumber)
const PropertyName propertyName = bindingProperty.name(); const PropertyName propertyName = bindingProperty.name();
ModelNode targetNode = bindingProperty.parentModelNode(); ModelNode targetNode = bindingProperty.parentModelNode();
RewriterTransaction transaction = connectionView()->beginRewriterTransaction(QByteArrayLiteral("DynamicPropertiesModel::updatePropertyType")); connectionView()->executeInTransaction("DynamicPropertiesModel::updatePropertyType", [=](){
try {
targetNode.removeProperty(bindingProperty.name()); targetNode.removeProperty(bindingProperty.name());
targetNode.bindingProperty(propertyName).setDynamicTypeNameAndExpression(newType, expression); 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)); updateCustomData(rowNumber, targetNode.bindingProperty(propertyName));
return; return;
@@ -539,18 +528,14 @@ void DynamicPropertiesModel::updatePropertyType(int rowNumber)
ModelNode targetNode = variantProperty.parentModelNode(); ModelNode targetNode = variantProperty.parentModelNode();
const PropertyName propertyName = variantProperty.name(); const PropertyName propertyName = variantProperty.name();
RewriterTransaction transaction = connectionView()->beginRewriterTransaction(QByteArrayLiteral("DynamicPropertiesModel::updatePropertyType")); connectionView()->executeInTransaction("DynamicPropertiesModel::updatePropertyType", [=](){
try {
targetNode.removeProperty(variantProperty.name()); targetNode.removeProperty(variantProperty.name());
if (newType == "alias") { //alias properties have to be bindings if (newType == "alias") { //alias properties have to be bindings
targetNode.bindingProperty(propertyName).setDynamicTypeNameAndExpression(newType, QLatin1String("none.none")); targetNode.bindingProperty(propertyName).setDynamicTypeNameAndExpression(newType, QLatin1String("none.none"));
} else { } else {
targetNode.variantProperty(propertyName).setDynamicTypeNameAndValue(newType, convertVariantForTypeName(value, newType)); 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)); updateCustomData(rowNumber, targetNode.variantProperty(propertyName));

View File

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

View File

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

View File

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

View File

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

View File

@@ -136,10 +136,7 @@ void TimelineMoveTool::mouseReleaseEvent(TimelineMovableAbstractItem *item,
} }
} }
try { scene()->timelineView()->executeInTransaction("TimelineMoveTool::mouseReleaseEvent", [this, current](){
RewriterTransaction transaction(scene()->timelineView()->beginRewriterTransaction(
"TimelineMoveTool::mouseReleaseEvent"));
current->commitPosition(mapToItem(current, current->rect().center())); current->commitPosition(mapToItem(current, current->rect().center()));
if (current->asTimelineKeyframeItem()) { if (current->asTimelineKeyframeItem()) {
@@ -152,12 +149,7 @@ void TimelineMoveTool::mouseReleaseEvent(TimelineMovableAbstractItem *item,
if (keyframe != current) if (keyframe != current)
keyframe->commitPosition(mapToItem(current, keyframe->rect().center())); 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(); blockUpdates();
try { m_frame.view()->executeInTransaction("TimelineKeyframeItem::commitPosition", [this, frame](){
RewriterTransaction transaction(
m_frame.view()->beginRewriterTransaction("TimelineKeyframeItem::commitPosition"));
m_frame.variantProperty("frame").setValue(frame); m_frame.variantProperty("frame").setValue(frame);
transaction.commit(); });
} catch (const RewritingException &e) {
e.showException();
}
enableUpdates(); enableUpdates();
} }

View File

@@ -821,20 +821,15 @@ void TimelineBarItem::commitPosition(const QPointF & /*point*/)
{ {
if (sectionItem()->view()) { if (sectionItem()->view()) {
if (m_handle != Location::Undefined) { if (m_handle != Location::Undefined) {
sectionItem()->view()->executeInTransaction("TimelineBarItem::commitPosition", [this](){
qreal scaleFactor = rect().width() / m_oldRect.width(); qreal scaleFactor = rect().width() / m_oldRect.width();
qreal moved = (rect().topLeft().x() - m_oldRect.topLeft().x()) / rulerScaling(); qreal moved = (rect().topLeft().x() - m_oldRect.topLeft().x()) / rulerScaling();
qreal supposedFirstFrame = qRound(sectionItem()->firstFrame() + moved); qreal supposedFirstFrame = qRound(sectionItem()->firstFrame() + moved);
try {
RewriterTransaction transaction(sectionItem()->view()->beginRewriterTransaction(
"TimelineBarItem::commitPosition"));
sectionItem()->scaleAllFrames(scaleFactor); sectionItem()->scaleAllFrames(scaleFactor);
sectionItem()->moveAllFrames(supposedFirstFrame - sectionItem()->firstFrame()); 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) void TimelineSettingsModel::updateTimeline(int row)
{ {
timelineView()->executeInTransaction("TimelineSettingsModel::updateTimeline", [this, row](){
QmlModelState modelState(stateForRow(row)); QmlModelState modelState(stateForRow(row));
QmlTimeline timeline(timelineForRow(row)); QmlTimeline timeline(timelineForRow(row));
ModelNode animation(animationForRow(row)); ModelNode animation(animationForRow(row));
QmlTimeline oldTimeline = timelineView()->timelineForState(modelState); QmlTimeline oldTimeline = timelineView()->timelineForState(modelState);
RewriterTransaction transaction = timelineView()->beginRewriterTransaction(
QByteArrayLiteral("TimelineSettingsModel::updateTimeline"));
try {
if (modelState.isBaseState()) { if (modelState.isBaseState()) {
if (oldTimeline.isValid()) if (oldTimeline.isValid())
oldTimeline.modelNode().variantProperty("enabled").setValue(false); oldTimeline.modelNode().variantProperty("enabled").setValue(false);
@@ -301,27 +299,20 @@ void TimelineSettingsModel::updateTimeline(int row)
propertyChanges.modelNode().variantProperty("enabled").setValue(true); propertyChanges.modelNode().variantProperty("enabled").setValue(true);
} }
} }
});
} catch (Exception &e) {
m_exceptionError = e.description();
QTimer::singleShot(200, this, &TimelineSettingsModel::handleException);
}
resetRow(row); resetRow(row);
} }
void TimelineSettingsModel::updateAnimation(int row) void TimelineSettingsModel::updateAnimation(int row)
{ {
timelineView()->executeInTransaction("TimelineSettingsModel::updateAnimation", [this, row](){
QmlModelState modelState(stateForRow(row)); QmlModelState modelState(stateForRow(row));
QmlTimeline timeline(timelineForRow(row)); QmlTimeline timeline(timelineForRow(row));
ModelNode animation(animationForRow(row)); ModelNode animation(animationForRow(row));
QmlTimeline oldTimeline = timelineView()->timelineForState(modelState); QmlTimeline oldTimeline = timelineView()->timelineForState(modelState);
ModelNode oldAnimation = animationForTimelineAndState(oldTimeline, modelState); ModelNode oldAnimation = animationForTimelineAndState(oldTimeline, modelState);
RewriterTransaction transaction = timelineView()->beginRewriterTransaction(
QByteArrayLiteral("TimelineSettingsModel::updateAnimation"));
try {
if (modelState.isBaseState()) { if (modelState.isBaseState()) {
if (oldAnimation.isValid()) if (oldAnimation.isValid())
oldAnimation.variantProperty("running").setValue(false); oldAnimation.variantProperty("running").setValue(false);
@@ -353,27 +344,20 @@ void TimelineSettingsModel::updateAnimation(int row)
propertyChanges.modelNode().variantProperty("running").setValue(true); propertyChanges.modelNode().variantProperty("running").setValue(true);
} }
} }
} catch (Exception &e) { });
m_exceptionError = e.description();
QTimer::singleShot(200, this, &TimelineSettingsModel::handleException);
}
resetRow(row); resetRow(row);
} }
void TimelineSettingsModel::updateFixedFrameRow(int row) void TimelineSettingsModel::updateFixedFrameRow(int row)
{ {
timelineView()->executeInTransaction("TimelineSettingsModel::updateFixedFrameRow", [this, row](){
QmlModelState modelState(stateForRow(row)); QmlModelState modelState(stateForRow(row));
QmlTimeline timeline(timelineForRow(row)); QmlTimeline timeline(timelineForRow(row));
ModelNode animation = animationForTimelineAndState(timeline, modelState); ModelNode animation = animationForTimelineAndState(timeline, modelState);
RewriterTransaction transaction = timelineView()->beginRewriterTransaction(
QByteArrayLiteral("TimelineSettingsModel::updateFixedFrameRow"));
int fixedFrame = fixedFrameForRow(row); int fixedFrame = fixedFrameForRow(row);
try {
if (modelState.isBaseState()) { if (modelState.isBaseState()) {
if (animation.isValid()) if (animation.isValid())
animation.variantProperty("running").setValue(false); animation.variantProperty("running").setValue(false);
@@ -390,10 +374,8 @@ void TimelineSettingsModel::updateFixedFrameRow(int row)
if (propertyChanges.isValid()) if (propertyChanges.isValid())
propertyChanges.modelNode().variantProperty("currentFrame").setValue(fixedFrame); propertyChanges.modelNode().variantProperty("currentFrame").setValue(fixedFrame);
} }
} catch (Exception &e) {
m_exceptionError = e.description(); });
QTimer::singleShot(200, this, &TimelineSettingsModel::handleException);
}
resetRow(row); resetRow(row);
} }

View File

@@ -264,9 +264,7 @@ const QmlTimeline TimelineView::addNewTimeline()
ModelNode timelineNode; ModelNode timelineNode;
try { executeInTransaction("TimelineView::addNewTimeline", [=, &timelineNode](){
RewriterTransaction transaction(beginRewriterTransaction("TimelineView::addNewTimeline"));
bool hasTimelines = getTimelines().isEmpty(); bool hasTimelines = getTimelines().isEmpty();
timelineNode = createModelNode(timelineType, timelineNode = createModelNode(timelineType,
@@ -279,10 +277,7 @@ const QmlTimeline TimelineView::addNewTimeline()
timelineNode.variantProperty("enabled").setValue(hasTimelines); timelineNode.variantProperty("enabled").setValue(hasTimelines);
rootModelNode().defaultNodeListProperty().reparentHere(timelineNode); rootModelNode().defaultNodeListProperty().reparentHere(timelineNode);
transaction.commit(); });
} catch (const Exception &e) {
e.showException();
}
return QmlTimeline(timelineNode); return QmlTimeline(timelineNode);
} }
@@ -300,10 +295,8 @@ ModelNode TimelineView::addAnimation(QmlTimeline timeline)
QTC_ASSERT(metaInfo.isValid(), return ModelNode()); QTC_ASSERT(metaInfo.isValid(), return ModelNode());
ModelNode animationNode; ModelNode animationNode;
try {
RewriterTransaction transaction(
beginRewriterTransaction("TimelineSettingsDialog::addAnimation"));
executeInTransaction("TimelineView::addAnimation", [=, &animationNode](){
animationNode = createModelNode(animationType, animationNode = createModelNode(animationType,
metaInfo.majorVersion(), metaInfo.majorVersion(),
metaInfo.minorVersion()); metaInfo.minorVersion());
@@ -321,10 +314,7 @@ ModelNode TimelineView::addAnimation(QmlTimeline timeline)
if (timeline.modelNode().hasProperty("currentFrame")) if (timeline.modelNode().hasProperty("currentFrame"))
timeline.modelNode().removeProperty("currentFrame"); timeline.modelNode().removeProperty("currentFrame");
transaction.commit(); });
} catch (const Exception &e) {
e.showException();
}
return animationNode; return animationNode;
} }
@@ -391,9 +381,7 @@ void TimelineView::insertKeyframe(const ModelNode &target, const PropertyName &p
ModelNode targetNode = target; ModelNode targetNode = target;
if (timeline.isValid() && targetNode.isValid() if (timeline.isValid() && targetNode.isValid()
&& QmlObjectNode::isValidQmlObjectNode(targetNode)) { && QmlObjectNode::isValidQmlObjectNode(targetNode)) {
try { executeInTransaction("TimelineView::insertKeyframe", [=, &timeline, &targetNode](){
RewriterTransaction transaction(
beginRewriterTransaction("TimelineView::insertKeyframe"));
targetNode.validId(); targetNode.validId();
@@ -408,10 +396,7 @@ void TimelineView::insertKeyframe(const ModelNode &target, const PropertyName &p
timelineFrames.setValue(value, frame); 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/") 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()) if (!definition().isValid())
return; return;
const QTextBlock block = currentBlock(); QTextBlock block = currentBlock();
KSyntaxHighlighting::State state; KSyntaxHighlighting::State state;
setCurrentBlockState(qMax(0, previousBlockState())); TextDocumentLayout::setBraceDepth(block, TextDocumentLayout::braceDepth(block.previous()));
if (TextBlockUserData *data = TextDocumentLayout::testUserData(block)) { if (TextBlockUserData *data = TextDocumentLayout::testUserData(block)) {
state = data->syntaxState(); state = data->syntaxState();
data->setFoldingStartIncluded(false); data->setFoldingStartIncluded(false);
@@ -298,8 +298,11 @@ void Highlighter::highlightBlock(const QString &text)
if (nextBlock.isValid()) { if (nextBlock.isValid()) {
TextBlockUserData *data = TextDocumentLayout::userData(nextBlock); TextBlockUserData *data = TextDocumentLayout::userData(nextBlock);
if (data->syntaxState() != state) {
data->setSyntaxState(state); data->setSyntaxState(state);
data->setFoldingIndent(currentBlockState()); setCurrentBlockState(currentBlockState() ^ 1); // force rehighlight of next block
}
data->setFoldingIndent(TextDocumentLayout::braceDepth(block));
} }
formatSpaces(text); formatSpaces(text);
@@ -316,24 +319,24 @@ void Highlighter::applyFolding(int offset,
{ {
if (!region.isValid()) if (!region.isValid())
return; return;
const QTextBlock &block = currentBlock(); QTextBlock block = currentBlock();
const QString &text = block.text(); const QString &text = block.text();
TextBlockUserData *data = TextDocumentLayout::userData(currentBlock()); TextBlockUserData *data = TextDocumentLayout::userData(currentBlock());
const bool fromStart = TabSettings::firstNonSpace(text) == offset; const bool fromStart = TabSettings::firstNonSpace(text) == offset;
const bool toEnd = (offset + length) == (text.length() - TabSettings::trailingWhitespaces(text)); const bool toEnd = (offset + length) == (text.length() - TabSettings::trailingWhitespaces(text));
if (region.type() == KSyntaxHighlighting::FoldingRegion::Begin) { 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 there is only a folding begin in the line move the current block into the fold
if (fromStart && toEnd) { if (fromStart && toEnd) {
data->setFoldingIndent(currentBlockState()); data->setFoldingIndent(TextDocumentLayout::braceDepth(block));
data->setFoldingStartIncluded(true); data->setFoldingStartIncluded(true);
} }
} else if (region.type() == KSyntaxHighlighting::FoldingRegion::End) { } 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 the folding end is at the end of the line move the current block into the fold
if (toEnd) if (toEnd)
data->setFoldingEndIncluded(true); data->setFoldingEndIncluded(true);
else else
data->setFoldingIndent(currentBlockState()); data->setFoldingIndent(TextDocumentLayout::braceDepth(block));
} }
} }

View File

@@ -21,5 +21,13 @@ Item {
{ {
console.log("test") 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 x
var y = 12 var y = 12
var a_var = 1
let a_let = 2
const a_const = 3
function foo(a, b) { function foo(a, b) {
x = 15 x = 15
x += 4 x += 4
@@ -28,6 +32,12 @@ while (true) {
for (var x in a) { for (var x in a) {
print(a[x]) print(a[x])
} }
for (let x in a) {
print(a[x])
}
for (const x in a) {
print(a[x])
}
do { do {
a = x a = x

View File

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

View File

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

View File

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

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