mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 23:27:09 +02:00
Ensure controls aren't duplictated
This commit is contained in:
parent
e109da037e
commit
3637fec397
1 changed files with 13 additions and 1 deletions
|
@ -27,6 +27,16 @@ namespace {
|
|||
return st::callShadow.extend;
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
TitleWidgetQt::TitleWidgetQt(QWidget *parent)
|
||||
|
@ -181,10 +191,12 @@ void TitleWidgetQt::updateControlsPosition() {
|
|||
void TitleWidgetQt::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