Cocoa: Add setAlertState(), isAlertState(), beep() functions
Also, fix operator precedence error in QApplication::alert(). Change-Id: I140ccfba29638d24bc1c97f5f9a9611f66eb6b8f Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
This commit is contained in:
parent
1f6ab6a661
commit
f2fa65e4bf
@ -65,6 +65,8 @@ public:
|
||||
|
||||
NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource) Q_DECL_OVERRIDE;
|
||||
|
||||
Q_INVOKABLE void beep();
|
||||
|
||||
static void *cglContextForContext(QOpenGLContext *context);
|
||||
static void *nsOpenGLContextForContext(QOpenGLContext* context);
|
||||
|
||||
|
@ -124,6 +124,11 @@ QPlatformNativeInterface::NativeResourceForIntegrationFunction QCocoaNativeInter
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QCocoaNativeInterface::beep()
|
||||
{
|
||||
NSBeep();
|
||||
}
|
||||
|
||||
QPlatformPrinterSupport *QCocoaNativeInterface::createPlatformPrinterSupport()
|
||||
{
|
||||
#ifndef QT_NO_WIDGETS
|
||||
|
@ -106,6 +106,8 @@ public:
|
||||
void setWindowTitle(const QString &title);
|
||||
void setWindowFilePath(const QString &filePath);
|
||||
void setWindowIcon(const QIcon &icon);
|
||||
void setAlertState(bool enabled);
|
||||
bool isAlertState() const;
|
||||
void raise();
|
||||
void lower();
|
||||
bool isExposed() const;
|
||||
@ -190,6 +192,9 @@ public: // for QNSView
|
||||
bool m_frameStrutEventsEnabled;
|
||||
bool m_isExposed;
|
||||
int m_registerTouchCount;
|
||||
|
||||
static const int NoAlertRequest;
|
||||
NSInteger m_alertRequest;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -188,6 +188,8 @@ static bool isMouseEvent(NSEvent *ev)
|
||||
|
||||
@end
|
||||
|
||||
const int QCocoaWindow::NoAlertRequest = -1;
|
||||
|
||||
QCocoaWindow::QCocoaWindow(QWindow *tlw)
|
||||
: QPlatformWindow(tlw)
|
||||
, m_nsWindow(0)
|
||||
@ -202,6 +204,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
|
||||
, m_frameStrutEventsEnabled(false)
|
||||
, m_isExposed(false)
|
||||
, m_registerTouchCount(0)
|
||||
, m_alertRequest(NoAlertRequest)
|
||||
{
|
||||
#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG
|
||||
qDebug() << "QCocoaWindow::QCocoaWindow" << this;
|
||||
@ -496,6 +499,21 @@ void QCocoaWindow::setWindowIcon(const QIcon &icon)
|
||||
}
|
||||
}
|
||||
|
||||
void QCocoaWindow::setAlertState(bool enabled)
|
||||
{
|
||||
if (m_alertRequest == NoAlertRequest && enabled) {
|
||||
m_alertRequest = [NSApp requestUserAttention:NSCriticalRequest];
|
||||
} else if (m_alertRequest != NoAlertRequest && !enabled) {
|
||||
[NSApp cancelUserAttentionRequest:m_alertRequest];
|
||||
m_alertRequest = NoAlertRequest;
|
||||
}
|
||||
}
|
||||
|
||||
bool QCocoaWindow::isAlertState() const
|
||||
{
|
||||
return m_alertRequest != NoAlertRequest;
|
||||
}
|
||||
|
||||
void QCocoaWindow::raise()
|
||||
{
|
||||
//qDebug() << "raise" << this;
|
||||
|
@ -415,7 +415,7 @@ void QApplication::beep()
|
||||
void QApplication::alert(QWidget *widget, int duration)
|
||||
{
|
||||
if (widget) {
|
||||
if (widget->window()->isActiveWindow()&& !widget->window()->windowState() & Qt::WindowMinimized)
|
||||
if (widget->window()->isActiveWindow() && !(widget->window()->windowState() & Qt::WindowMinimized))
|
||||
return;
|
||||
if (QWindow *window= QApplicationPrivate::windowForWidget(widget))
|
||||
window->alert(duration);
|
||||
|
Loading…
Reference in New Issue
Block a user