summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoamessagedialog.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoamessagedialog.h')
-rw-r--r--src/plugins/platforms/cocoa/qcocoamessagedialog.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoamessagedialog.h b/src/plugins/platforms/cocoa/qcocoamessagedialog.h
new file mode 100644
index 0000000000..b8c273469a
--- /dev/null
+++ b/src/plugins/platforms/cocoa/qcocoamessagedialog.h
@@ -0,0 +1,38 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef QCOCOAMESSAGEDIALOG_H
+#define QCOCOAMESSAGEDIALOG_H
+
+#include <qpa/qplatformdialoghelper.h>
+
+Q_FORWARD_DECLARE_OBJC_CLASS(NSAlert);
+typedef long NSInteger;
+typedef NSInteger NSModalResponse;
+
+QT_BEGIN_NAMESPACE
+
+class QEventLoop;
+
+class QCocoaMessageDialog : public QPlatformMessageDialogHelper
+{
+public:
+ QCocoaMessageDialog() = default;
+ ~QCocoaMessageDialog();
+
+ void exec() override;
+ bool show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent) override;
+ void hide() override;
+
+private:
+ Qt::WindowModality modality() const;
+ NSAlert *m_alert = nullptr;
+ QEventLoop *m_eventLoop = nullptr;
+ NSModalResponse runModal() const;
+ void processResponse(NSModalResponse response);
+};
+
+QT_END_NAMESPACE
+
+#endif // QCOCOAMESSAGEDIALOG_H
+