mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
Mac-specific: Adjust code for MacOS 10.9
This commit is contained in:
parent
8644ef0c1d
commit
ff44dcebf2
|
@ -31,6 +31,8 @@ public:
|
|||
|
||||
/// Called from event loop callback
|
||||
void mouseMoved();
|
||||
|
||||
static bool isAXAPIEnabled();
|
||||
|
||||
signals:
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue