summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/fx/qfxtextedit.cpp23
-rw-r--r--src/declarative/fx/qfxtextedit.h4
-rw-r--r--src/declarative/fx/qfxtextedit_p.h5
-rw-r--r--src/declarative/util/qfxview.cpp17
-rw-r--r--src/declarative/util/qfxview.h2
5 files changed, 50 insertions, 1 deletions
diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp
index 74c9b5b..35b1173 100644
--- a/src/declarative/fx/qfxtextedit.cpp
+++ b/src/declarative/fx/qfxtextedit.cpp
@@ -430,6 +430,26 @@ void QFxTextEdit::setCursorVisible(bool on)
d->control->processEvent(&focusEvent, QPointF(0, 0));
}
+/*!
+ \qmlproperty bool TextEdit::focusOnPress
+
+ Whether the TextEdit should gain focus on a mouse press. By default this is
+ set to false;
+*/
+bool QFxTextEdit::focusOnPress() const
+{
+ Q_D(const QFxTextEdit);
+ return d->focusOnPress;
+}
+
+void QFxTextEdit::setFocusOnPress(bool on)
+{
+ Q_D(QFxTextEdit);
+ if (d->focusOnPress == on)
+ return;
+ d->focusOnPress = on;
+}
+
void QFxTextEdit::geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry)
{
@@ -643,6 +663,7 @@ void QFxTextEdit::keyReleaseEvent(QKeyEvent *event)
void QFxTextEdit::focusChanged(bool hasFocus)
{
Q_D(QFxTextEdit);
+ setCursorVisible(hasFocus);
}
/*!
@@ -684,6 +705,8 @@ Handles the given mouse \a event.
void QFxTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QFxTextEdit);
+ if (d->focusOnPress)
+ setFocus(true);
QMouseEvent *me = sceneMouseEventToMouseEvent(event);
d->control->processEvent(me, QPointF(0, 0));
event->setAccepted(me->isAccepted());
diff --git a/src/declarative/fx/qfxtextedit.h b/src/declarative/fx/qfxtextedit.h
index 5d95cd1..0aaa17b 100644
--- a/src/declarative/fx/qfxtextedit.h
+++ b/src/declarative/fx/qfxtextedit.h
@@ -77,6 +77,7 @@ class Q_DECLARATIVE_EXPORT QFxTextEdit : public QFxPaintedItem
Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat)
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible)
+ Q_PROPERTY(bool focusOnPress READ focusOnPress WRITE setFocusOnPress)
Q_CLASSINFO("DefaultProperty", "text")
public:
@@ -127,6 +128,9 @@ public:
bool isCursorVisible() const;
void setCursorVisible(bool on);
+ bool focusOnPress() const;
+ void setFocusOnPress(bool on);
+
virtual void dump(int depth);
virtual QString propertyInfo() const;
diff --git a/src/declarative/fx/qfxtextedit_p.h b/src/declarative/fx/qfxtextedit_p.h
index dd2a1bf..a9b7237 100644
--- a/src/declarative/fx/qfxtextedit_p.h
+++ b/src/declarative/fx/qfxtextedit_p.h
@@ -68,7 +68,9 @@ class QFxTextEditPrivate : public QFxPaintedItemPrivate
public:
QFxTextEditPrivate()
- : font(0), color("black"), imgDirty(true), hAlign(QFxTextEdit::AlignLeft), vAlign(QFxTextEdit::AlignTop), dirty(false), wrap(false), richText(false), cursorVisible(false), format(QFxTextEdit::AutoText), document(0)
+ : font(0), color("black"), imgDirty(true), hAlign(QFxTextEdit::AlignLeft), vAlign(QFxTextEdit::AlignTop),
+ dirty(false), wrap(false), richText(false), cursorVisible(false), focusOnPress(false),
+ format(QFxTextEdit::AutoText), document(0)
{
}
@@ -95,6 +97,7 @@ public:
bool wrap;
bool richText;
bool cursorVisible;
+ bool focusOnPress;
QFxTextEdit::TextFormat format;
QTextDocument *document;
QTextControl *control;
diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp
index 078916b..e17decf 100644
--- a/src/declarative/util/qfxview.cpp
+++ b/src/declarative/util/qfxview.cpp
@@ -105,6 +105,8 @@ public:
QmlComponent *component;
QBasicTimer resizetimer;
+ QSize initialSize;
+
void init();
};
@@ -137,6 +139,7 @@ public:
QFxView::QFxView(QWidget *parent)
: QSimpleCanvas(parent), d(new QFxViewPrivate(this))
{
+ setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
d->init();
}
@@ -150,6 +153,7 @@ QFxView::QFxView(QWidget *parent)
QFxView::QFxView(QSimpleCanvas::CanvasMode mode, QWidget *parent)
: QSimpleCanvas(mode, parent), d(new QFxViewPrivate(this))
{
+ setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
d->init();
}
@@ -381,10 +385,23 @@ void QFxView::timerEvent(QTimerEvent* e)
if (d->root)
emit sceneResized(QSize(d->root->width(),d->root->height()));
d->resizetimer.stop();
+ updateGeometry();
}
}
/*!
+ The size hint is the size of the root item.
+*/
+QSize QFxView::sizeHint() const
+{
+ if (d->initialSize.width() <= 0)
+ d->initialSize.setWidth(d->root->width());
+ if (d->initialSize.height() <= 0)
+ d->initialSize.setHeight(d->root->height());
+ return d->initialSize;
+}
+
+/*!
Creates a \l{QmlComponent} {component} from the \a qml
string, and returns it as an \l {QFxItem} {item}. If the
\a parent item is provided, it becomes the new item's
diff --git a/src/declarative/util/qfxview.h b/src/declarative/util/qfxview.h
index f575f27..d6f786c 100644
--- a/src/declarative/util/qfxview.h
+++ b/src/declarative/util/qfxview.h
@@ -82,6 +82,8 @@ public:
virtual QFxItem *root() const;
+ QSize sizeHint() const;
+
void dumpRoot();
static void printErrorLine(const QmlError &);