parent
195cc61df7
commit
db2d34f840
src/widgets
@ -26,6 +26,8 @@
|
|||||||
#include <QPaintEvent>
|
#include <QPaintEvent>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
|
||||||
|
#include "core/iconloader.h"
|
||||||
|
|
||||||
#include "favoritewidget.h"
|
#include "favoritewidget.h"
|
||||||
|
|
||||||
const int FavoriteWidget::kStarSize = 15;
|
const int FavoriteWidget::kStarSize = 15;
|
||||||
@ -34,8 +36,8 @@ FavoriteWidget::FavoriteWidget(const int tab_index, const bool favorite, QWidget
|
|||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
tab_index_(tab_index),
|
tab_index_(tab_index),
|
||||||
favorite_(favorite),
|
favorite_(favorite),
|
||||||
on_(":/icons/64x64/star.png"),
|
on_(IconLoader::Load("star")),
|
||||||
off_(":/icons/64x64/star-grey.png"),
|
off_(IconLoader::Load("star-grey")),
|
||||||
rect_(0, 0, kStarSize, kStarSize) {}
|
rect_(0, 0, kStarSize, kStarSize) {}
|
||||||
|
|
||||||
void FavoriteWidget::SetFavorite(const bool favorite) {
|
void FavoriteWidget::SetFavorite(const bool favorite) {
|
||||||
@ -59,12 +61,21 @@ void FavoriteWidget::paintEvent(QPaintEvent *e) {
|
|||||||
|
|
||||||
QStylePainter p(this);
|
QStylePainter p(this);
|
||||||
|
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
if (favorite_) {
|
if (favorite_) {
|
||||||
p.drawPixmap(rect_, on_);
|
p.drawPixmap(rect_, on_.pixmap(rect_.size(), devicePixelRatioF()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
p.drawPixmap(rect_, off_);
|
p.drawPixmap(rect_, off_.pixmap(rect_.size(), devicePixelRatioF()));
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (favorite_) {
|
||||||
|
p.drawPixmap(rect_, on_.pixmap(rect_.size()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
p.drawPixmap(rect_, off_.pixmap(rect_.size()));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QPixmap>
|
#include <QIcon>
|
||||||
#include <QRect>
|
#include <QRect>
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
|
|
||||||
@ -56,8 +56,8 @@ class FavoriteWidget : public QWidget {
|
|||||||
// The playlist's id this widget belongs to
|
// The playlist's id this widget belongs to
|
||||||
int tab_index_;
|
int tab_index_;
|
||||||
bool favorite_;
|
bool favorite_;
|
||||||
QPixmap on_;
|
QIcon on_;
|
||||||
QPixmap off_;
|
QIcon off_;
|
||||||
QRect rect_;
|
QRect rect_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user