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