File indexing completed on 2024-04-28 07:39:27

0001 /*
0002     SPDX-FileCopyrightText: 2009-2010 Daniel Laidig <d.laidig@gmx.de>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef PRACTICE_BOXESWIDGET_H
0007 #define PRACTICE_BOXESWIDGET_H
0008 
0009 #include "imagewidget.h"
0010 
0011 namespace Practice
0012 {
0013 class ThemedBackgroundRenderer;
0014 
0015 class BoxesWidget : public ImageWidget
0016 {
0017     Q_OBJECT
0018 
0019 public:
0020     explicit BoxesWidget(QWidget *parent = nullptr);
0021     QSize minimumSizeHint() const override;
0022 
0023     void setRenderer(ThemedBackgroundRenderer *renderer);
0024     void setBoxCount(int boxCount);
0025     void setBoxes(int currentBox, int lastBox = -1);
0026 
0027     void updatePixmap();
0028 
0029 protected:
0030     bool event(QEvent *e) override;
0031 
0032 private:
0033     void drawElement(QPainter *p, const QString &id);
0034 
0035     int m_boxCount{1};
0036     int m_currentBox{-1};
0037     int m_lastBox{-1};
0038 
0039     ThemedBackgroundRenderer *m_renderer{nullptr};
0040 
0041     QPixmap m_box;
0042     QPixmap m_activeBox;
0043 
0044     QPixmap m_arrowBegin;
0045     QPixmap m_arrowCenter;
0046     QPixmap m_arrowEnd;
0047 
0048     QRect m_rect;
0049     bool m_fixedSize{true};
0050 
0051     int m_arrowHint{0};
0052     int m_spacingHint{0};
0053 };
0054 
0055 }
0056 
0057 #endif // PRACTICE_BOXESWIDGET_H