Implement QApplication::beep().

Invoke slot "beep" on QPlatformNativeInterface. Implement for
Windows and X11.

Task-number: QTBUG-30416

Change-Id: I2be651165b899e5147818a012001d354827bb090
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
This commit is contained in:
Friedemann Kleint 2013-04-10 14:43:07 +02:00 committed by The Qt Project
parent da01deb0ac
commit 155ff13bb6
4 changed files with 20 additions and 0 deletions

View File

@ -113,6 +113,8 @@ public:
Q_INVOKABLE QString registerWindowClass(const QString &classNameIn, void *eventProc) const;
Q_INVOKABLE void beep() { MessageBeep(MB_OK); } // For QApplication
bool asyncExpose() const;
void setAsyncExpose(bool value);

View File

@ -57,6 +57,10 @@
#include "qglxintegration.h"
#endif
#ifndef XCB_USE_XLIB
# include <stdio.h>
#endif
QT_BEGIN_NAMESPACE
class QXcbResourceMap : public QMap<QByteArray, QXcbNativeInterface::ResourceType>
@ -84,6 +88,16 @@ QXcbNativeInterface::QXcbNativeInterface() :
{
}
void QXcbNativeInterface::beep() // For QApplication::beep()
{
#ifdef XCB_USE_XLIB
::Display *display = (::Display *)nativeResourceForScreen(QByteArrayLiteral("display"), QGuiApplication::primaryScreen());
XBell(display, 0);
#else
fputc(7, stdout);
#endif
}
void *QXcbNativeInterface::nativeResourceForContext(const QByteArray &resourceString, QOpenGLContext *context)
{
QByteArray lowerCaseResource = resourceString.toLower();

View File

@ -53,6 +53,7 @@ class QXcbConnection;
class QXcbNativeInterface : public QPlatformNativeInterface
{
Q_OBJECT
public:
enum ResourceType {
Display,
@ -89,6 +90,8 @@ public:
static void *eglContextForContext(QOpenGLContext *context);
static void *glxContextForContext(QOpenGLContext *context);
Q_INVOKABLE void beep();
private:
const QByteArray m_genericEventFilterType;

View File

@ -409,6 +409,7 @@ QWidget *QApplication::topLevelAt(const QPoint &pos)
void QApplication::beep()
{
QMetaObject::invokeMethod(QGuiApplication::platformNativeInterface(), "beep");
}
void QApplication::alert(QWidget *widget, int duration)