mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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;
|
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
|
} // namespace
|
||||||
|
|
||||||
TitleWidgetQt::TitleWidgetQt(QWidget *parent)
|
TitleWidgetQt::TitleWidgetQt(QWidget *parent)
|
||||||
|
@ -181,10 +191,12 @@ void TitleWidgetQt::updateControlsPosition() {
|
||||||
void TitleWidgetQt::updateControlsPositionBySide(
|
void TitleWidgetQt::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