added a check to verify is the focus is already there when the widget it appears

preferencesAboutTextFull
Claudio Valerio 12 years ago
parent 6a1e6b6268
commit 0c0f9e15a6
  1. 14
      src/gui/UBTeacherGuideWidgetsTools.cpp

@ -164,7 +164,7 @@ void UBTGAdaptableText::keyReleaseEvent(QKeyEvent* e)
void UBTGAdaptableText::showEvent(QShowEvent* e) void UBTGAdaptableText::showEvent(QShowEvent* e)
{ {
Q_UNUSED(e); Q_UNUSED(e);
if(!mIsUpdatingSize && mHasPlaceHolder && toPlainText().isEmpty() && !isReadOnly()){ if(!mIsUpdatingSize && !hasFocus() && mHasPlaceHolder && toPlainText().isEmpty() && !isReadOnly()){
setTextColor(QColor(Qt::lightGray)); setTextColor(QColor(Qt::lightGray));
setPlainText(mPlaceHolderText); setPlainText(mPlaceHolderText);
} }
@ -193,7 +193,8 @@ void UBTGAdaptableText::onTextChanged()
if(documentSize < mMinimumHeight){ if(documentSize < mMinimumHeight){
setFixedHeight(mMinimumHeight); setFixedHeight(mMinimumHeight);
}else{ }
else{
setFixedHeight(documentSize+mBottomMargin); setFixedHeight(documentSize+mBottomMargin);
} }
@ -237,12 +238,14 @@ void UBTGAdaptableText::focusInEvent(QFocusEvent* e)
QTextEdit::focusInEvent(e); QTextEdit::focusInEvent(e);
} }
void UBTGAdaptableText::focusOutEvent(QFocusEvent* e){ void UBTGAdaptableText::focusOutEvent(QFocusEvent* e)
{
managePlaceholder(false); managePlaceholder(false);
QTextEdit::focusOutEvent(e); QTextEdit::focusOutEvent(e);
} }
void UBTGAdaptableText::managePlaceholder(bool focus){ void UBTGAdaptableText::managePlaceholder(bool focus)
{
if(focus){ if(focus){
if(toPlainText() == mPlaceHolderText){ if(toPlainText() == mPlaceHolderText){
setTextColor(QColor(Qt::black)); setTextColor(QColor(Qt::black));
@ -258,7 +261,8 @@ void UBTGAdaptableText::managePlaceholder(bool focus){
} }
} }
void UBTGAdaptableText::setCursorToTheEnd(){ void UBTGAdaptableText::setCursorToTheEnd()
{
QTextDocument* doc = document(); QTextDocument* doc = document();
if(NULL != doc){ if(NULL != doc){
QTextBlock block = doc->lastBlock(); QTextBlock block = doc->lastBlock();

Loading…
Cancel
Save