summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarshit Maurya <hmaurya999@gmail.com>2020-05-16 04:01:05 +0530
committerHarshit Maurya <hmaurya999@gmail.com>2020-05-16 04:01:05 +0530
commit3deebd91f84e8baba004f571b7d75884e232ae19 (patch)
tree698a74e34a8623f60be89531954391b2e467b742
parentc8e750602793436447dd065acf0c1cfed11cf2e2 (diff)
parentc2827eee84aab5333bc7f20a33635cd436acb7b5 (diff)
resolve merge conflict
-rw-r--r--src/util/widgethelper.h24
-rw-r--r--src/widget/woverview.cpp7
-rw-r--r--src/widget/wwaveformviewer.cpp22
3 files changed, 44 insertions, 9 deletions
diff --git a/src/util/widgethelper.h b/src/util/widgethelper.h
new file mode 100644
index 0000000000..dc552663a7
--- /dev/null
+++ b/src/util/widgethelper.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#include <QScreen>
+
+namespace mixxx {
+namespace widgethelper {
+/// Returns an adjusted upper left point for displaying the popup
+/// with the given size on the screen, shifting the popup if it would go off
+/// the right or bottom edges of the screen.
+inline QPoint mapPopupToScreen(
+ const QSize& screenSize,
+ const QPoint& popupUpperLeft,
+ const QSize& popupSize) {
+ QPoint newTopLeft = popupUpperLeft;
+ if (popupUpperLeft.x() + popupSize.width() > screenSize.width()) {
+ newTopLeft.setX(screenSize.width() - popupSize.width());
+ }
+ if (popupUpperLeft.y() + popupSize.height() > screenSize.height()) {
+ newTopLeft.setY(screenSize.height() - popupSize.height());
+ }
+ return newTopLeft;
+}
+} // namespace widgethelper
+} // namespace mixxx
diff --git a/src/widget/woverview.cpp b/src/widget/woverview.cpp
index c885c3e65e..a2c6b0bdc5 100644
--- a/src/widget/woverview.cpp
+++ b/src/widget/woverview.cpp
@@ -34,6 +34,7 @@
#include "util/math.h"
#include "util/painterscope.h"
#include "util/timer.h"
+#include "util/widgethelper.h"
#include "waveform/waveform.h"
#include "waveform/waveformwidgetfactory.h"
#include "widget/controlwidgetconnection.h"
@@ -529,7 +530,11 @@ void WOverview::mousePressEvent(QMouseEvent* e) {
}
if (pHoveredCue != nullptr) {
m_pCueMenuPopup->setTrackAndCue(m_pCurrentTrack, pHoveredCue);
- m_pCueMenuPopup->popup(e->globalPos());
+ QPoint cueMenuTopLeft = mixxx::widgethelper::mapPopupToScreen(
+ windowHandle()->screen()->size(),
+ e->globalPos(),
+ m_pCueMenuPopup->size());
+ m_pCueMenuPopup->popup(cueMenuTopLeft);
}
}
}
diff --git a/src/widget/wwaveformviewer.cpp b/src/widget/wwaveformviewer.cpp
index c26977f33a..e475a9fb4c 100644
--- a/src/widget/wwaveformviewer.cpp
+++ b/src/widget/wwaveformviewer.cpp
@@ -1,19 +1,21 @@
-#include <QtDebug>
+#include "widget/wwaveformviewer.h"
+
#include <QDomNode>
-#include <QEvent>
#include <QDragEnterEvent>
-#include <QUrl>
-#include <QPainter>
+#include <QEvent>
#include <QMimeData>
+#include <QPainter>
+#include <QUrl>
+#include <QtDebug>
#include "control/controlobject.h"
#include "control/controlproxy.h"
#include "track/track.h"
-#include "waveform/widgets/waveformwidgetabstract.h"
-#include "widget/wwaveformviewer.h"
-#include "waveform/waveformwidgetfactory.h"
#include "util/dnd.h"
#include "util/math.h"
+#include "util/widgethelper.h"
+#include "waveform/waveformwidgetfactory.h"
+#include "waveform/widgets/waveformwidgetabstract.h"
WWaveformViewer::WWaveformViewer(const char* group, UserSettingsPointer pConfig, QWidget* parent)
: WWidget(parent),
@@ -83,7 +85,11 @@ void WWaveformViewer::mousePressEvent(QMouseEvent* event) {
auto cueAtClickPos = getCuePointerFromCueMark(m_pHoveredMark);
if (cueAtClickPos) {
m_pCueMenuPopup->setTrackAndCue(currentTrack, cueAtClickPos);
- m_pCueMenuPopup->popup(event->globalPos());
+ QPoint cueMenuTopLeft = mixxx::widgethelper::mapPopupToScreen(
+ windowHandle()->screen()->size(),
+ event->globalPos(),
+ m_pCueMenuPopup->size());
+ m_pCueMenuPopup->popup(cueMenuTopLeft);
}
} else {
// If we are scratching then disable and reset because the two shouldn't