2013-04-22 23:00:27 +00:00
|
|
|
#ifndef STARWIDGET_H
|
|
|
|
#define STARWIDGET_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
2013-04-27 15:27:27 +00:00
|
|
|
enum StarConfig {SPACING = 2, IMG_SIZE = 16, TOTALSTARS = 5};
|
2013-04-22 23:00:27 +00:00
|
|
|
|
|
|
|
class StarWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit StarWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
|
|
|
|
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);
|
|
|
|
|
2013-06-19 17:20:16 +00:00
|
|
|
public slots:
|
2013-04-22 23:00:27 +00:00
|
|
|
void setCurrentStars(int value);
|
2013-05-18 23:42:59 +00:00
|
|
|
void setReadOnly( bool readOnly);
|
2013-04-22 23:00:27 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/*reimp*/ void mouseReleaseEvent(QMouseEvent* );
|
|
|
|
/*reimp*/ void paintEvent(QPaintEvent* );
|
2013-12-20 13:33:22 +00:00
|
|
|
/*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;
|
|
|
|
|
2013-04-27 15:27:27 +00:00
|
|
|
static QPixmap* activeStar;
|
|
|
|
static QPixmap* inactiveStar;
|
2013-04-22 23:00:27 +00:00
|
|
|
QPixmap grayImage(QPixmap *coloredImg);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // STARWIDGET_H
|