summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-09-10 03:23:06 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-09-10 03:23:06 (GMT)
commit155f7c91e869092962f23c0e1d793cb82fb7544d (patch)
tree407c119e3c158bdb321344abf1fa40cf7841ee0f
parent2c0255521f00a1fd95988161a03c39631350eaba (diff)
parentc41597a34b3435ea2d06f70e90f7d0c561a24215 (diff)
downloadQt-155f7c91e869092962f23c0e1d793cb82fb7544d.zip
Qt-155f7c91e869092962f23c0e1d793cb82fb7544d.tar.gz
Qt-155f7c91e869092962f23c0e1d793cb82fb7544d.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--demos/declarative/flickr/common/MediaLineEdit.qml2
-rw-r--r--demos/declarative/flickr/mobile/TitleBar.qml2
-rw-r--r--demos/declarative/twitter/content/AuthView.qml6
-rw-r--r--demos/declarative/twitter/content/HomeTitleBar.qml2
-rw-r--r--src/declarative/QmlChanges.txt2
-rw-r--r--src/declarative/fx/qfxtextedit.cpp26
-rw-r--r--src/declarative/fx/qfxtextedit.h12
-rw-r--r--src/declarative/fx/qfxtextedit_p.h4
-rw-r--r--src/declarative/fx/qfxtextinput.cpp121
-rw-r--r--src/declarative/fx/qfxtextinput.h31
-rw-r--r--src/declarative/fx/qfxtextinput_p.h8
11 files changed, 154 insertions, 62 deletions
diff --git a/demos/declarative/flickr/common/MediaLineEdit.qml b/demos/declarative/flickr/common/MediaLineEdit.qml
index 094571f..7599ce6a05 100644
--- a/demos/declarative/flickr/common/MediaLineEdit.qml
+++ b/demos/declarative/flickr/common/MediaLineEdit.qml
@@ -90,7 +90,7 @@ Item {
id: Editor
font.bold: true
color: "white"
- highlightColor: "green"
+ selectionColor: "green"
width: 0
clip: true
anchors.left: Label.right
diff --git a/demos/declarative/flickr/mobile/TitleBar.qml b/demos/declarative/flickr/mobile/TitleBar.qml
index b95452a..13484a2 100644
--- a/demos/declarative/flickr/mobile/TitleBar.qml
+++ b/demos/declarative/flickr/mobile/TitleBar.qml
@@ -50,7 +50,7 @@ Item {
verticalCenter: parent.verticalCenter
}
cursorVisible: true; font.bold: true
- color: "#151515"; highlightColor: "Green"
+ color: "#151515"; selectionColor: "Green"
}
Keys.forwardTo: [ (ReturnKey), (Editor)]
diff --git a/demos/declarative/twitter/content/AuthView.qml b/demos/declarative/twitter/content/AuthView.qml
index febee94..3fe7e7e 100644
--- a/demos/declarative/twitter/content/AuthView.qml
+++ b/demos/declarative/twitter/content/AuthView.qml
@@ -27,7 +27,7 @@ Item {
anchors.centerIn: parent
maximumLength:21
font.bold: true
- color: "#151515"; highlightColor: "green"
+ color: "#151515"; selectionColor: "green"
Keys.forwardTo: [(tabber), (nameIn)]
Item {
id: tabber
@@ -56,9 +56,9 @@ Item {
height: parent.height - 12
anchors.centerIn: parent
maximumLength:21
- echoMode: 2
+ echoMode: TextInput.Password
font.bold: true
- color: "#151515"; highlightColor: "green"
+ color: "#151515"; selectionColor: "green"
}
}
}
diff --git a/demos/declarative/twitter/content/HomeTitleBar.qml b/demos/declarative/twitter/content/HomeTitleBar.qml
index 9bca2c8..bd3bc2c 100644
--- a/demos/declarative/twitter/content/HomeTitleBar.qml
+++ b/demos/declarative/twitter/content/HomeTitleBar.qml
@@ -92,7 +92,7 @@ Item {
height: parent.height - 8
font.pointSize: 10
wrap:true
- color: "#151515"; highlightColor: "green"
+ color: "#151515"; selectionColor: "green"
}
Keys.forwardTo: [(ReturnKey), (Editor)]
Item {
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index 9043421..eace089 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -39,6 +39,8 @@ MouseRegion: ymin -> minimumY
MouseRegion: ymin -> maximumY
Text elements: hAlign -> horizontalAlignment
Text elements: vAlign -> verticalAlignment
+Text elements: highlightColor -> selectionColor
+Text elements: highlightedTextColor -> selectedTextColor
State: operations -> changes
Transition: operations -> animations
Transition: fromState -> from
diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp
index c2c418e..72f12cc 100644
--- a/src/declarative/fx/qfxtextedit.cpp
+++ b/src/declarative/fx/qfxtextedit.cpp
@@ -271,24 +271,24 @@ void QFxTextEdit::setColor(const QColor &color)
}
/*!
- \qmlproperty color TextEdit::highlightColor
+ \qmlproperty color TextEdit::selectionColor
The text highlight color, used behind selections.
*/
-QColor QFxTextEdit::highlightColor() const
+QColor QFxTextEdit::selectionColor() const
{
Q_D(const QFxTextEdit);
- return d->highlightColor;
+ return d->selectionColor;
}
-void QFxTextEdit::setHighlightColor(const QColor &color)
+void QFxTextEdit::setSelectionColor(const QColor &color)
{
Q_D(QFxTextEdit);
- if (d->highlightColor == color)
+ if (d->selectionColor == color)
return;
clearCache();
- d->highlightColor = color;
+ d->selectionColor = color;
QPalette pal = d->control->palette();
pal.setColor(QPalette::Highlight, color);
d->control->setPalette(pal);
@@ -296,24 +296,24 @@ void QFxTextEdit::setHighlightColor(const QColor &color)
}
/*!
- \qmlproperty color TextEdit::highlightedTextColor
+ \qmlproperty color TextEdit::selectedTextColor
- The highlighted text color, used in selections.
+ The selected text color, used in selections.
*/
-QColor QFxTextEdit::highlightedTextColor() const
+QColor QFxTextEdit::selectedTextColor() const
{
Q_D(const QFxTextEdit);
- return d->highlightedTextColor;
+ return d->selectedTextColor;
}
-void QFxTextEdit::setHighlightedTextColor(const QColor &color)
+void QFxTextEdit::setSelectedTextColor(const QColor &color)
{
Q_D(QFxTextEdit);
- if (d->highlightedTextColor == color)
+ if (d->selectedTextColor == color)
return;
clearCache();
- d->highlightedTextColor = color;
+ d->selectedTextColor = color;
QPalette pal = d->control->palette();
pal.setColor(QPalette::HighlightedText, color);
d->control->setPalette(pal);
diff --git a/src/declarative/fx/qfxtextedit.h b/src/declarative/fx/qfxtextedit.h
index 6a10e85..1a5d968 100644
--- a/src/declarative/fx/qfxtextedit.h
+++ b/src/declarative/fx/qfxtextedit.h
@@ -68,8 +68,8 @@ class Q_DECLARATIVE_EXPORT QFxTextEdit : public QFxPaintedItem
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY(QColor color READ color WRITE setColor)
- Q_PROPERTY(QColor highlightColor READ highlightColor WRITE setHighlightColor) //### selectionColor
- Q_PROPERTY(QColor highlightedTextColor READ highlightedTextColor WRITE setHighlightedTextColor) //### selectedTextColor
+ Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor)
+ Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor)
Q_PROPERTY(QFont font READ font WRITE setFont)
Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign)
Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign)
@@ -119,11 +119,11 @@ public:
QColor color() const;
void setColor(const QColor &c);
- QColor highlightColor() const;
- void setHighlightColor(const QColor &c);
+ QColor selectionColor() const;
+ void setSelectionColor(const QColor &c);
- QColor highlightedTextColor() const;
- void setHighlightedTextColor(const QColor &c);
+ QColor selectedTextColor() const;
+ void setSelectedTextColor(const QColor &c);
HAlignment hAlign() const;
void setHAlign(HAlignment align);
diff --git a/src/declarative/fx/qfxtextedit_p.h b/src/declarative/fx/qfxtextedit_p.h
index fb757de..9c73db9 100644
--- a/src/declarative/fx/qfxtextedit_p.h
+++ b/src/declarative/fx/qfxtextedit_p.h
@@ -84,8 +84,8 @@ public:
QString text;
QFont font;
QColor color;
- QColor highlightColor;
- QColor highlightedTextColor;
+ QColor selectionColor;
+ QColor selectedTextColor;
QString style;
QColor styleColor;
bool imgDirty;
diff --git a/src/declarative/fx/qfxtextinput.cpp b/src/declarative/fx/qfxtextinput.cpp
index 6bd793b..d9da308 100644
--- a/src/declarative/fx/qfxtextinput.cpp
+++ b/src/declarative/fx/qfxtextinput.cpp
@@ -55,6 +55,12 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,QIntValidator,QIntValidator);
/*!
\qmlclass TextInput
The TextInput item allows you to add an editable line of text to a scene.
+
+ TextInput can only display a single line of text, and can only display
+ plain text. However it can provide addition input constraints on the text.
+
+ Input constraints include setting a QValidator, an input mask, or a
+ maximum input length.
*/
QFxTextInput::QFxTextInput(QFxItem* parent)
: QFxPaintedItem(*(new QFxTextInputPrivate), parent)
@@ -148,47 +154,62 @@ void QFxTextInput::setColor(const QColor &c)
/*!
- \qmlproperty color TextInput::highlightColor
+ \qmlproperty color TextInput::selectionColor
The text highlight color, used behind selections.
*/
-QColor QFxTextInput::highlightColor() const
+QColor QFxTextInput::selectionColor() const
{
Q_D(const QFxTextInput);
- return d->highlightColor;
+ return d->selectionColor;
}
-void QFxTextInput::setHighlightColor(const QColor &color)
+void QFxTextInput::setSelectionColor(const QColor &color)
{
Q_D(QFxTextInput);
- if (d->highlightColor == color)
+ if (d->selectionColor == color)
return;
- d->highlightColor = color;
+ d->selectionColor = color;
//TODO: implement
}
/*!
- \qmlproperty color TextInput::highlightedTextColor
+ \qmlproperty color TextInput::selectedTextColor
The highlighted text color, used in selections.
*/
-QColor QFxTextInput::highlightedTextColor() const
+QColor QFxTextInput::selectedTextColor() const
{
Q_D(const QFxTextInput);
- return d->highlightedTextColor;
+ return d->selectedTextColor;
}
-void QFxTextInput::setHighlightedTextColor(const QColor &color)
+void QFxTextInput::setSelectedTextColor(const QColor &color)
{
Q_D(QFxTextInput);
- if (d->highlightedTextColor == color)
+ if (d->selectedTextColor == color)
return;
- d->highlightedTextColor = color;
+ d->selectedTextColor = color;
//TODO: implement
}
+/*!
+ \qmlproperty enumeration TextInput::horizontalAlignment
+
+ Sets the horizontal alignment of the text within the TextInput item's
+ width and height. By default, the text is left aligned.
+
+ TextInput does not have vertical alignment, as the natural height is
+ exactly the height of the single line of text. If you set the height
+ manually to something larger, TextInput will always be top aligned
+ vertically. You can use anchors to align it however you want within
+ another item.
+
+ The valid values for \c horizontalAlignment are \c AlignLeft, \c AlignRight and
+ \c AlignHCenter.
+*/
QFxTextInput::HAlignment QFxTextInput::hAlign() const
{
Q_D(const QFxTextInput);
@@ -340,6 +361,34 @@ QString QFxTextInput::selectedText() const
return d->control->selectedText();
}
+/*!
+ \qmlproperty bool TextInput::focusOnPress
+
+ Whether the TextInput should gain focus on a mouse press. By default this is
+ set to true.
+*/
+bool QFxTextInput::focusOnPress() const
+{
+ Q_D(const QFxTextInput);
+ return d->focusOnPress;
+}
+
+void QFxTextInput::setFocusOnPress(bool b)
+{
+ Q_D(QFxTextInput);
+ d->focusOnPress = b;
+}
+
+/*!
+ \qmlproperty QValidator* TextInput::validator
+
+ Allows you to set a QValidator on the TextInput. When a validator is set
+ the TextInput will only accept input which leaves the text property in
+ an acceptable or intermediate state. The accepted signal will only be sent
+ if the text is in an acceptable state when enter is pressed.
+
+ \sa acceptableInput, inputMask
+*/
QValidator* QFxTextInput::validator() const
{
Q_D(const QFxTextInput);
@@ -357,6 +406,15 @@ void QFxTextInput::setValidator(QValidator* v)
}
}
+/*!
+ \qmlproperty string TextInput::inputMask
+
+ Allows you to set an input mask on the TextInput, restricting the allowable
+ text inputs. See QLineEdit::inputMask for further details, as the exact
+ same mask strings are used by TextInput.
+
+ \sa acceptableInput, validator
+*/
QString QFxTextInput::inputMask() const
{
Q_D(const QFxTextInput);
@@ -369,22 +427,40 @@ void QFxTextInput::setInputMask(const QString &im)
d->control->setInputMask(im);
}
+/*!
+ \qmlproperty bool TextInput::acceptableInput
+
+ This property is always true unless a validator or input mask has been set.
+ If a validator or input mask has been set, this property will only be true
+ if the current text is acceptable to the validator or input mask as a final
+ string (not as an intermediate string).
+*/
bool QFxTextInput::hasAcceptableInput() const
{
Q_D(const QFxTextInput);
return d->control->hasAcceptableInput();
}
-uint QFxTextInput::echoMode() const
+/*!
+ \qmlproperty TextInput.EchoMode TextInput::echoMode
+
+ Specifies how the text should be displayed in the TextInput.
+ The default is Normal, which displays the text as it is. Other values
+ are Password, which displays asterixes instead of characters, NoEcho,
+ which displays nothing, and PasswordEchoOnEdit, which displays all but the
+ current character as asterixes.
+
+*/
+QFxTextInput::EchoMode QFxTextInput::echoMode() const
{
Q_D(const QFxTextInput);
- return d->control->echoMode();
+ return (QFxTextInput::EchoMode)d->control->echoMode();
}
-void QFxTextInput::setEchoMode(uint echo)
+void QFxTextInput::setEchoMode(QFxTextInput::EchoMode echo)
{
Q_D(QFxTextInput);
- d->control->setEchoMode(echo);
+ d->control->setEchoMode((uint)echo);
}
/*!
@@ -431,7 +507,7 @@ void QFxTextInputPrivate::startCreatingCursor()
q->connect(cursorComponent, SIGNAL(statusChanged(int)),
q, SLOT(createCursor()));
}else{//isError
- qWarning() << "You could really use the error checking for QFxTextInput. We'll implement it soon.";
+ qWarning() << "You could really use the error checking for QFxTextInput. We'll implement it soon.";//TODO:better error handling
}
}
@@ -446,7 +522,7 @@ void QFxTextInput::createCursor()
delete d->cursorItem;
d->cursorItem = qobject_cast<QFxItem*>(d->cursorComponent->create());
if(!d->cursorItem){
- qWarning() << "You could really use the error reporting for QFxTextInput. We'll implement it soon.";
+ qWarning() << "You could really use the error reporting for QFxTextInput. We'll implement it soon.";//TODO:better error handling
return;
}
@@ -495,11 +571,12 @@ void QFxTextInput::keyPressEvent(QKeyEvent* ev)
void QFxTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QFxTextInput);
- setFocus(true);//###Should we make 'focusOnPress' be optional like TextEdit?
- setCursorVisible(true);
- d->focused = true;
+ if(d->focusOnPress){
+ setFocus(true);
+ setCursorVisible(true);
+ d->focused = true;
+ }
d->control->processEvent(event);
- //event->accept();
}
bool QFxTextInput::event(QEvent* ev)
diff --git a/src/declarative/fx/qfxtextinput.h b/src/declarative/fx/qfxtextinput.h
index 1dca945..4fa4100 100644
--- a/src/declarative/fx/qfxtextinput.h
+++ b/src/declarative/fx/qfxtextinput.h
@@ -59,11 +59,12 @@ class Q_DECLARATIVE_EXPORT QFxTextInput : public QFxPaintedItem
{
Q_OBJECT
Q_ENUMS(HAlignment)
+ Q_ENUMS(EchoMode)
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY(QColor color READ color WRITE setColor)
- Q_PROPERTY(QColor highlightColor READ highlightColor WRITE setHighlightColor) //### selectionColor
- Q_PROPERTY(QColor highlightedTextColor READ highlightedTextColor WRITE setHighlightedTextColor) //### selectedTextColor
+ Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor)
+ Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor)
Q_PROPERTY(QFont font READ font WRITE setFont)
Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign)
@@ -79,13 +80,20 @@ class Q_DECLARATIVE_EXPORT QFxTextInput : public QFxPaintedItem
Q_PROPERTY(QValidator* validator READ validator WRITE setValidator)
Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask)
Q_PROPERTY(bool acceptableInput READ hasAcceptableInput NOTIFY acceptableInputChanged)
- Q_PROPERTY(uint echoMode READ echoMode WRITE setEchoMode) //### enum
- //### Q_PROPERTY(bool focusOnPress READ focusOnPress WRITE setFocusOnPress)
+ Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode)
+ Q_PROPERTY(bool focusOnPress READ focusOnPress WRITE setFocusOnPress)
public:
QFxTextInput(QFxItem* parent=0);
~QFxTextInput();
+ enum EchoMode {//To match QLineEdit::EchoMode
+ Normal,
+ NoEcho,
+ Password,
+ PasswordEchoOnEdit
+ };
+
enum HAlignment {
AlignLeft = Qt::AlignLeft,
AlignRight = Qt::AlignRight,
@@ -105,11 +113,11 @@ public:
QColor color() const;
void setColor(const QColor &c);
- QColor highlightColor() const;
- void setHighlightColor(const QColor &c);
+ QColor selectionColor() const;
+ void setSelectionColor(const QColor &c);
- QColor highlightedTextColor() const;
- void setHighlightedTextColor(const QColor &c);
+ QColor selectedTextColor() const;
+ void setSelectedTextColor(const QColor &c);
HAlignment hAlign() const;
void setHAlign(HAlignment align);
@@ -140,12 +148,15 @@ public:
QString inputMask() const;
void setInputMask(const QString &im);
- uint echoMode() const;
- void setEchoMode(uint echo);
+ EchoMode echoMode() const;
+ void setEchoMode(EchoMode echo);
QmlComponent* cursorDelegate() const;
void setCursorDelegate(QmlComponent*);
+ bool focusOnPress() const;
+ void setFocusOnPress(bool);
+
bool hasAcceptableInput() const;
void drawContents(QPainter *p,const QRect &r);
diff --git a/src/declarative/fx/qfxtextinput_p.h b/src/declarative/fx/qfxtextinput_p.h
index b533854..a2b45bb 100644
--- a/src/declarative/fx/qfxtextinput_p.h
+++ b/src/declarative/fx/qfxtextinput_p.h
@@ -66,7 +66,8 @@ public:
QFxTextInputPrivate() : control(new QLineControl(QString())),
color((QRgb)0), style(QFxText::Normal),
styleColor((QRgb)0), hAlign(QFxTextInput::AlignLeft),
- hscroll(0), oldScroll(0), focused(false), cursorVisible(false)
+ hscroll(0), oldScroll(0), focused(false), focusOnPress(true),
+ cursorVisible(false)
{
}
@@ -82,8 +83,8 @@ public:
QFont font;
QColor color;
- QColor highlightColor;
- QColor highlightedTextColor;
+ QColor selectionColor;
+ QColor selectedTextColor;
QFxText::TextStyle style;
QColor styleColor;
QFxTextInput::HAlignment hAlign;
@@ -98,6 +99,7 @@ public:
int hscroll;
int oldScroll;
bool focused;
+ bool focusOnPress;
bool cursorVisible;
};