|
@@ -4,6 +4,7 @@
|
|
|
#include "FreeVirtualKeyboardInputContext.h"
|
|
|
|
|
|
#include <QDebug>
|
|
|
+#include <QPointer>
|
|
|
#include <QEvent>
|
|
|
#include <QGuiApplication>
|
|
|
#include <QQmlEngine>
|
|
@@ -52,15 +53,16 @@ FreeVirtualKeyboardInputContext::FreeVirtualKeyboardInputContext() :
|
|
|
d->FlickableContentScrollAnimation->setDuration(400);
|
|
|
d->FlickableContentScrollAnimation->setEasingCurve(QEasingCurve(QEasingCurve::OutBack));
|
|
|
qmlRegisterSingletonType<DeclarativeInputEngine>("FreeVirtualKeyboard", 1, 0,
|
|
|
- "InputEngine", inputEngineProvider);
|
|
|
+ "InputEngine", inputEngineProvider);
|
|
|
connect(d->InputEngine, SIGNAL(animatingChanged()), this, SLOT(ensureFocusedObjectVisible()));
|
|
|
+ connect(d->InputEngine, SIGNAL(reset()), this, SLOT(resetInputEngine()));
|
|
|
}
|
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
FreeVirtualKeyboardInputContext::~FreeVirtualKeyboardInputContext()
|
|
|
{
|
|
|
- qDebug( "FreeVirtualKeyboardInputContext DESTRUCTOR");
|
|
|
+ qDebug( "FreeVirtualKeyboardInputContext DESTRUCTOR !!!");
|
|
|
}
|
|
|
|
|
|
|
|
@@ -76,6 +78,7 @@ FreeVirtualKeyboardInputContext* FreeVirtualKeyboardInputContext::instance()
|
|
|
//==============================================================================
|
|
|
bool FreeVirtualKeyboardInputContext::isValid() const
|
|
|
{
|
|
|
+ qDebug("IS VALID called");
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -83,6 +86,7 @@ bool FreeVirtualKeyboardInputContext::isValid() const
|
|
|
//==============================================================================
|
|
|
QRectF FreeVirtualKeyboardInputContext::keyboardRect() const
|
|
|
{
|
|
|
+ qDebug("QRect called");
|
|
|
return QRectF();
|
|
|
}
|
|
|
|
|
@@ -125,9 +129,10 @@ bool FreeVirtualKeyboardInputContext::isAnimating() const
|
|
|
void FreeVirtualKeyboardInputContext::setFocusObject(QObject *object)
|
|
|
{
|
|
|
static const int NumericInputHints = Qt::ImhPreferNumbers | Qt::ImhDate
|
|
|
- | Qt::ImhTime | Qt::ImhDigitsOnly | Qt::ImhFormattedNumbersOnly;
|
|
|
+ | Qt::ImhTime | Qt::ImhDigitsOnly | Qt::ImhFormattedNumbersOnly;
|
|
|
static const int DialableInputHints = Qt::ImhDialableCharactersOnly;
|
|
|
|
|
|
+ d->Flickable = 0;
|
|
|
|
|
|
qDebug() << "FreeVirtualKeyboardInputContext::setFocusObject";
|
|
|
if (!object)
|
|
@@ -170,25 +175,48 @@ void FreeVirtualKeyboardInputContext::setFocusObject(QObject *object)
|
|
|
|
|
|
// Search for the top most flickable so that we can scroll the control
|
|
|
// into the visible area, if the keyboard hides the control
|
|
|
- QQuickItem* i = d->FocusItem;
|
|
|
- d->Flickable = 0;
|
|
|
- while (i)
|
|
|
- {
|
|
|
- QQuickFlickable* Flickable = dynamic_cast<QQuickFlickable*>(i);
|
|
|
- if (Flickable)
|
|
|
- {
|
|
|
- d->Flickable = Flickable;
|
|
|
- qDebug() << "is QQuickFlickable";
|
|
|
- }
|
|
|
- i = i->parentItem();
|
|
|
- }
|
|
|
+ // QQuickItem* i = d->FocusItem;
|
|
|
+ // while (i)
|
|
|
+ // {
|
|
|
+ // QQuickFlickable* Flickable = dynamic_cast<QQuickFlickable*>(i);
|
|
|
+ // if (Flickable)
|
|
|
+ // {
|
|
|
+ // d->Flickable = Flickable;
|
|
|
+ // qDebug() << "is QQuickFlickable";
|
|
|
+ // }
|
|
|
+ // i = i->parentItem();
|
|
|
+ // }
|
|
|
|
|
|
ensureFocusedObjectVisible();
|
|
|
}
|
|
|
|
|
|
+//==============================================================================
|
|
|
+void resetInputEngine(){
|
|
|
+
|
|
|
+ qDebug() << "RESET INPUT ENGINE !!!!!";
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
//==============================================================================
|
|
|
void FreeVirtualKeyboardInputContext::ensureFocusedObjectVisible()
|
|
|
{
|
|
|
+ if (d->Visible && !d->InputEngine->isAnimating() )
|
|
|
+ {
|
|
|
+ QQuickItem* i = d->FocusItem;
|
|
|
+ while (i)
|
|
|
+ {
|
|
|
+ QQuickFlickable* Flickable = dynamic_cast<QQuickFlickable*>(i);
|
|
|
+ if (Flickable)
|
|
|
+ {
|
|
|
+ d->Flickable = Flickable;
|
|
|
+ qDebug() << "is QQuickFlickable";
|
|
|
+ }
|
|
|
+ i = i->parentItem();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
// If the keyboard is hidden, no scrollable element exists or the keyboard
|
|
|
// is just animating, then we leave here
|
|
|
if (!d->Visible || !d->Flickable || d->InputEngine->isAnimating() )
|
|
@@ -197,12 +225,13 @@ void FreeVirtualKeyboardInputContext::ensureFocusedObjectVisible()
|
|
|
}
|
|
|
|
|
|
qDebug() << "FreeVirtualKeyboardInputContext::ensureFocusedObjectVisible";
|
|
|
- QRectF FocusItemRect(0, 0, d->FocusItem->width(), d->FocusItem->height());
|
|
|
|
|
|
+
|
|
|
+ QRectF FocusItemRect(0, 0, d->FocusItem->width(), d->FocusItem->height());
|
|
|
FocusItemRect = d->Flickable->mapRectFromItem(d->FocusItem, FocusItemRect);
|
|
|
qDebug() << "FocusItemRect: " << FocusItemRect;
|
|
|
- qDebug() << "Content origin: " << QPointF(d->Flickable->contentX(),
|
|
|
- d->Flickable->contentY());
|
|
|
+ qDebug() << "Content origin: " << QPointF(d->Flickable->contentX(), d->Flickable->contentY());
|
|
|
+
|
|
|
qDebug() << "Flickable size: " << QSize(d->Flickable->width(), d->Flickable->height());
|
|
|
d->FlickableContentScrollAnimation->setTargetObject(d->Flickable);
|
|
|
qreal ContentY = d->Flickable->contentY();
|