Commit ef00f675 authored by Christoffer Ackelman's avatar Christoffer Ackelman

Fixed popup menu location

parent 1902e0b9
...@@ -79,6 +79,7 @@ extern "C" { ...@@ -79,6 +79,7 @@ extern "C" {
#include <QColor> #include <QColor>
#include <QInputDialog> #include <QInputDialog>
#include <QScrollArea>
#include <QTimer> #include <QTimer>
#include <QVBoxLayout> #include <QVBoxLayout>
...@@ -102,11 +103,11 @@ WNavQt::WNavQt(void *xn_parent_ctx, QWidget *xn_parent_wid, const char *xn_name, ...@@ -102,11 +103,11 @@ WNavQt::WNavQt(void *xn_parent_ctx, QWidget *xn_parent_wid, const char *xn_name,
trace_obj = new WNavQtTraceObject(this); trace_obj = new WNavQtTraceObject(this);
debug_print("creating a scrolledbrowwidgetqt\n"); QScrollArea *scrolledbrow = ((QScrollArea *)
QWidget *scrolledbrow = scrolledbrowwidgetqt_new(WNav::init_brow_base_cb, this, &brow_widget));
scrolledbrowwidgetqt_new(WNav::init_brow_base_cb, this, &brow_widget);
scrolledbrow->setFrameShape(QFrame::Box);
scrolledbrow->setStyleSheet("QMainWindow{border: 3px solid black;}"); scrolledbrow->setLineWidth(3);
showNow(brow_widget); showNow(brow_widget);
......
...@@ -613,7 +613,8 @@ int WttQt::create_popup_menu(pwr_sAttrRef aref, int x, int y) ...@@ -613,7 +613,8 @@ int WttQt::create_popup_menu(pwr_sAttrRef aref, int x, int y)
} else { } else {
return 0; return 0;
} }
popupmenu_x += 10; popupmenu_x += palette_paned->pos().x();
popupmenu_y += palette_paned->pos().y();
// Create the menu // Create the menu
sts = get_popup_menu_items(aref, pwr_cNCid); sts = get_popup_menu_items(aref, pwr_cNCid);
...@@ -2560,6 +2561,7 @@ QMenu *WttQt::build_submenu(int MenuType, const char *MenuTitle, ...@@ -2560,6 +2561,7 @@ QMenu *WttQt::build_submenu(int MenuType, const char *MenuTitle,
if (Items[idx].Item == ldh_eMenuItem_Cascade) { if (Items[idx].Item == ldh_eMenuItem_Cascade) {
QMenu *sub = menu->addMenu(fl(Items[idx].Name)); QMenu *sub = menu->addMenu(fl(Items[idx].Name));
debug_print("build_submenu recursively calling build_submenu to add a submenu\n");
QMenu *w = build_submenu(MENU_PULLDOWN, Items[idx].Name, Callback, Items, QMenu *w = build_submenu(MENU_PULLDOWN, Items[idx].Name, Callback, Items,
idx + 1); idx + 1);
sub->addMenu(w); sub->addMenu(w);
......
...@@ -77,6 +77,15 @@ void dbg_print(const char *file, int line, const char *fmt, ...) ...@@ -77,6 +77,15 @@ void dbg_print(const char *file, int line, const char *fmt, ...)
} }
} }
void dbg_print(QString str)
{
if (DEBUG) {
QByteArray ba = str.toLocal8Bit();
const char *c_str = ba.data();
fprintf(stderr, "%s\n", c_str);
}
}
QString fl(const char *text) QString fl(const char *text)
{ {
return QString::fromLocal8Bit(text); return QString::fromLocal8Bit(text);
......
...@@ -50,6 +50,8 @@ void print_time(FILE *stream, int fulldate = 0); ...@@ -50,6 +50,8 @@ void print_time(FILE *stream, int fulldate = 0);
void dbg_print(const char *file, int line, const char *fmt, ...); void dbg_print(const char *file, int line, const char *fmt, ...);
void dbg_print(QString str);
#define debug_print(fmt, args...) \ #define debug_print(fmt, args...) \
do { if (DEBUG) { dbg_print(__FILE__, __LINE__, fmt, ##args); } } while (0) do { if (DEBUG) { dbg_print(__FILE__, __LINE__, fmt, ##args); } } while (0)
......
...@@ -587,31 +587,25 @@ void CoWowQt::PopupPosition(QWidget *parent, int x_event, int y_event, int *x, ...@@ -587,31 +587,25 @@ void CoWowQt::PopupPosition(QWidget *parent, int x_event, int y_event, int *x,
int x1 = 0; int x1 = 0;
int y1 = 0; int y1 = 0;
int x0 = (int) x_event; QPoint p0((int) x_event, (int) y_event);
int y0 = (int) y_event;
grandparent = parent->parentWidget(); grandparent = parent->parentWidget();
while (!grandparent->isWindow()) { while (!grandparent->isWindow()) {
if (!x1 && !y1 && (parent->pos().x() || parent->pos().y())) { if ( !x1 && !y1 && (parent->geometry().x() || parent->geometry().y())) {
// Add first widget with nonzero position x1 = parent->geometry().x();
x1 = parent->pos().x(); y1 = parent->geometry().y();
y1 = parent->pos().y(); p0 = parent->mapToParent(p0);
x0 += x1;
y0 += y1;
} }
parent = grandparent; parent = grandparent;
grandparent = parent->parentWidget(); grandparent = parent->parentWidget();
} }
if (grandparent) { if (grandparent) {
// Add window widget position // Add window widget position
x1 = grandparent->pos().x(); p0 = grandparent->mapToParent(p0);
y1 = grandparent->pos().y();
x0 += x1;
y0 += y1;
} }
*x = x0; *x = p0.x();
*y = y0; *y = p0.y();
} }
// //
......
...@@ -395,7 +395,7 @@ int FlowDrawQt::event_handler(QEvent *event) ...@@ -395,7 +395,7 @@ int FlowDrawQt::event_handler(QEvent *event)
} }
case QEvent::MouseButtonPress: { case QEvent::MouseButtonPress: {
QMouseEvent *mouseEvent = ((QMouseEvent *) event); QMouseEvent *mouseEvent = ((QMouseEvent *) event);
debug_print("event_handler: MouseButtonPress button=%d\n", mouseEvent->button()); debug_print("event_handler: MouseButtonPress button=%d, x=%d, y=%d, globalX=%d, globalY=%d\n", mouseEvent->button(), mouseEvent->x(), mouseEvent->y(), mouseEvent->globalX(), mouseEvent->globalY());
switch (mouseEvent->button()) { switch (mouseEvent->button()) {
case Qt::LeftButton: case Qt::LeftButton:
basectx->event_handler(flow_eEvent_MB1Down, mouseEvent->x(), basectx->event_handler(flow_eEvent_MB1Down, mouseEvent->x(),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment