Commit b821cd4f authored by David Jarvie's avatar David Jarvie
Browse files

Show context menu at correct position on Wayland

parent 103d92c5
...@@ -359,7 +359,7 @@ void DayMatrix::mousePressEvent(QMouseEvent* e) ...@@ -359,7 +359,7 @@ void DayMatrix::mousePressEvent(QMouseEvent* e)
{ {
if (i < mSelStart || i > mSelEnd) if (i < mSelStart || i > mSelEnd)
setMouseSelection(i, i, true); setMouseSelection(i, i, true);
popupMenu(); popupMenu(e->globalPos());
} }
else if (e->button() == Qt::LeftButton) else if (e->button() == Qt::LeftButton)
{ {
...@@ -374,13 +374,13 @@ void DayMatrix::mousePressEvent(QMouseEvent* e) ...@@ -374,13 +374,13 @@ void DayMatrix::mousePressEvent(QMouseEvent* e)
} }
} }
void DayMatrix::popupMenu() void DayMatrix::popupMenu(const QPoint& pos)
{ {
NewAlarmAction newAction(false, QString(), nullptr); NewAlarmAction newAction(false, QString(), nullptr);
QMenu* popup = newAction.menu(); QMenu* popup = newAction.menu();
connect(&newAction, &NewAlarmAction::selected, this, &DayMatrix::newAlarm); connect(&newAction, &NewAlarmAction::selected, this, &DayMatrix::newAlarm);
connect(&newAction, &NewAlarmAction::selectedTemplate, this, &DayMatrix::newAlarmFromTemplate); connect(&newAction, &NewAlarmAction::selectedTemplate, this, &DayMatrix::newAlarmFromTemplate);
popup->exec(QCursor::pos()); popup->exec(pos);
} }
void DayMatrix::mouseReleaseEvent(QMouseEvent* e) void DayMatrix::mouseReleaseEvent(QMouseEvent* e)
......
...@@ -93,7 +93,7 @@ private: ...@@ -93,7 +93,7 @@ private:
bool recalculateToday(); bool recalculateToday();
QString getHolidayLabel(int offset) const; QString getHolidayLabel(int offset) const;
void setMouseSelection(int start, int end, bool emitSignal); void setMouseSelection(int start, int end, bool emitSignal);
void popupMenu(); // pop up a context menu for creating a new alarm void popupMenu(const QPoint&); // pop up a context menu for creating a new alarm
int getDayIndex(const QPoint&) const; // get index of the day located at a point in the matrix int getDayIndex(const QPoint&) const; // get index of the day located at a point in the matrix
// If changes are pending, recalculates which days in the matrix have // If changes are pending, recalculates which days in the matrix have
......
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