mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added context menu process to chats filters tabs slider.
This commit is contained in:
parent
6f09e1699f
commit
607c7e7777
2 changed files with 35 additions and 0 deletions
|
@ -185,4 +185,33 @@ void ChatsFiltersTabs::paintEvent(QPaintEvent *e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatsFiltersTabs::mousePressEvent(QMouseEvent *e) {
|
||||||
|
const auto mouseButton = e->button();
|
||||||
|
if (mouseButton == Qt::MouseButton::LeftButton) {
|
||||||
|
Ui::SettingsSlider::mousePressEvent(e);
|
||||||
|
} else {
|
||||||
|
Ui::RpWidget::mousePressEvent(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChatsFiltersTabs::contextMenuEvent(QContextMenuEvent *e) {
|
||||||
|
const auto pos = e->pos();
|
||||||
|
auto left = 0;
|
||||||
|
auto index = 0;
|
||||||
|
enumerateSections([&](const Section §ion) {
|
||||||
|
const auto currentRight = section.left + section.width;
|
||||||
|
if (pos.x() > left && pos.x() < currentRight) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
left = currentRight;
|
||||||
|
index++;
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
_contextMenuRequested.fire_copy(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<int> ChatsFiltersTabs::contextMenuRequested() const {
|
||||||
|
return _contextMenuRequested.events();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
|
@ -29,8 +29,12 @@ public:
|
||||||
void fitWidthToSections();
|
void fitWidthToSections();
|
||||||
void setUnreadCount(int index, int unreadCount);
|
void setUnreadCount(int index, int unreadCount);
|
||||||
|
|
||||||
|
[[nodiscard]] rpl::producer<int> contextMenuRequested() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *e) override;
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
void mousePressEvent(QMouseEvent *e) override;
|
||||||
|
void contextMenuEvent(QContextMenuEvent *e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
[[nodiscard]] QImage cacheUnreadCount(int count) const;
|
[[nodiscard]] QImage cacheUnreadCount(int count) const;
|
||||||
|
@ -50,6 +54,8 @@ private:
|
||||||
std::optional<Ui::RoundRect> _bar;
|
std::optional<Ui::RoundRect> _bar;
|
||||||
std::optional<Ui::RoundRect> _barActive;
|
std::optional<Ui::RoundRect> _barActive;
|
||||||
|
|
||||||
|
rpl::event_stream<int> _contextMenuRequested;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
Loading…
Add table
Reference in a new issue