Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Connect to QScreen for orientation change updates
Style

Removed old Qt4 code, MDeclarativeScreenPrivate::physicalOrientation now uses QScreen
  • Loading branch information
bzeller committed Oct 9, 2013
1 parent 17a97e5 commit c512966
Show file tree
Hide file tree
Showing 20 changed files with 54 additions and 436 deletions.
4 changes: 0 additions & 4 deletions src/components/kernel/common.h
Expand Up @@ -47,11 +47,7 @@
#endif

#ifndef SINCE_VERSION
# if QT_VERSION >= 0x050000
# define SINCE_VERSION(major, minor) 2, 0
# else
# define SINCE_VERSION(major, minor) major, minor
# endif
#endif

#endif // COMMON_H
6 changes: 0 additions & 6 deletions src/components/models/qrangemodel.h
Expand Up @@ -42,13 +42,7 @@
#define QRANGEMODEL_H

#include <QtCore/qobject.h>

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QtQml/qqml.h>
#else
#include <QtDeclarative/qdeclarative.h>
#endif

#include <kernel/common.h>

class QRangeModelPrivate;
Expand Down
5 changes: 0 additions & 5 deletions src/components/qglobalenums.h
Expand Up @@ -42,12 +42,7 @@
#define QGLOBALENUMS_H

#include <QtCore/qobject.h>

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QtQml/qqml.h>
#else
#include <QtDeclarative/qdeclarative.h>
#endif

#include <kernel/common.h>

Expand Down
5 changes: 0 additions & 5 deletions src/meego/mdatetimehelper.h
Expand Up @@ -42,12 +42,7 @@
#define MDATETIMEHELPER_H

#include <QObject>

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <qqml.h>
#else
#include <qdeclarative.h>
#endif

class MDateTimeHelper : public QObject
{
Expand Down
4 changes: 0 additions & 4 deletions src/meego/mdeclarativeimattributeextension.h
Expand Up @@ -125,11 +125,7 @@ class MDeclarativeIMAttributeExtension : public QDeclarativeItem
#endif
}

#if QT_VERSION >= 0x050000
Q_INVOKABLE void registerInputElement(QQuickItem *element) const {
#else
Q_INVOKABLE void registerInputElement(QDeclarativeItem *element) const {
#endif
#ifdef HAVE_MALIIT
if (element)
element->setProperty("meego-inputmethod-attribute-extension-id", extension.id());
Expand Down
58 changes: 0 additions & 58 deletions src/meego/mdeclarativeimobserver.cpp
Expand Up @@ -40,9 +40,6 @@

#include "mdeclarativeimobserver.h"

#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
#include <QInputContext>
#endif
#include <QInputMethodEvent>
#include <QGuiApplication>
#include <QGraphicsObject>
Expand All @@ -56,66 +53,11 @@ MDeclarativeIMObserver::MDeclarativeIMObserver(QDeclarativeItem *parent) :

bool MDeclarativeIMObserver::sceneEventFilter(QGraphicsItem * watched, QEvent * event)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
if (event->type()==QEvent::InputMethod) {
if (m_omitInputMethodEvents) {
return true;
}

QInputMethodEvent *ime = static_cast<QInputMethodEvent*>(event);
QString newPreedit = ime->preeditString();

QGraphicsObject *g = parentObject();
if (g != 0 && g->property("maximumLength").isValid()) {
int maximumTextLength = g->property("maximumLength").toInt();
int textLength = g->property("text").toString().length();
int selectedTextLength = g->property("selectedText").toString().length();
if (textLength == maximumTextLength &&
newPreedit.length() - ime->replacementLength() > 0 &&
selectedTextLength == 0) {
m_omitInputMethodEvents = true;
QInputContext *ic = qApp->inputContext();
ic->reset();
m_omitInputMethodEvents = false;
return true;
}
}

if (newPreedit!=m_preedit) {
m_preedit = newPreedit;
emit preeditChanged();
}

QList<QInputMethodEvent::Attribute> attributes = ime->attributes();
QList<QInputMethodEvent::Attribute>::iterator i;
for (i = attributes.begin(); i != attributes.end(); ++i) {
QInputMethodEvent::Attribute attribute = *i;
if (attribute.type == QInputMethodEvent::Cursor) {
m_preeditCursorPosition = attribute.start;
emit preeditCursorPositionChanged();
}
}
}

return QDeclarativeItem::sceneEventFilter(watched,event);
#else
Q_UNUSED(watched)
return false; // FIXME: How do we deal with this?
#endif
}

#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
void MDeclarativeIMObserver::itemChange(ItemChange, const ItemChangeData &)
{
// FIXME: How do we deal with this?
}
#else
QVariant MDeclarativeIMObserver::itemChange(GraphicsItemChange c, const QVariant &v)
{
if(c==QGraphicsItem::ItemParentHasChanged || c== QGraphicsItem::ItemSceneHasChanged){
parentItem()->installSceneEventFilter(this);
}
return v;
}
#endif

4 changes: 0 additions & 4 deletions src/meego/mdeclarativeimobserver.h
Expand Up @@ -68,11 +68,7 @@ public slots:

protected:
bool sceneEventFilter(QGraphicsItem * watched, QEvent * event);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
void itemChange(ItemChange, const ItemChangeData &);
#else
QVariant itemChange(GraphicsItemChange c, const QVariant &v);
#endif

private:
QString m_preedit;
Expand Down
11 changes: 0 additions & 11 deletions src/meego/mdeclarativeimplicitsizeitem.cpp
Expand Up @@ -69,23 +69,12 @@ void MDeclarativeImplicitSizeItem::setImplicitHeightNotify(const qreal height)

bool MDeclarativeImplicitSizeItem::platformFocusable() const
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
Q_ASSERT_X(false, "MDeclarativeImplicitSizeItem", "platformFocusable is deprecated");
return true;
#else
return flags() & QGraphicsItem::ItemIsFocusable;
#endif
}

void MDeclarativeImplicitSizeItem::setPlatformFocusable(bool shouldFocus)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
Q_UNUSED(shouldFocus);
Q_ASSERT_X(false, "MDeclarativeImplicitSizeItem", "setPlatformFocusable is deprecated");
#else
if (shouldFocus != platformFocusable()) {
setFlag(ItemIsFocusable, shouldFocus);
emit platformFocusableChanged();
}
#endif
}
61 changes: 4 additions & 57 deletions src/meego/mdeclarativeinputcontext.cpp
Expand Up @@ -46,14 +46,10 @@
#include <QClipboard>
#include <QDebug>

#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
#include <QInputContext>
#endif

#ifdef HAVE_MALIIT
#include <maliit/inputmethod.h>
#include <maliit/preeditinjectionevent.h>
#elif QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#else
#include <QInputMethod>
#include <QGuiApplication>
#endif
Expand All @@ -66,9 +62,8 @@ class MDeclarativeInputContextPrivate
MDeclarativeInputContextPrivate(MDeclarativeInputContext *qq);
~MDeclarativeInputContextPrivate();

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)

void _q_updateKeyboardRectangle();
#endif
void _q_sipChanged(const QRect &);
void _q_checkMicroFocusHint();

Expand Down Expand Up @@ -104,7 +99,7 @@ MDeclarativeInputContextPrivate::MDeclarativeInputContextPrivate(MDeclarativeInp
simulateSip = false;
QObject::connect(Maliit::InputMethod::instance(), SIGNAL(areaChanged(const QRect &)),
q, SLOT(_q_sipChanged(const QRect &)));
#elif QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#else
simulateSip = false;
QObject::connect(qApp->inputMethod(), SIGNAL(keyboardRectangleChanged()),
q, SLOT(_q_updateKeyboardRectangle()));
Expand All @@ -115,12 +110,10 @@ MDeclarativeInputContextPrivate::~MDeclarativeInputContextPrivate()
{
}

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
void MDeclarativeInputContextPrivate::_q_updateKeyboardRectangle()
{
_q_sipChanged(qApp->inputMethod()->keyboardRectangle().toRect());
}
#endif

void MDeclarativeInputContextPrivate::_q_sipChanged(const QRect &rect)
{
Expand All @@ -141,23 +134,7 @@ void MDeclarativeInputContextPrivate::_q_sipChanged(const QRect &rect)

void MDeclarativeInputContext::updateMicroFocus()
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
d->microFocus = qApp->inputMethod()->cursorRectangle();
#else
if (QWidget *widget = QApplication::focusWidget()) {
QVariant v = widget->inputMethodQuery(Qt::ImMicroFocus);
if (!v.toRectF().isValid()) {
d->microFocus = QRectF(-1, -1, -1, -1);
return;
}
QRectF mf = v.toRectF();
if (mf != d->microFocus) {
d->microFocus = mf;
}
} else {
d->microFocus = QRectF(-1, -1, -1, -1);
}
#endif
}

MDeclarativeInputContext::MDeclarativeInputContext(QQuickItem *parent)
Expand Down Expand Up @@ -210,31 +187,17 @@ bool MDeclarativeInputContext::softwareInputPanelVisible() const

QRect MDeclarativeInputContext::softwareInputPanelRect() const
{
#if defined(HAVE_MALIIT) || QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
return d->sipRect;
#else
return QRect(d->sipSimulationRect);
#endif
}

void MDeclarativeInputContext::reset()
{
#if defined(HAVE_MALIIT) || QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
qApp->inputMethod()->reset();
#else
QInputContext *ic = qApp->inputContext();
if (ic) ic->reset();
#endif
}

void MDeclarativeInputContext::update()
{
#if defined(HAVE_MALIIT) || QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
qApp->inputMethod()->update(Qt::ImQueryAll);
#else
QInputContext *ic = qApp->inputContext();
if (ic) ic->update();
#endif
}


Expand Down Expand Up @@ -280,18 +243,11 @@ QQuickItem *MDeclarativeInputContext::customSoftwareInputPanelTextField() const
return d->sipVkbTextField;
}

#if QT_VERSION >= 0x050000
void MDeclarativeInputContext::setCustomSoftwareInputPanelTextField(QQuickItem *item)
#else

void MDeclarativeInputContext::setCustomSoftwareInputPanelTextField(QQuickItem *item)
#endif
{
if(d->sipVkbTextField != item) {
#if QT_VERSION >= 0x050000
d->sipVkbTextField = static_cast<QQuickItem*>(item);
#else
d->sipVkbTextField = item;
#endif
emit customSoftwareInputPanelTextFieldChanged();
}
}
Expand Down Expand Up @@ -322,19 +278,10 @@ void MDeclarativeInputContext::simulateSipClose()

bool MDeclarativeInputContext::setPreeditText(const QString &newPreedit, int eventCursorPosition, int replacementStart, int replacementLength)
{
#if defined(HAVE_MALIIT) && QT_VERSION < 0x050000
QInputContext *ic = qApp->inputContext();
if (ic) {
Maliit::PreeditInjectionEvent event(newPreedit, eventCursorPosition);
event.setReplacement(replacementStart, replacementLength);
return ic->filterEvent(&event);
}
#else
Q_UNUSED(newPreedit)
Q_UNUSED(eventCursorPosition)
Q_UNUSED(replacementStart)
Q_UNUSED(replacementLength)
#endif
return false;
}

Expand Down
2 changes: 0 additions & 2 deletions src/meego/mdeclarativeinputcontext.h
Expand Up @@ -107,9 +107,7 @@ class MDeclarativeInputContext : public QObject
private:
Q_DISABLE_COPY(MDeclarativeInputContext)

#if QT_VERSION >= 0x050000
Q_PRIVATE_SLOT(d, void _q_updateKeyboardRectangle())
#endif
Q_PRIVATE_SLOT(d, void _q_sipChanged(const QRect &))

friend class MDeclarativeInputContextPrivate;
Expand Down
24 changes: 1 addition & 23 deletions src/meego/mdeclarativemousefilter.cpp
Expand Up @@ -67,7 +67,6 @@ MDeclarativeMouseFilter::~MDeclarativeMouseFilter()
}
}

#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
void MDeclarativeMouseFilter::itemChange(ItemChange change, const ItemChangeData &)
{
if (change == QQuickItem::ItemParentHasChanged || change == QQuickItem::ItemSceneChange) {
Expand All @@ -77,22 +76,8 @@ void MDeclarativeMouseFilter::itemChange(ItemChange change, const ItemChangeData
}
}
}
#else
QVariant MDeclarativeMouseFilter::itemChange(GraphicsItemChange c, const QVariant &v)
{
if(c==QGraphicsItem::ItemParentHasChanged || c== QGraphicsItem::ItemSceneHasChanged){
parentItem()->setHandlesChildEvents(true);
setKeepMouseGrab(true);
}
return v;
}
#endif

#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
bool MDeclarativeMouseFilter::event(QEvent *event)
#else
bool MDeclarativeMouseFilter::sceneEvent(QEvent *event)
#endif
{
switch (event->type()) {
case QEvent::GraphicsSceneMouseDoubleClick: {
Expand Down Expand Up @@ -185,11 +170,8 @@ bool MDeclarativeMouseFilter::sceneEvent(QEvent *event)
emit finished();
return true;
}
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))

bool ret = QDeclarativeItem::event(event);
#else
bool ret = QDeclarativeItem::sceneEvent(event);
#endif
emit finished();
return ret;
}
Expand All @@ -206,11 +188,7 @@ bool MDeclarativeMouseFilter::sceneEvent(QEvent *event)
break;
}

#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
return QDeclarativeItem::event(event);
#else
return QDeclarativeItem::sceneEvent(event);
#endif
}

void MDeclarativeMouseFilter::timerEvent(QTimerEvent *ev)
Expand Down

0 comments on commit c512966

Please sign in to comment.