forked from qt-creator/qt-creator
QmlEditorWidgets: Inline contextpanewidgetrectangle.ui
Change-Id: I8f823c0035ef74671e8240cb50f447a521ec088e Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -6,7 +6,7 @@ add_qtc_library(QmlEditorWidgets
|
|||||||
contextpanetextwidget.cpp contextpanetextwidget.h
|
contextpanetextwidget.cpp contextpanetextwidget.h
|
||||||
contextpanewidget.cpp contextpanewidget.h
|
contextpanewidget.cpp contextpanewidget.h
|
||||||
contextpanewidgetimage.cpp contextpanewidgetimage.h
|
contextpanewidgetimage.cpp contextpanewidgetimage.h
|
||||||
contextpanewidgetrectangle.cpp contextpanewidgetrectangle.h contextpanewidgetrectangle.ui
|
contextpanewidgetrectangle.cpp contextpanewidgetrectangle.h
|
||||||
customcolordialog.cpp customcolordialog.h
|
customcolordialog.cpp customcolordialog.h
|
||||||
easingpane/easingcontextpane.cpp easingpane/easingcontextpane.h
|
easingpane/easingcontextpane.cpp easingpane/easingcontextpane.h
|
||||||
easingpane/easinggraph.cpp easingpane/easinggraph.h
|
easingpane/easinggraph.cpp easingpane/easinggraph.h
|
||||||
|
@@ -2,40 +2,82 @@
|
|||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
#include "contextpanewidgetrectangle.h"
|
#include "contextpanewidgetrectangle.h"
|
||||||
#include "ui_contextpanewidgetrectangle.h"
|
|
||||||
|
#include "colorbutton.h"
|
||||||
#include "contextpanewidget.h"
|
#include "contextpanewidget.h"
|
||||||
#include "customcolordialog.h"
|
#include "customcolordialog.h"
|
||||||
|
#include "gradientline.h"
|
||||||
|
|
||||||
#include <qmljs/qmljspropertyreader.h>
|
#include <qmljs/qmljspropertyreader.h>
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
#include <qmljs/qmljsutils.h>
|
#include <qmljs/qmljsutils.h>
|
||||||
|
|
||||||
|
#include <QButtonGroup>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QTimerEvent>
|
||||||
|
#include <QToolButton>
|
||||||
|
|
||||||
namespace QmlEditorWidgets {
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
ContextPaneWidgetRectangle::ContextPaneWidgetRectangle(QWidget *parent) :
|
ContextPaneWidgetRectangle::ContextPaneWidgetRectangle(QWidget *parent)
|
||||||
QWidget(parent),
|
: QWidget(parent)
|
||||||
ui(new Ui::ContextPaneWidgetRectangle)
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
const auto toolButton = [] (const QString &icon) {
|
||||||
|
auto result = new QToolButton;
|
||||||
|
result->setAutoExclusive(true);
|
||||||
|
result->setCheckable(true);
|
||||||
|
result->setFixedSize(30, 30);
|
||||||
|
result->setIcon(QIcon(":/qmldesigner/images/" + icon + ".png"));
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
ui->colorColorButton->setShowArrow(false);
|
m_gradientLabel = new QLabel(tr("Gradient"));
|
||||||
ui->borderColorButton->setShowArrow(false);
|
m_gradientLabel->setAlignment(Qt::AlignBottom);
|
||||||
|
m_gradientLine = new GradientLine;
|
||||||
|
m_gradientLine->setMinimumWidth(240);
|
||||||
|
|
||||||
connect(ui->colorColorButton, &QmlEditorWidgets::ColorButton::toggled,
|
m_colorColorButton = new ColorButton;
|
||||||
|
m_colorColorButton->setShowArrow(false);
|
||||||
|
m_colorSolid = toolButton("icon_color_solid");
|
||||||
|
m_colorGradient = toolButton("icon_color_gradient");
|
||||||
|
m_colorNone = toolButton("icon_color_none");
|
||||||
|
auto colorButtons = new QButtonGroup(this);
|
||||||
|
colorButtons->addButton(m_colorSolid);
|
||||||
|
colorButtons->addButton(m_colorGradient);
|
||||||
|
colorButtons->addButton(m_colorNone);
|
||||||
|
|
||||||
|
m_borderColorButton = new ColorButton;
|
||||||
|
m_borderColorButton->setShowArrow(false);
|
||||||
|
m_borderSolid = toolButton("icon_color_solid");
|
||||||
|
m_borderNone = toolButton("icon_color_none");
|
||||||
|
auto borderButtons = new QButtonGroup(this);
|
||||||
|
borderButtons->addButton(m_borderSolid);
|
||||||
|
borderButtons->addButton(m_borderNone);
|
||||||
|
|
||||||
|
using namespace Utils::Layouting;
|
||||||
|
Grid {
|
||||||
|
m_gradientLabel, m_gradientLine, br,
|
||||||
|
tr("Color"), Row { m_colorColorButton, m_colorSolid, m_colorGradient, m_colorNone, st, }, br,
|
||||||
|
tr("Border"), Row { m_borderColorButton, m_borderSolid, m_borderNone, st, }, br,
|
||||||
|
}.attachTo(this);
|
||||||
|
|
||||||
|
connect(m_colorColorButton, &QmlEditorWidgets::ColorButton::toggled,
|
||||||
this, &ContextPaneWidgetRectangle::onColorButtonToggled);
|
this, &ContextPaneWidgetRectangle::onColorButtonToggled);
|
||||||
connect(ui->borderColorButton, &QmlEditorWidgets::ColorButton::toggled,
|
connect(m_borderColorButton, &QmlEditorWidgets::ColorButton::toggled,
|
||||||
this, &ContextPaneWidgetRectangle::onBorderColorButtonToggled);
|
this, &ContextPaneWidgetRectangle::onBorderColorButtonToggled);
|
||||||
|
|
||||||
connect(ui->colorSolid, &QToolButton::clicked,
|
connect(m_colorSolid, &QToolButton::clicked,
|
||||||
this, &ContextPaneWidgetRectangle::onColorSolidClicked);
|
this, &ContextPaneWidgetRectangle::onColorSolidClicked);
|
||||||
connect(ui->borderSolid, &QToolButton::clicked,
|
connect(m_borderSolid, &QToolButton::clicked,
|
||||||
this, &ContextPaneWidgetRectangle::onBorderSolidClicked);
|
this, &ContextPaneWidgetRectangle::onBorderSolidClicked);
|
||||||
|
|
||||||
connect(ui->colorNone, &QToolButton::clicked,
|
connect(m_colorNone, &QToolButton::clicked,
|
||||||
this, &ContextPaneWidgetRectangle::onColorNoneClicked);
|
this, &ContextPaneWidgetRectangle::onColorNoneClicked);
|
||||||
connect(ui->borderNone, &QToolButton::clicked,
|
connect(m_borderNone, &QToolButton::clicked,
|
||||||
this, &ContextPaneWidgetRectangle::onBorderNoneClicked);
|
this, &ContextPaneWidgetRectangle::onBorderNoneClicked);
|
||||||
|
|
||||||
connect(ui->colorGradient, &QToolButton::clicked, this, &ContextPaneWidgetRectangle::onGradientClicked);
|
connect(m_colorGradient, &QToolButton::clicked, this, &ContextPaneWidgetRectangle::onGradientClicked);
|
||||||
|
|
||||||
ContextPaneWidget *parentContextWidget = qobject_cast<ContextPaneWidget*>(parentWidget());
|
ContextPaneWidget *parentContextWidget = qobject_cast<ContextPaneWidget*>(parentWidget());
|
||||||
connect(parentContextWidget->colorDialog(), &CustomColorDialog::accepted,
|
connect(parentContextWidget->colorDialog(), &CustomColorDialog::accepted,
|
||||||
@@ -43,17 +85,12 @@ ContextPaneWidgetRectangle::ContextPaneWidgetRectangle(QWidget *parent) :
|
|||||||
connect(parentContextWidget->colorDialog(), &CustomColorDialog::rejected,
|
connect(parentContextWidget->colorDialog(), &CustomColorDialog::rejected,
|
||||||
this, &ContextPaneWidgetRectangle::onColorDialogCancled);
|
this, &ContextPaneWidgetRectangle::onColorDialogCancled);
|
||||||
|
|
||||||
connect(ui->gradientLine, &QmlEditorWidgets::GradientLine::openColorDialog,
|
connect(m_gradientLine, &QmlEditorWidgets::GradientLine::openColorDialog,
|
||||||
this, &ContextPaneWidgetRectangle::onGradientLineDoubleClicked);
|
this, &ContextPaneWidgetRectangle::onGradientLineDoubleClicked);
|
||||||
connect(ui->gradientLine, &QmlEditorWidgets::GradientLine::gradientChanged,
|
connect(m_gradientLine, &QmlEditorWidgets::GradientLine::gradientChanged,
|
||||||
this, &ContextPaneWidgetRectangle::onUpdateGradient);
|
this, &ContextPaneWidgetRectangle::onUpdateGradient);
|
||||||
}
|
}
|
||||||
|
|
||||||
ContextPaneWidgetRectangle::~ContextPaneWidgetRectangle()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContextPaneWidgetRectangle::setProperties(QmlJS::PropertyReader *propertyReader)
|
void ContextPaneWidgetRectangle::setProperties(QmlJS::PropertyReader *propertyReader)
|
||||||
{
|
{
|
||||||
m_hasGradient = propertyReader->hasProperty(QLatin1String("gradient"));
|
m_hasGradient = propertyReader->hasProperty(QLatin1String("gradient"));
|
||||||
@@ -64,44 +101,44 @@ void ContextPaneWidgetRectangle::setProperties(QmlJS::PropertyReader *propertyRe
|
|||||||
QString str = propertyReader->readProperty(QLatin1String("color")).toString();
|
QString str = propertyReader->readProperty(QLatin1String("color")).toString();
|
||||||
if (QmlJS::toQColor(str).alpha() == 0)
|
if (QmlJS::toQColor(str).alpha() == 0)
|
||||||
m_none = true;
|
m_none = true;
|
||||||
ui->colorColorButton->setColor(str);
|
m_colorColorButton->setColor(str);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ui->colorColorButton->setColor(QLatin1String("white"));
|
m_colorColorButton->setColor(QLatin1String("white"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (propertyReader->hasProperty(QLatin1String("border.color"))) {
|
if (propertyReader->hasProperty(QLatin1String("border.color"))) {
|
||||||
ui->borderColorButton->setColor(propertyReader->readProperty(QLatin1String("border.color")).toString());
|
m_borderColorButton->setColor(propertyReader->readProperty(QLatin1String("border.color")).toString());
|
||||||
m_hasBorder = true;
|
m_hasBorder = true;
|
||||||
} else {
|
} else {
|
||||||
ui->borderColorButton->setColor(QLatin1String("transparent"));
|
m_borderColorButton->setColor(QLatin1String("transparent"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (propertyReader->hasProperty(QLatin1String("border.width")))
|
if (propertyReader->hasProperty(QLatin1String("border.width")))
|
||||||
m_hasBorder = true;
|
m_hasBorder = true;
|
||||||
|
|
||||||
ui->colorSolid->setChecked(true);
|
m_colorSolid->setChecked(true);
|
||||||
ui->borderNone->setChecked(true);
|
m_borderNone->setChecked(true);
|
||||||
ui->borderSolid->setChecked(m_hasBorder);
|
m_borderSolid->setChecked(m_hasBorder);
|
||||||
|
|
||||||
if (m_none)
|
if (m_none)
|
||||||
ui->colorNone->setChecked(true);
|
m_colorNone->setChecked(true);
|
||||||
|
|
||||||
ui->gradientLabel->setEnabled(true);
|
m_gradientLabel->setEnabled(true);
|
||||||
ui->gradientLine->setEnabled(true);
|
m_gradientLine->setEnabled(true);
|
||||||
|
|
||||||
if (m_hasGradient && isGradientEditingEnabled()) {
|
if (m_hasGradient && isGradientEditingEnabled()) {
|
||||||
bool isBound;
|
bool isBound;
|
||||||
ui->colorGradient->setChecked(true);
|
m_colorGradient->setChecked(true);
|
||||||
ui->gradientLine->setGradient(propertyReader->parseGradient(QLatin1String("gradient"), &isBound));
|
m_gradientLine->setGradient(propertyReader->parseGradient(QLatin1String("gradient"), &isBound));
|
||||||
if (isBound) {
|
if (isBound) {
|
||||||
ui->gradientLabel->setEnabled(false);
|
m_gradientLabel->setEnabled(false);
|
||||||
ui->gradientLine->setEnabled(false);
|
m_gradientLine->setEnabled(false);
|
||||||
ui->colorColorButton->setColor(QLatin1String("invalidColor"));
|
m_colorColorButton->setColor(QLatin1String("invalidColor"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ui->gradientLine->setEnabled(false);
|
m_gradientLine->setEnabled(false);
|
||||||
ui->gradientLabel->setEnabled(false);
|
m_gradientLabel->setEnabled(false);
|
||||||
setColor();
|
setColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +147,7 @@ void ContextPaneWidgetRectangle::setProperties(QmlJS::PropertyReader *propertyRe
|
|||||||
m_gradientTimer = -1;
|
m_gradientTimer = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->colorGradient->setEnabled(isGradientEditingEnabled());
|
m_colorGradient->setEnabled(isGradientEditingEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextPaneWidgetRectangle::enabableGradientEditing(bool b)
|
void ContextPaneWidgetRectangle::enabableGradientEditing(bool b)
|
||||||
@@ -121,12 +158,12 @@ void ContextPaneWidgetRectangle::enabableGradientEditing(bool b)
|
|||||||
void ContextPaneWidgetRectangle::onBorderColorButtonToggled(bool flag)
|
void ContextPaneWidgetRectangle::onBorderColorButtonToggled(bool flag)
|
||||||
{
|
{
|
||||||
if (flag) {
|
if (flag) {
|
||||||
ui->colorColorButton->setChecked(false);
|
m_colorColorButton->setChecked(false);
|
||||||
m_gradientLineDoubleClicked = false;
|
m_gradientLineDoubleClicked = false;
|
||||||
}
|
}
|
||||||
ContextPaneWidget *parentContextWidget = qobject_cast<ContextPaneWidget*>(parentWidget());
|
ContextPaneWidget *parentContextWidget = qobject_cast<ContextPaneWidget*>(parentWidget());
|
||||||
QPoint p = mapToGlobal(ui->borderColorButton->pos());
|
QPoint p = mapToGlobal(m_borderColorButton->pos());
|
||||||
parentContextWidget->colorDialog()->setupColor(ui->borderColorButton->convertedColor());
|
parentContextWidget->colorDialog()->setupColor(m_borderColorButton->convertedColor());
|
||||||
p = parentContextWidget->colorDialog()->parentWidget()->mapFromGlobal(p);
|
p = parentContextWidget->colorDialog()->parentWidget()->mapFromGlobal(p);
|
||||||
parentContextWidget->onShowColorDialog(flag, p);
|
parentContextWidget->onShowColorDialog(flag, p);
|
||||||
}
|
}
|
||||||
@@ -134,12 +171,12 @@ void ContextPaneWidgetRectangle::onBorderColorButtonToggled(bool flag)
|
|||||||
void ContextPaneWidgetRectangle::onColorButtonToggled(bool flag )
|
void ContextPaneWidgetRectangle::onColorButtonToggled(bool flag )
|
||||||
{
|
{
|
||||||
if (flag) {
|
if (flag) {
|
||||||
ui->borderColorButton->setChecked(false);
|
m_borderColorButton->setChecked(false);
|
||||||
m_gradientLineDoubleClicked = false;
|
m_gradientLineDoubleClicked = false;
|
||||||
}
|
}
|
||||||
ContextPaneWidget *parentContextWidget = qobject_cast<ContextPaneWidget*>(parentWidget());
|
ContextPaneWidget *parentContextWidget = qobject_cast<ContextPaneWidget*>(parentWidget());
|
||||||
QPoint p = mapToGlobal(ui->colorColorButton->pos());
|
QPoint p = mapToGlobal(m_colorColorButton->pos());
|
||||||
parentContextWidget->colorDialog()->setupColor(ui->colorColorButton->convertedColor());
|
parentContextWidget->colorDialog()->setupColor(m_colorColorButton->convertedColor());
|
||||||
p = parentContextWidget->colorDialog()->parentWidget()->mapFromGlobal(p);
|
p = parentContextWidget->colorDialog()->parentWidget()->mapFromGlobal(p);
|
||||||
parentContextWidget->onShowColorDialog(flag, p);
|
parentContextWidget->onShowColorDialog(flag, p);
|
||||||
}
|
}
|
||||||
@@ -148,14 +185,14 @@ void ContextPaneWidgetRectangle::onColorDialogApplied(const QColor &)
|
|||||||
{
|
{
|
||||||
ContextPaneWidget *parentContextWidget = qobject_cast<ContextPaneWidget*>(parentWidget());
|
ContextPaneWidget *parentContextWidget = qobject_cast<ContextPaneWidget*>(parentWidget());
|
||||||
parentContextWidget->onShowColorDialog(false, QPoint());
|
parentContextWidget->onShowColorDialog(false, QPoint());
|
||||||
if (ui->colorColorButton->isChecked())
|
if (m_colorColorButton->isChecked())
|
||||||
emit propertyChanged(QLatin1String("color"),parentContextWidget->colorDialog()->color()); //write back color
|
emit propertyChanged(QLatin1String("color"),parentContextWidget->colorDialog()->color()); //write back color
|
||||||
if (ui->borderColorButton->isChecked())
|
if (m_borderColorButton->isChecked())
|
||||||
emit propertyChanged(QLatin1String("border.color"),parentContextWidget->colorDialog()->color()); //write back color
|
emit propertyChanged(QLatin1String("border.color"),parentContextWidget->colorDialog()->color()); //write back color
|
||||||
if (m_gradientLineDoubleClicked)
|
if (m_gradientLineDoubleClicked)
|
||||||
ui->gradientLine->setActiveColor(parentContextWidget->colorDialog()->color());
|
m_gradientLine->setActiveColor(parentContextWidget->colorDialog()->color());
|
||||||
ui->colorColorButton->setChecked(false);
|
m_colorColorButton->setChecked(false);
|
||||||
ui->borderColorButton->setChecked(false);
|
m_borderColorButton->setChecked(false);
|
||||||
m_gradientLineDoubleClicked = false;
|
m_gradientLineDoubleClicked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,48 +200,48 @@ void ContextPaneWidgetRectangle::onColorDialogCancled()
|
|||||||
{
|
{
|
||||||
ContextPaneWidget *parentContextWidget = qobject_cast<ContextPaneWidget*>(parentWidget());
|
ContextPaneWidget *parentContextWidget = qobject_cast<ContextPaneWidget*>(parentWidget());
|
||||||
parentContextWidget->onShowColorDialog(false, QPoint());
|
parentContextWidget->onShowColorDialog(false, QPoint());
|
||||||
ui->colorColorButton->setChecked(false);
|
m_colorColorButton->setChecked(false);
|
||||||
ui->borderColorButton->setChecked(false);
|
m_borderColorButton->setChecked(false);
|
||||||
m_gradientLineDoubleClicked = false;
|
m_gradientLineDoubleClicked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextPaneWidgetRectangle::onGradientClicked()
|
void ContextPaneWidgetRectangle::onGradientClicked()
|
||||||
{
|
{
|
||||||
if (ui->colorGradient->isChecked()) {
|
if (m_colorGradient->isChecked()) {
|
||||||
m_hasGradient = true;
|
m_hasGradient = true;
|
||||||
QLinearGradient gradient;
|
QLinearGradient gradient;
|
||||||
QGradientStops stops;
|
QGradientStops stops;
|
||||||
stops.append(QGradientStop(0, ui->colorColorButton->convertedColor()));
|
stops.append(QGradientStop(0, m_colorColorButton->convertedColor()));
|
||||||
stops.append(QGradientStop(1, Qt::white));
|
stops.append(QGradientStop(1, Qt::white));
|
||||||
gradient.setStops(stops);
|
gradient.setStops(stops);
|
||||||
ui->gradientLine->setEnabled(true);
|
m_gradientLine->setEnabled(true);
|
||||||
ui->gradientLine->setGradient(gradient);
|
m_gradientLine->setGradient(gradient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextPaneWidgetRectangle::onColorNoneClicked()
|
void ContextPaneWidgetRectangle::onColorNoneClicked()
|
||||||
{
|
{
|
||||||
if (ui->colorNone->isChecked()) {
|
if (m_colorNone->isChecked()) {
|
||||||
ui->colorGradient->setEnabled(isGradientEditingEnabled());
|
m_colorGradient->setEnabled(isGradientEditingEnabled());
|
||||||
emit removeAndChangeProperty(QLatin1String("gradient"), QLatin1String("color"),
|
emit removeAndChangeProperty(QLatin1String("gradient"), QLatin1String("color"),
|
||||||
QLatin1String("\"transparent\""), true);
|
QLatin1String("\"transparent\""), true);
|
||||||
}
|
}
|
||||||
ui->colorGradient->setEnabled(isGradientEditingEnabled());
|
m_colorGradient->setEnabled(isGradientEditingEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextPaneWidgetRectangle::onColorSolidClicked()
|
void ContextPaneWidgetRectangle::onColorSolidClicked()
|
||||||
{
|
{
|
||||||
if (ui->colorSolid->isChecked()) {
|
if (m_colorSolid->isChecked()) {
|
||||||
ui->gradientLine->setEnabled(false);
|
m_gradientLine->setEnabled(false);
|
||||||
emit removeAndChangeProperty(QLatin1String("gradient"), QLatin1String("color"),
|
emit removeAndChangeProperty(QLatin1String("gradient"), QLatin1String("color"),
|
||||||
QLatin1String("\"black\""), true);
|
QLatin1String("\"black\""), true);
|
||||||
}
|
}
|
||||||
ui->colorGradient->setEnabled(isGradientEditingEnabled());
|
m_colorGradient->setEnabled(isGradientEditingEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextPaneWidgetRectangle::onBorderNoneClicked()
|
void ContextPaneWidgetRectangle::onBorderNoneClicked()
|
||||||
{
|
{
|
||||||
if (ui->borderNone->isChecked()) {
|
if (m_borderNone->isChecked()) {
|
||||||
emit removeProperty(QLatin1String("border.color"));
|
emit removeProperty(QLatin1String("border.color"));
|
||||||
emit removeProperty(QLatin1String("border.width"));//###
|
emit removeProperty(QLatin1String("border.width"));//###
|
||||||
}
|
}
|
||||||
@@ -212,7 +249,7 @@ void ContextPaneWidgetRectangle::onBorderNoneClicked()
|
|||||||
|
|
||||||
void ContextPaneWidgetRectangle::onBorderSolidClicked()
|
void ContextPaneWidgetRectangle::onBorderSolidClicked()
|
||||||
{
|
{
|
||||||
if (ui->borderSolid->isChecked())
|
if (m_borderSolid->isChecked())
|
||||||
emit propertyChanged(QLatin1String("border.color"), QLatin1String("\"black\""));
|
emit propertyChanged(QLatin1String("border.color"), QLatin1String("\"black\""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,7 +258,7 @@ void ContextPaneWidgetRectangle::onGradientLineDoubleClicked(const QPoint &p)
|
|||||||
m_gradientLineDoubleClicked = true;
|
m_gradientLineDoubleClicked = true;
|
||||||
ContextPaneWidget *parentContextWidget = qobject_cast<ContextPaneWidget*>(parentWidget());
|
ContextPaneWidget *parentContextWidget = qobject_cast<ContextPaneWidget*>(parentWidget());
|
||||||
QPoint pos = mapToGlobal(p);
|
QPoint pos = mapToGlobal(p);
|
||||||
parentContextWidget->colorDialog()->setupColor(ui->gradientLine->activeColor());
|
parentContextWidget->colorDialog()->setupColor(m_gradientLine->activeColor());
|
||||||
pos = parentContextWidget->colorDialog()->parentWidget()->mapFromGlobal(pos);
|
pos = parentContextWidget->colorDialog()->parentWidget()->mapFromGlobal(pos);
|
||||||
parentContextWidget->onShowColorDialog(true, pos);
|
parentContextWidget->onShowColorDialog(true, pos);
|
||||||
}
|
}
|
||||||
@@ -239,7 +276,7 @@ void ContextPaneWidgetRectangle::timerEvent(QTimerEvent *event)
|
|||||||
killTimer(m_gradientTimer);
|
killTimer(m_gradientTimer);
|
||||||
m_gradientTimer = -1;
|
m_gradientTimer = -1;
|
||||||
|
|
||||||
QLinearGradient gradient = ui->gradientLine->gradient();
|
QLinearGradient gradient = m_gradientLine->gradient();
|
||||||
QString str = QLatin1String("Gradient {\n");
|
QString str = QLatin1String("Gradient {\n");
|
||||||
const QGradientStops stops = gradient.stops();
|
const QGradientStops stops = gradient.stops();
|
||||||
for (const QGradientStop &stop : stops) {
|
for (const QGradientStop &stop : stops) {
|
||||||
@@ -257,11 +294,11 @@ void ContextPaneWidgetRectangle::setColor()
|
|||||||
{
|
{
|
||||||
QLinearGradient gradient;
|
QLinearGradient gradient;
|
||||||
QGradientStops stops;
|
QGradientStops stops;
|
||||||
QColor color = ui->colorColorButton->convertedColor();
|
QColor color = m_colorColorButton->convertedColor();
|
||||||
stops.append(QGradientStop(0, color));
|
stops.append(QGradientStop(0, color));
|
||||||
stops.append(QGradientStop(1, color));
|
stops.append(QGradientStop(1, color));
|
||||||
gradient.setStops(stops);
|
gradient.setStops(stops);
|
||||||
ui->gradientLine->setGradient(gradient);
|
m_gradientLine->setGradient(gradient);
|
||||||
}
|
}
|
||||||
|
|
||||||
} //QmlDesigner
|
} //QmlDesigner
|
||||||
|
@@ -7,20 +7,24 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class ContextPaneWidgetRectangle; }
|
class QLabel;
|
||||||
|
class QToolButton;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace QmlJS { class PropertyReader; }
|
namespace QmlJS { class PropertyReader; }
|
||||||
|
|
||||||
namespace QmlEditorWidgets {
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
|
class ColorButton;
|
||||||
|
class GradientLine;
|
||||||
|
|
||||||
class QMLEDITORWIDGETS_EXPORT ContextPaneWidgetRectangle : public QWidget
|
class QMLEDITORWIDGETS_EXPORT ContextPaneWidgetRectangle : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ContextPaneWidgetRectangle(QWidget *parent = nullptr);
|
explicit ContextPaneWidgetRectangle(QWidget *parent = nullptr);
|
||||||
~ContextPaneWidgetRectangle();
|
|
||||||
void setProperties(QmlJS::PropertyReader *propertyReader);
|
void setProperties(QmlJS::PropertyReader *propertyReader);
|
||||||
void enabableGradientEditing(bool);
|
void enabableGradientEditing(bool);
|
||||||
|
|
||||||
@@ -48,7 +52,17 @@ private:
|
|||||||
void setColor();
|
void setColor();
|
||||||
bool isGradientEditingEnabled() const
|
bool isGradientEditingEnabled() const
|
||||||
{ return m_enableGradientEditing; }
|
{ return m_enableGradientEditing; }
|
||||||
Ui::ContextPaneWidgetRectangle *ui;
|
|
||||||
|
QLabel *m_gradientLabel;
|
||||||
|
GradientLine *m_gradientLine;
|
||||||
|
ColorButton *m_colorColorButton;
|
||||||
|
QToolButton *m_colorSolid;
|
||||||
|
QToolButton *m_colorGradient;
|
||||||
|
QToolButton *m_colorNone;
|
||||||
|
ColorButton *m_borderColorButton;
|
||||||
|
QToolButton *m_borderSolid;
|
||||||
|
QToolButton *m_borderNone;
|
||||||
|
|
||||||
bool m_hasBorder = false;
|
bool m_hasBorder = false;
|
||||||
bool m_hasGradient = false;
|
bool m_hasGradient = false;
|
||||||
bool m_none = false;
|
bool m_none = false;
|
||||||
|
@@ -1,314 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>ContextPaneWidgetRectangle</class>
|
|
||||||
<widget class="QWidget" name="ContextPaneWidgetRectangle">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>241</width>
|
|
||||||
<height>120</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>2</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>2</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>2</number>
|
|
||||||
</property>
|
|
||||||
<property name="horizontalSpacing">
|
|
||||||
<number>4</number>
|
|
||||||
</property>
|
|
||||||
<property name="verticalSpacing">
|
|
||||||
<number>2</number>
|
|
||||||
</property>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="gradientLabel">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Gradient</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignBottom|Qt::AlignRight|Qt::AlignTrailing</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1" colspan="5">
|
|
||||||
<widget class="QmlEditorWidgets::GradientLine" name="gradientLine" native="true">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>160</width>
|
|
||||||
<height>50</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>240</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Color</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="2">
|
|
||||||
<widget class="QmlEditorWidgets::ColorButton" name="colorColorButton">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>22</width>
|
|
||||||
<height>22</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>22</width>
|
|
||||||
<height>22</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>...</string>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="3" colspan="2">
|
|
||||||
<widget class="QWidget" name="widget_3" native="true">
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<property name="spacing">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="margin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="colorSolid">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>30</width>
|
|
||||||
<height>30</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="resources.qrc">
|
|
||||||
<normaloff>:/qmldesigner/images/icon_color_solid.png</normaloff>:/qmldesigner/images/icon_color_solid.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="autoExclusive">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="colorGradient">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>30</width>
|
|
||||||
<height>30</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="resources.qrc">
|
|
||||||
<normaloff>:/qmldesigner/images/icon_color_gradient.png</normaloff>:/qmldesigner/images/icon_color_gradient.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="autoExclusive">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="colorNone">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>30</width>
|
|
||||||
<height>30</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="resources.qrc">
|
|
||||||
<normaloff>:/qmldesigner/images/icon_color_none.png</normaloff>:/qmldesigner/images/icon_color_none.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="autoExclusive">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="5">
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>9</width>
|
|
||||||
<height>29</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QLabel" name="label_3">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Border</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="2">
|
|
||||||
<widget class="QmlEditorWidgets::ColorButton" name="borderColorButton">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>22</width>
|
|
||||||
<height>22</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>22</width>
|
|
||||||
<height>22</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>...</string>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="3">
|
|
||||||
<widget class="QWidget" name="widget_2" native="true">
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<property name="spacing">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="margin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="borderSolid">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>30</width>
|
|
||||||
<height>30</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="resources.qrc">
|
|
||||||
<normaloff>:/qmldesigner/images/icon_color_solid.png</normaloff>:/qmldesigner/images/icon_color_solid.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="autoExclusive">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="borderNone">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>30</width>
|
|
||||||
<height>30</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="resources.qrc">
|
|
||||||
<normaloff>:/qmldesigner/images/icon_color_none.png</normaloff>:/qmldesigner/images/icon_color_none.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="autoExclusive">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>QmlEditorWidgets::ColorButton</class>
|
|
||||||
<extends>QToolButton</extends>
|
|
||||||
<header location="global">qmleditorwidgets/colorbutton.h</header>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
|
||||||
<class>QmlEditorWidgets::GradientLine</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header location="global">qmleditorwidgets/gradientline.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources>
|
|
||||||
<include location="resources.qrc"/>
|
|
||||||
</resources>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
@@ -20,7 +20,7 @@ QtcLibrary {
|
|||||||
"contextpanetextwidget.cpp", "contextpanetextwidget.h",
|
"contextpanetextwidget.cpp", "contextpanetextwidget.h",
|
||||||
"contextpanewidget.cpp", "contextpanewidget.h",
|
"contextpanewidget.cpp", "contextpanewidget.h",
|
||||||
"contextpanewidgetimage.cpp", "contextpanewidgetimage.h",
|
"contextpanewidgetimage.cpp", "contextpanewidgetimage.h",
|
||||||
"contextpanewidgetrectangle.cpp", "contextpanewidgetrectangle.h", "contextpanewidgetrectangle.ui",
|
"contextpanewidgetrectangle.cpp", "contextpanewidgetrectangle.h",
|
||||||
"customcolordialog.cpp", "customcolordialog.h",
|
"customcolordialog.cpp", "customcolordialog.h",
|
||||||
"filewidget.cpp", "filewidget.h",
|
"filewidget.cpp", "filewidget.h",
|
||||||
"fontsizespinbox.cpp", "fontsizespinbox.h",
|
"fontsizespinbox.cpp", "fontsizespinbox.h",
|
||||||
|
Reference in New Issue
Block a user