Slightly simplified resize handler for menu items.

This commit is contained in:
23rd
2026-01-06 07:57:47 +03:00
parent b958e0a275
commit 9d09a637fe
17 changed files with 22 additions and 22 deletions
@@ -32,7 +32,7 @@ CoverItem::CoverItem(
, _st(st) { , _st(st) {
setPointerCursor(false); setPointerCursor(false);
initResizeHook(parent->sizeValue()); fitToMenuWidth();
enableMouseSelecting(); enableMouseSelecting();
enableMouseSelecting(_cover.widget()); enableMouseSelecting(_cover.widget());
@@ -66,7 +66,7 @@ AboutItem::AboutItem(
, _dummyAction(new QAction(parent)) { , _dummyAction(new QAction(parent)) {
setPointerCursor(false); setPointerCursor(false);
initResizeHook(parent->sizeValue()); fitToMenuWidth();
enableMouseSelecting(); enableMouseSelecting();
enableMouseSelecting(_text.get()); enableMouseSelecting(_text.get());
@@ -128,7 +128,7 @@ JoinAsAction::JoinAsAction(
+ st::groupCallJoinAsPhotoSize + st::groupCallJoinAsPhotoSize
+ st::groupCallJoinAsPadding.bottom()) { + st::groupCallJoinAsPadding.bottom()) {
setAcceptBoth(true); setAcceptBoth(true);
initResizeHook(parent->sizeValue()); fitToMenuWidth();
setClickedCallback(std::move(callback)); setClickedCallback(std::move(callback));
paintRequest( paintRequest(
@@ -262,7 +262,7 @@ RecordingAction::RecordingAction(
}, lifetime()); }, lifetime());
setAcceptBoth(true); setAcceptBoth(true);
initResizeHook(parent->sizeValue()); fitToMenuWidth();
setClickedCallback(std::move(callback)); setClickedCallback(std::move(callback));
paintRequest( paintRequest(
@@ -65,7 +65,7 @@ MenuVolumeItem::MenuVolumeItem(
_localMuted ? 0. : (startVolume / float(maxVolume)), _localMuted ? 0. : (startVolume / float(maxVolume)),
Ui::Paint::ArcsAnimation::Direction::Right)) { Ui::Paint::ArcsAnimation::Direction::Right)) {
initResizeHook(parent->sizeValue()); fitToMenuWidth();
enableMouseSelecting(); enableMouseSelecting();
enableMouseSelecting(_slider.get()); enableMouseSelecting(_slider.get());
@@ -78,7 +78,7 @@ Subsection::Subsection(
, _dummyAction(Ui::CreateChild<QAction>(parent)) { , _dummyAction(Ui::CreateChild<QAction>(parent)) {
setPointerCursor(false); setPointerCursor(false);
initResizeHook(parent->sizeValue()); fitToMenuWidth();
_text->resizeToWidth(st::callDeviceSelectionLabel.minWidth); _text->resizeToWidth(st::callDeviceSelectionLabel.minWidth);
_text->moveToLeft(st.itemPadding.left(), st.itemPadding.top()); _text->moveToLeft(st.itemPadding.left(), st.itemPadding.top());
@@ -110,7 +110,7 @@ Selector::Selector(
, _dummyAction(Ui::CreateChild<QAction>(parent)) { , _dummyAction(Ui::CreateChild<QAction>(parent)) {
setPointerCursor(false); setPointerCursor(false);
initResizeHook(parent->sizeValue()); fitToMenuWidth();
const auto padding = st.itemPadding; const auto padding = st.itemPadding;
const auto group = std::make_shared<Ui::RadiobuttonGroup>(); const auto group = std::make_shared<Ui::RadiobuttonGroup>();
@@ -105,7 +105,7 @@ ResolveBankCardAction::ResolveBankCardAction(
, _st(st) , _st(st)
, _height(st::groupCallJoinAsPhotoSize) { , _height(st::groupCallJoinAsPhotoSize) {
setAcceptBoth(true); setAcceptBoth(true);
initResizeHook(parent->sizeValue()); fitToMenuWidth();
setStatus(Status::Loading); setStatus(Status::Loading);
} }
@@ -92,7 +92,7 @@ ResolvePhoneAction::ResolvePhoneAction(
, _height(rect::m::sum::v(st::groupCallJoinAsPadding) , _height(rect::m::sum::v(st::groupCallJoinAsPadding)
+ st::groupCallJoinAsPhotoSize) { + st::groupCallJoinAsPhotoSize) {
setAcceptBoth(true); setAcceptBoth(true);
initResizeHook(parent->sizeValue()); fitToMenuWidth();
setClickedCallback([=] { setClickedCallback([=] {
if (const auto peer = _peer.current()) { if (const auto peer = _peer.current()) {
controller->showPeerInfo(peer); controller->showPeerInfo(peer);
@@ -100,7 +100,7 @@ Action::Action(
_text.setText(st::semiboldTextStyle, label); _text.setText(st::semiboldTextStyle, label);
_icon->subscribeToUpdates([=] { update(); }); _icon->subscribeToUpdates([=] { update(); });
initResizeHook(parent->sizeValue()); fitToMenuWidth();
resolveMinWidth(); resolveMinWidth();
paintRequest( paintRequest(
@@ -107,7 +107,7 @@ TwoTextAction::TwoTextAction(
+ _st.itemStyle.font->height + _st.itemStyle.font->height
+ st::ttlItemTimerFont->height + st::ttlItemTimerFont->height
+ st::ttlItemPadding.bottom()) { + st::ttlItemPadding.bottom()) {
initResizeHook(parent->sizeValue()); fitToMenuWidth();
setClickedCallback(std::move(callback)); setClickedCallback(std::move(callback));
paintRequest( paintRequest(
@@ -95,7 +95,7 @@ TextItem::TextItem(
}, lifetime()); }, lifetime());
_label->resizeToWidth(parent->width() - added); _label->resizeToWidth(parent->width() - added);
initResizeHook(parent->sizeValue()); fitToMenuWidth();
} }
not_null<QAction*> TextItem::action() const { not_null<QAction*> TextItem::action() const {
@@ -665,7 +665,7 @@ BotAction::BotAction(
+ _st.itemStyle.font->height + _st.itemStyle.font->height
+ _st.itemPadding.bottom()) { + _st.itemPadding.bottom()) {
setAcceptBoth(false); setAcceptBoth(false);
initResizeHook(parent->sizeValue()); fitToMenuWidth();
setClickedCallback(std::move(callback)); setClickedCallback(std::move(callback));
_icon.move(_st.itemIconPosition); _icon.move(_st.itemIconPosition);
@@ -95,7 +95,7 @@ SpeedSliderItem::SpeedSliderItem(
+ st.dropdown.menu.itemStyle.font->height + st.dropdown.menu.itemStyle.font->height
+ st.sliderPadding.bottom()) + st.sliderPadding.bottom())
, _debounceTimer([=] { _debounced.fire(current()); }) { , _debounceTimer([=] { _debounced.fire(current()); }) {
initResizeHook(parent->sizeValue()); fitToMenuWidth();
enableMouseSelecting(); enableMouseSelecting();
enableMouseSelecting(_slider.get()); enableMouseSelecting(_slider.get());
@@ -35,7 +35,7 @@ RateTranscribe::RateTranscribe(
, _dummyAction(Ui::CreateChild<QAction>(this)) { , _dummyAction(Ui::CreateChild<QAction>(this)) {
setAcceptBoth(true); setAcceptBoth(true);
initResizeHook(popupMenu->menu()->sizeValue()); fitToMenuWidth();
enableMouseSelecting(); enableMouseSelecting();
+1 -1
View File
@@ -109,7 +109,7 @@ TextItem::TextItem(
(s.height() - _label->height()) / 2); (s.height() - _label->height()) / 2);
}, lifetime()); }, lifetime());
initResizeHook(parent->sizeValue()); fitToMenuWidth();
} }
not_null<QAction*> TextItem::action() const { not_null<QAction*> TextItem::action() const {
@@ -69,7 +69,7 @@ Action::Action(
+ st::ttlItemTimerFont->height + st::ttlItemTimerFont->height
+ st::ttlItemPadding.bottom()) { + st::ttlItemPadding.bottom()) {
setAcceptBoth(true); setAcceptBoth(true);
initResizeHook(parent->sizeValue()); fitToMenuWidth();
setClickedCallback([=] { setClickedCallback([=] {
if (isEnabled()) { if (isEnabled()) {
callback(DownloadsAction::Open); callback(DownloadsAction::Open);
@@ -83,7 +83,7 @@ ActionWithTimer::ActionWithTimer(
+ st::ttlItemTimerFont->height + st::ttlItemTimerFont->height
+ st::ttlItemPadding.bottom()) { + st::ttlItemPadding.bottom()) {
setAcceptBoth(true); setAcceptBoth(true);
initResizeHook(parent->sizeValue()); fitToMenuWidth();
setClickedCallback(std::move(callback)); setClickedCallback(std::move(callback));
paintRequest( paintRequest(
@@ -214,7 +214,7 @@ Action::Action(
}; };
setAcceptBoth(true); setAcceptBoth(true);
initResizeHook(parent->sizeValue()); fitToMenuWidth();
std::move( std::move(
content content
@@ -519,7 +519,7 @@ WhenAction::WhenAction(
const auto parent = parentMenu->menu(); const auto parent = parentMenu->menu();
setAcceptBoth(true); setAcceptBoth(true);
initResizeHook(parent->sizeValue()); fitToMenuWidth();
std::move( std::move(
content content
@@ -735,7 +735,7 @@ WhoReactedEntryAction::WhoReactedEntryAction(
, _height(st::defaultWhoRead.photoSkip * 2 + st::defaultWhoRead.photoSize) { , _height(st::defaultWhoRead.photoSkip * 2 + st::defaultWhoRead.photoSize) {
setAcceptBoth(true); setAcceptBoth(true);
initResizeHook(parent->sizeValue()); fitToMenuWidth();
setData(std::move(data)); setData(std::move(data));
paintRequest( paintRequest(