-
Notifications
You must be signed in to change notification settings - Fork 0
/
qcolordialog-position.patch
86 lines (76 loc) · 3 KB
/
qcolordialog-position.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp
index f69efe0..1a12b75 100644
--- a/src/gui/kernel/qplatformdialoghelper.cpp
+++ b/src/gui/kernel/qplatformdialoghelper.cpp
@@ -396,6 +396,16 @@ void QPlatformColorDialogHelper::setOptions(const QSharedPointer<QColorDialogOpt
m_options = options;
}
+void QPlatformColorDialogHelper::setPosition(const QPoint position)
+{
+ m_position = position;
+}
+
+QPoint QPlatformColorDialogHelper::position(void)
+{
+ return m_position;
+}
+
// File dialog
class QFileDialogOptionsPrivate : public QSharedData
diff --git a/src/gui/kernel/qplatformdialoghelper.h b/src/gui/kernel/qplatformdialoghelper.h
index 936dbdf..7b7d61b 100644
--- a/src/gui/kernel/qplatformdialoghelper.h
+++ b/src/gui/kernel/qplatformdialoghelper.h
@@ -46,6 +46,7 @@
#include <QtCore/QtGlobal>
#include <QtCore/QObject>
#include <QtCore/QList>
+#include <QtCore/QPoint>
#include <QtCore/QSharedDataPointer>
#include <QtCore/QSharedPointer>
#include <QtCore/QDir>
@@ -212,6 +212,8 @@ class Q_GUI_EXPORT QPlatformColorDialogHelper : public QPlatformDialogHelper
public:
const QSharedPointer<QColorDialogOptions> &options() const;
void setOptions(const QSharedPointer<QColorDialogOptions> &options);
+ void setPosition(const QPoint position);
+ QPoint position(void);
virtual void setCurrentColor(const QColor &) = 0;
virtual QColor currentColor() const = 0;
@@ -222,6 +224,7 @@ Q_SIGNALS:
private:
QSharedPointer<QColorDialogOptions> m_options;
+ QPoint m_position;
};
class Q_GUI_EXPORT QFontDialogOptions
diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
index 41ebd08..04373f7 100644
--- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
@@ -44,6 +44,7 @@
#include "qcocoacolordialoghelper.h"
#include "qcocoahelpers.h"
#include "qcocoaeventdispatcher.h"
+#include "qcocoascreen.h"
#import <AppKit/AppKit.h>
@@ -112,6 +113,8 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPa
{
mHelper = helper;
+ [mColorPanel setFrameTopLeftPoint:QCocoaScreen::mapToNative(mHelper->position())];
+
if (mHelper->options()->testOption(QColorDialogOptions::NoButtons)) {
[self restoreOriginalContentView];
} else if (!mStolenContentView) {
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp
index 468bffe..dfeca9f 100644
--- a/src/widgets/dialogs/qcolordialog.cpp
+++ b/src/widgets/dialogs/qcolordialog.cpp
@@ -1873,8 +1873,9 @@ void QColorDialogPrivate::initHelper(QPlatformDialogHelper *h)
static_cast<QPlatformColorDialogHelper *>(h)->setOptions(options);
}
-void QColorDialogPrivate::helperPrepareShow(QPlatformDialogHelper *)
+void QColorDialogPrivate::helperPrepareShow(QPlatformDialogHelper *h)
{
+ static_cast<QPlatformColorDialogHelper *>(h)->setPosition(q_func()->pos());
options->setWindowTitle(q_func()->windowTitle());
}