Commit 88c3e1c5 authored by Amandeep Singh's avatar Amandeep Singh

Made linking libkdea11yclient and keyboard-focus-tracking optional

parent 0bc696d8
......@@ -4,7 +4,12 @@ find_package(KDE4 REQUIRED)
include (KDE4Defaults)
include (MacroLibrary)
find_package(LibKdeAccessibilityClient)
macro_optional_find_package(LibKdeAccessibilityClient)
macro_log_feature(LibKdeAccessibilityClient_FOUND "libkdeaccessibilityclient" "KDE client-side accessibility library" "https://projects.kde.org/projects/playground/accessibility/libkdeaccessibilityclient" FALSE "" "Required to enable keyboard focus tracking.")
configure_file(
"${PROJECT_SOURCE_DIR}/focustrackconfig.h.in"
"${PROJECT_BINARY_DIR}/focustrackconfig.h")
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
add_definitions( -DQT_NO_CAST_FROM_ASCII )
......@@ -26,10 +31,14 @@ set(kmag_SRCS
kde4_add_executable(kmag ${kmag_SRCS})
target_link_libraries(kmag ${KDE4_KIO_LIBS})
target_link_libraries(kmag kdeaccessibilityclient)
if(LibKdeAccessibilityClient_FOUND)
target_link_libraries(kmag kdeaccessibilityclient)
endif(LibKdeAccessibilityClient_FOUND)
install(TARGETS kmag ${INSTALL_TARGETS_DEFAULT_ARGS} )
macro_display_feature_log()
########### install files ###############
......
#cmakedefine LibKdeAccessibilityClient_FOUND
......@@ -182,6 +182,7 @@ void KmagApp::initActions()
m_modeFollowMouse->setToolTip(i18n("Magnify around the mouse cursor"));
m_modeFollowMouse->setWhatsThis(i18n("If selected, the area around the mouse cursor is magnified"));
#ifdef LibKdeAccessibilityClient_FOUND
m_modeFollowFocus = new KToggleAction(KIcon(QLatin1String( "view-restore" )), i18n("&Follow Focus Mode"), this);
actionCollection()->addAction(QLatin1String( "mode_followfocus" ), m_modeFollowFocus);
connect(m_modeFollowFocus, SIGNAL(triggered(bool)), SLOT(slotModeFollowFocus()));
......@@ -189,6 +190,7 @@ void KmagApp::initActions()
m_modeFollowFocus->setIconText(i18n("Focus"));
m_modeFollowFocus->setToolTip(i18n("Magnify around the keyboard focus"));
m_modeFollowFocus->setWhatsThis(i18n("If selected, the area around the keyboard cursor is magnified"));
#endif
m_modeSelWin = new KToggleAction(KIcon(QLatin1String( "window" )), i18n("Se&lection Window Mode"), this);
actionCollection()->addAction(QLatin1String( "mode_selectionwindow" ), m_modeSelWin);
......@@ -330,8 +332,10 @@ void KmagApp::saveOptions()
if (m_modeFollowMouse->isChecked())
cg.writeEntry("Mode", "followmouse");
#ifdef LibKdeAccessibilityClient_FOUND
else if (m_modeFollowFocus->isChecked())
cg.writeEntry("Mode", "followfocus");
#endif
else if (m_modeWholeScreen->isChecked())
cg.writeEntry("Mode", "wholescreen");
else if (m_modeSelWin->isChecked())
......@@ -385,8 +389,10 @@ void KmagApp::readOptions()
slotModeWholeScreen();
else if (mode == QLatin1String( "selectionwindow" ))
slotModeSelWin();
#ifdef LibKdeAccessibilityClient_FOUND
else if (mode == QLatin1String( "followfocus" ))
slotModeFollowFocus();
#endif
else
slotModeFollowMouse();
......@@ -640,12 +646,14 @@ void KmagApp::slotToggleRefresh()
void KmagApp::slotModeWholeScreen()
{
m_zoomView->followMouse(false);
m_zoomView->followFocus(false);
m_zoomView->setSelRectPos(QRect (0, 0, QApplication::desktop()->width(), QApplication::desktop()->height()));
m_zoomView->showSelRect(false);
m_zoomView->setFitToWindow (false);
m_modeFollowMouse->setChecked(false);
#ifdef LibKdeAccessibilityClient_FOUND
m_zoomView->followFocus(false);
m_modeFollowFocus->setChecked(false);
#endif
m_modeWholeScreen->setChecked(true);
m_modeSelWin->setChecked(false);
}
......@@ -654,11 +662,13 @@ void KmagApp::slotModeWholeScreen()
void KmagApp::slotModeSelWin()
{
m_zoomView->followMouse(false);
m_zoomView->followFocus(false);
m_zoomView->showSelRect(true);
m_zoomView->setFitToWindow (false);
m_modeFollowMouse->setChecked(false);
#ifdef LibKdeAccessibilityClient_FOUND
m_zoomView->followFocus(false);
m_modeFollowFocus->setChecked(false);
#endif
m_modeWholeScreen->setChecked(false);
m_modeSelWin->setChecked(true);
}
......@@ -667,16 +677,19 @@ void KmagApp::slotModeSelWin()
void KmagApp::slotModeFollowMouse()
{
m_zoomView->followMouse(true);
m_zoomView->followFocus(false);
m_zoomView->showSelRect(false);
m_zoomView->setFitToWindow (true);
m_modeFollowMouse->setChecked(true);
#ifdef LibKdeAccessibilityClient_FOUND
m_zoomView->followFocus(false);
m_modeFollowFocus->setChecked(false);
#endif
m_modeWholeScreen->setChecked(false);
m_modeSelWin->setChecked(false);
}
#ifdef LibKdeAccessibilityClient_FOUND
void KmagApp::slotModeFollowFocus()
{
m_zoomView->followMouse(false);
......@@ -688,7 +701,7 @@ void KmagApp::slotModeFollowFocus()
m_modeWholeScreen->setChecked(false);
m_modeSelWin->setChecked(false);
}
#endif
void KmagApp::slotToggleHideCursor()
{
......
......@@ -25,6 +25,7 @@
#define KMAG_H
#include "kmagzoomview.h"
#include "focustrackconfig.h"
// include files for Qt
#include <QtGui/QContextMenuEvent>
......@@ -113,7 +114,9 @@ class KmagApp : public KXmlGuiWindow
void slotToggleRefresh();
void slotModeFollowMouse();
#ifdef LibKdeAccessibilityClient_FOUND
void slotModeFollowFocus();
#endif
void slotModeWholeScreen();
void slotModeSelWin();
......
......@@ -139,8 +139,10 @@ KMagZoomView::KMagZoomView(QWidget *parent, const char *name)
if(m_fitToWindow)
fitToWindow();
#ifdef LibKdeAccessibilityClient_FOUND
//subscribe to focus events from registry
m_registry.subscribeEventListeners(KAccessibleClient::Registry::Focus);
#endif
}
KMagZoomView::~KMagZoomView()
......@@ -206,6 +208,7 @@ void KMagZoomView::followMouse(bool follow)
}
}
#ifdef LibKdeAccessibilityClient_FOUND
/**
* This function will set/reset keyboard focus following of grab window.
*/
......@@ -236,6 +239,7 @@ void KMagZoomView::focusChanged(const KAccessibleClient::AccessibleObject &objec
m_oldFocus = object.focusPoint();
qDebug() << m_oldFocus;
}
#endif
/**
* Called when the widget is hidden. Stop refresh when this happens.
......@@ -891,9 +895,11 @@ void KMagZoomView::grabFrame()
if(m_followMouse) {
// set new center to be the current mouse position
newCenter = QCursor::pos();
#ifdef LibKdeAccessibilityClient_FOUND
} else if(m_followFocus) {
// set the new center to the current keyboard cursor position
newCenter = m_oldFocus;
#endif
}
// make sure the mouse position is not taking the grab window outside
......
......@@ -44,6 +44,8 @@
//class KMagSelRect;
#include "kmagselrect.h"
#include "focustrackconfig.h"
/**
* The KMagZoomView class provides the view widget for the KmagApp instance.
*
......@@ -70,9 +72,11 @@ class KMagZoomView : public QAbstractScrollArea
/// Returns the status of followMouse
bool getFollowMouse() const { return m_followMouse; }
#ifdef LibKdeAccessibilityClient_FOUND
/// Returns the status of followFocus
bool getFollowFocus() const { return m_followFocus; }
#endif
/// Get the status of "show rect. always"
bool getShowSelRect() const { return (m_selRect.getAlwaysVisible()); }
......@@ -109,8 +113,10 @@ class KMagZoomView : public QAbstractScrollArea
/// Set grab-window-follows-mouse mode
void followMouse(bool follow = true);
#ifdef LibKdeAccessibilityClient_FOUND
/// Set grab-window-follows-keyboard-focus mode
void followFocus(bool follow = true);
#endif
/// Shows/Hides the selection marker
void showSelRect(bool show=true);
......@@ -130,10 +136,11 @@ class KMagZoomView : public QAbstractScrollArea
/// Fits the zoom view to the zoom view window
void fitToWindow();
#ifdef LibKdeAccessibilityClient_FOUND
private slots:
/// Called from a dbus service when followFocus is true
void focusChanged(const KAccessibleClient::AccessibleObject &object);
#endif
protected:
/// Called when the widget is hidden
void hideEvent( QHideEvent * e);
......@@ -187,8 +194,11 @@ class KMagZoomView : public QAbstractScrollArea
void setupMatrix();
private:
#ifdef LibKdeAccessibilityClient_FOUND
/// Global Accessibility Registry
KAccessibleClient::Registry m_registry;
#endif
/// Stores the pixmap which is recolored from the grabbed one
QPixmap m_coloredPixmap;
......@@ -211,8 +221,10 @@ class KMagZoomView : public QAbstractScrollArea
/// Saves the center of the grab window
QPoint m_oldCenter;
#ifdef LibKdeAccessibilityClient_FOUND
/// Saves the keyboard focus position
QPoint m_oldFocus;
#endif
/// Possible modes for the mouse to be in
enum KMagMouseMode {
......
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