- added signal that is emitted, when a context-menu is opened

- added functions to read back the position where the context-menu was opened
This commit is contained in:
kriegerj 2015-10-10 12:42:55 +02:00
parent bb98d3843e
commit bb6baffa28
2 changed files with 12 additions and 0 deletions

View File

@ -60,6 +60,8 @@ JKQtPlotter::JKQtPlotter(QWidget *parent):
void JKQtPlotter::init(bool datastore_internal, QWidget* parent, JKQTPdatastore* datast)
{
mouseContextX=0;
mouseContextY=0;
setParent(parent);
connect(&resizeTimer, SIGNAL(timeout()), this, SLOT(delayedResizeEvent()));
doDrawing=false;
@ -303,9 +305,12 @@ void JKQtPlotter::mousePressEvent ( QMouseEvent * event ){
//update();
event->accept();
} else if (rightMouseButtonAction==JKQtPlotter::RightMouseButtonContextMenu) {
mouseContextX=plotter->p2x(event->x()/magnification);
mouseContextY=plotter->p2y((event->y()-getPlotYOffset())/magnification);
contextMenu->close();
initContextMenu();
contextMenu->popup(event->globalPos());
emit contextMenuOpened(mouseContextX, mouseContextY, contextMenu);
event->accept();
}
}

View File

@ -202,6 +202,9 @@ class LIB_EXPORT JKQtPlotter: public QWidget {
JKQTPGET_SET_MACRO(bool, zoomByMouseWheel);
JKQTPGetMacro(double, mouseContextX)
JKQTPGetMacro(double, mouseContextY)
inline JKQTPhorizontalAxis* getXAxis() { return plotter->getXAxis(); }
inline JKQTPverticalAxis* getYAxis() { return plotter->getYAxis(); }
inline JKQTPhorizontalAxis* get_xAxis() { return plotter->get_xAxis(); }
@ -410,6 +413,8 @@ class LIB_EXPORT JKQtPlotter: public QWidget {
void plotScalingRecalculated();
/** \brief emitted before the plot scaling has been recalculated */
void beforePlotScalingRecalculate();
/** \brief emitted when a context-emnu was opened at the given position */
void contextMenuOpened(double x, double y, QMenu* contextMenu);
/** \brief signal: emitted whenever the user selects a new x-y zoom range (by mouse) */
@ -590,6 +595,8 @@ class LIB_EXPORT JKQtPlotter: public QWidget {
QSize minSize;
QMenu* contextMenu;
double mouseContextX;
double mouseContextY;
QList<QMenu*> contextSubMenus;
void initContextMenu();