From 2a5849a266f1a59e017aa35c21b0338aeb022c10 Mon Sep 17 00:00:00 2001 From: mfreiholz Date: Wed, 3 Feb 2016 09:15:07 +0100 Subject: [PATCH] Toggles visible of FloatingWidget by context-menu actions --- AdvancedDockingSystem/src/ContainerWidget.cpp | 1 + AdvancedDockingSystemDemo/src/mainwindow.cpp | 9 ++++++++- AdvancedDockingSystemDemo/src/mainwindow.h | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/AdvancedDockingSystem/src/ContainerWidget.cpp b/AdvancedDockingSystem/src/ContainerWidget.cpp index 1fba05c..af87ddd 100644 --- a/AdvancedDockingSystem/src/ContainerWidget.cpp +++ b/AdvancedDockingSystem/src/ContainerWidget.cpp @@ -315,6 +315,7 @@ QMenu* ContainerWidget::createContextMenu() const QAction* a = m->addAction(QIcon(), QString("Floating %1").arg(c->uid())); a->setCheckable(true); a->setChecked(fw->isVisible()); + QObject::connect(a, &QAction::toggled, fw, &FloatingWidget::setVisible); } } diff --git a/AdvancedDockingSystemDemo/src/mainwindow.cpp b/AdvancedDockingSystemDemo/src/mainwindow.cpp index 431eb4f..688183c 100644 --- a/AdvancedDockingSystemDemo/src/mainwindow.cpp +++ b/AdvancedDockingSystemDemo/src/mainwindow.cpp @@ -100,4 +100,11 @@ void MainWindow::onActionAddSectionContentTriggered() // auto section = new ads::SectionWidget(_container); // _container->addSection(section); // section->addContent(content); -} \ No newline at end of file +} + +void MainWindow::contextMenuEvent(QContextMenuEvent* e) +{ + QMenu* m = _container->createContextMenu(); + m->exec(QCursor::pos()); + delete m; +} diff --git a/AdvancedDockingSystemDemo/src/mainwindow.h b/AdvancedDockingSystemDemo/src/mainwindow.h index 7c132d5..eab5146 100644 --- a/AdvancedDockingSystemDemo/src/mainwindow.h +++ b/AdvancedDockingSystemDemo/src/mainwindow.h @@ -23,6 +23,9 @@ public: private slots: void onActionAddSectionContentTriggered(); +protected: + virtual void contextMenuEvent(QContextMenuEvent* e); + private: Ui::MainWindow *ui; ads::ContainerWidget* _container;