Commit 953e3291 authored by Amandeep Singh's avatar Amandeep Singh

KMag uses libkdeaccessibilityclient to get focus information

parent 333b494a
......@@ -24,6 +24,7 @@ set(kmag_SRCS
kde4_add_executable(kmag ${kmag_SRCS})
target_link_libraries(kmag ${KDE4_KIO_LIBS})
target_link_libraries(kmag kdeaccessibilityclient)
install(TARGETS kmag ${INSTALL_TARGETS_DEFAULT_ARGS} )
......
......@@ -49,6 +49,7 @@
#include <kcursor.h>
#include <kdebug.h>
#include <klocale.h>
#include <kdeaccessibilityclient/accessibleobject.h>
// include bitmaps for cursors
static uchar left_ptr_bits[] = {
......@@ -137,6 +138,9 @@ KMagZoomView::KMagZoomView(QWidget *parent, const char *name)
if(m_fitToWindow)
fitToWindow();
//subscribe to focus events from registry
m_registry.subscribeEventListeners(KAccessibleClient::Registry::Focus);
}
KMagZoomView::~KMagZoomView()
......@@ -214,20 +218,23 @@ void KMagZoomView::followFocus(bool follow)
if(follow) {
setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
if(QDBusConnection::sessionBus().isConnected())
QDBusConnection::sessionBus().connect(QLatin1String( "org.kde.kaccessibleapp" ), QLatin1String( "/Adaptor" ), QLatin1String( "org.kde.kaccessibleapp.Adaptor" ), QLatin1String( "focusChanged" ), this, SLOT(focusChanged(int,int,int,int,int,int)));
connect(&m_registry,SIGNAL(focusChanged(const KAccessibleClient::AccessibleObject &)),
this, SLOT(focusChanged(const KAccessibleClient::AccessibleObject &)));
} else {
setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOn);
setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOn);
if(QDBusConnection::sessionBus().isConnected())
QDBusConnection::sessionBus().disconnect(QLatin1String( "org.kde.kaccessibleapp" ), QLatin1String( "/Adaptor" ), QLatin1String( "org.kde.kaccessibleapp.Adaptor" ), QLatin1String( "focusChanged" ), this, SLOT(focusChanged(int,int,int,int,int,int)));
disconnect(&m_registry, SIGNAL(focusChanged(const KAccessibleClient::AccessibleObject &)),
this, SLOT(focusChanged(const KAccessibleClient::AccessibleObject &)));
}
}
void KMagZoomView::focusChanged(int px, int py, int rx, int ry, int rwidth, int rheight)
void KMagZoomView::focusChanged(const KAccessibleClient::AccessibleObject &object)
{
//kDebug() << "px=" << px << "py=" << py << "rx=" << rx << "ry=" << ry << "rwidth=" << rwidth << "rheight=" << rheight;
m_oldFocus = (px >= 0 && py >= 0) ? QPoint(px, py) : QPoint( rx + qMax(0, (qMin(width(), rwidth)/2)-60), ry + qMax(0, (qMin(height(), rheight)/2)-60) );
m_oldFocus = object.focusPoint();
qDebug() << m_oldFocus;
}
/**
......
......@@ -39,6 +39,8 @@
#include <QtGui/QResizeEvent>
#include <QtGui/QMouseEvent>
#include <kdeaccessibilityclient/registry.h>
//class KMagSelRect;
#include "kmagselrect.h"
......@@ -130,7 +132,7 @@ class KMagZoomView : public QAbstractScrollArea
private slots:
/// Called from a dbus service when followFocus is true
void focusChanged(int px, int py, int rx, int ry, int rwidth, int rheight);
void focusChanged(const KAccessibleClient::AccessibleObject &object);
protected:
/// Called when the widget is hidden
......@@ -185,6 +187,9 @@ class KMagZoomView : public QAbstractScrollArea
void setupMatrix();
private:
/// Global Accessibility Registry
KAccessibleClient::Registry m_registry;
/// Stores the pixmap which is recolored from the grabbed one
QPixmap m_coloredPixmap;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment