44
44
#include < QSettings>
45
45
#include < QToolButton>
46
46
#include < QMenu>
47
+ #include < QSvgWidget>
47
48
48
49
int QgsAttributeForm::sFormCounter = 0 ;
49
50
@@ -185,20 +186,20 @@ void QgsAttributeForm::setMode( QgsAttributeForm::Mode mode )
185
186
case QgsAttributeForm::SingleEditMode:
186
187
setFeature ( mFeature );
187
188
mSearchButtonBox ->setVisible ( false );
188
- mInvalidConstraintMessage ->show ();
189
+ mTopMessageWidget ->show ();
189
190
break ;
190
191
191
192
case QgsAttributeForm::AddFeatureMode:
192
193
synchronizeEnabledState ();
193
194
mSearchButtonBox ->setVisible ( false );
194
- mInvalidConstraintMessage ->show ();
195
+ mTopMessageWidget ->show ();
195
196
break ;
196
197
197
198
case QgsAttributeForm::MultiEditMode:
198
199
resetMultiEdit ( false );
199
200
synchronizeEnabledState ();
200
201
mSearchButtonBox ->setVisible ( false );
201
- mInvalidConstraintMessage ->show ();
202
+ mTopMessageWidget ->show ();
202
203
break ;
203
204
204
205
case QgsAttributeForm::SearchMode:
@@ -211,7 +212,7 @@ void QgsAttributeForm::setMode( QgsAttributeForm::Mode mode )
211
212
}
212
213
else
213
214
{
214
- mInvalidConstraintMessage ->hide ();
215
+ mTopMessageWidget ->hide ();
215
216
}
216
217
break ;
217
218
}
@@ -792,9 +793,8 @@ bool QgsAttributeForm::currentFormFeature( QgsFeature &feature )
792
793
793
794
void QgsAttributeForm::clearInvalidConstraintsMessage ()
794
795
{
795
- mInvalidConstraintMessage ->hide ();
796
+ mTopMessageWidget ->hide ();
796
797
mInvalidConstraintMessage ->clear ();
797
- mInvalidConstraintMessage ->setStyleSheet ( QString () );
798
798
}
799
799
800
800
void QgsAttributeForm::displayInvalidConstraintMessage ( const QStringList& f,
@@ -809,14 +809,10 @@ void QgsAttributeForm::displayInvalidConstraintMessage( const QStringList& f,
809
809
for ( int i = 0 ; i < size; i++ )
810
810
descriptions += QString ( " <li>%1: <i>%2</i></li>" ).arg ( f[i] ).arg ( d[i] );
811
811
812
- QString icPath = QgsApplication::iconPath ( " /mIconWarning.svg " ) ;
812
+ QString msg = QString ( " <b>%1</b><ul>%2</ul> " ). arg ( tr ( " Invalid fields " ) ). arg ( descriptions ) ;
813
813
814
- QString title = QString ( " <img src=\" %1\" > <b>%2:" ).arg ( icPath ).arg ( tr ( " Invalid fields" ) );
815
- QString msg = QString ( " %1</b><ul>%2</ul>" ).arg ( title ).arg ( descriptions ) ;
816
-
817
- mInvalidConstraintMessage ->show ();
818
814
mInvalidConstraintMessage ->setText ( msg );
819
- mInvalidConstraintMessage -> setStyleSheet ( " QLabel { background-color : #ffc800; } " );
815
+ mTopMessageWidget -> show ( );
820
816
}
821
817
822
818
void QgsAttributeForm::registerContainerInformation ( QgsAttributeForm::ContainerInformation* info )
@@ -1070,9 +1066,18 @@ void QgsAttributeForm::init()
1070
1066
mMessageBar ->setSizePolicy ( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
1071
1067
vl->addWidget ( mMessageBar );
1072
1068
1069
+ mTopMessageWidget = new QWidget ();
1070
+ mTopMessageWidget ->hide ();
1071
+ mTopMessageWidget ->setLayout ( new QHBoxLayout () );
1072
+
1073
+ QSvgWidget* warningIcon = new QSvgWidget ( QgsApplication::iconPath ( " /mIconWarning.svg" ) );
1074
+ warningIcon->setFixedSize ( 48 , 48 );
1075
+ mTopMessageWidget ->layout ()->addWidget ( warningIcon );
1073
1076
mInvalidConstraintMessage = new QLabel ( this );
1074
- mInvalidConstraintMessage ->hide ();
1075
- vl->addWidget ( mInvalidConstraintMessage );
1077
+ mTopMessageWidget ->layout ()->addWidget ( mInvalidConstraintMessage );
1078
+ mTopMessageWidget ->hide ();
1079
+
1080
+ vl->addWidget ( mTopMessageWidget );
1076
1081
1077
1082
setLayout ( vl );
1078
1083
0 commit comments