iOS: Implement support for QApplication::beep()
Vibrates the device or plays an alert sound on devices that do not support vibration. The other implementations of beep() have been moved to QPlatformIntegration as a proper API instead of having them as invokables in QPlatformNativeInterface. Change-Id: Ic597dbef04b46d49862b070e78ddfc0d763829a2 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com> Reviewed-by: Kai Uwe Broulik <kde@privat.broulik.de>
This commit is contained in:
parent
a1bb00bece
commit
420438b5d3
@ -557,6 +557,17 @@ void QPlatformIntegration::sync()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 5.7
|
||||
|
||||
Should sound a bell, using the default volume and sound.
|
||||
|
||||
\sa QApplication::beep()
|
||||
*/
|
||||
void QPlatformIntegration::beep() const
|
||||
{
|
||||
}
|
||||
|
||||
#ifndef QT_NO_OPENGL
|
||||
/*!
|
||||
Platform integration function for querying the OpenGL implementation type.
|
||||
|
@ -176,6 +176,8 @@ public:
|
||||
|
||||
void removeScreen(QScreen *screen);
|
||||
|
||||
virtual void beep() const;
|
||||
|
||||
protected:
|
||||
void screenAdded(QPlatformScreen *screen, bool isPrimary = false);
|
||||
void destroyScreen(QPlatformScreen *screen);
|
||||
|
@ -148,6 +148,9 @@ public:
|
||||
QList<QCocoaWindow *> *popupWindowStack();
|
||||
|
||||
void setApplicationIcon(const QIcon &icon) const Q_DECL_OVERRIDE;
|
||||
|
||||
void beep() const Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
static QCocoaIntegration *mInstance;
|
||||
Options mOptions;
|
||||
|
@ -614,4 +614,9 @@ void QCocoaIntegration::setApplicationIcon(const QIcon &icon) const
|
||||
[image release];
|
||||
}
|
||||
|
||||
void QCocoaIntegration::beep() const
|
||||
{
|
||||
NSBeep();
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -60,8 +60,6 @@ public:
|
||||
|
||||
NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource) Q_DECL_OVERRIDE;
|
||||
|
||||
Q_INVOKABLE void beep();
|
||||
|
||||
#ifndef QT_NO_OPENGL
|
||||
static void *cglContextForContext(QOpenGLContext *context);
|
||||
static void *nsOpenGLContextForContext(QOpenGLContext* context);
|
||||
|
@ -139,11 +139,6 @@ QPlatformNativeInterface::NativeResourceForIntegrationFunction QCocoaNativeInter
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QCocoaNativeInterface::beep()
|
||||
{
|
||||
NSBeep();
|
||||
}
|
||||
|
||||
QPlatformPrinterSupport *QCocoaNativeInterface::createPlatformPrinterSupport()
|
||||
{
|
||||
#if !defined(QT_NO_WIDGETS) && !defined(QT_NO_PRINTER)
|
||||
|
@ -6,7 +6,7 @@ PLUGIN_CLASS_NAME = QIOSIntegrationPlugin
|
||||
load(qt_plugin)
|
||||
|
||||
QT += core-private gui-private platformsupport-private
|
||||
LIBS += -framework Foundation -framework UIKit -framework QuartzCore -framework AssetsLibrary
|
||||
LIBS += -framework Foundation -framework UIKit -framework QuartzCore -framework AssetsLibrary -framework AudioToolbox
|
||||
|
||||
OBJECTIVE_SOURCES = \
|
||||
plugin.mm \
|
||||
|
@ -82,6 +82,8 @@ public:
|
||||
void addScreen(QPlatformScreen *screen) { screenAdded(screen); }
|
||||
void destroyScreen(QPlatformScreen *screen) { QPlatformIntegration::destroyScreen(screen); }
|
||||
|
||||
void beep() const Q_DECL_OVERRIDE;
|
||||
|
||||
static QIOSIntegration *instance();
|
||||
|
||||
// -- QPlatformNativeInterface --
|
||||
|
@ -53,6 +53,8 @@
|
||||
#include <QtPlatformSupport/private/qmacmime_p.h>
|
||||
#include <QDir>
|
||||
|
||||
#import <AudioToolbox/AudioServices.h>
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@ -266,6 +268,13 @@ QPlatformNativeInterface *QIOSIntegration::nativeInterface() const
|
||||
return const_cast<QIOSIntegration *>(this);
|
||||
}
|
||||
|
||||
void QIOSIntegration::beep() const
|
||||
{
|
||||
#if !TARGET_IPHONE_SIMULATOR
|
||||
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
|
||||
#endif
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
void *QIOSIntegration::nativeResourceForWindow(const QByteArray &resource, QWindow *window)
|
||||
|
@ -596,4 +596,9 @@ QPlatformServices *QWindowsIntegration::services() const
|
||||
return &d->m_services;
|
||||
}
|
||||
|
||||
void QWindowsIntegration::beep() const
|
||||
{
|
||||
MessageBeep(MB_OK); // For QApplication
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -96,6 +96,8 @@ public:
|
||||
|
||||
unsigned options() const;
|
||||
|
||||
void beep() const Q_DECL_OVERRIDE;
|
||||
|
||||
#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
|
||||
QPlatformSessionManager *createPlatformSessionManager(const QString &id, const QString &key) const Q_DECL_OVERRIDE;
|
||||
#endif
|
||||
|
@ -211,11 +211,6 @@ QString QWindowsNativeInterface::registerWindowClass(const QString &classNameIn,
|
||||
return QWindowsContext::instance()->registerWindowClass(classNameIn, (WNDPROC)eventProc);
|
||||
}
|
||||
|
||||
void QWindowsNativeInterface::beep()
|
||||
{
|
||||
MessageBeep(MB_OK); // For QApplication
|
||||
}
|
||||
|
||||
bool QWindowsNativeInterface::asyncExpose() const
|
||||
{
|
||||
return QWindowsContext::instance()->asyncExpose();
|
||||
|
@ -75,8 +75,6 @@ public:
|
||||
|
||||
Q_INVOKABLE QString registerWindowClass(const QString &classNameIn, void *eventProc) const;
|
||||
|
||||
Q_INVOKABLE void beep();
|
||||
|
||||
Q_INVOKABLE void registerWindowsMime(void *mimeIn);
|
||||
Q_INVOKABLE void unregisterWindowsMime(void *mime);
|
||||
Q_INVOKABLE int registerMimeType(const QString &mimeType);
|
||||
|
@ -454,4 +454,17 @@ void QXcbIntegration::sync()
|
||||
}
|
||||
}
|
||||
|
||||
// For QApplication::beep()
|
||||
void QXcbIntegration::beep() const
|
||||
{
|
||||
QScreen *priScreen = QGuiApplication::primaryScreen();
|
||||
if (!priScreen)
|
||||
return;
|
||||
QPlatformScreen *screen = priScreen->handle();
|
||||
if (!screen)
|
||||
return;
|
||||
xcb_connection_t *connection = static_cast<QXcbScreen *>(screen)->xcb_connection();
|
||||
xcb_bell(connection, 0);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -104,6 +104,8 @@ public:
|
||||
|
||||
void sync() Q_DECL_OVERRIDE;
|
||||
|
||||
void beep() const Q_DECL_OVERRIDE;
|
||||
|
||||
static QXcbIntegration *instance() { return m_instance; }
|
||||
|
||||
private:
|
||||
|
@ -92,18 +92,6 @@ QXcbNativeInterface::QXcbNativeInterface() :
|
||||
{
|
||||
}
|
||||
|
||||
void QXcbNativeInterface::beep() // For QApplication::beep()
|
||||
{
|
||||
QScreen *priScreen = QGuiApplication::primaryScreen();
|
||||
if (!priScreen)
|
||||
return;
|
||||
QPlatformScreen *screen = priScreen->handle();
|
||||
if (!screen)
|
||||
return;
|
||||
xcb_connection_t *connection = static_cast<QXcbScreen *>(screen)->xcb_connection();
|
||||
xcb_bell(connection, 0);
|
||||
}
|
||||
|
||||
static inline QXcbSystemTrayTracker *systemTrayTracker(const QScreen *s)
|
||||
{
|
||||
if (!s)
|
||||
|
@ -108,7 +108,6 @@ public:
|
||||
static void setAppTime(QScreen *screen, xcb_timestamp_t time);
|
||||
static void setAppUserTime(QScreen *screen, xcb_timestamp_t time);
|
||||
|
||||
Q_INVOKABLE void beep();
|
||||
Q_INVOKABLE bool systemTrayAvailable(const QScreen *screen) const;
|
||||
Q_INVOKABLE void setParentRelativeBackPixmap(QWindow *window);
|
||||
Q_INVOKABLE bool systrayVisualHasAlphaChannel();
|
||||
|
@ -4116,7 +4116,7 @@ bool QApplication::isEffectEnabled(Qt::UIEffect effect)
|
||||
*/
|
||||
void QApplication::beep()
|
||||
{
|
||||
QMetaObject::invokeMethod(QGuiApplication::platformNativeInterface(), "beep");
|
||||
QGuiApplicationPrivate::platformIntegration()->beep();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
Loading…
x
Reference in New Issue
Block a user