From 8a0cfc566523d880314a01fff19ee99e57b49024 Mon Sep 17 00:00:00 2001 From: Matt Gajownik Date: Fri, 14 Feb 2020 23:30:34 +1100 Subject: [PATCH] UI: Use OBS dock menu instead of Qt dock context menu --- UI/window-basic-main.cpp | 15 +++++++++++++++ UI/window-basic-main.hpp | 2 ++ 2 files changed, 17 insertions(+) diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index 9e658cc19..0ec29df9c 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -206,6 +206,10 @@ OBSBasic::OBSBasic(QWidget *parent) setAcceptDrops(true); + setContextMenuPolicy(Qt::CustomContextMenu); + connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, + SLOT(on_customContextMenuRequested(const QPoint &))); + api = InitializeAPIInterface(this); ui->setupUi(this); @@ -7773,3 +7777,14 @@ void OBSBasic::ResetStatsHotkey() foreach(OBSBasicStats * s, list) s->Reset(); } + +void OBSBasic::on_customContextMenuRequested(const QPoint &pos) +{ + QWidget *widget = childAt(pos); + const char *className = nullptr; + if (widget != nullptr) + className = widget->metaObject()->className(); + + if (!className || strstr(className, "Dock") != nullptr) + ui->viewMenuDocks->exec(mapToGlobal(pos)); +} diff --git a/UI/window-basic-main.hpp b/UI/window-basic-main.hpp index 5770bb2db..5eb18e430 100644 --- a/UI/window-basic-main.hpp +++ b/UI/window-basic-main.hpp @@ -834,6 +834,8 @@ private slots: void on_actionVerticalCenter_triggered(); void on_actionHorizontalCenter_triggered(); + void on_customContextMenuRequested(const QPoint &pos); + void on_scenes_currentItemChanged(QListWidgetItem *current, QListWidgetItem *prev); void on_scenes_customContextMenuRequested(const QPoint &pos);