From 7154ff838f330234ba2bf644377eb2273833da37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B5=D0=BB=D0=B8=D0=BF=D0=B5=D0=BD=D0=BA=D0=BE=20?= =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD?= Date: Sat, 21 Oct 2017 19:57:18 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/libs@301 a8b55f48-bf90-11e4-a774-851b48703e85 --- qad/blockview/blockview.cpp | 20 ++- qad/blockview/blockview.h | 4 + qad/blockview/drawtools.cpp | 64 ++++++++- qad/blockview/drawtools.h | 4 +- qad/blockview/drawtools.ui | 268 +++++++++++++++++++---------------- qad/graphic/graphic_conf.cpp | 13 +- qad/graphic/graphic_conf.ui | 85 +---------- 7 files changed, 243 insertions(+), 215 deletions(-) diff --git a/qad/blockview/blockview.cpp b/qad/blockview/blockview.cpp index 62c6d18..1acaeff 100644 --- a/qad/blockview/blockview.cpp +++ b/qad/blockview/blockview.cpp @@ -980,6 +980,24 @@ void BlockView::centerOn(const QGraphicsItem * item) { } +void BlockView::fitInView(const QRectF & rect, Qt::AspectRatioMode aspectRatioMode) { + QGraphicsView::fitInView(rect, aspectRatioMode); + nav_target = _nav(); +} + + +void BlockView::fitInView(qreal x, qreal y, qreal w, qreal h, Qt::AspectRatioMode aspectRatioMode) { + QGraphicsView::fitInView(x, y, w, h, aspectRatioMode); + nav_target = _nav(); +} + + +void BlockView::fitInView(const QGraphicsItem * item, Qt::AspectRatioMode aspectRatioMode) { + QGraphicsView::fitInView(item, aspectRatioMode); + nav_target = _nav(); +} + + void BlockView::restoreSelState() { foreach (QGraphicsItem * i, sel_items) { i->setPos(i->data(1001).toPointF()); @@ -1521,7 +1539,7 @@ void BlockView::_setThumb(double v) { void BlockView::_setNav(QRectF v) { - fitInView(v); + QGraphicsView::fitInView(v); } diff --git a/qad/blockview/blockview.h b/qad/blockview/blockview.h index d6c9c99..29c1822 100644 --- a/qad/blockview/blockview.h +++ b/qad/blockview/blockview.h @@ -78,6 +78,10 @@ public: void centerOn(qreal x, qreal y); void centerOn(const QGraphicsItem * item); + void fitInView(const QRectF & rect, Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio); + void fitInView(qreal x, qreal y, qreal w, qreal h, Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio); + void fitInView(const QGraphicsItem * item, Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio); + protected: void _init(); void _updateBack(); diff --git a/qad/blockview/drawtools.cpp b/qad/blockview/drawtools.cpp index ee36882..075a27c 100644 --- a/qad/blockview/drawtools.cpp +++ b/qad/blockview/drawtools.cpp @@ -56,6 +56,7 @@ void _DTSizeItem::assignObject(QGraphicsItem * item) { QGraphicsEllipseItem * iell = qgraphicsitem_cast(cur_item); QGraphicsLineItem * iline = qgraphicsitem_cast(cur_item); if (irect || iell || iline) { + resizeHandles(); is_line = qgraphicsitem_cast(item); for (int i = 0; i < (is_line ? 2 : 8); ++i) { rects[i].setParentItem(item); @@ -115,6 +116,14 @@ void _DTSizeItem::doubleClick() { } +void _DTSizeItem::resizeHandles() { + double sz = QApplication::fontMetrics().size(0, "0").height() / 3.; + QRectF r(-sz, -sz, sz*2, sz*2); + for (int i = 0; i < 8; ++i) + rects[i].setRect(r); +} + + QRectF _DTSizeItem::itemRect(const QGraphicsItem * item) const { if (!cur_item) return QRectF(); QGraphicsRectItem * irect = qgraphicsitem_cast(cur_item); @@ -220,6 +229,22 @@ actions_Z_up(this), actions_Z_top(this), actions_Z_down(this), actions_Z_bottom( ui = new Ui::DrawTools(); ui->setupUi(widget_props); widget_props->setEnabled(false); + int fh = qMax(QApplication::fontMetrics().size(0, "0").height(), 22); + int thick = qMax(qRound(QApplication::fontMetrics().size(0, "0").height() / 15.), 1); + QSize sz(fh * 2.5, fh); + QStringList styles; + styles << tr("NoPen") << tr("Solid") << tr("Dash") + << tr("Dot") << tr("Dash-Dot") << tr("Dash-Dot-Dot"); + ui->comboLineStyle->setIconSize(sz); + for (int i = 0; i < 6; i++) { + QPixmap pix(sz); + pix.fill(); + QPainter p(&pix); + p.setPen(QPen(Qt::black, thick, (Qt::PenStyle)i)); + p.drawLine(0, pix.height() / 2, pix.width(), pix.height() / 2); + p.end(); + ui->comboLineStyle->addItem(QIcon(pix), styles[i]); + } setAlignCompact(false); menu_hor.addActions(QList() << ui->actionLeft << ui->actionHCenter << ui->actionRight); menu_ver.addActions(QList() << ui->actionTop << ui->actionVCenter << ui->actionBottom); @@ -265,6 +290,7 @@ actions_Z_up(this), actions_Z_top(this), actions_Z_down(this), actions_Z_bottom( connect(ui->spinScale, SIGNAL(editingFinished()), this, SLOT(changeFinished())); connect(ui->comboText, SIGNAL(editTextChanged(QString)), this, SLOT(propertyChanged())); connect(ui->comboText->lineEdit(), SIGNAL(editingFinished()), this, SLOT(changeFinished())); + connect(ui->comboLineStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(comboLineStyleChanged())); connect(ui->colorButtonPen, SIGNAL(colorChanged(QColor)), this, SLOT(propertyChanged())); connect(ui->colorButtonPen, SIGNAL(colorChanged(QColor)), this, SLOT(changeFinished())); connect(ui->colorButtonBrush, SIGNAL(colorChanged(QColor)), this, SLOT(propertyChanged())); @@ -414,6 +440,15 @@ QComboBox * DrawTools::textEditCombo() const { return ui->comboText; } +/* +void DrawTools::changeEvent(QEvent * e) { + if (e->type() == QEvent::LanguageChange) { + ui->retranslateUi(this); + return; + } + QObject::changeEvent(e); +} +*/ QAction * DrawTools::newAction(const QString & text, const QIcon & icon, int type) { QAction * ret = new QAction(icon, text, this); @@ -469,6 +504,7 @@ void DrawTools::blockPropSignals(bool block_) { ui->spinHeight->blockSignals(block_); ui->spinThick->blockSignals(block_); ui->comboText->blockSignals(block_); + ui->comboLineStyle->blockSignals(block_); ui->colorButtonPen->blockSignals(block_); ui->colorButtonBrush->blockSignals(block_); ui->actionTop->blockSignals(block_); @@ -608,6 +644,7 @@ void DrawTools::selectionChanged() { ui->colorButtonPen->setColor(ishape->pen().color()); ui->colorButtonBrush->setColor(ishape->brush().color()); ui->spinThick->setValue(ishape->pen().widthF()); + ui->comboLineStyle->setCurrentIndex(qMin((int)ishape->pen().style(), ui->comboLineStyle->count() - 1)); setPenBrushEnabled(true, true); if (resize_enabled) size_item.assignObject(ishape); @@ -616,6 +653,7 @@ void DrawTools::selectionChanged() { ui->stackedProperties->setCurrentIndex(1); ui->colorButtonPen->setColor(iline->pen().color()); ui->spinThick->setValue(iline->pen().widthF()); + ui->comboLineStyle->setCurrentIndex(qMin((int)iline->pen().style(), ui->comboLineStyle->count() - 1)); setPenBrushEnabled(true, false); if (resize_enabled) size_item.assignObject(iline); @@ -690,7 +728,7 @@ void DrawTools::propertyChanged() { iell->setRect(QRectF(iell->rect().topLeft(), QSizeF(ui->spinWidth->value(), ui->spinHeight->value()))); } if (ishape) { - ishape->setPen(QPen(ui->colorButtonPen->color(), ui->spinThick->value())); + ishape->setPen(QPen(ui->colorButtonPen->color(), ui->spinThick->value(), (Qt::PenStyle)ui->comboLineStyle->currentIndex())); ishape->setBrush(ui->colorButtonBrush->color()); if (resize_enabled) size_item.assignObject(ishape); @@ -703,6 +741,30 @@ void DrawTools::propertyChanged() { } +void DrawTools::comboLineStyleChanged() { + if (!cur_item) return; + QGraphicsRectItem * irect = qgraphicsitem_cast(cur_item); + QGraphicsEllipseItem * iell = qgraphicsitem_cast(cur_item); + QGraphicsLineItem * iline = qgraphicsitem_cast(cur_item); + if (irect || iell) { + QAbstractGraphicsShapeItem * ishape(0); + if (irect) + ishape = irect; + if (iell) + ishape = iell; + if (ishape) { + QPen p(ishape->pen()); + p.setStyle((Qt::PenStyle)ui->comboLineStyle->currentIndex()); + ishape->setPen(p); + } + } else if (iline) { + QPen p(iline->pen()); + p.setStyle((Qt::PenStyle)ui->comboLineStyle->currentIndex()); + iline->setPen(p); + } +} + + void DrawTools::buttonImage_clicked() { QGraphicsPixmapItem * pi = qgraphicsitem_cast(cur_item); if (!pi) return; diff --git a/qad/blockview/drawtools.h b/qad/blockview/drawtools.h index fd5d546..8f40f5d 100644 --- a/qad/blockview/drawtools.h +++ b/qad/blockview/drawtools.h @@ -24,6 +24,7 @@ protected: void moveRects(); void applyRect(); void doubleClick(); + void resizeHandles(); QRectF itemRect(const QGraphicsItem * item) const; QRectF boundingRect() const; void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0) {} @@ -46,7 +47,7 @@ signals: namespace Ui { class DrawTools; -}; +} class DrawTools: public QObject { @@ -98,6 +99,7 @@ private slots: void selectionChanged(); void sizeChanged(); void propertyChanged(); + void comboLineStyleChanged(); void changeFinished() {if (cur_item) emit itemEdited(cur_item);} void moveZUpAvailable(bool yes) {actions_Z_up.setEnabled(yes); actions_Z_top.setEnabled(yes);} void moveZDownAvailable(bool yes) {actions_Z_down.setEnabled(yes); actions_Z_bottom.setEnabled(yes);} diff --git a/qad/blockview/drawtools.ui b/qad/blockview/drawtools.ui index c7f57fb..82c8648 100644 --- a/qad/blockview/drawtools.ui +++ b/qad/blockview/drawtools.ui @@ -6,8 +6,8 @@ 0 0 - 712 - 111 + 863 + 73 @@ -126,12 +126,6 @@ :/icons/align-hor.png:/icons/align-hor.png - - - 27 - 22 - - QToolButton::InstantPopup @@ -146,12 +140,6 @@ :/icons/align-ver.png:/icons/align-ver.png - - - 27 - 22 - - QToolButton::InstantPopup @@ -432,116 +420,148 @@ 0 - - - - 0 - 0 - - - - Size: - - - - - - - - 0 - 0 - - - - 0 - - - 1000.000000000000000 - - - 10.000000000000000 - - - - - - - - 0 - 0 - - - - X - - - - - - - - 0 - 0 - - - - 0 - - - 1000.000000000000000 - - - 10.000000000000000 - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 20 - 20 - - - - - - - - - 0 - 0 - - - - Width: - - - - - - - - 0 - 0 - - - - 1 - - - 999.000000000000000 - - - 0.500000000000000 - - + + + + + + 0 + 0 + + + + 0 + + + 1000.000000000000000 + + + 10.000000000000000 + + + + + + + + 0 + 0 + + + + 0 + + + 1000.000000000000000 + + + 10.000000000000000 + + + + + + + + 0 + 0 + + + + Width: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + 1 + + + 999.000000000000000 + + + 0.500000000000000 + + + + + + + + 0 + 0 + + + + Thickness: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + Height: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + Style: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + diff --git a/qad/graphic/graphic_conf.cpp b/qad/graphic/graphic_conf.cpp index 1fe4421..ae88331 100644 --- a/qad/graphic/graphic_conf.cpp +++ b/qad/graphic/graphic_conf.cpp @@ -6,16 +6,19 @@ GraphicConf::GraphicConf(QVector & graphics_, QWidget * parent): QD ui = new Ui::GraphicConf(); ui->setupUi(this); QStringList styles; + int fh = qMax(fontMetrics().size(0, "0").height(), 22); + int thick = qMax(qRound(fontMetrics().size(0, "0").height() / 15.), 1); + QSize sz(fh * 2.5, fh); styles << tr("NoPen") << tr("Solid") << tr("Dash") << tr("Dot") << tr("Dash-Dot") << tr("Dash-Dot-Dot"); - ui->comboStyleGrid->setIconSize(QSize(60, 22)); - ui->comboStyleGraphic->setIconSize(QSize(60, 22)); - ui->cbGraphicNames->setIconSize(QSize(60, 22)); + ui->comboStyleGrid->setIconSize(sz); + ui->comboStyleGraphic->setIconSize(sz); + ui->cbGraphicNames->setIconSize(sz); for (int i = 0; i < 6; i++) { - QPixmap pix(60, 22); + QPixmap pix(sz); pix.fill(); QPainter p(&pix); - p.setPen(QPen(Qt::black, 1, (Qt::PenStyle)i)); + p.setPen(QPen(Qt::black, thick, (Qt::PenStyle)i)); p.drawLine(0, pix.height() / 2, pix.width(), pix.height() / 2); p.end(); ui->comboStyleGraphic->addItem(QIcon(pix), styles[i]); diff --git a/qad/graphic/graphic_conf.ui b/qad/graphic/graphic_conf.ui index 4f7ebf5..1d32b42 100644 --- a/qad/graphic/graphic_conf.ui +++ b/qad/graphic/graphic_conf.ui @@ -9,8 +9,8 @@ 0 0 - 492 - 585 + 500 + 583 @@ -20,42 +20,12 @@ true - - 2 - - - 2 - - - 2 - - - 2 - - - 2 - Appearance - - 2 - - - 2 - - - 2 - - - 2 - - - 2 - @@ -154,24 +124,6 @@ QFormLayout::AllNonFixedFieldsGrow - - 2 - - - 2 - - - 2 - - - 2 - - - 2 - - - 2 - @@ -275,24 +227,6 @@ QFormLayout::AllNonFixedFieldsGrow - - 2 - - - 2 - - - 2 - - - 2 - - - 2 - - - 2 - @@ -426,21 +360,6 @@ Margins - - 2 - - - 2 - - - 2 - - - 2 - - - 2 -