mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-26 08:01:51 +08:00
#125 [UI] fixed popup windows issue: now windows must disappear when switching between applications (Alt+Tab etc.)
This commit is contained in:
parent
e68abb25fe
commit
0ccb564099
@ -70,7 +70,6 @@
|
||||
#include <QDebug>
|
||||
#include <QGraphicsDropShadowEffect>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsProxyWidget>
|
||||
#include <QGridLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QKeyEvent>
|
||||
@ -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<QWidget*>(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<QWidget*>(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();
|
||||
|
@ -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);
|
||||
|
@ -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()
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user