|
6 | 6 | #include <QQmlComponent> |
7 | 7 | #include <QQuickItem> |
8 | 8 | #include <QQuickWindow> |
| 9 | +#include <QCursor> |
9 | 10 |
|
10 | 11 | #include <CoreApi/runtimeinterface.h> |
11 | 12 |
|
@@ -44,12 +45,18 @@ namespace Core { |
44 | 45 | } |
45 | 46 | auto width = dialog->property("width").toDouble(); |
46 | 47 | auto height = dialog->property("height").toDouble(); |
47 | | - dialog->setProperty("x", window->width() / 2.0 - width / 2); |
48 | | - if (auto popupTopMarginHint = window->property("popupTopMarginHint"); popupTopMarginHint.isValid()) { |
49 | | - // Assume it is project window |
50 | | - dialog->setProperty("y", popupTopMarginHint); |
| 48 | + if (shouldDialogPopupAtCursor) { |
| 49 | + auto pos = window->mapFromGlobal(QCursor::pos()).toPointF(); |
| 50 | + dialog->setProperty("x", qBound(0.0, pos.x(), window->width() - width)); |
| 51 | + dialog->setProperty("y", qBound(0.0, pos.y(), window->height() - height)); |
51 | 52 | } else { |
52 | | - dialog->setProperty("y", window->height() / 2.0 - height / 2); |
| 53 | + dialog->setProperty("x", window->width() / 2.0 - width / 2); |
| 54 | + if (auto popupTopMarginHint = window->property("popupTopMarginHint"); popupTopMarginHint.isValid()) { |
| 55 | + // Assume it is project window |
| 56 | + dialog->setProperty("y", popupTopMarginHint); |
| 57 | + } else { |
| 58 | + dialog->setProperty("y", window->height() / 2.0 - height / 2); |
| 59 | + } |
53 | 60 | } |
54 | 61 | return dialog; |
55 | 62 |
|
@@ -110,6 +117,20 @@ namespace Core { |
110 | 117 | Q_EMIT documentChanged(); |
111 | 118 | } |
112 | 119 | } |
| 120 | + |
| 121 | + bool EditTempoTimeSignatureScenario::shouldDialogPopupAtCursor() const { |
| 122 | + Q_D(const EditTempoTimeSignatureScenario); |
| 123 | + return d->shouldDialogPopupAtCursor; |
| 124 | + } |
| 125 | + |
| 126 | + void EditTempoTimeSignatureScenario::setShouldDialogPopupAtCursor(bool shouldDialogPopupAtCursor) { |
| 127 | + Q_D(EditTempoTimeSignatureScenario); |
| 128 | + if (d->shouldDialogPopupAtCursor != shouldDialogPopupAtCursor) { |
| 129 | + d->shouldDialogPopupAtCursor = shouldDialogPopupAtCursor; |
| 130 | + Q_EMIT shouldDialogPopupAtCursorChanged(); |
| 131 | + } |
| 132 | + } |
| 133 | + |
113 | 134 | void EditTempoTimeSignatureScenario::editTempo() const { |
114 | 135 | Q_D(const EditTempoTimeSignatureScenario); |
115 | 136 | if (!d->projectTimeline) |
@@ -153,14 +174,14 @@ namespace Core { |
153 | 174 | for (auto redundantTempoItem : currentTempos) { |
154 | 175 | if (redundantTempoItem != tempoItem) { |
155 | 176 | tempoSequence->removeItem(redundantTempoItem); |
156 | | - redundantTempoItem->deleteLater(); |
| 177 | + d->document->model()->destroyItem(redundantTempoItem); |
157 | 178 | } |
158 | 179 | } |
159 | 180 | tempoItem->setValue(tempo); |
160 | 181 | } |
161 | 182 | return true; |
162 | 183 | }, [] { |
163 | | - qCWarning(lcEditTempoTimeSignatureScenario) << "Failed to edit tempo in exclusive transaction"; |
| 184 | + qCCritical(lcEditTempoTimeSignatureScenario) << "Failed to edit tempo in exclusive transaction"; |
164 | 185 | }); |
165 | 186 |
|
166 | 187 |
|
@@ -224,15 +245,15 @@ namespace Core { |
224 | 245 | for (auto redundantTimeSignatureItem : currentTimeSignatures) { |
225 | 246 | if (redundantTimeSignatureItem != timeSignatureItem) { |
226 | 247 | timeSignatureSequence->removeItem(redundantTimeSignatureItem); |
227 | | - redundantTimeSignatureItem->deleteLater(); |
| 248 | + d->document->model()->destroyItem(redundantTimeSignatureItem); |
228 | 249 | } |
229 | 250 | } |
230 | 251 | timeSignatureItem->setNumerator(numerator); |
231 | 252 | timeSignatureItem->setDenominator(denominator); |
232 | 253 | } |
233 | 254 | return true; |
234 | 255 | }, [] { |
235 | | - qCWarning(lcEditTempoTimeSignatureScenario) << "Failed to edit tempo in exclusive transaction"; |
| 256 | + qCCritical(lcEditTempoTimeSignatureScenario) << "Failed to edit tempo in exclusive transaction"; |
236 | 257 | }); |
237 | 258 | } |
238 | 259 | void EditTempoTimeSignatureScenario::insertTimeSignatureAt(int position) const { |
|
0 commit comments