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

View file

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

View file

@ -50,7 +50,8 @@ public:
virtual bool rowIsMe(not_null<PeerData*> participantPeer) = 0; virtual bool rowIsMe(not_null<PeerData*> participantPeer) = 0;
virtual bool rowCanMuteMembers() = 0; virtual bool rowCanMuteMembers() = 0;
virtual void rowUpdateRow(not_null<MembersRow*> row) = 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( virtual void rowPaintIcon(
Painter &p, Painter &p,
QRect rect, QRect rect,
@ -63,6 +64,7 @@ public:
not_null<MembersRow*> row, not_null<MembersRow*> row,
const IconState &state) = 0; const IconState &state) = 0;
virtual bool rowIsNarrow() = 0; virtual bool rowIsNarrow() = 0;
virtual void rowShowContextMenu(not_null<PeerListRow*> row) = 0;
//virtual void rowPaintNarrowBackground( //virtual void rowPaintNarrowBackground(
// Painter &p, // Painter &p,
// int x, // int x,
@ -182,6 +184,8 @@ public:
[[nodiscard]] MembersRowDelegate::IconState computeIconState( [[nodiscard]] MembersRowDelegate::IconState computeIconState(
MembersRowStyle style = MembersRowStyle::None) const; MembersRowStyle style = MembersRowStyle::None) const;
void showContextMenu();
private: private:
struct BlobsAnimation; struct BlobsAnimation;
struct StatusIcon; 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) { void Viewport::handleMousePress(QPoint position, Qt::MouseButton button) {
handleMouseMove(position); handleMouseMove(position);
setPressed(_selected);
if (button == Qt::LeftButton) {
setPressed(_selected);
}
} }
void Viewport::handleMouseRelease(QPoint position, Qt::MouseButton button) { void Viewport::handleMouseRelease(QPoint position, Qt::MouseButton button) {
@ -160,7 +157,9 @@ void Viewport::handleMouseRelease(QPoint position, Qt::MouseButton button) {
setPressed({}); setPressed({});
if (const auto tile = pressed.tile) { if (const auto tile = pressed.tile) {
if (pressed == _selected) { if (pressed == _selected) {
if (!wide()) { if (button == Qt::RightButton) {
tile->row()->showContextMenu();
} else if (!wide()) {
_clicks.fire_copy(tile->endpoint()); _clicks.fire_copy(tile->endpoint());
} else if (pressed.element == Selection::Element::PinButton) { } else if (pressed.element == Selection::Element::PinButton) {
_pinToggles.fire({ _pinToggles.fire({

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