Mac-specific: Adjust code for MacOS 10.9

This commit is contained in:
Abs62 2013-12-26 18:13:10 +04:00
parent 8644ef0c1d
commit ff44dcebf2
3 changed files with 16 additions and 4 deletions

View file

@ -31,6 +31,8 @@ public:
/// Called from event loop callback
void mouseMoved();
static bool isAXAPIEnabled();
signals:

View file

@ -1,8 +1,9 @@
#include "macmouseover.hh"
include "macmouseover.hh"
#include <AppKit/NSTouch.h>
#include <AppKit/NSEvent.h>
#include <AppKit/NSScreen.h>
#include <Foundation/NSAutoreleasePool.h>
#include <Foundation/Foundation.h>
const int mouseOverInterval = 300;
@ -91,7 +92,7 @@ void MacMouseOver::mouseMoved()
void MacMouseOver::enableMouseOver()
{
mouseTimer.stop();
if( !AXAPIEnabled() )
if( !isAXAPIEnabled() )
return;
if( !tapRef )
tapRef = CGEventTapCreate( kCGAnnotatedSessionEventTap, kCGHeadInsertEventTap,
@ -318,3 +319,11 @@ void MacMouseOver::handleRetrievedString( QString & wordSeq, int wordSeqPos )
emit instance().hovered( word, false );
}
bool MacMouseOver::isAXAPIEnabled()
{
if( NSFoundationVersionNumber >= 1000 ) // MacOS 10.9+
return AXIsProcessTrusted();
return AXAPIEnabled();
}

View file

@ -32,6 +32,7 @@
#ifdef Q_OS_MAC
#include "lionsupport.h"
#include "macmouseover.hh"
#endif
#ifdef Q_OS_WIN32
@ -758,7 +759,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
updateStatusLine();
#ifdef Q_OS_MACX
if( cfg.preferences.startWithScanPopupOn && !AXAPIEnabled() )
if( cfg.preferences.startWithScanPopupOn && !MacMouseOver::isAXAPIEnabled() )
mainStatusBar->showMessage( tr( "Accessibility API is not enabled" ), 10000,
QPixmap( ":/icons/error.png" ) );
#endif
@ -2768,7 +2769,7 @@ void MainWindow::scanEnableToggled( bool on )
{
scanPopup->enableScanning();
#ifdef Q_OS_MACX
if( !AXAPIEnabled() )
if( !MacMouseOver::isAXAPIEnabled() )
mainStatusBar->showMessage( tr( "Accessibility API is not enabled" ), 10000,
QPixmap( ":/icons/error.png" ) );
#endif