version 2.17.0
iconedlabel icon size scale in auto scale mode BlockItem decors visibility logic flags
This commit is contained in:
@@ -3,8 +3,8 @@ cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
|||||||
cmake_policy(SET CMP0072 NEW) # FindOpenGL prefers GLVND by default
|
cmake_policy(SET CMP0072 NEW) # FindOpenGL prefers GLVND by default
|
||||||
project(QAD)
|
project(QAD)
|
||||||
set(QAD_MAJOR 2)
|
set(QAD_MAJOR 2)
|
||||||
set(QAD_MINOR 16)
|
set(QAD_MINOR 17)
|
||||||
set(QAD_REVISION 3)
|
set(QAD_REVISION 0)
|
||||||
set(QAD_SUFFIX )
|
set(QAD_SUFFIX )
|
||||||
set(QAD_COMPANY SHS)
|
set(QAD_COMPANY SHS)
|
||||||
set(QAD_DOMAIN org.SHS)
|
set(QAD_DOMAIN org.SHS)
|
||||||
|
|||||||
@@ -48,8 +48,19 @@ enum BlockviewItemData {
|
|||||||
bvidBlockDecor, // bool item is BlockItem decor
|
bvidBlockDecor, // bool item is BlockItem decor
|
||||||
bvidDTHandle, // bool
|
bvidDTHandle, // bool
|
||||||
bvidCorrectMove, // bool
|
bvidCorrectMove, // bool
|
||||||
|
bvidDecorShowLogic, // uint
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum BlockviewDecorShowLogic {
|
||||||
|
bvdslAlways = 0x0,
|
||||||
|
bvdslEnabled = 0x1,
|
||||||
|
bvdslHovered = 0x2,
|
||||||
|
bvdslSelected = 0x4,
|
||||||
|
bvdslInverse = 0x8,
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_FLAGS(BlockviewDecorShowLogics, BlockviewDecorShowLogic)
|
||||||
|
|
||||||
enum BlockviewItemType {
|
enum BlockviewItemType {
|
||||||
bvitInvalid,
|
bvitInvalid,
|
||||||
bvitPin,
|
bvitPin,
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ BlockEditor::BlockEditor(QWidget * parent): QWidget(parent), ui(new Ui::BlockEdi
|
|||||||
src_title = windowTitle();
|
src_title = windowTitle();
|
||||||
connect(ui->blockView->scene(), SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
|
connect(ui->blockView->scene(), SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
|
||||||
block.setFlags(QGraphicsItem::GraphicsItemFlags());
|
block.setFlags(QGraphicsItem::GraphicsItemFlags());
|
||||||
|
block.is_blockeditor = true;
|
||||||
ui->blockView->addItem(&block);
|
ui->blockView->addItem(&block);
|
||||||
ui->blockView->viewport()->installEventFilter(this);
|
ui->blockView->viewport()->installEventFilter(this);
|
||||||
DrawTools * drawtools = new DrawTools(ui->blockView);
|
DrawTools * drawtools = new DrawTools(ui->blockView);
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ void BlockItem::removePin(BlockItemPin * pin) {
|
|||||||
|
|
||||||
|
|
||||||
void BlockItem::addDecor(QGraphicsItem * item) {
|
void BlockItem::addDecor(QGraphicsItem * item) {
|
||||||
|
if (!item) return;
|
||||||
if (decors_.contains(item)) return;
|
if (decors_.contains(item)) return;
|
||||||
if (qgraphicsitem_cast<QGraphicsPixmapItem *>(item))
|
if (qgraphicsitem_cast<QGraphicsPixmapItem *>(item))
|
||||||
qgraphicsitem_cast<QGraphicsPixmapItem *>(item)->setTransformationMode(Qt::SmoothTransformation);
|
qgraphicsitem_cast<QGraphicsPixmapItem *>(item)->setTransformationMode(Qt::SmoothTransformation);
|
||||||
@@ -179,9 +180,19 @@ QVector<BlockItemPin *> BlockItem::pinsOnSide(Qt::Alignment al) const {
|
|||||||
|
|
||||||
|
|
||||||
QByteArray BlockItem::saveModel() {
|
QByteArray BlockItem::saveModel() {
|
||||||
|
QVector<uint32_t> decor_vis_flags;
|
||||||
|
for (auto i: decors_)
|
||||||
|
decor_vis_flags << i->data(bvidDecorShowLogic).toUInt();
|
||||||
ChunkStream cs;
|
ChunkStream cs;
|
||||||
cs << cs.chunk(1, pos()) << cs.chunk(2, rotation()) << cs.chunk(3, size()) << cs.chunk(4, color()) << cs.chunk(5, pins())
|
cs.add(1, pos())
|
||||||
<< cs.chunk(6, decors_) << cs.chunk(7, pins_margin) << cs.chunk(0xFF, _blockitem_current_version_);
|
.add(2, rotation())
|
||||||
|
.add(3, size())
|
||||||
|
.add(4, color())
|
||||||
|
.add(5, pins())
|
||||||
|
.add(6, decors_)
|
||||||
|
.add(7, pins_margin)
|
||||||
|
.add(8, decor_vis_flags)
|
||||||
|
.add(0xFF, _blockitem_current_version_);
|
||||||
return cs.data();
|
return cs.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,6 +207,7 @@ void BlockItem::loadModel(const QByteArray & data) {
|
|||||||
ChunkStream cs(data);
|
ChunkStream cs(data);
|
||||||
QVector<BlockItemPin *> tp;
|
QVector<BlockItemPin *> tp;
|
||||||
QList<QGraphicsItem *> dl;
|
QList<QGraphicsItem *> dl;
|
||||||
|
QVector<uint32_t> decor_vis_flags;
|
||||||
int version = -1;
|
int version = -1;
|
||||||
while (!cs.atEnd()) {
|
while (!cs.atEnd()) {
|
||||||
switch (cs.read()) {
|
switch (cs.read()) {
|
||||||
@@ -214,10 +226,14 @@ void BlockItem::loadModel(const QByteArray & data) {
|
|||||||
addDecor(d);
|
addDecor(d);
|
||||||
break;
|
break;
|
||||||
case 7: setPinsMargin(cs.getData<int>()); break;
|
case 7: setPinsMargin(cs.getData<int>()); break;
|
||||||
|
case 8: cs.get(decor_vis_flags); break;
|
||||||
case 0xFF: cs.get(version); break;
|
case 0xFF: cs.get(version); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < qMin(decors_.size(), decor_vis_flags.size()); ++i)
|
||||||
|
decors_[i]->setData(bvidDecorShowLogic, decor_vis_flags[i]);
|
||||||
if (version <= 0) _moveToTop(true);
|
if (version <= 0) _moveToTop(true);
|
||||||
|
procDecorShowLogic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -228,9 +244,8 @@ QByteArray BlockItem::save() const {
|
|||||||
// qDebug() << "save pin" << p->text() << "->" << p->properties().size();
|
// qDebug() << "save pin" << p->text() << "->" << p->properties().size();
|
||||||
pp[p->text()] = p->properties();
|
pp[p->text()] = p->properties();
|
||||||
}
|
}
|
||||||
cs << cs.chunk(1, pos()) << cs.chunk(2, rotation()) << cs.chunk(3, props) << cs.chunk(5, pp) << cs.chunk(6, size());
|
cs.add(1, pos()).add(2, rotation()).add(3, props).add(5, pp).add(6, size());
|
||||||
cs << cs.chunk(10, data(2000)) << cs.chunk(11, data(2001)) << cs.chunk(12, prop_bindings)
|
cs.add(10, data(2000)).add(11, data(2001)).add(12, prop_bindings).add(0xFF, _blockitem_current_version_);
|
||||||
<< cs.chunk(0xFF, _blockitem_current_version_);
|
|
||||||
return cs.data();
|
return cs.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,16 +299,10 @@ BlockItem * BlockItem::copy() const {
|
|||||||
np->properties() = p->properties();
|
np->properties() = p->properties();
|
||||||
ret->addPin(np);
|
ret->addPin(np);
|
||||||
}
|
}
|
||||||
QByteArray ba;
|
for (auto i: decors_) {
|
||||||
foreach(QGraphicsItem * i, decors_) {
|
ret->addDecor(qDeserialize<QGraphicsItem *>(qSerialize(i)));
|
||||||
ba.clear();
|
|
||||||
QGraphicsItem * ni = 0;
|
|
||||||
QDataStream s(&ba, QIODevice::ReadWrite);
|
|
||||||
s << i;
|
|
||||||
QDataStream s2(ba);
|
|
||||||
s2 >> ni;
|
|
||||||
if (ni) ret->addDecor(ni);
|
|
||||||
}
|
}
|
||||||
|
ret->procDecorShowLogic();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,27 +341,13 @@ QRectF BlockItem::boundingRect() const {
|
|||||||
|
|
||||||
|
|
||||||
void BlockItem::hoverEnterEvent(QGraphicsSceneHoverEvent * e) {
|
void BlockItem::hoverEnterEvent(QGraphicsSceneHoverEvent * e) {
|
||||||
bool anim = ((BlockView *)scene()->views().back())->isBlockAnimationEnabled();
|
setHovered(true);
|
||||||
if (anim) {
|
|
||||||
anim_thick.stop();
|
|
||||||
anim_thick.setStartValue(thickness());
|
|
||||||
anim_thick.setEndValue(2.5);
|
|
||||||
anim_thick.start();
|
|
||||||
} else
|
|
||||||
setThickness(2.5);
|
|
||||||
emit blockHoverEnter(this);
|
emit blockHoverEnter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BlockItem::hoverLeaveEvent(QGraphicsSceneHoverEvent * e) {
|
void BlockItem::hoverLeaveEvent(QGraphicsSceneHoverEvent * e) {
|
||||||
bool anim = ((BlockView *)scene()->views().back())->isBlockAnimationEnabled();
|
setHovered(false);
|
||||||
if (anim) {
|
|
||||||
anim_thick.stop();
|
|
||||||
anim_thick.setStartValue(thickness());
|
|
||||||
anim_thick.setEndValue(1);
|
|
||||||
anim_thick.start();
|
|
||||||
} else
|
|
||||||
setThickness(1);
|
|
||||||
emit blockHoverLeave(this);
|
emit blockHoverLeave(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -463,7 +458,7 @@ QStringList BlockItem::getBindProps() const {
|
|||||||
|
|
||||||
QVariant BlockItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant & value) {
|
QVariant BlockItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant & value) {
|
||||||
if (change == QGraphicsItem::ItemSelectedChange) {
|
if (change == QGraphicsItem::ItemSelectedChange) {
|
||||||
// qDebug() << "select" << value.toBool();
|
// qDebug() << "select" << value.toBool();
|
||||||
if (value.toBool() && !isSelected() && ((BlockView *)scene()->views().back())->isBlockAnimationEnabled() && t_sel.elapsed() > 50) {
|
if (value.toBool() && !isSelected() && ((BlockView *)scene()->views().back())->isBlockAnimationEnabled() && t_sel.elapsed() > 50) {
|
||||||
g_selection.setRect(enlargedRect(g_main.rect(), 0, 0, 16));
|
g_selection.setRect(enlargedRect(g_main.rect(), 0, 0, 16));
|
||||||
anim_sel.setStartValue(selectionRect());
|
anim_sel.setStartValue(selectionRect());
|
||||||
@@ -473,7 +468,40 @@ QVariant BlockItem::itemChange(QGraphicsItem::GraphicsItemChange change, const Q
|
|||||||
t_sel.restart();
|
t_sel.restart();
|
||||||
g_selection.setVisible(value.toBool());
|
g_selection.setVisible(value.toBool());
|
||||||
}
|
}
|
||||||
return QGraphicsItem::itemChange(change, value);
|
auto ret = QGraphicsItem::itemChange(change, value);
|
||||||
|
if (change == QGraphicsItem::ItemSelectedChange) procDecorShowLogic();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BlockItem::setHovered(bool yes) {
|
||||||
|
is_hovered = yes;
|
||||||
|
double thick = yes ? 2.5 : 1.;
|
||||||
|
if (((BlockView *)scene()->views().back())->isBlockAnimationEnabled()) {
|
||||||
|
anim_thick.stop();
|
||||||
|
anim_thick.setStartValue(thickness());
|
||||||
|
anim_thick.setEndValue(thick);
|
||||||
|
anim_thick.start();
|
||||||
|
} else
|
||||||
|
setThickness(thick);
|
||||||
|
procDecorShowLogic();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BlockItem::procDecorShowLogic() {
|
||||||
|
if (is_blockeditor) return;
|
||||||
|
bool is_selected = g_selection.isVisible();
|
||||||
|
// qDebug() << "procDecorShowLogic" << is_selected << is_hovered;
|
||||||
|
for (auto i: decors_) {
|
||||||
|
BlockviewDecorShowLogics slf(i->data(bvidDecorShowLogic).toUInt());
|
||||||
|
if (slf == bvdslAlways) continue;
|
||||||
|
bool vis = false;
|
||||||
|
if (isEnabled() && slf.testFlag(bvdslEnabled)) vis = true;
|
||||||
|
if (is_hovered && slf.testFlag(bvdslHovered)) vis = true;
|
||||||
|
if (is_selected && slf.testFlag(bvdslSelected)) vis = true;
|
||||||
|
if (slf.testFlag(bvdslInverse)) vis = !vis;
|
||||||
|
i->setVisible(vis);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class QAD_BLOCKVIEW_EXPORT BlockItem
|
|||||||
friend class BlockView;
|
friend class BlockView;
|
||||||
friend class BlockItemPin;
|
friend class BlockItemPin;
|
||||||
friend class DrawTools;
|
friend class DrawTools;
|
||||||
|
friend class BlockEditor;
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(double _thickness READ thickness WRITE setThickness DESIGNABLE false SCRIPTABLE false)
|
Q_PROPERTY(double _thickness READ thickness WRITE setThickness DESIGNABLE false SCRIPTABLE false)
|
||||||
Q_PROPERTY(QRectF _selRect READ selectionRect WRITE setSelectionRect DESIGNABLE false SCRIPTABLE false)
|
Q_PROPERTY(QRectF _selRect READ selectionRect WRITE setSelectionRect DESIGNABLE false SCRIPTABLE false)
|
||||||
@@ -109,6 +110,8 @@ protected:
|
|||||||
double bottom() const { return boundingRect().bottom(); }
|
double bottom() const { return boundingRect().bottom(); }
|
||||||
void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = nullptr) {}
|
void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = nullptr) {}
|
||||||
QVariant itemChange(GraphicsItemChange change, const QVariant & value);
|
QVariant itemChange(GraphicsItemChange change, const QVariant & value);
|
||||||
|
void setHovered(bool yes);
|
||||||
|
void procDecorShowLogic();
|
||||||
|
|
||||||
QGraphicsRectItem g_main, g_selection;
|
QGraphicsRectItem g_main, g_selection;
|
||||||
int pins_margin;
|
int pins_margin;
|
||||||
@@ -125,6 +128,7 @@ private:
|
|||||||
|
|
||||||
QPropertyAnimation anim_thick, anim_sel;
|
QPropertyAnimation anim_thick, anim_sel;
|
||||||
QElapsedTimer t_sel;
|
QElapsedTimer t_sel;
|
||||||
|
bool is_hovered = false, is_blockeditor = false;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void blockHoverEnter(BlockItem * b);
|
void blockHoverEnter(BlockItem * b);
|
||||||
|
|||||||
@@ -250,10 +250,8 @@ DrawTools::DrawTools(BlockView * parent)
|
|||||||
widget_props = new QWidget();
|
widget_props = new QWidget();
|
||||||
ui = new Ui::DrawTools();
|
ui = new Ui::DrawTools();
|
||||||
ui->setupUi(widget_props);
|
ui->setupUi(widget_props);
|
||||||
ui->labelPen->setMinimumSize(preferredIconSize(1.5, widget_props));
|
ui->labelPen->setIconSizeAutoScale(1.5);
|
||||||
ui->labelPen->setMaximumSize(ui->labelPen->minimumSize());
|
ui->labelBrush->setIconSizeAutoScale(1.5);
|
||||||
ui->labelBrush->setMinimumSize(ui->labelPen->minimumSize());
|
|
||||||
ui->labelBrush->setMaximumSize(ui->labelBrush->minimumSize());
|
|
||||||
widget_props->setEnabled(false);
|
widget_props->setEnabled(false);
|
||||||
int fh = qMax<int>(fontHeight(this), 22);
|
int fh = qMax<int>(fontHeight(this), 22);
|
||||||
int thick = lineThickness(this);
|
int thick = lineThickness(this);
|
||||||
@@ -331,6 +329,11 @@ DrawTools::DrawTools(BlockView * parent)
|
|||||||
connect(ui->actionLeft, SIGNAL(triggered(bool)), this, SLOT(actionLeft_triggered(bool)));
|
connect(ui->actionLeft, SIGNAL(triggered(bool)), this, SLOT(actionLeft_triggered(bool)));
|
||||||
connect(ui->actionHCenter, SIGNAL(triggered(bool)), this, SLOT(actionHCenter_triggered(bool)));
|
connect(ui->actionHCenter, SIGNAL(triggered(bool)), this, SLOT(actionHCenter_triggered(bool)));
|
||||||
connect(ui->actionRight, SIGNAL(triggered(bool)), this, SLOT(actionRight_triggered(bool)));
|
connect(ui->actionRight, SIGNAL(triggered(bool)), this, SLOT(actionRight_triggered(bool)));
|
||||||
|
connect(ui->groupShowLogic, SIGNAL(toggled(bool)), this, SLOT(decorVisibleLogicChanged()));
|
||||||
|
connect(ui->checkVLEnabled, SIGNAL(toggled(bool)), this, SLOT(decorVisibleLogicChanged()));
|
||||||
|
connect(ui->checkVLHovered, SIGNAL(toggled(bool)), this, SLOT(decorVisibleLogicChanged()));
|
||||||
|
connect(ui->checkVLSelected, SIGNAL(toggled(bool)), this, SLOT(decorVisibleLogicChanged()));
|
||||||
|
connect(ui->checkVLInverse, SIGNAL(toggled(bool)), this, SLOT(decorVisibleLogicChanged()));
|
||||||
connect(&font_dlg, SIGNAL(currentFontChanged(QFont)), this, SLOT(propertyChanged()));
|
connect(&font_dlg, SIGNAL(currentFontChanged(QFont)), this, SLOT(propertyChanged()));
|
||||||
connect(&size_item, SIGNAL(sizeChanged()), this, SLOT(sizeChanged()));
|
connect(&size_item, SIGNAL(sizeChanged()), this, SLOT(sizeChanged()));
|
||||||
connect(&size_item, SIGNAL(textEditRequest()), this, SLOT(buttonTextEdit_clicked()));
|
connect(&size_item, SIGNAL(textEditRequest()), this, SLOT(buttonTextEdit_clicked()));
|
||||||
@@ -573,9 +576,13 @@ void DrawTools::blockPropSignals(bool block_) {
|
|||||||
ui->actionHCenter->blockSignals(block_);
|
ui->actionHCenter->blockSignals(block_);
|
||||||
ui->actionLeft->blockSignals(block_);
|
ui->actionLeft->blockSignals(block_);
|
||||||
ui->actionRight->blockSignals(block_);
|
ui->actionRight->blockSignals(block_);
|
||||||
foreach(QToolButton * b, buttons_align) {
|
for (auto * b: buttons_align)
|
||||||
b->blockSignals(block_);
|
b->blockSignals(block_);
|
||||||
}
|
ui->groupShowLogic->blockSignals(block_);
|
||||||
|
ui->checkVLEnabled->blockSignals(block_);
|
||||||
|
ui->checkVLHovered->blockSignals(block_);
|
||||||
|
ui->checkVLSelected->blockSignals(block_);
|
||||||
|
ui->checkVLInverse->blockSignals(block_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -643,8 +650,9 @@ void DrawTools::selectionChanged() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
widget_props->setEnabled(true);
|
widget_props->setEnabled(true);
|
||||||
cur_item = sil[0];
|
if (!sil.isEmpty()) cur_item = sil[0];
|
||||||
if (!cur_item) {
|
if (!cur_item) {
|
||||||
|
ui->groupShowLogic->setEnabled(false);
|
||||||
emitZAvailabe();
|
emitZAvailabe();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -654,8 +662,10 @@ void DrawTools::selectionChanged() {
|
|||||||
QGraphicsRectItem * irect = qgraphicsitem_cast<QGraphicsRectItem *>(cur_item);
|
QGraphicsRectItem * irect = qgraphicsitem_cast<QGraphicsRectItem *>(cur_item);
|
||||||
QGraphicsEllipseItem * iell = qgraphicsitem_cast<QGraphicsEllipseItem *>(cur_item);
|
QGraphicsEllipseItem * iell = qgraphicsitem_cast<QGraphicsEllipseItem *>(cur_item);
|
||||||
QGraphicsLineItem * iline = qgraphicsitem_cast<QGraphicsLineItem *>(cur_item);
|
QGraphicsLineItem * iline = qgraphicsitem_cast<QGraphicsLineItem *>(cur_item);
|
||||||
|
bool is_decor = false;
|
||||||
blockPropSignals(true);
|
blockPropSignals(true);
|
||||||
if (itext) {
|
if (itext) {
|
||||||
|
is_decor = true;
|
||||||
ui->stackedProperties->setCurrentIndex(0);
|
ui->stackedProperties->setCurrentIndex(0);
|
||||||
ui->comboText->setEditText(itext->text());
|
ui->comboText->setEditText(itext->text());
|
||||||
ui->colorButtonPen->setColor(itext->brush().color());
|
ui->colorButtonPen->setColor(itext->brush().color());
|
||||||
@@ -667,6 +677,7 @@ void DrawTools::selectionChanged() {
|
|||||||
ui->widgetAlign9->setEnabled(false);
|
ui->widgetAlign9->setEnabled(false);
|
||||||
size_item.assignObject(itext);
|
size_item.assignObject(itext);
|
||||||
} else if (iatext) {
|
} else if (iatext) {
|
||||||
|
is_decor = true;
|
||||||
ui->stackedProperties->setCurrentIndex(0);
|
ui->stackedProperties->setCurrentIndex(0);
|
||||||
ui->comboText->setEditText(iatext->text());
|
ui->comboText->setEditText(iatext->text());
|
||||||
ui->colorButtonPen->setColor(iatext->brush().color());
|
ui->colorButtonPen->setColor(iatext->brush().color());
|
||||||
@@ -717,11 +728,13 @@ void DrawTools::selectionChanged() {
|
|||||||
ui->widgetAlign9->setEnabled(true);
|
ui->widgetAlign9->setEnabled(true);
|
||||||
size_item.assignObject(iatext);
|
size_item.assignObject(iatext);
|
||||||
} else if (ipixmap) {
|
} else if (ipixmap) {
|
||||||
|
is_decor = true;
|
||||||
ui->stackedProperties->setCurrentIndex(2);
|
ui->stackedProperties->setCurrentIndex(2);
|
||||||
ui->spinScale->setValue(sqrt(ipixmap->transform().determinant()));
|
ui->spinScale->setValue(sqrt(ipixmap->transform().determinant()));
|
||||||
setToolButtonsEnabled(false, false, false);
|
setToolButtonsEnabled(false, false, false);
|
||||||
size_item.assignObject(ipixmap);
|
size_item.assignObject(ipixmap);
|
||||||
} else if (irect || iell) {
|
} else if (irect || iell) {
|
||||||
|
is_decor = true;
|
||||||
ui->stackedProperties->setCurrentIndex(1);
|
ui->stackedProperties->setCurrentIndex(1);
|
||||||
QAbstractGraphicsShapeItem * ishape = nullptr;
|
QAbstractGraphicsShapeItem * ishape = nullptr;
|
||||||
if (irect) {
|
if (irect) {
|
||||||
@@ -743,6 +756,7 @@ void DrawTools::selectionChanged() {
|
|||||||
if (resize_enabled) size_item.assignObject(ishape);
|
if (resize_enabled) size_item.assignObject(ishape);
|
||||||
}
|
}
|
||||||
} else if (iline) {
|
} else if (iline) {
|
||||||
|
is_decor = true;
|
||||||
ui->stackedProperties->setCurrentIndex(1);
|
ui->stackedProperties->setCurrentIndex(1);
|
||||||
ui->colorButtonPen->setColor(iline->pen().color());
|
ui->colorButtonPen->setColor(iline->pen().color());
|
||||||
ui->spinThick->setValue(iline->pen().widthF());
|
ui->spinThick->setValue(iline->pen().widthF());
|
||||||
@@ -753,6 +767,15 @@ void DrawTools::selectionChanged() {
|
|||||||
ui->stackedProperties->setCurrentIndex(3);
|
ui->stackedProperties->setCurrentIndex(3);
|
||||||
widget_props->setEnabled(false);
|
widget_props->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
ui->groupShowLogic->setEnabled(is_decor);
|
||||||
|
if (is_decor) {
|
||||||
|
BlockviewDecorShowLogics slf(cur_item->data(bvidDecorShowLogic).toUInt());
|
||||||
|
ui->groupShowLogic->setChecked(slf != bvdslAlways);
|
||||||
|
ui->checkVLEnabled->setChecked(slf.testFlag(bvdslEnabled));
|
||||||
|
ui->checkVLHovered->setChecked(slf.testFlag(bvdslHovered));
|
||||||
|
ui->checkVLSelected->setChecked(slf.testFlag(bvdslSelected));
|
||||||
|
ui->checkVLInverse->setChecked(slf.testFlag(bvdslInverse));
|
||||||
|
}
|
||||||
emitZAvailabe(cur_item);
|
emitZAvailabe(cur_item);
|
||||||
blockPropSignals(false);
|
blockPropSignals(false);
|
||||||
}
|
}
|
||||||
@@ -855,6 +878,19 @@ void DrawTools::comboLineStyleChanged() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DrawTools::decorVisibleLogicChanged() {
|
||||||
|
if (!cur_item) return;
|
||||||
|
uint f = 0;
|
||||||
|
if (ui->groupShowLogic->isChecked()) {
|
||||||
|
if (ui->checkVLEnabled->isChecked()) f |= bvdslEnabled;
|
||||||
|
if (ui->checkVLHovered->isChecked()) f |= bvdslHovered;
|
||||||
|
if (ui->checkVLSelected->isChecked()) f |= bvdslSelected;
|
||||||
|
if (ui->checkVLInverse->isChecked()) f |= bvdslInverse;
|
||||||
|
}
|
||||||
|
cur_item->setData(bvidDecorShowLogic, f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DrawTools::buttonImage_clicked() {
|
void DrawTools::buttonImage_clicked() {
|
||||||
QGraphicsPixmapItem * pi = qgraphicsitem_cast<QGraphicsPixmapItem *>(cur_item);
|
QGraphicsPixmapItem * pi = qgraphicsitem_cast<QGraphicsPixmapItem *>(cur_item);
|
||||||
if (!pi) return;
|
if (!pi) return;
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ private slots:
|
|||||||
actions_Z_down.setEnabled(yes);
|
actions_Z_down.setEnabled(yes);
|
||||||
actions_Z_bottom.setEnabled(yes);
|
actions_Z_bottom.setEnabled(yes);
|
||||||
}
|
}
|
||||||
|
void decorVisibleLogicChanged();
|
||||||
|
|
||||||
void buttonImage_clicked();
|
void buttonImage_clicked();
|
||||||
void buttonImagePaste_clicked();
|
void buttonImagePaste_clicked();
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1197</width>
|
<width>1166</width>
|
||||||
<height>268</height>
|
<height>108</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QStackedWidget" name="stackedProperties">
|
<widget class="QStackedWidget" name="stackedProperties">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="pageText">
|
<widget class="QWidget" name="pageText">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||||
@@ -686,12 +686,16 @@
|
|||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="labelPen">
|
<widget class="IconedLabel" name="labelPen">
|
||||||
<property name="pixmap">
|
<property name="sizePolicy">
|
||||||
<pixmap resource="qad_blockview.qrc">:/icons/format-stroke-color.png</pixmap>
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="scaledContents">
|
<property name="icon">
|
||||||
<bool>true</bool>
|
<iconset resource="qad_blockview.qrc">
|
||||||
|
<normaloff>:/icons/format-stroke-color.png</normaloff>:/icons/format-stroke-color.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -722,12 +726,16 @@
|
|||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="labelBrush">
|
<widget class="IconedLabel" name="labelBrush">
|
||||||
<property name="pixmap">
|
<property name="sizePolicy">
|
||||||
<pixmap resource="qad_blockview.qrc">:/icons/format-fill-color.png</pixmap>
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="scaledContents">
|
<property name="icon">
|
||||||
<bool>true</bool>
|
<iconset resource="qad_blockview.qrc">
|
||||||
|
<normaloff>:/icons/format-fill-color.png</normaloff>:/icons/format-fill-color.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -741,6 +749,68 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_5">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Preferred</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupShowLogic">
|
||||||
|
<property name="title">
|
||||||
|
<string>Visible logic</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QCheckBox" name="checkVLEnabled">
|
||||||
|
<property name="text">
|
||||||
|
<string>Enabled</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QCheckBox" name="checkVLHovered">
|
||||||
|
<property name="text">
|
||||||
|
<string>Hovered</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QCheckBox" name="checkVLSelected">
|
||||||
|
<property name="text">
|
||||||
|
<string>Selected</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QCheckBox" name="checkVLInverse">
|
||||||
|
<property name="text">
|
||||||
|
<string>Iversed</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
<action name="actionTop">
|
<action name="actionTop">
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
@@ -812,6 +882,11 @@
|
|||||||
<extends>QPushButton</extends>
|
<extends>QPushButton</extends>
|
||||||
<header>colorbutton.h</header>
|
<header>colorbutton.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>IconedLabel</class>
|
||||||
|
<extends>QFrame</extends>
|
||||||
|
<header>iconedlabel.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="qad_blockview.qrc"/>
|
<include location="qad_blockview.qrc"/>
|
||||||
|
|||||||
@@ -696,29 +696,6 @@ BINARY_STREAM_READ(QImage) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/// pure Qt
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
QByteArray qSerialize(const T & value, int version = -1) {
|
|
||||||
QByteArray ret;
|
|
||||||
QDataStream s(&ret, QIODevice::ReadWrite);
|
|
||||||
if (version > 0) s.setVersion((QDataStream::Version)version);
|
|
||||||
s << value;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
T qDeserialize(const QByteArray & data, int version = -1) {
|
|
||||||
T ret;
|
|
||||||
if (!data.isEmpty()) {
|
|
||||||
QDataStream s(data);
|
|
||||||
if (version > 0) s.setVersion((QDataStream::Version)version);
|
|
||||||
s >> ret;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// PIP with QByteArray
|
/// PIP with QByteArray
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -306,4 +306,25 @@ QAD_UTILS_EXPORT void enableHighDPI();
|
|||||||
QAD_UTILS_EXPORT const QMetaObject * getQtMetaObject();
|
QAD_UTILS_EXPORT const QMetaObject * getQtMetaObject();
|
||||||
|
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
QByteArray qSerialize(const T & value, int version = -1) {
|
||||||
|
QByteArray ret;
|
||||||
|
QDataStream s(&ret, QIODevice::ReadWrite);
|
||||||
|
if (version > 0) s.setVersion((QDataStream::Version)version);
|
||||||
|
s << value;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T qDeserialize(const QByteArray & data, int version = -1) {
|
||||||
|
T ret;
|
||||||
|
if (!data.isEmpty()) {
|
||||||
|
QDataStream s(data);
|
||||||
|
if (version > 0) s.setVersion((QDataStream::Version)version);
|
||||||
|
s >> ret;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // QAD_TYPES_H
|
#endif // QAD_TYPES_H
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ void IconedLabel::checkSpacing() {
|
|||||||
|
|
||||||
|
|
||||||
QSize IconedLabel::realIconSize() const {
|
QSize IconedLabel::realIconSize() const {
|
||||||
return size_.isValid() ? size_ : preferredIconSize(1.f, this);
|
return size_.isEmpty() ? preferredIconSize(m_iconSizeAutoScale, this) : size_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -96,3 +96,9 @@ void IconedLabel::setDirection(IconedLabel::Direction d) {
|
|||||||
checkSpacing();
|
checkSpacing();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void IconedLabel::setIconSizeAutoScale(double newIconSizeAutoScale) {
|
||||||
|
m_iconSizeAutoScale = newIconSizeAutoScale;
|
||||||
|
setIconSize(iconSize());
|
||||||
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class QAD_WIDGETS_EXPORT IconedLabel: public QFrame {
|
|||||||
Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
|
Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
|
||||||
Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
|
Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
|
||||||
Q_PROPERTY(Direction direction READ direction WRITE setDirection)
|
Q_PROPERTY(Direction direction READ direction WRITE setDirection)
|
||||||
|
Q_PROPERTY(double iconSizeAutoScale READ iconSizeAutoScale WRITE setIconSizeAutoScale)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Direction {
|
enum Direction {
|
||||||
@@ -51,6 +52,9 @@ public:
|
|||||||
|
|
||||||
QLabel * textLabel() { return &label_; }
|
QLabel * textLabel() { return &label_; }
|
||||||
|
|
||||||
|
double iconSizeAutoScale() const { return m_iconSizeAutoScale; }
|
||||||
|
void setIconSizeAutoScale(double newIconSizeAutoScale);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setText(const QString & t);
|
void setText(const QString & t);
|
||||||
void setIcon(const QIcon & i);
|
void setIcon(const QIcon & i);
|
||||||
@@ -66,6 +70,7 @@ protected:
|
|||||||
QIcon sicon_;
|
QIcon sicon_;
|
||||||
QSize size_;
|
QSize size_;
|
||||||
Direction dir_;
|
Direction dir_;
|
||||||
|
double m_iconSizeAutoScale = 1.;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ICONEDLABEL_H
|
#endif // ICONEDLABEL_H
|
||||||
|
|||||||
Reference in New Issue
Block a user