~kubuntu-members/kmag/4.11

« back to all changes in this revision

Viewing changes to kmagzoomview.cpp

  • Committer: Amandeep Singh
  • Date: 2012-09-26 18:26:03 UTC
  • Revision ID: git-v1:2278a10a069ed436d0167ae3ef099b020e35f663
Allowing KMag to follow both mouse & kbd-focus together

   -Made the followMouseMode & followFocusMode selectable together.
   -With just followMouseMode checked, Kmag follows mouse,
     and with followFocusMode checked, Kmag follows focus.
   -And when both are selected, it follows both the mouse,
     and the keyboard focus, whichever is relevant.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
#include <QtGui/QResizeEvent>
43
43
#include <QtGui/QMouseEvent>
44
44
#include <QtGui/QDesktopWidget>
 
45
#include <QtGui/QCursor>
45
46
#include <QtDBus/QDBusConnection>
46
47
 
47
48
// include files for KDE
211
212
}
212
213
 
213
214
#ifdef QAccessibilityClient_FOUND
 
215
 
 
216
void KMagZoomView::followBoth(bool follow)
 
217
{
 
218
    m_followBoth = follow;
 
219
    if(follow){
 
220
        m_followMouse = true;
 
221
        m_followFocus = false;
 
222
        setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
 
223
        setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
 
224
 
 
225
        connect(&m_registry, SIGNAL(focusChanged(const QAccessibleClient::AccessibleObject &)),
 
226
                this, SLOT(focusChanged(const QAccessibleClient::AccessibleObject &)));
 
227
    } else {
 
228
        setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOn);
 
229
        setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOn);
 
230
 
 
231
        disconnect(&m_registry, SIGNAL(focusChanged(const QAccessibleClient::AccessibleObject &)),
 
232
                this, SLOT(focusChanged(const QAccessibleClient::AccessibleObject &)));
 
233
    }
 
234
}
 
235
 
214
236
/**
215
237
 * This function will set/reset keyboard focus following of grab window.
216
238
 */
239
261
void KMagZoomView::focusChanged(const QAccessibleClient::AccessibleObject &object)
240
262
{
241
263
    m_oldFocus = object.focusPoint();
242
 
    qDebug() << m_oldFocus;
 
264
    if(m_followBoth && !m_selRect.contains(m_oldFocus)) {
 
265
        QCursor::setPos(m_oldFocus);
 
266
        m_followFocus = true;
 
267
        m_followMouse = false;
 
268
    }
243
269
}
 
270
 
244
271
#endif
245
272
 
246
273
/**
901
928
    } else if(m_followFocus) {
902
929
        // set the new center to the current keyboard cursor position
903
930
        newCenter = m_oldFocus;
 
931
        if(m_followBoth) {
 
932
            m_followFocus=false;
 
933
            m_followMouse=true;
 
934
        }
904
935
#endif
905
936
    }
906
937