Ensure controls aren't duplicated
This commit is contained in:
parent
3bc42db7bc
commit
34fc25a56c
1 changed files with 16 additions and 1 deletions
|
|
@ -21,6 +21,19 @@
|
|||
|
||||
namespace Ui {
|
||||
namespace Platform {
|
||||
namespace {
|
||||
|
||||
template <typename T>
|
||||
void RemoveDuplicates(std::vector<T> &v) {
|
||||
auto end = v.end();
|
||||
for (auto it = v.begin(); it != end; ++it) {
|
||||
end = std::remove(it + 1, end, *it);
|
||||
}
|
||||
|
||||
v.erase(end, v.end());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TitleControls::TitleControls(
|
||||
not_null<RpWidget*> parent,
|
||||
|
|
@ -197,10 +210,12 @@ void TitleControls::updateControlsPosition() {
|
|||
void TitleControls::updateControlsPositionBySide(
|
||||
const std::vector<Control> &controls,
|
||||
bool right) {
|
||||
const auto preparedControls = right
|
||||
auto preparedControls = right
|
||||
? (ranges::view::reverse(controls) | ranges::to_vector)
|
||||
: controls;
|
||||
|
||||
RemoveDuplicates(preparedControls);
|
||||
|
||||
auto position = 0;
|
||||
for (const auto &control : preparedControls) {
|
||||
const auto widget = controlWidget(control);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue