Fixed stuff in user popup
This commit is contained in:
@@ -100,6 +100,8 @@ void Label::paintEvent(QPaintEvent *)
|
||||
? Qt::AlignLeft | Qt::AlignVCenter
|
||||
: Qt::AlignCenter;
|
||||
|
||||
painter.setBrush(this->palette().windowText());
|
||||
|
||||
QTextOption option(alignment);
|
||||
option.setWrapMode(QTextOption::NoWrap);
|
||||
painter.drawText(textRect, this->text_, option);
|
||||
|
||||
@@ -38,14 +38,14 @@ const QPixmap &Button::getPixmap() const
|
||||
return this->pixmap_;
|
||||
}
|
||||
|
||||
void Button::setDim(bool value)
|
||||
void Button::setDim(Dim value)
|
||||
{
|
||||
this->dimPixmap_ = value;
|
||||
|
||||
this->update();
|
||||
}
|
||||
|
||||
bool Button::getDim() const
|
||||
Button::Dim Button::getDim() const
|
||||
{
|
||||
return this->dimPixmap_;
|
||||
}
|
||||
@@ -76,7 +76,12 @@ bool Button::getEnableMargin() const
|
||||
|
||||
qreal Button::getCurrentDimAmount() const
|
||||
{
|
||||
return this->dimPixmap_ && !this->mouseOver_ ? 0.7 : 1;
|
||||
if (this->dimPixmap_ == Dim::None || this->mouseOver_)
|
||||
return 1;
|
||||
else if (this->dimPixmap_ == Dim::Some)
|
||||
return 0.7;
|
||||
else
|
||||
return 0.15;
|
||||
}
|
||||
|
||||
void Button::setBorderColor(const QColor &color)
|
||||
@@ -114,13 +119,13 @@ void Button::paintEvent(QPaintEvent *)
|
||||
|
||||
if (!this->pixmap_.isNull())
|
||||
{
|
||||
if (!this->mouseOver_ && this->dimPixmap_ && this->enabled_)
|
||||
{
|
||||
painter.setOpacity(this->getCurrentDimAmount());
|
||||
}
|
||||
painter.setOpacity(this->getCurrentDimAmount());
|
||||
|
||||
QRect rect = this->rect();
|
||||
int s = this->enableMargin_ ? int(6 * this->scale()) : 0;
|
||||
|
||||
int margin = this->height() < 22 * this->scale() ? 3 : 6;
|
||||
|
||||
int s = this->enableMargin_ ? int(margin * this->scale()) : 0;
|
||||
|
||||
rect.moveLeft(s);
|
||||
rect.setRight(rect.right() - s - s);
|
||||
|
||||
@@ -28,14 +28,16 @@ class Button : public BaseWidget
|
||||
};
|
||||
|
||||
public:
|
||||
enum class Dim { None, Some, Lots };
|
||||
|
||||
Button(BaseWidget *parent = nullptr);
|
||||
|
||||
void setMouseEffectColor(boost::optional<QColor> color);
|
||||
void setPixmap(const QPixmap &pixmap_);
|
||||
const QPixmap &getPixmap() const;
|
||||
|
||||
void setDim(bool value);
|
||||
bool getDim() const;
|
||||
void setDim(Dim value);
|
||||
Dim getDim() const;
|
||||
qreal getCurrentDimAmount() const;
|
||||
|
||||
void setEnable(bool value);
|
||||
@@ -76,7 +78,7 @@ private:
|
||||
|
||||
QColor borderColor_{};
|
||||
QPixmap pixmap_{};
|
||||
bool dimPixmap_{true};
|
||||
Dim dimPixmap_{Dim::Some};
|
||||
bool enableMargin_{true};
|
||||
QPoint mousePos_{};
|
||||
double hoverMultiplier_{0.0};
|
||||
|
||||
Reference in New Issue
Block a user