2017-04-27 20:26:05 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2013-04-22 16:00:27 -07:00
|
|
|
#ifndef STARWIDGET_H
|
|
|
|
#define STARWIDGET_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
2014-02-27 20:09:57 -08:00
|
|
|
enum StarConfig {
|
|
|
|
TOTALSTARS = 5
|
|
|
|
};
|
2013-04-22 16:00:27 -07:00
|
|
|
|
2014-02-27 20:09:57 -08:00
|
|
|
class StarWidget : public QWidget {
|
2013-04-22 16:00:27 -07:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2020-10-25 14:27:39 -07:00
|
|
|
explicit StarWidget(QWidget *parent = 0);
|
2013-04-22 16:00:27 -07:00
|
|
|
int currentStars() const;
|
|
|
|
|
2018-09-29 22:13:44 +02:00
|
|
|
QSize sizeHint() const override;
|
2013-04-22 16:00:27 -07:00
|
|
|
|
2014-06-19 18:45:26 -03:00
|
|
|
static const QImage& starActive();
|
|
|
|
static const QImage& starInactive();
|
2013-04-22 16:00:27 -07:00
|
|
|
|
2013-06-19 10:20:16 -07:00
|
|
|
signals:
|
2013-04-22 16:00:27 -07:00
|
|
|
void valueChanged(int stars);
|
|
|
|
|
2014-02-27 20:09:57 -08:00
|
|
|
public
|
|
|
|
slots:
|
2013-04-22 16:00:27 -07:00
|
|
|
void setCurrentStars(int value);
|
2014-02-27 20:09:57 -08:00
|
|
|
void setReadOnly(bool readOnly);
|
2013-04-22 16:00:27 -07:00
|
|
|
|
|
|
|
protected:
|
2018-09-29 22:13:44 +02:00
|
|
|
void mouseReleaseEvent(QMouseEvent *) override;
|
|
|
|
void paintEvent(QPaintEvent *) override;
|
|
|
|
void focusInEvent(QFocusEvent *) override;
|
|
|
|
void focusOutEvent(QFocusEvent *) override;
|
|
|
|
void keyPressEvent(QKeyEvent *) override;
|
2014-02-27 20:09:57 -08:00
|
|
|
|
2013-04-22 16:00:27 -07:00
|
|
|
private:
|
|
|
|
int current;
|
2013-11-30 09:18:01 -08:00
|
|
|
bool readOnly;
|
|
|
|
|
2014-06-19 18:45:26 -03:00
|
|
|
static QImage activeStar;
|
|
|
|
static QImage inactiveStar;
|
2013-04-22 16:00:27 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // STARWIDGET_H
|