diff options
Diffstat (limited to 'src')
18 files changed, 56 insertions, 29 deletions
| diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index 0968c9deed1..82cb4dd399f 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 af89a734552..382e16b4ca2 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 c7875af83e1..7943926ba33 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 e469ec5c74c..245cfe33beb 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 d018c056357..e46a622d3a4 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 d2d3a7d562d..f776f746de1 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 236234628d0..b1075d3c0f6 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 7d23fe1d620..e670d83a8d7 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 72c9286f861..37b38662994 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 5f22ca18877..f43265be679 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 cb10bf08f59..a93e2c98569 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 57e33e63223..5b0f6f637ee 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 653442de399..48de0f514d5 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 19e8b1de7d7..c42ea627a83 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 4e2a3c2bbdc..f833015596b 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 8a47fe1b43c..1403cee622e 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 c823b474abd..fdda10e307f 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 a843fdeda54..095ab3005db 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();  }  /*! | 
