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 Ui {
|
||||||
namespace Platform {
|
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(
|
TitleControls::TitleControls(
|
||||||
not_null<RpWidget*> parent,
|
not_null<RpWidget*> parent,
|
||||||
|
|
@ -197,10 +210,12 @@ void TitleControls::updateControlsPosition() {
|
||||||
void TitleControls::updateControlsPositionBySide(
|
void TitleControls::updateControlsPositionBySide(
|
||||||
const std::vector<Control> &controls,
|
const std::vector<Control> &controls,
|
||||||
bool right) {
|
bool right) {
|
||||||
const auto preparedControls = right
|
auto preparedControls = right
|
||||||
? (ranges::view::reverse(controls) | ranges::to_vector)
|
? (ranges::view::reverse(controls) | ranges::to_vector)
|
||||||
: controls;
|
: controls;
|
||||||
|
|
||||||
|
RemoveDuplicates(preparedControls);
|
||||||
|
|
||||||
auto position = 0;
|
auto position = 0;
|
||||||
for (const auto &control : preparedControls) {
|
for (const auto &control : preparedControls) {
|
||||||
const auto widget = controlWidget(control);
|
const auto widget = controlWidget(control);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue