diff --git a/profiler_gui/blocks_graphics_view.cpp b/profiler_gui/blocks_graphics_view.cpp index d3a3d4b..00a766d 100644 --- a/profiler_gui/blocks_graphics_view.cpp +++ b/profiler_gui/blocks_graphics_view.cpp @@ -70,7 +70,6 @@ #include #include #include -#include #include #include #include @@ -556,18 +555,28 @@ bool BackgroundItem::contains(const QPointF& scenePos) const return y >= visibleSceneRect.height(); } -void BackgroundItem::onIdleTimeout() +void BackgroundItem::onWindowActivationChanged(bool isActiveWindow) { - if (m_bookmark < EASY_GLOBALS.bookmarks.size()) + if (!isActiveWindow) { delete m_tooltip; m_tooltip = nullptr; + } +} +void BackgroundItem::onIdleTimeout() +{ + auto parent = static_cast(scene()->parent()); + + delete m_tooltip; + m_tooltip = nullptr; + + if (m_bookmark < EASY_GLOBALS.bookmarks.size() && parent->window()->isActiveWindow()) + { const auto& text = EASY_GLOBALS.bookmarks[m_bookmark].text; if (text.empty()) return; - auto parent = static_cast(scene()->parent()); m_tooltip = new QLabel(QString::fromStdString(text), parent, Qt::ToolTip | Qt::WindowTransparentForInput); @@ -693,6 +702,15 @@ BlocksGraphicsView::~BlocksGraphicsView() ////////////////////////////////////////////////////////////////////////// +void BlocksGraphicsView::onWindowActivationChanged() +{ + const bool isActive = window()->isActiveWindow(); + if (!isActive) + removePopup(); + if (m_backgroundItem != nullptr) + m_backgroundItem->onWindowActivationChanged(isActive); +} + void BlocksGraphicsView::removePopup() { delete m_popupWidget; @@ -2160,6 +2178,9 @@ void BlocksGraphicsView::onIdleTimeout() if (m_popupWidget != nullptr) return; + if (!window()->isActiveWindow()) + return; + auto focusWidget = qApp->focusWidget(); while (focusWidget != nullptr && !focusWidget->property("stayVisible").toBool()) focusWidget = focusWidget->parentWidget(); @@ -2721,6 +2742,11 @@ BlocksGraphicsView* DiagramWidget::view() return m_view; } +ThreadNamesWidget* DiagramWidget::threadsView() +{ + return m_threadNamesWidget; +} + void DiagramWidget::clear() { m_scrollbar->clear(); @@ -2890,7 +2916,13 @@ ThreadNamesWidget::ThreadNamesWidget(BlocksGraphicsView* _view, int _additionalH ThreadNamesWidget::~ThreadNamesWidget() { + removePopup(); +} +void ThreadNamesWidget::onWindowActivationChanged() +{ + if (!window()->isActiveWindow()) + removePopup(); } void ThreadNamesWidget::removePopup() @@ -2967,6 +2999,9 @@ void ThreadNamesWidget::onIdleTimeout() if (m_popupWidget != nullptr) return; + if (!window()->isActiveWindow()) + return; + auto focusWidget = qApp->focusWidget(); while (focusWidget != nullptr && !focusWidget->property("stayVisible").toBool()) focusWidget = focusWidget->parentWidget(); diff --git a/profiler_gui/blocks_graphics_view.h b/profiler_gui/blocks_graphics_view.h index c948253..7272685 100644 --- a/profiler_gui/blocks_graphics_view.h +++ b/profiler_gui/blocks_graphics_view.h @@ -81,7 +81,6 @@ ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// -class QGraphicsProxyWidget; class BlocksGraphicsView; class GraphicsBlockItem; class GraphicsScrollbar; @@ -146,6 +145,9 @@ signals: void bookmarkChanged(size_t index); void moved(); +public slots: + void onWindowActivationChanged(bool isActiveWindow); + private slots: void onIdleTimeout(); @@ -261,6 +263,9 @@ public: onInspectCurrentView(_strict); } +public slots: + void onWindowActivationChanged(); + signals: // Signals @@ -397,6 +402,9 @@ public: return m_view; } +public slots: + void onWindowActivationChanged(); + private: void removePopup(); @@ -429,6 +437,7 @@ public: ~DiagramWidget() override; BlocksGraphicsView* view(); + ThreadNamesWidget* threadsView(); void clear(); void save(class QSettings& settings); diff --git a/profiler_gui/main_window.cpp b/profiler_gui/main_window.cpp index cd6c42d..b9ea501 100644 --- a/profiler_gui/main_window.cpp +++ b/profiler_gui/main_window.cpp @@ -323,6 +323,8 @@ MainWindow::MainWindow() : Parent(), m_theme("default"), m_lastAddress("localhos auto graphicsView = new DiagramWidget(this); graphicsView->setObjectName("ProfilerGUI_Diagram_GraphicsView"); + connect(this, &MainWindow::activationChanged, graphicsView->view(), &BlocksGraphicsView::onWindowActivationChanged); + connect(this, &MainWindow::activationChanged, graphicsView->threadsView(), &ThreadNamesWidget::onWindowActivationChanged); m_graphicsView->setWidget(graphicsView); m_treeWidget = new DockWidget("Hierarchy", this); @@ -1547,6 +1549,14 @@ void MainWindow::closeEvent(QCloseEvent* close_event) Parent::closeEvent(close_event); } +void MainWindow::changeEvent(QEvent* event) +{ + if (event->type() == QEvent::ActivationChange) + { + emit activationChanged(); + } +} + ////////////////////////////////////////////////////////////////////////// void MainWindow::loadSettings() diff --git a/profiler_gui/main_window.h b/profiler_gui/main_window.h index b5f6553..a6c484f 100644 --- a/profiler_gui/main_window.h +++ b/profiler_gui/main_window.h @@ -313,11 +313,15 @@ public: void showEvent(QShowEvent* event) override; void closeEvent(QCloseEvent* close_event) override; + void changeEvent(QEvent* event) override; void dragEnterEvent(QDragEnterEvent* drag_event) override; void dragMoveEvent(QDragMoveEvent* drag_event) override; void dragLeaveEvent(QDragLeaveEvent* drag_event) override; void dropEvent(QDropEvent* drop_event) override; +signals: + void activationChanged(); + protected slots: void onThemeChange(bool);