From 0c0f9e15a6e921887e1e6ddfcaee0d0ef1ad2ae2 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Fri, 28 Sep 2012 10:16:38 +0200 Subject: [PATCH] added a check to verify is the focus is already there when the widget it appears --- src/gui/UBTeacherGuideWidgetsTools.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/gui/UBTeacherGuideWidgetsTools.cpp b/src/gui/UBTeacherGuideWidgetsTools.cpp index db2d8bf7..587bc817 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.cpp +++ b/src/gui/UBTeacherGuideWidgetsTools.cpp @@ -164,7 +164,7 @@ void UBTGAdaptableText::keyReleaseEvent(QKeyEvent* e) void UBTGAdaptableText::showEvent(QShowEvent* e) { Q_UNUSED(e); - if(!mIsUpdatingSize && mHasPlaceHolder && toPlainText().isEmpty() && !isReadOnly()){ + if(!mIsUpdatingSize && !hasFocus() && mHasPlaceHolder && toPlainText().isEmpty() && !isReadOnly()){ setTextColor(QColor(Qt::lightGray)); setPlainText(mPlaceHolderText); } @@ -193,7 +193,8 @@ void UBTGAdaptableText::onTextChanged() if(documentSize < mMinimumHeight){ setFixedHeight(mMinimumHeight); - }else{ + } + else{ setFixedHeight(documentSize+mBottomMargin); } @@ -237,12 +238,14 @@ void UBTGAdaptableText::focusInEvent(QFocusEvent* e) QTextEdit::focusInEvent(e); } -void UBTGAdaptableText::focusOutEvent(QFocusEvent* e){ +void UBTGAdaptableText::focusOutEvent(QFocusEvent* e) +{ managePlaceholder(false); QTextEdit::focusOutEvent(e); } -void UBTGAdaptableText::managePlaceholder(bool focus){ +void UBTGAdaptableText::managePlaceholder(bool focus) +{ if(focus){ if(toPlainText() == mPlaceHolderText){ setTextColor(QColor(Qt::black)); @@ -258,7 +261,8 @@ void UBTGAdaptableText::managePlaceholder(bool focus){ } } -void UBTGAdaptableText::setCursorToTheEnd(){ +void UBTGAdaptableText::setCursorToTheEnd() +{ QTextDocument* doc = document(); if(NULL != doc){ QTextBlock block = doc->lastBlock();