ui: Added custom tooltipping to code and graph (issue #195)
* Tooltips show node type with access specifier, reference count and fully qualified name * Fields and global variables include the type name * Methods and functinos show whole signature. Gets broken into multiple lines if too long. Included changes: * Upgraded to C++14 * fixed clang warnings * Pass location of .srctrlprj file to build.sh script to load on launch * Split off QtCodeField for showing highlighted and annotated code fom QtCodeArea * removed TokenComponentSignature * added TaskDecoratorDelay bug id = 195
This commit is contained in:
@@ -55,6 +55,11 @@ void QtMainView::hideView(View* view)
|
||||
);
|
||||
}
|
||||
|
||||
View* QtMainView::findFloatingView(const std::string& name) const
|
||||
{
|
||||
return m_window->findFloatingView(name);
|
||||
}
|
||||
|
||||
void QtMainView::loadLayout()
|
||||
{
|
||||
m_window->loadLayout();
|
||||
|
||||
@@ -38,6 +38,8 @@ public:
|
||||
virtual void showView(View* view);
|
||||
virtual void hideView(View* view);
|
||||
|
||||
virtual View* findFloatingView(const std::string& name) const;
|
||||
|
||||
virtual QStatusBar* getStatusBar();
|
||||
virtual void setStatusBar(QStatusBar* statusBar);
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
#include "qt/view/QtTooltipView.h"
|
||||
|
||||
#include "qt/element/QtTooltip.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "qt/view/QtMainView.h"
|
||||
#include "qt/view/QtViewWidgetWrapper.h"
|
||||
#include "qt/window/QtMainWindow.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
QtTooltipView::QtTooltipView(ViewLayout* viewLayout)
|
||||
: TooltipView(viewLayout)
|
||||
{
|
||||
m_widget = new QtTooltip(dynamic_cast<QtMainView*>(getViewLayout())->getMainWindow());
|
||||
}
|
||||
|
||||
QtTooltipView::~QtTooltipView()
|
||||
{
|
||||
}
|
||||
|
||||
void QtTooltipView::createWidgetWrapper()
|
||||
{
|
||||
setWidgetWrapper(std::make_shared<QtViewWidgetWrapper>(m_widget));
|
||||
}
|
||||
|
||||
void QtTooltipView::initView()
|
||||
{
|
||||
}
|
||||
|
||||
void QtTooltipView::refreshView()
|
||||
{
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
setStyleSheet();
|
||||
});
|
||||
}
|
||||
|
||||
void QtTooltipView::showTooltip(TooltipInfo info, const View* parent)
|
||||
{
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
if (m_widget->isHovered())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_widget->hide();
|
||||
m_widget->setTooltipInfo(info);
|
||||
|
||||
if (parent)
|
||||
{
|
||||
m_widget->setParentView(QtViewWidgetWrapper::getWidgetOfView(parent)->parentWidget());
|
||||
}
|
||||
|
||||
m_widget->show();
|
||||
});
|
||||
}
|
||||
|
||||
void QtTooltipView::hideTooltip(bool force)
|
||||
{
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
m_widget->hide(force);
|
||||
});
|
||||
}
|
||||
|
||||
bool QtTooltipView::tooltipVisible() const
|
||||
{
|
||||
return m_widget->isVisible();
|
||||
}
|
||||
|
||||
void QtTooltipView::setStyleSheet()
|
||||
{
|
||||
m_widget->setStyleSheet(
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("tooltip_view/tooltip.css"))).c_str()
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#ifndef QT_TOOLTIP_VIEW
|
||||
#define QT_TOOLTIP_VIEW
|
||||
|
||||
#include "component/view/TooltipView.h"
|
||||
#include "qt/utility/QtThreadedFunctor.h"
|
||||
|
||||
class QTimer;
|
||||
class QtTooltip;
|
||||
|
||||
class QtTooltipView
|
||||
: public TooltipView
|
||||
{
|
||||
public:
|
||||
QtTooltipView(ViewLayout* viewLayout);
|
||||
~QtTooltipView();
|
||||
|
||||
// View implementation
|
||||
virtual void createWidgetWrapper();
|
||||
virtual void initView();
|
||||
virtual void refreshView();
|
||||
|
||||
virtual void showTooltip(TooltipInfo info, const View* parent);
|
||||
virtual void hideTooltip(bool force);
|
||||
|
||||
virtual bool tooltipVisible() const;
|
||||
|
||||
private:
|
||||
void setStyleSheet();
|
||||
void doRefreshView();
|
||||
|
||||
QtThreadedLambdaFunctor m_onQtThread;
|
||||
|
||||
QtTooltip* m_widget;
|
||||
};
|
||||
|
||||
#endif // QT_TOOLTIP_VIEW
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "qt/view/QtStatusBarView.h"
|
||||
#include "qt/view/QtStatusView.h"
|
||||
#include "qt/view/QtTabbedView.h"
|
||||
#include "qt/view/QtTooltipView.h"
|
||||
#include "qt/view/QtUndoRedoView.h"
|
||||
|
||||
QtViewFactory::QtViewFactory()
|
||||
@@ -93,6 +94,11 @@ std::shared_ptr<StatusBarView> QtViewFactory::createStatusBarView(ViewLayout* vi
|
||||
return View::createAndInit<QtStatusBarView>(viewLayout);
|
||||
}
|
||||
|
||||
std::shared_ptr<TooltipView> QtViewFactory::createTooltipView(ViewLayout* viewLayout) const
|
||||
{
|
||||
return View::createAndInit<QtTooltipView>(viewLayout);
|
||||
}
|
||||
|
||||
std::shared_ptr<UndoRedoView> QtViewFactory::createUndoRedoView(ViewLayout* viewLayout) const
|
||||
{
|
||||
return View::createInitAndAddToLayout<QtUndoRedoView>(viewLayout);
|
||||
|
||||
@@ -23,6 +23,7 @@ public:
|
||||
virtual std::shared_ptr<SearchView> createSearchView(ViewLayout* viewLayout) const;
|
||||
virtual std::shared_ptr<StatusBarView> createStatusBarView(ViewLayout* viewLayout) const;
|
||||
virtual std::shared_ptr<StatusView> createStatusView(ViewLayout* viewLayout) const;
|
||||
virtual std::shared_ptr<TooltipView> createTooltipView(ViewLayout* viewLayout) const;
|
||||
virtual std::shared_ptr<UndoRedoView> createUndoRedoView(ViewLayout* viewLayout) const;
|
||||
|
||||
virtual std::shared_ptr<DialogView> createDialogView(ViewLayout* viewLayout, StorageAccess* storageAccess) const;
|
||||
|
||||
@@ -16,8 +16,11 @@
|
||||
#include "utility/messaging/type/MessageFocusIn.h"
|
||||
#include "utility/messaging/type/MessageFocusOut.h"
|
||||
#include "utility/messaging/type/MessageGraphNodeBundleSplit.h"
|
||||
#include "utility/messaging/type/MessageTooltipShow.h"
|
||||
#include "utility/messaging/type/MessageTooltipHide.h"
|
||||
#include "utility/utility.h"
|
||||
|
||||
QtGraphEdge* QtGraphEdge::s_focusedEdge = nullptr;
|
||||
QtGraphEdge* QtGraphEdge::s_focusedBezierEdge = nullptr;
|
||||
|
||||
QtGraphEdge::QtGraphEdge(
|
||||
@@ -52,6 +55,7 @@ QtGraphEdge::QtGraphEdge(
|
||||
m_fromActive = m_owner.lock()->getIsActive();
|
||||
m_toActive = m_target.lock()->getIsActive();
|
||||
|
||||
s_focusedEdge = nullptr;
|
||||
s_focusedBezierEdge = nullptr;
|
||||
}
|
||||
|
||||
@@ -85,26 +89,7 @@ void QtGraphEdge::updateLine()
|
||||
return;
|
||||
}
|
||||
|
||||
Edge::EdgeType type;
|
||||
if (getData())
|
||||
{
|
||||
type = getData()->getType();
|
||||
}
|
||||
else
|
||||
{
|
||||
type = Edge::EDGE_AGGREGATION;
|
||||
}
|
||||
|
||||
QString toolTip = Edge::getReadableTypeString(type).c_str();
|
||||
if (type == Edge::EDGE_AGGREGATION)
|
||||
{
|
||||
toolTip += ": " + QString::number(m_weight) + " edge";
|
||||
if (m_weight != 1)
|
||||
{
|
||||
toolTip += "s";
|
||||
}
|
||||
}
|
||||
|
||||
Edge::EdgeType type = (getData() ? getData()->getType() : Edge::EDGE_AGGREGATION);
|
||||
GraphViewStyle::EdgeStyle style = GraphViewStyle::getStyleForEdgeType(type, m_isActive | m_isFocused, false, m_isTrailEdge);
|
||||
|
||||
if (m_useBezier)
|
||||
@@ -130,10 +115,8 @@ void QtGraphEdge::updateLine()
|
||||
bezier->updateLine(ownerRect, rect, ownerParentRect, rect, style, m_weight, false);
|
||||
bezier->setRoute(route);
|
||||
bezier->setPivot(QtLineItemBase::PIVOT_MIDDLE);
|
||||
bezier->setToolTip(toolTip);
|
||||
|
||||
QtLineItemStraight* line = new QtLineItemStraight(this);
|
||||
line->setToolTip(toolTip);
|
||||
if (route == QtLineItemBase::ROUTE_HORIZONTAL)
|
||||
{
|
||||
line->updateLine(Vec2i(rect.x(), (rect.y() + rect.w()) / 2), Vec2i(rect.z(), (rect.y() + rect.w()) / 2), style);
|
||||
@@ -155,7 +138,6 @@ void QtGraphEdge::updateLine()
|
||||
style, m_weight, showArrow);
|
||||
bezier->setRoute(route);
|
||||
bezier->setPivot(QtLineItemBase::PIVOT_MIDDLE);
|
||||
bezier->setToolTip(toolTip);
|
||||
|
||||
if (owner->getLastParent() == target->getLastParent())
|
||||
{
|
||||
@@ -221,8 +203,6 @@ void QtGraphEdge::updateLine()
|
||||
owner->getBoundingRect(), target->getBoundingRect(),
|
||||
owner->getParentBoundingRect(), target->getParentBoundingRect(),
|
||||
style, m_weight, showArrow);
|
||||
|
||||
child->setToolTip(toolTip);
|
||||
}
|
||||
|
||||
this->setZValue(style.zValue);
|
||||
@@ -301,6 +281,22 @@ void QtGraphEdge::focusIn()
|
||||
{
|
||||
m_isFocused = true;
|
||||
updateLine();
|
||||
|
||||
if (s_focusedEdge == this)
|
||||
{
|
||||
Edge::EdgeType type = (getData() ? getData()->getType() : Edge::EDGE_AGGREGATION);
|
||||
|
||||
TooltipInfo info;
|
||||
info.title = Edge::getReadableTypeString(type);
|
||||
if (type == Edge::EDGE_AGGREGATION)
|
||||
{
|
||||
info.count = m_weight;
|
||||
info.countText = "edge";
|
||||
}
|
||||
info.offset = Vec2i(10, 20);
|
||||
|
||||
MessageTooltipShow(info, TOOLTIP_ORIGIN_GRAPH).dispatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,6 +306,11 @@ void QtGraphEdge::focusOut()
|
||||
{
|
||||
m_isFocused = false;
|
||||
updateLine();
|
||||
|
||||
if (s_focusedEdge == this)
|
||||
{
|
||||
MessageTooltipHide().dispatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,9 +350,11 @@ void QtGraphEdge::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
|
||||
s_focusedBezierEdge = this;
|
||||
}
|
||||
|
||||
s_focusedEdge = this;
|
||||
|
||||
if (getData() && !m_useBezier)
|
||||
{
|
||||
MessageFocusIn(std::vector<Id>(1, getData()->getId())).dispatch();
|
||||
MessageFocusIn(std::vector<Id>(1, getData()->getId()), TOOLTIP_ORIGIN_GRAPH).dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -371,6 +374,8 @@ void QtGraphEdge::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
|
||||
{
|
||||
focusOut();
|
||||
}
|
||||
|
||||
s_focusedEdge = nullptr;
|
||||
}
|
||||
|
||||
void QtGraphEdge::setDirection(TokenComponentAggregation::Direction direction)
|
||||
|
||||
@@ -64,6 +64,9 @@ protected:
|
||||
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event);
|
||||
|
||||
private:
|
||||
// used to send tooltip message on focusIn(), because both focus messages are filtered out if sent close together
|
||||
static QtGraphEdge* s_focusedEdge;
|
||||
|
||||
// used to unfocus recent edge, because hover leave event is not always received for bezier edges
|
||||
static QtGraphEdge* s_focusedBezierEdge;
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "utility/messaging/type/MessageGraphNodeMove.h"
|
||||
|
||||
#include "data/graph/token_component/TokenComponentFilePath.h"
|
||||
#include "data/graph/token_component/TokenComponentSignature.h"
|
||||
|
||||
QtGraphNodeData::QtGraphNodeData(const Node* data, const std::string& name, bool hasParent, bool childVisible, bool hasQualifier)
|
||||
: m_data(data)
|
||||
@@ -18,39 +17,6 @@ QtGraphNodeData::QtGraphNodeData(const Node* data, const std::string& name, bool
|
||||
this->setAcceptHoverEvents(true);
|
||||
|
||||
this->setName(name);
|
||||
|
||||
std::string toolTip = data->getReadableTypeString();
|
||||
if (!data->isDefined() && data->isType(Node::NODE_FILE))
|
||||
{
|
||||
toolTip = "incomplete " + toolTip;
|
||||
}
|
||||
else if (!data->isDefined() && !data->isType(Node::NODE_NON_INDEXED))
|
||||
{
|
||||
toolTip = "non-indexed " + toolTip;
|
||||
}
|
||||
else if (data->isImplicit())
|
||||
{
|
||||
toolTip = "implicit " + toolTip;
|
||||
}
|
||||
|
||||
if (data->isType(Node::NODE_FUNCTION | Node::NODE_METHOD))
|
||||
{
|
||||
TokenComponentSignature* sig = data->getComponent<TokenComponentSignature>();
|
||||
if (sig)
|
||||
{
|
||||
toolTip += ": " + sig->getSignature();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FilePath path = getFilePath();
|
||||
if (!path.empty())
|
||||
{
|
||||
toolTip += ": " + path.str();
|
||||
}
|
||||
}
|
||||
|
||||
this->setToolTip(QString::fromStdString(toolTip));
|
||||
}
|
||||
|
||||
QtGraphNodeData::~QtGraphNodeData()
|
||||
@@ -113,7 +79,7 @@ void QtGraphNodeData::updateStyle()
|
||||
|
||||
void QtGraphNodeData::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
|
||||
{
|
||||
MessageFocusIn(std::vector<Id>(1, m_data->getId())).dispatch();
|
||||
MessageFocusIn(std::vector<Id>(1, m_data->getId()), TOOLTIP_ORIGIN_GRAPH).dispatch();
|
||||
}
|
||||
|
||||
void QtGraphNodeData::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
|
||||
|
||||
Reference in New Issue
Block a user