- Setup C++/Qt6 desktop application structure - Added initial Go proxy backend for TMDB/IGDB integration
38 lines
931 B
C++
38 lines
931 B
C++
#pragma once
|
|
|
|
#include <QWidget>
|
|
|
|
namespace umt {
|
|
|
|
// Interactive 0..10 rating widget rendered as 5 half-clickable stars.
|
|
class StarRating : public QWidget {
|
|
Q_OBJECT
|
|
public:
|
|
explicit StarRating(QWidget *parent = nullptr);
|
|
|
|
int rating() const { return m_rating; } // 0..10 (in half-stars)
|
|
void setRating(int r);
|
|
void setReadOnly(bool ro) { m_readOnly = ro; }
|
|
void setStarSize(int px) { m_star = px; updateGeometry(); }
|
|
|
|
QSize sizeHint() const override;
|
|
|
|
signals:
|
|
void ratingChanged(int rating);
|
|
|
|
protected:
|
|
void paintEvent(QPaintEvent *) override;
|
|
void mouseMoveEvent(QMouseEvent *) override;
|
|
void mousePressEvent(QMouseEvent *) override;
|
|
void leaveEvent(QEvent *) override;
|
|
|
|
private:
|
|
int ratingAt(const QPointF &pos) const; // -> 0..10
|
|
|
|
int m_rating = 0;
|
|
int m_hover = -1;
|
|
int m_star = 22;
|
|
bool m_readOnly = false;
|
|
};
|
|
|
|
} // namespace umt
|