mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-30 22:25:12 +00:00
Improve new settings design.
This commit is contained in:
@@ -78,7 +78,7 @@ void AbstractButton::mouseReleaseEvent(QMouseEvent *e) {
|
||||
emit clicked();
|
||||
}
|
||||
if (weak) {
|
||||
_clicks.fire({});
|
||||
_clicks.fire(e->button());
|
||||
}
|
||||
} else {
|
||||
setOver(false, StateChangeSource::ByHover);
|
||||
|
@@ -43,7 +43,7 @@ public:
|
||||
_clickedCallback = std::move(callback);
|
||||
}
|
||||
|
||||
rpl::producer<> clicks() const {
|
||||
rpl::producer<Qt::MouseButton> clicks() const {
|
||||
return _clicks.events();
|
||||
}
|
||||
template <typename Handler>
|
||||
@@ -100,7 +100,7 @@ private:
|
||||
|
||||
Fn<void()> _clickedCallback;
|
||||
|
||||
rpl::event_stream<> _clicks;
|
||||
rpl::event_stream<Qt::MouseButton> _clicks;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -266,6 +266,11 @@ void RoundButton::setFullWidth(int newFullWidth) {
|
||||
refreshText();
|
||||
}
|
||||
|
||||
void RoundButton::setFullRadius(bool enabled) {
|
||||
_fullRadius = enabled;
|
||||
update();
|
||||
}
|
||||
|
||||
void RoundButton::refreshText() {
|
||||
_text = computeFullText();
|
||||
_textWidth = _text.isEmpty() ? 0 : _st.font->width(_text);
|
||||
@@ -319,12 +324,24 @@ void RoundButton::paintEvent(QPaintEvent *e) {
|
||||
if (_fullWidthOverride < 0) {
|
||||
rounded = QRect(0, rounded.top(), innerWidth - _fullWidthOverride, rounded.height());
|
||||
}
|
||||
App::roundRect(p, myrtlrect(rounded), _st.textBg, ImageRoundRadius::Small);
|
||||
const auto drawRect = [&](const style::color &color) {
|
||||
const auto fill = myrtlrect(rounded);
|
||||
if (_fullRadius) {
|
||||
const auto radius = rounded.height() / 2;
|
||||
PainterHighQualityEnabler hq(p);
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(color);
|
||||
p.drawRoundedRect(fill, radius, radius);
|
||||
} else {
|
||||
App::roundRect(p, fill, color, ImageRoundRadius::Small);
|
||||
}
|
||||
};
|
||||
drawRect(_st.textBg);
|
||||
|
||||
auto over = isOver();
|
||||
auto down = isDown();
|
||||
if (over || down) {
|
||||
App::roundRect(p, myrtlrect(rounded), _st.textBgOver, ImageRoundRadius::Small);
|
||||
drawRect(_st.textBgOver);
|
||||
}
|
||||
|
||||
auto ms = getms();
|
||||
@@ -369,7 +386,9 @@ QImage RoundButton::prepareRippleMask() const {
|
||||
if (_fullWidthOverride < 0) {
|
||||
rounded = QRect(0, rounded.top(), innerWidth - _fullWidthOverride, rounded.height());
|
||||
}
|
||||
return RippleAnimation::roundRectMask(rounded.size(), st::buttonRadius);
|
||||
return RippleAnimation::roundRectMask(
|
||||
rounded.size(),
|
||||
_fullRadius ? (rounded.height() / 2) : st::buttonRadius);
|
||||
}
|
||||
|
||||
QPoint RoundButton::prepareRippleStartPosition() const {
|
||||
|
@@ -120,6 +120,7 @@ public:
|
||||
int contentWidth() const;
|
||||
|
||||
void setFullWidth(int newFullWidth);
|
||||
void setFullRadius(bool enabled);
|
||||
|
||||
enum class TextTransform {
|
||||
NoTransform,
|
||||
@@ -153,6 +154,7 @@ private:
|
||||
const style::RoundButton &_st;
|
||||
|
||||
TextTransform _transform = TextTransform::ToUpper;
|
||||
bool _fullRadius = false;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -87,13 +87,15 @@ void SeparatePanel::updateTitlePosition() {
|
||||
|
||||
rpl::producer<> SeparatePanel::backRequests() const {
|
||||
return rpl::merge(
|
||||
_back->entity()->clicks(),
|
||||
_back->entity()->clicks(
|
||||
) | rpl::map([] { return rpl::empty_value(); }),
|
||||
_synteticBackRequests.events());
|
||||
}
|
||||
|
||||
rpl::producer<> SeparatePanel::closeRequests() const {
|
||||
return rpl::merge(
|
||||
_close->clicks(),
|
||||
_close->clicks(
|
||||
) | rpl::map([] { return rpl::empty_value(); }),
|
||||
_userCloseRequests.events());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user