Merge remote-tracking branch 'origin/4.15'

Change-Id: I23d25ad32c396811acad88873ac556ee13372ee3
This commit is contained in:
Eike Ziller
2021-04-12 09:18:06 +02:00
45 changed files with 678 additions and 440 deletions

View File

@@ -153,9 +153,7 @@ OutputWindow::OutputWindow(Context context, const QString &settingsKey, QWidget
EditorManager::openEditorAt(fp.toString(), line, column);
});
connect(verticalScrollBar(), &QAbstractSlider::sliderMoved,
this, &OutputWindow::updateAutoScroll);
connect(verticalScrollBar(), &QAbstractSlider::sliderReleased,
connect(verticalScrollBar(), &QAbstractSlider::actionTriggered,
this, &OutputWindow::updateAutoScroll);
undoAction->setEnabled(false);
@@ -451,7 +449,7 @@ void OutputWindow::handleOutputChunk(const QString &output, OutputFormat format)
void OutputWindow::updateAutoScroll()
{
d->scrollToBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum() - 1;
d->scrollToBottom = verticalScrollBar()->sliderPosition() >= verticalScrollBar()->maximum() - 1;
}
void OutputWindow::setMaxCharCount(int count)

View File

@@ -37,10 +37,12 @@
#include <abstractview.h>
#include <nodemetainfo.h>
#include <exception.h>
#include <rewritertransaction.h>
#include <utils/qtcassert.h>
#include <QTimer>
#include <QScopeGuard>
GradientModel::GradientModel(QObject *parent) :
QAbstractListModel(parent)
@@ -109,9 +111,9 @@ int GradientModel::addStop(qreal position, const QColor &color)
if (m_itemNode.modelNode().hasNodeProperty(gradientPropertyName().toUtf8())) {
int properPos = 0;
try {
QmlDesigner::ModelNode gradientNode = m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).modelNode();
try {
QmlDesigner::ModelNode gradientNode = m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).modelNode();
QmlDesigner::ModelNode gradientStopNode = createGradientStopNode();
@@ -128,6 +130,9 @@ int GradientModel::addStop(qreal position, const QColor &color)
gradientNode.nodeListProperty("stops").slide(stopNodes.count() - 1, properPos);
setupModel();
resetPuppet();
emit gradientCountChanged();
} catch (const QmlDesigner::Exception &e) {
e.showException();
}
@@ -176,6 +181,7 @@ void GradientModel::addGradient()
if (m_gradientTypeName != "Gradient")
resetPuppet(); /*Unfortunately required */
emit hasGradientChanged();
emit gradientTypeChanged();
}
@@ -247,9 +253,15 @@ void GradientModel::removeStop(int index)
if (stop.isValid()) {
stop.destroy();
setupModel();
resetPuppet();
emit gradientCountChanged();
}
});
return;
}
qWarning() << Q_FUNC_INFO << "invalid index";
}
@@ -301,10 +313,10 @@ qreal GradientModel::readGradientProperty(const QString &propertyName) const
void GradientModel::setupModel()
{
m_locked = true;
beginResetModel();
auto guard = qScopeGuard([&] { m_locked = false; });
beginResetModel();
endResetModel();
m_locked = false;
}
void GradientModel::setAnchorBackend(const QVariant &anchorBackend)
@@ -324,12 +336,11 @@ void GradientModel::setAnchorBackend(const QVariant &anchorBackend)
setupModel();
m_locked = true;
auto guard = qScopeGuard([&] { m_locked = false; });
emit anchorBackendChanged();
emit hasGradientChanged();
emit gradientTypeChanged();
m_locked = false;
}
QString GradientModel::gradientPropertyName() const
@@ -482,9 +493,10 @@ void GradientModel::deleteGradientNode(bool saveTransaction)
if (m_itemNode.isInBaseState()) {
if (modelNode.hasProperty(gradientPropertyName().toUtf8())) {
QmlDesigner::RewriterTransaction transaction;
if (saveTransaction)
QmlDesigner::RewriterTransaction transaction = view()->beginRewriterTransaction(
QByteArrayLiteral("GradientModel::deleteGradient"));
transaction = view()->beginRewriterTransaction(QByteArrayLiteral("GradientModel::deleteGradient"));
QmlDesigner::ModelNode gradientNode
= modelNode.nodeProperty(gradientPropertyName().toUtf8()).modelNode();
if (QmlDesigner::QmlObjectNode(gradientNode).isValid())
@@ -529,7 +541,8 @@ void GradientModel::setPresetByID(int presetID)
void GradientModel::setPresetByStops(const QList<qreal> &stopsPositions,
const QList<QString> &stopsColors,
int stopsCount)
int stopsCount,
bool saveTransaction)
{
if (m_locked)
return;
@@ -537,8 +550,9 @@ void GradientModel::setPresetByStops(const QList<qreal> &stopsPositions,
if (!m_itemNode.isValid() || gradientPropertyName().isEmpty())
return;
QmlDesigner::RewriterTransaction transaction = view()->beginRewriterTransaction(
QByteArrayLiteral("GradientModel::setCustomPreset"));
QmlDesigner::RewriterTransaction transaction;
if (saveTransaction)
transaction = view()->beginRewriterTransaction(QByteArrayLiteral("GradientModel::setCustomPreset"));
deleteGradientNode(false);
@@ -599,6 +613,8 @@ void GradientModel::savePreset()
void GradientModel::updateGradient()
{
beginResetModel();
QList<qreal> stops;
QList<QString> colors;
int stopsCount = rowCount();
@@ -607,5 +623,7 @@ void GradientModel::updateGradient()
colors.append(getColor(i).name(QColor::HexArgb));
}
setPresetByStops(stops, colors, stopsCount);
setPresetByStops(stops, colors, stopsCount, false);
endResetModel();
}

View File

@@ -38,7 +38,7 @@ class GradientModel : public QAbstractListModel
Q_PROPERTY(QVariant anchorBackendProperty READ anchorBackend WRITE setAnchorBackend NOTIFY anchorBackendChanged)
Q_PROPERTY(QString gradientPropertyName READ gradientPropertyName WRITE setGradientPropertyName)
Q_PROPERTY(QString gradientTypeName READ gradientTypeName WRITE setGradientTypeName NOTIFY gradientTypeChanged)
Q_PROPERTY(int count READ rowCount)
Q_PROPERTY(int count READ rowCount NOTIFY gradientCountChanged)
Q_PROPERTY(bool hasGradient READ hasGradient NOTIFY hasGradientChanged)
public:
@@ -73,7 +73,8 @@ public:
Q_INVOKABLE void setPresetByID(int presetID);
Q_INVOKABLE void setPresetByStops(const QList<qreal> &stopsPositions,
const QList<QString> &stopsColors,
int stopsCount);
int stopsCount,
bool saveTransaction = true);
Q_INVOKABLE void savePreset();
@@ -83,6 +84,7 @@ signals:
void anchorBackendChanged();
void hasGradientChanged();
void gradientTypeChanged();
void gradientCountChanged();
private:
void setupModel();