-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsipfixer.cpp
61 lines (53 loc) · 1.59 KB
/
sipfixer.cpp
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
#include <QApplication>
#include <QInputContext>
#include <QDebug>
#include <qplatformdefs.h>
#include "sipfixer.h"
static SipFixer *instance_;
SipFixer *SipFixer::instance() {
if (!instance_) {
instance_ = new SipFixer();
}
return instance_;
}
void SipFixer::close() {
delete instance_;
instance_ = 0;
}
SipFixer::SipFixer(QObject *parent): QObject(parent), prevFocusWidget(0), enabled_(false) {
}
bool SipFixer::eventFilter(QObject *obj, QEvent *event) {
#if defined(MEEGO_EDITION_HARMATTAN)
if (enabled_) {
QInputContext *ic = qApp->inputContext();
if (ic) {
QWidget *focusWidget = ic->focusWidget();
if (!focusWidget && prevFocusWidget) {
qDebug() << "SipFixer::eventFilter: Close SIP";
QEvent closeSIPEvent(QEvent::CloseSoftwareInputPanel);
ic->filterEvent(&closeSIPEvent);
} else if (!prevFocusWidget && focusWidget) {
qDebug() << "SipFixer::eventFilter: Open SIP";
QEvent openSIPEvent(QEvent::RequestSoftwareInputPanel);
ic->filterEvent(&openSIPEvent);
}
prevFocusWidget = focusWidget;
}
}
#endif
return QObject::eventFilter(obj, event);
}
bool SipFixer::enabled() {
return enabled_;
}
void SipFixer::setEnabled(bool v) {
enabled_ = v;
if (!enabled_) {
QInputContext *ic = qApp->inputContext();
if (ic) {
QEvent closeSipEvent(QEvent::CloseSoftwareInputPanel);
ic->filterEvent(&closeSipEvent);
}
}
emit enabledChanged();
}