From 50efa519754df3ea7f63bcaa389a7dd35640a678 Mon Sep 17 00:00:00 2001 From: Ivan Pelipenko Date: Tue, 23 Jun 2020 19:57:16 +0300 Subject: [PATCH 1/5] version 1.5.0 IconedLabel now remove spacings in case of empty text or icon --- qad/CMakeLists.txt | 4 ++-- qad/widgets/iconedlabel.cpp | 34 ++++++++++++++++++++++++++++++++++ qad/widgets/iconedlabel.h | 7 +++++-- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/qad/CMakeLists.txt b/qad/CMakeLists.txt index 8a8e8cb..2d4d974 100644 --- a/qad/CMakeLists.txt +++ b/qad/CMakeLists.txt @@ -2,9 +2,9 @@ cmake_minimum_required(VERSION 3.0) cmake_policy(SET CMP0017 NEW) # need include() with .cmake project(qad) set(_QAD_MAJOR 1) -set(_QAD_MINOR 4) +set(_QAD_MINOR 5) set(_QAD_REVISION 0) -set(_QAD_SUFFIX alpha) +set(_QAD_SUFFIX ) set(_QAD_COMPANY SHS) set(_QAD_DOMAIN org.SHS) diff --git a/qad/widgets/iconedlabel.cpp b/qad/widgets/iconedlabel.cpp index e374b6c..5d690a1 100644 --- a/qad/widgets/iconedlabel.cpp +++ b/qad/widgets/iconedlabel.cpp @@ -1,6 +1,7 @@ #include "iconedlabel.h" #include "qad_types.h" #include +#include #include @@ -8,13 +9,23 @@ IconedLabel::IconedLabel(QWidget * parent): QFrame(parent) { label_.setAlignment(Qt::AlignCenter); icon_.setAlignment(Qt::AlignCenter); icon_.setScaledContents(true); + icon_.setHidden(true); setIconSize(QSize()); setDirection(RightToLeft); } +QString IconedLabel::text() const { + return label_.text(); +} + + QIcon IconedLabel::icon() const { +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) + return icon_.pixmap(Qt::ReturnByValue).isNull() ? QIcon() : QIcon(icon_.pixmap(Qt::ReturnByValue)); +#else return icon_.pixmap() == 0 ? QIcon() : QIcon(*icon_.pixmap()); +#endif } @@ -25,14 +36,36 @@ bool IconedLabel::event(QEvent * e) { } +void IconedLabel::checkSpacing() { + label_.setHidden(label_.text().isEmpty()); + if (!layout()) return; + if (label_.isHidden() || icon_.isHidden()) { + layout()->setSpacing(0); + } else { + QStyle * s = style(); + if (s) + layout()->setSpacing(s->layoutSpacing(QSizePolicy::Label, QSizePolicy::Label, + dir_ <= Direction::RightToLeft ? Qt::Horizontal : Qt::Vertical)); + } +} + + QSize IconedLabel::realIconSize() const { return size_.isValid() ? size_ : preferredIconSize(1.f, this); } +void IconedLabel::setText(const QString & t) { + label_.setText(t); + checkSpacing(); +} + + void IconedLabel::setIcon(const QIcon & i) { sicon_ = i; setIconSize(iconSize()); + icon_.setHidden(icon().isNull()); + checkSpacing(); } @@ -55,5 +88,6 @@ void IconedLabel::setDirection(IconedLabel::Direction d) { lay->addItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Expanding)); lay->setContentsMargins(0, 0, 0, 0); setLayout(lay); + checkSpacing(); update(); } diff --git a/qad/widgets/iconedlabel.h b/qad/widgets/iconedlabel.h index aff167a..01ad746 100644 --- a/qad/widgets/iconedlabel.h +++ b/qad/widgets/iconedlabel.h @@ -38,13 +38,16 @@ public: explicit IconedLabel(QWidget * parent = 0); - QString text() const {return label_.text();} + QString text() const; QIcon icon() const; QSize iconSize() const {return size_;} Direction direction() const {return dir_;} + QLabel * textLabel() {return &label_;} + protected: virtual bool event(QEvent * e); + void checkSpacing(); QSize realIconSize() const; QLabel label_, icon_; @@ -53,7 +56,7 @@ protected: Direction dir_; public slots: - void setText(const QString & t) {label_.setText(t);} + void setText(const QString & t); void setIcon(const QIcon & i); void setIconSize(const QSize & s); void setDirection(Direction d); From ba5a30a7ddec2d43651eb87874a72207fcd83d2e Mon Sep 17 00:00:00 2001 From: Ivan Pelipenko Date: Wed, 24 Jun 2020 02:09:08 +0300 Subject: [PATCH 2/5] Android graphic fix --- qad/graphic/graphic.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qad/graphic/graphic.h b/qad/graphic/graphic.h index c34bc15..1dd457d 100644 --- a/qad/graphic/graphic.h +++ b/qad/graphic/graphic.h @@ -379,6 +379,9 @@ protected: GraphicConf * conf; EvalSpinBox line_x_min, line_x_max, line_y_min, line_y_max; QElapsedTimer tm; +#ifdef Q_OS_ANDROID + QElapsedTimer tm_fscr; +#endif QIcon icon_exp_x, icon_exp_y, icon_exp_sx, icon_exp_sy; QImage icon_pause_b, icon_pause_f; Graduation grad_x, grad_y; From 754d46a25085f991764e58633d9d1a77580a6fd8 Mon Sep 17 00:00:00 2001 From: Ivan Pelipenko Date: Wed, 24 Jun 2020 11:45:56 +0300 Subject: [PATCH 3/5] missing Graphic::setGraphicStyle(const Qt::PenStyle & style, int index) --- qad/graphic/graphic.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qad/graphic/graphic.h b/qad/graphic/graphic.h index 1dd457d..125758c 100644 --- a/qad/graphic/graphic.h +++ b/qad/graphic/graphic.h @@ -234,7 +234,8 @@ public slots: void setGraphicColor(const QColor & color) {setGraphicColor(color, curGraphic);} void setGridColor(const QColor & color) {grid_pen.setColor(color); if (aupdate) update();} void setSelectionColor(const QColor & color) {selpen.setColor(color);} - void setGraphicStyle(const Qt::PenStyle & style) {graphics[curGraphic].pen.setStyle(style); updateLegend(); if (aupdate) update();} + void setGraphicStyle(const Qt::PenStyle & style, int index) {graphics[index].pen.setStyle(style); updateLegend(); if (aupdate) update();} + void setGraphicStyle(const Qt::PenStyle & style) {setGraphicStyle(style, curGraphic);} void setGridStyle(const Qt::PenStyle & style) {grid_pen.setStyle(style); if (aupdate) update();} void setSelectionStyle(const Qt::PenStyle & style) {selpen.setStyle(style);} void setGraphicVisible(bool visible, int index) {graphics[index].visible = visible; updateLegendChecks(); if (aupdate) update();} From ab4f2a3d4021fe1f34e3dc1a65fcd1e126eb2c08 Mon Sep 17 00:00:00 2001 From: Ivan Pelipenko Date: Thu, 25 Jun 2020 12:05:45 +0300 Subject: [PATCH 4/5] Graphic mouse signals fix --- qad/graphic/graphic.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qad/graphic/graphic.cpp b/qad/graphic/graphic.cpp index a77636d..c7b7eb6 100644 --- a/qad/graphic/graphic.cpp +++ b/qad/graphic/graphic.cpp @@ -371,7 +371,7 @@ void Graphic::canvasMouseMoveEvent(QMouseEvent * e) { void Graphic::canvasMousePressEvent(QMouseEvent * e) { - emit graphicMousePressEvent(canvas2real(QPointF(e->pos())), e->buttons()); + emit graphicMousePressEvent(canvas2real(QPointF(e->pos())), e->button()); if (!navigation) return; if (gestures && !need_mouse_pan) return; #ifdef HAS_GL @@ -415,7 +415,7 @@ void Graphic::canvasMousePressEvent(QMouseEvent * e) { void Graphic::canvasMouseReleaseEvent(QMouseEvent * e) { - emit graphicMouseReleaseEvent(canvas2real(QPointF(e->pos())), e->buttons()); + emit graphicMouseReleaseEvent(canvas2real(QPointF(e->pos())), e->button()); if (gestures) return; need_mouse_pan = false; if (!navigation) return; From 8363ad29ef98c6800968197911911ef5545e0d3b Mon Sep 17 00:00:00 2001 From: Ivan Pelipenko Date: Fri, 26 Jun 2020 09:51:27 +0300 Subject: [PATCH 5/5] pip --- pip | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pip b/pip index 02ac402..5de62b1 160000 --- a/pip +++ b/pip @@ -1 +1 @@ -Subproject commit 02ac4020d3f7a948c87dd0349db093934c0aed3c +Subproject commit 5de62b1c8352e60c3cb4990f7bd283f6b5fb3bc6