|
|
@ -148,30 +148,10 @@ void UBTGAdaptableText::setPlaceHolderText(QString text) |
|
|
|
setPlainText(mPlaceHolderText); |
|
|
|
setPlainText(mPlaceHolderText); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBTGAdaptableText::keyPressEvent(QKeyEvent* e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(isReadOnly()){ |
|
|
|
|
|
|
|
// this is important if you set a placeholder. In this case even if the text field is readonly the
|
|
|
|
|
|
|
|
// keypressed event came here. So if you don't ignore it you'll have a flick on the text zone
|
|
|
|
|
|
|
|
e->ignore(); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(toPlainText() == mPlaceHolderText){ |
|
|
|
|
|
|
|
setPlainText(""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
setTextColor(QColor(Qt::black)); |
|
|
|
|
|
|
|
QTextEdit::keyPressEvent(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBTGAdaptableText::keyReleaseEvent(QKeyEvent* e) |
|
|
|
void UBTGAdaptableText::keyReleaseEvent(QKeyEvent* e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QTextEdit::keyReleaseEvent(e); |
|
|
|
QTextEdit::keyReleaseEvent(e); |
|
|
|
|
|
|
|
|
|
|
|
if(toPlainText().isEmpty()){ |
|
|
|
|
|
|
|
setTextColor(QColor(Qt::lightGray)); |
|
|
|
|
|
|
|
setPlainText(mPlaceHolderText); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(mMaximumLength && toPlainText().length()>mMaximumLength){ |
|
|
|
if(mMaximumLength && toPlainText().length()>mMaximumLength){ |
|
|
|
setPlainText(toPlainText().left(mMaximumLength)); |
|
|
|
setPlainText(toPlainText().left(mMaximumLength)); |
|
|
|
QTextCursor tc(document()); |
|
|
|
QTextCursor tc(document()); |
|
|
@ -183,8 +163,10 @@ 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()) |
|
|
|
if(!mIsUpdatingSize && mHasPlaceHolder && toPlainText().isEmpty()){ |
|
|
|
setPlainText(mPlaceHolderText); |
|
|
|
setTextColor(QColor(Qt::lightGray)); |
|
|
|
|
|
|
|
setPlainText(mPlaceHolderText); |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
// If the teacherguide is collapsed, don't updated the size. Or set the size as the expanded size
|
|
|
|
// If the teacherguide is collapsed, don't updated the size. Or set the size as the expanded size
|
|
|
|
onTextChanged(); |
|
|
|
onTextChanged(); |
|
|
@ -201,9 +183,7 @@ QString UBTGAdaptableText::text() |
|
|
|
|
|
|
|
|
|
|
|
void UBTGAdaptableText::onTextChanged() |
|
|
|
void UBTGAdaptableText::onTextChanged() |
|
|
|
{ |
|
|
|
{ |
|
|
|
//qDebug() << ">> onTextChanged CALLED!";
|
|
|
|
|
|
|
|
qreal documentSize = document()->size().height(); |
|
|
|
qreal documentSize = document()->size().height(); |
|
|
|
//qDebug() << ">> documentSize: " << documentSize << ", height: " << height();
|
|
|
|
|
|
|
|
if(height() == documentSize + mBottomMargin){ |
|
|
|
if(height() == documentSize + mBottomMargin){ |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -248,6 +228,28 @@ void UBTGAdaptableText::bottomMargin(int newValue) |
|
|
|
onTextChanged(); |
|
|
|
onTextChanged(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBTGAdaptableText::focusInEvent(QFocusEvent* e){ |
|
|
|
|
|
|
|
if(isReadOnly()){ |
|
|
|
|
|
|
|
e->ignore(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
managePlaceholder(); |
|
|
|
|
|
|
|
QTextEdit::focusInEvent(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBTGAdaptableText::focusOutEvent(QFocusEvent* e){ |
|
|
|
|
|
|
|
if(toPlainText().isEmpty()){ |
|
|
|
|
|
|
|
setTextColor(QColor(Qt::lightGray)); |
|
|
|
|
|
|
|
setPlainText(mPlaceHolderText); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
QTextEdit::focusOutEvent(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBTGAdaptableText::managePlaceholder(){ |
|
|
|
|
|
|
|
if(toPlainText() == mPlaceHolderText){ |
|
|
|
|
|
|
|
setTextColor(QColor(Qt::black)); |
|
|
|
|
|
|
|
setPlainText(""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
/***************************************************************************
|
|
|
|
* class UBTGDraggableWeb * |
|
|
|
* class UBTGDraggableWeb * |
|
|
|