mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-12-17 23:04:06 +00:00
Mac-specific: Adjust code for MacOS 10.9
This commit is contained in:
parent
8644ef0c1d
commit
ff44dcebf2
|
@ -32,6 +32,8 @@ public:
|
||||||
/// Called from event loop callback
|
/// Called from event loop callback
|
||||||
void mouseMoved();
|
void mouseMoved();
|
||||||
|
|
||||||
|
static bool isAXAPIEnabled();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
/// Emitted when there was some text under cursor which was hovered over.
|
/// Emitted when there was some text under cursor which was hovered over.
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
#include "macmouseover.hh"
|
include "macmouseover.hh"
|
||||||
#include <AppKit/NSTouch.h>
|
#include <AppKit/NSTouch.h>
|
||||||
#include <AppKit/NSEvent.h>
|
#include <AppKit/NSEvent.h>
|
||||||
#include <AppKit/NSScreen.h>
|
#include <AppKit/NSScreen.h>
|
||||||
#include <Foundation/NSAutoreleasePool.h>
|
#include <Foundation/NSAutoreleasePool.h>
|
||||||
|
#include <Foundation/Foundation.h>
|
||||||
|
|
||||||
const int mouseOverInterval = 300;
|
const int mouseOverInterval = 300;
|
||||||
|
|
||||||
|
@ -91,7 +92,7 @@ void MacMouseOver::mouseMoved()
|
||||||
void MacMouseOver::enableMouseOver()
|
void MacMouseOver::enableMouseOver()
|
||||||
{
|
{
|
||||||
mouseTimer.stop();
|
mouseTimer.stop();
|
||||||
if( !AXAPIEnabled() )
|
if( !isAXAPIEnabled() )
|
||||||
return;
|
return;
|
||||||
if( !tapRef )
|
if( !tapRef )
|
||||||
tapRef = CGEventTapCreate( kCGAnnotatedSessionEventTap, kCGHeadInsertEventTap,
|
tapRef = CGEventTapCreate( kCGAnnotatedSessionEventTap, kCGHeadInsertEventTap,
|
||||||
|
@ -318,3 +319,11 @@ void MacMouseOver::handleRetrievedString( QString & wordSeq, int wordSeqPos )
|
||||||
|
|
||||||
emit instance().hovered( word, false );
|
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
|
#ifdef Q_OS_MAC
|
||||||
#include "lionsupport.h"
|
#include "lionsupport.h"
|
||||||
|
#include "macmouseover.hh"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
|
@ -758,7 +759,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
||||||
updateStatusLine();
|
updateStatusLine();
|
||||||
|
|
||||||
#ifdef Q_OS_MACX
|
#ifdef Q_OS_MACX
|
||||||
if( cfg.preferences.startWithScanPopupOn && !AXAPIEnabled() )
|
if( cfg.preferences.startWithScanPopupOn && !MacMouseOver::isAXAPIEnabled() )
|
||||||
mainStatusBar->showMessage( tr( "Accessibility API is not enabled" ), 10000,
|
mainStatusBar->showMessage( tr( "Accessibility API is not enabled" ), 10000,
|
||||||
QPixmap( ":/icons/error.png" ) );
|
QPixmap( ":/icons/error.png" ) );
|
||||||
#endif
|
#endif
|
||||||
|
@ -2768,7 +2769,7 @@ void MainWindow::scanEnableToggled( bool on )
|
||||||
{
|
{
|
||||||
scanPopup->enableScanning();
|
scanPopup->enableScanning();
|
||||||
#ifdef Q_OS_MACX
|
#ifdef Q_OS_MACX
|
||||||
if( !AXAPIEnabled() )
|
if( !MacMouseOver::isAXAPIEnabled() )
|
||||||
mainStatusBar->showMessage( tr( "Accessibility API is not enabled" ), 10000,
|
mainStatusBar->showMessage( tr( "Accessibility API is not enabled" ), 10000,
|
||||||
QPixmap( ":/icons/error.png" ) );
|
QPixmap( ":/icons/error.png" ) );
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue