Merge pull request 'master' (#48) from master into release
All checks were successful
SHS Gitea/libs/pipeline/head This commit looks good

This commit was merged in pull request #48.
This commit is contained in:
2020-06-26 09:56:46 +03:00
6 changed files with 49 additions and 8 deletions

2
pip

Submodule pip updated: 02ac4020d3...5de62b1c83

View File

@@ -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)

View File

@@ -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;

View File

@@ -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();}
@@ -379,6 +380,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;

View File

@@ -1,6 +1,7 @@
#include "iconedlabel.h"
#include "qad_types.h"
#include <QHBoxLayout>
#include <QStyle>
#include <QEvent>
@@ -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();
}

View File

@@ -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);