version 2.0.0_alpha

Important! All QtWraps macros renamed!
Qt 6 support
Graphic export feature
qad_types cross-Qt small changes
This commit is contained in:
2021-03-05 13:05:23 +03:00
parent add26cf9ad
commit 7b011ed242
46 changed files with 815 additions and 219 deletions

View File

@@ -29,7 +29,7 @@ void AlignedTextItem::setFont(const QFont & f) {
QFont AlignedTextItem::sceneFont(const QFont & f) {
QFont ret = f;
double scl = 16. / QApplication::fontMetrics().size(0, "0").height();
double scl = 16. / fontHeight();
ret.setPointSizeF(ret.pointSizeF() * scl);
return ret;
}

View File

@@ -609,9 +609,9 @@ void BlockBusItem::mousePressEvent(QGraphicsSceneMouseEvent * e) {
if (endpoints().contains(selPoint))
QMetaObject::invokeMethod(scene()->views().back(), "startBusPointMove", Q_ARG(int, busType()));
}
if (e->buttons().testFlag(Qt::LeftButton)) btncnt++;
if (e->buttons().testFlag(Qt::LeftButton )) btncnt++;
if (e->buttons().testFlag(Qt::RightButton)) btncnt++;
if (e->buttons().testFlag(Qt::MidButton)) btncnt++;
if (e->buttons().testFlag(QT_MID_BUTTON )) btncnt++;
if (btncnt > 0) mm_mods = e->modifiers();
if (btncnt >= 2 && e->button() == Qt::RightButton) {
//qDebug() << "bus revert";
@@ -722,9 +722,9 @@ void BlockBusItem::mouseMoveEvent(QGraphicsSceneMouseEvent * e) {
void BlockBusItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * e) {
mm_mods = Qt::KeyboardModifiers();
int btncnt = 0;
if (e->buttons().testFlag(Qt::LeftButton)) btncnt++;
if (e->buttons().testFlag(Qt::LeftButton )) btncnt++;
if (e->buttons().testFlag(Qt::RightButton)) btncnt++;
if (e->buttons().testFlag(Qt::MidButton)) btncnt++;
if (e->buttons().testFlag(QT_MID_BUTTON )) btncnt++;
if (btncnt == 0) mm_cancel = false;
if (new_segment) {
QMetaObject::invokeMethod(scene()->views().back(), "newBranchAccept", Q_ARG(BlockBusItem * , this));

View File

@@ -168,9 +168,10 @@ void BlockItem::clearPins() {
void BlockItem::clearDecors() {
bool pbs = false;
if (scene()) pbs = scene()->blockSignals(true);
if (scene())
if (scene()) {
foreach (QGraphicsItem * i, decors_)
scene()->sendEvent(i, new QGraphicsSceneEvent(QEvent::Close));
}
qDeleteAll(decors_);
decors_.clear();
if (scene()) {

View File

@@ -14,14 +14,6 @@
const QString _BlockView_Mime_ = "_BlockView_copypaste_";
template <typename T> QSet<T> QList2QSet(const QList<T> & l) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
return QSet<T>(l.begin(), l.end());
#else
return QSet<T>::fromList(l);
#endif
}
BlockView::BlockView(QWidget * parent): QGraphicsView(parent), tmp_bus(true) {
_init();
}
@@ -218,7 +210,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
}
if (me->buttons().testFlag(Qt::LeftButton )) btncnt++;
if (me->buttons().testFlag(Qt::RightButton)) btncnt++;
if (me->buttons().testFlag(Qt::MidButton )) btncnt++;
if (me->buttons().testFlag(QT_MID_BUTTON )) btncnt++;
mm_cancel = btncnt >= 2;
match_bus = bus_from = 0;
hpin = 0;
@@ -266,7 +258,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
mm_drag = moved = false;
screen_point = me->screenPos();
scene_point = me->scenePos();
if ((me->button() == Qt::MidButton) || (me->button() == Qt::RightButton)) {
if ((me->button() == QT_MID_BUTTON) || (me->button() == Qt::RightButton)) {
thumbShow();
restartTimer(timer_thumb, thumb_hide_delay);
return true;
@@ -525,10 +517,10 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
case QEvent::GraphicsSceneMouseRelease:
if (me->buttons().testFlag(Qt::LeftButton)) btncnt++;
if (me->buttons().testFlag(Qt::RightButton)) btncnt++;
if (me->buttons().testFlag(Qt::MidButton)) btncnt++;
if (me->buttons().testFlag(QT_MID_BUTTON)) btncnt++;
cur_bus = 0;
mm_cancel = btncnt > 0;
if (mm_cancel || (me->button() == Qt::MidButton) || (me->button() == Qt::RightButton)) {
if (mm_cancel || (me->button() == QT_MID_BUTTON) || (me->button() == Qt::RightButton)) {
mm_ci = 0;
return true;
}
@@ -665,19 +657,19 @@ void BlockView::timerEvent(QTimerEvent * e) {
void BlockView::wheelEvent(QWheelEvent * e) {
if (!navigation) return;
if (wheel_zoom || e->modifiers().testFlag(Qt::ControlModifier)) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
double scl = 1. - e->angleDelta().y() / 500.;
#else
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
double scl = 1. - e->delta() / 500.;
#else
double scl = 1. - e->angleDelta().y() / 500.;
#endif
if (!is_nav_anim || (nav_anim.state() != QPropertyAnimation::Running))
nav_target = _nav();
QRectF r = nav_target;
double vw = viewport()->width(), vh = viewport()->height();
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
double cx = double(e->position().x()) / vw, cy = double(e->position().y()) / vh;
#else
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
double cx = double(e->pos().x()) / vw, cy = double(e->pos().y()) / vh;
#else
double cx = double(e->position().x()) / vw, cy = double(e->position().y()) / vh;
#endif
double pw = r.width(), ph = r.height();
r.setWidth(r.width() * scl);
@@ -692,7 +684,7 @@ void BlockView::wheelEvent(QWheelEvent * e) {
void BlockView::mousePressEvent(QMouseEvent * event) {
press_point = event->pos();
if (event->buttons().testFlag(Qt::MidButton) || event->buttons().testFlag(Qt::RightButton)) {
if (event->buttons().testFlag(QT_MID_BUTTON) || event->buttons().testFlag(Qt::RightButton)) {
setCursor(Qt::ClosedHandCursor);
//sel_rect.hide();
if (sel_rect.scene())
@@ -723,7 +715,7 @@ void BlockView::scrolled() {
void BlockView::mouseMoveEvent(QMouseEvent * event) {
if (!event) return;
if (navigation) {
if (event->buttons().testFlag(Qt::MidButton) || event->buttons().testFlag(Qt::RightButton)) {
if (event->buttons().testFlag(QT_MID_BUTTON) || event->buttons().testFlag(Qt::RightButton)) {
QPoint dp = (press_point - event->pos());
horizontalScrollBar()->setValue(horizontalScrollBar()->value() + dp.x());
verticalScrollBar()->setValue(verticalScrollBar()->value() + dp.y());
@@ -740,7 +732,7 @@ void BlockView::mouseMoveEvent(QMouseEvent * event) {
void BlockView::mouseDoubleClickEvent(QMouseEvent * event) {
if (event->buttons().testFlag(Qt::MidButton) || event->buttons().testFlag(Qt::RightButton)) {
if (event->buttons().testFlag(QT_MID_BUTTON) || event->buttons().testFlag(Qt::RightButton)) {
fitInView();
return;
}

View File

@@ -223,7 +223,8 @@ protected slots:
void startBusPointMove(int bus_type);
void endBusPointMove();
void pinHoverInOut(BlockItemPin * pin);
void checkPaste(bool queued = false);
void checkPaste(bool queued);
void checkPaste() {checkPaste(false);}
public slots:
void setGridPen(const QPen & pen) {grid_pen = pen; _updateBack();}

View File

@@ -119,7 +119,7 @@ void _DTSizeItem::doubleClick() {
void _DTSizeItem::resizeHandles() {
double sz = QApplication::fontMetrics().size(0, "0").height() / 3.;
double sz = fontHeight() / 3.;
QRectF r(-sz, -sz, sz*2, sz*2);
for (int i = 0; i < 8; ++i)
rects[i].setRect(r);
@@ -235,7 +235,7 @@ actions_Z_up(this), actions_Z_top(this), actions_Z_down(this), actions_Z_bottom(
ui->labelBrush->setMinimumSize(ui->labelPen->minimumSize());
ui->labelBrush->setMaximumSize(ui->labelBrush->minimumSize());
widget_props->setEnabled(false);
int fh = qMax<int>(QApplication::fontMetrics().size(0, "0").height(), 22);
int fh = qMax<int>(fontHeight(), 22);
int thick = lineThickness();
QSize sz(fh * 2.5, fh);
ui->comboLineStyle->setIconSize(sz);