[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdepim] mobile/mail: Don't abuse the height property to pass the
From:       Volker Krause <vkrause () kde ! org>
Date:       2011-09-10 9:36:02
Message-ID: 20110910093602.B4393A60A6 () git ! kde ! org
[Download RAW message or body]

Git commit aae623bdc24403bfb4f522f7d524031f8fb12318 by Volker Krause.
Committed on 10/09/2011 at 11:34.
Pushed by vkrause into branch 'master'.

Don't abuse the height property to pass the available screen height.

This allows using proper bindings here and enable the composer to use all
available screen space.

M  +3    -1    mobile/mail/EditorView.qml
M  +4    -6    mobile/mail/composerautoresizer.cpp
M  +0    -1    mobile/mail/composerautoresizer.h
M  +11   -1    mobile/mail/composerview.cpp
M  +2    -0    mobile/mail/kmail-composer.qml

http://commits.kde.org/kdepim/aae623bdc24403bfb4f522f7d524031f8fb12318

diff --git a/mobile/mail/EditorView.qml b/mobile/mail/EditorView.qml
index f5e9483..3bff54d 100644
--- a/mobile/mail/EditorView.qml
+++ b/mobile/mail/EditorView.qml
@@ -25,7 +25,9 @@ import org.kde.messagecomposer 4.5 as MessageComposer
 import "../mobileui/ScreenFunctions.js" as Screen
 
 Item {
+  id: root
   property int contentHeight: subject.height + messageContent.height + \
bottomContainer.height + 20; +  property int screenHeight: 480
   anchors.topMargin: 12
   anchors.leftMargin: 48
   anchors.rightMargin: 2
@@ -104,7 +106,7 @@ Item {
 
   MessageComposer.Editor {
     id: messageContent
-    height: 424 - Screen.fingerSize
+    availableScreenHeight: root.screenHeight - bottomContainer.height - \
subject.height - cryptoIndicator.height - cryptoIndicator.anchors.topMargin - \
root.anchors.topMargin - 2  anchors {
       top: cryptoIndicator.bottom
       left: parent.left
diff --git a/mobile/mail/composerautoresizer.cpp \
b/mobile/mail/composerautoresizer.cpp index 9769f60..587c2c3 100644
--- a/mobile/mail/composerautoresizer.cpp
+++ b/mobile/mail/composerautoresizer.cpp
@@ -32,9 +32,6 @@ ComposerAutoResizer::ComposerAutoResizer( QTextEdit* parent )
   // detect when the text changes
   connect( parent, SIGNAL(textChanged()), this, SLOT(textEditChanged()) );
   connect( parent, SIGNAL(cursorPositionChanged()), this, SLOT(textEditChanged()) );
-
-  // get the original minimum size of the widget
-  mMinimumHeight = mComposer->size().height();
 }
 
 QDeclarativeItem *ComposerAutoResizer::findFlickable( QGraphicsItem *parent ) const
@@ -66,8 +63,9 @@ void ComposerAutoResizer::textEditChanged()
   const QRect contentsRect = mComposer->contentsRect();
 
   // sets the size of the widget dynamically
-  mComposer->setMinimumHeight( qMax( mMinimumHeight, size.height() + \
                (frameRect.height() - contentsRect.height()) ) );
-  mComposer->setMaximumHeight( qMax( mMinimumHeight, size.height() + \
(frameRect.height() - contentsRect.height()) ) ); +  int minHeight = \
mComposer->property( "availableScreenHeight" ).toInt(); +  \
mComposer->setMinimumHeight( qMax( minHeight, size.height() + (frameRect.height() - \
contentsRect.height()) ) ); +  mComposer->setMaximumHeight( qMax( minHeight, \
size.height() + (frameRect.height() - contentsRect.height()) ) );  
   const QGraphicsProxyWidget *proxy = mComposer->graphicsProxyWidget();
   QGraphicsItem *proxyItem = proxy->parentItem();
@@ -78,7 +76,7 @@ void ComposerAutoResizer::textEditChanged()
   // make sure the cursor is visible so the user doesn't loose track of the kb focus
   if ( mFlickable || (mFlickable = findFlickable( proxyItem )) ) {
     const int dy = cursor.center().y();
-    const int y = pos.y() + dy - mMinimumHeight;
+    const int y = pos.y() + dy - minHeight;
     if ( y >= 0 ) {
       mFlickable->setProperty( "contentY", y );
     } else {
diff --git a/mobile/mail/composerautoresizer.h b/mobile/mail/composerautoresizer.h
index c7e8ca8..d5b7fb9 100644
--- a/mobile/mail/composerautoresizer.h
+++ b/mobile/mail/composerautoresizer.h
@@ -38,7 +38,6 @@ class ComposerAutoResizer : public QObject
 
   private:
     QTextEdit *mComposer;
-    int mMinimumHeight;
     QDeclarativeItem *mFlickable;
 };
 
diff --git a/mobile/mail/composerview.cpp b/mobile/mail/composerview.cpp
index c2103c2..de89c6f 100644
--- a/mobile/mail/composerview.cpp
+++ b/mobile/mail/composerview.cpp
@@ -71,7 +71,15 @@
 #include <mailtransport/transportmanagementwidget.h>
 #endif
 
-typedef DeclarativeWidgetBase<Message::KMeditor, ComposerView, \
&ComposerView::setEditor> DeclarativeEditor; +class DeclarativeEditor : public \
DeclarativeWidgetBase<Message::KMeditor, ComposerView, &ComposerView::setEditor> +{
+   Q_OBJECT
+   Q_PROPERTY( int availableScreenHeight READ availableScreenHeight WRITE \
setAvailableScreenHeight ) +  public:
+    int availableScreenHeight() { return widget()->property( "availableScreenHeight" \
).toInt(); } +    void setAvailableScreenHeight( int height ) { \
widget()->setProperty( "availableScreenHeight", height ); } +};
+
 typedef DeclarativeWidgetBase<MessageComposer::RecipientsEditor, ComposerView, \
&ComposerView::setRecipientsEditor> DeclarativeRecipientsEditor;  
 QML_DECLARE_TYPE( DeclarativeEditor )
@@ -680,3 +688,5 @@ void ComposerView::setAutoSaveFileName(const QString &fileName)
 
 
 #include "composerview.moc"
+#include "moc_composerview.cpp"
+
diff --git a/mobile/mail/kmail-composer.qml b/mobile/mail/kmail-composer.qml
index 7108646..beb3599 100644
--- a/mobile/mail/kmail-composer.qml
+++ b/mobile/mail/kmail-composer.qml
@@ -23,6 +23,7 @@ import org.kde.pim.mobileui 4.5 as KPIM
 import org.kde.messagecomposer 4.5 as MessageComposer
 
 KPIM.MainView {
+  id: root
 
   KPIM.DecoratedFlickable {
     id: flick
@@ -34,6 +35,7 @@ KPIM.MainView {
         id: editorView
         enabled: !window.busy
         anchors.fill: parent
+        screenHeight: root.height
       }
     ]
   }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic