From e862ba4c88c7a24969b5f93115f21305b3664f48 Mon Sep 17 00:00:00 2001 From: Victor Zarubkin Date: Mon, 1 May 2017 03:52:48 +0300 Subject: [PATCH] (GUI) #35 #33 Added "Use Right Mouse Button..." hint to Hierarchy window --- profiler_gui/blocks_tree_widget.cpp | 14 +++++++++++++- profiler_gui/blocks_tree_widget.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/profiler_gui/blocks_tree_widget.cpp b/profiler_gui/blocks_tree_widget.cpp index a2d79e7..4a35859 100644 --- a/profiler_gui/blocks_tree_widget.cpp +++ b/profiler_gui/blocks_tree_widget.cpp @@ -135,6 +135,7 @@ EasyTreeWidget::EasyTreeWidget(QWidget* _parent) , m_beginTime(::std::numeric_limits::max()) , m_lastFound(nullptr) , m_progress(nullptr) + , m_hintLabel(nullptr) , m_mode(EasyTreeMode_Plain) , m_bColorRows(true) , m_bLocked(false) @@ -253,6 +254,10 @@ EasyTreeWidget::EasyTreeWidget(QWidget* _parent) m_progress->setValue(100); //m_progress->hide(); + m_hintLabel = new QLabel("Use Right Mouse Button on the Diagram to build a hierarchy...\nPress and hold, move, release", this); + m_hintLabel->setAlignment(Qt::AlignCenter); + m_hintLabel->setStyleSheet("QLabel { color: gray; font: 12pt; }"); + QTimer::singleShot(1500, this, &This::alignProgressBar); } @@ -260,6 +265,7 @@ EasyTreeWidget::~EasyTreeWidget() { saveSettings(); delete m_progress; + delete m_hintLabel; } ////////////////////////////////////////////////////////////////////////// @@ -320,6 +326,7 @@ void EasyTreeWidget::setTree(const unsigned int _blocksNumber, const ::profiler: if (!_blocksTree.empty()) { m_bLocked = true; + m_hintLabel->hide(); m_progress->setValue(0); m_progress->show(); m_hierarchyBuilder.fillTree(m_beginTime, _blocksNumber, _blocksTree, m_bColorRows, m_mode); @@ -353,6 +360,7 @@ void EasyTreeWidget::setTreeBlocks(const ::profiler_gui::TreeBlocks& _blocks, :: if (!m_inputBlocks.empty()) { m_bLocked = true; + m_hintLabel->hide(); m_progress->setValue(0); m_progress->show(); m_hierarchyBuilder.fillTreeBlocks(m_inputBlocks, _session_begin_time, _left, _right, _strict, m_bColorRows, m_mode); @@ -396,6 +404,8 @@ void EasyTreeWidget::clearSilent(bool _global) //m_progress->hide(); } + m_hintLabel->show(); + m_bLocked = false; m_beginTime = ::std::numeric_limits::max(); @@ -731,8 +741,10 @@ void EasyTreeWidget::moveEvent(QMoveEvent* _event) void EasyTreeWidget::alignProgressBar() { - auto pos = mapToGlobal(rect().center()); + auto center = rect().center(); + auto pos = mapToGlobal(center); m_progress->move(pos.x() - (m_progress->width() >> 1), pos.y() - (m_progress->height() >> 1)); + m_hintLabel->move(center.x() - (m_hintLabel->width() >> 1), std::max(center.y() - (m_hintLabel->height() >> 1), header()->height())); } ////////////////////////////////////////////////////////////////////////// diff --git a/profiler_gui/blocks_tree_widget.h b/profiler_gui/blocks_tree_widget.h index 5c17ade..a847269 100644 --- a/profiler_gui/blocks_tree_widget.h +++ b/profiler_gui/blocks_tree_widget.h @@ -91,6 +91,7 @@ protected: QTreeWidgetItem* m_lastFound; ::profiler::timestamp_t m_beginTime; class QProgressDialog* m_progress; + class QLabel* m_hintLabel; EasyTreeMode m_mode; bool m_bColorRows; bool m_bLocked;