Commit ef00f675 authored by Christoffer Ackelman's avatar Christoffer Ackelman

Fixed popup menu location

parent 1902e0b9
......@@ -79,6 +79,7 @@ extern "C" {
#include <QColor>
#include <QInputDialog>
#include <QScrollArea>
#include <QTimer>
#include <QVBoxLayout>
......@@ -102,11 +103,11 @@ WNavQt::WNavQt(void *xn_parent_ctx, QWidget *xn_parent_wid, const char *xn_name,
trace_obj = new WNavQtTraceObject(this);
debug_print("creating a scrolledbrowwidgetqt\n");
QWidget *scrolledbrow =
scrolledbrowwidgetqt_new(WNav::init_brow_base_cb, this, &brow_widget);
QScrollArea *scrolledbrow = ((QScrollArea *)
scrolledbrowwidgetqt_new(WNav::init_brow_base_cb, this, &brow_widget));
scrolledbrow->setStyleSheet("QMainWindow{border: 3px solid black;}");
scrolledbrow->setFrameShape(QFrame::Box);
scrolledbrow->setLineWidth(3);
showNow(brow_widget);
......
......@@ -613,7 +613,8 @@ int WttQt::create_popup_menu(pwr_sAttrRef aref, int x, int y)
} else {
return 0;
}
popupmenu_x += 10;
popupmenu_x += palette_paned->pos().x();
popupmenu_y += palette_paned->pos().y();
// Create the menu
sts = get_popup_menu_items(aref, pwr_cNCid);
......@@ -2560,6 +2561,7 @@ QMenu *WttQt::build_submenu(int MenuType, const char *MenuTitle,
if (Items[idx].Item == ldh_eMenuItem_Cascade) {
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,
idx + 1);
sub->addMenu(w);
......
......@@ -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)
{
return QString::fromLocal8Bit(text);
......
......@@ -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(QString str);
#define debug_print(fmt, args...) \
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,
int x1 = 0;
int y1 = 0;
int x0 = (int) x_event;
int y0 = (int) y_event;
QPoint p0((int) x_event, (int) y_event);
grandparent = parent->parentWidget();
while (!grandparent->isWindow()) {
if (!x1 && !y1 && (parent->pos().x() || parent->pos().y())) {
// Add first widget with nonzero position
x1 = parent->pos().x();
y1 = parent->pos().y();
x0 += x1;
y0 += y1;
if ( !x1 && !y1 && (parent->geometry().x() || parent->geometry().y())) {
x1 = parent->geometry().x();
y1 = parent->geometry().y();
p0 = parent->mapToParent(p0);
}
parent = grandparent;
grandparent = parent->parentWidget();
}
if (grandparent) {
// Add window widget position
x1 = grandparent->pos().x();
y1 = grandparent->pos().y();
x0 += x1;
y0 += y1;
p0 = grandparent->mapToParent(p0);
}
*x = x0;
*y = y0;
*x = p0.x();
*y = p0.y();
}
//
......
......@@ -395,7 +395,7 @@ int FlowDrawQt::event_handler(QEvent *event)
}
case QEvent::MouseButtonPress: {
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()) {
case Qt::LeftButton:
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