@ -163,7 +163,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 ( ) ) {
if ( ! mIsUpdatingSize & & mHasPlaceHolder & & toPlainText ( ) . isEmpty ( ) & & ! isReadOnly ( ) ) {
setTextColor ( QColor ( Qt : : lightGray ) ) ;
setTextColor ( QColor ( Qt : : lightGray ) ) ;
setPlainText ( mPlaceHolderText ) ;
setPlainText ( mPlaceHolderText ) ;
}
}
@ -204,8 +204,6 @@ void UBTGAdaptableText::onTextChanged()
setFocus ( ) ;
setFocus ( ) ;
}
}
mIsUpdatingSize = false ;
mIsUpdatingSize = false ;
}
}
void UBTGAdaptableText : : setInitialText ( const QString & text )
void UBTGAdaptableText : : setInitialText ( const QString & text )
@ -232,23 +230,27 @@ void UBTGAdaptableText::focusInEvent(QFocusEvent* e){
if ( isReadOnly ( ) ) {
if ( isReadOnly ( ) ) {
e - > ignore ( ) ;
e - > ignore ( ) ;
}
}
managePlaceholder ( ) ;
managePlaceholder ( true ) ;
QTextEdit : : focusInEvent ( e ) ;
QTextEdit : : focusInEvent ( e ) ;
}
}
void UBTGAdaptableText : : focusOutEvent ( QFocusEvent * e ) {
void UBTGAdaptableText : : focusOutEvent ( QFocusEvent * e ) {
if ( toPlainText ( ) . isEmpty ( ) ) {
managePlaceholder ( false ) ;
setTextColor ( QColor ( Qt : : lightGray ) ) ;
setPlainText ( mPlaceHolderText ) ;
}
QTextEdit : : focusOutEvent ( e ) ;
QTextEdit : : focusOutEvent ( e ) ;
}
}
void UBTGAdaptableText : : managePlaceholder ( ) {
void UBTGAdaptableText : : managePlaceholder ( bool focus ) {
if ( focus ) {
if ( toPlainText ( ) = = mPlaceHolderText ) {
if ( toPlainText ( ) = = mPlaceHolderText ) {
setTextColor ( QColor ( Qt : : black ) ) ;
setTextColor ( QColor ( Qt : : black ) ) ;
setPlainText ( " " ) ;
setPlainText ( " " ) ;
}
}
} else {
if ( toPlainText ( ) . isEmpty ( ) ) {
setTextColor ( QColor ( Qt : : lightGray ) ) ;
setPlainText ( mPlaceHolderText ) ;
}
}
}
}
/***************************************************************************
/***************************************************************************