Merge remote-tracking branch 'origin/4.14' into master

Change-Id: Ic5e99ec54e2cedbabd78eabc2f0350f90daa0cec
This commit is contained in:
Eike Ziller
2020-10-26 12:13:49 +01:00
47 changed files with 546 additions and 364 deletions

View File

@@ -24,7 +24,6 @@
****************************************************************************/
import QtQuick 2.15
import QtQuick3D 1.15
Item {
id: root
@@ -33,10 +32,12 @@ Item {
property alias contentItem: contentItem
/*
View3D {
// Dummy view to hold the context in case View3D items are used in the component
// TODO remove when QTBUG-87678 is fixed
}
*/
Item {
id: contentItem

View File

@@ -63,7 +63,7 @@ Column {
Section {
anchors.left: parent.left
anchors.right: parent.right
caption: "Rectangle"
caption: qsTr("Rectangle")
SectionLayout {
rows: 2

View File

@@ -45,7 +45,10 @@ Item {
width: 96
implicitHeight: spinBox.height
onFocusChanged: transaction.end();
onFocusChanged: {
restoreCursor();
transaction.end();
}
StudioControls.RealSpinBox {
id: spinBox
@@ -60,6 +63,8 @@ Item {
transaction.end();
}
onDragging: holdCursorInPlace();
onRealValueModified: {
if (transaction.active())
commitValue();

View File

@@ -55,7 +55,8 @@ Rectangle {
visible: text !== StudioTheme.Constants.actionIcon || actionIndicator.forceVisible
|| (myControl !== undefined &&
((myControl.edit !== undefined && myControl.edit)
|| (myControl.hover !== undefined && myControl.hover)))
|| (myControl.hover !== undefined && myControl.hover)
|| (myControl.drag !== undefined && myControl.drag)))
color: StudioTheme.Values.themeTextColor
font.family: StudioTheme.Constants.iconFont.family
font.pixelSize: StudioTheme.Values.myIconFontSize

View File

@@ -55,6 +55,7 @@ T.SpinBox {
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 alias actionIndicatorVisible: actionIndicator.visible
@@ -77,6 +78,7 @@ T.SpinBox {
signal compressedRealValueModified
signal dragStarted
signal dragEnded
signal dragging
// Use custom wheel handling due to bugs
property bool __wheelEnabled: false

View File

@@ -70,61 +70,25 @@ TextInput {
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 {
id: dragModifierWorkaround
Keys.onPressed: {
event.accepted = true
if (event.modifiers & Qt.ControlModifier)
dragHandler.multiplier = 0.1
if (event.modifiers & Qt.ControlModifier) {
mouseArea.stepSize = myControl.minStepSize
mouseArea.calcValue(myControl.realValueModified)
}
if (event.modifiers & Qt.ShiftModifier)
dragHandler.multiplier = 10.0
if (event.modifiers & Qt.ShiftModifier) {
mouseArea.stepSize = myControl.maxStepSize
mouseArea.calcValue(myControl.realValueModified)
}
}
Keys.onReleased: {
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)
}
TapHandler {
id: tapHandler
acceptedDevices: PointerDevice.Mouse
enabled: true
onTapped: {
textInput.forceActiveFocus()
textInput.deselect() // QTBUG-75862
}
}
MouseArea {
id: mouseArea
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
enabled: true
hoverEnabled: true
@@ -156,7 +120,90 @@ TextInput {
cursorShape: Qt.PointingHandCursor
// Sets the global hover
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: {
if (!myControl.__wheelEnabled)
return
@@ -187,14 +234,6 @@ TextInput {
color: StudioTheme.Values.themeControlBackground
border.color: StudioTheme.Values.themeControlOutline
}
PropertyChanges {
target: dragHandler
enabled: true
}
PropertyChanges {
target: tapHandler
enabled: true
}
PropertyChanges {
target: mouseArea
cursorShape: Qt.PointingHandCursor
@@ -217,14 +256,6 @@ TextInput {
color: StudioTheme.Values.themeFocusEdit
border.color: StudioTheme.Values.themeInteraction
}
PropertyChanges {
target: dragHandler
enabled: false
}
PropertyChanges {
target: tapHandler
enabled: false
}
PropertyChanges {
target: mouseArea
cursorShape: Qt.IBeamCursor

View File

@@ -50,7 +50,7 @@ QtObject {
property real sliderControlSize: 12
property real sliderControlSizeMulti: values.sliderControlSize * values.scaleFactor
property int dragLength: 400 // px
property int dragThreshold: 10 // px
property real spinControlIconSize: 8
property real spinControlIconSizeMulti: values.spinControlIconSize * values.scaleFactor

View File

@@ -34,22 +34,28 @@ find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Quick REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick REQUIRED)
@endif
if(ANDROID)
add_library(%{ProjectName} SHARED
%{MainCppFileName}
qml.qrc
@if %{HasTranslation}
${TS_FILES}
@endif
set(PROJECT_SOURCES
%{MainCppFileName}
qml.qrc
@if %{HasTranslation}
${TS_FILES}
@endif
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(%{ProjectName}
${PROJECT_SOURCES}
)
else()
add_executable(%{ProjectName}
%{MainCppFileName}
qml.qrc
@if %{HasTranslation}
${TS_FILES}
@endif
)
if(ANDROID)
add_library(%{ProjectName} SHARED
${PROJECT_SOURCES}
)
else()
add_executable(%{ProjectName}
${PROJECT_SOURCES}
)
endif()
endif()
target_compile_definitions(%{ProjectName}

View File

@@ -34,30 +34,32 @@ find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)
@endif
if(ANDROID)
add_library(%{ProjectName} SHARED
%{MainFileName}
%{SrcFileName}
%{HdrFileName}
@if %{GenerateForm}
%{FormFileName}
@endif
@if %{HasTranslation}
${TS_FILES}
@endif
)
set(PROJECT_SOURCES
%{MainFileName}
%{SrcFileName}
%{HdrFileName}
@if %{GenerateForm}
%{FormFileName}
@endif
@if %{HasTranslation}
${TS_FILES}
@endif
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(%{ProjectName}
${PROJECT_SOURCES}
)
else()
add_executable(%{ProjectName}
%{MainFileName}
%{SrcFileName}
%{HdrFileName}
@if %{GenerateForm}
%{FormFileName}
@endif
@if %{HasTranslation}
${TS_FILES}
@endif
)
if(ANDROID)
add_library(%{ProjectName} SHARED
${PROJECT_SOURCES}
)
else()
add_executable(%{ProjectName}
${PROJECT_SOURCES}
)
endif()
endif()
target_link_libraries(%{ProjectName} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)

View File

@@ -29,6 +29,7 @@
#include <utils/fileutils.h>
#include <QDebug>
#include <QString>
namespace QmlJS {

View File

@@ -997,13 +997,13 @@ Container<T> static_container_cast(const Container<Base> &container)
template <typename 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>
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
@@ -1012,7 +1012,7 @@ inline void sort(Container &container, R S::*member)
{
auto f = std::mem_fn(member);
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) {
return f(a) < f(b);
});
@@ -1024,7 +1024,7 @@ inline void sort(Container &container, R (S::*function)() const)
{
auto f = std::mem_fn(function);
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) {
return f(a) < f(b);
});

View File

@@ -90,7 +90,8 @@ AndroidDeployQtStep::AndroidDeployQtStep(BuildStepList *parent, Utils::Id id)
m_uninstallPreviousPackage = addAspect<BoolAspect>();
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);
const QtSupport::BaseQtVersion * const qt = QtSupport::QtKitAspect::qtVersion(kit());

View File

@@ -445,7 +445,7 @@ void VcsManager::promptToAdd(const QString &directory, const QStringList &fileNa
if (dlg.exec() == QDialog::Accepted) {
QStringList notAddedToVc;
foreach (const QString &file, unmanagedFiles) {
if (!vc->vcsAdd(file))
if (!vc->vcsAdd(QDir(directory).filePath(file)))
notAddedToVc << file;
}

View File

@@ -36,6 +36,7 @@
#include <coreplugin/icore.h>
#include <cppeditor/cppeditorconstants.h>
#include <texteditor/codestyleeditor.h>
#include <texteditor/fontsettings.h>
#include <texteditor/icodestylepreferencesfactory.h>
#include <texteditor/textdocument.h>
#include <texteditor/displaysettings.h>

View File

@@ -32,7 +32,7 @@ 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"
DEPENDS ${FWWebKit} ${FWAppKit}
DEFINES QTC_MAC_NATIVE_HELPVIEWER

View File

@@ -41,10 +41,11 @@ public:
explicit QLiteHtmlWidget(QWidget *parent = nullptr);
~QLiteHtmlWidget() override;
// declaring the getters Q_INVOKABLE to make them Squish-testable
void setUrl(const QUrl &url);
QUrl url() const;
Q_INVOKABLE QUrl url() const;
void setHtml(const QString &content);
QString title() const;
Q_INVOKABLE QString title() const;
void setZoomFactor(qreal scale);
qreal zoomFactor() const;
@@ -62,7 +63,8 @@ public:
using ResourceHandler = std::function<QByteArray(QUrl)>;
void setResourceHandler(const ResourceHandler &handler);
QString selectedText() const;
// declaring this Q_INVOKABLE to make it Squish-testable
Q_INVOKABLE QString selectedText() const;
signals:
void linkClicked(const QUrl &url);

View File

@@ -1,5 +1,10 @@
find_package(Qt5 COMPONENTS SvgWidgets QUIET)
if (TARGET Qt5::SvgWidgets)
set(SVG_WIDGETS Qt5::SvgWidgets)
endif()
add_qtc_plugin(ImageViewer
DEPENDS OptionalSvg
DEPENDS OptionalSvg ${SVG_WIDGETS}
PLUGIN_DEPENDS Core
SOURCES
exportdialog.cpp exportdialog.h

View File

@@ -26,7 +26,12 @@
#include "editorsettingspropertiespage.h"
#include "editorconfiguration.h"
#include "project.h"
#include <texteditor/behaviorsettings.h>
#include <texteditor/extraencodingsettings.h>
#include <texteditor/marginsettings.h>
#include <texteditor/storagesettings.h>
#include <texteditor/typingsettings.h>
#include <QTextCodec>

View File

@@ -775,7 +775,10 @@ void Target::setNamedSettings(const QString &name, const QVariant &value)
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

View File

@@ -1121,13 +1121,13 @@ void QbsBuildSystem::updateApplicationTargets()
if (result.error().hasError()) {
Core::MessageManager::write(tr("Error retrieving run environment: %1")
.arg(result.error().toString()));
} else {
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));
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));
m_envCache.insert(key, env);
};

View File

@@ -27,6 +27,7 @@
#include "assetexportpluginconstants.h"
#include <QColor>
#include <QFontInfo>
#include <QHash>
namespace {
@@ -68,10 +69,14 @@ QJsonObject TextNodeParser::json(Component &component) const
QJsonObject textDetails;
textDetails.insert(TextContentTag, propertyValue("text").toString());
textDetails.insert(FontFamilyTag, propertyValue("font.family").toString());
textDetails.insert(FontStyleTag, propertyValue("font.styleName").toString());
textDetails.insert(FontSizeTag, propertyValue("font.pixelSize").toInt());
textDetails.insert(LetterSpacingTag, propertyValue("font.letterSpacing").toFloat());
QFont font = propertyValue("font").value<QFont>();
QFontInfo fontInfo(font);
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());
textDetails.insert(TextColorTag, fontColor.name(QColor::HexArgb));

View File

@@ -217,6 +217,7 @@ Utils::FilePath DesignDocument::fileName() const
{
if (editor())
return editor()->document()->filePath();
return Utils::FilePath();
}
@@ -239,14 +240,11 @@ void DesignDocument::loadDocument(QPlainTextEdit *edit)
{
Q_CHECK_PTR(edit);
connect(edit, &QPlainTextEdit::undoAvailable,
this, &DesignDocument::undoAvailable);
connect(edit, &QPlainTextEdit::redoAvailable,
this, &DesignDocument::redoAvailable);
connect(edit, &QPlainTextEdit::modificationChanged,
this, &DesignDocument::dirtyStateChanged);
connect(edit, &QPlainTextEdit::undoAvailable, this, &DesignDocument::undoAvailable);
connect(edit, &QPlainTextEdit::redoAvailable, 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);
@@ -266,7 +264,6 @@ void DesignDocument::changeToDocumentModel()
viewManager().detachRewriterView();
viewManager().detachViewsExceptRewriterAndComponetView();
m_inFileComponentModel.reset();
viewManager().attachRewriterView();
@@ -299,7 +296,8 @@ void DesignDocument::updateQrcFiles()
ProjectExplorer::Project *currentProject = ProjectExplorer::SessionManager::projectForFile(fileName());
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"))
QmlJS::ModelManagerInterface::instance()->updateQrcFile(fileName.toString());
}
@@ -350,6 +348,7 @@ bool DesignDocument::isUndoAvailable() const
{
if (plainTextEdit())
return plainTextEdit()->document()->isUndoAvailable();
return false;
}
@@ -357,6 +356,7 @@ bool DesignDocument::isRedoAvailable() const
{
if (plainTextEdit())
return plainTextEdit()->document()->isRedoAvailable();
return false;
}
@@ -380,7 +380,7 @@ void DesignDocument::deleteSelected()
QStringList lockedNodes;
for (const ModelNode &modelNode : view()->selectedModelNodes()) {
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());
}
}
@@ -408,9 +408,8 @@ void DesignDocument::deleteSelected()
return;
}
rewriterView()->executeInTransaction("DesignDocument::deleteSelected", [this](){
QList<ModelNode> toDelete = view()->selectedModelNodes();
rewriterView()->executeInTransaction("DesignDocument::deleteSelected", [this]() {
const QList<ModelNode> toDelete = view()->selectedModelNodes();
for (ModelNode node : toDelete) {
if (node.isValid() && !node.isRootNode() && QmlObjectNode::isValidQmlObjectNode(node))
QmlObjectNode(node).destroy();
@@ -442,32 +441,33 @@ static void scatterItem(const ModelNode &pastedNode, const ModelNode &targetNode
return;
bool scatter = false;
foreach (const ModelNode &childNode, targetNode.directSubModelNodes()) {
if ((childNode.variantProperty("x").value() == pastedNode.variantProperty("x").value()) &&
(childNode.variantProperty("y").value() == pastedNode.variantProperty("y").value()))
for (const ModelNode &childNode : targetNode.directSubModelNodes()) {
if (childNode.variantProperty("x").value() == pastedNode.variantProperty("x").value() &&
childNode.variantProperty("y").value() == pastedNode.variantProperty("y").value()) {
scatter = true;
break;
}
}
if (!scatter)
return;
if (offset == -2000) {
if (offset == -2000) { // scatter in range
double x = pastedNode.variantProperty("x").value().toDouble();
double y = pastedNode.variantProperty("y").value().toDouble();
double targetWidth = 20;
double targetHeight = 20;
x = x + double(QRandomGenerator::global()->generate()) / RAND_MAX * targetWidth
- targetWidth / 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;
const double scatterRange = 20.;
x += QRandomGenerator::global()->generateDouble() * scatterRange - scatterRange / 2;
y += QRandomGenerator::global()->generateDouble() * scatterRange - scatterRange / 2;
pastedNode.variantProperty("x").setValue(int(x));
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())
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()) {
targetNode = targetNode.parentProperty().parentModelNode();
} else {
@@ -516,19 +516,20 @@ void DesignDocument::paste()
if (!targetNode.isValid())
targetNode = view.rootModelNode();
foreach (const ModelNode &node, selectedNodes) {
foreach (const ModelNode &node2, selectedNodes) {
for (const ModelNode &node : qAsConst(selectedNodes)) {
for (const ModelNode &node2 : qAsConst(selectedNodes)) {
if (node.isAncestorOf(node2))
selectedNodes.removeAll(node2);
}
}
rewriterView()->executeInTransaction("DesignDocument::paste1", [&view, selectedNodes, targetNode](){
rewriterView()->executeInTransaction("DesignDocument::paste1", [&view, selectedNodes, targetNode]() {
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());
ModelNode pastedNode(view.insertModel(node));
pastedNodeList.append(pastedNode);
@@ -572,11 +573,11 @@ void DesignDocument::paste()
PropertyName defaultProperty(targetNode.metaInfo().defaultPropertyName());
scatterItem(pastedNode, targetNode);
if (targetNode.metaInfo().propertyIsListProperty(defaultProperty)) {
if (targetNode.metaInfo().propertyIsListProperty(defaultProperty))
targetNode.nodeListProperty(defaultProperty).reparentHere(pastedNode);
} else {
else
qWarning() << "Cannot reparent to" << targetNode;
}
view.setSelectedModelNodes({pastedNode});
});
view.model()->clearMetaInfoCache();
@@ -591,7 +592,6 @@ void DesignDocument::selectAll()
DesignDocumentView view;
currentModel()->attachView(&view);
QList<ModelNode> allNodesExceptRootNode(view.allModelNodes());
allNodesExceptRootNode.removeOne(view.rootModelNode());
view.setSelectedModelNodes(allNodesExceptRootNode);
@@ -607,7 +607,6 @@ void DesignDocument::setEditor(Core::IEditor *editor)
m_textEditor = editor;
// if the user closed the file explicit we do not want to do anything with it anymore
connect(Core::EditorManager::instance(), &Core::EditorManager::aboutToSave,
this, [this](Core::IDocument *document) {
if (m_textEditor && m_textEditor->document() == document) {
@@ -622,8 +621,7 @@ void DesignDocument::setEditor(Core::IEditor *editor)
m_textEditor.clear();
});
connect(editor->document(), &Core::IDocument::filePathChanged,
this, &DesignDocument::updateFileName);
connect(editor->document(), &Core::IDocument::filePathChanged, this, &DesignDocument::updateFileName);
updateActiveTarget();
updateActiveTarget();
@@ -678,7 +676,6 @@ static Target *getActiveTarget(DesignDocument *designDocument)
if (!currentProject)
return nullptr;
QObject::connect(ProjectTree::instance(), &ProjectTree::currentProjectChanged,
designDocument, &DesignDocument::updateActiveTarget, Qt::UniqueConnection);

View File

@@ -32,7 +32,8 @@
#include "navigatortreemodel.h"
#include "qproxystyle.h"
#include "metainfo.h"
#include <metainfo.h>
#include <theme.h>
#include <utils/qtcassert.h>
@@ -55,7 +56,7 @@ IconCheckboxItemDelegate::IconCheckboxItemDelegate(QObject *parent,
QSize IconCheckboxItemDelegate::sizeHint(const QStyleOptionViewItem & /*option*/,
const QModelIndex & /*modelIndex*/) const
{
return {15, 20};
return {15, 20};
}
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;
}
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)
@@ -82,6 +83,13 @@ void IconCheckboxItemDelegate::paint(QPainter *painter,
const QStyleOptionViewItem &styleOption,
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;
// We need to invert the check status if visibility icon
bool checked = isVisibilityIcon ? isChecked(modelIndex) : !isChecked(modelIndex);
@@ -89,10 +97,7 @@ void IconCheckboxItemDelegate::paint(QPainter *painter,
return;
if (rowIsPropertyRole(modelIndex.model(), modelIndex))
return; //Do not paint icons for property rows
if (styleOption.state & QStyle::State_Selected)
NavigatorTreeView::drawSelectionBackground(painter, styleOption);
return; // Do not paint icons for property rows
if (!getModelNode(modelIndex).isRootNode()) {
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 QIcon &icon = isChecked(modelIndex) ? m_checkedIcon : m_uncheckedIcon;
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->drawPixmap(iconRect.topLeft(), iconPixmap);
painter->drawPixmap(iconRect.topLeft() + QPoint(0, delegateMargin), iconPixmap);
if (!visible)
painter->restore();
painter->restore();
}
}

View File

@@ -34,6 +34,7 @@
#include <metainfo.h>
#include <modelnodecontextmenu.h>
#include <qmlobjectnode.h>
#include <theme.h>
#include <coreplugin/messagebox.h>
#include <utils/qtcassert.h>
@@ -47,6 +48,8 @@
namespace QmlDesigner {
int NameItemDelegate::iconOffset = 0;
static QPixmap generateWavyPixmap(qreal maxRadius, const QPen &pen)
{
QPixmap pixmap;
@@ -111,13 +114,15 @@ NameItemDelegate::NameItemDelegate(QObject *parent)
static int drawIcon(QPainter *painter, const QStyleOptionViewItem &styleOption, const QModelIndex &modelIndex)
{
QIcon icon = modelIndex.data(Qt::DecorationRole).value<QIcon>();
const int pixmapSize = icon.isNull() ? 4 : 16;
const QIcon icon = modelIndex.data(Qt::DecorationRole).value<QIcon>();
int pixmapSize = icon.isNull() ? 4 : 16;
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;
}
@@ -128,19 +133,20 @@ static QRect drawText(QPainter *painter,
int iconOffset)
{
QString displayString = modelIndex.data(Qt::DisplayRole).toString();
if (displayString.isEmpty())
displayString = modelIndex.data(Qt::DisplayRole).toString();
QPoint displayStringOffset;
int width = 0;
// 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);
QPoint textPosition = styleOption.rect.bottomLeft() + displayStringOffset;
const QPoint textPosition = styleOption.rect.bottomLeft() + displayStringOffset;
painter->drawText(textPosition, displayString);
QRect textFrame;
@@ -150,9 +156,9 @@ static QRect drawText(QPainter *painter,
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)
@@ -175,17 +181,56 @@ static void drawRedWavyUnderLine(QPainter *painter,
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,
const QStyleOptionViewItem &styleOption,
const QModelIndex &modelIndex) const
{
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)
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);
QRect textFrame = drawText(painter, styleOption, modelIndex, iconOffset);
@@ -196,28 +241,8 @@ void NameItemDelegate::paint(QPainter *painter,
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,
const QStyleOptionViewItem & /*option*/,
const QStyleOptionViewItem &/*option*/,
const QModelIndex &index) const
{
if (!getModelNode(index).isValid())
@@ -235,42 +260,35 @@ void NameItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index)
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
{
Q_UNUSED(model)
auto lineEdit = static_cast<QLineEdit*>(editor);
setId(index,lineEdit->text());
setId(index, lineEdit->text());
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,
const QStyleOptionViewItem &option,
const QModelIndex & /*index*/) const
const QModelIndex &/*index*/) const
{
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

View File

@@ -34,18 +34,28 @@ class NavigatorTreeModel;
class NameItemDelegate : public QStyledItemDelegate
{
public:
static int iconOffset;
explicit NameItemDelegate(QObject *parent);
void paint(QPainter *painter, const QStyleOptionViewItem &styleOption,
const QModelIndex &index) const override;
QSize sizeHint(const QStyleOptionViewItem &option,
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;
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
protected:
bool editorEvent ( QEvent * event, QAbstractItemModel * model, const QStyleOptionViewItem & option, const QModelIndex & index ) override;
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
bool editorEvent(QEvent *event,
QAbstractItemModel *model,
const QStyleOptionViewItem &option,
const QModelIndex &index) override;
void updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option,
const QModelIndex &index) const override;
};
} // namespace QmlDesigner

View File

@@ -203,6 +203,12 @@ QVariant NavigatorTreeModel::data(const QModelIndex &index, int role) const
if (role == ItemIsVisibleRole) // independent of column
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 (role == Qt::DisplayRole) {
return modelNode.displayName();
@@ -237,8 +243,6 @@ QVariant NavigatorTreeModel::data(const QModelIndex &index, int role) const
auto op = m_actionManager->modelNodePreviewOperation(modelNode);
if (op)
return op(modelNode);
} else if (role == ModelNodeRole) {
return QVariant::fromValue<ModelNode>(modelNode);
}
} else if (index.column() == ColumnType::Alias) { // export
if (role == Qt::CheckStateRole)
@@ -268,7 +272,7 @@ Qt::ItemFlags NavigatorTreeModel::flags(const QModelIndex &index) const
if (index.column() == ColumnType::Alias
|| index.column() == ColumnType::Visibility
|| 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);
if (ModelNode::isThisOrAncestorLocked(modelNode))
@@ -277,8 +281,7 @@ Qt::ItemFlags NavigatorTreeModel::flags(const QModelIndex &index) const
if (index.column() == ColumnType::Name)
return Qt::ItemIsEditable | Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsSelectable | Qt::ItemIsEnabled;
return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable
| Qt::ItemNeverHasChildren;
return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemNeverHasChildren;
}
void static appendForcedNodes(const NodeListProperty &property, QList<ModelNode> &list)

View File

@@ -33,6 +33,7 @@
#include "previewtooltip.h"
#include <metainfo.h>
#include <theme.h>
#include <utils/icon.h>
#include <utils/utilsicons.h>
@@ -63,32 +64,28 @@ public:
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;
if (element == QStyle::PE_PanelItemViewRow) {
if (option->state & QStyle::State_MouseOver)
mouseOverStateSavedFrameRectangle = option->rect;
if (option->state & QStyle::State_Selected)
NavigatorTreeView::drawSelectionBackground(painter, *option);
painter->fillRect(option->rect.adjusted(0, delegateMargin, 0, -delegateMargin),
Theme::getColor(Theme::Color::QmlDesigner_BorderColor));
} else if (element == PE_IndicatorItemViewItemDrop) {
// between elements and on elements we have a width
if (option->rect.width() > 0) {
m_currentTextColor = option->palette.text().color();
QRect frameRectangle = adjustedRectangleToWidgetWidth(option->rect, widget);
painter->save();
if (option->rect.height() == 0) {
bool isNotRootItem = option->rect.top() > 10 && mouseOverStateSavedFrameRectangle.top() > 10;
if (isNotRootItem) {
if (isNotRootItem)
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 {
drawHighlightFrame(frameRectangle, painter);
}
@@ -96,12 +93,72 @@ public:
}
} else if (element == PE_FrameFocusRect) {
// 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 {
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)
return 0;
else
@@ -180,7 +237,8 @@ NavigatorTreeView::NavigatorTreeView(QWidget *parent)
void NavigatorTreeView::drawSelectionBackground(QPainter *painter, const QStyleOption &option)
{
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();
}
@@ -223,5 +281,4 @@ bool NavigatorTreeView::viewportEvent(QEvent *event)
return QTreeView::viewportEvent(event);
}
}

View File

@@ -145,6 +145,7 @@ void NavigatorView::modelAttached(Model *model)
treeView->header()->resizeSection(NavigatorTreeModel::ColumnType::Visibility, 26);
treeView->header()->resizeSection(NavigatorTreeModel::ColumnType::Lock, 26);
treeView->setIndentation(20);
treeView->setSelectionBehavior(QAbstractItemView::SelectRows);
m_currentModelInterface->setFilter(false);
@@ -493,7 +494,6 @@ void NavigatorView::changeSelection(const QItemSelection & /*newSelection*/, con
QSet<ModelNode> nodeSet;
for (const QModelIndex &index : treeWidget()->selectionModel()->selectedIndexes()) {
const ModelNode modelNode = modelNodeForIndex(index);
if (modelNode.isValid())
nodeSet.insert(modelNode);
@@ -539,7 +539,7 @@ void NavigatorView::updateItemSelection()
}
bool blocked = blockSelectionChangedSignal(true);
treeWidget()->selectionModel()->select(itemSelection, QItemSelectionModel::ClearAndSelect);
treeWidget()->selectionModel()->select(itemSelection, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
blockSelectionChangedSignal(blocked);
if (!selectedModelNodes().isEmpty())
@@ -586,7 +586,7 @@ void NavigatorView::reparentAndCatch(NodeAbstractProperty property, const ModelN
{
try {
property.reparentHere(modelNode);
} catch (Exception &exception) {
} catch (Exception &exception) {
exception.showException();
}
}
@@ -620,29 +620,29 @@ void NavigatorView::setupWidget()
const QIcon visibilityOnIcon =
Utils::StyleHelper::getIconFromIconFont(fontName,
Theme::getIconUnicode(Theme::Icon::visibilityOn),
28, 28, QColor(Qt::white));
20, 20, QColor(Qt::white));
const QIcon visibilityOffIcon =
Utils::StyleHelper::getIconFromIconFont(fontName,
Theme::getIconUnicode(Theme::Icon::visibilityOff),
28, 28, QColor(Qt::white));
20, 20, QColor(Qt::white));
const QIcon aliasOnIcon =
Utils::StyleHelper::getIconFromIconFont(fontName,
Theme::getIconUnicode(Theme::Icon::idAliasOn),
28, 28, QColor(Qt::red));
20, 20, QColor(Qt::red));
const QIcon aliasOffIcon =
Utils::StyleHelper::getIconFromIconFont(fontName,
Theme::getIconUnicode(Theme::Icon::idAliasOff),
28, 28, QColor(Qt::white));
20, 20, QColor(Qt::white));
const QIcon lockOnIcon =
Utils::StyleHelper::getIconFromIconFont(fontName,
Theme::getIconUnicode(Theme::Icon::lockOn),
28, 28, QColor(Qt::white));
20, 20, QColor(Qt::white));
const QIcon lockOffIcon =
Utils::StyleHelper::getIconFromIconFont(fontName,
Theme::getIconUnicode(Theme::Icon::lockOff),
28, 28, QColor(Qt::white));
20, 20, QColor(Qt::white));
auto idDelegate = new NameItemDelegate(this);

View File

@@ -43,6 +43,8 @@ QT_END_NAMESPACE
namespace QmlDesigner {
static int delegateMargin = 2;
class NavigatorWidget;
class NavigatorTreeModel;
@@ -50,7 +52,8 @@ enum NavigatorRoles {
ItemIsVisibleRole = Qt::UserRole,
RowIsPropertyRole = Qt::UserRole + 1,
ModelNodeRole = Qt::UserRole + 2,
ToolTipImageRole = Qt::UserRole + 3
ToolTipImageRole = Qt::UserRole + 3,
ItemOrAncestorLocked = Qt::UserRole + 4
};
class NavigatorView : public AbstractView

View File

@@ -31,7 +31,6 @@
#include <imagecache.h>
#include <QApplication>
#include <QDesktopWidget>
#include <QMetaObject>
namespace QmlDesigner {
@@ -65,8 +64,7 @@ void PreviewTooltipBackend::showTooltip()
},
[] {});
auto desktopWidget = QApplication::desktop();
auto mousePosition = desktopWidget->cursor().pos();
auto mousePosition = QCursor::pos();
mousePosition += {20, 20};
m_tooltip->move(mousePosition);

View File

@@ -42,6 +42,7 @@
#include <QFontDatabase>
#include <QMessageBox>
#include <QQmlContext>
#include <QWindow>
#include <coreplugin/icore.h>
@@ -495,7 +496,9 @@ void PropertyEditorContextObject::hideCursor()
return;
QApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
m_lastPos = QCursor::pos();
if (QWidget *w = QApplication::activeWindow())
m_lastPos = QCursor::pos(w->screen());
}
void PropertyEditorContextObject::restoreCursor()
@@ -503,8 +506,19 @@ void PropertyEditorContextObject::restoreCursor()
if (!QApplication::overrideCursor())
return;
QCursor::setPos(m_lastPos);
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)

View File

@@ -91,6 +91,7 @@ public:
Q_INVOKABLE void hideCursor();
Q_INVOKABLE void restoreCursor();
Q_INVOKABLE void holdCursorInPlace();
Q_INVOKABLE QStringList styleNamesForFamily(const QString &family);

View File

@@ -693,35 +693,33 @@ void ModelNode::removeProperty(const PropertyName &name) const
model()->d->removeProperty(internalNode()->property(name));
}
/*! \brief removes this node from the node tree
*/
static QList<ModelNode> descendantNodes(const ModelNode &parent)
static QList<ModelNode> descendantNodes(const ModelNode &node)
{
QList<ModelNode> descendants(parent.directSubModelNodes());
foreach (const ModelNode &child, parent.directSubModelNodes()) {
const QList<ModelNode> children = node.directSubModelNodes();
QList<ModelNode> descendants = children;
for (const ModelNode &child : children)
descendants += descendantNodes(child);
}
return descendants;
}
static void removeModelNodeFromSelection(const ModelNode &node)
{
{ // remove nodes from the active selection:
QList<ModelNode> selectedList = node.view()->selectedModelNodes();
// remove nodes from the active selection
QList<ModelNode> selectedList = node.view()->selectedModelNodes();
foreach (const ModelNode &childModelNode, descendantNodes(node))
selectedList.removeAll(childModelNode);
selectedList.removeAll(node);
const QList<ModelNode> descendants = descendantNodes(node);
for (const ModelNode &descendantNode : descendants)
selectedList.removeAll(descendantNode);
node.view()->setSelectedModelNodes(selectedList);
}
selectedList.removeAll(node);
node.view()->setSelectedModelNodes(selectedList);
}
/*! \brief complete removes this ModelNode from the Model
*/
void ModelNode::destroy()
{

View File

@@ -208,6 +208,8 @@ QmlDesignerPlugin::~QmlDesignerPlugin()
////////////////////////////////////////////////////
bool QmlDesignerPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage/* = 0*/)
{
QDir{}.mkpath(Core::ICore::cacheResourcePath());
if (!Utils::HostOsInfo::canCreateOpenGLContext(errorMessage))
return false;
d = new QmlDesignerPluginPrivate;

View File

@@ -30,6 +30,7 @@
#include "qmljsindenter.h"
#include "qmljsqtstylecodeformatter.h"
#include <texteditor/fontsettings.h>
#include <texteditor/snippets/snippetprovider.h>
#include <texteditor/tabsettings.h>
#include <texteditor/simplecodestylepreferences.h>

View File

@@ -143,9 +143,9 @@ void BaseHoverHandler::identifyMatch(TextEditorWidget *editorWidget, int pos, Re
void BaseHoverHandler::operateTooltip(TextEditorWidget *editorWidget, const QPoint &point)
{
const QVariant helpItem = m_lastHelpItemIdentified.isEmpty()
? QVariant()
: QVariant::fromValue(m_lastHelpItemIdentified);
const QVariant helpItem = m_lastHelpItemIdentified.isValid()
? QVariant::fromValue(m_lastHelpItemIdentified)
: QVariant();
const bool extractHelp = m_lastHelpItemIdentified.isValid()
&& !m_lastHelpItemIdentified.isFuzzyMatch();
const QString helpContents = extractHelp ? m_lastHelpItemIdentified.firstParagraph()

View File

@@ -305,23 +305,17 @@ void CodeAssistantPrivate::displayProposal(IAssistProposal *newProposal, AssistR
// TODO: The proposal should own the model until someone takes it explicitly away.
QScopedPointer<IAssistProposal> proposalCandidate(newProposal);
bool destroyCurrentContext = false;
if (isDisplayingProposal()) {
if (!m_proposal->isFragile())
return;
destroyCurrentContext = true;
}
if (isDisplayingProposal() && !m_proposal->isFragile())
return;
int basePosition = proposalCandidate->basePosition();
if (m_editorWidget->position() < basePosition) {
if (destroyCurrentContext)
destroyContext();
destroyContext();
return;
}
if (m_abortedBasePosition == basePosition && reason != ExplicitlyInvoked) {
if (destroyCurrentContext)
destroyContext();
destroyContext();
return;
}
@@ -333,8 +327,7 @@ void CodeAssistantPrivate::displayProposal(IAssistProposal *newProposal, AssistR
return;
}
if (destroyCurrentContext)
destroyContext();
destroyContext();
clearAbortedPosition();
m_proposal.reset(proposalCandidate.take());

View File

@@ -32,6 +32,7 @@
#include "ui_snippetssettingspage.h"
#include <coreplugin/icore.h>
#include <texteditor/fontsettings.h>
#include <texteditor/textdocument.h>
#include <texteditor/texteditorconstants.h>
#include <texteditor/texteditorsettings.h>

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

View File

@@ -23,5 +23,7 @@
<file>images/expandarrow.png</file>
<file>images/expandarrow@2x.png</file>
<file>images/border.png</file>
<file>images/download.png</file>
<file>images/download@2x.png</file>
</qresource>
</RCC>

View File

@@ -287,6 +287,7 @@ public:
auto l = new QVBoxLayout;
l->setContentsMargins(0, 0, 0, 0);
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("community", tr("Online Community"), "https://forum.qt.io", this));
l->addWidget(new IconAndLink("blogs", tr("Blogs"), "https://planet.qt.io", this));

View File

@@ -86,32 +86,32 @@ QVector<ProFileEvaluator::SourceFile> ProFileEvaluator::fixifiedValues(
QVector<SourceFile> result;
foreach (const ProString &str, d->values(ProKey(variable))) {
const QString &el = d->m_option->expandEnvVars(str.toQString());
if (IoUtils::isAbsolutePath(el)) {
result << SourceFile{QDir::cleanPath(el), str.sourceFile()};
const QString fn = IoUtils::isAbsolutePath(el)
? 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 {
QString fn = QDir::cleanPath(baseDirectory + QLatin1Char('/') + el);
if (IoUtils::exists(fn)) {
if (IoUtils::isAbsolutePath(el)) {
result << SourceFile{fn, str.sourceFile()};
} else {
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 {
result << SourceFile{QDir::cleanPath(buildDirectory + QLatin1Char('/') + el),
str.sourceFile()};
}
result << SourceFile{QDir::cleanPath(buildDirectory + QLatin1Char('/') + el),
str.sourceFile()};
}
}
}

View File

@@ -7069,6 +7069,24 @@
id="path5457-0-5"
style="display:inline" />
</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
id="src/libs/utils/images/member"
transform="translate(-28,0)">

Before

Width:  |  Height:  |  Size: 380 KiB

After

Width:  |  Height:  |  Size: 381 KiB

View File

@@ -519,6 +519,7 @@ enum AdditionalCriteria
static bool matchesAdditionalCriteria(int criteria)
{
#ifdef Q_OS_UNIX
Q_UNUSED(criteria)
return true;
#else
return !(criteria & NeedsInferiorCall);

View File

@@ -670,9 +670,9 @@ def getChildByClass(parent, classToSearchFor, occurrence=1):
return children[occurrence - 1]
def getHelpViewer():
return waitForObject("{type='Help::Internal::TextBrowserHelpWidget' unnamed='1' "
"visible='1' window=':Qt Creator_Core::Internal::MainWindow'}",
return waitForObject("{type='QLiteHtmlWidget' unnamed='1' visible='1' "
"window=':Qt Creator_Core::Internal::MainWindow'}",
1000)
def getHelpTitle():
return str(getHelpViewer().documentTitle)
return str(getHelpViewer().title())

View File

@@ -32,27 +32,17 @@ urlDictionary = { "abundance":"qthelp://com.trolltech.qt.487/qdoc/gettingstarted
def __getSelectedText__():
hv = getHelpViewer()
try:
return hv.textCursor().selectedText()
except:
pass
try:
test.log("Falling back to searching for selection in HTML.")
return getHighlightsInHtml(str(hv.toHtml()))
return str(getHelpViewer().selectedText())
except:
test.warning("Could not get highlighted text.")
return str("")
def __getUrl__():
helpViewer = getHelpViewer()
try:
url = helpViewer.url
url = getHelpViewer().url()
except:
try:
url = helpViewer.source
except:
return ""
return ""
return str(url.scheme) + "://" + str(url.host) + str(url.path)
def getHighlightsInHtml(htmlCode):