Add context menu to video tile right click.

This commit is contained in:
John Preston 2021-05-27 23:20:16 +04:00
parent 9d07bb2946
commit 5b0278847d
5 changed files with 23 additions and 10 deletions

View File

@ -96,6 +96,7 @@ public:
not_null<MembersRow*> row,
const IconState &state) override;
bool rowIsNarrow() override;
void rowShowContextMenu(not_null<PeerListRow*> row);
//void rowPaintNarrowBackground(
// Painter &p,
// int x,
@ -1156,6 +1157,10 @@ bool Members::Controller::rowIsNarrow() {
return (_mode == PanelMode::Wide);
}
void Members::Controller::rowShowContextMenu(not_null<PeerListRow*> row) {
showRowMenu(row);
}
//void Members::Controller::rowPaintNarrowBackground(
// Painter &p,
// int x,
@ -1366,15 +1371,16 @@ base::unique_qptr<Ui::PopupMenu> Members::Controller::createRowContextMenu(
}
return getCurrentWindow();
};
const auto weakMenu = Ui::MakeWeak(result.get());
const auto performOnMainWindow = [=](auto callback) {
if (const auto window = getWindow()) {
if (_menu) {
_menu->discardParentReActivate();
if (const auto menu = weakMenu.data()) {
menu->discardParentReActivate();
// We must hide PopupMenu before we activate the MainWindow,
// otherwise we set focus in field inside MainWindow and then
// PopupMenu::hide activates back the group call panel :(
_menu = nullptr;
delete weakMenu;
}
callback(window);
window->widget()->activate();

View File

@ -869,6 +869,10 @@ MembersRowDelegate::IconState MembersRow::computeIconState(
};
}
void MembersRow::showContextMenu() {
return _delegate->rowShowContextMenu(this);
}
void MembersRow::refreshStatus() {
setCustomStatus(
(_speaking

View File

@ -50,7 +50,8 @@ public:
virtual bool rowIsMe(not_null<PeerData*> participantPeer) = 0;
virtual bool rowCanMuteMembers() = 0;
virtual void rowUpdateRow(not_null<MembersRow*> row) = 0;
virtual void rowScheduleRaisedHandStatusRemove(not_null<MembersRow*> row) = 0;
virtual void rowScheduleRaisedHandStatusRemove(
not_null<MembersRow*> row) = 0;
virtual void rowPaintIcon(
Painter &p,
QRect rect,
@ -63,6 +64,7 @@ public:
not_null<MembersRow*> row,
const IconState &state) = 0;
virtual bool rowIsNarrow() = 0;
virtual void rowShowContextMenu(not_null<PeerListRow*> row) = 0;
//virtual void rowPaintNarrowBackground(
// Painter &p,
// int x,
@ -182,6 +184,8 @@ public:
[[nodiscard]] MembersRowDelegate::IconState computeIconState(
MembersRowStyle style = MembersRowStyle::None) const;
void showContextMenu();
private:
struct BlobsAnimation;
struct StatusIcon;

View File

@ -148,10 +148,7 @@ void Viewport::setMode(PanelMode mode, not_null<QWidget*> parent) {
void Viewport::handleMousePress(QPoint position, Qt::MouseButton button) {
handleMouseMove(position);
if (button == Qt::LeftButton) {
setPressed(_selected);
}
setPressed(_selected);
}
void Viewport::handleMouseRelease(QPoint position, Qt::MouseButton button) {
@ -160,7 +157,9 @@ void Viewport::handleMouseRelease(QPoint position, Qt::MouseButton button) {
setPressed({});
if (const auto tile = pressed.tile) {
if (pressed == _selected) {
if (!wide()) {
if (button == Qt::RightButton) {
tile->row()->showContextMenu();
} else if (!wide()) {
_clicks.fire_copy(tile->endpoint());
} else if (pressed.element == Selection::Element::PinButton) {
_pinToggles.fire({

@ -1 +1 @@
Subproject commit d3eab9af84bad9dd9a0853078feee3e53d365ef5
Subproject commit 11cd08b14206a2ce3669cebafb6e693a30ef14ab