forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/4.14' into master
Change-Id: Ic5e99ec54e2cedbabd78eabc2f0350f90daa0cec
This commit is contained in:
@@ -24,7 +24,6 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
import QtQuick 2.15
|
import QtQuick 2.15
|
||||||
import QtQuick3D 1.15
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
@@ -33,10 +32,12 @@ Item {
|
|||||||
|
|
||||||
property alias contentItem: contentItem
|
property alias contentItem: contentItem
|
||||||
|
|
||||||
|
/*
|
||||||
View3D {
|
View3D {
|
||||||
// Dummy view to hold the context in case View3D items are used in the component
|
// Dummy view to hold the context in case View3D items are used in the component
|
||||||
// TODO remove when QTBUG-87678 is fixed
|
// TODO remove when QTBUG-87678 is fixed
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: contentItem
|
id: contentItem
|
||||||
|
@@ -63,7 +63,7 @@ Column {
|
|||||||
Section {
|
Section {
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
caption: "Rectangle"
|
caption: qsTr("Rectangle")
|
||||||
|
|
||||||
SectionLayout {
|
SectionLayout {
|
||||||
rows: 2
|
rows: 2
|
||||||
|
@@ -45,7 +45,10 @@ Item {
|
|||||||
width: 96
|
width: 96
|
||||||
implicitHeight: spinBox.height
|
implicitHeight: spinBox.height
|
||||||
|
|
||||||
onFocusChanged: transaction.end();
|
onFocusChanged: {
|
||||||
|
restoreCursor();
|
||||||
|
transaction.end();
|
||||||
|
}
|
||||||
|
|
||||||
StudioControls.RealSpinBox {
|
StudioControls.RealSpinBox {
|
||||||
id: spinBox
|
id: spinBox
|
||||||
@@ -60,6 +63,8 @@ Item {
|
|||||||
transaction.end();
|
transaction.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onDragging: holdCursorInPlace();
|
||||||
|
|
||||||
onRealValueModified: {
|
onRealValueModified: {
|
||||||
if (transaction.active())
|
if (transaction.active())
|
||||||
commitValue();
|
commitValue();
|
||||||
|
@@ -55,7 +55,8 @@ Rectangle {
|
|||||||
visible: text !== StudioTheme.Constants.actionIcon || actionIndicator.forceVisible
|
visible: text !== StudioTheme.Constants.actionIcon || actionIndicator.forceVisible
|
||||||
|| (myControl !== undefined &&
|
|| (myControl !== undefined &&
|
||||||
((myControl.edit !== undefined && myControl.edit)
|
((myControl.edit !== undefined && myControl.edit)
|
||||||
|| (myControl.hover !== undefined && myControl.hover)))
|
|| (myControl.hover !== undefined && myControl.hover)
|
||||||
|
|| (myControl.drag !== undefined && myControl.drag)))
|
||||||
color: StudioTheme.Values.themeTextColor
|
color: StudioTheme.Values.themeTextColor
|
||||||
font.family: StudioTheme.Constants.iconFont.family
|
font.family: StudioTheme.Constants.iconFont.family
|
||||||
font.pixelSize: StudioTheme.Values.myIconFontSize
|
font.pixelSize: StudioTheme.Values.myIconFontSize
|
||||||
|
@@ -55,6 +55,7 @@ T.SpinBox {
|
|||||||
|
|
||||||
property bool dirty: false // user modification flag
|
property bool dirty: false // user modification flag
|
||||||
|
|
||||||
|
// TODO Not used anymore. Will be removed when all dependencies were removed.
|
||||||
property real realDragRange: mySpinBox.realTo - mySpinBox.realFrom
|
property real realDragRange: mySpinBox.realTo - mySpinBox.realFrom
|
||||||
|
|
||||||
property alias actionIndicatorVisible: actionIndicator.visible
|
property alias actionIndicatorVisible: actionIndicator.visible
|
||||||
@@ -77,6 +78,7 @@ T.SpinBox {
|
|||||||
signal compressedRealValueModified
|
signal compressedRealValueModified
|
||||||
signal dragStarted
|
signal dragStarted
|
||||||
signal dragEnded
|
signal dragEnded
|
||||||
|
signal dragging
|
||||||
|
|
||||||
// Use custom wheel handling due to bugs
|
// Use custom wheel handling due to bugs
|
||||||
property bool __wheelEnabled: false
|
property bool __wheelEnabled: false
|
||||||
|
@@ -70,61 +70,25 @@ TextInput {
|
|||||||
height: StudioTheme.Values.height
|
height: StudioTheme.Values.height
|
||||||
}
|
}
|
||||||
|
|
||||||
DragHandler {
|
|
||||||
id: dragHandler
|
|
||||||
target: null
|
|
||||||
acceptedDevices: PointerDevice.Mouse
|
|
||||||
enabled: true
|
|
||||||
|
|
||||||
property real initialValue: myControl.realValue
|
|
||||||
property real multiplier: 1.0
|
|
||||||
|
|
||||||
onActiveChanged: {
|
|
||||||
if (dragHandler.active) {
|
|
||||||
dragHandler.initialValue = myControl.realValue
|
|
||||||
mouseArea.cursorShape = Qt.ClosedHandCursor // TODO
|
|
||||||
myControl.drag = true
|
|
||||||
myControl.dragStarted()
|
|
||||||
// Force focus on the non visible component to receive key events
|
|
||||||
dragModifierWorkaround.forceActiveFocus()
|
|
||||||
} else {
|
|
||||||
if (myControl.compressedValueTimer.running) {
|
|
||||||
myControl.compressedValueTimer.stop()
|
|
||||||
calcValue(myControl.compressedRealValueModified)
|
|
||||||
}
|
|
||||||
mouseArea.cursorShape = Qt.PointingHandCursor // TODO
|
|
||||||
myControl.drag = false
|
|
||||||
myControl.dragEnded()
|
|
||||||
// Avoid active focus on the component after dragging
|
|
||||||
dragModifierWorkaround.focus = false
|
|
||||||
textInput.focus = false
|
|
||||||
myControl.focus = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onTranslationChanged: calcValue(myControl.realValueModified)
|
|
||||||
onMultiplierChanged: calcValue(myControl.realValueModified)
|
|
||||||
|
|
||||||
function calcValue(callback) {
|
|
||||||
var tmp = myControl.realDragRange / StudioTheme.Values.dragLength
|
|
||||||
myControl.setRealValue(dragHandler.initialValue + (tmp * dragHandler.translation.x * dragHandler.multiplier))
|
|
||||||
callback()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: dragModifierWorkaround
|
id: dragModifierWorkaround
|
||||||
Keys.onPressed: {
|
Keys.onPressed: {
|
||||||
event.accepted = true
|
event.accepted = true
|
||||||
|
|
||||||
if (event.modifiers & Qt.ControlModifier)
|
if (event.modifiers & Qt.ControlModifier) {
|
||||||
dragHandler.multiplier = 0.1
|
mouseArea.stepSize = myControl.minStepSize
|
||||||
|
mouseArea.calcValue(myControl.realValueModified)
|
||||||
|
}
|
||||||
|
|
||||||
if (event.modifiers & Qt.ShiftModifier)
|
if (event.modifiers & Qt.ShiftModifier) {
|
||||||
dragHandler.multiplier = 10.0
|
mouseArea.stepSize = myControl.maxStepSize
|
||||||
|
mouseArea.calcValue(myControl.realValueModified)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Keys.onReleased: {
|
Keys.onReleased: {
|
||||||
event.accepted = true
|
event.accepted = true
|
||||||
dragHandler.multiplier = 1.0
|
mouseArea.stepSize = myControl.realStepSize
|
||||||
|
mouseArea.calcValue(myControl.realValueModified)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,21 +97,21 @@ TextInput {
|
|||||||
event.accepted = (event.key === Qt.Key_Up || event.key === Qt.Key_Down)
|
event.accepted = (event.key === Qt.Key_Up || event.key === Qt.Key_Down)
|
||||||
}
|
}
|
||||||
|
|
||||||
TapHandler {
|
|
||||||
id: tapHandler
|
|
||||||
acceptedDevices: PointerDevice.Mouse
|
|
||||||
enabled: true
|
|
||||||
onTapped: {
|
|
||||||
textInput.forceActiveFocus()
|
|
||||||
textInput.deselect() // QTBUG-75862
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: mouseArea
|
id: mouseArea
|
||||||
|
|
||||||
property real stepSize: myControl.realStepSize
|
property real stepSize: myControl.realStepSize
|
||||||
|
|
||||||
|
property bool dragging: false
|
||||||
|
property bool wasDragging: false
|
||||||
|
property bool potentialDragStart: false
|
||||||
|
|
||||||
|
property real initialValue: myControl.realValue
|
||||||
|
|
||||||
|
property real pressStartX: 0.0
|
||||||
|
property real dragStartX: 0.0
|
||||||
|
property real translationX: 0.0
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
enabled: true
|
enabled: true
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
@@ -156,7 +120,90 @@ TextInput {
|
|||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
// Sets the global hover
|
// Sets the global hover
|
||||||
onContainsMouseChanged: myControl.hover = containsMouse
|
onContainsMouseChanged: myControl.hover = containsMouse
|
||||||
onPressed: mouse.accepted = false
|
|
||||||
|
onPositionChanged: {
|
||||||
|
if (!mouseArea.dragging
|
||||||
|
&& !myControl.edit
|
||||||
|
&& Math.abs(mouseArea.pressStartX - mouse.x) > StudioTheme.Values.dragThreshold
|
||||||
|
&& mouse.buttons === 1
|
||||||
|
&& mouseArea.potentialDragStart) {
|
||||||
|
mouseArea.dragging = true
|
||||||
|
mouseArea.potentialDragStart = false
|
||||||
|
mouseArea.initialValue = myControl.realValue
|
||||||
|
mouseArea.cursorShape = Qt.ClosedHandCursor
|
||||||
|
mouseArea.dragStartX = mouseArea.mouseX
|
||||||
|
|
||||||
|
myControl.drag = true
|
||||||
|
myControl.dragStarted()
|
||||||
|
// Force focus on the non visible component to receive key events
|
||||||
|
dragModifierWorkaround.forceActiveFocus()
|
||||||
|
textInput.deselect()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mouseArea.dragging)
|
||||||
|
return
|
||||||
|
|
||||||
|
mouse.accepted = true
|
||||||
|
|
||||||
|
mouseArea.translationX += (mouseArea.mouseX - mouseArea.dragStartX)
|
||||||
|
mouseArea.calcValue(myControl.realValueModified)
|
||||||
|
}
|
||||||
|
|
||||||
|
onCanceled: mouseArea.endDrag()
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
if (mouseArea.wasDragging) {
|
||||||
|
mouseArea.wasDragging = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
textInput.forceActiveFocus()
|
||||||
|
textInput.deselect() // QTBUG-75862
|
||||||
|
}
|
||||||
|
|
||||||
|
onPressed: {
|
||||||
|
mouseArea.potentialDragStart = true
|
||||||
|
mouseArea.pressStartX = mouseArea.mouseX
|
||||||
|
}
|
||||||
|
|
||||||
|
onReleased: mouseArea.endDrag()
|
||||||
|
|
||||||
|
function endDrag() {
|
||||||
|
if (!mouseArea.dragging)
|
||||||
|
return
|
||||||
|
|
||||||
|
mouseArea.dragging = false
|
||||||
|
mouseArea.wasDragging = true
|
||||||
|
|
||||||
|
if (myControl.compressedValueTimer.running) {
|
||||||
|
myControl.compressedValueTimer.stop()
|
||||||
|
mouseArea.calcValue(myControl.compressedRealValueModified)
|
||||||
|
}
|
||||||
|
mouseArea.cursorShape = Qt.PointingHandCursor
|
||||||
|
myControl.drag = false
|
||||||
|
myControl.dragEnded()
|
||||||
|
// Avoid active focus on the component after dragging
|
||||||
|
dragModifierWorkaround.focus = false
|
||||||
|
textInput.focus = false
|
||||||
|
myControl.focus = false
|
||||||
|
|
||||||
|
mouseArea.translationX = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function calcValue(callback) {
|
||||||
|
var minTranslation = (myControl.realFrom - mouseArea.initialValue) / mouseArea.stepSize
|
||||||
|
var maxTranslation = (myControl.realTo - mouseArea.initialValue) / mouseArea.stepSize
|
||||||
|
|
||||||
|
mouseArea.translationX = Math.min(Math.max(mouseArea.translationX, minTranslation), maxTranslation)
|
||||||
|
|
||||||
|
myControl.setRealValue(mouseArea.initialValue + (mouseArea.translationX * mouseArea.stepSize))
|
||||||
|
|
||||||
|
if (mouseArea.dragging)
|
||||||
|
myControl.dragging()
|
||||||
|
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
|
||||||
onWheel: {
|
onWheel: {
|
||||||
if (!myControl.__wheelEnabled)
|
if (!myControl.__wheelEnabled)
|
||||||
return
|
return
|
||||||
@@ -187,14 +234,6 @@ TextInput {
|
|||||||
color: StudioTheme.Values.themeControlBackground
|
color: StudioTheme.Values.themeControlBackground
|
||||||
border.color: StudioTheme.Values.themeControlOutline
|
border.color: StudioTheme.Values.themeControlOutline
|
||||||
}
|
}
|
||||||
PropertyChanges {
|
|
||||||
target: dragHandler
|
|
||||||
enabled: true
|
|
||||||
}
|
|
||||||
PropertyChanges {
|
|
||||||
target: tapHandler
|
|
||||||
enabled: true
|
|
||||||
}
|
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
target: mouseArea
|
target: mouseArea
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
@@ -217,14 +256,6 @@ TextInput {
|
|||||||
color: StudioTheme.Values.themeFocusEdit
|
color: StudioTheme.Values.themeFocusEdit
|
||||||
border.color: StudioTheme.Values.themeInteraction
|
border.color: StudioTheme.Values.themeInteraction
|
||||||
}
|
}
|
||||||
PropertyChanges {
|
|
||||||
target: dragHandler
|
|
||||||
enabled: false
|
|
||||||
}
|
|
||||||
PropertyChanges {
|
|
||||||
target: tapHandler
|
|
||||||
enabled: false
|
|
||||||
}
|
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
target: mouseArea
|
target: mouseArea
|
||||||
cursorShape: Qt.IBeamCursor
|
cursorShape: Qt.IBeamCursor
|
||||||
|
@@ -50,7 +50,7 @@ QtObject {
|
|||||||
property real sliderControlSize: 12
|
property real sliderControlSize: 12
|
||||||
property real sliderControlSizeMulti: values.sliderControlSize * values.scaleFactor
|
property real sliderControlSizeMulti: values.sliderControlSize * values.scaleFactor
|
||||||
|
|
||||||
property int dragLength: 400 // px
|
property int dragThreshold: 10 // px
|
||||||
property real spinControlIconSize: 8
|
property real spinControlIconSize: 8
|
||||||
property real spinControlIconSizeMulti: values.spinControlIconSize * values.scaleFactor
|
property real spinControlIconSizeMulti: values.spinControlIconSize * values.scaleFactor
|
||||||
|
|
||||||
|
@@ -34,22 +34,28 @@ find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Quick REQUIRED)
|
|||||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick REQUIRED)
|
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick REQUIRED)
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
if(ANDROID)
|
set(PROJECT_SOURCES
|
||||||
add_library(%{ProjectName} SHARED
|
%{MainCppFileName}
|
||||||
%{MainCppFileName}
|
qml.qrc
|
||||||
qml.qrc
|
@if %{HasTranslation}
|
||||||
@if %{HasTranslation}
|
${TS_FILES}
|
||||||
${TS_FILES}
|
@endif
|
||||||
@endif
|
)
|
||||||
|
|
||||||
|
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||||
|
qt_add_executable(%{ProjectName}
|
||||||
|
${PROJECT_SOURCES}
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
add_executable(%{ProjectName}
|
if(ANDROID)
|
||||||
%{MainCppFileName}
|
add_library(%{ProjectName} SHARED
|
||||||
qml.qrc
|
${PROJECT_SOURCES}
|
||||||
@if %{HasTranslation}
|
)
|
||||||
${TS_FILES}
|
else()
|
||||||
@endif
|
add_executable(%{ProjectName}
|
||||||
)
|
${PROJECT_SOURCES}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_compile_definitions(%{ProjectName}
|
target_compile_definitions(%{ProjectName}
|
||||||
|
@@ -34,30 +34,32 @@ find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED)
|
|||||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)
|
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
if(ANDROID)
|
set(PROJECT_SOURCES
|
||||||
add_library(%{ProjectName} SHARED
|
%{MainFileName}
|
||||||
%{MainFileName}
|
%{SrcFileName}
|
||||||
%{SrcFileName}
|
%{HdrFileName}
|
||||||
%{HdrFileName}
|
@if %{GenerateForm}
|
||||||
@if %{GenerateForm}
|
%{FormFileName}
|
||||||
%{FormFileName}
|
@endif
|
||||||
@endif
|
@if %{HasTranslation}
|
||||||
@if %{HasTranslation}
|
${TS_FILES}
|
||||||
${TS_FILES}
|
@endif
|
||||||
@endif
|
)
|
||||||
)
|
|
||||||
|
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||||
|
qt_add_executable(%{ProjectName}
|
||||||
|
${PROJECT_SOURCES}
|
||||||
|
)
|
||||||
else()
|
else()
|
||||||
add_executable(%{ProjectName}
|
if(ANDROID)
|
||||||
%{MainFileName}
|
add_library(%{ProjectName} SHARED
|
||||||
%{SrcFileName}
|
${PROJECT_SOURCES}
|
||||||
%{HdrFileName}
|
)
|
||||||
@if %{GenerateForm}
|
else()
|
||||||
%{FormFileName}
|
add_executable(%{ProjectName}
|
||||||
@endif
|
${PROJECT_SOURCES}
|
||||||
@if %{HasTranslation}
|
)
|
||||||
${TS_FILES}
|
endif()
|
||||||
@endif
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(%{ProjectName} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
target_link_libraries(%{ProjectName} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace QmlJS {
|
namespace QmlJS {
|
||||||
|
@@ -997,13 +997,13 @@ Container<T> static_container_cast(const Container<Base> &container)
|
|||||||
template <typename Container>
|
template <typename Container>
|
||||||
inline void sort(Container &container)
|
inline void sort(Container &container)
|
||||||
{
|
{
|
||||||
std::sort(std::begin(container), std::end(container));
|
std::stable_sort(std::begin(container), std::end(container));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Container, typename Predicate>
|
template <typename Container, typename Predicate>
|
||||||
inline void sort(Container &container, Predicate p)
|
inline void sort(Container &container, Predicate p)
|
||||||
{
|
{
|
||||||
std::sort(std::begin(container), std::end(container), p);
|
std::stable_sort(std::begin(container), std::end(container), p);
|
||||||
}
|
}
|
||||||
|
|
||||||
// pointer to member
|
// pointer to member
|
||||||
@@ -1012,7 +1012,7 @@ inline void sort(Container &container, R S::*member)
|
|||||||
{
|
{
|
||||||
auto f = std::mem_fn(member);
|
auto f = std::mem_fn(member);
|
||||||
using const_ref = typename Container::const_reference;
|
using const_ref = typename Container::const_reference;
|
||||||
std::sort(std::begin(container), std::end(container),
|
std::stable_sort(std::begin(container), std::end(container),
|
||||||
[&f](const_ref a, const_ref b) {
|
[&f](const_ref a, const_ref b) {
|
||||||
return f(a) < f(b);
|
return f(a) < f(b);
|
||||||
});
|
});
|
||||||
@@ -1024,7 +1024,7 @@ inline void sort(Container &container, R (S::*function)() const)
|
|||||||
{
|
{
|
||||||
auto f = std::mem_fn(function);
|
auto f = std::mem_fn(function);
|
||||||
using const_ref = typename Container::const_reference;
|
using const_ref = typename Container::const_reference;
|
||||||
std::sort(std::begin(container), std::end(container),
|
std::stable_sort(std::begin(container), std::end(container),
|
||||||
[&f](const_ref a, const_ref b) {
|
[&f](const_ref a, const_ref b) {
|
||||||
return f(a) < f(b);
|
return f(a) < f(b);
|
||||||
});
|
});
|
||||||
|
@@ -90,7 +90,8 @@ AndroidDeployQtStep::AndroidDeployQtStep(BuildStepList *parent, Utils::Id id)
|
|||||||
|
|
||||||
m_uninstallPreviousPackage = addAspect<BoolAspect>();
|
m_uninstallPreviousPackage = addAspect<BoolAspect>();
|
||||||
m_uninstallPreviousPackage->setSettingsKey(UninstallPreviousPackageKey);
|
m_uninstallPreviousPackage->setSettingsKey(UninstallPreviousPackageKey);
|
||||||
m_uninstallPreviousPackage->setLabel(tr("Uninstall the existing app first"));
|
m_uninstallPreviousPackage->setLabel(tr("Uninstall the existing app first"),
|
||||||
|
BoolAspect::LabelPlacement::AtCheckBox);
|
||||||
m_uninstallPreviousPackage->setValue(false);
|
m_uninstallPreviousPackage->setValue(false);
|
||||||
|
|
||||||
const QtSupport::BaseQtVersion * const qt = QtSupport::QtKitAspect::qtVersion(kit());
|
const QtSupport::BaseQtVersion * const qt = QtSupport::QtKitAspect::qtVersion(kit());
|
||||||
|
@@ -445,7 +445,7 @@ void VcsManager::promptToAdd(const QString &directory, const QStringList &fileNa
|
|||||||
if (dlg.exec() == QDialog::Accepted) {
|
if (dlg.exec() == QDialog::Accepted) {
|
||||||
QStringList notAddedToVc;
|
QStringList notAddedToVc;
|
||||||
foreach (const QString &file, unmanagedFiles) {
|
foreach (const QString &file, unmanagedFiles) {
|
||||||
if (!vc->vcsAdd(file))
|
if (!vc->vcsAdd(QDir(directory).filePath(file)))
|
||||||
notAddedToVc << file;
|
notAddedToVc << file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -36,6 +36,7 @@
|
|||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <cppeditor/cppeditorconstants.h>
|
#include <cppeditor/cppeditorconstants.h>
|
||||||
#include <texteditor/codestyleeditor.h>
|
#include <texteditor/codestyleeditor.h>
|
||||||
|
#include <texteditor/fontsettings.h>
|
||||||
#include <texteditor/icodestylepreferencesfactory.h>
|
#include <texteditor/icodestylepreferencesfactory.h>
|
||||||
#include <texteditor/textdocument.h>
|
#include <texteditor/textdocument.h>
|
||||||
#include <texteditor/displaysettings.h>
|
#include <texteditor/displaysettings.h>
|
||||||
|
@@ -32,7 +32,7 @@ extend_qtc_plugin(Help
|
|||||||
)
|
)
|
||||||
|
|
||||||
extend_qtc_plugin(Help
|
extend_qtc_plugin(Help
|
||||||
CONDITION FWWebKit AND FWAppKit
|
CONDITION FWWebKit AND FWAppKit AND Qt5_VERSION VERSION_LESS 6.0.0
|
||||||
FEATURE_INFO "Native WebKit help viewer"
|
FEATURE_INFO "Native WebKit help viewer"
|
||||||
DEPENDS ${FWWebKit} ${FWAppKit}
|
DEPENDS ${FWWebKit} ${FWAppKit}
|
||||||
DEFINES QTC_MAC_NATIVE_HELPVIEWER
|
DEFINES QTC_MAC_NATIVE_HELPVIEWER
|
||||||
|
@@ -41,10 +41,11 @@ public:
|
|||||||
explicit QLiteHtmlWidget(QWidget *parent = nullptr);
|
explicit QLiteHtmlWidget(QWidget *parent = nullptr);
|
||||||
~QLiteHtmlWidget() override;
|
~QLiteHtmlWidget() override;
|
||||||
|
|
||||||
|
// declaring the getters Q_INVOKABLE to make them Squish-testable
|
||||||
void setUrl(const QUrl &url);
|
void setUrl(const QUrl &url);
|
||||||
QUrl url() const;
|
Q_INVOKABLE QUrl url() const;
|
||||||
void setHtml(const QString &content);
|
void setHtml(const QString &content);
|
||||||
QString title() const;
|
Q_INVOKABLE QString title() const;
|
||||||
|
|
||||||
void setZoomFactor(qreal scale);
|
void setZoomFactor(qreal scale);
|
||||||
qreal zoomFactor() const;
|
qreal zoomFactor() const;
|
||||||
@@ -62,7 +63,8 @@ public:
|
|||||||
using ResourceHandler = std::function<QByteArray(QUrl)>;
|
using ResourceHandler = std::function<QByteArray(QUrl)>;
|
||||||
void setResourceHandler(const ResourceHandler &handler);
|
void setResourceHandler(const ResourceHandler &handler);
|
||||||
|
|
||||||
QString selectedText() const;
|
// declaring this Q_INVOKABLE to make it Squish-testable
|
||||||
|
Q_INVOKABLE QString selectedText() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void linkClicked(const QUrl &url);
|
void linkClicked(const QUrl &url);
|
||||||
|
@@ -1,5 +1,10 @@
|
|||||||
|
find_package(Qt5 COMPONENTS SvgWidgets QUIET)
|
||||||
|
if (TARGET Qt5::SvgWidgets)
|
||||||
|
set(SVG_WIDGETS Qt5::SvgWidgets)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_qtc_plugin(ImageViewer
|
add_qtc_plugin(ImageViewer
|
||||||
DEPENDS OptionalSvg
|
DEPENDS OptionalSvg ${SVG_WIDGETS}
|
||||||
PLUGIN_DEPENDS Core
|
PLUGIN_DEPENDS Core
|
||||||
SOURCES
|
SOURCES
|
||||||
exportdialog.cpp exportdialog.h
|
exportdialog.cpp exportdialog.h
|
||||||
|
@@ -26,7 +26,12 @@
|
|||||||
#include "editorsettingspropertiespage.h"
|
#include "editorsettingspropertiespage.h"
|
||||||
#include "editorconfiguration.h"
|
#include "editorconfiguration.h"
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
|
|
||||||
|
#include <texteditor/behaviorsettings.h>
|
||||||
|
#include <texteditor/extraencodingsettings.h>
|
||||||
#include <texteditor/marginsettings.h>
|
#include <texteditor/marginsettings.h>
|
||||||
|
#include <texteditor/storagesettings.h>
|
||||||
|
#include <texteditor/typingsettings.h>
|
||||||
|
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
|
|
||||||
|
@@ -775,7 +775,10 @@ void Target::setNamedSettings(const QString &name, const QVariant &value)
|
|||||||
|
|
||||||
QVariant Target::additionalData(Utils::Id id) const
|
QVariant Target::additionalData(Utils::Id id) const
|
||||||
{
|
{
|
||||||
return buildSystem()->additionalData(id);
|
if (const BuildSystem *bs = buildSystem())
|
||||||
|
return bs->additionalData(id);
|
||||||
|
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
MakeInstallCommand Target::makeInstallCommand(const QString &installRoot) const
|
MakeInstallCommand Target::makeInstallCommand(const QString &installRoot) const
|
||||||
|
@@ -1121,13 +1121,13 @@ void QbsBuildSystem::updateApplicationTargets()
|
|||||||
if (result.error().hasError()) {
|
if (result.error().hasError()) {
|
||||||
Core::MessageManager::write(tr("Error retrieving run environment: %1")
|
Core::MessageManager::write(tr("Error retrieving run environment: %1")
|
||||||
.arg(result.error().toString()));
|
.arg(result.error().toString()));
|
||||||
} else {
|
return;
|
||||||
QProcessEnvironment fullEnv = result.environment();
|
|
||||||
QTC_ASSERT(!fullEnv.isEmpty(), fullEnv = procEnv);
|
|
||||||
env = Utils::Environment();
|
|
||||||
for (const QString &key : fullEnv.keys())
|
|
||||||
env.set(key, fullEnv.value(key));
|
|
||||||
}
|
}
|
||||||
|
QProcessEnvironment fullEnv = result.environment();
|
||||||
|
QTC_ASSERT(!fullEnv.isEmpty(), fullEnv = procEnv);
|
||||||
|
env = Utils::Environment();
|
||||||
|
for (const QString &key : fullEnv.keys())
|
||||||
|
env.set(key, fullEnv.value(key));
|
||||||
m_envCache.insert(key, env);
|
m_envCache.insert(key, env);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
#include "assetexportpluginconstants.h"
|
#include "assetexportpluginconstants.h"
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
#include <QFontInfo>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -68,10 +69,14 @@ QJsonObject TextNodeParser::json(Component &component) const
|
|||||||
|
|
||||||
QJsonObject textDetails;
|
QJsonObject textDetails;
|
||||||
textDetails.insert(TextContentTag, propertyValue("text").toString());
|
textDetails.insert(TextContentTag, propertyValue("text").toString());
|
||||||
textDetails.insert(FontFamilyTag, propertyValue("font.family").toString());
|
|
||||||
textDetails.insert(FontStyleTag, propertyValue("font.styleName").toString());
|
QFont font = propertyValue("font").value<QFont>();
|
||||||
textDetails.insert(FontSizeTag, propertyValue("font.pixelSize").toInt());
|
QFontInfo fontInfo(font);
|
||||||
textDetails.insert(LetterSpacingTag, propertyValue("font.letterSpacing").toFloat());
|
textDetails.insert(FontFamilyTag, fontInfo.family());
|
||||||
|
textDetails.insert(FontStyleTag, fontInfo.styleName());
|
||||||
|
textDetails.insert(FontSizeTag, fontInfo.pixelSize());
|
||||||
|
textDetails.insert(LetterSpacingTag, font.letterSpacing());
|
||||||
|
|
||||||
|
|
||||||
QColor fontColor(propertyValue("font.color").toString());
|
QColor fontColor(propertyValue("font.color").toString());
|
||||||
textDetails.insert(TextColorTag, fontColor.name(QColor::HexArgb));
|
textDetails.insert(TextColorTag, fontColor.name(QColor::HexArgb));
|
||||||
|
@@ -217,6 +217,7 @@ Utils::FilePath DesignDocument::fileName() const
|
|||||||
{
|
{
|
||||||
if (editor())
|
if (editor())
|
||||||
return editor()->document()->filePath();
|
return editor()->document()->filePath();
|
||||||
|
|
||||||
return Utils::FilePath();
|
return Utils::FilePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,14 +240,11 @@ void DesignDocument::loadDocument(QPlainTextEdit *edit)
|
|||||||
{
|
{
|
||||||
Q_CHECK_PTR(edit);
|
Q_CHECK_PTR(edit);
|
||||||
|
|
||||||
connect(edit, &QPlainTextEdit::undoAvailable,
|
connect(edit, &QPlainTextEdit::undoAvailable, this, &DesignDocument::undoAvailable);
|
||||||
this, &DesignDocument::undoAvailable);
|
connect(edit, &QPlainTextEdit::redoAvailable, this, &DesignDocument::redoAvailable);
|
||||||
connect(edit, &QPlainTextEdit::redoAvailable,
|
connect(edit, &QPlainTextEdit::modificationChanged, this, &DesignDocument::dirtyStateChanged);
|
||||||
this, &DesignDocument::redoAvailable);
|
|
||||||
connect(edit, &QPlainTextEdit::modificationChanged,
|
|
||||||
this, &DesignDocument::dirtyStateChanged);
|
|
||||||
|
|
||||||
m_documentTextModifier.reset(new BaseTextEditModifier(dynamic_cast<TextEditor::TextEditorWidget*>(plainTextEdit())));
|
m_documentTextModifier.reset(new BaseTextEditModifier(qobject_cast<TextEditor::TextEditorWidget *>(plainTextEdit())));
|
||||||
|
|
||||||
connect(m_documentTextModifier.data(), &TextModifier::textChanged, this, &DesignDocument::updateQrcFiles);
|
connect(m_documentTextModifier.data(), &TextModifier::textChanged, this, &DesignDocument::updateQrcFiles);
|
||||||
|
|
||||||
@@ -266,7 +264,6 @@ void DesignDocument::changeToDocumentModel()
|
|||||||
viewManager().detachRewriterView();
|
viewManager().detachRewriterView();
|
||||||
viewManager().detachViewsExceptRewriterAndComponetView();
|
viewManager().detachViewsExceptRewriterAndComponetView();
|
||||||
|
|
||||||
|
|
||||||
m_inFileComponentModel.reset();
|
m_inFileComponentModel.reset();
|
||||||
|
|
||||||
viewManager().attachRewriterView();
|
viewManager().attachRewriterView();
|
||||||
@@ -299,7 +296,8 @@ void DesignDocument::updateQrcFiles()
|
|||||||
ProjectExplorer::Project *currentProject = ProjectExplorer::SessionManager::projectForFile(fileName());
|
ProjectExplorer::Project *currentProject = ProjectExplorer::SessionManager::projectForFile(fileName());
|
||||||
|
|
||||||
if (currentProject) {
|
if (currentProject) {
|
||||||
for (const Utils::FilePath &fileName : currentProject->files(ProjectExplorer::Project::SourceFiles)) {
|
const auto srcFiles = currentProject->files(ProjectExplorer::Project::SourceFiles);
|
||||||
|
for (const Utils::FilePath &fileName : srcFiles) {
|
||||||
if (fileName.endsWith(".qrc"))
|
if (fileName.endsWith(".qrc"))
|
||||||
QmlJS::ModelManagerInterface::instance()->updateQrcFile(fileName.toString());
|
QmlJS::ModelManagerInterface::instance()->updateQrcFile(fileName.toString());
|
||||||
}
|
}
|
||||||
@@ -350,6 +348,7 @@ bool DesignDocument::isUndoAvailable() const
|
|||||||
{
|
{
|
||||||
if (plainTextEdit())
|
if (plainTextEdit())
|
||||||
return plainTextEdit()->document()->isUndoAvailable();
|
return plainTextEdit()->document()->isUndoAvailable();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,6 +356,7 @@ bool DesignDocument::isRedoAvailable() const
|
|||||||
{
|
{
|
||||||
if (plainTextEdit())
|
if (plainTextEdit())
|
||||||
return plainTextEdit()->document()->isRedoAvailable();
|
return plainTextEdit()->document()->isRedoAvailable();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,7 +380,7 @@ void DesignDocument::deleteSelected()
|
|||||||
QStringList lockedNodes;
|
QStringList lockedNodes;
|
||||||
for (const ModelNode &modelNode : view()->selectedModelNodes()) {
|
for (const ModelNode &modelNode : view()->selectedModelNodes()) {
|
||||||
for (const ModelNode &node : modelNode.allSubModelNodesAndThisNode()) {
|
for (const ModelNode &node : modelNode.allSubModelNodesAndThisNode()) {
|
||||||
if (node.isValid() && !node.isRootNode() && node.locked())
|
if (node.isValid() && !node.isRootNode() && node.locked() && !lockedNodes.contains(node.id()))
|
||||||
lockedNodes.push_back(node.id());
|
lockedNodes.push_back(node.id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -408,9 +408,8 @@ void DesignDocument::deleteSelected()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rewriterView()->executeInTransaction("DesignDocument::deleteSelected", [this](){
|
rewriterView()->executeInTransaction("DesignDocument::deleteSelected", [this]() {
|
||||||
QList<ModelNode> toDelete = view()->selectedModelNodes();
|
const QList<ModelNode> toDelete = view()->selectedModelNodes();
|
||||||
|
|
||||||
for (ModelNode node : toDelete) {
|
for (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();
|
||||||
@@ -442,32 +441,33 @@ static void scatterItem(const ModelNode &pastedNode, const ModelNode &targetNode
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
bool scatter = false;
|
bool scatter = false;
|
||||||
foreach (const ModelNode &childNode, targetNode.directSubModelNodes()) {
|
for (const ModelNode &childNode : targetNode.directSubModelNodes()) {
|
||||||
if ((childNode.variantProperty("x").value() == pastedNode.variantProperty("x").value()) &&
|
if (childNode.variantProperty("x").value() == pastedNode.variantProperty("x").value() &&
|
||||||
(childNode.variantProperty("y").value() == pastedNode.variantProperty("y").value()))
|
childNode.variantProperty("y").value() == pastedNode.variantProperty("y").value()) {
|
||||||
scatter = true;
|
scatter = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!scatter)
|
if (!scatter)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (offset == -2000) {
|
if (offset == -2000) { // scatter in range
|
||||||
double x = pastedNode.variantProperty("x").value().toDouble();
|
double x = pastedNode.variantProperty("x").value().toDouble();
|
||||||
double y = pastedNode.variantProperty("y").value().toDouble();
|
double y = pastedNode.variantProperty("y").value().toDouble();
|
||||||
double targetWidth = 20;
|
|
||||||
double targetHeight = 20;
|
const double scatterRange = 20.;
|
||||||
x = x + double(QRandomGenerator::global()->generate()) / RAND_MAX * targetWidth
|
x += QRandomGenerator::global()->generateDouble() * scatterRange - scatterRange / 2;
|
||||||
- targetWidth / 2;
|
y += QRandomGenerator::global()->generateDouble() * scatterRange - scatterRange / 2;
|
||||||
y = y + double(QRandomGenerator::global()->generate()) / RAND_MAX * targetHeight
|
|
||||||
- targetHeight / 2;
|
|
||||||
pastedNode.variantProperty("x").setValue(int(x));
|
|
||||||
pastedNode.variantProperty("y").setValue(int(y));
|
|
||||||
} else {
|
|
||||||
double x = pastedNode.variantProperty("x").value().toDouble();
|
|
||||||
double y = pastedNode.variantProperty("y").value().toDouble();
|
|
||||||
x = x + offset;
|
|
||||||
y = y + offset;
|
|
||||||
pastedNode.variantProperty("x").setValue(int(x));
|
pastedNode.variantProperty("x").setValue(int(x));
|
||||||
pastedNode.variantProperty("y").setValue(int(y));
|
pastedNode.variantProperty("y").setValue(int(y));
|
||||||
|
} else { // offset
|
||||||
|
int x = pastedNode.variantProperty("x").value().toInt();
|
||||||
|
int y = pastedNode.variantProperty("y").value().toInt();
|
||||||
|
x += offset;
|
||||||
|
y += offset;
|
||||||
|
pastedNode.variantProperty("x").setValue(x);
|
||||||
|
pastedNode.variantProperty("y").setValue(y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -495,7 +495,7 @@ void DesignDocument::paste()
|
|||||||
if (!view.selectedModelNodes().isEmpty())
|
if (!view.selectedModelNodes().isEmpty())
|
||||||
targetNode = view.selectedModelNodes().constFirst();
|
targetNode = view.selectedModelNodes().constFirst();
|
||||||
|
|
||||||
//In case we copy and paste a selection we paste in the parent item
|
// in case we copy and paste a selection we paste in the parent item
|
||||||
if ((view.selectedModelNodes().count() == selectedNodes.count()) && targetNode.isValid() && targetNode.hasParentProperty()) {
|
if ((view.selectedModelNodes().count() == selectedNodes.count()) && targetNode.isValid() && targetNode.hasParentProperty()) {
|
||||||
targetNode = targetNode.parentProperty().parentModelNode();
|
targetNode = targetNode.parentProperty().parentModelNode();
|
||||||
} else {
|
} else {
|
||||||
@@ -516,19 +516,20 @@ void DesignDocument::paste()
|
|||||||
if (!targetNode.isValid())
|
if (!targetNode.isValid())
|
||||||
targetNode = view.rootModelNode();
|
targetNode = view.rootModelNode();
|
||||||
|
|
||||||
foreach (const ModelNode &node, selectedNodes) {
|
for (const ModelNode &node : qAsConst(selectedNodes)) {
|
||||||
foreach (const ModelNode &node2, selectedNodes) {
|
for (const ModelNode &node2 : qAsConst(selectedNodes)) {
|
||||||
if (node.isAncestorOf(node2))
|
if (node.isAncestorOf(node2))
|
||||||
selectedNodes.removeAll(node2);
|
selectedNodes.removeAll(node2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rewriterView()->executeInTransaction("DesignDocument::paste1", [&view, selectedNodes, targetNode](){
|
rewriterView()->executeInTransaction("DesignDocument::paste1", [&view, selectedNodes, targetNode]() {
|
||||||
QList<ModelNode> pastedNodeList;
|
QList<ModelNode> pastedNodeList;
|
||||||
|
|
||||||
int offset = double(QRandomGenerator::global()->generate()) / RAND_MAX * 20 - 10;
|
const double scatterRange = 20.;
|
||||||
|
int offset = QRandomGenerator::global()->generateDouble() * scatterRange - scatterRange / 2;
|
||||||
|
|
||||||
foreach (const ModelNode &node, selectedNodes) {
|
for (const ModelNode &node : qAsConst(selectedNodes)) {
|
||||||
PropertyName defaultProperty(targetNode.metaInfo().defaultPropertyName());
|
PropertyName defaultProperty(targetNode.metaInfo().defaultPropertyName());
|
||||||
ModelNode pastedNode(view.insertModel(node));
|
ModelNode pastedNode(view.insertModel(node));
|
||||||
pastedNodeList.append(pastedNode);
|
pastedNodeList.append(pastedNode);
|
||||||
@@ -572,11 +573,11 @@ void DesignDocument::paste()
|
|||||||
PropertyName defaultProperty(targetNode.metaInfo().defaultPropertyName());
|
PropertyName defaultProperty(targetNode.metaInfo().defaultPropertyName());
|
||||||
|
|
||||||
scatterItem(pastedNode, targetNode);
|
scatterItem(pastedNode, targetNode);
|
||||||
if (targetNode.metaInfo().propertyIsListProperty(defaultProperty)) {
|
if (targetNode.metaInfo().propertyIsListProperty(defaultProperty))
|
||||||
targetNode.nodeListProperty(defaultProperty).reparentHere(pastedNode);
|
targetNode.nodeListProperty(defaultProperty).reparentHere(pastedNode);
|
||||||
} else {
|
else
|
||||||
qWarning() << "Cannot reparent to" << targetNode;
|
qWarning() << "Cannot reparent to" << targetNode;
|
||||||
}
|
|
||||||
view.setSelectedModelNodes({pastedNode});
|
view.setSelectedModelNodes({pastedNode});
|
||||||
});
|
});
|
||||||
view.model()->clearMetaInfoCache();
|
view.model()->clearMetaInfoCache();
|
||||||
@@ -591,7 +592,6 @@ void DesignDocument::selectAll()
|
|||||||
DesignDocumentView view;
|
DesignDocumentView view;
|
||||||
currentModel()->attachView(&view);
|
currentModel()->attachView(&view);
|
||||||
|
|
||||||
|
|
||||||
QList<ModelNode> allNodesExceptRootNode(view.allModelNodes());
|
QList<ModelNode> allNodesExceptRootNode(view.allModelNodes());
|
||||||
allNodesExceptRootNode.removeOne(view.rootModelNode());
|
allNodesExceptRootNode.removeOne(view.rootModelNode());
|
||||||
view.setSelectedModelNodes(allNodesExceptRootNode);
|
view.setSelectedModelNodes(allNodesExceptRootNode);
|
||||||
@@ -607,7 +607,6 @@ void DesignDocument::setEditor(Core::IEditor *editor)
|
|||||||
m_textEditor = editor;
|
m_textEditor = editor;
|
||||||
// if the user closed the file explicit we do not want to do anything with it anymore
|
// if the user closed the file explicit we do not want to do anything with it anymore
|
||||||
|
|
||||||
|
|
||||||
connect(Core::EditorManager::instance(), &Core::EditorManager::aboutToSave,
|
connect(Core::EditorManager::instance(), &Core::EditorManager::aboutToSave,
|
||||||
this, [this](Core::IDocument *document) {
|
this, [this](Core::IDocument *document) {
|
||||||
if (m_textEditor && m_textEditor->document() == document) {
|
if (m_textEditor && m_textEditor->document() == document) {
|
||||||
@@ -622,8 +621,7 @@ void DesignDocument::setEditor(Core::IEditor *editor)
|
|||||||
m_textEditor.clear();
|
m_textEditor.clear();
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(editor->document(), &Core::IDocument::filePathChanged,
|
connect(editor->document(), &Core::IDocument::filePathChanged, this, &DesignDocument::updateFileName);
|
||||||
this, &DesignDocument::updateFileName);
|
|
||||||
|
|
||||||
updateActiveTarget();
|
updateActiveTarget();
|
||||||
updateActiveTarget();
|
updateActiveTarget();
|
||||||
@@ -678,7 +676,6 @@ static Target *getActiveTarget(DesignDocument *designDocument)
|
|||||||
if (!currentProject)
|
if (!currentProject)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
|
||||||
QObject::connect(ProjectTree::instance(), &ProjectTree::currentProjectChanged,
|
QObject::connect(ProjectTree::instance(), &ProjectTree::currentProjectChanged,
|
||||||
designDocument, &DesignDocument::updateActiveTarget, Qt::UniqueConnection);
|
designDocument, &DesignDocument::updateActiveTarget, Qt::UniqueConnection);
|
||||||
|
|
||||||
|
@@ -32,7 +32,8 @@
|
|||||||
#include "navigatortreemodel.h"
|
#include "navigatortreemodel.h"
|
||||||
#include "qproxystyle.h"
|
#include "qproxystyle.h"
|
||||||
|
|
||||||
#include "metainfo.h"
|
#include <metainfo.h>
|
||||||
|
#include <theme.h>
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ IconCheckboxItemDelegate::IconCheckboxItemDelegate(QObject *parent,
|
|||||||
QSize IconCheckboxItemDelegate::sizeHint(const QStyleOptionViewItem & /*option*/,
|
QSize IconCheckboxItemDelegate::sizeHint(const QStyleOptionViewItem & /*option*/,
|
||||||
const QModelIndex & /*modelIndex*/) const
|
const QModelIndex & /*modelIndex*/) const
|
||||||
{
|
{
|
||||||
return {15, 20};
|
return {15, 20};
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isChecked(const QModelIndex &modelIndex)
|
static bool isChecked(const QModelIndex &modelIndex)
|
||||||
@@ -63,9 +64,9 @@ static bool isChecked(const QModelIndex &modelIndex)
|
|||||||
return modelIndex.model()->data(modelIndex, Qt::CheckStateRole) == Qt::Checked;
|
return modelIndex.model()->data(modelIndex, Qt::CheckStateRole) == Qt::Checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isVisible(const QModelIndex &modelIndex)
|
static bool isThisOrAncestorLocked(const QModelIndex &modelIndex)
|
||||||
{
|
{
|
||||||
return modelIndex.model()->data(modelIndex, ItemIsVisibleRole).toBool();
|
return modelIndex.model()->data(modelIndex, ItemOrAncestorLocked).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
static ModelNode getModelNode(const QModelIndex &modelIndex)
|
static ModelNode getModelNode(const QModelIndex &modelIndex)
|
||||||
@@ -82,6 +83,13 @@ void IconCheckboxItemDelegate::paint(QPainter *painter,
|
|||||||
const QStyleOptionViewItem &styleOption,
|
const QStyleOptionViewItem &styleOption,
|
||||||
const QModelIndex &modelIndex) const
|
const QModelIndex &modelIndex) const
|
||||||
{
|
{
|
||||||
|
if (styleOption.state & QStyle::State_MouseOver && !isThisOrAncestorLocked(modelIndex))
|
||||||
|
painter->fillRect(styleOption.rect.adjusted(0, delegateMargin, 0, -delegateMargin),
|
||||||
|
Theme::getColor(Theme::Color::DSsliderHandle));
|
||||||
|
|
||||||
|
if (styleOption.state & QStyle::State_Selected)
|
||||||
|
NavigatorTreeView::drawSelectionBackground(painter, styleOption);
|
||||||
|
|
||||||
bool isVisibilityIcon = modelIndex.column() != NavigatorTreeModel::ColumnType::Visibility;
|
bool isVisibilityIcon = modelIndex.column() != NavigatorTreeModel::ColumnType::Visibility;
|
||||||
// We need to invert the check status if visibility icon
|
// We need to invert the check status if visibility icon
|
||||||
bool checked = isVisibilityIcon ? isChecked(modelIndex) : !isChecked(modelIndex);
|
bool checked = isVisibilityIcon ? isChecked(modelIndex) : !isChecked(modelIndex);
|
||||||
@@ -89,10 +97,7 @@ void IconCheckboxItemDelegate::paint(QPainter *painter,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (rowIsPropertyRole(modelIndex.model(), modelIndex))
|
if (rowIsPropertyRole(modelIndex.model(), modelIndex))
|
||||||
return; //Do not paint icons for property rows
|
return; // Do not paint icons for property rows
|
||||||
|
|
||||||
if (styleOption.state & QStyle::State_Selected)
|
|
||||||
NavigatorTreeView::drawSelectionBackground(painter, styleOption);
|
|
||||||
|
|
||||||
if (!getModelNode(modelIndex).isRootNode()) {
|
if (!getModelNode(modelIndex).isRootNode()) {
|
||||||
QWindow *window = dynamic_cast<QWidget*>(painter->device())->window()->windowHandle();
|
QWindow *window = dynamic_cast<QWidget*>(painter->device())->window()->windowHandle();
|
||||||
@@ -101,17 +106,15 @@ void IconCheckboxItemDelegate::paint(QPainter *painter,
|
|||||||
const QRect iconRect(styleOption.rect.left() + 2, styleOption.rect.top() + 2, 16, 16);
|
const QRect iconRect(styleOption.rect.left() + 2, styleOption.rect.top() + 2, 16, 16);
|
||||||
const QIcon &icon = isChecked(modelIndex) ? m_checkedIcon : m_uncheckedIcon;
|
const QIcon &icon = isChecked(modelIndex) ? m_checkedIcon : m_uncheckedIcon;
|
||||||
const QPixmap iconPixmap = icon.pixmap(window, iconRect.size());
|
const QPixmap iconPixmap = icon.pixmap(window, iconRect.size());
|
||||||
const bool visible = isVisible(modelIndex);
|
|
||||||
|
|
||||||
if (!visible) {
|
painter->save();
|
||||||
painter->save();
|
|
||||||
|
if (isThisOrAncestorLocked(modelIndex))
|
||||||
painter->setOpacity(0.5);
|
painter->setOpacity(0.5);
|
||||||
}
|
|
||||||
|
|
||||||
painter->drawPixmap(iconRect.topLeft(), iconPixmap);
|
painter->drawPixmap(iconRect.topLeft() + QPoint(0, delegateMargin), iconPixmap);
|
||||||
|
|
||||||
if (!visible)
|
painter->restore();
|
||||||
painter->restore();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -34,6 +34,7 @@
|
|||||||
#include <metainfo.h>
|
#include <metainfo.h>
|
||||||
#include <modelnodecontextmenu.h>
|
#include <modelnodecontextmenu.h>
|
||||||
#include <qmlobjectnode.h>
|
#include <qmlobjectnode.h>
|
||||||
|
#include <theme.h>
|
||||||
|
|
||||||
#include <coreplugin/messagebox.h>
|
#include <coreplugin/messagebox.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -47,6 +48,8 @@
|
|||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
|
int NameItemDelegate::iconOffset = 0;
|
||||||
|
|
||||||
static QPixmap generateWavyPixmap(qreal maxRadius, const QPen &pen)
|
static QPixmap generateWavyPixmap(qreal maxRadius, const QPen &pen)
|
||||||
{
|
{
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
@@ -111,13 +114,15 @@ NameItemDelegate::NameItemDelegate(QObject *parent)
|
|||||||
|
|
||||||
static int drawIcon(QPainter *painter, const QStyleOptionViewItem &styleOption, const QModelIndex &modelIndex)
|
static int drawIcon(QPainter *painter, const QStyleOptionViewItem &styleOption, const QModelIndex &modelIndex)
|
||||||
{
|
{
|
||||||
QIcon icon = modelIndex.data(Qt::DecorationRole).value<QIcon>();
|
const QIcon icon = modelIndex.data(Qt::DecorationRole).value<QIcon>();
|
||||||
|
int pixmapSize = icon.isNull() ? 4 : 16;
|
||||||
const int pixmapSize = icon.isNull() ? 4 : 16;
|
|
||||||
|
|
||||||
QPixmap pixmap = icon.pixmap(pixmapSize, pixmapSize);
|
QPixmap pixmap = icon.pixmap(pixmapSize, pixmapSize);
|
||||||
|
|
||||||
painter->drawPixmap(styleOption.rect.x() + 1 , styleOption.rect.y() + 2, pixmap);
|
painter->drawPixmap(styleOption.rect.x() + 1 + delegateMargin,
|
||||||
|
styleOption.rect.y() + 2 + delegateMargin,
|
||||||
|
pixmap);
|
||||||
|
|
||||||
|
pixmapSize += delegateMargin;
|
||||||
|
|
||||||
return pixmapSize;
|
return pixmapSize;
|
||||||
}
|
}
|
||||||
@@ -128,19 +133,20 @@ static QRect drawText(QPainter *painter,
|
|||||||
int iconOffset)
|
int iconOffset)
|
||||||
{
|
{
|
||||||
QString displayString = modelIndex.data(Qt::DisplayRole).toString();
|
QString displayString = modelIndex.data(Qt::DisplayRole).toString();
|
||||||
if (displayString.isEmpty())
|
|
||||||
displayString = modelIndex.data(Qt::DisplayRole).toString();
|
|
||||||
QPoint displayStringOffset;
|
QPoint displayStringOffset;
|
||||||
int width = 0;
|
int width = 0;
|
||||||
|
|
||||||
// Check text length does not exceed available space
|
// Check text length does not exceed available space
|
||||||
int extraSpace = 12 + iconOffset;
|
const int extraSpace = 12 + iconOffset;
|
||||||
|
|
||||||
|
displayString = styleOption.fontMetrics.elidedText(displayString,
|
||||||
|
Qt::ElideMiddle,
|
||||||
|
styleOption.rect.width() - extraSpace);
|
||||||
|
displayStringOffset = QPoint(5 + iconOffset, -5 - delegateMargin);
|
||||||
|
|
||||||
displayString = styleOption.fontMetrics.elidedText(displayString, Qt::ElideMiddle, styleOption.rect.width() - extraSpace);
|
|
||||||
displayStringOffset = QPoint(5 + iconOffset, -5);
|
|
||||||
width = styleOption.fontMetrics.horizontalAdvance(displayString);
|
width = styleOption.fontMetrics.horizontalAdvance(displayString);
|
||||||
|
|
||||||
QPoint textPosition = styleOption.rect.bottomLeft() + displayStringOffset;
|
const QPoint textPosition = styleOption.rect.bottomLeft() + displayStringOffset;
|
||||||
painter->drawText(textPosition, displayString);
|
painter->drawText(textPosition, displayString);
|
||||||
|
|
||||||
QRect textFrame;
|
QRect textFrame;
|
||||||
@@ -150,9 +156,9 @@ static QRect drawText(QPainter *painter,
|
|||||||
return textFrame;
|
return textFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isVisible(const QModelIndex &modelIndex)
|
static bool isThisOrAncestorLocked(const QModelIndex &modelIndex)
|
||||||
{
|
{
|
||||||
return modelIndex.model()->data(modelIndex, ItemIsVisibleRole).toBool();
|
return modelIndex.model()->data(modelIndex, ItemOrAncestorLocked).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
static ModelNode getModelNode(const QModelIndex &modelIndex)
|
static ModelNode getModelNode(const QModelIndex &modelIndex)
|
||||||
@@ -175,17 +181,56 @@ static void drawRedWavyUnderLine(QPainter *painter,
|
|||||||
painter->fillRect(textFrame.x(), 0, qCeil(textFrame.width()), qMin(wave.height(), descent), wave);
|
painter->fillRect(textFrame.x(), 0, qCeil(textFrame.width()), qMin(wave.height(), descent), wave);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setId(const QModelIndex &index, const QString &newId)
|
||||||
|
{
|
||||||
|
ModelNode modelNode = getModelNode(index);
|
||||||
|
|
||||||
|
if (!modelNode.isValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (modelNode.id() == newId)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!modelNode.isValidId(newId)) {
|
||||||
|
Core::AsynchronousMessageBox::warning(NavigatorTreeView::tr("Invalid Id"),
|
||||||
|
NavigatorTreeView::tr("%1 is an invalid id.").arg(newId));
|
||||||
|
} else if (modelNode.view()->hasId(newId)) {
|
||||||
|
Core::AsynchronousMessageBox::warning(NavigatorTreeView::tr("Invalid Id"),
|
||||||
|
NavigatorTreeView::tr("%1 already exists.").arg(newId));
|
||||||
|
} else {
|
||||||
|
modelNode.setIdWithRefactoring(newId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void openContextMenu(const QModelIndex &index, const QPoint &pos)
|
||||||
|
{
|
||||||
|
const ModelNode modelNode = getModelNode(index);
|
||||||
|
QTC_ASSERT(modelNode.isValid(), return);
|
||||||
|
ModelNodeContextMenu::showContextMenu(modelNode.view(), pos, QPoint(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize NameItemDelegate::sizeHint(const QStyleOptionViewItem & /*option*/,
|
||||||
|
const QModelIndex & /*modelIndex*/) const
|
||||||
|
{
|
||||||
|
return {15, 20 + (2 * delegateMargin)};
|
||||||
|
}
|
||||||
|
|
||||||
void NameItemDelegate::paint(QPainter *painter,
|
void NameItemDelegate::paint(QPainter *painter,
|
||||||
const QStyleOptionViewItem &styleOption,
|
const QStyleOptionViewItem &styleOption,
|
||||||
const QModelIndex &modelIndex) const
|
const QModelIndex &modelIndex) const
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
|
if (styleOption.state & QStyle::State_MouseOver && !isThisOrAncestorLocked(modelIndex))
|
||||||
|
painter->fillRect(styleOption.rect.adjusted(0, delegateMargin, 0, -delegateMargin),
|
||||||
|
Theme::getColor(Theme::Color::DSsliderHandle));
|
||||||
|
|
||||||
if (styleOption.state & QStyle::State_Selected)
|
if (styleOption.state & QStyle::State_Selected)
|
||||||
NavigatorTreeView::drawSelectionBackground(painter, styleOption);
|
NavigatorTreeView::drawSelectionBackground(painter, styleOption);
|
||||||
|
|
||||||
int iconOffset = drawIcon(painter, styleOption, modelIndex);
|
iconOffset = drawIcon(painter, styleOption, modelIndex);
|
||||||
|
|
||||||
if (!isVisible(modelIndex))
|
if (isThisOrAncestorLocked(modelIndex))
|
||||||
painter->setOpacity(0.5);
|
painter->setOpacity(0.5);
|
||||||
|
|
||||||
QRect textFrame = drawText(painter, styleOption, modelIndex, iconOffset);
|
QRect textFrame = drawText(painter, styleOption, modelIndex, iconOffset);
|
||||||
@@ -196,28 +241,8 @@ void NameItemDelegate::paint(QPainter *painter,
|
|||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void openContextMenu(const QModelIndex &index, const QPoint &pos)
|
|
||||||
{
|
|
||||||
const ModelNode modelNode = getModelNode(index);
|
|
||||||
QTC_ASSERT(modelNode.isValid(), return);
|
|
||||||
ModelNodeContextMenu::showContextMenu(modelNode.view(), pos, QPoint(), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NameItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *, const QStyleOptionViewItem &, const QModelIndex &index)
|
|
||||||
{
|
|
||||||
if (event->type() == QEvent::MouseButtonRelease) {
|
|
||||||
auto mouseEvent = static_cast<QMouseEvent *>(event);
|
|
||||||
if (mouseEvent->button() == Qt::RightButton) {
|
|
||||||
openContextMenu(index, mouseEvent->globalPos());
|
|
||||||
mouseEvent->accept();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget *NameItemDelegate::createEditor(QWidget *parent,
|
QWidget *NameItemDelegate::createEditor(QWidget *parent,
|
||||||
const QStyleOptionViewItem & /*option*/,
|
const QStyleOptionViewItem &/*option*/,
|
||||||
const QModelIndex &index) const
|
const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!getModelNode(index).isValid())
|
if (!getModelNode(index).isValid())
|
||||||
@@ -235,42 +260,35 @@ void NameItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index)
|
|||||||
lineEdit->setText(value);
|
lineEdit->setText(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setId(const QModelIndex &index, const QString &newId)
|
|
||||||
{
|
|
||||||
ModelNode modelNode = getModelNode(index);
|
|
||||||
|
|
||||||
if (!modelNode.isValid())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (modelNode.id() == newId)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!modelNode.isValidId(newId)) {
|
|
||||||
Core::AsynchronousMessageBox::warning(NavigatorTreeView::tr("Invalid Id"),
|
|
||||||
NavigatorTreeView::tr("%1 is an invalid id.").arg(newId));
|
|
||||||
} else if (modelNode.view()->hasId(newId)) {
|
|
||||||
Core::AsynchronousMessageBox::warning(NavigatorTreeView::tr("Invalid Id"),
|
|
||||||
NavigatorTreeView::tr("%1 already exists.").arg(newId));
|
|
||||||
} else {
|
|
||||||
modelNode.setIdWithRefactoring(newId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void NameItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
|
void NameItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(model)
|
Q_UNUSED(model)
|
||||||
auto lineEdit = static_cast<QLineEdit*>(editor);
|
auto lineEdit = static_cast<QLineEdit*>(editor);
|
||||||
setId(index,lineEdit->text());
|
setId(index, lineEdit->text());
|
||||||
lineEdit->clearFocus();
|
lineEdit->clearFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NameItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *, const QStyleOptionViewItem &, const QModelIndex &index)
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::MouseButtonRelease) {
|
||||||
|
auto mouseEvent = static_cast<QMouseEvent *>(event);
|
||||||
|
if (mouseEvent->button() == Qt::RightButton) {
|
||||||
|
openContextMenu(index, mouseEvent->globalPos());
|
||||||
|
mouseEvent->accept();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void NameItemDelegate::updateEditorGeometry(QWidget *editor,
|
void NameItemDelegate::updateEditorGeometry(QWidget *editor,
|
||||||
const QStyleOptionViewItem &option,
|
const QStyleOptionViewItem &option,
|
||||||
const QModelIndex & /*index*/) const
|
const QModelIndex &/*index*/) const
|
||||||
{
|
{
|
||||||
auto lineEdit = static_cast<QLineEdit*>(editor);
|
auto lineEdit = static_cast<QLineEdit*>(editor);
|
||||||
lineEdit->setGeometry(option.rect);
|
lineEdit->setTextMargins(0, 0, 0, 2);
|
||||||
|
// + 2 is shifting the QLineEdit to the left so it will align with the text when activated
|
||||||
|
lineEdit->setGeometry(option.rect.adjusted(iconOffset + 2, delegateMargin, 0, -delegateMargin));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
@@ -34,18 +34,28 @@ class NavigatorTreeModel;
|
|||||||
class NameItemDelegate : public QStyledItemDelegate
|
class NameItemDelegate : public QStyledItemDelegate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static int iconOffset;
|
||||||
|
|
||||||
explicit NameItemDelegate(QObject *parent);
|
explicit NameItemDelegate(QObject *parent);
|
||||||
|
|
||||||
void paint(QPainter *painter, const QStyleOptionViewItem &styleOption,
|
QSize sizeHint(const QStyleOptionViewItem &option,
|
||||||
const QModelIndex &index) const override;
|
const QModelIndex &index) const override;
|
||||||
|
void paint(QPainter *painter,
|
||||||
|
const QStyleOptionViewItem &styleOption,
|
||||||
|
const QModelIndex &index) const override;
|
||||||
|
|
||||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||||
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
|
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
|
||||||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
|
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool editorEvent ( QEvent * event, QAbstractItemModel * model, const QStyleOptionViewItem & option, const QModelIndex & index ) override;
|
bool editorEvent(QEvent *event,
|
||||||
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
QAbstractItemModel *model,
|
||||||
|
const QStyleOptionViewItem &option,
|
||||||
|
const QModelIndex &index) override;
|
||||||
|
void updateEditorGeometry(QWidget *editor,
|
||||||
|
const QStyleOptionViewItem &option,
|
||||||
|
const QModelIndex &index) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
@@ -203,6 +203,12 @@ QVariant NavigatorTreeModel::data(const QModelIndex &index, int role) const
|
|||||||
if (role == ItemIsVisibleRole) // independent of column
|
if (role == ItemIsVisibleRole) // independent of column
|
||||||
return m_view->isNodeInvisible(modelNode) ? Qt::Unchecked : Qt::Checked;
|
return m_view->isNodeInvisible(modelNode) ? Qt::Unchecked : Qt::Checked;
|
||||||
|
|
||||||
|
if (role == ItemOrAncestorLocked)
|
||||||
|
return ModelNode::isThisOrAncestorLocked(modelNode);
|
||||||
|
|
||||||
|
if (role == ModelNodeRole)
|
||||||
|
return QVariant::fromValue<ModelNode>(modelNode);
|
||||||
|
|
||||||
if (index.column() == ColumnType::Name) {
|
if (index.column() == ColumnType::Name) {
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
return modelNode.displayName();
|
return modelNode.displayName();
|
||||||
@@ -237,8 +243,6 @@ QVariant NavigatorTreeModel::data(const QModelIndex &index, int role) const
|
|||||||
auto op = m_actionManager->modelNodePreviewOperation(modelNode);
|
auto op = m_actionManager->modelNodePreviewOperation(modelNode);
|
||||||
if (op)
|
if (op)
|
||||||
return op(modelNode);
|
return op(modelNode);
|
||||||
} else if (role == ModelNodeRole) {
|
|
||||||
return QVariant::fromValue<ModelNode>(modelNode);
|
|
||||||
}
|
}
|
||||||
} else if (index.column() == ColumnType::Alias) { // export
|
} else if (index.column() == ColumnType::Alias) { // export
|
||||||
if (role == Qt::CheckStateRole)
|
if (role == Qt::CheckStateRole)
|
||||||
@@ -268,7 +272,7 @@ Qt::ItemFlags NavigatorTreeModel::flags(const QModelIndex &index) const
|
|||||||
if (index.column() == ColumnType::Alias
|
if (index.column() == ColumnType::Alias
|
||||||
|| index.column() == ColumnType::Visibility
|
|| index.column() == ColumnType::Visibility
|
||||||
|| index.column() == ColumnType::Lock)
|
|| index.column() == ColumnType::Lock)
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemNeverHasChildren;
|
return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemNeverHasChildren;
|
||||||
|
|
||||||
const ModelNode modelNode = modelNodeForIndex(index);
|
const ModelNode modelNode = modelNodeForIndex(index);
|
||||||
if (ModelNode::isThisOrAncestorLocked(modelNode))
|
if (ModelNode::isThisOrAncestorLocked(modelNode))
|
||||||
@@ -277,8 +281,7 @@ Qt::ItemFlags NavigatorTreeModel::flags(const QModelIndex &index) const
|
|||||||
if (index.column() == ColumnType::Name)
|
if (index.column() == ColumnType::Name)
|
||||||
return Qt::ItemIsEditable | Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsSelectable | Qt::ItemIsEnabled;
|
return Qt::ItemIsEditable | Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsSelectable | Qt::ItemIsEnabled;
|
||||||
|
|
||||||
return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable
|
return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemNeverHasChildren;
|
||||||
| Qt::ItemNeverHasChildren;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void static appendForcedNodes(const NodeListProperty &property, QList<ModelNode> &list)
|
void static appendForcedNodes(const NodeListProperty &property, QList<ModelNode> &list)
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include "previewtooltip.h"
|
#include "previewtooltip.h"
|
||||||
|
|
||||||
#include <metainfo.h>
|
#include <metainfo.h>
|
||||||
|
#include <theme.h>
|
||||||
|
|
||||||
#include <utils/icon.h>
|
#include <utils/icon.h>
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
@@ -63,32 +64,28 @@ public:
|
|||||||
baseStyle()->setParent(parent);
|
baseStyle()->setParent(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const override
|
void drawPrimitive(PrimitiveElement element,
|
||||||
|
const QStyleOption *option,
|
||||||
|
QPainter *painter,
|
||||||
|
const QWidget *widget = nullptr) const override
|
||||||
{
|
{
|
||||||
static QRect mouseOverStateSavedFrameRectangle;
|
static QRect mouseOverStateSavedFrameRectangle;
|
||||||
if (element == QStyle::PE_PanelItemViewRow) {
|
if (element == QStyle::PE_PanelItemViewRow) {
|
||||||
if (option->state & QStyle::State_MouseOver)
|
if (option->state & QStyle::State_MouseOver)
|
||||||
mouseOverStateSavedFrameRectangle = option->rect;
|
mouseOverStateSavedFrameRectangle = option->rect;
|
||||||
|
|
||||||
if (option->state & QStyle::State_Selected)
|
painter->fillRect(option->rect.adjusted(0, delegateMargin, 0, -delegateMargin),
|
||||||
NavigatorTreeView::drawSelectionBackground(painter, *option);
|
Theme::getColor(Theme::Color::QmlDesigner_BorderColor));
|
||||||
|
|
||||||
} else if (element == PE_IndicatorItemViewItemDrop) {
|
} else if (element == PE_IndicatorItemViewItemDrop) {
|
||||||
// between elements and on elements we have a width
|
// between elements and on elements we have a width
|
||||||
if (option->rect.width() > 0) {
|
if (option->rect.width() > 0) {
|
||||||
m_currentTextColor = option->palette.text().color();
|
m_currentTextColor = option->palette.text().color();
|
||||||
QRect frameRectangle = adjustedRectangleToWidgetWidth(option->rect, widget);
|
QRect frameRectangle = adjustedRectangleToWidgetWidth(option->rect, widget);
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
if (option->rect.height() == 0) {
|
if (option->rect.height() == 0) {
|
||||||
bool isNotRootItem = option->rect.top() > 10 && mouseOverStateSavedFrameRectangle.top() > 10;
|
bool isNotRootItem = option->rect.top() > 10 && mouseOverStateSavedFrameRectangle.top() > 10;
|
||||||
if (isNotRootItem) {
|
if (isNotRootItem)
|
||||||
drawIndicatorLine(frameRectangle.topLeft(), frameRectangle.topRight(), painter);
|
drawIndicatorLine(frameRectangle.topLeft(), frameRectangle.topRight(), painter);
|
||||||
// there is only a line in the styleoption object at this moment
|
|
||||||
// so we need to use the last saved rect from the mouse over state
|
|
||||||
frameRectangle = adjustedRectangleToWidgetWidth(mouseOverStateSavedFrameRectangle, widget);
|
|
||||||
drawBackgroundFrame(frameRectangle, painter);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
drawHighlightFrame(frameRectangle, painter);
|
drawHighlightFrame(frameRectangle, painter);
|
||||||
}
|
}
|
||||||
@@ -96,12 +93,72 @@ public:
|
|||||||
}
|
}
|
||||||
} else if (element == PE_FrameFocusRect) {
|
} else if (element == PE_FrameFocusRect) {
|
||||||
// don't draw
|
// don't draw
|
||||||
|
} else if (element == PE_IndicatorBranch) {
|
||||||
|
painter->save();
|
||||||
|
static const int decoration_size = 10;
|
||||||
|
int mid_h = option->rect.x() + option->rect.width() / 2;
|
||||||
|
int mid_v = option->rect.y() + option->rect.height() / 2;
|
||||||
|
int bef_h = mid_h;
|
||||||
|
int bef_v = mid_v;
|
||||||
|
int aft_h = mid_h;
|
||||||
|
int aft_v = mid_v;
|
||||||
|
QBrush brush(Theme::getColor(Theme::Color::DSsliderHandle), Qt::SolidPattern);
|
||||||
|
if (option->state & State_Item) {
|
||||||
|
if (option->direction == Qt::RightToLeft)
|
||||||
|
painter->fillRect(option->rect.left(), mid_v, bef_h - option->rect.left(), 1, brush);
|
||||||
|
else
|
||||||
|
painter->fillRect(aft_h, mid_v, option->rect.right() - aft_h + 1, 1, brush);
|
||||||
|
}
|
||||||
|
if (option->state & State_Sibling)
|
||||||
|
painter->fillRect(mid_h, aft_v, 1, option->rect.bottom() - aft_v + 1, brush);
|
||||||
|
if (option->state & (State_Open | State_Children | State_Item | State_Sibling))
|
||||||
|
painter->fillRect(mid_h, option->rect.y(), 1, bef_v - option->rect.y(), brush);
|
||||||
|
if (option->state & State_Children) {
|
||||||
|
int delta = decoration_size / 2;
|
||||||
|
bef_h -= delta;
|
||||||
|
bef_v -= delta;
|
||||||
|
aft_h += delta;
|
||||||
|
aft_v += delta;
|
||||||
|
|
||||||
|
const QRectF rect(bef_h, bef_v, decoration_size + 1, decoration_size + 1);
|
||||||
|
painter->fillRect(rect, QBrush(Theme::getColor(Theme::Color::QmlDesigner_BackgroundColorDarkAlternate)));
|
||||||
|
|
||||||
|
static const QPointF collapsePoints[3] = {
|
||||||
|
QPointF(0.0, 0.0),
|
||||||
|
QPointF(4.0, 4.0),
|
||||||
|
QPointF(0.0, 8.0)
|
||||||
|
};
|
||||||
|
|
||||||
|
static const QPointF expandPoints[3] = {
|
||||||
|
QPointF(0.0, 0.0),
|
||||||
|
QPointF(8.0, 0.0),
|
||||||
|
QPointF(4.0, 4.0)
|
||||||
|
};
|
||||||
|
|
||||||
|
auto color = Theme::getColor(Theme::Color::IconsBaseColor);
|
||||||
|
painter->setPen(color);
|
||||||
|
painter->setBrush(color);
|
||||||
|
|
||||||
|
if (option->state & QStyle::State_Open) {
|
||||||
|
painter->translate(QPointF(mid_h - 4, mid_v - 2));
|
||||||
|
painter->drawConvexPolygon(expandPoints, 3);
|
||||||
|
} else {
|
||||||
|
painter->translate(QPointF(mid_h - 2, mid_v - 4));
|
||||||
|
painter->drawConvexPolygon(collapsePoints, 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
painter->restore();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
QProxyStyle::drawPrimitive(element, option, painter, widget);
|
QProxyStyle::drawPrimitive(element, option, painter, widget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int styleHint(StyleHint hint, const QStyleOption *option = nullptr, const QWidget *widget = nullptr, QStyleHintReturn *returnData = nullptr) const override {
|
int styleHint(StyleHint hint,
|
||||||
|
const QStyleOption *option = nullptr,
|
||||||
|
const QWidget *widget = nullptr,
|
||||||
|
QStyleHintReturn *returnData = nullptr) const override
|
||||||
|
{
|
||||||
if (hint == SH_ItemView_ShowDecorationSelected)
|
if (hint == SH_ItemView_ShowDecorationSelected)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
@@ -180,7 +237,8 @@ NavigatorTreeView::NavigatorTreeView(QWidget *parent)
|
|||||||
void NavigatorTreeView::drawSelectionBackground(QPainter *painter, const QStyleOption &option)
|
void NavigatorTreeView::drawSelectionBackground(QPainter *painter, const QStyleOption &option)
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->fillRect(option.rect, option.palette.color(QPalette::Highlight));
|
painter->fillRect(option.rect.adjusted(0, delegateMargin, 0, -delegateMargin),
|
||||||
|
Theme::getColor(Theme::Color::QmlDesigner_HighlightColor));
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,5 +281,4 @@ bool NavigatorTreeView::viewportEvent(QEvent *event)
|
|||||||
return QTreeView::viewportEvent(event);
|
return QTreeView::viewportEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -145,6 +145,7 @@ void NavigatorView::modelAttached(Model *model)
|
|||||||
treeView->header()->resizeSection(NavigatorTreeModel::ColumnType::Visibility, 26);
|
treeView->header()->resizeSection(NavigatorTreeModel::ColumnType::Visibility, 26);
|
||||||
treeView->header()->resizeSection(NavigatorTreeModel::ColumnType::Lock, 26);
|
treeView->header()->resizeSection(NavigatorTreeModel::ColumnType::Lock, 26);
|
||||||
treeView->setIndentation(20);
|
treeView->setIndentation(20);
|
||||||
|
treeView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
|
|
||||||
m_currentModelInterface->setFilter(false);
|
m_currentModelInterface->setFilter(false);
|
||||||
|
|
||||||
@@ -493,7 +494,6 @@ void NavigatorView::changeSelection(const QItemSelection & /*newSelection*/, con
|
|||||||
QSet<ModelNode> nodeSet;
|
QSet<ModelNode> nodeSet;
|
||||||
|
|
||||||
for (const QModelIndex &index : treeWidget()->selectionModel()->selectedIndexes()) {
|
for (const QModelIndex &index : treeWidget()->selectionModel()->selectedIndexes()) {
|
||||||
|
|
||||||
const ModelNode modelNode = modelNodeForIndex(index);
|
const ModelNode modelNode = modelNodeForIndex(index);
|
||||||
if (modelNode.isValid())
|
if (modelNode.isValid())
|
||||||
nodeSet.insert(modelNode);
|
nodeSet.insert(modelNode);
|
||||||
@@ -539,7 +539,7 @@ void NavigatorView::updateItemSelection()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool blocked = blockSelectionChangedSignal(true);
|
bool blocked = blockSelectionChangedSignal(true);
|
||||||
treeWidget()->selectionModel()->select(itemSelection, QItemSelectionModel::ClearAndSelect);
|
treeWidget()->selectionModel()->select(itemSelection, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
||||||
blockSelectionChangedSignal(blocked);
|
blockSelectionChangedSignal(blocked);
|
||||||
|
|
||||||
if (!selectedModelNodes().isEmpty())
|
if (!selectedModelNodes().isEmpty())
|
||||||
@@ -586,7 +586,7 @@ void NavigatorView::reparentAndCatch(NodeAbstractProperty property, const ModelN
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
property.reparentHere(modelNode);
|
property.reparentHere(modelNode);
|
||||||
} catch (Exception &exception) {
|
} catch (Exception &exception) {
|
||||||
exception.showException();
|
exception.showException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -620,29 +620,29 @@ void NavigatorView::setupWidget()
|
|||||||
const QIcon visibilityOnIcon =
|
const QIcon visibilityOnIcon =
|
||||||
Utils::StyleHelper::getIconFromIconFont(fontName,
|
Utils::StyleHelper::getIconFromIconFont(fontName,
|
||||||
Theme::getIconUnicode(Theme::Icon::visibilityOn),
|
Theme::getIconUnicode(Theme::Icon::visibilityOn),
|
||||||
28, 28, QColor(Qt::white));
|
20, 20, QColor(Qt::white));
|
||||||
const QIcon visibilityOffIcon =
|
const QIcon visibilityOffIcon =
|
||||||
Utils::StyleHelper::getIconFromIconFont(fontName,
|
Utils::StyleHelper::getIconFromIconFont(fontName,
|
||||||
Theme::getIconUnicode(Theme::Icon::visibilityOff),
|
Theme::getIconUnicode(Theme::Icon::visibilityOff),
|
||||||
28, 28, QColor(Qt::white));
|
20, 20, QColor(Qt::white));
|
||||||
|
|
||||||
const QIcon aliasOnIcon =
|
const QIcon aliasOnIcon =
|
||||||
Utils::StyleHelper::getIconFromIconFont(fontName,
|
Utils::StyleHelper::getIconFromIconFont(fontName,
|
||||||
Theme::getIconUnicode(Theme::Icon::idAliasOn),
|
Theme::getIconUnicode(Theme::Icon::idAliasOn),
|
||||||
28, 28, QColor(Qt::red));
|
20, 20, QColor(Qt::red));
|
||||||
const QIcon aliasOffIcon =
|
const QIcon aliasOffIcon =
|
||||||
Utils::StyleHelper::getIconFromIconFont(fontName,
|
Utils::StyleHelper::getIconFromIconFont(fontName,
|
||||||
Theme::getIconUnicode(Theme::Icon::idAliasOff),
|
Theme::getIconUnicode(Theme::Icon::idAliasOff),
|
||||||
28, 28, QColor(Qt::white));
|
20, 20, QColor(Qt::white));
|
||||||
|
|
||||||
const QIcon lockOnIcon =
|
const QIcon lockOnIcon =
|
||||||
Utils::StyleHelper::getIconFromIconFont(fontName,
|
Utils::StyleHelper::getIconFromIconFont(fontName,
|
||||||
Theme::getIconUnicode(Theme::Icon::lockOn),
|
Theme::getIconUnicode(Theme::Icon::lockOn),
|
||||||
28, 28, QColor(Qt::white));
|
20, 20, QColor(Qt::white));
|
||||||
const QIcon lockOffIcon =
|
const QIcon lockOffIcon =
|
||||||
Utils::StyleHelper::getIconFromIconFont(fontName,
|
Utils::StyleHelper::getIconFromIconFont(fontName,
|
||||||
Theme::getIconUnicode(Theme::Icon::lockOff),
|
Theme::getIconUnicode(Theme::Icon::lockOff),
|
||||||
28, 28, QColor(Qt::white));
|
20, 20, QColor(Qt::white));
|
||||||
|
|
||||||
auto idDelegate = new NameItemDelegate(this);
|
auto idDelegate = new NameItemDelegate(this);
|
||||||
|
|
||||||
|
@@ -43,6 +43,8 @@ QT_END_NAMESPACE
|
|||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
|
static int delegateMargin = 2;
|
||||||
|
|
||||||
class NavigatorWidget;
|
class NavigatorWidget;
|
||||||
class NavigatorTreeModel;
|
class NavigatorTreeModel;
|
||||||
|
|
||||||
@@ -50,7 +52,8 @@ enum NavigatorRoles {
|
|||||||
ItemIsVisibleRole = Qt::UserRole,
|
ItemIsVisibleRole = Qt::UserRole,
|
||||||
RowIsPropertyRole = Qt::UserRole + 1,
|
RowIsPropertyRole = Qt::UserRole + 1,
|
||||||
ModelNodeRole = Qt::UserRole + 2,
|
ModelNodeRole = Qt::UserRole + 2,
|
||||||
ToolTipImageRole = Qt::UserRole + 3
|
ToolTipImageRole = Qt::UserRole + 3,
|
||||||
|
ItemOrAncestorLocked = Qt::UserRole + 4
|
||||||
};
|
};
|
||||||
|
|
||||||
class NavigatorView : public AbstractView
|
class NavigatorView : public AbstractView
|
||||||
|
@@ -31,7 +31,6 @@
|
|||||||
#include <imagecache.h>
|
#include <imagecache.h>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDesktopWidget>
|
|
||||||
#include <QMetaObject>
|
#include <QMetaObject>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
@@ -65,8 +64,7 @@ void PreviewTooltipBackend::showTooltip()
|
|||||||
},
|
},
|
||||||
[] {});
|
[] {});
|
||||||
|
|
||||||
auto desktopWidget = QApplication::desktop();
|
auto mousePosition = QCursor::pos();
|
||||||
auto mousePosition = desktopWidget->cursor().pos();
|
|
||||||
|
|
||||||
mousePosition += {20, 20};
|
mousePosition += {20, 20};
|
||||||
m_tooltip->move(mousePosition);
|
m_tooltip->move(mousePosition);
|
||||||
|
@@ -42,6 +42,7 @@
|
|||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
|
#include <QWindow>
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
@@ -495,7 +496,9 @@ void PropertyEditorContextObject::hideCursor()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
QApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
|
QApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
|
||||||
m_lastPos = QCursor::pos();
|
|
||||||
|
if (QWidget *w = QApplication::activeWindow())
|
||||||
|
m_lastPos = QCursor::pos(w->screen());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertyEditorContextObject::restoreCursor()
|
void PropertyEditorContextObject::restoreCursor()
|
||||||
@@ -503,8 +506,19 @@ void PropertyEditorContextObject::restoreCursor()
|
|||||||
if (!QApplication::overrideCursor())
|
if (!QApplication::overrideCursor())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QCursor::setPos(m_lastPos);
|
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
|
|
||||||
|
if (QWidget *w = QApplication::activeWindow())
|
||||||
|
QCursor::setPos(w->screen(), m_lastPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertyEditorContextObject::holdCursorInPlace()
|
||||||
|
{
|
||||||
|
if (!QApplication::overrideCursor())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (QWidget *w = QApplication::activeWindow())
|
||||||
|
QCursor::setPos(w->screen(), m_lastPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList PropertyEditorContextObject::styleNamesForFamily(const QString &family)
|
QStringList PropertyEditorContextObject::styleNamesForFamily(const QString &family)
|
||||||
|
@@ -91,6 +91,7 @@ public:
|
|||||||
|
|
||||||
Q_INVOKABLE void hideCursor();
|
Q_INVOKABLE void hideCursor();
|
||||||
Q_INVOKABLE void restoreCursor();
|
Q_INVOKABLE void restoreCursor();
|
||||||
|
Q_INVOKABLE void holdCursorInPlace();
|
||||||
|
|
||||||
Q_INVOKABLE QStringList styleNamesForFamily(const QString &family);
|
Q_INVOKABLE QStringList styleNamesForFamily(const QString &family);
|
||||||
|
|
||||||
|
@@ -693,35 +693,33 @@ void ModelNode::removeProperty(const PropertyName &name) const
|
|||||||
model()->d->removeProperty(internalNode()->property(name));
|
model()->d->removeProperty(internalNode()->property(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief removes this node from the node tree
|
/*! \brief removes this node from the node tree
|
||||||
*/
|
*/
|
||||||
|
static QList<ModelNode> descendantNodes(const ModelNode &node)
|
||||||
static QList<ModelNode> descendantNodes(const ModelNode &parent)
|
|
||||||
{
|
{
|
||||||
QList<ModelNode> descendants(parent.directSubModelNodes());
|
const QList<ModelNode> children = node.directSubModelNodes();
|
||||||
foreach (const ModelNode &child, parent.directSubModelNodes()) {
|
QList<ModelNode> descendants = children;
|
||||||
|
for (const ModelNode &child : children)
|
||||||
descendants += descendantNodes(child);
|
descendants += descendantNodes(child);
|
||||||
}
|
|
||||||
return descendants;
|
return descendants;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void removeModelNodeFromSelection(const ModelNode &node)
|
static void removeModelNodeFromSelection(const ModelNode &node)
|
||||||
{
|
{
|
||||||
{ // remove nodes from the active selection:
|
// remove nodes from the active selection
|
||||||
QList<ModelNode> selectedList = node.view()->selectedModelNodes();
|
QList<ModelNode> selectedList = node.view()->selectedModelNodes();
|
||||||
|
|
||||||
foreach (const ModelNode &childModelNode, descendantNodes(node))
|
const QList<ModelNode> descendants = descendantNodes(node);
|
||||||
selectedList.removeAll(childModelNode);
|
for (const ModelNode &descendantNode : descendants)
|
||||||
selectedList.removeAll(node);
|
selectedList.removeAll(descendantNode);
|
||||||
|
|
||||||
node.view()->setSelectedModelNodes(selectedList);
|
selectedList.removeAll(node);
|
||||||
}
|
|
||||||
|
node.view()->setSelectedModelNodes(selectedList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief complete removes this ModelNode from the Model
|
/*! \brief complete removes this ModelNode from the Model
|
||||||
|
|
||||||
*/
|
*/
|
||||||
void ModelNode::destroy()
|
void ModelNode::destroy()
|
||||||
{
|
{
|
||||||
|
@@ -208,6 +208,8 @@ QmlDesignerPlugin::~QmlDesignerPlugin()
|
|||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
bool QmlDesignerPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage/* = 0*/)
|
bool QmlDesignerPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage/* = 0*/)
|
||||||
{
|
{
|
||||||
|
QDir{}.mkpath(Core::ICore::cacheResourcePath());
|
||||||
|
|
||||||
if (!Utils::HostOsInfo::canCreateOpenGLContext(errorMessage))
|
if (!Utils::HostOsInfo::canCreateOpenGLContext(errorMessage))
|
||||||
return false;
|
return false;
|
||||||
d = new QmlDesignerPluginPrivate;
|
d = new QmlDesignerPluginPrivate;
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
#include "qmljsindenter.h"
|
#include "qmljsindenter.h"
|
||||||
#include "qmljsqtstylecodeformatter.h"
|
#include "qmljsqtstylecodeformatter.h"
|
||||||
|
|
||||||
|
#include <texteditor/fontsettings.h>
|
||||||
#include <texteditor/snippets/snippetprovider.h>
|
#include <texteditor/snippets/snippetprovider.h>
|
||||||
#include <texteditor/tabsettings.h>
|
#include <texteditor/tabsettings.h>
|
||||||
#include <texteditor/simplecodestylepreferences.h>
|
#include <texteditor/simplecodestylepreferences.h>
|
||||||
|
@@ -143,9 +143,9 @@ void BaseHoverHandler::identifyMatch(TextEditorWidget *editorWidget, int pos, Re
|
|||||||
|
|
||||||
void BaseHoverHandler::operateTooltip(TextEditorWidget *editorWidget, const QPoint &point)
|
void BaseHoverHandler::operateTooltip(TextEditorWidget *editorWidget, const QPoint &point)
|
||||||
{
|
{
|
||||||
const QVariant helpItem = m_lastHelpItemIdentified.isEmpty()
|
const QVariant helpItem = m_lastHelpItemIdentified.isValid()
|
||||||
? QVariant()
|
? QVariant::fromValue(m_lastHelpItemIdentified)
|
||||||
: QVariant::fromValue(m_lastHelpItemIdentified);
|
: QVariant();
|
||||||
const bool extractHelp = m_lastHelpItemIdentified.isValid()
|
const bool extractHelp = m_lastHelpItemIdentified.isValid()
|
||||||
&& !m_lastHelpItemIdentified.isFuzzyMatch();
|
&& !m_lastHelpItemIdentified.isFuzzyMatch();
|
||||||
const QString helpContents = extractHelp ? m_lastHelpItemIdentified.firstParagraph()
|
const QString helpContents = extractHelp ? m_lastHelpItemIdentified.firstParagraph()
|
||||||
|
@@ -305,23 +305,17 @@ void CodeAssistantPrivate::displayProposal(IAssistProposal *newProposal, AssistR
|
|||||||
// TODO: The proposal should own the model until someone takes it explicitly away.
|
// TODO: The proposal should own the model until someone takes it explicitly away.
|
||||||
QScopedPointer<IAssistProposal> proposalCandidate(newProposal);
|
QScopedPointer<IAssistProposal> proposalCandidate(newProposal);
|
||||||
|
|
||||||
bool destroyCurrentContext = false;
|
if (isDisplayingProposal() && !m_proposal->isFragile())
|
||||||
if (isDisplayingProposal()) {
|
return;
|
||||||
if (!m_proposal->isFragile())
|
|
||||||
return;
|
|
||||||
destroyCurrentContext = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int basePosition = proposalCandidate->basePosition();
|
int basePosition = proposalCandidate->basePosition();
|
||||||
if (m_editorWidget->position() < basePosition) {
|
if (m_editorWidget->position() < basePosition) {
|
||||||
if (destroyCurrentContext)
|
destroyContext();
|
||||||
destroyContext();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_abortedBasePosition == basePosition && reason != ExplicitlyInvoked) {
|
if (m_abortedBasePosition == basePosition && reason != ExplicitlyInvoked) {
|
||||||
if (destroyCurrentContext)
|
destroyContext();
|
||||||
destroyContext();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,8 +327,7 @@ void CodeAssistantPrivate::displayProposal(IAssistProposal *newProposal, AssistR
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (destroyCurrentContext)
|
destroyContext();
|
||||||
destroyContext();
|
|
||||||
|
|
||||||
clearAbortedPosition();
|
clearAbortedPosition();
|
||||||
m_proposal.reset(proposalCandidate.take());
|
m_proposal.reset(proposalCandidate.take());
|
||||||
|
@@ -32,6 +32,7 @@
|
|||||||
#include "ui_snippetssettingspage.h"
|
#include "ui_snippetssettingspage.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
#include <texteditor/fontsettings.h>
|
||||||
#include <texteditor/textdocument.h>
|
#include <texteditor/textdocument.h>
|
||||||
#include <texteditor/texteditorconstants.h>
|
#include <texteditor/texteditorconstants.h>
|
||||||
#include <texteditor/texteditorsettings.h>
|
#include <texteditor/texteditorsettings.h>
|
||||||
|
BIN
src/plugins/welcome/images/download.png
Normal file
BIN
src/plugins/welcome/images/download.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 197 B |
BIN
src/plugins/welcome/images/download@2x.png
Normal file
BIN
src/plugins/welcome/images/download@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 264 B |
@@ -23,5 +23,7 @@
|
|||||||
<file>images/expandarrow.png</file>
|
<file>images/expandarrow.png</file>
|
||||||
<file>images/expandarrow@2x.png</file>
|
<file>images/expandarrow@2x.png</file>
|
||||||
<file>images/border.png</file>
|
<file>images/border.png</file>
|
||||||
|
<file>images/download.png</file>
|
||||||
|
<file>images/download@2x.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@@ -287,6 +287,7 @@ public:
|
|||||||
auto l = new QVBoxLayout;
|
auto l = new QVBoxLayout;
|
||||||
l->setContentsMargins(0, 0, 0, 0);
|
l->setContentsMargins(0, 0, 0, 0);
|
||||||
l->setSpacing(5);
|
l->setSpacing(5);
|
||||||
|
l->addWidget(new IconAndLink("download", tr("Get Qt"), "https://www.qt.io/download", this));
|
||||||
l->addWidget(new IconAndLink("qtaccount", tr("Qt Account"), "https://account.qt.io", this));
|
l->addWidget(new IconAndLink("qtaccount", tr("Qt Account"), "https://account.qt.io", this));
|
||||||
l->addWidget(new IconAndLink("community", tr("Online Community"), "https://forum.qt.io", this));
|
l->addWidget(new IconAndLink("community", tr("Online Community"), "https://forum.qt.io", this));
|
||||||
l->addWidget(new IconAndLink("blogs", tr("Blogs"), "https://planet.qt.io", this));
|
l->addWidget(new IconAndLink("blogs", tr("Blogs"), "https://planet.qt.io", this));
|
||||||
|
@@ -86,32 +86,32 @@ QVector<ProFileEvaluator::SourceFile> ProFileEvaluator::fixifiedValues(
|
|||||||
QVector<SourceFile> result;
|
QVector<SourceFile> result;
|
||||||
foreach (const ProString &str, d->values(ProKey(variable))) {
|
foreach (const ProString &str, d->values(ProKey(variable))) {
|
||||||
const QString &el = d->m_option->expandEnvVars(str.toQString());
|
const QString &el = d->m_option->expandEnvVars(str.toQString());
|
||||||
if (IoUtils::isAbsolutePath(el)) {
|
const QString fn = IoUtils::isAbsolutePath(el)
|
||||||
result << SourceFile{QDir::cleanPath(el), str.sourceFile()};
|
? QDir::cleanPath(el) : QDir::cleanPath(baseDirectory + QLatin1Char('/') + el);
|
||||||
|
if (IoUtils::exists(fn)) {
|
||||||
|
result << SourceFile{fn, str.sourceFile()};
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
QStringView fileNamePattern;
|
||||||
|
if (expandWildcards) {
|
||||||
|
fileNamePattern = IoUtils::fileName(fn);
|
||||||
|
expandWildcards = fileNamePattern.contains('*') || fileNamePattern.contains('?');
|
||||||
|
}
|
||||||
|
if (expandWildcards) {
|
||||||
|
const QString patternBaseDir = IoUtils::pathName(fn).toString();
|
||||||
|
const QDir::Filters filters = QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot;
|
||||||
|
for (const QString &fileName : QDir(patternBaseDir).entryList(
|
||||||
|
QStringList(fileNamePattern.toString()), filters)) {
|
||||||
|
const QString fullFilePath
|
||||||
|
= QDir::cleanPath(patternBaseDir + '/' + fileName);
|
||||||
|
result << SourceFile({fullFilePath, str.sourceFile()});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
QString fn = QDir::cleanPath(baseDirectory + QLatin1Char('/') + el);
|
if (IoUtils::isAbsolutePath(el)) {
|
||||||
if (IoUtils::exists(fn)) {
|
|
||||||
result << SourceFile{fn, str.sourceFile()};
|
result << SourceFile{fn, str.sourceFile()};
|
||||||
} else {
|
} else {
|
||||||
QStringView fileNamePattern;
|
result << SourceFile{QDir::cleanPath(buildDirectory + QLatin1Char('/') + el),
|
||||||
if (expandWildcards) {
|
str.sourceFile()};
|
||||||
fileNamePattern = IoUtils::fileName(fn);
|
|
||||||
expandWildcards = fileNamePattern.contains('*')
|
|
||||||
|| fileNamePattern.contains('?');
|
|
||||||
}
|
|
||||||
if (expandWildcards) {
|
|
||||||
const QString patternBaseDir = IoUtils::pathName(fn).toString();
|
|
||||||
const QDir::Filters filters = QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot;
|
|
||||||
for (const QString &fileName : QDir(patternBaseDir).entryList(
|
|
||||||
QStringList(fileNamePattern.toString()), filters)) {
|
|
||||||
const QString fullFilePath
|
|
||||||
= QDir::cleanPath(patternBaseDir + '/' + fileName);
|
|
||||||
result << SourceFile({fullFilePath, str.sourceFile()});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result << SourceFile{QDir::cleanPath(buildDirectory + QLatin1Char('/') + el),
|
|
||||||
str.sourceFile()};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7069,6 +7069,24 @@
|
|||||||
id="path5457-0-5"
|
id="path5457-0-5"
|
||||||
style="display:inline" />
|
style="display:inline" />
|
||||||
</g>
|
</g>
|
||||||
|
<g
|
||||||
|
id="src/plugins/welcome/images/download"
|
||||||
|
transform="translate(32)">
|
||||||
|
<use
|
||||||
|
style="display:inline"
|
||||||
|
x="0"
|
||||||
|
y="0"
|
||||||
|
xlink:href="#backgroundRect"
|
||||||
|
id="use5933-0-9-4"
|
||||||
|
width="100%"
|
||||||
|
height="100%"
|
||||||
|
transform="translate(144,148)" />
|
||||||
|
<path
|
||||||
|
id="path2540"
|
||||||
|
style="fill:none;stroke-width:2;stroke:#000000;stroke-linejoin:round"
|
||||||
|
d="m 128,599 h 16 m -14.5,-9.5 6.5,6.5 6.5,-6.5 M 136,584 v 12"
|
||||||
|
sodipodi:nodetypes="ccccccc" />
|
||||||
|
</g>
|
||||||
<g
|
<g
|
||||||
id="src/libs/utils/images/member"
|
id="src/libs/utils/images/member"
|
||||||
transform="translate(-28,0)">
|
transform="translate(-28,0)">
|
||||||
|
Before Width: | Height: | Size: 380 KiB After Width: | Height: | Size: 381 KiB |
@@ -519,6 +519,7 @@ enum AdditionalCriteria
|
|||||||
static bool matchesAdditionalCriteria(int criteria)
|
static bool matchesAdditionalCriteria(int criteria)
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_UNIX
|
#ifdef Q_OS_UNIX
|
||||||
|
Q_UNUSED(criteria)
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
return !(criteria & NeedsInferiorCall);
|
return !(criteria & NeedsInferiorCall);
|
||||||
|
@@ -670,9 +670,9 @@ def getChildByClass(parent, classToSearchFor, occurrence=1):
|
|||||||
return children[occurrence - 1]
|
return children[occurrence - 1]
|
||||||
|
|
||||||
def getHelpViewer():
|
def getHelpViewer():
|
||||||
return waitForObject("{type='Help::Internal::TextBrowserHelpWidget' unnamed='1' "
|
return waitForObject("{type='QLiteHtmlWidget' unnamed='1' visible='1' "
|
||||||
"visible='1' window=':Qt Creator_Core::Internal::MainWindow'}",
|
"window=':Qt Creator_Core::Internal::MainWindow'}",
|
||||||
1000)
|
1000)
|
||||||
|
|
||||||
def getHelpTitle():
|
def getHelpTitle():
|
||||||
return str(getHelpViewer().documentTitle)
|
return str(getHelpViewer().title())
|
||||||
|
@@ -32,27 +32,17 @@ urlDictionary = { "abundance":"qthelp://com.trolltech.qt.487/qdoc/gettingstarted
|
|||||||
|
|
||||||
|
|
||||||
def __getSelectedText__():
|
def __getSelectedText__():
|
||||||
hv = getHelpViewer()
|
|
||||||
try:
|
try:
|
||||||
return hv.textCursor().selectedText()
|
return str(getHelpViewer().selectedText())
|
||||||
except:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
test.log("Falling back to searching for selection in HTML.")
|
|
||||||
return getHighlightsInHtml(str(hv.toHtml()))
|
|
||||||
except:
|
except:
|
||||||
test.warning("Could not get highlighted text.")
|
test.warning("Could not get highlighted text.")
|
||||||
return str("")
|
return str("")
|
||||||
|
|
||||||
def __getUrl__():
|
def __getUrl__():
|
||||||
helpViewer = getHelpViewer()
|
|
||||||
try:
|
try:
|
||||||
url = helpViewer.url
|
url = getHelpViewer().url()
|
||||||
except:
|
except:
|
||||||
try:
|
return ""
|
||||||
url = helpViewer.source
|
|
||||||
except:
|
|
||||||
return ""
|
|
||||||
return str(url.scheme) + "://" + str(url.host) + str(url.path)
|
return str(url.scheme) + "://" + str(url.host) + str(url.path)
|
||||||
|
|
||||||
def getHighlightsInHtml(htmlCode):
|
def getHighlightsInHtml(htmlCode):
|
||||||
|
Reference in New Issue
Block a user