mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
Move some checks from ScanPopup into MouseOver
This commit is contained in:
parent
68c80f48b2
commit
a11774483d
24
mouseover.cc
24
mouseover.cc
|
@ -83,7 +83,8 @@ static void SetLowLabelToGDSynchroObjects()
|
|||
|
||||
#endif // Q_OS_WIN32
|
||||
|
||||
MouseOver::MouseOver()
|
||||
MouseOver::MouseOver() :
|
||||
pPref(NULL)
|
||||
{
|
||||
#ifdef Q_OS_WIN32
|
||||
HMODULE hm;
|
||||
|
@ -167,13 +168,30 @@ void MouseOver::disableMouseOver()
|
|||
|
||||
#ifdef Q_OS_WIN32
|
||||
|
||||
LRESULT MouseOver::makeScanBitMask()
|
||||
{
|
||||
LRESULT res = 0;
|
||||
if( pPref == NULL )
|
||||
return 0;
|
||||
if( !pPref->enableScanPopupModifiers || checkModifiersPressed( pPref->scanPopupModifiers ) ) {
|
||||
res = GD_FLAG_METHOD_STANDARD;
|
||||
if( pPref->scanPopupUseUIAutomation !=0 )
|
||||
res |= GD_FLAG_METHOD_UI_AUTOMATION;
|
||||
if( pPref->scanPopupUseIAccessibleEx !=0 )
|
||||
res |= GD_FLAG_METHOD_IACCESSIBLEEX;
|
||||
if( pPref->scanPopupUseGDMessage !=0 )
|
||||
res |= GD_FLAG_METHOD_GD_MESSAGE;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK MouseOver::eventHandler( HWND hwnd, UINT msg,
|
||||
WPARAM wparam, LPARAM lparam )
|
||||
{
|
||||
if ( msg == WM_MY_SHOW_TRANSLATION )
|
||||
{
|
||||
LRESULT res = 0;
|
||||
emit instance().getScanBitMask( &res );
|
||||
LRESULT res = instance().makeScanBitMask();
|
||||
|
||||
if( res == 0 )
|
||||
return 0; // Don't handle word without necessity
|
||||
|
||||
|
|
19
mouseover.hh
19
mouseover.hh
|
@ -2,6 +2,8 @@
|
|||
#define __MOUSEOVER_HH_INCLUDED__
|
||||
|
||||
#include <QObject>
|
||||
#include "config.hh"
|
||||
#include "keyboardstate.hh"
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
#include <windows.h>
|
||||
|
@ -15,7 +17,7 @@
|
|||
///
|
||||
/// The Windows platform is the only one supported; it works with the help of
|
||||
/// two external .dll files,
|
||||
class MouseOver: public QObject
|
||||
class MouseOver: public QObject, public KeyboardState
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -28,24 +30,22 @@ public:
|
|||
void enableMouseOver();
|
||||
/// Disables mouseover.
|
||||
void disableMouseOver();
|
||||
|
||||
/// Set pointer to program configuration
|
||||
void setPreferencesPtr( Config::Preferences const *ppref ) { pPref = ppref; };
|
||||
|
||||
signals:
|
||||
|
||||
/// Emitted when there was some text under cursor which was hovered over.
|
||||
void hovered( QString const & );
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
|
||||
/// Ask mask for scan methods
|
||||
void getScanBitMask( LRESULT * );
|
||||
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
MouseOver();
|
||||
~MouseOver();
|
||||
|
||||
Config::Preferences const *pPref;
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
|
||||
static LRESULT CALLBACK eventHandler( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam );
|
||||
|
@ -55,6 +55,9 @@ private:
|
|||
HINSTANCE spyDll;
|
||||
bool mouseOverEnabled;
|
||||
|
||||
/// Create mask for scan methods
|
||||
LRESULT makeScanBitMask();
|
||||
|
||||
#endif
|
||||
|
||||
};
|
||||
|
|
29
scanpopup.cc
29
scanpopup.cc
|
@ -153,12 +153,7 @@ ScanPopup::ScanPopup( QWidget * parent,
|
|||
connect( &mouseGrabPollTimer, SIGNAL( timeout() ),
|
||||
this, SLOT(mouseGrabPoll()) );
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
|
||||
connect( &MouseOver::instance(), SIGNAL( getScanBitMask( LRESULT * ) ),
|
||||
this, SLOT( makeScanBitMask( LRESULT * ) ), Qt::DirectConnection );
|
||||
|
||||
#endif
|
||||
MouseOver::instance().setPreferencesPtr( &( cfg.preferences ) );
|
||||
}
|
||||
|
||||
ScanPopup::~ScanPopup()
|
||||
|
@ -771,25 +766,3 @@ void ScanPopup::mutedDictionariesChanged()
|
|||
if ( dictionaryBar.toggleViewAction()->isChecked() )
|
||||
definition->updateMutedContents();
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
|
||||
void ScanPopup::makeScanBitMask( LRESULT *pMask )
|
||||
{
|
||||
if( cfg.preferences.enableScanPopupModifiers && !checkModifiersPressed( cfg.preferences.scanPopupModifiers ) )
|
||||
{
|
||||
*pMask = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pMask = GD_FLAG_METHOD_STANDARD;
|
||||
if( cfg.preferences.scanPopupUseUIAutomation != 0 )
|
||||
*pMask |= GD_FLAG_METHOD_UI_AUTOMATION;
|
||||
if( cfg.preferences.scanPopupUseIAccessibleEx != 0 )
|
||||
*pMask |= GD_FLAG_METHOD_IACCESSIBLEEX;
|
||||
if( cfg.preferences.scanPopupUseGDMessage != 0 )
|
||||
*pMask |= GD_FLAG_METHOD_GD_MESSAGE;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // Q_OS_WIN32
|
||||
|
|
|
@ -15,10 +15,6 @@
|
|||
#include "history.hh"
|
||||
#include "dictionarybar.hh"
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
#include "mouseover_win32/ThTypes.h"
|
||||
#endif
|
||||
|
||||
/// This is a popup dialog to show translations when clipboard scanning mode
|
||||
/// is enabled.
|
||||
class ScanPopup: public QMainWindow, KeyboardState
|
||||
|
@ -138,10 +134,6 @@ private slots:
|
|||
void altModeExpired();
|
||||
void altModePoll();
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
void makeScanBitMask( LRESULT *pMask );
|
||||
#endif
|
||||
|
||||
/// Called repeatedly once the popup is initially engaged and we monitor the
|
||||
/// mouse as it may move away from the window. This simulates mouse grab, in
|
||||
/// essense, but seems more reliable. Once the mouse enters the window, the
|
||||
|
|
Loading…
Reference in a new issue