mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Replaced design of restriction buttons for sending media with checkbox.
This commit is contained in:
parent
3ce3baee61
commit
5f2c8acae9
1 changed files with 53 additions and 2 deletions
|
@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_info.h"
|
||||
#include "styles/style_window.h"
|
||||
#include "styles/style_settings.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -286,6 +287,52 @@ not_null<Ui::SettingsButton*> SendMediaToggle(
|
|||
return button;
|
||||
}
|
||||
|
||||
not_null<Ui::SettingsButton*> AddInnerCheckbox(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
const QString &text,
|
||||
bool toggled,
|
||||
rpl::producer<> toggledChanges) {
|
||||
class Button final : public Ui::SettingsButton {
|
||||
public:
|
||||
using Ui::SettingsButton::SettingsButton;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override {
|
||||
Painter p(this);
|
||||
|
||||
const auto paintOver = (isOver() || isDown()) && !isDisabled();
|
||||
Ui::SettingsButton::paintBg(p, e->rect(), paintOver);
|
||||
Ui::SettingsButton::paintRipple(p, 0, 0);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
const auto checkbox = container->add(
|
||||
object_ptr<Ui::Checkbox>(
|
||||
container,
|
||||
text,
|
||||
toggled,
|
||||
st::settingsCheckbox),
|
||||
st::rightsButton.padding);
|
||||
const auto button = Ui::CreateChild<Button>(
|
||||
container.get(),
|
||||
rpl::single(QString()));
|
||||
button->stackUnder(checkbox);
|
||||
rpl::combine(
|
||||
container->widthValue(),
|
||||
checkbox->geometryValue()
|
||||
) | rpl::start_with_next([=](int w, const QRect &r) {
|
||||
button->setGeometry(0, r.y(), w, r.height());
|
||||
}, button->lifetime());
|
||||
checkbox->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
std::move(
|
||||
toggledChanges
|
||||
) | rpl::start_with_next([=] {
|
||||
checkbox->setChecked(button->toggled());
|
||||
}, checkbox->lifetime());
|
||||
return button;
|
||||
};
|
||||
|
||||
not_null<Ui::SettingsButton*> AddDefaultCheckbox(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
const QString &text,
|
||||
|
@ -919,11 +966,11 @@ EditFlagsControl<ChatRestrictions, Ui::RpWidget> CreateEditRestrictions(
|
|||
});
|
||||
state->inner = container->add(std::move(wrap));
|
||||
}
|
||||
const auto checkbox = AddDefaultCheckbox(
|
||||
const auto checkbox = AddInnerCheckbox(
|
||||
state->inner->entity(),
|
||||
text,
|
||||
toggled,
|
||||
locked);
|
||||
state->restrictions.events() | rpl::to_empty);
|
||||
return checkbox;
|
||||
} else {
|
||||
return AddDefaultCheckbox(container, text, toggled, locked);
|
||||
|
@ -946,6 +993,10 @@ EditFlagsControl<ChatRestrictions, Ui::RpWidget> CreateEditRestrictions(
|
|||
rpl::duplicate(
|
||||
result.changes
|
||||
) | rpl::start_to_stream(state->restrictions, state->inner->lifetime());
|
||||
result.widget->widthValue(
|
||||
) | rpl::start_with_next([=](int w) {
|
||||
state->inner->resizeToWidth(w);
|
||||
}, state->inner->lifetime());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue