mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-27 00:31:02 +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 <QDebug>
|
||||||
#include <QGraphicsDropShadowEffect>
|
#include <QGraphicsDropShadowEffect>
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QGraphicsProxyWidget>
|
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
@ -556,18 +555,28 @@ bool BackgroundItem::contains(const QPointF& scenePos) const
|
|||||||
return y >= visibleSceneRect.height();
|
return y >= visibleSceneRect.height();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackgroundItem::onIdleTimeout()
|
void BackgroundItem::onWindowActivationChanged(bool isActiveWindow)
|
||||||
{
|
{
|
||||||
if (m_bookmark < EASY_GLOBALS.bookmarks.size())
|
if (!isActiveWindow)
|
||||||
{
|
{
|
||||||
delete m_tooltip;
|
delete m_tooltip;
|
||||||
m_tooltip = nullptr;
|
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;
|
const auto& text = EASY_GLOBALS.bookmarks[m_bookmark].text;
|
||||||
if (text.empty())
|
if (text.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto parent = static_cast<QWidget*>(scene()->parent());
|
|
||||||
m_tooltip = new QLabel(QString::fromStdString(text),
|
m_tooltip = new QLabel(QString::fromStdString(text),
|
||||||
parent, Qt::ToolTip | Qt::WindowTransparentForInput);
|
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()
|
void BlocksGraphicsView::removePopup()
|
||||||
{
|
{
|
||||||
delete m_popupWidget;
|
delete m_popupWidget;
|
||||||
@ -2160,6 +2178,9 @@ void BlocksGraphicsView::onIdleTimeout()
|
|||||||
if (m_popupWidget != nullptr)
|
if (m_popupWidget != nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!window()->isActiveWindow())
|
||||||
|
return;
|
||||||
|
|
||||||
auto focusWidget = qApp->focusWidget();
|
auto focusWidget = qApp->focusWidget();
|
||||||
while (focusWidget != nullptr && !focusWidget->property("stayVisible").toBool())
|
while (focusWidget != nullptr && !focusWidget->property("stayVisible").toBool())
|
||||||
focusWidget = focusWidget->parentWidget();
|
focusWidget = focusWidget->parentWidget();
|
||||||
@ -2721,6 +2742,11 @@ BlocksGraphicsView* DiagramWidget::view()
|
|||||||
return m_view;
|
return m_view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ThreadNamesWidget* DiagramWidget::threadsView()
|
||||||
|
{
|
||||||
|
return m_threadNamesWidget;
|
||||||
|
}
|
||||||
|
|
||||||
void DiagramWidget::clear()
|
void DiagramWidget::clear()
|
||||||
{
|
{
|
||||||
m_scrollbar->clear();
|
m_scrollbar->clear();
|
||||||
@ -2890,7 +2916,13 @@ ThreadNamesWidget::ThreadNamesWidget(BlocksGraphicsView* _view, int _additionalH
|
|||||||
|
|
||||||
ThreadNamesWidget::~ThreadNamesWidget()
|
ThreadNamesWidget::~ThreadNamesWidget()
|
||||||
{
|
{
|
||||||
|
removePopup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ThreadNamesWidget::onWindowActivationChanged()
|
||||||
|
{
|
||||||
|
if (!window()->isActiveWindow())
|
||||||
|
removePopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadNamesWidget::removePopup()
|
void ThreadNamesWidget::removePopup()
|
||||||
@ -2967,6 +2999,9 @@ void ThreadNamesWidget::onIdleTimeout()
|
|||||||
if (m_popupWidget != nullptr)
|
if (m_popupWidget != nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!window()->isActiveWindow())
|
||||||
|
return;
|
||||||
|
|
||||||
auto focusWidget = qApp->focusWidget();
|
auto focusWidget = qApp->focusWidget();
|
||||||
while (focusWidget != nullptr && !focusWidget->property("stayVisible").toBool())
|
while (focusWidget != nullptr && !focusWidget->property("stayVisible").toBool())
|
||||||
focusWidget = focusWidget->parentWidget();
|
focusWidget = focusWidget->parentWidget();
|
||||||
|
@ -81,7 +81,6 @@
|
|||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class QGraphicsProxyWidget;
|
|
||||||
class BlocksGraphicsView;
|
class BlocksGraphicsView;
|
||||||
class GraphicsBlockItem;
|
class GraphicsBlockItem;
|
||||||
class GraphicsScrollbar;
|
class GraphicsScrollbar;
|
||||||
@ -146,6 +145,9 @@ signals:
|
|||||||
void bookmarkChanged(size_t index);
|
void bookmarkChanged(size_t index);
|
||||||
void moved();
|
void moved();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void onWindowActivationChanged(bool isActiveWindow);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void onIdleTimeout();
|
void onIdleTimeout();
|
||||||
@ -261,6 +263,9 @@ public:
|
|||||||
onInspectCurrentView(_strict);
|
onInspectCurrentView(_strict);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void onWindowActivationChanged();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
// Signals
|
// Signals
|
||||||
@ -397,6 +402,9 @@ public:
|
|||||||
return m_view;
|
return m_view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void onWindowActivationChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void removePopup();
|
void removePopup();
|
||||||
@ -429,6 +437,7 @@ public:
|
|||||||
~DiagramWidget() override;
|
~DiagramWidget() override;
|
||||||
|
|
||||||
BlocksGraphicsView* view();
|
BlocksGraphicsView* view();
|
||||||
|
ThreadNamesWidget* threadsView();
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void save(class QSettings& settings);
|
void save(class QSettings& settings);
|
||||||
|
@ -323,6 +323,8 @@ MainWindow::MainWindow() : Parent(), m_theme("default"), m_lastAddress("localhos
|
|||||||
|
|
||||||
auto graphicsView = new DiagramWidget(this);
|
auto graphicsView = new DiagramWidget(this);
|
||||||
graphicsView->setObjectName("ProfilerGUI_Diagram_GraphicsView");
|
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_graphicsView->setWidget(graphicsView);
|
||||||
|
|
||||||
m_treeWidget = new DockWidget("Hierarchy", this);
|
m_treeWidget = new DockWidget("Hierarchy", this);
|
||||||
@ -1547,6 +1549,14 @@ void MainWindow::closeEvent(QCloseEvent* close_event)
|
|||||||
Parent::closeEvent(close_event);
|
Parent::closeEvent(close_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::changeEvent(QEvent* event)
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::ActivationChange)
|
||||||
|
{
|
||||||
|
emit activationChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void MainWindow::loadSettings()
|
void MainWindow::loadSettings()
|
||||||
|
@ -313,11 +313,15 @@ public:
|
|||||||
|
|
||||||
void showEvent(QShowEvent* event) override;
|
void showEvent(QShowEvent* event) override;
|
||||||
void closeEvent(QCloseEvent* close_event) override;
|
void closeEvent(QCloseEvent* close_event) override;
|
||||||
|
void changeEvent(QEvent* event) override;
|
||||||
void dragEnterEvent(QDragEnterEvent* drag_event) override;
|
void dragEnterEvent(QDragEnterEvent* drag_event) override;
|
||||||
void dragMoveEvent(QDragMoveEvent* drag_event) override;
|
void dragMoveEvent(QDragMoveEvent* drag_event) override;
|
||||||
void dragLeaveEvent(QDragLeaveEvent* drag_event) override;
|
void dragLeaveEvent(QDragLeaveEvent* drag_event) override;
|
||||||
void dropEvent(QDropEvent* drop_event) override;
|
void dropEvent(QDropEvent* drop_event) override;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void activationChanged();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
|
||||||
void onThemeChange(bool);
|
void onThemeChange(bool);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user