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 {
|
|
|
|
SPACING = 2,
|
|
|
|
IMG_SIZE = 16,
|
|
|
|
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:
|
2014-02-28 04:09:57 +00:00
|
|
|
explicit StarWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
2013-04-22 23:00:27 +00:00
|
|
|
int currentStars() const;
|
|
|
|
|
|
|
|
/*reimp*/ QSize sizeHint() const;
|
|
|
|
|
2013-04-27 15:27:27 +00:00
|
|
|
static QPixmap starActive();
|
|
|
|
static QPixmap 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:
|
2014-02-28 04:09:57 +00:00
|
|
|
/*reimp*/ void mouseReleaseEvent(QMouseEvent *);
|
|
|
|
/*reimp*/ void paintEvent(QPaintEvent *);
|
|
|
|
/*reimp*/ void focusInEvent(QFocusEvent *);
|
|
|
|
/*reimp*/ void focusOutEvent(QFocusEvent *);
|
|
|
|
/*reimp*/ void keyPressEvent(QKeyEvent *);
|
|
|
|
|
2013-04-22 23:00:27 +00:00
|
|
|
private:
|
|
|
|
int current;
|
2013-11-30 17:18:01 +00:00
|
|
|
bool readOnly;
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
static QPixmap *activeStar;
|
|
|
|
static QPixmap *inactiveStar;
|
2013-04-22 23:00:27 +00:00
|
|
|
QPixmap grayImage(QPixmap *coloredImg);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // STARWIDGET_H
|