From 9beec46e22cbe53b011c10f204d56b3750a87edb Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 3 Jan 2021 12:49:26 +0100 Subject: [PATCH] statistics: use RoundRectItem for legend and info-box Dirk says rounded corners look better. This now looks a bit extreme to me and probably the border size should be increased. Signed-off-by: Berthold Stoeger --- profile-widget/divetooltipitem.cpp | 2 +- stats/informationbox.cpp | 3 ++- stats/informationbox.h | 5 +++-- stats/legend.cpp | 4 +++- stats/legend.h | 5 +++-- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/profile-widget/divetooltipitem.cpp b/profile-widget/divetooltipitem.cpp index f62a68ad8..f61471be5 100644 --- a/profile-widget/divetooltipitem.cpp +++ b/profile-widget/divetooltipitem.cpp @@ -132,7 +132,7 @@ void ToolTipItem::expand() status = EXPANDED; } -ToolTipItem::ToolTipItem(QGraphicsItem *parent) : RoundRectItem(parent), +ToolTipItem::ToolTipItem(QGraphicsItem *parent) : RoundRectItem(8.0, parent), title(new QGraphicsSimpleTextItem(tr("Information"), this)), status(COLLAPSED), timeAxis(0), diff --git a/stats/informationbox.cpp b/stats/informationbox.cpp index 015f821be..706035f93 100644 --- a/stats/informationbox.cpp +++ b/stats/informationbox.cpp @@ -8,9 +8,10 @@ static const QColor informationBorderColor(Qt::black); static const QColor informationColor(0xff, 0xff, 0x00, 192); // Note: fourth argument is opacity static const int informationBorder = 2; +static const double informationBorderRadius = 4.0; // Radius of rounded corners static const int distanceFromPointer = 10; // Distance to place box from mouse pointer or scatter item -InformationBox::InformationBox(QtCharts::QChart *chart) : QGraphicsRectItem(chart), chart(chart) +InformationBox::InformationBox(QtCharts::QChart *chart) : RoundRectItem(informationBorderRadius, chart), chart(chart) { setPen(QPen(informationBorderColor, informationBorder)); setBrush(informationColor); diff --git a/stats/informationbox.h b/stats/informationbox.h index 7e9253dc7..0c71447aa 100644 --- a/stats/informationbox.h +++ b/stats/informationbox.h @@ -4,9 +4,10 @@ #ifndef INFORMATION_BOX_H #define INFORMATION_BOX_H +#include "backend-shared/roundrectitem.h" + #include #include -#include #include namespace QtCharts { @@ -15,7 +16,7 @@ namespace QtCharts { struct dive; // Information window showing data of highlighted dive -struct InformationBox : QGraphicsRectItem { +struct InformationBox : RoundRectItem { InformationBox(QtCharts::QChart *chart); void setText(const std::vector &text, QPointF pos); void setPos(QPointF pos); diff --git a/stats/legend.cpp b/stats/legend.cpp index 457ce42f6..99340a8f9 100644 --- a/stats/legend.cpp +++ b/stats/legend.cpp @@ -10,13 +10,15 @@ static const double legendBorderSize = 2.0; static const double legendBoxBorderSize = 1.0; +static const double legendBoxBorderRadius = 4.0; // radius of rounded corners static const double legendBoxScale = 0.8; // 1.0: text-height of the used font static const double legendInternalBorderSize = 2.0; static const QColor legendColor(0x00, 0x8e, 0xcc, 192); // Note: fourth argument is opacity static const QColor legendBorderColor(Qt::black); Legend::Legend(QGraphicsWidget *chart, const std::vector &names) : - QGraphicsRectItem(chart), chart(chart), displayedItems(0), width(0.0), height(0.0) + RoundRectItem(legendBoxBorderRadius, chart), chart(chart), + displayedItems(0), width(0.0), height(0.0) { setZValue(ZValues::legend); entries.reserve(names.size()); diff --git a/stats/legend.h b/stats/legend.h index e6c5af1e0..2baf6f67b 100644 --- a/stats/legend.h +++ b/stats/legend.h @@ -3,13 +3,14 @@ #ifndef STATS_LEGEND_H #define STATS_LEGEND_H +#include "backend-shared/roundrectitem.h" + #include #include -#include class QGraphicsSceneMouseEvent; -class Legend : public QGraphicsRectItem { +class Legend : public RoundRectItem { public: Legend(QGraphicsWidget *chart, const std::vector &names); void hover(QPointF pos);