Make audio device selection box wider.

This commit is contained in:
John Preston 2019-01-21 10:37:31 +04:00
parent 1da8841ac7
commit b3f0a3c9f5
2 changed files with 22 additions and 18 deletions

View File

@ -11,6 +11,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/localstorage.h" #include "storage/localstorage.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "ui/widgets/checkbox.h" #include "ui/widgets/checkbox.h"
#include "ui/wrap/vertical_layout.h"
#include "ui/wrap/padding_wrap.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
SingleChoiceBox::SingleChoiceBox( SingleChoiceBox::SingleChoiceBox(
@ -31,17 +33,25 @@ void SingleChoiceBox::prepare() {
addButton(langFactory(lng_box_ok), [=] { closeBox(); }); addButton(langFactory(lng_box_ok), [=] { closeBox(); });
const auto group = std::make_shared<Ui::RadiobuttonGroup>(_initialSelection); const auto group = std::make_shared<Ui::RadiobuttonGroup>(_initialSelection);
auto y = st::boxOptionListPadding.top()
+ st::autolockButton.margin.top(); const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
_options.reserve(_optionTexts.size()); content->add(object_ptr<Ui::FixedHeightWidget>(
auto i = 0; content,
for (const auto &text : _optionTexts) { st::boxOptionListPadding.top() + st::autolockButton.margin.top()));
_options.emplace_back(this, group, i, text, st::autolockButton); auto &&ints = ranges::view::ints(0);
_options.back()->moveToLeft( for (const auto &[i, text] : ranges::view::zip(ints, _optionTexts)) {
st::boxPadding.left() + st::boxOptionListPadding.left(), content->add(
y); object_ptr<Ui::Radiobutton>(
y += _options.back()->heightNoMargins() + st::boxOptionListSkip; content,
i++; group,
i,
text,
st::defaultBoxCheckbox),
QMargins(
st::boxPadding.left() + st::boxOptionListPadding.left(),
0,
st::boxPadding.right(),
st::boxOptionListSkip));
} }
group->setChangedCallback([=](int value) { group->setChangedCallback([=](int value) {
const auto weak = make_weak(this); const auto weak = make_weak(this);
@ -50,11 +60,6 @@ void SingleChoiceBox::prepare() {
closeBox(); closeBox();
} }
}); });
setDimensionsToContent(st::boxWidth, content);
const auto height = y
- st::boxOptionListSkip
+ st::boxOptionListPadding.bottom()
+ st::boxPadding.bottom();
setDimensions(st::autolockWidth, height);
} }

View File

@ -33,7 +33,6 @@ private:
std::vector<QString> _optionTexts; std::vector<QString> _optionTexts;
int _initialSelection = 0; int _initialSelection = 0;
Fn<void(int)> _callback; Fn<void(int)> _callback;
std::vector<object_ptr<Ui::Radiobutton>> _options;
}; };