# HG changeset patch # User Paper # Date 1698863426 14400 # Node ID 2f373d48f889f823c127dfb03bfeb9a5eab6687e # Parent d5efb81540b31b8cdb1a32e31d38803a03de0264 *: etc changes to graph stuff diff -r d5efb81540b3 -r 2f373d48f889 include/gui/widgets/graph.h --- a/include/gui/widgets/graph.h Wed Nov 01 13:52:34 2023 -0400 +++ b/include/gui/widgets/graph.h Wed Nov 01 14:30:26 2023 -0400 @@ -1,5 +1,6 @@ #ifndef __gui__widgets__graph_h #define __gui__widgets__graph_h + #include #include #include @@ -9,7 +10,7 @@ #include #include -template /* does this even work?? */ +template class Graph final : public QWidget { public: Graph(QWidget* parent = nullptr) : QWidget(parent) {}; @@ -36,7 +37,7 @@ int i = 0; for (const auto& item : map) { - painter.drawText(QRect(0, i*ITEM_HEIGHT, TEXT_WIDTH, ITEM_HEIGHT), Qt::AlignRight | Qt::AlignVCenter, QString::number(item.first)); + painter.drawText(QRect(rect.x(), rect.y() + i * ITEM_HEIGHT, TEXT_WIDTH, ITEM_HEIGHT), Qt::AlignRight | Qt::AlignVCenter, QString::number(item.first)); if (size) { painter.save(); @@ -45,7 +46,7 @@ painter.setPen(pen); QPainterPath path; - path.addRect(rect.x()+35, rect.y()+(i*ITEM_HEIGHT), (static_cast(item.second)/size)*(rect.width()-35), ITEM_HEIGHT); + path.addRect(rect.x()+35, rect.y() + i * ITEM_HEIGHT, (static_cast(item.second)/size)*(rect.width()-35), ITEM_HEIGHT); painter.fillPath(path, Qt::blue); painter.drawPath(path); diff -r d5efb81540b3 -r 2f373d48f889 src/gui/pages/statistics.cc --- a/src/gui/pages/statistics.cc Wed Nov 01 13:52:34 2023 -0400 +++ b/src/gui/pages/statistics.cc Wed Nov 01 14:30:26 2023 -0400 @@ -28,13 +28,16 @@ tr("Anime count:\nEpisode count:\nTime spent watching:\nTime to complete:\nAverage score:\nScore deviation:"), "", this)); - /* spaghetti incoming */ QWidget* score_dist_widget = new QWidget(this); QVBoxLayout* score_dist_layout = new QVBoxLayout(score_dist_widget); + score_dist_layout->addWidget(new TextWidgets::Header(tr("Score distribution"), score_dist_widget)); + + /* I have to explain myself here: I hate this :). This makes a widget as a layer to create a margin, + similar to what I do in text.cc with sections. I hate it and it should really be put into a separate + class, but whatever. */ QWidget* content = new QWidget(score_dist_widget); QVBoxLayout* content_layout = new QVBoxLayout(content); - score_dist_layout->addWidget(new TextWidgets::Header(tr("Score distribution"), content)); _score_distribution_graph.reset(new Graph(content)); content_layout->addWidget(_score_distribution_graph.get()); content_layout->setContentsMargins(0, 0, 0, 0);