mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Diagram editor : dock used to edit the shape item, can now edit several items in the same time
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5756 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -165,16 +165,14 @@ void DiagramPropertiesEditorDockWidget::selectionChanged()
|
||||
}
|
||||
case QetShapeItem::Type: //1008
|
||||
{
|
||||
if (count_ > 1)
|
||||
{
|
||||
clear();
|
||||
m_edited_qgi_type = -1;
|
||||
return;
|
||||
QList<QetShapeItem *> shapes_list;
|
||||
for (QGraphicsItem *qgi : m_diagram->selectedItems()) {
|
||||
shapes_list.append(static_cast<QetShapeItem*>(qgi));
|
||||
}
|
||||
|
||||
if (m_edited_qgi_type == type_)
|
||||
{
|
||||
static_cast<ShapeGraphicsItemPropertiesWidget*>(editors().first())->setItem(static_cast<QetShapeItem*>(item));
|
||||
static_cast<ShapeGraphicsItemPropertiesWidget*>(editors().first())->setItems(shapes_list);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
Copyright 2006-2019 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
@@ -36,6 +36,14 @@ ShapeGraphicsItemPropertiesWidget::ShapeGraphicsItemPropertiesWidget(QetShapeIte
|
||||
setItem(item);
|
||||
}
|
||||
|
||||
ShapeGraphicsItemPropertiesWidget::ShapeGraphicsItemPropertiesWidget(QList<QetShapeItem *> items_list, QWidget *parent) :
|
||||
PropertiesEditorWidget (parent),
|
||||
ui(new Ui::ShapeGraphicsItemPropertiesWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setItems(items_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ShapeGraphicsItemPropertiesWidget::~ShapeGraphicsItemPropertiesWidget
|
||||
* Destructor
|
||||
@@ -52,13 +60,16 @@ ShapeGraphicsItemPropertiesWidget::~ShapeGraphicsItemPropertiesWidget()
|
||||
*/
|
||||
void ShapeGraphicsItemPropertiesWidget::setItem(QetShapeItem *shape)
|
||||
{
|
||||
if (!shape || shape == m_shape) return;
|
||||
|
||||
if (m_shape && m_live_edit)
|
||||
if (m_shape != shape)
|
||||
{
|
||||
disconnect(m_shape, &QetShapeItem::penChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
||||
disconnect(m_shape, &QetShapeItem::brushChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
||||
disconnect(m_shape, &QetShapeItem::closeChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
||||
for (QMetaObject::Connection c : m_connect_list) {
|
||||
disconnect(c);
|
||||
}
|
||||
|
||||
m_connect_list.clear();
|
||||
}
|
||||
if (!shape) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_shape = shape;
|
||||
@@ -67,14 +78,46 @@ void ShapeGraphicsItemPropertiesWidget::setItem(QetShapeItem *shape)
|
||||
|
||||
if (m_live_edit)
|
||||
{
|
||||
connect(m_shape, &QetShapeItem::penChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
||||
connect(m_shape, &QetShapeItem::brushChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
||||
connect(m_shape, &QetShapeItem::closeChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
||||
m_connect_list << connect(m_shape, &QetShapeItem::penChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
||||
m_connect_list << connect(m_shape, &QetShapeItem::brushChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
||||
m_connect_list << connect(m_shape, &QetShapeItem::closeChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
||||
}
|
||||
|
||||
setUpEditConnection();
|
||||
updateUi();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ShapeGraphicsItemPropertiesWidget::setItems
|
||||
* Set a list of shapes to be edited
|
||||
* @param shapes_list
|
||||
*/
|
||||
void ShapeGraphicsItemPropertiesWidget::setItems(QList<QetShapeItem *> shapes_list)
|
||||
{
|
||||
for (QMetaObject::Connection c : m_connect_list) {
|
||||
disconnect(c);
|
||||
}
|
||||
m_connect_list.clear();
|
||||
m_shapes_list.clear();
|
||||
m_shape = nullptr;
|
||||
|
||||
if (shapes_list.size() == 0) {
|
||||
updateUi();
|
||||
}
|
||||
else if (shapes_list.size() == 1)
|
||||
{
|
||||
setItem(shapes_list.first());
|
||||
}
|
||||
else
|
||||
{
|
||||
for (QetShapeItem *shape : shapes_list) {
|
||||
m_shapes_list.append(QPointer<QetShapeItem>(shape));
|
||||
}
|
||||
updateUi();
|
||||
}
|
||||
setUpEditConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ShapeGraphicsItemPropertiesWidget::apply
|
||||
* Apply the current change, by pushing an undo command to the
|
||||
@@ -82,9 +125,29 @@ void ShapeGraphicsItemPropertiesWidget::setItem(QetShapeItem *shape)
|
||||
*/
|
||||
void ShapeGraphicsItemPropertiesWidget::apply()
|
||||
{
|
||||
if (m_shape->diagram())
|
||||
if (QUndoCommand *undo = associatedUndo())
|
||||
m_shape->diagram()->undoStack().push(undo);
|
||||
Diagram *d = nullptr;
|
||||
|
||||
if (m_shape && m_shape->diagram()) {
|
||||
d = m_shape->diagram();
|
||||
}
|
||||
else if (!m_shapes_list.isEmpty())
|
||||
{
|
||||
for (QPointer<QetShapeItem> qsi : m_shapes_list)
|
||||
{
|
||||
if (qsi->diagram()) {
|
||||
d = qsi->diagram();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (d)
|
||||
{
|
||||
QUndoCommand *undo = associatedUndo();
|
||||
if (undo) {
|
||||
d->undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,7 +166,13 @@ void ShapeGraphicsItemPropertiesWidget::reset() {
|
||||
*/
|
||||
QUndoCommand* ShapeGraphicsItemPropertiesWidget::associatedUndo() const
|
||||
{
|
||||
if (m_live_edit)
|
||||
{
|
||||
//One shape is edited
|
||||
if (m_shapes_list.isEmpty())
|
||||
{
|
||||
QPropertyUndoCommand *undo = nullptr;
|
||||
|
||||
QPen old_pen = m_shape->pen();
|
||||
QPen new_pen = old_pen;
|
||||
|
||||
@@ -151,6 +220,142 @@ QUndoCommand* ShapeGraphicsItemPropertiesWidget::associatedUndo() const
|
||||
}
|
||||
|
||||
return undo;
|
||||
}
|
||||
else if (!m_shapes_list.isEmpty()) //seberal shapes are edited
|
||||
{
|
||||
QUndoCommand *parent_undo = nullptr;
|
||||
QetShapeItem *shape_ = m_shapes_list.first().data();
|
||||
|
||||
//Pen
|
||||
QHash <QetShapeItem *, QPen> pen_H;
|
||||
|
||||
if (ui->m_style_cb->currentIndex() != -1 &&
|
||||
Qt::PenStyle(ui->m_style_cb->currentIndex() + 1) != shape_->pen().style())
|
||||
{
|
||||
for (QPointer<QetShapeItem> qsi : m_shapes_list)
|
||||
{
|
||||
QPen pen = qsi->pen();
|
||||
|
||||
if (ui->m_style_cb->currentIndex() ==5) {
|
||||
pen.setDashPattern( QVector<qreal>() << 10 << 10 );
|
||||
pen.setStyle( Qt::CustomDashLine );
|
||||
} else {
|
||||
pen.setStyle(Qt::PenStyle(ui->m_style_cb->currentIndex() + 1));
|
||||
}
|
||||
pen_H.insert(qsi, pen);
|
||||
}
|
||||
}
|
||||
|
||||
if (ui->m_size_dsb->value() > 0 &&
|
||||
ui->m_size_dsb->value() != shape_->pen().widthF())
|
||||
{
|
||||
for (QPointer<QetShapeItem> qsi : m_shapes_list)
|
||||
{
|
||||
QPen pen = pen_H.contains(qsi) ? pen_H.value(qsi) : qsi->pen();
|
||||
pen.setWidthF(ui->m_size_dsb->value());
|
||||
pen_H.insert(qsi, pen);
|
||||
}
|
||||
}
|
||||
|
||||
QColor c =ui->m_color_pb->palette().color(QPalette::Button);
|
||||
if (c != QPalette().color(QPalette::Button) && shape_->pen().color() != c)
|
||||
{
|
||||
for (QPointer<QetShapeItem> qsi : m_shapes_list)
|
||||
{
|
||||
QPen pen = pen_H.contains(qsi) ? pen_H.value(qsi) : qsi->pen();
|
||||
pen.setColor(c);
|
||||
pen_H.insert(qsi, pen);
|
||||
}
|
||||
}
|
||||
|
||||
for (QPointer<QetShapeItem> qsi : pen_H.keys())
|
||||
{
|
||||
if (!parent_undo) {
|
||||
parent_undo = new QUndoCommand(tr("Modifier une forme simple"));
|
||||
}
|
||||
new QPropertyUndoCommand(qsi, "pen", qsi->pen(), pen_H.value(qsi), parent_undo);
|
||||
}
|
||||
|
||||
//Brush
|
||||
QHash <QetShapeItem *, QBrush> brush_H;
|
||||
if (ui->m_brush_style_cb->currentIndex() != -1 &&
|
||||
shape_->brush().style() != Qt::BrushStyle(ui->m_brush_style_cb->currentIndex()))
|
||||
{
|
||||
for (QPointer<QetShapeItem> qsi : m_shapes_list)
|
||||
{
|
||||
QBrush brush = qsi->brush();
|
||||
brush.setStyle(Qt::BrushStyle(ui->m_brush_style_cb->currentIndex()));
|
||||
brush_H.insert(qsi, brush);
|
||||
}
|
||||
}
|
||||
|
||||
c = ui->m_brush_color_pb->palette().color(QPalette::Button);
|
||||
if (c != QPalette().color(QPalette::Button) && shape_->brush().color() != c)
|
||||
{
|
||||
for (QPointer<QetShapeItem> qsi : m_shapes_list)
|
||||
{
|
||||
QBrush brush = brush_H.contains(qsi) ? brush_H.value(qsi) : qsi->brush();
|
||||
brush.setColor(c);
|
||||
brush_H.insert(qsi, brush);
|
||||
}
|
||||
}
|
||||
|
||||
for (QPointer<QetShapeItem> qsi : brush_H.keys())
|
||||
{
|
||||
if (!parent_undo) {
|
||||
parent_undo = new QUndoCommand(tr("Modifier une forme simple"));
|
||||
}
|
||||
|
||||
new QPropertyUndoCommand(qsi, "brush", qsi->brush(), brush_H.value(qsi), parent_undo);
|
||||
}
|
||||
|
||||
return parent_undo;
|
||||
}
|
||||
}
|
||||
//In mode not live edit, only one shape can be edited
|
||||
else if (m_shapes_list.isEmpty())
|
||||
{
|
||||
QUndoCommand *undo = new QUndoCommand(tr("Modifier les propriétés d'une forme simple"));
|
||||
QPen old_pen = m_shape->pen();
|
||||
QPen new_pen = old_pen;
|
||||
|
||||
new_pen.setStyle(Qt::PenStyle(ui->m_style_cb->currentIndex() + 1));
|
||||
new_pen.setWidthF(ui->m_size_dsb->value());
|
||||
|
||||
if (ui->m_style_cb->currentIndex() ==5) {
|
||||
new_pen.setDashPattern( QVector<qreal>() << 10 << 10 );
|
||||
new_pen.setStyle( Qt::CustomDashLine );
|
||||
}
|
||||
//painter.setPen( new_pen );
|
||||
new_pen.setColor(ui->m_color_pb->palette().color(QPalette::Button));
|
||||
|
||||
if (new_pen != old_pen) {
|
||||
new QPropertyUndoCommand(m_shape, "pen", old_pen, new_pen, undo);
|
||||
}
|
||||
|
||||
QBrush old_brush = m_shape->brush();
|
||||
QBrush new_brush = old_brush;
|
||||
new_brush.setStyle(Qt::BrushStyle(ui->m_brush_style_cb->currentIndex()));
|
||||
new_brush.setColor(ui->m_brush_color_pb->palette().color(QPalette::Button));
|
||||
|
||||
if (new_brush != old_brush) {
|
||||
new QPropertyUndoCommand(m_shape, "brush", old_brush, new_brush, undo);
|
||||
}
|
||||
|
||||
if (ui->m_close_polygon->isChecked() != m_shape->isClosed()) {
|
||||
QPropertyUndoCommand(m_shape, "close", m_shape->isClosed(), ui->m_close_polygon->isChecked(), undo);
|
||||
}
|
||||
|
||||
if (undo->childCount()) {
|
||||
return undo;
|
||||
} else {
|
||||
delete undo;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,8 +363,19 @@ QUndoCommand* ShapeGraphicsItemPropertiesWidget::associatedUndo() const
|
||||
*/
|
||||
void ShapeGraphicsItemPropertiesWidget::updateUi()
|
||||
{
|
||||
bool le = m_live_edit;
|
||||
setLiveEdit(false); //Disable temporally live edit mode to avoid weird behavior
|
||||
if (!m_shape && m_shapes_list.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Disconnect every connections of editor widgets
|
||||
//to avoid an unwanted edition (QSpinBox emit valueChanged no matter if changer by user or by program)
|
||||
for (QMetaObject::Connection c : m_edit_connection) {
|
||||
disconnect(c);
|
||||
}
|
||||
m_edit_connection.clear();
|
||||
|
||||
if (m_shape)
|
||||
{
|
||||
//Pen
|
||||
ui->m_style_cb->setCurrentIndex(static_cast<int>(m_shape->pen().style()) - 1);
|
||||
ui->m_size_dsb ->setValue(m_shape->pen().widthF());
|
||||
@@ -174,7 +390,69 @@ void ShapeGraphicsItemPropertiesWidget::updateUi()
|
||||
|
||||
ui->m_lock_pos_cb->setChecked(!m_shape->isMovable());
|
||||
ui->m_close_polygon->setChecked(m_shape->isClosed());
|
||||
setLiveEdit(le);
|
||||
}
|
||||
else if (m_shapes_list.size() >= 2)
|
||||
{
|
||||
ui->m_close_polygon->setHidden(true);
|
||||
bool same = true;
|
||||
//Pen
|
||||
Qt::PenStyle ps = m_shapes_list.first()->pen().style();
|
||||
for (QetShapeItem *qsi : m_shapes_list) {
|
||||
if (qsi->pen().style() != ps) {
|
||||
same = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ui->m_style_cb->setCurrentIndex(same ? static_cast<int>(ps) - 1 : -1);
|
||||
|
||||
same = true;
|
||||
qreal pw = m_shapes_list.first()->pen().widthF();
|
||||
for (QetShapeItem *qsi : m_shapes_list) {
|
||||
if (qsi->pen().widthF() != pw) {
|
||||
same = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ui->m_size_dsb->setValue(same ? pw : 0);
|
||||
|
||||
same = true;
|
||||
QColor pc = m_shapes_list.first()->pen().color();
|
||||
for (QetShapeItem *qsi : m_shapes_list) {
|
||||
if (qsi->pen().color() != pc) {
|
||||
same = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
setPenColorButton(same ? pc : QColor());
|
||||
|
||||
//Brush
|
||||
ui->m_filling_gb->setVisible(true);
|
||||
|
||||
same = true;
|
||||
Qt::BrushStyle bs = m_shapes_list.first()->brush().style();
|
||||
for (QetShapeItem *qsi : m_shapes_list) {
|
||||
if (qsi->brush().style() != bs) {
|
||||
same = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ui->m_brush_style_cb->setCurrentIndex(same ? static_cast<int>(bs) : -1);
|
||||
|
||||
same = true;
|
||||
QColor bc = m_shapes_list.first()->brush().color();
|
||||
for (QetShapeItem *qsi : m_shapes_list) {
|
||||
if (qsi->brush().color() != bc) {
|
||||
same = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
setBrushColorButton(same ? bc : QColor());
|
||||
|
||||
ui->m_lock_pos_cb->setChecked(false);
|
||||
ui->m_close_polygon->setChecked(false);
|
||||
}
|
||||
|
||||
setUpEditConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,26 +462,20 @@ void ShapeGraphicsItemPropertiesWidget::updateUi()
|
||||
*/
|
||||
bool ShapeGraphicsItemPropertiesWidget::setLiveEdit(bool live_edit)
|
||||
{
|
||||
if (live_edit == m_live_edit) return true;
|
||||
if (live_edit == m_live_edit) {
|
||||
return true;
|
||||
}
|
||||
m_live_edit = live_edit;
|
||||
|
||||
if (m_live_edit)
|
||||
{
|
||||
connect (ui->m_style_cb, SIGNAL(activated(int)), this, SLOT(apply()));
|
||||
connect (ui->m_size_dsb, SIGNAL(valueChanged(double)), this, SLOT(apply()));
|
||||
connect (ui->m_brush_style_cb, SIGNAL(activated(int)), this, SLOT(apply()));
|
||||
connect (ui->m_close_polygon, &QCheckBox::clicked, this, &ShapeGraphicsItemPropertiesWidget::apply);
|
||||
connect (m_shape, &QetShapeItem::penChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
||||
connect (m_shape, &QetShapeItem::closeChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
||||
if (m_live_edit) {
|
||||
setUpEditConnection();
|
||||
}
|
||||
else
|
||||
{
|
||||
disconnect (ui->m_style_cb, SIGNAL(activated(int)), this, SLOT(apply()));
|
||||
disconnect (ui->m_size_dsb, SIGNAL(valueChanged(double)), this, SLOT(apply()));
|
||||
disconnect (ui->m_brush_style_cb, SIGNAL(activated(int)), this, SLOT(apply()));
|
||||
disconnect (ui->m_close_polygon, &QCheckBox::clicked, this, &ShapeGraphicsItemPropertiesWidget::apply);
|
||||
disconnect (m_shape, &QetShapeItem::penChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
||||
disconnect (m_shape, &QetShapeItem::closeChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
||||
for (QMetaObject::Connection c : m_edit_connection) {
|
||||
disconnect(c);
|
||||
}
|
||||
m_edit_connection.clear();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -215,9 +487,12 @@ bool ShapeGraphicsItemPropertiesWidget::setLiveEdit(bool live_edit)
|
||||
*/
|
||||
void ShapeGraphicsItemPropertiesWidget::setPenColorButton(const QColor &color)
|
||||
{
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::Button, color);
|
||||
ui -> m_color_pb -> setStyleSheet(QString("background-color: %1; min-height: 1.5em; border-style: outset; border-width: 2px; border-color: gray; border-radius: 4px;").arg(color.name()));
|
||||
if (!color.isValid()) {
|
||||
ui->m_color_pb->setStyleSheet("");
|
||||
return;
|
||||
}
|
||||
|
||||
ui->m_color_pb->setStyleSheet(QString("background-color : %1").arg(color.name()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -227,13 +502,46 @@ void ShapeGraphicsItemPropertiesWidget::setPenColorButton(const QColor &color)
|
||||
*/
|
||||
void ShapeGraphicsItemPropertiesWidget::setBrushColorButton(const QColor &color)
|
||||
{
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::Button, color);
|
||||
ui->m_brush_color_pb->setStyleSheet(QString("background-color: %1; min-height: 1.5em; border-style: outset; border-width: 2px; border-color: gray; border-radius: 4px;").arg(color.name()));
|
||||
if (!color.isValid()) {
|
||||
ui->m_brush_color_pb->setStyleSheet("");
|
||||
return;
|
||||
}
|
||||
|
||||
ui->m_brush_color_pb->setStyleSheet(QString("background-color : %1").arg(color.name()));
|
||||
}
|
||||
|
||||
void ShapeGraphicsItemPropertiesWidget::on_m_lock_pos_cb_clicked() {
|
||||
/**
|
||||
* @brief ShapeGraphicsItemPropertiesWidget::setUpEditConnection
|
||||
* Disconnect the previous connection, and reconnect the connection between the editors widgets and void ShapeGraphicsItemPropertiesWidget::apply function
|
||||
*/
|
||||
void ShapeGraphicsItemPropertiesWidget::setUpEditConnection()
|
||||
{
|
||||
for (QMetaObject::Connection c : m_edit_connection) {
|
||||
disconnect(c);
|
||||
}
|
||||
m_edit_connection.clear();
|
||||
|
||||
if (m_shape || !m_shapes_list.isEmpty())
|
||||
{
|
||||
m_edit_connection << connect (ui->m_style_cb, SIGNAL(activated(int)), this, SLOT(apply()));
|
||||
m_edit_connection << connect (ui->m_size_dsb, SIGNAL(valueChanged(double)), this, SLOT(apply()));
|
||||
m_edit_connection << connect (ui->m_brush_style_cb, SIGNAL(activated(int)), this, SLOT(apply()));
|
||||
m_edit_connection << connect (ui->m_close_polygon, &QCheckBox::clicked, this, &ShapeGraphicsItemPropertiesWidget::apply);
|
||||
m_edit_connection << connect (m_shape, &QetShapeItem::penChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
||||
m_edit_connection << connect (m_shape, &QetShapeItem::closeChanged, this, &ShapeGraphicsItemPropertiesWidget::updateUi);
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeGraphicsItemPropertiesWidget::on_m_lock_pos_cb_clicked()
|
||||
{
|
||||
if (m_shape) {
|
||||
m_shape->setMovable(!ui->m_lock_pos_cb->isChecked());
|
||||
}
|
||||
else if (!m_shapes_list.isEmpty()) {
|
||||
for (QPointer<QetShapeItem> qsi : m_shapes_list) {
|
||||
qsi->setMovable(!ui->m_lock_pos_cb->isChecked());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,11 +550,17 @@ void ShapeGraphicsItemPropertiesWidget::on_m_lock_pos_cb_clicked() {
|
||||
*/
|
||||
void ShapeGraphicsItemPropertiesWidget::on_m_color_pb_clicked()
|
||||
{
|
||||
QColor color = QColorDialog::getColor(m_shape->pen().color(), this);
|
||||
if (color.isValid())
|
||||
if (!m_shape && m_shapes_list.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
QetShapeItem *shape_ = m_shape ? m_shape : m_shapes_list.first().data();
|
||||
QColor color = QColorDialog::getColor(shape_->pen().color(), this);
|
||||
if (color.isValid()) {
|
||||
setPenColorButton(color);
|
||||
if (m_live_edit)
|
||||
}
|
||||
if (m_live_edit) {
|
||||
apply();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,11 +569,18 @@ void ShapeGraphicsItemPropertiesWidget::on_m_color_pb_clicked()
|
||||
*/
|
||||
void ShapeGraphicsItemPropertiesWidget::on_m_brush_color_pb_clicked()
|
||||
{
|
||||
QColor color = QColorDialog::getColor(m_shape->brush().color(), this);
|
||||
if (color.isValid())
|
||||
if (!m_shape && m_shapes_list.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
QetShapeItem *shape_ = m_shape ? m_shape : m_shapes_list.first().data();
|
||||
|
||||
QColor color = QColorDialog::getColor(shape_->brush().color(), this);
|
||||
if (color.isValid()) {
|
||||
setBrushColorButton(color);
|
||||
if (m_live_edit)
|
||||
}
|
||||
if (m_live_edit) {
|
||||
apply();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,9 +36,11 @@ class ShapeGraphicsItemPropertiesWidget : public PropertiesEditorWidget
|
||||
|
||||
public:
|
||||
explicit ShapeGraphicsItemPropertiesWidget(QetShapeItem *item, QWidget *parent = nullptr);
|
||||
ShapeGraphicsItemPropertiesWidget(QList<QetShapeItem *> items_list, QWidget *parent =nullptr);
|
||||
~ShapeGraphicsItemPropertiesWidget() override;
|
||||
|
||||
void setItem(QetShapeItem *shape);
|
||||
void setItems(QList<QetShapeItem *> shapes_list);
|
||||
|
||||
public slots:
|
||||
void apply() override;
|
||||
@@ -52,6 +54,7 @@ class ShapeGraphicsItemPropertiesWidget : public PropertiesEditorWidget
|
||||
private:
|
||||
void setPenColorButton(const QColor &color);
|
||||
void setBrushColorButton(const QColor &color);
|
||||
void setUpEditConnection();
|
||||
|
||||
private slots:
|
||||
void on_m_lock_pos_cb_clicked();
|
||||
@@ -63,6 +66,9 @@ class ShapeGraphicsItemPropertiesWidget : public PropertiesEditorWidget
|
||||
private:
|
||||
Ui::ShapeGraphicsItemPropertiesWidget *ui;
|
||||
QetShapeItem *m_shape;
|
||||
QList <QPointer<QetShapeItem>> m_shapes_list;
|
||||
QList <QMetaObject::Connection> m_connect_list,
|
||||
m_edit_connection;
|
||||
};
|
||||
|
||||
#endif // SHAPEGRAPHICSITEMPROPERTIESWIDGET_H
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>261</width>
|
||||
<height>346</height>
|
||||
<width>245</width>
|
||||
<height>311</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
||||
Reference in New Issue
Block a user