Merge branch 'qml' of https://vcs.maemo.org/git/situare into qml
authorSami Rämö <sami.ramo@ixonos.com>
Mon, 22 Nov 2010 15:39:19 +0000 (17:39 +0200)
committerSami Rämö <sami.ramo@ixonos.com>
Mon, 22 Nov 2010 15:39:19 +0000 (17:39 +0200)
Conflicts:
src/qmlui/res.qrc
src/src.pro

src/qmlui/DetailEditorRow.qml
src/qmlui/ExtendedTextEdit.qml [new file with mode: 0644]
src/qmlui/res.qrc
src/src.pro

index eb67755..05c4cad 100644 (file)
@@ -11,11 +11,39 @@ Item {
     anchors.right: parent.right
     width: parent.width
 //    height: messageEditor.height > image.height ? messageEditor.height : image.height
-    height: messageEditor.height
+    height: textEditRow.y + textEditRow.height + 3
+    clip: true
+
+    Rectangle {
+        id: charactersLeftRect
+        anchors.fill: charactersLeft
+        anchors.leftMargin: -4
+        anchors.rightMargin: anchors.leftMargin
+        border { color: "black"; width: 1 }
+        color: "white"
+        radius: 5
+        opacity: 0
+        Behavior on opacity { NumberAnimation { duration: animationDuration } }
+    }
+
+    Text {
+        id: charactersLeft
+        anchors.top: parent.top
+        anchors.horizontalCenter: messageEditorRect.horizontalCenter
+        font.pixelSize: 14
+        opacity: 0
+        Behavior on opacity { NumberAnimation { duration: animationDuration } }
+    }
+
+    Item {
+        id:textEditRow
+        anchors { left: parent.left; top: charactersLeftRect.bottom; topMargin: 2; right: parent.right }
+        height: messageEditor.height
+    }
 
     Image {
         id: image
-        anchors { left: parent.left; top: parent.top }
+        anchors { left: parent.left; top: textEditRow.top }
     }
 
     Rectangle {
@@ -29,23 +57,16 @@ Item {
         Behavior on opacity { NumberAnimation { duration: animationDuration } }
     }
 
-    TextEdit {
+    ExtendedTextEdit {
         id: messageEditor
-        anchors { leftMargin: 5; left: image.right; right: buttonsArea.left; rightMargin: 5; top: parent.top }
+        anchors { leftMargin: 5; left: image.right; right: buttonsArea.left; rightMargin: 5; top: textEditRow.top }
         height: paintedHeight > buttonsArea.height ? paintedHeight : buttonsArea.height
-        focus: true
-        selectByMouse: true
-        font.pixelSize: image.height * 0.7
-        clip: true;
-        wrapMode: TextEdit.Wrap
         onActiveFocusChanged: {
-            if (activeFocus) {
-                console.log("messageEditor got focus")
+            if (activeFocus)
                 parent.state = "edit"
-            } else {
-                console.log("messageEditor lost focus")
-            }
-
+        }
+        onCharacterCountChanged: {
+            charactersLeft.text = 255 - characterCount + " characters left"
         }
     }
 
@@ -80,10 +101,10 @@ Item {
     Item {
         id: buttonsArea
         anchors {
-            top: parent.top
+            top: textEditRow.top
             right: cancelButton.right
             left: cancelButton.right
-            bottom: parent.top
+            bottom: textEditRow.top
         }
     }
 
@@ -104,13 +125,21 @@ Item {
                 opacity: 0.3
             }
             PropertyChanges {
+                target: charactersLeftRect
+                opacity: 0.3
+            }
+            PropertyChanges {
+                target: charactersLeft
+                opacity: 0.8
+            }
+            PropertyChanges {
                 target: cancelButton
                 scale: 1
             }
             AnchorChanges {
                 target: buttonsArea
                 anchors.left: cancelButton.left
-                anchors.bottom: cancelButton.bottom
+                anchors.bottom: textEditRow.bottom
             }
         }
     ]
@@ -127,7 +156,6 @@ Item {
                     AnchorAnimation { targets: buttonsArea; duration: animationDuration }
                     NumberAnimation { target: messageEditor; properties: "height"; duration: animationDuration }
                 }
-
             }
         },
         Transition {
diff --git a/src/qmlui/ExtendedTextEdit.qml b/src/qmlui/ExtendedTextEdit.qml
new file mode 100644 (file)
index 0000000..e809c53
--- /dev/null
@@ -0,0 +1,16 @@
+import Qt 4.7
+
+TextEdit {
+    id: textEdit
+
+    property int characterCount: 0
+
+    focus: true
+    selectByMouse: true
+    font.pixelSize: image.height * 0.7
+    clip: true;
+    wrapMode: TextEdit.Wrap
+    textFormat: TextEdit.PlainText
+
+    onTextChanged: { characterCount = text.length }
+}
index 2a5fecc..dd37b58 100644 (file)
@@ -31,6 +31,7 @@
         <file>ListBase.qml</file>
         <file>DetailEditorRow.qml</file>
         <file>PanelSelectorButton.qml</file>
+        <file>ExtendedTextEdit.qml</file>
         <file>res/busy.png</file>
         <file>BusyIndicator.qml</file>
     </qresource>
index b524559..1b7c3ed 100644 (file)
@@ -206,6 +206,7 @@ OTHER_FILES += qmlui/Main.qml \
     qmlui/LocationsView.qml \
     qmlui/DetailEditorRow.qml \
     qmlui/PanelSelectorButton.qml \
+    qmlui/ExtendedTextEdit.qml \
     qmlui/BusyIndicator.qml
 
 QT += network \