mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Added highlight filter button from filters container on dialog drag.
This commit is contained in:
@@ -505,7 +505,8 @@ void SetupFilterDragAndDrop(
|
||||
not_null<Ui::RpWidget*> outer,
|
||||
not_null<Main::Session*> session,
|
||||
Fn<std::optional<FilterId>(QPoint)> filterIdAtPosition,
|
||||
Fn<FilterId()> activeFilterId) {
|
||||
Fn<FilterId()> activeFilterId,
|
||||
Fn<void(FilterId)> selectByFilterId) {
|
||||
const auto hasAction = [=](not_null<QDropEvent*> drop, bool perform) {
|
||||
const auto mimeData = drop->mimeData();
|
||||
const auto filterId = filterIdAtPosition(
|
||||
@@ -522,6 +523,7 @@ void SetupFilterDragAndDrop(
|
||||
if (perform) {
|
||||
v.add(id);
|
||||
}
|
||||
selectByFilterId(perform ? FilterId(-1) : id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -531,10 +533,12 @@ void SetupFilterDragAndDrop(
|
||||
if (perform) {
|
||||
v.remove(active);
|
||||
}
|
||||
selectByFilterId(perform ? FilterId(-1) : active);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
selectByFilterId(-1);
|
||||
return false;
|
||||
};
|
||||
outer->setAcceptDrops(true);
|
||||
@@ -560,6 +564,7 @@ void SetupFilterDragAndDrop(
|
||||
dm->ignore();
|
||||
}
|
||||
} else if (e->type() == QEvent::DragLeave) {
|
||||
selectByFilterId(-1);
|
||||
} else if (e->type() == QEvent::Drop) {
|
||||
const auto drop = static_cast<QDropEvent*>(e.get());
|
||||
if (hasAction(drop, true)) {
|
||||
|
||||
@@ -62,7 +62,8 @@ void SetupFilterDragAndDrop(
|
||||
not_null<Ui::RpWidget*> outer,
|
||||
not_null<Main::Session*> session,
|
||||
Fn<std::optional<FilterId>(QPoint)> filterIdAtPosition,
|
||||
Fn<FilterId()> activeFilterId);
|
||||
Fn<FilterId()> activeFilterId,
|
||||
Fn<void(FilterId)> selectByFilterId);
|
||||
|
||||
[[nodiscard]] History *HistoryFromMimeData(
|
||||
const QMimeData *mime,
|
||||
|
||||
@@ -310,7 +310,8 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
|
||||
? slider->lookupSectionLeft(i + 1)
|
||||
: slider->width();
|
||||
if (x >= left && x < right) {
|
||||
const auto &list = session->data().chatsFilters().list();
|
||||
const auto &list
|
||||
= session->data().chatsFilters().list();
|
||||
return (i < list.size())
|
||||
? list[i].id()
|
||||
: FilterId();
|
||||
@@ -318,7 +319,17 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
|
||||
}
|
||||
return std::nullopt;
|
||||
},
|
||||
[=] { return state->lastFilterId.value_or(FilterId()); });
|
||||
[=] { return state->lastFilterId.value_or(FilterId()); },
|
||||
[=](FilterId id) {
|
||||
const auto &list = session->data().chatsFilters().list();
|
||||
for (auto i = 0; i < list.size(); i++) {
|
||||
if (list[i].id() == id) {
|
||||
slider->selectSection(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
slider->selectSection(-1);
|
||||
});
|
||||
}
|
||||
wrap->toggle(false, anim::type::instant);
|
||||
scroll->setCustomWheelProcess([=](not_null<QWheelEvent*> e) {
|
||||
|
||||
@@ -58,6 +58,27 @@ void DiscreteSlider::finishAnimating() {
|
||||
}
|
||||
}
|
||||
|
||||
void DiscreteSlider::selectSection(int index) {
|
||||
if (index < 0 || index >= _sections.size()) {
|
||||
for (auto &other : _sections) {
|
||||
if (other.ripple) {
|
||||
other.ripple->lastStop();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
auto §ion = _sections[index];
|
||||
if (section.ripple && !section.ripple->empty()) {
|
||||
return;
|
||||
}
|
||||
for (auto &other : _sections) {
|
||||
if (other.ripple) {
|
||||
other.ripple->lastStop();
|
||||
}
|
||||
}
|
||||
startRipple(index);
|
||||
}
|
||||
|
||||
void DiscreteSlider::setAdditionalContentWidthToSection(int index, int w) {
|
||||
if (index >= 0 && index < _sections.size()) {
|
||||
auto §ion = _sections[index];
|
||||
|
||||
@@ -45,6 +45,7 @@ public:
|
||||
void setActiveSection(int index);
|
||||
void setActiveSectionFast(int index);
|
||||
void finishAnimating();
|
||||
void selectSection(int index);
|
||||
|
||||
void setAdditionalContentWidthToSection(int index, int width);
|
||||
|
||||
|
||||
@@ -145,7 +145,12 @@ void FiltersMenu::setupDragAndDrop() {
|
||||
}
|
||||
return std::nullopt;
|
||||
},
|
||||
[=] { return _activeFilterId; });
|
||||
[=] { return _activeFilterId; },
|
||||
[=](FilterId filterId) {
|
||||
for (const auto &[id, button] : _filters) {
|
||||
button->setForceRippled(id == filterId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void FiltersMenu::setupMainMenuIcon() {
|
||||
|
||||
Reference in New Issue
Block a user