From aae623bdc24403bfb4f522f7d524031f8fb12318 Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Sat, 10 Sep 2011 11:34:58 +0200 Subject: [PATCH] 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. --- mobile/mail/EditorView.qml | 4 +++- mobile/mail/composerautoresizer.cpp | 10 ++++------ mobile/mail/composerautoresizer.h | 1 - mobile/mail/composerview.cpp | 12 +++++++++++- mobile/mail/kmail-composer.qml | 2 ++ 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/mobile/mail/EditorView.qml b/mobile/mail/EditorView.qml index f5e94835c5..3bff54d084 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 9769f60164..587c2c3a5c 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 c7e8ca8dea..d5b7fb9d94 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 c2103c2a8f..de89c6f18a 100644 --- a/mobile/mail/composerview.cpp +++ b/mobile/mail/composerview.cpp @@ -71,7 +71,15 @@ #include #endif -typedef DeclarativeWidgetBase DeclarativeEditor; +class DeclarativeEditor : public DeclarativeWidgetBase +{ + 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 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 71086466a4..beb35991d9 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 } ] } -- 2.11.4.GIT