summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>2015-12-16 15:55:12 +0100
committerTor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>2015-12-17 17:14:34 +0000
commit420438b5d304f815b65510fa8678beb08bcc4fd2 (patch)
tree30e87ff53de8d827bc0f43c13054c5972c10dec1 /src
parenta1bb00becec04bfb4d775cd8056b6894f4eef198 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qplatformintegration.cpp11
-rw-r--r--src/gui/kernel/qplatformintegration.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.h3
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm5
-rw-r--r--src/plugins/platforms/cocoa/qcocoanativeinterface.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoanativeinterface.mm5
-rw-r--r--src/plugins/platforms/ios/ios.pro2
-rw-r--r--src/plugins/platforms/ios/qiosintegration.h2
-rw-r--r--src/plugins/platforms/ios/qiosintegration.mm9
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.cpp5
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeinterface.cpp5
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeinterface.h2
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp13
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.h2
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.cpp12
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.h1
-rw-r--r--src/widgets/kernel/qapplication.cpp2
18 files changed, 56 insertions, 29 deletions
diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp
index 0968c9deed..82cb4dd399 100644
--- a/src/gui/kernel/qplatformintegration.cpp
+++ b/src/gui/kernel/qplatformintegration.cpp
@@ -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.
diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h
index af89a73455..382e16b4ca 100644
--- a/src/gui/kernel/qplatformintegration.h
+++ b/src/gui/kernel/qplatformintegration.h
@@ -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);
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h
index c7875af83e..7943926ba3 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.h
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.h
@@ -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;
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index e469ec5c74..245cfe33be 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -614,4 +614,9 @@ void QCocoaIntegration::setApplicationIcon(const QIcon &icon) const
[image release];
}
+void QCocoaIntegration::beep() const
+{
+ NSBeep();
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.h b/src/plugins/platforms/cocoa/qcocoanativeinterface.h
index d018c05635..e46a622d3a 100644
--- a/src/plugins/platforms/cocoa/qcocoanativeinterface.h
+++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.h
@@ -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);
diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
index d2d3a7d562..f776f746de 100644
--- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
+++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
@@ -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)
diff --git a/src/plugins/platforms/ios/ios.pro b/src/plugins/platforms/ios/ios.pro
index 236234628d..b1075d3c0f 100644
--- a/src/plugins/platforms/ios/ios.pro
+++ b/src/plugins/platforms/ios/ios.pro
@@ -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 \
diff --git a/src/plugins/platforms/ios/qiosintegration.h b/src/plugins/platforms/ios/qiosintegration.h
index 7d23fe1d62..e670d83a8d 100644
--- a/src/plugins/platforms/ios/qiosintegration.h
+++ b/src/plugins/platforms/ios/qiosintegration.h
@@ -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 --
diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm
index 72c9286f86..37b3866299 100644
--- a/src/plugins/platforms/ios/qiosintegration.mm
+++ b/src/plugins/platforms/ios/qiosintegration.mm
@@ -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)
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp
index 5f22ca1887..f43265be67 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsintegration.cpp
@@ -596,4 +596,9 @@ QPlatformServices *QWindowsIntegration::services() const
return &d->m_services;
}
+void QWindowsIntegration::beep() const
+{
+ MessageBeep(MB_OK); // For QApplication
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsintegration.h b/src/plugins/platforms/windows/qwindowsintegration.h
index cb10bf08f5..a93e2c9856 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.h
+++ b/src/plugins/platforms/windows/qwindowsintegration.h
@@ -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
diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
index 57e33e6322..5b0f6f637e 100644
--- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
+++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
@@ -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();
diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.h b/src/plugins/platforms/windows/qwindowsnativeinterface.h
index 653442de39..48de0f514d 100644
--- a/src/plugins/platforms/windows/qwindowsnativeinterface.h
+++ b/src/plugins/platforms/windows/qwindowsnativeinterface.h
@@ -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);
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp
index 19e8b1de7d..c42ea627a8 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.cpp
+++ b/src/plugins/platforms/xcb/qxcbintegration.cpp
@@ -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
diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h
index 4e2a3c2bbd..f833015596 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.h
+++ b/src/plugins/platforms/xcb/qxcbintegration.h
@@ -104,6 +104,8 @@ public:
void sync() Q_DECL_OVERRIDE;
+ void beep() const Q_DECL_OVERRIDE;
+
static QXcbIntegration *instance() { return m_instance; }
private:
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
index 8a47fe1b43..1403cee622 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
@@ -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)
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h
index c823b474ab..fdda10e307 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.h
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h
@@ -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();
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index a843fdeda5..095ab3005d 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -4116,7 +4116,7 @@ bool QApplication::isEffectEnabled(Qt::UIEffect effect)
*/
void QApplication::beep()
{
- QMetaObject::invokeMethod(QGuiApplication::platformNativeInterface(), "beep");
+ QGuiApplicationPrivate::platformIntegration()->beep();
}
/*!