forked from goldendict/goldendict
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmouseover.hh
71 lines (50 loc) · 1.62 KB
/
mouseover.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef __MOUSEOVER_HH_INCLUDED__
#define __MOUSEOVER_HH_INCLUDED__
#include <QObject>
#include "config.hh"
#include "keyboardstate.hh"
#ifdef Q_OS_WIN32
#include <windows.h>
#endif
/// This is a mouseover feature interface, where you can point your mouse at
/// any word in any window and wait a little, and it would provide that word
/// for the translation.
/// This interface always exists, even on platforms that don't support that
/// feature -- it just remains dormant on them.
///
/// The Windows platform is the only one supported; it works with the help of
/// two external .dll files,
class MouseOver: public QObject, public KeyboardState
{
Q_OBJECT
public:
/// The class is a singleton.
static MouseOver & instance();
/// Enables mouseover. The mouseover is initially disabled.
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 &, bool forcePopup );
#ifdef Q_OS_WIN32
/// Ask for source window is GoldenDict window
bool isGoldenDictWindow( HWND hwnd );
#endif
private:
MouseOver();
~MouseOver();
Config::Preferences const *pPref;
#ifdef Q_OS_WIN32
static LRESULT CALLBACK eventHandler( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam );
typedef void ( *ActivateSpyFn )( bool );
ActivateSpyFn activateSpyFn;
HINSTANCE spyDll;
bool mouseOverEnabled;
/// Create mask for scan methods
LRESULT makeScanBitMask();
#endif
};
#endif