Dynamic StarWidget metrics

The default IMG_SIZE and SPACING in the StarWidget are not appropriate
for HiDPI displays. Replace them with StarMetrics which are
auto-computed from the (default) font size (which Qt determines from the
display DPI settings).

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Giuseppe Bilotta 2014-10-15 15:30:46 +02:00 committed by Dirk Hohndel
parent 29851d956f
commit 0171368b6d
3 changed files with 35 additions and 11 deletions

View file

@ -4,11 +4,14 @@
#include <QWidget>
enum StarConfig {
SPACING = 2,
IMG_SIZE = 16,
TOTALSTARS = 5
};
struct StarMetrics {
int size;
int spacing;
};
class StarWidget : public QWidget {
Q_OBJECT
public:
@ -19,6 +22,7 @@ public:
static const QImage& starActive();
static const QImage& starInactive();
static const StarMetrics& metrics();
signals:
void valueChanged(int stars);
@ -41,6 +45,7 @@ private:
static QImage activeStar;
static QImage inactiveStar;
static StarMetrics imgMetrics;
};
#endif // STARWIDGET_H