mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Fix build on Linux.
This commit is contained in:
@@ -37,100 +37,6 @@ namespace Info {
|
||||
namespace Profile {
|
||||
namespace {
|
||||
|
||||
class SectionToggle : public Ui::AbstractCheckView {
|
||||
public:
|
||||
SectionToggle(
|
||||
const style::InfoToggle &st,
|
||||
bool checked,
|
||||
Fn<void()> updateCallback);
|
||||
|
||||
QSize getSize() const override;
|
||||
void paint(
|
||||
Painter &p,
|
||||
int left,
|
||||
int top,
|
||||
int outerWidth) override;
|
||||
QImage prepareRippleMask() const override;
|
||||
bool checkRippleStartPosition(QPoint position) const override;
|
||||
|
||||
private:
|
||||
QSize rippleSize() const;
|
||||
|
||||
const style::InfoToggle &_st;
|
||||
|
||||
};
|
||||
|
||||
SectionToggle::SectionToggle(
|
||||
const style::InfoToggle &st,
|
||||
bool checked,
|
||||
Fn<void()> updateCallback)
|
||||
: AbstractCheckView(st.duration, checked, std::move(updateCallback))
|
||||
, _st(st) {
|
||||
}
|
||||
|
||||
QSize SectionToggle::getSize() const {
|
||||
return QSize(_st.size, _st.size);
|
||||
}
|
||||
|
||||
void SectionToggle::paint(
|
||||
Painter &p,
|
||||
int left,
|
||||
int top,
|
||||
int outerWidth) {
|
||||
auto sqrt2 = sqrt(2.);
|
||||
auto vLeft = style::rtlpoint(left + _st.skip, 0, outerWidth).x() + 0.;
|
||||
auto vTop = top + _st.skip + 0.;
|
||||
auto vWidth = _st.size - 2 * _st.skip;
|
||||
auto vHeight = _st.size - 2 * _st.skip;
|
||||
auto vStroke = _st.stroke / sqrt2;
|
||||
constexpr auto kPointCount = 6;
|
||||
std::array<QPointF, kPointCount> pathV = { {
|
||||
{ vLeft, vTop + (vHeight / 4.) + vStroke },
|
||||
{ vLeft + vStroke, vTop + (vHeight / 4.) },
|
||||
{ vLeft + (vWidth / 2.), vTop + (vHeight * 3. / 4.) - vStroke },
|
||||
{ vLeft + vWidth - vStroke, vTop + (vHeight / 4.) },
|
||||
{ vLeft + vWidth, vTop + (vHeight / 4.) + vStroke },
|
||||
{ vLeft + (vWidth / 2.), vTop + (vHeight * 3. / 4.) + vStroke },
|
||||
} };
|
||||
|
||||
auto toggled = currentAnimationValue();
|
||||
auto alpha = (toggled - 1.) * M_PI_2;
|
||||
auto cosalpha = cos(alpha);
|
||||
auto sinalpha = sin(alpha);
|
||||
auto shiftx = vLeft + (vWidth / 2.);
|
||||
auto shifty = vTop + (vHeight / 2.);
|
||||
for (auto &point : pathV) {
|
||||
auto x = point.x() - shiftx;
|
||||
auto y = point.y() - shifty;
|
||||
point.setX(shiftx + x * cosalpha - y * sinalpha);
|
||||
point.setY(shifty + y * cosalpha + x * sinalpha);
|
||||
}
|
||||
QPainterPath path;
|
||||
path.moveTo(pathV[0]);
|
||||
for (int i = 1; i != kPointCount; ++i) {
|
||||
path.lineTo(pathV[i]);
|
||||
}
|
||||
path.lineTo(pathV[0]);
|
||||
|
||||
PainterHighQualityEnabler hq(p);
|
||||
p.fillPath(path, _st.color);
|
||||
}
|
||||
|
||||
QImage SectionToggle::prepareRippleMask() const {
|
||||
return Ui::RippleAnimation::ellipseMask(rippleSize());
|
||||
}
|
||||
|
||||
QSize SectionToggle::rippleSize() const {
|
||||
return getSize() + 2 * QSize(
|
||||
_st.rippleAreaPadding,
|
||||
_st.rippleAreaPadding);
|
||||
}
|
||||
|
||||
bool SectionToggle::checkRippleStartPosition(QPoint position) const {
|
||||
return QRect(QPoint(0, 0), rippleSize()).contains(position);
|
||||
|
||||
}
|
||||
|
||||
auto MembersStatusText(int count) {
|
||||
return tr::lng_chat_status_members(tr::now, lt_count_decimal, count);
|
||||
};
|
||||
|
Reference in New Issue
Block a user