mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Adds real support for ToolTips.
This patch changes the Event drawing so it can display tooltips. It is now the responsibility of the item to show / hide a tooltip. A bit of code-refactoring got on here too because I was using only QGraphicsItem calls and I wanted to use a hover in / hover out event to show / hide the tooltip. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
c928b9cb94
commit
d590cb9519
2 changed files with 160 additions and 60 deletions
|
@ -10,26 +10,16 @@ struct graphics_context;
|
|||
struct plot_info;
|
||||
typedef struct text_render_options text_render_options_t;
|
||||
|
||||
|
||||
class ToolTipItem;
|
||||
class ToolTipStatusHandler;
|
||||
|
||||
class ToolTipStatusHandler :public QObject, public QGraphicsEllipseItem {
|
||||
public:
|
||||
explicit ToolTipStatusHandler(QObject* parent = 0);
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent* event);
|
||||
};
|
||||
|
||||
class ToolTipItem :public QObject, public QGraphicsPathItem {
|
||||
Q_OBJECT
|
||||
void updateTitlePosition();
|
||||
Q_PROPERTY(QRectF rect READ boundingRect WRITE setRect)
|
||||
|
||||
public:
|
||||
enum Status {COLLAPSED, EXPANDED};
|
||||
enum {ICON_SMALL = 16, ICON_MEDIUM = 24, ICON_BIG = 32};
|
||||
enum Status{COLLAPSED, EXPANDED};
|
||||
enum {ICON_SMALL = 16, ICON_MEDIUM = 24, ICON_BIG = 32, SPACING=4};
|
||||
|
||||
explicit ToolTipItem(QGraphicsItem* parent = 0);
|
||||
explicit ToolTipItem(QGraphicsItem* parent = 0);
|
||||
|
||||
void collapse();
|
||||
void expand();
|
||||
|
@ -42,12 +32,30 @@ public Q_SLOTS:
|
|||
|
||||
private:
|
||||
typedef QPair<QGraphicsPixmapItem*, QGraphicsSimpleTextItem*> ToolTip;
|
||||
enum Status status;
|
||||
QMap<QString, ToolTip > toolTips;
|
||||
QGraphicsRectItem *background;
|
||||
QGraphicsLineItem *separator;
|
||||
QGraphicsSimpleTextItem *title;
|
||||
|
||||
QRectF rectangle;
|
||||
};
|
||||
|
||||
class EventItem : public QGraphicsPolygonItem{
|
||||
public:
|
||||
explicit EventItem(QGraphicsItem* parent = 0);
|
||||
void addToolTip(const QString& text,const QIcon& icon = QIcon());
|
||||
void setToolTipController(ToolTipItem *controller);
|
||||
|
||||
protected:
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent* event);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent* event);
|
||||
|
||||
private:
|
||||
ToolTipItem *controller;
|
||||
QString text;
|
||||
QIcon icon;
|
||||
};
|
||||
|
||||
class ProfileGraphicsView : public QGraphicsView {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -70,5 +78,4 @@ private:
|
|||
ToolTipItem *toolTip;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue