Improved visual style of favorite buttons.
This commit is contained in:
@@ -2,6 +2,21 @@
|
|||||||
#define FAVBUTTON_H
|
#define FAVBUTTON_H
|
||||||
|
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
#include <QProxyStyle>
|
||||||
|
|
||||||
|
class FavButtonStyle : public QProxyStyle
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FavButtonStyle();
|
||||||
|
virtual ~FavButtonStyle();
|
||||||
|
|
||||||
|
// QStyle interface
|
||||||
|
public:
|
||||||
|
void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(FavButtonStyle)
|
||||||
|
};
|
||||||
|
|
||||||
class FavButton : public QToolButton
|
class FavButton : public QToolButton
|
||||||
{
|
{
|
||||||
@@ -17,6 +32,9 @@ signals:
|
|||||||
protected:
|
protected:
|
||||||
virtual void dragEnterEvent(QDragEnterEvent *event) override;
|
virtual void dragEnterEvent(QDragEnterEvent *event) override;
|
||||||
virtual void dropEvent(QDropEvent *event) override;
|
virtual void dropEvent(QDropEvent *event) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
FavButtonStyle m_style;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FAVBUTTON_H
|
#endif // FAVBUTTON_H
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ void ShopSettingsForm::drawButtons()
|
|||||||
btn->setMinimumHeight(entity()->favBtnSize());
|
btn->setMinimumHeight(entity()->favBtnSize());
|
||||||
btn->setMinimumWidth(entity()->favBtnSize());
|
btn->setMinimumWidth(entity()->favBtnSize());
|
||||||
}
|
}
|
||||||
|
btn->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||||
((QGridLayout*)ui->btnWidget->layout())->addWidget(btn, i, j);
|
((QGridLayout*)ui->btnWidget->layout())->addWidget(btn, i, j);
|
||||||
|
|
||||||
connect(btn, &FavButton::clicked, [this, btn](bool){
|
connect(btn, &FavButton::clicked, [this, btn](bool){
|
||||||
@@ -161,8 +162,33 @@ void ShopSettingsForm::on_favBtnSize_textChanged(const QString &arg1)
|
|||||||
drawButtons();
|
drawButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////
|
||||||
|
/// \brief FavButtonStyle::FavButtonStyle
|
||||||
|
///
|
||||||
|
|
||||||
|
FavButtonStyle::FavButtonStyle()
|
||||||
|
:QProxyStyle()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
FavButtonStyle::~FavButtonStyle()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void FavButtonStyle::drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole) const
|
||||||
|
{
|
||||||
|
flags |= Qt::TextWordWrap;
|
||||||
|
QProxyStyle::drawItemText(painter, rect, flags, pal, enabled, text, textRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
/// \brief FavButton::FavButton
|
||||||
|
/// \param parent
|
||||||
|
///
|
||||||
|
|
||||||
FavButton::FavButton(QWidget *parent) : QToolButton(parent)
|
FavButton::FavButton(QWidget *parent) : QToolButton(parent)
|
||||||
{
|
{
|
||||||
|
setStyle(&m_style);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FavButton::dragEnterEvent(QDragEnterEvent *event)
|
void FavButton::dragEnterEvent(QDragEnterEvent *event)
|
||||||
|
|||||||
@@ -176,6 +176,7 @@ void ShopForm::loadButtons()
|
|||||||
btn->setMinimumHeight(settings->favBtnSize());
|
btn->setMinimumHeight(settings->favBtnSize());
|
||||||
btn->setMinimumWidth(settings->favBtnSize());
|
btn->setMinimumWidth(settings->favBtnSize());
|
||||||
}
|
}
|
||||||
|
btn->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||||
((QGridLayout*)ui->favorites->layout())->addWidget(btn, i + 1, j);
|
((QGridLayout*)ui->favorites->layout())->addWidget(btn, i + 1, j);
|
||||||
|
|
||||||
if (btnMap[btnName] != NULL)
|
if (btnMap[btnName] != NULL)
|
||||||
|
|||||||
Reference in New Issue
Block a user