1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-07-26 00:14:24 +02:00

Added tooltip event triggers for info messages

This commit is contained in:
2019-10-15 23:59:15 +02:00
parent 694847a424
commit 9c96e7124a
32 changed files with 112 additions and 69 deletions

36
src/GUI/graphicsscene.h Normal file
View File

@ -0,0 +1,36 @@
#ifndef GRAPHICSSCENE_H
#define GRAPHICSSCENE_H
#include <QGraphicsScene>
#include <QGraphicsItem>
#include <QGraphicsSceneHelpEvent>
#include <QWidget>
#include "popup.h"
class GraphicsItem : public QGraphicsItem
{
public:
GraphicsItem(QGraphicsItem *parent = 0) : QGraphicsItem(parent) {}
virtual QString info() const = 0;
int type() const {return QGraphicsItem::UserType + 1;}
};
class GraphicsScene : public QGraphicsScene
{
public:
GraphicsScene(QObject *parent = 0) : QGraphicsScene(parent) {}
protected:
void helpEvent(QGraphicsSceneHelpEvent *event)
{
QGraphicsItem *item = itemAt(event->scenePos(), QTransform());
if (item && item->type() == QGraphicsItem::UserType + 1) {
GraphicsItem *mi = static_cast<GraphicsItem*>(item);
Popup::show(event->screenPos(), mi->info(),
static_cast<QWidget*>(parent()));
}
}
};
#endif // GRAPHICSSCENE_H